llvm.org GIT mirror llvm / 44b2c50
memory inputs to an inline asm are required to have an address available. If the operand is not already an indirect operand, spill it to a constant pool entry or a stack slot. This fixes PR1356 and CodeGen/X86/2007-04-27-InlineAsm-IntMemInput.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36536 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
2 changed file(s) with 34 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
31223122 // slots and always reusing the same one. We currently always create
31233123 // new ones, as reuse may inhibit scheduling.
31243124 const Type *Ty = MVT::getTypeForValueType(ExtraVT);
3125 unsigned TySize = (unsigned)TLI.getTargetData()->getTypeSize(Ty);
3125 uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
31263126 unsigned Align = TLI.getTargetData()->getPrefTypeAlignment(Ty);
31273127 MachineFunction &MF = DAG.getMachineFunction();
31283128 int SSFI =
3129 MF.getFrameInfo()->CreateStackObject((unsigned)TySize, Align);
3129 MF.getFrameInfo()->CreateStackObject(TySize, Align);
31303130 SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy());
31313131 Result = DAG.getTruncStore(DAG.getEntryNode(), Node->getOperand(0),
31323132 StackSlot, NULL, 0, ExtraVT);
33963396 CTy = TLI.getConstraintType(ConstraintCode);
33973397
33983398 if (CTy == TargetLowering::C_Other) {
3399 assert(!Constraints[i].isIndirect &&
3400 "Don't know how to handle indirect other inputs yet!");
3401
33993402 InOperandVal = TLI.isOperandValidForConstraint(InOperandVal,
34003403 ConstraintCode[0], DAG);
34013404 if (!InOperandVal.Val) {
34103413 AsmNodeOperands.push_back(InOperandVal);
34113414 break;
34123415 } else if (CTy == TargetLowering::C_Memory) {
3413 // Memory input.
3414
3415 // If the operand is a float, spill to a constant pool entry to get its
3416 // address.
3417 if (ConstantFP *Val = dyn_cast(I.getOperand(OpNum-1)))
3418 InOperandVal = DAG.getConstantPool(Val, TLI.getPointerTy());
3419
3420 if (!MVT::isInteger(InOperandVal.getValueType())) {
3421 cerr << "Match failed, cannot handle this yet!\n";
3422 InOperandVal.Val->dump();
3423 exit(1);
3416 // Memory input. Memory operands really want the address of the value,
3417 // so we want an indirect input. If we don't have an indirect input,
3418 // spill the value somewhere if we can, otherwise spill it to a stack
3419 // slot.
3420 if (!Constraints[i].isIndirect) {
3421 // If the operand is a float, integer, or vector constant, spill to a
3422 // constant pool entry to get its address.
3423 Value *OpVal = I.getOperand(OpNum-1);
3424 if (isa(OpVal) || isa(OpVal) ||
3425 isa(OpVal)) {
3426 InOperandVal = DAG.getConstantPool(cast(OpVal),
3427 TLI.getPointerTy());
3428 } else {
3429 // Otherwise, create a stack slot and emit a store to it before the
3430 // asm.
3431 const Type *Ty = OpVal->getType();
3432 uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
3433 unsigned Align = TLI.getTargetData()->getPrefTypeAlignment(Ty);
3434 MachineFunction &MF = DAG.getMachineFunction();
3435 int SSFI = MF.getFrameInfo()->CreateStackObject(TySize, Align);
3436 SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy());
3437 Chain = DAG.getStore(Chain, InOperandVal, StackSlot, NULL, 0);
3438 InOperandVal = StackSlot;
3439 }
34243440 }
34253441
3426 // Extend/truncate to the right pointer type if needed.
3427 MVT::ValueType PtrType = TLI.getPointerTy();
3428 if (InOperandVal.getValueType() < PtrType)
3429 InOperandVal = DAG.getNode(ISD::ZERO_EXTEND, PtrType, InOperandVal);
3430 else if (InOperandVal.getValueType() > PtrType)
3431 InOperandVal = DAG.getNode(ISD::TRUNCATE, PtrType, InOperandVal);
3432
3442 assert(InOperandVal.getValueType() == TLI.getPointerTy() &&
3443 "Memory operands expect pointer values");
3444
34333445 // Add information to the INLINEASM node to know about this input.
34343446 unsigned ResOpType = 4/*MEM*/ | (1 << 3);
34353447 AsmNodeOperands.push_back(DAG.getConstant(ResOpType, MVT::i32));
34383450 }
34393451
34403452 assert(CTy == TargetLowering::C_RegisterClass && "Unknown op type!");
3453 assert(!Constraints[i].isIndirect &&
3454 "Don't know how to handle indirect register inputs yet!");
34413455
34423456 // Copy the input into the appropriate registers.
34433457 RegsForValue InRegs =