llvm.org GIT mirror llvm / 09e4b7e
memory operands that have a direct operand should have their stores created before the copies into physregs are done. This avoids having flag operands skip the store, causing cycles in the dag at sched time. This fixes infinite loops on these tests: test/CodeGen/Generic/2007-04-08-MultipleFrameIndices.ll for PR1308 test/CodeGen/PowerPC/2007-01-29-lbrx-asm.ll test/CodeGen/PowerPC/2007-01-31-InlineAsmAddrMode.ll test/CodeGen/X86/2006-07-12-InlineAsmQConstraint.ll for PR828 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36547 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
1 changed file(s) with 42 addition(s) and 35 deletion(s). Raw diff Collapse all Expand all
32643264 // FIXME: merge this into GetMostGeneralConstraint.
32653265 OpInfo.ConstraintType = TLI.getConstraintType(OpInfo.ConstraintCode);
32663266
3267
3268 // If this is a memory input, and if the operand is not indirect, do what we
3269 // need to to provide an address for the memory input.
3270 if (OpInfo.ConstraintType == TargetLowering::C_Memory &&
3271 !OpInfo.isIndirect) {
3272 assert(OpInfo.Type == InlineAsm::isInput &&
3273 "Can only indirectify direct input operands!");
3274
3275 // Memory operands really want the address of the value. If we don't have
3276 // an indirect input, put it in the constpool if we can, otherwise spill
3277 // it to a stack slot.
3278
3279 // If the operand is a float, integer, or vector constant, spill to a
3280 // constant pool entry to get its address.
3281 Value *OpVal = OpInfo.CallOperandVal;
3282 if (isa(OpVal) || isa(OpVal) ||
3283 isa(OpVal)) {
3284 OpInfo.CallOperand = DAG.getConstantPool(cast(OpVal),
3285 TLI.getPointerTy());
3286 } else {
3287 // Otherwise, create a stack slot and emit a store to it before the
3288 // asm.
3289 const Type *Ty = OpVal->getType();
3290 uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
3291 unsigned Align = TLI.getTargetData()->getPrefTypeAlignment(Ty);
3292 MachineFunction &MF = DAG.getMachineFunction();
3293 int SSFI = MF.getFrameInfo()->CreateStackObject(TySize, Align);
3294 SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy());
3295 Chain = DAG.getStore(Chain, OpInfo.CallOperand, StackSlot, NULL, 0);
3296 OpInfo.CallOperand = StackSlot;
3297 }
3298
3299 // There is no longer a Value* corresponding to this operand.
3300 OpInfo.CallOperandVal = 0;
3301 // It is now an indirect operand.
3302 OpInfo.isIndirect = true;
3303 }
3304
3305
32673306 if (TLI.getRegForInlineAsmConstraint(OpInfo.ConstraintCode, OpVT).first ==0)
32683307 continue; // Not assigned a fixed reg.
32693308
33223361 if (OpInfo.ConstraintType != TargetLowering::C_RegisterClass &&
33233362 OpInfo.ConstraintType != TargetLowering::C_Register) {
33243363 // Memory output, or 'other' output (e.g. 'X' constraint).
3325 SDOperand InOperandVal = OpInfo.CallOperand;
3326
3327 // Check that the operand (the address to store to) isn't a float.
3328 if (!MVT::isInteger(InOperandVal.getValueType()))
3329 assert(0 && "MATCH FAIL!");
3330
3331 if (!OpInfo.isIndirect)
3332 assert(0 && "MATCH FAIL!");
3364 assert(OpInfo.isIndirect && "Memory output must be indirect operand");
33333365
33343366 // Add information to the INLINEASM node to know about this output.
33353367 unsigned ResOpType = 4/*MEM*/ | (1 << 3);
33363368 AsmNodeOperands.push_back(DAG.getConstant(ResOpType, MVT::i32));
3337 AsmNodeOperands.push_back(InOperandVal);
3369 AsmNodeOperands.push_back(OpInfo.CallOperand);
33383370 break;
33393371 }
33403372
34393471 AsmNodeOperands.push_back(InOperandVal);
34403472 break;
34413473 } else if (OpInfo.ConstraintType == TargetLowering::C_Memory) {
3442 // Memory input. Memory operands really want the address of the value,
3443 // so we want an indirect input. If we don't have an indirect input,
3444 // spill the value somewhere if we can, otherwise spill it to a stack
3445 // slot.
3446 if (!OpInfo.isIndirect) {
3447 // If the operand is a float, integer, or vector constant, spill to a
3448 // constant pool entry to get its address.
3449 Value *OpVal = OpInfo.CallOperandVal;
3450 if (isa(OpVal) || isa(OpVal) ||
3451 isa(OpVal)) {
3452 InOperandVal = DAG.getConstantPool(cast(OpVal),
3453 TLI.getPointerTy());
3454 } else {
3455 // Otherwise, create a stack slot and emit a store to it before the
3456 // asm.
3457 const Type *Ty = OpVal->getType();
3458 uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
3459 unsigned Align = TLI.getTargetData()->getPrefTypeAlignment(Ty);
3460 MachineFunction &MF = DAG.getMachineFunction();
3461 int SSFI = MF.getFrameInfo()->CreateStackObject(TySize, Align);
3462 SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy());
3463 Chain = DAG.getStore(Chain, InOperandVal, StackSlot, NULL, 0);
3464 InOperandVal = StackSlot;
3465 }
3466 }
3467
3474 assert(OpInfo.isIndirect && "Operand must be indirect to be a mem!");
34683475 assert(InOperandVal.getValueType() == TLI.getPointerTy() &&
34693476 "Memory operands expect pointer values");
34703477