diff options
author | Chris Lattner <sabre@nondot.org> | 2006-02-24 01:11:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-02-24 01:11:24 +0000 |
commit | 87bc3bd1213ced06eade93e3267178198d41a381 (patch) | |
tree | 35aecd293f22d103f8db5fd07d5f177e416ac279 /lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | |
parent | 2b7401e28e0c3c18ef027345560f9ce5abeef4d2 (diff) |
Lower C_Memory operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26346 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 69 |
1 files changed, 44 insertions, 25 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 2028332f2f..aa8bbee3dd 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -1549,36 +1549,55 @@ void SelectionDAGLowering::visitInlineAsm(CallInst &I) { // Use the produced MatchedRegs object to MatchedRegs.getCopyToRegs(InOperandVal, DAG, Chain, Flag); MatchedRegs.AddInlineAsmOperands(1 /*REGUSE*/, DAG, AsmNodeOperands); - } else { - TargetLowering::ConstraintType CTy = TargetLowering::C_RegisterClass; - if (ConstraintCode.size() == 1) // not a physreg name. - CTy = TLI.getConstraintType(ConstraintCode[0]); + break; + } + + TargetLowering::ConstraintType CTy = TargetLowering::C_RegisterClass; + if (ConstraintCode.size() == 1) // not a physreg name. + CTy = TLI.getConstraintType(ConstraintCode[0]); - if (CTy == TargetLowering::C_Other) { - if (!TLI.isOperandValidForConstraint(InOperandVal, ConstraintCode[0])) - assert(0 && "MATCH FAIL!"); - - // Add information to the INLINEASM node to know about this input. - unsigned ResOpType = 3 /*imm*/ | (1 << 3); - AsmNodeOperands.push_back(DAG.getConstant(ResOpType, MVT::i32)); - AsmNodeOperands.push_back(InOperandVal); - break; - } + if (CTy == TargetLowering::C_Other) { + if (!TLI.isOperandValidForConstraint(InOperandVal, ConstraintCode[0])) + assert(0 && "MATCH FAIL!"); - assert(CTy == TargetLowering::C_RegisterClass && "Unknown op type!"); - - // Copy the input into the appropriate registers. - RegsForValue InRegs = - GetRegistersForValue(ConstraintCode, ConstraintVTs[i], - false, true, OutputRegs, InputRegs); - // FIXME: should be match fail. - assert(!InRegs.Regs.empty() && "Couldn't allocate input reg!"); - - InRegs.getCopyToRegs(InOperandVal, DAG, Chain, Flag); + // Add information to the INLINEASM node to know about this input. + unsigned ResOpType = 3 /*IMM*/ | (1 << 3); + AsmNodeOperands.push_back(DAG.getConstant(ResOpType, MVT::i32)); + AsmNodeOperands.push_back(InOperandVal); + break; + } else if (CTy == TargetLowering::C_Memory) { + // Memory input. + + // Check that the operand isn't a float. + if (!MVT::isInteger(InOperandVal.getValueType())) + assert(0 && "MATCH FAIL!"); - InRegs.AddInlineAsmOperands(1/*REGUSE*/, DAG, AsmNodeOperands); + // Extend/truncate to the right pointer type if needed. + MVT::ValueType PtrType = TLI.getPointerTy(); + if (InOperandVal.getValueType() < PtrType) + InOperandVal = DAG.getNode(ISD::ZERO_EXTEND, PtrType, InOperandVal); + else if (InOperandVal.getValueType() > PtrType) + InOperandVal = DAG.getNode(ISD::TRUNCATE, PtrType, InOperandVal); + + // Add information to the INLINEASM node to know about this input. + unsigned ResOpType = 4/*MEM*/ | (1 << 3); + AsmNodeOperands.push_back(DAG.getConstant(ResOpType, MVT::i32)); + AsmNodeOperands.push_back(InOperandVal); break; } + + assert(CTy == TargetLowering::C_RegisterClass && "Unknown op type!"); + + // Copy the input into the appropriate registers. + RegsForValue InRegs = + GetRegistersForValue(ConstraintCode, ConstraintVTs[i], + false, true, OutputRegs, InputRegs); + // FIXME: should be match fail. + assert(!InRegs.Regs.empty() && "Couldn't allocate input reg!"); + + InRegs.getCopyToRegs(InOperandVal, DAG, Chain, Flag); + + InRegs.AddInlineAsmOperands(1/*REGUSE*/, DAG, AsmNodeOperands); break; } case InlineAsm::isClobber: { |