From: Chris Lattner Date: Wed, 28 Feb 2007 07:00:42 +0000 (+0000) Subject: make use of helper functions in CCState for analyzing formals and calls. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=638402b2539f2f28ab22eebf27e8309acaff405d;p=oota-llvm.git make use of helper functions in CCState for analyzing formals and calls. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34737 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 980d465c28b..87625a19682 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -609,17 +609,12 @@ SDOperand X86TargetLowering::LowerCCCArguments(SDOperand Op, SelectionDAG &DAG, SDOperand Root = Op.getOperand(0); bool isVarArg = cast(Op.getOperand(2))->getValue() != 0; + // Assign locations to all of the incoming arguments. SmallVector ArgLocs; CCState CCInfo(MF.getFunction()->getCallingConv(), getTargetMachine(), ArgLocs); - - for (unsigned i = 0; i != NumArgs; ++i) { - MVT::ValueType ArgVT = Op.getValue(i).getValueType(); - unsigned ArgFlags = cast(Op.getOperand(3+i))->getValue(); - if (CC_X86_32_C(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, CCInfo)) - assert(0 && "Unhandled argument type!"); - } - + CCInfo.AnalyzeFormalArguments(Op.Val, CC_X86_32_C); + SmallVector ArgValues; unsigned LastVal = ~0U; for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) { @@ -708,15 +703,10 @@ SDOperand X86TargetLowering::LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, SDOperand Callee = Op.getOperand(4); unsigned NumOps = (Op.getNumOperands() - 5) / 2; + // Analyze operands of the call, assigning locations to each operand. SmallVector ArgLocs; CCState CCInfo(CC, getTargetMachine(), ArgLocs); - - for (unsigned i = 0; i != NumOps; ++i) { - MVT::ValueType ArgVT = Op.getOperand(5+2*i).getValueType(); - unsigned ArgFlags =cast(Op.getOperand(5+2*i+1))->getValue(); - if (CC_X86_32_C(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, CCInfo)) - assert(0 && "Unhandled argument type!"); - } + CCInfo.AnalyzeCallOperands(Op.Val, CC_X86_32_C); // Get a count of how many bytes are to be pushed on the stack. unsigned NumBytes = CCInfo.getNextStackOffset(); @@ -865,21 +855,15 @@ SDOperand X86TargetLowering::LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, // reasons. SDOperand X86TargetLowering::LowerFastCCArguments(SDOperand Op, SelectionDAG &DAG) { - unsigned NumArgs = Op.Val->getNumValues()-1; MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo *MFI = MF.getFrameInfo(); SDOperand Root = Op.getOperand(0); + // Assign locations to all of the incoming arguments. SmallVector ArgLocs; CCState CCInfo(MF.getFunction()->getCallingConv(), getTargetMachine(), ArgLocs); - - for (unsigned i = 0; i != NumArgs; ++i) { - MVT::ValueType ArgVT = Op.getValue(i).getValueType(); - unsigned ArgFlags = cast(Op.getOperand(3+i))->getValue(); - if (CC_X86_32_FastCall(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags,CCInfo)) - assert(0 && "Unhandled argument type!"); - } + CCInfo.AnalyzeFormalArguments(Op.Val, CC_X86_32_FastCall); SmallVector ArgValues; unsigned LastVal = ~0U; @@ -956,18 +940,11 @@ SDOperand X86TargetLowering::LowerFastCCCallTo(SDOperand Op, SelectionDAG &DAG, SDOperand Chain = Op.getOperand(0); bool isTailCall = cast(Op.getOperand(3))->getValue() != 0; SDOperand Callee = Op.getOperand(4); - unsigned NumOps = (Op.getNumOperands() - 5) / 2; - + // Analyze operands of the call, assigning locations to each operand. SmallVector ArgLocs; CCState CCInfo(CC, getTargetMachine(), ArgLocs); - - for (unsigned i = 0; i != NumOps; ++i) { - MVT::ValueType ArgVT = Op.getOperand(5+2*i).getValueType(); - unsigned ArgFlags =cast(Op.getOperand(5+2*i+1))->getValue(); - if (CC_X86_32_C(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, CCInfo)) - assert(0 && "Unhandled argument type!"); - } + CCInfo.AnalyzeCallOperands(Op.Val, CC_X86_32_FastCall); // Get a count of how many bytes are to be pushed on the stack. unsigned NumBytes = CCInfo.getNextStackOffset(); @@ -1098,7 +1075,6 @@ SDOperand X86TargetLowering::LowerFastCCCallTo(SDOperand Op, SelectionDAG &DAG, SDOperand X86TargetLowering::LowerX86_64CCCArguments(SDOperand Op, SelectionDAG &DAG) { - unsigned NumArgs = Op.Val->getNumValues() - 1; MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo *MFI = MF.getFrameInfo(); SDOperand Root = Op.getOperand(0); @@ -1112,16 +1088,12 @@ X86TargetLowering::LowerX86_64CCCArguments(SDOperand Op, SelectionDAG &DAG) { X86::XMM4, X86::XMM5, X86::XMM6, X86::XMM7 }; + + // Assign locations to all of the incoming arguments. SmallVector ArgLocs; CCState CCInfo(MF.getFunction()->getCallingConv(), getTargetMachine(), ArgLocs); - - for (unsigned i = 0; i != NumArgs; ++i) { - MVT::ValueType ArgVT = Op.getValue(i).getValueType(); - unsigned ArgFlags = cast(Op.getOperand(3+i))->getValue(); - if (CC_X86_64_C(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, CCInfo)) - assert(0 && "Unhandled argument type!"); - } + CCInfo.AnalyzeFormalArguments(Op.Val, CC_X86_64_C); SmallVector ArgValues; unsigned LastVal = ~0U; @@ -1243,17 +1215,11 @@ X86TargetLowering::LowerX86_64CCCCallTo(SDOperand Op, SelectionDAG &DAG, bool isVarArg = cast(Op.getOperand(2))->getValue() != 0; bool isTailCall = cast(Op.getOperand(3))->getValue() != 0; SDOperand Callee = Op.getOperand(4); - unsigned NumOps = (Op.getNumOperands() - 5) / 2; - + + // Analyze operands of the call, assigning locations to each operand. SmallVector ArgLocs; CCState CCInfo(CC, getTargetMachine(), ArgLocs); - - for (unsigned i = 0; i != NumOps; ++i) { - MVT::ValueType ArgVT = Op.getOperand(5+2*i).getValueType(); - unsigned ArgFlags =cast(Op.getOperand(5+2*i+1))->getValue(); - if (CC_X86_64_C(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, CCInfo)) - assert(0 && "Unhandled argument type!"); - } + CCInfo.AnalyzeCallOperands(Op.Val, CC_X86_64_C); // Get a count of how many bytes are to be pushed on the stack. unsigned NumBytes = CCInfo.getNextStackOffset();