llvm.org GIT mirror llvm / 86098bd
Add "inreg" field to CallSDNode (doesn't increase its size). Adjust various lowering functions to pass this info through from CallInst. Use it to implement sseregparm returns on X86. Remove X86_ssecall calling convention. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56677 91177308-0d34-0410-b5e6-96231b3b80d8 Dale Johannesen 11 years ago
20 changed file(s) with 51 addition(s) and 58 deletion(s). Raw diff Collapse all Expand all
5656 /// X86_FastCall - 'fast' analog of X86_StdCall. Passes first two arguments
5757 /// in ECX:EDX registers, others - via stack. Callee is responsible for
5858 /// stack cleaning.
59 X86_FastCall = 65,
60
61 /// X86_SSEreg - The standard convention except that float and double
62 /// values are returned in XMM0 if SSE support is available.
63 X86_SSECall = 66
59 X86_FastCall = 65
6460 };
6561 } // End CallingConv namespace
6662
466466 /// getCall - Create a CALL node from the given information.
467467 ///
468468 SDValue getCall(unsigned CallingConv, bool IsVarArgs, bool IsTailCall,
469 SDVTList VTs, const SDValue *Operands, unsigned NumOperands);
469 bool isInreg, SDVTList VTs, const SDValue *Operands,
470 unsigned NumOperands);
470471
471472 /// getLoad - Loads are not normal binary operators: their result type is not
472473 /// determined by their operands, and they produce a value AND a token chain.
21902190 unsigned CallingConv;
21912191 bool IsVarArg;
21922192 bool IsTailCall;
2193 // We might eventually want a full-blown Attributes for the result; that
2194 // will expand the size of the representation. At the moment we only
2195 // need Inreg.
2196 bool Inreg;
21932197 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
21942198 protected:
21952199 friend class SelectionDAG;
2196 CallSDNode(unsigned cc, bool isvararg, bool istailcall,
2200 CallSDNode(unsigned cc, bool isvararg, bool istailcall, bool isinreg,
21972201 SDVTList VTs, const SDValue *Operands, unsigned numOperands)
21982202 : SDNode(ISD::CALL, VTs, Operands, numOperands),
2199 CallingConv(cc), IsVarArg(isvararg), IsTailCall(istailcall) {}
2203 CallingConv(cc), IsVarArg(isvararg), IsTailCall(istailcall),
2204 Inreg(isinreg) {}
22002205 public:
22012206 unsigned getCallingConv() const { return CallingConv; }
22022207 unsigned isVarArg() const { return IsVarArg; }
22032208 unsigned isTailCall() const { return IsTailCall; }
2209 unsigned isInreg() const { return Inreg; }
22042210
22052211 /// Set this call to not be marked as a tail call. Normally setter
22062212 /// methods in SDNodes are unsafe because it breaks the CSE map,
993993 typedef std::vector ArgListTy;
994994 virtual std::pair
995995 LowerCallTo(SDValue Chain, const Type *RetTy, bool RetSExt, bool RetZExt,
996 bool isVarArg, unsigned CallingConv, bool isTailCall,
997 SDValue Callee, ArgListTy &Args, SelectionDAG &DAG);
998
996 bool isVarArg, bool isInreg, unsigned CallingConv,
997 bool isTailCall, SDValue Callee, ArgListTy &Args,
998 SelectionDAG &DAG);
999999
10001000 /// EmitTargetCodeForMemcpy - Emit target-specific code that performs a
10011001 /// memcpy. This can be used by targets to provide code sequences for cases
482482 KEYWORD("coldcc", COLDCC_TOK);
483483 KEYWORD("x86_stdcallcc", X86_STDCALLCC_TOK);
484484 KEYWORD("x86_fastcallcc", X86_FASTCALLCC_TOK);
485 KEYWORD("x86_ssecallcc", X86_SSECALLCC_TOK);
486485
487486 KEYWORD("signext", SIGNEXT);
488487 KEYWORD("zeroext", ZEROEXT);
10841084 %token OPAQUE EXTERNAL TARGET TRIPLE ALIGN ADDRSPACE
10851085 %token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT
10861086 %token CC_TOK CCC_TOK FASTCC_TOK COLDCC_TOK X86_STDCALLCC_TOK X86_FASTCALLCC_TOK
1087 %token X86_SSECALLCC_TOK
10881087 %token DATALAYOUT
10891088 %type OptCallingConv LocalNumber
10901089 %type OptAttributes Attribute
12511250 COLDCC_TOK { $$ = CallingConv::Cold; } |
12521251 X86_STDCALLCC_TOK { $$ = CallingConv::X86_StdCall; } |
12531252 X86_FASTCALLCC_TOK { $$ = CallingConv::X86_FastCall; } |
1254 X86_SSECALLCC_TOK { $$ = CallingConv::X86_SSECall; } |
12551253 CC_TOK EUINT64VAL {
12561254 if ((unsigned)$2 != $2)
12571255 GEN_ERROR("Calling conv too large");
125125 void CCState::AnalyzeCallResult(CallSDNode *TheCall, CCAssignFn Fn) {
126126 for (unsigned i = 0, e = TheCall->getNumRetVals(); i != e; ++i) {
127127 MVT VT = TheCall->getRetValType(i);
128 if (Fn(i, VT, VT, CCValAssign::Full, ISD::ArgFlagsTy(), *this)) {
128 ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy();
129 if (TheCall->isInreg())
130 Flags.setInReg();
131 if (Fn(i, VT, VT, CCValAssign::Full, Flags, *this)) {
129132 cerr << "Call result #" << i << " has unhandled type "
130133 << VT.getMVTString() << "\n";
131134 abort();
39783978 TargetLowering::ArgListTy Args;
39793979 std::pair CallResult =
39803980 TLI.LowerCallTo(Tmp1, Type::VoidTy,
3981 false, false, false, CallingConv::C, false,
3981 false, false, false, false, CallingConv::C, false,
39823982 DAG.getExternalSymbol("abort", TLI.getPointerTy()),
39833983 Args, DAG);
39843984 Result = CallResult.second;
53015301 // Splice the libcall in wherever FindInputOutputChains tells us to.
53025302 const Type *RetTy = Node->getValueType(0).getTypeForMVT();
53035303 std::pair CallInfo =
5304 TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, CallingConv::C,
5305 false, Callee, Args, DAG);
5304 TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false,
5305 CallingConv::C, false, Callee, Args, DAG);
53065306
53075307 // Legalize the call sequence, starting with the chain. This will advance
53085308 // the LastCALLSEQ_END to the legalized version of the CALLSEQ_END node that
628628 const Type *RetTy = RetVT.getTypeForMVT();
629629 std::pair CallInfo =
630630 TLI.LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false,
631 CallingConv::C, false, Callee, Args, DAG);
631 false, CallingConv::C, false, Callee, Args, DAG);
632632 return CallInfo.first;
633633 }
634634
31133113 Entry.Node = Size; Args.push_back(Entry);
31143114 std::pair CallResult =
31153115 TLI.LowerCallTo(Chain, Type::VoidTy,
3116 false, false, false, CallingConv::C, false,
3116 false, false, false, false, CallingConv::C, false,
31173117 getExternalSymbol("memcpy", TLI.getPointerTy()),
31183118 Args, *this);
31193119 return CallResult.second;
31583158 Entry.Node = Size; Args.push_back(Entry);
31593159 std::pair CallResult =
31603160 TLI.LowerCallTo(Chain, Type::VoidTy,
3161 false, false, false, CallingConv::C, false,
3161 false, false, false, false, CallingConv::C, false,
31623162 getExternalSymbol("memmove", TLI.getPointerTy()),
31633163 Args, *this);
31643164 return CallResult.second;
32093209 Args.push_back(Entry);
32103210 std::pair CallResult =
32113211 TLI.LowerCallTo(Chain, Type::VoidTy,
3212 false, false, false, CallingConv::C, false,
3212 false, false, false, false, CallingConv::C, false,
32133213 getExternalSymbol("memset", TLI.getPointerTy()),
32143214 Args, *this);
32153215 return CallResult.second;
33283328
33293329 SDValue
33303330 SelectionDAG::getCall(unsigned CallingConv, bool IsVarArgs, bool IsTailCall,
3331 SDVTList VTs,
3331 bool IsInreg, SDVTList VTs,
33323332 const SDValue *Operands, unsigned NumOperands) {
33333333 // Do not include isTailCall in the folding set profile.
33343334 FoldingSetNodeID ID;
33443344 return SDValue(E, 0);
33453345 }
33463346 SDNode *N = NodeAllocator.Allocate();
3347 new (N) CallSDNode(CallingConv, IsVarArgs, IsTailCall,
3347 new (N) CallSDNode(CallingConv, IsVarArgs, IsTailCall, IsInreg,
33483348 VTs, Operands, NumOperands);
33493349 CSEMap.InsertNode(N, IP);
33503350 AllNodes.push_back(N);
41224122 std::pair Result =
41234123 TLI.LowerCallTo(getRoot(), CS.getType(),
41244124 CS.paramHasAttr(0, Attribute::SExt),
4125 CS.paramHasAttr(0, Attribute::ZExt),
4126 FTy->isVarArg(), CS.getCallingConv(),
4125 CS.paramHasAttr(0, Attribute::ZExt), FTy->isVarArg(),
4126 CS.paramHasAttr(0, Attribute::InReg),
4127 CS.getCallingConv(),
41274128 IsTailCall && PerformTailCallOpt,
41284129 Callee, Args, DAG);
41294130 if (CS.getType() != Type::VoidTy)
50495050 Args.push_back(Entry);
50505051
50515052 std::pair Result =
5052 TLI.LowerCallTo(getRoot(), I.getType(), false, false, false, CallingConv::C,
5053 PerformTailCallOpt, DAG.getExternalSymbol("malloc", IntPtr),
5053 TLI.LowerCallTo(getRoot(), I.getType(), false, false, false, false,
5054 CallingConv::C, PerformTailCallOpt,
5055 DAG.getExternalSymbol("malloc", IntPtr),
50545056 Args, DAG);
50555057 setValue(&I, Result.first); // Pointers always fit in registers
50565058 DAG.setRoot(Result.second);
50645066 Args.push_back(Entry);
50655067 MVT IntPtr = TLI.getPointerTy();
50665068 std::pair Result =
5067 TLI.LowerCallTo(getRoot(), Type::VoidTy, false, false, false,
5069 TLI.LowerCallTo(getRoot(), Type::VoidTy, false, false, false, false,
50685070 CallingConv::C, PerformTailCallOpt,
50695071 DAG.getExternalSymbol("free", IntPtr), Args, DAG);
50705072 DAG.setRoot(Result.second);
52335235 std::pair
52345236 TargetLowering::LowerCallTo(SDValue Chain, const Type *RetTy,
52355237 bool RetSExt, bool RetZExt, bool isVarArg,
5238 bool isInreg,
52365239 unsigned CallingConv, bool isTailCall,
52375240 SDValue Callee,
52385241 ArgListTy &Args, SelectionDAG &DAG) {
53255328 LoweredRetTys.push_back(MVT::Other); // Always has a chain.
53265329
53275330 // Create the CALL node.
5328 SDValue Res = DAG.getCall(CallingConv, isVarArg, isTailCall,
5331 SDValue Res = DAG.getCall(CallingConv, isVarArg, isTailCall, isInreg,
53295332 DAG.getVTList(&LoweredRetTys[0],
53305333 LoweredRetTys.size()),
5331 &Ops[0], Ops.size());
5334 &Ops[0], Ops.size()
5335 );
53325336 Chain = Res.getValue(LoweredRetTys.size() - 1);
53335337
53345338 // Gather up the call result into a single value.
747747 Entry.Ty = (const Type *) Type::Int32Ty;
748748 Args.push_back(Entry);
749749 std::pair CallResult =
750 LowerCallTo(Chain, (const Type *) Type::Int32Ty, false, false, false,
750 LowerCallTo(Chain, (const Type *) Type::Int32Ty, false, false, false, false,
751751 CallingConv::C, false,
752752 DAG.getExternalSymbol("__tls_get_addr", PtrVT), Args, DAG);
753753 return CallResult.first;
317317 std::pair
318318 AlphaTargetLowering::LowerCallTo(SDValue Chain, const Type *RetTy,
319319 bool RetSExt, bool RetZExt, bool isVarArg,
320 unsigned CallingConv, bool isTailCall,
321 SDValue Callee, ArgListTy &Args,
322 SelectionDAG &DAG) {
320 bool isInreg, unsigned CallingConv,
321 bool isTailCall, SDValue Callee,
322 ArgListTy &Args, SelectionDAG &DAG) {
323323 int NumBytes = 0;
324324 if (Args.size() > 6)
325325 NumBytes = (Args.size() - 6) * 8;
8080 /// actual call.
8181 virtual std::pair
8282 LowerCallTo(SDValue Chain, const Type *RetTy, bool RetSExt, bool RetZExt,
83 bool isVarArg, unsigned CC, bool isTailCall, SDValue Callee,
84 ArgListTy &Args, SelectionDAG &DAG);
83 bool isVarArg, bool isInreg, unsigned CC, bool isTailCall,
84 SDValue Callee, ArgListTy &Args, SelectionDAG &DAG);
8585
8686 ConstraintType getConstraintType(const std::string &Constraint) const;
8787
303303
304304 std::pair
305305 IA64TargetLowering::LowerCallTo(SDValue Chain, const Type *RetTy,
306 bool RetSExt, bool RetZExt,
307 bool isVarArg, unsigned CallingConv,
306 bool RetSExt, bool RetZExt, bool isVarArg,
307 bool isInreg, unsigned CallingConv,
308308 bool isTailCall, SDValue Callee,
309309 ArgListTy &Args, SelectionDAG &DAG) {
310310
5959 /// actual call.
6060 virtual std::pair
6161 LowerCallTo(SDValue Chain, const Type *RetTy,
62 bool RetSExt, bool RetZExt, bool isVarArg,
62 bool RetSExt, bool RetZExt, bool isVarArg, bool isInreg,
6363 unsigned CC, bool isTailCall,
6464 SDValue Callee, ArgListTy &Args, SelectionDAG &DAG);
6565
12391239 // Lower to a call to __trampoline_setup(Trmp, TrampSize, FPtr, ctx_reg)
12401240 std::pair CallResult =
12411241 LowerCallTo(Chain, Op.getValueType().getTypeForMVT(), false, false,
1242 false, CallingConv::C, false,
1242 false, false, CallingConv::C, false,
12431243 DAG.getExternalSymbol("__trampoline_setup", PtrVT),
12441244 Args, DAG);
12451245
6464 CCDelegateTo
6565 ]>;
6666
67 // X86-32 SSEregparm return-value convention.
68 def RetCC_X86_32_SSE : CallingConv<[
69 // The X86-32 sseregparm calling convention returns FP values in XMM0 if the
70 // target has SSE2, otherwise it is the C calling convention.
71 CCIfType<[f32], CCIfSubtarget<"hasSSE2()", CCAssignToReg<[XMM0, XMM1]>>>,
72 CCIfType<[f64], CCIfSubtarget<"hasSSE2()", CCAssignToReg<[XMM0, XMM1]>>>,
73 CCDelegateTo
74 ]>;
75
7667 // X86-64 C return-value convention.
7768 def RetCC_X86_64_C : CallingConv<[
7869 // The X86-64 calling convention always returns FP values in XMM0.
10293 def RetCC_X86_32 : CallingConv<[
10394 // If FastCC, use RetCC_X86_32_Fast.
10495 CCIfCC<"CallingConv::Fast", CCDelegateTo>,
105 // If SSECC, use RetCC_X86_32_SSE.
106 CCIfCC<"CallingConv::X86_SSECall", CCDelegateTo>,
10796 // Otherwise, use RetCC_X86_32_C.
10897 CCDelegateTo
10998 ]>;
51565156 Entry.Node = Size;
51575157 Args.push_back(Entry);
51585158 std::pair CallResult =
5159 LowerCallTo(Chain, Type::VoidTy, false, false, false, CallingConv::C,
5160 false, DAG.getExternalSymbol(bzeroEntry, IntPtr),
5161 Args, DAG);
5159 LowerCallTo(Chain, Type::VoidTy, false, false, false, false,
5160 CallingConv::C, false,
5161 DAG.getExternalSymbol(bzeroEntry, IntPtr), Args, DAG);
51625162 return CallResult.second;
51635163 }
51645164
13501350 case CallingConv::Cold: Out << "coldcc "; break;
13511351 case CallingConv::X86_StdCall: Out << "x86_stdcallcc "; break;
13521352 case CallingConv::X86_FastCall: Out << "x86_fastcallcc "; break;
1353 case CallingConv::X86_SSECall: Out << "x86_ssecallcc "; break;
13541353 default: Out << "cc" << F->getCallingConv() << " "; break;
13551354 }
13561355
16341633 case CallingConv::Cold: Out << " coldcc"; break;
16351634 case CallingConv::X86_StdCall: Out << " x86_stdcallcc"; break;
16361635 case CallingConv::X86_FastCall: Out << " x86_fastcallcc"; break;
1637 case CallingConv::X86_SSECall: Out << " x86_ssecallcc"; break;
16381636 default: Out << " cc" << CI->getCallingConv(); break;
16391637 }
16401638
16791677 case CallingConv::Cold: Out << " coldcc"; break;
16801678 case CallingConv::X86_StdCall: Out << " x86_stdcallcc"; break;
16811679 case CallingConv::X86_FastCall: Out << " x86_fastcallcc"; break;
1682 case CallingConv::X86_SSECall: Out << " x86_ssecallcc"; break;
16831680 default: Out << " cc" << II->getCallingConv(); break;
16841681 }
16851682