llvm.org GIT mirror llvm / d2ea0e1
Change interface for TargetLowering::LowerCallTo and TargetLowering::LowerCall to pass around a struct instead of a large set of individual values. This cleans up the interface and allows more information to be added to the struct for future targets without requiring changes to each and every target. NV_CONTRIB git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157479 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Holewinski 8 years ago
30 changed file(s) with 345 addition(s) and 292 deletion(s). Raw diff Collapse all Expand all
2424 #include "llvm/CallingConv.h"
2525 #include "llvm/InlineAsm.h"
2626 #include "llvm/Attributes.h"
27 #include "llvm/Support/CallSite.h"
2728 #include "llvm/CodeGen/SelectionDAGNodes.h"
2829 #include "llvm/CodeGen/RuntimeLibcalls.h"
2930 #include "llvm/Support/DebugLoc.h"
12021203 llvm_unreachable("Not Implemented");
12031204 }
12041205
1205 /// LowerCallTo - This function lowers an abstract call to a function into an
1206 /// actual call. This returns a pair of operands. The first element is the
1207 /// return value for the function (if RetTy is not VoidTy). The second
1208 /// element is the outgoing token chain. It calls LowerCall to do the actual
1209 /// lowering.
12101206 struct ArgListEntry {
12111207 SDValue Node;
12121208 Type* Ty;
12221218 isSRet(false), isNest(false), isByVal(false), Alignment(0) { }
12231219 };
12241220 typedef std::vector ArgListTy;
1225 std::pair
1226 LowerCallTo(SDValue Chain, Type *RetTy, bool RetSExt, bool RetZExt,
1227 bool isVarArg, bool isInreg, unsigned NumFixedArgs,
1228 CallingConv::ID CallConv, bool isTailCall,
1229 bool doesNotRet, bool isReturnValueUsed,
1230 SDValue Callee, ArgListTy &Args,
1231 SelectionDAG &DAG, DebugLoc dl) const;
1221
1222 /// CallLoweringInfo - This structure contains all information that is
1223 /// necessary for lowering calls. It is passed to TLI::LowerCallTo when the
1224 /// SelectionDAG builder needs to lower a call, and targets will see this
1225 /// struct in their LowerCall implementation.
1226 struct CallLoweringInfo {
1227 SDValue Chain;
1228 Type *RetTy;
1229 bool RetSExt : 1;
1230 bool RetZExt : 1;
1231 bool IsVarArg : 1;
1232 bool IsInReg : 1;
1233 bool DoesNotReturn : 1;
1234 bool IsReturnValueUsed : 1;
1235
1236 // IsTailCall should be modified by implementations of
1237 // TargetLowering::LowerCall that perform tail call conversions.
1238 bool IsTailCall;
1239
1240 unsigned NumFixedArgs;
1241 CallingConv::ID CallConv;
1242 SDValue Callee;
1243 ArgListTy &Args;
1244 SelectionDAG &DAG;
1245 DebugLoc DL;
1246 ImmutableCallSite *CS;
1247 SmallVector Outs;
1248 SmallVector OutVals;
1249 SmallVector Ins;
1250
1251
1252 /// CallLoweringInfo - Constructs a call lowering context based on the
1253 /// ImmutableCallSite \p cs.
1254 CallLoweringInfo(SDValue chain, Type *retTy,
1255 FunctionType *FTy, bool isTailCall, SDValue callee,
1256 ArgListTy &args, SelectionDAG &dag, DebugLoc dl,
1257 ImmutableCallSite &cs)
1258 : Chain(chain), RetTy(retTy), RetSExt(cs.paramHasAttr(0, Attribute::SExt)),
1259 RetZExt(cs.paramHasAttr(0, Attribute::ZExt)), IsVarArg(FTy->isVarArg()),
1260 IsInReg(cs.paramHasAttr(0, Attribute::InReg)),
1261 DoesNotReturn(cs.doesNotReturn()),
1262 IsReturnValueUsed(!cs.getInstruction()->use_empty()),
1263 IsTailCall(isTailCall), NumFixedArgs(FTy->getNumParams()),
1264 CallConv(cs.getCallingConv()), Callee(callee), Args(args), DAG(dag),
1265 DL(dl), CS(&cs) {}
1266
1267 /// CallLoweringInfo - Constructs a call lowering context based on the
1268 /// provided call information.
1269 CallLoweringInfo(SDValue chain, Type *retTy, bool retSExt, bool retZExt,
1270 bool isVarArg, bool isInReg, unsigned numFixedArgs,
1271 CallingConv::ID callConv, bool isTailCall,
1272 bool doesNotReturn, bool isReturnValueUsed, SDValue callee,
1273 ArgListTy &args, SelectionDAG &dag, DebugLoc dl)
1274 : Chain(chain), RetTy(retTy), RetSExt(retSExt), RetZExt(retZExt),
1275 IsVarArg(isVarArg), IsInReg(isInReg), DoesNotReturn(doesNotReturn),
1276 IsReturnValueUsed(isReturnValueUsed), IsTailCall(isTailCall),
1277 NumFixedArgs(numFixedArgs), CallConv(callConv), Callee(callee),
1278 Args(args), DAG(dag), DL(dl), CS(NULL) {}
1279 };
1280
1281 /// LowerCallTo - This function lowers an abstract call to a function into an
1282 /// actual call. This returns a pair of operands. The first element is the
1283 /// return value for the function (if RetTy is not VoidTy). The second
1284 /// element is the outgoing token chain. It calls LowerCall to do the actual
1285 /// lowering.
1286 std::pair LowerCallTo(CallLoweringInfo &CLI) const;
12321287
12331288 /// LowerCall - This hook must be implemented to lower calls into the
12341289 /// the specified DAG. The outgoing arguments to the call are described
12371292 /// InVals array with legal-type return values from the call, and return
12381293 /// the resulting token chain value.
12391294 virtual SDValue
1240 LowerCall(SDValue /*Chain*/, SDValue /*Callee*/,
1241 CallingConv::ID /*CallConv*/, bool /*isVarArg*/,
1242 bool /*doesNotRet*/, bool &/*isTailCall*/,
1243 const SmallVectorImpl &/*Outs*/,
1244 const SmallVectorImpl &/*OutVals*/,
1245 const SmallVectorImpl &/*Ins*/,
1246 DebugLoc /*dl*/, SelectionDAG &/*DAG*/,
1295 LowerCall(CallLoweringInfo &/*CLI*/,
12471296 SmallVectorImpl &/*InVals*/) const {
12481297 llvm_unreachable("Not Implemented");
12491298 }
17991799 if (isTailCall)
18001800 InChain = TCChain;
18011801
1802 std::pair CallInfo =
1803 TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false,
1802 TargetLowering::
1803 CallLoweringInfo CLI(InChain, RetTy, isSigned, !isSigned, false, false,
18041804 0, TLI.getLibcallCallingConv(LC), isTailCall,
18051805 /*doesNotReturn=*/false, /*isReturnValueUsed=*/true,
18061806 Callee, Args, DAG, Node->getDebugLoc());
1807 std::pair CallInfo = TLI.LowerCallTo(CLI);
1808
18071809
18081810 if (!CallInfo.second.getNode())
18091811 // It's a tailcall, return the chain (which is the DAG root).
18321834 TLI.getPointerTy());
18331835
18341836 Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
1835 std::pair CallInfo =
1836 TLI.LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false,
1837 false, 0, TLI.getLibcallCallingConv(LC), /*isTailCall=*/false,
1837 TargetLowering::
1838 CallLoweringInfo CLI(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false,
1839 false, 0, TLI.getLibcallCallingConv(LC),
1840 /*isTailCall=*/false,
18381841 /*doesNotReturn=*/false, /*isReturnValueUsed=*/true,
18391842 Callee, Args, DAG, dl);
1843 std::pair CallInfo = TLI.LowerCallTo(CLI);
18401844
18411845 return CallInfo.first;
18421846 }
18641868 TLI.getPointerTy());
18651869
18661870 Type *RetTy = Node->getValueType(0).getTypeForEVT(*DAG.getContext());
1867 std::pair CallInfo =
1868 TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false,
1871 TargetLowering::
1872 CallLoweringInfo CLI(InChain, RetTy, isSigned, !isSigned, false, false,
18691873 0, TLI.getLibcallCallingConv(LC), /*isTailCall=*/false,
18701874 /*doesNotReturn=*/false, /*isReturnValueUsed=*/true,
18711875 Callee, Args, DAG, Node->getDebugLoc());
1876 std::pair CallInfo = TLI.LowerCallTo(CLI);
18721877
18731878 return CallInfo;
18741879 }
19962001 TLI.getPointerTy());
19972002
19982003 DebugLoc dl = Node->getDebugLoc();
1999 std::pair CallInfo =
2000 TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false,
2004 TargetLowering::
2005 CallLoweringInfo CLI(InChain, RetTy, isSigned, !isSigned, false, false,
20012006 0, TLI.getLibcallCallingConv(LC), /*isTailCall=*/false,
20022007 /*doesNotReturn=*/false, /*isReturnValueUsed=*/true,
20032008 Callee, Args, DAG, dl);
2009 std::pair CallInfo = TLI.LowerCallTo(CLI);
20042010
20052011 // Remainder is loaded back from the stack frame.
20062012 SDValue Rem = DAG.getLoad(RetVT, dl, CallInfo.second, FIPtr,
25742580 // If the target didn't lower this, lower it to '__sync_synchronize()' call
25752581 // FIXME: handle "fence singlethread" more efficiently.
25762582 TargetLowering::ArgListTy Args;
2577 std::pair CallResult =
2578 TLI.LowerCallTo(Node->getOperand(0), Type::getVoidTy(*DAG.getContext()),
2583 TargetLowering::
2584 CallLoweringInfo CLI(Node->getOperand(0),
2585 Type::getVoidTy(*DAG.getContext()),
25792586 false, false, false, false, 0, CallingConv::C,
25802587 /*isTailCall=*/false,
25812588 /*doesNotReturn=*/false, /*isReturnValueUsed=*/true,
25822589 DAG.getExternalSymbol("__sync_synchronize",
25832590 TLI.getPointerTy()),
25842591 Args, DAG, dl);
2592 std::pair CallResult = TLI.LowerCallTo(CLI);
2593
25852594 Results.push_back(CallResult.second);
25862595 break;
25872596 }
26512660 case ISD::TRAP: {
26522661 // If this operation is not supported, lower it to 'abort()' call
26532662 TargetLowering::ArgListTy Args;
2654 std::pair CallResult =
2655 TLI.LowerCallTo(Node->getOperand(0), Type::getVoidTy(*DAG.getContext()),
2663 TargetLowering::
2664 CallLoweringInfo CLI(Node->getOperand(0),
2665 Type::getVoidTy(*DAG.getContext()),
26562666 false, false, false, false, 0, CallingConv::C,
26572667 /*isTailCall=*/false,
26582668 /*doesNotReturn=*/false, /*isReturnValueUsed=*/true,
26592669 DAG.getExternalSymbol("abort", TLI.getPointerTy()),
26602670 Args, DAG, dl);
2671 std::pair CallResult = TLI.LowerCallTo(CLI);
2672
26612673 Results.push_back(CallResult.second);
26622674 break;
26632675 }
23182318 Args.push_back(Entry);
23192319
23202320 SDValue Func = DAG.getExternalSymbol(TLI.getLibcallName(LC), PtrVT);
2321 std::pair CallInfo =
2322 TLI.LowerCallTo(Chain, RetTy, true, false, false, false,
2321 TargetLowering::
2322 CallLoweringInfo CLI(Chain, RetTy, true, false, false, false,
23232323 0, TLI.getLibcallCallingConv(LC),
23242324 /*isTailCall=*/false,
23252325 /*doesNotReturn=*/false, /*isReturnValueUsed=*/true,
23262326 Func, Args, DAG, dl);
2327 std::pair CallInfo = TLI.LowerCallTo(CLI);
23272328
23282329 SplitInteger(CallInfo.first, Lo, Hi);
23292330 SDValue Temp2 = DAG.getLoad(PtrVT, dl, CallInfo.second, Temp,
10541054 TLI.getPointerTy());
10551055
10561056 Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
1057 std::pair CallInfo =
1058 TLI.LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false,
1057 TargetLowering::
1058 CallLoweringInfo CLI(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false,
10591059 false, 0, TLI.getLibcallCallingConv(LC),
10601060 /*isTailCall=*/false,
10611061 /*doesNotReturn=*/false, /*isReturnValueUsed=*/true,
10621062 Callee, Args, DAG, dl);
1063 std::pair CallInfo = TLI.LowerCallTo(CLI);
1064
10631065 return CallInfo.first;
10641066 }
10651067
10861088 TLI.getPointerTy());
10871089
10881090 Type *RetTy = Node->getValueType(0).getTypeForEVT(*DAG.getContext());
1089 std::pair CallInfo =
1090 TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false,
1091 TargetLowering::
1092 CallLoweringInfo CLI(InChain, RetTy, isSigned, !isSigned, false, false,
10911093 0, TLI.getLibcallCallingConv(LC), /*isTailCall=*/false,
10921094 /*doesNotReturn=*/false, /*isReturnValueUsed=*/true,
10931095 Callee, Args, DAG, Node->getDebugLoc());
1096 std::pair CallInfo = TLI.LowerCallTo(CLI);
10941097
10951098 return CallInfo;
10961099 }
37063706 Entry.Node = Src; Args.push_back(Entry);
37073707 Entry.Node = Size; Args.push_back(Entry);
37083708 // FIXME: pass in DebugLoc
3709 std::pair CallResult =
3710 TLI.LowerCallTo(Chain, Type::getVoidTy(*getContext()),
3709 TargetLowering::
3710 CallLoweringInfo CLI(Chain, Type::getVoidTy(*getContext()),
37113711 false, false, false, false, 0,
37123712 TLI.getLibcallCallingConv(RTLIB::MEMCPY),
37133713 /*isTailCall=*/false,
37153715 getExternalSymbol(TLI.getLibcallName(RTLIB::MEMCPY),
37163716 TLI.getPointerTy()),
37173717 Args, *this, dl);
3718 std::pair CallResult = TLI.LowerCallTo(CLI);
3719
37183720 return CallResult.second;
37193721 }
37203722
37593761 Entry.Node = Src; Args.push_back(Entry);
37603762 Entry.Node = Size; Args.push_back(Entry);
37613763 // FIXME: pass in DebugLoc
3762 std::pair CallResult =
3763 TLI.LowerCallTo(Chain, Type::getVoidTy(*getContext()),
3764 TargetLowering::
3765 CallLoweringInfo CLI(Chain, Type::getVoidTy(*getContext()),
37643766 false, false, false, false, 0,
37653767 TLI.getLibcallCallingConv(RTLIB::MEMMOVE),
37663768 /*isTailCall=*/false,
37683770 getExternalSymbol(TLI.getLibcallName(RTLIB::MEMMOVE),
37693771 TLI.getPointerTy()),
37703772 Args, *this, dl);
3773 std::pair CallResult = TLI.LowerCallTo(CLI);
3774
37713775 return CallResult.second;
37723776 }
37733777
38203824 Entry.isSExt = false;
38213825 Args.push_back(Entry);
38223826 // FIXME: pass in DebugLoc
3823 std::pair CallResult =
3824 TLI.LowerCallTo(Chain, Type::getVoidTy(*getContext()),
3827 TargetLowering::
3828 CallLoweringInfo CLI(Chain, Type::getVoidTy(*getContext()),
38253829 false, false, false, false, 0,
38263830 TLI.getLibcallCallingConv(RTLIB::MEMSET),
38273831 /*isTailCall=*/false,
38293833 getExternalSymbol(TLI.getLibcallName(RTLIB::MEMSET),
38303834 TLI.getPointerTy()),
38313835 Args, *this, dl);
3836 std::pair CallResult = TLI.LowerCallTo(CLI);
3837
38323838 return CallResult.second;
38333839 }
38343840
50645064 return 0;
50655065 }
50665066 TargetLowering::ArgListTy Args;
5067 std::pair Result =
5068 TLI.LowerCallTo(getRoot(), I.getType(),
5067 TargetLowering::
5068 CallLoweringInfo CLI(getRoot(), I.getType(),
50695069 false, false, false, false, 0, CallingConv::C,
50705070 /*isTailCall=*/false,
50715071 /*doesNotRet=*/false, /*isReturnValueUsed=*/true,
50725072 DAG.getExternalSymbol(TrapFuncName.data(), TLI.getPointerTy()),
50735073 Args, DAG, getCurDebugLoc());
5074 std::pair Result = TLI.LowerCallTo(CLI);
50745075 DAG.setRoot(Result.second);
50755076 return 0;
50765077 }
52375238 if (isTailCall && TM.Options.EnableFastISel)
52385239 isTailCall = false;
52395240
5240 std::pair Result =
5241 TLI.LowerCallTo(getRoot(), RetTy,
5242 CS.paramHasAttr(0, Attribute::SExt),
5243 CS.paramHasAttr(0, Attribute::ZExt), FTy->isVarArg(),
5244 CS.paramHasAttr(0, Attribute::InReg), FTy->getNumParams(),
5245 CS.getCallingConv(),
5246 isTailCall,
5247 CS.doesNotReturn(),
5248 !CS.getInstruction()->use_empty(),
5249 Callee, Args, DAG, getCurDebugLoc());
5241 TargetLowering::
5242 CallLoweringInfo CLI(getRoot(), RetTy, FTy, isTailCall, Callee, Args, DAG,
5243 getCurDebugLoc(), CS);
5244 std::pair Result = TLI.LowerCallTo(CLI);
52505245 assert((isTailCall || Result.second.getNode()) &&
52515246 "Non-null chain expected with non-tail call!");
52525247 assert((Result.second.getNode() || !Result.first.getNode()) &&
63446339 /// FIXME: When all targets are
63456340 /// migrated to using LowerCall, this hook should be integrated into SDISel.
63466341 std::pair
6347 TargetLowering::LowerCallTo(SDValue Chain, Type *RetTy,
6348 bool RetSExt, bool RetZExt, bool isVarArg,
6349 bool isInreg, unsigned NumFixedArgs,
6350 CallingConv::ID CallConv, bool isTailCall,
6351 bool doesNotRet, bool isReturnValueUsed,
6352 SDValue Callee,
6353 ArgListTy &Args, SelectionDAG &DAG,
6354 DebugLoc dl) const {
6342 TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
63556343 // Handle all of the outgoing arguments.
6356 SmallVector Outs;
6357 SmallVector OutVals;
6344 CLI.Outs.clear();
6345 CLI.OutVals.clear();
6346 ArgListTy &Args = CLI.Args;
63586347 for (unsigned i = 0, e = Args.size(); i != e; ++i) {
63596348 SmallVector ValueVTs;
63606349 ComputeValueVTs(*this, Args[i].Ty, ValueVTs);
63616350 for (unsigned Value = 0, NumValues = ValueVTs.size();
63626351 Value != NumValues; ++Value) {
63636352 EVT VT = ValueVTs[Value];
6364 Type *ArgTy = VT.getTypeForEVT(RetTy->getContext());
6353 Type *ArgTy = VT.getTypeForEVT(CLI.RetTy->getContext());
63656354 SDValue Op = SDValue(Args[i].Node.getNode(),
63666355 Args[i].Node.getResNo() + Value);
63676356 ISD::ArgFlagsTy Flags;
63946383 Flags.setNest();
63956384 Flags.setOrigAlign(OriginalAlignment);
63966385
6397 EVT PartVT = getRegisterType(RetTy->getContext(), VT);
6398 unsigned NumParts = getNumRegisters(RetTy->getContext(), VT);
6386 EVT PartVT = getRegisterType(CLI.RetTy->getContext(), VT);
6387 unsigned NumParts = getNumRegisters(CLI.RetTy->getContext(), VT);
63996388 SmallVector Parts(NumParts);
64006389 ISD::NodeType ExtendKind = ISD::ANY_EXTEND;
64016390
64046393 else if (Args[i].isZExt)
64056394 ExtendKind = ISD::ZERO_EXTEND;
64066395
6407 getCopyToParts(DAG, dl, Op, &Parts[0], NumParts,
6396 getCopyToParts(CLI.DAG, CLI.DL, Op, &Parts[0], NumParts,
64086397 PartVT, ExtendKind);
64096398
64106399 for (unsigned j = 0; j != NumParts; ++j) {
64116400 // if it isn't first piece, alignment must be 1
64126401 ISD::OutputArg MyFlags(Flags, Parts[j].getValueType(),
6413 i < NumFixedArgs);
6402 i < CLI.NumFixedArgs);
64146403 if (NumParts > 1 && j == 0)
64156404 MyFlags.Flags.setSplit();
64166405 else if (j != 0)
64176406 MyFlags.Flags.setOrigAlign(1);
64186407
6419 Outs.push_back(MyFlags);
6420 OutVals.push_back(Parts[j]);
6408 CLI.Outs.push_back(MyFlags);
6409 CLI.OutVals.push_back(Parts[j]);
64216410 }
64226411 }
64236412 }
64246413
64256414 // Handle the incoming return values from the call.
6426 SmallVector Ins;
6415 CLI.Ins.clear();
64276416 SmallVector RetTys;
6428 ComputeValueVTs(*this, RetTy, RetTys);
6417 ComputeValueVTs(*this, CLI.RetTy, RetTys);
64296418 for (unsigned I = 0, E = RetTys.size(); I != E; ++I) {
64306419 EVT VT = RetTys[I];
6431 EVT RegisterVT = getRegisterType(RetTy->getContext(), VT);
6432 unsigned NumRegs = getNumRegisters(RetTy->getContext(), VT);
6420 EVT RegisterVT = getRegisterType(CLI.RetTy->getContext(), VT);
6421 unsigned NumRegs = getNumRegisters(CLI.RetTy->getContext(), VT);
64336422 for (unsigned i = 0; i != NumRegs; ++i) {
64346423 ISD::InputArg MyFlags;
64356424 MyFlags.VT = RegisterVT.getSimpleVT();
6436 MyFlags.Used = isReturnValueUsed;
6437 if (RetSExt)
6425 MyFlags.Used = CLI.IsReturnValueUsed;
6426 if (CLI.RetSExt)
64386427 MyFlags.Flags.setSExt();
6439 if (RetZExt)
6428 if (CLI.RetZExt)
64406429 MyFlags.Flags.setZExt();
6441 if (isInreg)
6430 if (CLI.IsInReg)
64426431 MyFlags.Flags.setInReg();
6443 Ins.push_back(MyFlags);
6432 CLI.Ins.push_back(MyFlags);
64446433 }
64456434 }
64466435
64476436 SmallVector InVals;
6448 Chain = LowerCall(Chain, Callee, CallConv, isVarArg, doesNotRet, isTailCall,
6449 Outs, OutVals, Ins, dl, DAG, InVals);
6437 CLI.Chain = LowerCall(CLI, InVals);
64506438
64516439 // Verify that the target's LowerCall behaved as expected.
6452 assert(Chain.getNode() && Chain.getValueType() == MVT::Other &&
6440 assert(CLI.Chain.getNode() && CLI.Chain.getValueType() == MVT::Other &&
64536441 "LowerCall didn't return a valid chain!");
6454 assert((!isTailCall || InVals.empty()) &&
6442 assert((!CLI.IsTailCall || InVals.empty()) &&
64556443 "LowerCall emitted a return value for a tail call!");
6456 assert((isTailCall || InVals.size() == Ins.size()) &&
6444 assert((CLI.IsTailCall || InVals.size() == CLI.Ins.size()) &&
64576445 "LowerCall didn't emit the correct number of values!");
64586446
64596447 // For a tail call, the return value is merely live-out and there aren't
64606448 // any nodes in the DAG representing it. Return a special value to
64616449 // indicate that a tail call has been emitted and no more Instructions
64626450 // should be processed in the current block.
6463 if (isTailCall) {
6464 DAG.setRoot(Chain);
6451 if (CLI.IsTailCall) {
6452 CLI.DAG.setRoot(CLI.Chain);
64656453 return std::make_pair(SDValue(), SDValue());
64666454 }
64676455
6468 DEBUG(for (unsigned i = 0, e = Ins.size(); i != e; ++i) {
6456 DEBUG(for (unsigned i = 0, e = CLI.Ins.size(); i != e; ++i) {
64696457 assert(InVals[i].getNode() &&
64706458 "LowerCall emitted a null value!");
6471 assert(EVT(Ins[i].VT) == InVals[i].getValueType() &&
6459 assert(EVT(CLI.Ins[i].VT) == InVals[i].getValueType() &&
64726460 "LowerCall emitted a value with the wrong type!");
64736461 });
64746462
64756463 // Collect the legal value parts into potentially illegal values
64766464 // that correspond to the original function's return values.
64776465 ISD::NodeType AssertOp = ISD::DELETED_NODE;
6478 if (RetSExt)
6466 if (CLI.RetSExt)
64796467 AssertOp = ISD::AssertSext;
6480 else if (RetZExt)
6468 else if (CLI.RetZExt)
64816469 AssertOp = ISD::AssertZext;
64826470 SmallVector ReturnValues;
64836471 unsigned CurReg = 0;
64846472 for (unsigned I = 0, E = RetTys.size(); I != E; ++I) {
64856473 EVT VT = RetTys[I];
6486 EVT RegisterVT = getRegisterType(RetTy->getContext(), VT);
6487 unsigned NumRegs = getNumRegisters(RetTy->getContext(), VT);
6488
6489 ReturnValues.push_back(getCopyFromParts(DAG, dl, &InVals[CurReg],
6474 EVT RegisterVT = getRegisterType(CLI.RetTy->getContext(), VT);
6475 unsigned NumRegs = getNumRegisters(CLI.RetTy->getContext(), VT);
6476
6477 ReturnValues.push_back(getCopyFromParts(CLI.DAG, CLI.DL, &InVals[CurReg],
64906478 NumRegs, RegisterVT, VT,
64916479 AssertOp));
64926480 CurReg += NumRegs;
64966484 // such a node, so we just return a null return value in that case. In
64976485 // that case, nothing will actually look at the value.
64986486 if (ReturnValues.empty())
6499 return std::make_pair(SDValue(), Chain);
6500
6501 SDValue Res = DAG.getNode(ISD::MERGE_VALUES, dl,
6502 DAG.getVTList(&RetTys[0], RetTys.size()),
6487 return std::make_pair(SDValue(), CLI.Chain);
6488
6489 SDValue Res = CLI.DAG.getNode(ISD::MERGE_VALUES, CLI.DL,
6490 CLI.DAG.getVTList(&RetTys[0], RetTys.size()),
65036491 &ReturnValues[0], ReturnValues.size());
6504 return std::make_pair(Res, Chain);
6492 return std::make_pair(Res, CLI.Chain);
65056493 }
65066494
65076495 void TargetLowering::LowerOperationWrapper(SDNode *N,
12881288 /// ARMISD:CALL <- callseq_end chain. Also add input and output parameter
12891289 /// nodes.
12901290 SDValue
1291 ARMTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
1292 CallingConv::ID CallConv, bool isVarArg,
1293 bool doesNotRet, bool &isTailCall,
1294 const SmallVectorImpl &Outs,
1295 const SmallVectorImpl &OutVals,
1296 const SmallVectorImpl &Ins,
1297 DebugLoc dl, SelectionDAG &DAG,
1291 ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
12981292 SmallVectorImpl &InVals) const {
1293 SelectionDAG &DAG = CLI.DAG;
1294 DebugLoc &dl = CLI.DL;
1295 SmallVector &Outs = CLI.Outs;
1296 SmallVector &OutVals = CLI.OutVals;
1297 SmallVector &Ins = CLI.Ins;
1298 SDValue Chain = CLI.Chain;
1299 SDValue Callee = CLI.Callee;
1300 bool &isTailCall = CLI.IsTailCall;
1301 CallingConv::ID CallConv = CLI.CallConv;
1302 bool doesNotRet = CLI.DoesNotReturn;
1303 bool isVarArg = CLI.IsVarArg;
1304
12991305 MachineFunction &MF = DAG.getMachineFunction();
13001306 bool IsStructRet = (Outs.empty()) ? false : Outs[0].Flags.isSRet();
13011307 bool IsSibCall = false;
20972103 Entry.Ty = (Type *) Type::getInt32Ty(*DAG.getContext());
20982104 Args.push_back(Entry);
20992105 // FIXME: is there useful debug info available here?
2100 std::pair CallResult =
2101 LowerCallTo(Chain, (Type *) Type::getInt32Ty(*DAG.getContext()),
2106 TargetLowering::CallLoweringInfo CLI(Chain,
2107 (Type *) Type::getInt32Ty(*DAG.getContext()),
21022108 false, false, false, false,
21032109 0, CallingConv::C, /*isTailCall=*/false,
21042110 /*doesNotRet=*/false, /*isReturnValueUsed=*/true,
21052111 DAG.getExternalSymbol("__tls_get_addr", PtrVT), Args, DAG, dl);
2112 std::pair CallResult = LowerCallTo(CLI);
21062113 return CallResult.first;
21072114 }
21082115
462462 unsigned &VARegSize, unsigned &VARegSaveSize) const;
463463
464464 virtual SDValue
465 LowerCall(SDValue Chain, SDValue Callee,
466 CallingConv::ID CallConv, bool isVarArg,
467 bool doesNotRet, bool &isTailCall,
468 const SmallVectorImpl &Outs,
469 const SmallVectorImpl &OutVals,
470 const SmallVectorImpl &Ins,
471 DebugLoc dl, SelectionDAG &DAG,
465 LowerCall(TargetLowering::CallLoweringInfo &CLI,
472466 SmallVectorImpl &InVals) const;
473467
474468 /// HandleByVal - Target-specific cleanup for ByVal support.
178178 Args.push_back(Entry);
179179
180180 // Emit __eabi_memset call
181 std::pair CallResult =
182 TLI.LowerCallTo(Chain,
181 TargetLowering::CallLoweringInfo CLI(Chain,
183182 Type::getVoidTy(*DAG.getContext()), // return type
184183 false, // return sign ext
185184 false, // return zero ext
192191 false, // is return val used
193192 DAG.getExternalSymbol(TLI.getLibcallName(RTLIB::MEMSET),
194193 TLI.getPointerTy()), // callee
195 Args, DAG, dl); // arg list, DAG and debug
194 Args, DAG, dl);
195 std::pair CallResult =
196 TLI.LowerCallTo(CLI);
196197
197198 return CallResult.second;
198199 }
7676 // Splice the libcall in wherever FindInputOutputChains tells us to.
7777 Type *RetTy =
7878 Op.getNode()->getValueType(0).getTypeForEVT(*DAG.getContext());
79 std::pair CallInfo =
80 TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false,
79 TargetLowering::CallLoweringInfo CLI(InChain, RetTy, isSigned, !isSigned,
80 false, false,
8181 0, TLI.getLibcallCallingConv(LC),
8282 /*isTailCall=*/false,
83 /*doesNotRet=*/false, /*isReturnValueUsed=*/true,
83 /*doesNotRet=*/false,
84 /*isReturnValueUsed=*/true,
8485 Callee, Args, DAG, Op.getDebugLoc());
86 std::pair CallInfo = TLI.LowerCallTo(CLI);
8587
8688 return CallInfo.first;
8789 }
12621264 }
12631265
12641266 SDValue
1265 SPUTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
1266 CallingConv::ID CallConv, bool isVarArg,
1267 bool doesNotRet, bool &isTailCall,
1268 const SmallVectorImpl &Outs,
1269 const SmallVectorImpl &OutVals,
1270 const SmallVectorImpl &Ins,
1271 DebugLoc dl, SelectionDAG &DAG,
1267 SPUTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
12721268 SmallVectorImpl &InVals) const {
1269 SelectionDAG &DAG = CLI.DAG;
1270 DebugLoc &dl = CLI.DL;
1271 SmallVector &Outs = CLI.Outs;
1272 SmallVector &OutVals = CLI.OutVals;
1273 SmallVector &Ins = CLI.Ins;
1274 SDValue Chain = CLI.Chain;
1275 SDValue Callee = CLI.Callee;
1276 bool &isTailCall = CLI.IsTailCall;
1277 CallingConv::ID CallConv = CLI.CallConv;
1278 bool isVarArg = CLI.IsVarArg;
1279
12731280 // CellSPU target does not yet support tail call optimization.
12741281 isTailCall = false;
12751282
158158 SmallVectorImpl &InVals) const;
159159
160160 virtual SDValue
161 LowerCall(SDValue Chain, SDValue Callee,
162 CallingConv::ID CallConv, bool isVarArg,
163 bool doesNotRet, bool &isTailCall,
164 const SmallVectorImpl &Outs,
165 const SmallVectorImpl &OutVals,
166 const SmallVectorImpl &Ins,
167 DebugLoc dl, SelectionDAG &DAG,
161 LowerCall(TargetLowering::CallLoweringInfo &CLI,
168162 SmallVectorImpl &InVals) const;
169163
170164 virtual SDValue
369369 /// LowerCall - Functions arguments are copied from virtual regs to
370370 /// (physical regs)/(stack frame), CALLSEQ_START and CALLSEQ_END are emitted.
371371 SDValue
372 HexagonTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
373 CallingConv::ID CallConv, bool isVarArg,
374 bool doesNotRet, bool &isTailCall,
375 const SmallVectorImpl &Outs,
376 const SmallVectorImpl &OutVals,
377 const SmallVectorImpl &Ins,
378 DebugLoc dl, SelectionDAG &DAG,
372 HexagonTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
379373 SmallVectorImpl &InVals) const {
374 SelectionDAG &DAG = CLI.DAG;
375 DebugLoc &dl = CLI.DL;
376 SmallVector &Outs = CLI.Outs;
377 SmallVector &OutVals = CLI.OutVals;
378 SmallVector &Ins = CLI.Ins;
379 SDValue Chain = CLI.Chain;
380 SDValue Callee = CLI.Callee;
381 bool &isTailCall = CLI.IsTailCall;
382 CallingConv::ID CallConv = CLI.CallConv;
383 bool isVarArg = CLI.IsVarArg;
380384
381385 bool IsStructRet = (Outs.empty()) ? false : Outs[0].Flags.isSRet();
382386
9595 SmallVectorImpl &InVals) const;
9696 SDValue LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const;
9797
98 SDValue LowerCall(SDValue Chain, SDValue Callee,
99 CallingConv::ID CallConv, bool isVarArg,
100 bool doesNotRet, bool &isTailCall,
101 const SmallVectorImpl &Outs,
102 const SmallVectorImpl &OutVals,
103 const SmallVectorImpl &Ins,
104 DebugLoc dl, SelectionDAG &DAG,
98 SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
10599 SmallVectorImpl &InVals) const;
106100
107101 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
680680 /// (physical regs)/(stack frame), CALLSEQ_START and CALLSEQ_END are emitted.
681681 /// TODO: isVarArg, isTailCall.
682682 SDValue MBlazeTargetLowering::
683 LowerCall(SDValue Chain, SDValue Callee, CallingConv::ID CallConv,
684 bool isVarArg, bool doesNotRet, bool &isTailCall,
685 const SmallVectorImpl &Outs,
686 const SmallVectorImpl &OutVals,
687 const SmallVectorImpl &Ins,
688 DebugLoc dl, SelectionDAG &DAG,
683 LowerCall(TargetLowering::CallLoweringInfo &CLI,
689684 SmallVectorImpl &InVals) const {
685 SelectionDAG &DAG = CLI.DAG;
686 DebugLoc &dl = CLI.DL;
687 SmallVector &Outs = CLI.Outs;
688 SmallVector &OutVals = CLI.OutVals;
689 SmallVector &Ins = CLI.Ins;
690 SDValue Chain = CLI.Chain;
691 SDValue Callee = CLI.Callee;
692 bool &isTailCall = CLI.IsTailCall;
693 CallingConv::ID CallConv = CLI.CallConv;
694 bool isVarArg = CLI.IsVarArg;
695
690696 // MBlaze does not yet support tail call optimization
691697 isTailCall = false;
692698
131131 SmallVectorImpl &InVals) const;
132132
133133 virtual SDValue
134 LowerCall(SDValue Chain, SDValue Callee,
135 CallingConv::ID CallConv, bool isVarArg,
136 bool doesNotRet, bool &isTailCall,
137 const SmallVectorImpl &Outs,
138 const SmallVectorImpl &OutVals,
139 const SmallVectorImpl &Ins,
140 DebugLoc dl, SelectionDAG &DAG,
134 LowerCall(TargetLowering::CallLoweringInfo &CLI,
141135 SmallVectorImpl &InVals) const;
142136
143137 virtual SDValue
265265 }
266266
267267 SDValue
268 MSP430TargetLowering::LowerCall(SDValue Chain, SDValue Callee,
269 CallingConv::ID CallConv, bool isVarArg,
270 bool doesNotRet, bool &isTailCall,
271 const SmallVectorImpl &Outs,
272 const SmallVectorImpl &OutVals,
273 const SmallVectorImpl &Ins,
274 DebugLoc dl, SelectionDAG &DAG,
268 MSP430TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
275269 SmallVectorImpl &InVals) const {
270 SelectionDAG &DAG = CLI.DAG;
271 DebugLoc &dl = CLI.DL;
272 SmallVector &Outs = CLI.Outs;
273 SmallVector &OutVals = CLI.OutVals;
274 SmallVector &Ins = CLI.Ins;
275 SDValue Chain = CLI.Chain;
276 SDValue Callee = CLI.Callee;
277 bool &isTailCall = CLI.IsTailCall;
278 CallingConv::ID CallConv = CLI.CallConv;
279 bool isVarArg = CLI.IsVarArg;
280
276281 // MSP430 target does not yet support tail call optimization.
277282 isTailCall = false;
278283
151151 DebugLoc dl, SelectionDAG &DAG,
152152 SmallVectorImpl &InVals) const;
153153 virtual SDValue
154 LowerCall(SDValue Chain, SDValue Callee, CallingConv::ID CallConv,
155 bool isVarArg, bool doesNotRet, bool &isTailCall,
156 const SmallVectorImpl &Outs,
157 const SmallVectorImpl &OutVals,
158 const SmallVectorImpl &Ins,
159 DebugLoc dl, SelectionDAG &DAG,
154 LowerCall(TargetLowering::CallLoweringInfo &CLI,
160155 SmallVectorImpl &InVals) const;
161156
162157 virtual SDValue
16391639 Entry.Ty = PtrTy;
16401640 Args.push_back(Entry);
16411641
1642 std::pair CallResult =
1643 LowerCallTo(DAG.getEntryNode(), PtrTy,
1642 TargetLowering::CallLoweringInfo CLI(DAG.getEntryNode(), PtrTy,
16441643 false, false, false, false, 0, CallingConv::C,
16451644 /*isTailCall=*/false, /*doesNotRet=*/false,
16461645 /*isReturnValueUsed=*/true,
16471646 TlsGetAddr, Args, DAG, dl);
1647 std::pair CallResult = LowerCallTo(CLI);
16481648
16491649 SDValue Ret = CallResult.first;
16501650
24142414 /// (physical regs)/(stack frame), CALLSEQ_START and CALLSEQ_END are emitted.
24152415 /// TODO: isTailCall.
24162416 SDValue
2417 MipsTargetLowering::LowerCall(SDValue InChain, SDValue Callee,
2418 CallingConv::ID CallConv, bool isVarArg,
2419 bool doesNotRet, bool &isTailCall,
2420 const SmallVectorImpl &Outs,
2421 const SmallVectorImpl &OutVals,
2422 const SmallVectorImpl &Ins,
2423 DebugLoc dl, SelectionDAG &DAG,
2417 MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
24242418 SmallVectorImpl &InVals) const {
2419 SelectionDAG &DAG = CLI.DAG;
2420 DebugLoc &dl = CLI.DL;
2421 SmallVector &Outs = CLI.Outs;
2422 SmallVector &OutVals = CLI.OutVals;
2423 SmallVector &Ins = CLI.Ins;
2424 SDValue InChain = CLI.Chain;
2425 SDValue Callee = CLI.Callee;
2426 bool &isTailCall = CLI.IsTailCall;
2427 CallingConv::ID CallConv = CLI.CallConv;
2428 bool isVarArg = CLI.IsVarArg;
2429
24252430 // MIPs target does not yet support tail call optimization.
24262431 isTailCall = false;
24272432
145145 SmallVectorImpl &InVals) const;
146146
147147 virtual SDValue
148 LowerCall(SDValue Chain, SDValue Callee,
149 CallingConv::ID CallConv, bool isVarArg,
150 bool doesNotRet, bool &isTailCall,
151 const SmallVectorImpl &Outs,
152 const SmallVectorImpl &OutVals,
153 const SmallVectorImpl &Ins,
154 DebugLoc dl, SelectionDAG &DAG,
148 LowerCall(TargetLowering::CallLoweringInfo &CLI,
155149 SmallVectorImpl &InVals) const;
156150
157151 virtual SDValue
437437 }
438438
439439
440 #if 0
441440 SDValue
442 NVPTXTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
443 CallingConv::ID CallConv, bool isVarArg,
444 bool doesNotRet, bool &isTailCall,
445 const SmallVectorImpl &Outs,
446 const SmallVectorImpl &OutVals,
447 const SmallVectorImpl &Ins,
448 DebugLoc dl, SelectionDAG &DAG,
449 SmallVectorImpl &InVals, Type *retTy,
450 const ArgListTy &Args) const {
441 NVPTXTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
442 SmallVectorImpl &InVals) const {
443 SelectionDAG &DAG = CLI.DAG;
444 DebugLoc &dl = CLI.DL;
445 SmallVector &Outs = CLI.Outs;
446 SmallVector &OutVals = CLI.OutVals;
447 SmallVector &Ins = CLI.Ins;
448 SDValue Chain = CLI.Chain;
449 SDValue Callee = CLI.Callee;
450 bool &isTailCall = CLI.IsTailCall;
451 ArgListTy &Args = CLI.Args;
452 Type *retTy = CLI.RetTy;
453 ImmutableCallSite *CS = CLI.CS;
454
451455 bool isABI = (nvptxSubtarget.getSmVersion() >= 20);
452456
453457 SDValue tempChain = Chain;
648652 InFlag = Chain.getValue(1);
649653 }
650654 else {
651 // @TODO: Re-enable getAlign calls. We do not have the
652 // ImmutableCallSite object here anymore.
653 //if (Func) { // direct call
654 //if (!llvm::getAlign(*(CS->getCalledFunction()), 0, retAlignment))
655 //retAlignment = TD->getABITypeAlignment(retTy);
656 //}
657 //else { // indirect call
658 //const CallInst *CallI = dyn_cast(CS->getInstruction());
659 //if (!llvm::getAlign(*CallI, 0, retAlignment))
660 //retAlignment = TD->getABITypeAlignment(retTy);
661 //}
662 // @TODO: Remove this hack!
663 // Functions with explicit alignment metadata will be broken, for now.
664 retAlignment = 16;
655 if (Func) { // direct call
656 if (!llvm::getAlign(*(CS->getCalledFunction()), 0, retAlignment))
657 retAlignment = getTargetData()->getABITypeAlignment(retTy);
658 } else { // indirect call
659 const CallInst *CallI = dyn_cast(CS->getInstruction());
660 if (!llvm::getAlign(*CallI, 0, retAlignment))
661 retAlignment = getTargetData()->getABITypeAlignment(retTy);
662 }
665663 SDVTList DeclareRetVTs = DAG.getVTList(MVT::Other, MVT::Glue);
666664 SDValue DeclareRetOps[] = { Chain, DAG.getConstant(retAlignment,
667665 MVT::i32),
822820 isTailCall = false;
823821 return Chain;
824822 }
825 #endif
826823
827824 // By default CONCAT_VECTORS is lowered by ExpandVectorBuildThroughStack()
828825 // (see LegalizeDAG.cpp). This is slow and uses local memory.
104104 SelectionDAG &DAG,
105105 SmallVectorImpl &InVals) const;
106106
107 // This will be re-added once the necessary changes to LowerCallTo are
108 // upstreamed.
109 // virtual SDValue
110 // LowerCall(SDValue Chain, SDValue Callee, CallingConv::ID CallConv,
111 // bool isVarArg, bool doesNotRet, bool &isTailCall,
112 // const SmallVectorImpl &Outs,
113 // const SmallVectorImpl &OutVals,
114 // const SmallVectorImpl &Ins,
115 // DebugLoc dl, SelectionDAG &DAG,
116 // SmallVectorImpl &InVals,
117 // Type *retTy, const ArgListTy &Args) const;
107 virtual SDValue
108 LowerCall(CallLoweringInfo &CLI, SmallVectorImpl &InVals) const;
118109
119110 std::string getPrototype(Type *, const ArgListTy &,
120111 const SmallVectorImpl &,
14391439 Entry.Node = Nest; Args.push_back(Entry);
14401440
14411441 // Lower to a call to __trampoline_setup(Trmp, TrampSize, FPtr, ctx_reg)
1442 std::pair CallResult =
1443 LowerCallTo(Chain, Type::getVoidTy(*DAG.getContext()),
1444 false, false, false, false, 0, CallingConv::C,
1442 TargetLowering::CallLoweringInfo CLI(Chain,
1443 Type::getVoidTy(*DAG.getContext()),
1444 false, false, false, false, 0,
1445 CallingConv::C,
14451446 /*isTailCall=*/false,
1446 /*doesNotRet=*/false, /*isReturnValueUsed=*/true,
1447 /*doesNotRet=*/false,
1448 /*isReturnValueUsed=*/true,
14471449 DAG.getExternalSymbol("__trampoline_setup", PtrVT),
14481450 Args, DAG, dl);
1451 std::pair CallResult = LowerCallTo(CLI);
14491452
14501453 return CallResult.second;
14511454 }
28632866 }
28642867
28652868 SDValue
2866 PPCTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
2867 CallingConv::ID CallConv, bool isVarArg,
2868 bool doesNotRet, bool &isTailCall,
2869 const SmallVectorImpl &Outs,
2870 const SmallVectorImpl &OutVals,
2871 const SmallVectorImpl &Ins,
2872 DebugLoc dl, SelectionDAG &DAG,
2869 PPCTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
28732870 SmallVectorImpl &InVals) const {
2871 SelectionDAG &DAG = CLI.DAG;
2872 DebugLoc &dl = CLI.DL;
2873 SmallVector &Outs = CLI.Outs;
2874 SmallVector &OutVals = CLI.OutVals;
2875 SmallVector &Ins = CLI.Ins;
2876 SDValue Chain = CLI.Chain;
2877 SDValue Callee = CLI.Callee;
2878 bool &isTailCall = CLI.IsTailCall;
2879 CallingConv::ID CallConv = CLI.CallConv;
2880 bool isVarArg = CLI.IsVarArg;
2881
28742882 if (isTailCall)
28752883 isTailCall = IsEligibleForTailCallOptimization(Callee, CallConv, isVarArg,
28762884 Ins, DAG);
438438 SmallVectorImpl &InVals) const;
439439
440440 virtual SDValue
441 LowerCall(SDValue Chain, SDValue Callee, CallingConv::ID CallConv,
442 bool isVarArg, bool doesNotRet, bool &isTailCall,
443 const SmallVectorImpl &Outs,
444 const SmallVectorImpl &OutVals,
445 const SmallVectorImpl &Ins,
446 DebugLoc dl, SelectionDAG &DAG,
441 LowerCall(TargetLowering::CallLoweringInfo &CLI,
447442 SmallVectorImpl &InVals) const;
448443
449444 virtual bool
344344 }
345345
346346 SDValue
347 SparcTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
348 CallingConv::ID CallConv, bool isVarArg,
349 bool doesNotRet, bool &isTailCall,
350 const SmallVectorImpl &Outs,
351 const SmallVectorImpl &OutVals,
352 const SmallVectorImpl &Ins,
353 DebugLoc dl, SelectionDAG &DAG,
347 SparcTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
354348 SmallVectorImpl &InVals) const {
349 SelectionDAG &DAG = CLI.DAG;
350 DebugLoc &dl = CLI.DL;
351 SmallVector &Outs = CLI.Outs;
352 SmallVector &OutVals = CLI.OutVals;
353 SmallVector &Ins = CLI.Ins;
354 SDValue Chain = CLI.Chain;
355 SDValue Callee = CLI.Callee;
356 bool &isTailCall = CLI.IsTailCall;
357 CallingConv::ID CallConv = CLI.CallConv;
358 bool isVarArg = CLI.IsVarArg;
359
355360 // Sparc target does not yet support tail call optimization.
356361 isTailCall = false;
357362
7575 SmallVectorImpl &InVals) const;
7676
7777 virtual SDValue
78 LowerCall(SDValue Chain, SDValue Callee, CallingConv::ID CallConv,
79 bool isVarArg, bool doesNotRet, bool &isTailCall,
80 const SmallVectorImpl &Outs,
81 const SmallVectorImpl &OutVals,
82 const SmallVectorImpl &Ins,
83 DebugLoc dl, SelectionDAG &DAG,
78 LowerCall(TargetLowering::CallLoweringInfo &CLI,
8479 SmallVectorImpl &InVals) const;
8580
8681 virtual SDValue
21292129 }
21302130
21312131 SDValue
2132 X86TargetLowering::LowerCall(SDValue Chain, SDValue Callee,
2133 CallingConv::ID CallConv, bool isVarArg,
2134 bool doesNotRet, bool &isTailCall,
2135 const SmallVectorImpl &Outs,
2136 const SmallVectorImpl &OutVals,
2137 const SmallVectorImpl &Ins,
2138 DebugLoc dl, SelectionDAG &DAG,
2132 X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
21392133 SmallVectorImpl &InVals) const {
2134 SelectionDAG &DAG = CLI.DAG;
2135 DebugLoc &dl = CLI.DL;
2136 SmallVector &Outs = CLI.Outs;
2137 SmallVector &OutVals = CLI.OutVals;
2138 SmallVector &Ins = CLI.Ins;
2139 SDValue Chain = CLI.Chain;
2140 SDValue Callee = CLI.Callee;
2141 CallingConv::ID CallConv = CLI.CallConv;
2142 bool &isTailCall = CLI.IsTailCall;
2143 bool isVarArg = CLI.IsVarArg;
2144
21402145 MachineFunction &MF = DAG.getMachineFunction();
21412146 bool Is64Bit = Subtarget->is64Bit();
21422147 bool IsWin64 = Subtarget->isTargetWin64();
802802 DebugLoc dl, SelectionDAG &DAG,
803803 SmallVectorImpl &InVals) const;
804804 virtual SDValue
805 LowerCall(SDValue Chain, SDValue Callee, CallingConv::ID CallConv,
806 bool isVarArg, bool doesNotRet, bool &isTailCall,
807 const SmallVectorImpl &Outs,
808 const SmallVectorImpl &OutVals,
809 const SmallVectorImpl &Ins,
810 DebugLoc dl, SelectionDAG &DAG,
805 LowerCall(CallLoweringInfo &CLI,
811806 SmallVectorImpl &InVals) const;
812807
813808 virtual SDValue
6161 Args.push_back(Entry);
6262 Entry.Node = Size;
6363 Args.push_back(Entry);
64 std::pair CallResult =
65 TLI.LowerCallTo(Chain, Type::getVoidTy(*DAG.getContext()),
64 TargetLowering::
65 CallLoweringInfo CLI(Chain, Type::getVoidTy(*DAG.getContext()),
6666 false, false, false, false,
6767 0, CallingConv::C, /*isTailCall=*/false,
6868 /*doesNotRet=*/false, /*isReturnValueUsed=*/false,
6969 DAG.getExternalSymbol(bzeroEntry, IntPtr), Args,
7070 DAG, dl);
71 std::pair CallResult =
72 TLI.LowerCallTo(CLI);
7173 return CallResult.second;
7274 }
7375
484484 Entry.Node = BasePtr;
485485 Args.push_back(Entry);
486486
487 std::pair CallResult =
488 LowerCallTo(Chain, IntPtrTy, false, false,
487 TargetLowering::CallLoweringInfo CLI(Chain, IntPtrTy, false, false,
489488 false, false, 0, CallingConv::C, /*isTailCall=*/false,
490489 /*doesNotRet=*/false, /*isReturnValueUsed=*/true,
491490 DAG.getExternalSymbol("__misaligned_load", getPointerTy()),
492491 Args, DAG, DL);
492 std::pair CallResult = LowerCallTo(CLI);
493493
494494 SDValue Ops[] =
495495 { CallResult.first, CallResult.second };
546546 Entry.Node = Value;
547547 Args.push_back(Entry);
548548
549 std::pair CallResult =
550 LowerCallTo(Chain, Type::getVoidTy(*DAG.getContext()), false, false,
549 TargetLowering::CallLoweringInfo CLI(Chain,
550 Type::getVoidTy(*DAG.getContext()), false, false,
551551 false, false, 0, CallingConv::C, /*isTailCall=*/false,
552552 /*doesNotRet=*/false, /*isReturnValueUsed=*/true,
553553 DAG.getExternalSymbol("__misaligned_store", getPointerTy()),
554554 Args, DAG, dl);
555 std::pair CallResult = LowerCallTo(CLI);
555556
556557 return CallResult.second;
557558 }
872873
873874 /// XCore call implementation
874875 SDValue
875 XCoreTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
876 CallingConv::ID CallConv, bool isVarArg,
877 bool doesNotRet, bool &isTailCall,
878 const SmallVectorImpl &Outs,
879 const SmallVectorImpl &OutVals,
880 const SmallVectorImpl &Ins,
881 DebugLoc dl, SelectionDAG &DAG,
876 XCoreTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
882877 SmallVectorImpl &InVals) const {
878 SelectionDAG &DAG = CLI.DAG;
879 DebugLoc &dl = CLI.DL;
880 SmallVector &Outs = CLI.Outs;
881 SmallVector &OutVals = CLI.OutVals;
882 SmallVector &Ins = CLI.Ins;
883 SDValue Chain = CLI.Chain;
884 SDValue Callee = CLI.Callee;
885 bool &isTailCall = CLI.IsTailCall;
886 CallingConv::ID CallConv = CLI.CallConv;
887 bool isVarArg = CLI.IsVarArg;
888
883889 // XCore target does not yet support tail call optimization.
884890 isTailCall = false;
885891
173173 SmallVectorImpl &InVals) const;
174174
175175 virtual SDValue
176 LowerCall(SDValue Chain, SDValue Callee, CallingConv::ID CallConv,
177 bool isVarArg, bool doesNotRet, bool &isTailCall,
178 const SmallVectorImpl &Outs,
179 const SmallVectorImpl &OutVals,
180 const SmallVectorImpl &Ins,
181 DebugLoc dl, SelectionDAG &DAG,
176 LowerCall(TargetLowering::CallLoweringInfo &CLI,
182177 SmallVectorImpl &InVals) const;
183178
184179 virtual SDValue