llvm.org GIT mirror llvm / 7d2ad62
Make LowerCallTo and LowerArguments take a DebugLoc argument. Adjust all callers and overloaded versions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63444 91177308-0d34-0410-b5e6-96231b3b80d8 Dale Johannesen 10 years ago
17 changed file(s) with 83 addition(s) and 53 deletion(s). Raw diff Collapse all Expand all
2828 #include "llvm/ADT/DenseMap.h"
2929 #include "llvm/ADT/SmallSet.h"
3030 #include "llvm/ADT/STLExtras.h"
31 #include "llvm/Codegen/DebugLoc.h"
3132 #include
3233 #include
3334 #include
10581059 /// lower the arguments for the specified function, into the specified DAG.
10591060 virtual void
10601061 LowerArguments(Function &F, SelectionDAG &DAG,
1061 SmallVectorImpl& ArgValues);
1062 SmallVectorImpl& ArgValues, DebugLoc dl);
10621063
10631064 /// LowerCallTo - This hook lowers an abstract call to a function into an
10641065 /// actual call. This returns a pair of operands. The first element is the
10831084 LowerCallTo(SDValue Chain, const Type *RetTy, bool RetSExt, bool RetZExt,
10841085 bool isVarArg, bool isInreg, unsigned CallingConv,
10851086 bool isTailCall, SDValue Callee, ArgListTy &Args,
1086 SelectionDAG &DAG);
1087 SelectionDAG &DAG, DebugLoc dl);
10871088
10881089 /// EmitTargetCodeForMemcpy - Emit target-specific code that performs a
10891090 /// memcpy. This can be used by targets to provide code sequences for cases
990990 assert(isTypeLegal(Op.getValueType()) &&
991991 "Caller should expand or promote operands that are not legal!");
992992 SDNode *Node = Op.getNode();
993 DebugLoc dl = Node->getDebugLoc();
993994
994995 // If this operation defines any values that cannot be represented in a
995996 // register on this target, make sure to expand or promote them.
43224323 TLI.LowerCallTo(Tmp1, Type::VoidTy,
43234324 false, false, false, false, CallingConv::C, false,
43244325 DAG.getExternalSymbol("abort", TLI.getPointerTy()),
4325 Args, DAG);
4326 Args, DAG, dl);
43264327 Result = CallResult.second;
43274328 break;
43284329 }
57905791 const Type *RetTy = Node->getValueType(0).getTypeForMVT();
57915792 std::pair CallInfo =
57925793 TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false,
5793 CallingConv::C, false, Callee, Args, DAG);
5794 CallingConv::C, false, Callee, Args, DAG,
5795 Node->getDebugLoc());
57945796
57955797 // Legalize the call sequence, starting with the chain. This will advance
57965798 // the LastCALLSEQ_END to the legalized version of the CALLSEQ_END node that
986986 TLI.getPointerTy());
987987
988988 const Type *RetTy = RetVT.getTypeForMVT();
989 // FIXME pass in debug loc
989990 std::pair CallInfo =
990991 TLI.LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false,
991 false, CallingConv::C, false, Callee, Args, DAG);
992 false, CallingConv::C, false, Callee, Args, DAG,
993 DebugLoc::getUnknownLoc());
992994 return CallInfo.first;
993995 }
994996
32843284 Entry.Node = Dst; Args.push_back(Entry);
32853285 Entry.Node = Src; Args.push_back(Entry);
32863286 Entry.Node = Size; Args.push_back(Entry);
3287 // FIXME: pass in DebugLoc
32873288 std::pair CallResult =
32883289 TLI.LowerCallTo(Chain, Type::VoidTy,
32893290 false, false, false, false, CallingConv::C, false,
32903291 getExternalSymbol("memcpy", TLI.getPointerTy()),
3291 Args, *this);
3292 Args, *this, DebugLoc::getUnknownLoc());
32923293 return CallResult.second;
32933294 }
32943295
33293330 Entry.Node = Dst; Args.push_back(Entry);
33303331 Entry.Node = Src; Args.push_back(Entry);
33313332 Entry.Node = Size; Args.push_back(Entry);
3333 // FIXME: pass in DebugLoc
33323334 std::pair CallResult =
33333335 TLI.LowerCallTo(Chain, Type::VoidTy,
33343336 false, false, false, false, CallingConv::C, false,
33353337 getExternalSymbol("memmove", TLI.getPointerTy()),
3336 Args, *this);
3338 Args, *this, DebugLoc::getUnknownLoc());
33373339 return CallResult.second;
33383340 }
33393341
33803382 Args.push_back(Entry);
33813383 Entry.Node = Size; Entry.Ty = IntPtrTy; Entry.isSExt = false;
33823384 Args.push_back(Entry);
3385 // FIXME: pass in DebugLoc
33833386 std::pair CallResult =
33843387 TLI.LowerCallTo(Chain, Type::VoidTy,
33853388 false, false, false, false, CallingConv::C, false,
33863389 getExternalSymbol("memset", TLI.getPointerTy()),
3387 Args, *this);
3390 Args, *this, DebugLoc::getUnknownLoc());
33883391 return CallResult.second;
33893392 }
33903393
43434343 CS.paramHasAttr(0, Attribute::InReg),
43444344 CS.getCallingConv(),
43454345 IsTailCall && PerformTailCallOpt,
4346 Callee, Args, DAG);
4346 Callee, Args, DAG, DAG.getCurDebugLoc());
43474347 if (CS.getType() != Type::VoidTy)
43484348 setValue(CS.getInstruction(), Result.first);
43494349 DAG.setRoot(Result.second);
53565356 TLI.LowerCallTo(getRoot(), I.getType(), false, false, false, false,
53575357 CallingConv::C, PerformTailCallOpt,
53585358 DAG.getExternalSymbol("malloc", IntPtr),
5359 Args, DAG);
5359 Args, DAG, DAG.getCurDebugLoc());
53605360 setValue(&I, Result.first); // Pointers always fit in registers
53615361 DAG.setRoot(Result.second);
53625362 }
53715371 std::pair Result =
53725372 TLI.LowerCallTo(getRoot(), Type::VoidTy, false, false, false, false,
53735373 CallingConv::C, PerformTailCallOpt,
5374 DAG.getExternalSymbol("free", IntPtr), Args, DAG);
5374 DAG.getExternalSymbol("free", IntPtr), Args, DAG,
5375 DAG.getCurDebugLoc());
53755376 DAG.setRoot(Result.second);
53765377 }
53775378
54115412 /// targets are migrated to using FORMAL_ARGUMENTS, this hook should be
54125413 /// integrated into SDISel.
54135414 void TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG,
5414 SmallVectorImpl &ArgValues) {
5415 SmallVectorImpl &ArgValues,
5416 DebugLoc dl) {
54155417 // Add CC# and isVararg as operands to the FORMAL_ARGUMENTS node.
54165418 SmallVector Ops;
54175419 Ops.push_back(DAG.getRoot());
54765478 RetVals.push_back(MVT::Other);
54775479
54785480 // Create the node.
5479 SDNode *Result = DAG.getNode(ISD::FORMAL_ARGUMENTS, DAG.getCurDebugLoc(),
5481 SDNode *Result = DAG.getNode(ISD::FORMAL_ARGUMENTS, dl,
54805482 DAG.getVTList(&RetVals[0], RetVals.size()),
54815483 &Ops[0], Ops.size()).getNode();
54825484
55445546 bool isInreg,
55455547 unsigned CallingConv, bool isTailCall,
55465548 SDValue Callee,
5547 ArgListTy &Args, SelectionDAG &DAG) {
5549 ArgListTy &Args, SelectionDAG &DAG, DebugLoc dl) {
55485550 assert((!isTailCall || PerformTailCallOpt) &&
55495551 "isTailCall set when tail-call optimizations are disabled!");
55505552
56355637 LoweredRetTys.push_back(MVT::Other); // Always has a chain.
56365638
56375639 // Create the CALL node.
5638 SDValue Res = DAG.getCall(CallingConv, DAG.getCurDebugLoc(),
5640 SDValue Res = DAG.getCall(CallingConv, dl,
56395641 isVarArg, isTailCall, isInreg,
56405642 DAG.getVTList(&LoweredRetTys[0],
56415643 LoweredRetTys.size()),
56675669 AssertOp);
56685670 ReturnValues.push_back(ReturnValue);
56695671 }
5670 Res = DAG.getNode(ISD::MERGE_VALUES, DAG.getCurDebugLoc(),
5672 Res = DAG.getNode(ISD::MERGE_VALUES, dl,
56715673 DAG.getVTList(&RetTys[0], RetTys.size()),
56725674 &ReturnValues[0], ReturnValues.size());
56735675 }
57115713 Function &F = *LLVMBB->getParent();
57125714 SDValue OldRoot = SDL->DAG.getRoot();
57135715 SmallVector Args;
5714 TLI.LowerArguments(F, SDL->DAG, Args);
5716 TLI.LowerArguments(F, SDL->DAG, Args, SDL->DAG.getCurDebugLoc());
57155717
57165718 unsigned a = 0;
57175719 for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end();
739739 Entry.Node = Argument;
740740 Entry.Ty = (const Type *) Type::Int32Ty;
741741 Args.push_back(Entry);
742 // FIXME: is there useful debug info available here?
742743 std::pair CallResult =
743744 LowerCallTo(Chain, (const Type *) Type::Int32Ty, false, false, false, false,
744745 CallingConv::C, false,
745 DAG.getExternalSymbol("__tls_get_addr", PtrVT), Args, DAG);
746 DAG.getExternalSymbol("__tls_get_addr", PtrVT), Args, DAG,
747 DebugLoc::getUnknownLoc());
746748 return CallResult.first;
747749 }
748750
355355 bool RetSExt, bool RetZExt, bool isVarArg,
356356 bool isInreg, unsigned CallingConv,
357357 bool isTailCall, SDValue Callee,
358 ArgListTy &Args, SelectionDAG &DAG) {
358 ArgListTy &Args, SelectionDAG &DAG,
359 DebugLoc dl) {
359360 int NumBytes = 0;
360361 if (Args.size() > 6)
361362 NumBytes = (Args.size() - 6) * 8;
373374 // Promote the integer to 64 bits. If the input type is signed use a
374375 // sign extend, otherwise use a zero extend.
375376 if (Args[i].isSExt)
376 Args[i].Node = DAG.getNode(ISD::SIGN_EXTEND, MVT::i64, Args[i].Node);
377 Args[i].Node = DAG.getNode(ISD::SIGN_EXTEND, dl,
378 MVT::i64, Args[i].Node);
377379 else if (Args[i].isZExt)
378 Args[i].Node = DAG.getNode(ISD::ZERO_EXTEND, MVT::i64, Args[i].Node);
380 Args[i].Node = DAG.getNode(ISD::ZERO_EXTEND, dl,
381 MVT::i64, Args[i].Node);
379382 else
380 Args[i].Node = DAG.getNode(ISD::ANY_EXTEND, MVT::i64, Args[i].Node);
383 Args[i].Node = DAG.getNode(ISD::ANY_EXTEND, dl, MVT::i64, Args[i].Node);
381384 break;
382385 case MVT::i64:
383386 case MVT::f64:
401404 Ops.push_back(Chain);
402405 Ops.push_back(Callee);
403406 Ops.insert(Ops.end(), args_to_use.begin(), args_to_use.end());
404 SDValue TheCall = DAG.getNode(AlphaISD::CALL, RetVals, &Ops[0], Ops.size());
407 SDValue TheCall = DAG.getNode(AlphaISD::CALL, dl,
408 RetVals, &Ops[0], Ops.size());
405409 Chain = TheCall.getValue(RetTyVT != MVT::isVoid);
406410 Chain = DAG.getCALLSEQ_END(Chain, DAG.getIntPtrConstant(NumBytes, true),
407411 DAG.getIntPtrConstant(0, true), SDValue());
415419 AssertKind = ISD::AssertZext;
416420
417421 if (AssertKind != ISD::DELETED_NODE)
418 RetVal = DAG.getNode(AssertKind, MVT::i64, RetVal,
422 RetVal = DAG.getNode(AssertKind, dl, MVT::i64, RetVal,
419423 DAG.getValueType(RetTyVT));
420424
421 RetVal = DAG.getNode(ISD::TRUNCATE, RetTyVT, RetVal);
425 RetVal = DAG.getNode(ISD::TRUNCATE, dl, RetTyVT, RetVal);
422426 }
423427
424428 return std::make_pair(RetVal, Chain);
8686 virtual std::pair
8787 LowerCallTo(SDValue Chain, const Type *RetTy, bool RetSExt, bool RetZExt,
8888 bool isVarArg, bool isInreg, unsigned CC, bool isTailCall,
89 SDValue Callee, ArgListTy &Args, SelectionDAG &DAG);
89 SDValue Callee, ArgListTy &Args, SelectionDAG &DAG,
90 DebugLoc dl);
9091
9192 ConstraintType getConstraintType(const std::string &Constraint) const;
9293
112112 const Type *RetTy = Op.getNode()->getValueType(0).getTypeForMVT();
113113 std::pair CallInfo =
114114 TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false,
115 CallingConv::C, false, Callee, Args, DAG);
115 CallingConv::C, false, Callee, Args, DAG,
116 Op.getNode()->getDebugLoc());
116117
117118 return CallInfo.first;
118119 }
144144 }
145145
146146 void IA64TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG,
147 SmallVectorImpl &ArgValues) {
147 SmallVectorImpl &ArgValues,
148 DebugLoc dl) {
148149 //
149150 // add beautiful description of IA64 stack frame format
150151 // here (from intel 24535803.pdf most likely)
198199 argt = newroot = DAG.getCopyFromReg(DAG.getRoot(), argVreg[count],
199200 MVT::f64);
200201 if (I->getType() == Type::FloatTy)
201 argt = DAG.getNode(ISD::FP_ROUND, MVT::f32, argt,
202 argt = DAG.getNode(ISD::FP_ROUND, dl, MVT::f32, argt,
202203 DAG.getIntPtrConstant(0));
203204 break;
204205 case MVT::i1: // NOTE: as far as C abi stuff goes,
217218 argt = newroot =
218219 DAG.getCopyFromReg(DAG.getRoot(), argVreg[count], MVT::i64);
219220 if ( getValueType(I->getType()) != MVT::i64)
220 argt = DAG.getNode(ISD::TRUNCATE, getValueType(I->getType()),
221 argt = DAG.getNode(ISD::TRUNCATE, dl, getValueType(I->getType()),
221222 newroot);
222223 break;
223224 }
229230 // Create the SelectionDAG nodes corresponding to a load
230231 //from this parameter
231232 SDValue FIN = DAG.getFrameIndex(FI, MVT::i64);
232 argt = newroot = DAG.getLoad(getValueType(I->getType()),
233 argt = newroot = DAG.getLoad(getValueType(I->getType()), dl,
233234 DAG.getEntryNode(), FIN, NULL, 0);
234235 }
235236 ++count;
306307 bool RetSExt, bool RetZExt, bool isVarArg,
307308 bool isInreg, unsigned CallingConv,
308309 bool isTailCall, SDValue Callee,
309 ArgListTy &Args, SelectionDAG &DAG) {
310 ArgListTy &Args, SelectionDAG &DAG,
311 DebugLoc dl) {
310312
311313 MachineFunction &MF = DAG.getMachineFunction();
312314
359361 ExtendKind = ISD::SIGN_EXTEND;
360362 else if (Args[i].isZExt)
361363 ExtendKind = ISD::ZERO_EXTEND;
362 Val = DAG.getNode(ExtendKind, MVT::i64, Val);
364 Val = DAG.getNode(ExtendKind, dl, MVT::i64, Val);
363365 // XXX: fall through
364366 }
365367 case MVT::i64:
372374 break;
373375 case MVT::f32:
374376 //promote to 64-bits
375 Val = DAG.getNode(ISD::FP_EXTEND, MVT::f64, Val);
377 Val = DAG.getNode(ISD::FP_EXTEND, dl, MVT::f64, Val);
376378 // XXX: fall through
377379 case MVT::f64:
378380 if(RegValuesToPass.size() >= 8) {
391393 StackPtr = DAG.getRegister(IA64::r12, MVT::i64);
392394 }
393395 SDValue PtrOff = DAG.getConstant(ArgOffset, getPointerTy());
394 PtrOff = DAG.getNode(ISD::ADD, MVT::i64, StackPtr, PtrOff);
395 Stores.push_back(DAG.getStore(Chain, ValToStore, PtrOff, NULL, 0));
396 PtrOff = DAG.getNode(ISD::ADD, dl, MVT::i64, StackPtr, PtrOff);
397 Stores.push_back(DAG.getStore(Chain, dl, ValToStore, PtrOff, NULL, 0));
396398 ArgOffset += ObjSize;
397399 }
398400
399401 if(ValToConvert.getNode()) {
400 Converts.push_back(DAG.getNode(IA64ISD::GETFD, MVT::i64, ValToConvert));
402 Converts.push_back(DAG.getNode(IA64ISD::GETFD, dl,
403 MVT::i64, ValToConvert));
401404 }
402405 }
403406
404407 // Emit all stores, make sure they occur before any copies into physregs.
405408 if (!Stores.empty())
406 Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, &Stores[0],Stores.size());
409 Chain = DAG.getNode(ISD::TokenFactor, dl,
410 MVT::Other, &Stores[0],Stores.size());
407411
408412 static const unsigned IntArgRegs[] = {
409413 IA64::out0, IA64::out1, IA64::out2, IA64::out3,
476480 assert(0 && "this should never happen!\n");
477481
478482 // to make way for a hack:
479 Chain = DAG.getNode(IA64ISD::BRCALL, NodeTys,
483 Chain = DAG.getNode(IA64ISD::BRCALL, dl, NodeTys,
480484 &CallOperands[0], CallOperands.size());
481485 InFlag = Chain.getValue(1);
482486
507511 InFlag = zeroReg.getValue(2);
508512 Chain = zeroReg.getValue(1);
509513
510 RetVal = DAG.getSetCC(MVT::i1, boolInR8, zeroReg, ISD::SETNE);
514 RetVal = DAG.getSetCC(dl, MVT::i1, boolInR8, zeroReg, ISD::SETNE);
511515 break;
512516 }
513517 case MVT::i8:
519523 // keep track of whether it is sign or zero extended (todo: bools?)
520524 /* XXX
521525 RetVal = DAG.getNode(RetTy->isSigned() ? ISD::AssertSext :ISD::AssertZext,
522 MVT::i64, RetVal, DAG.getValueType(RetTyVT));
526 dl, MVT::i64, RetVal, DAG.getValueType(RetTyVT));
523527 */
524 RetVal = DAG.getNode(ISD::TRUNCATE, RetTyVT, RetVal);
528 RetVal = DAG.getNode(ISD::TRUNCATE, dl, RetTyVT, RetVal);
525529 break;
526530 case MVT::i64:
527531 RetVal = DAG.getCopyFromReg(Chain, IA64::r8, MVT::i64, InFlag);
531535 case MVT::f32:
532536 RetVal = DAG.getCopyFromReg(Chain, IA64::F8, MVT::f64, InFlag);
533537 Chain = RetVal.getValue(1);
534 RetVal = DAG.getNode(ISD::FP_ROUND, MVT::f32, RetVal,
538 RetVal = DAG.getNode(ISD::FP_ROUND, dl, MVT::f32, RetVal,
535539 DAG.getIntPtrConstant(0));
536540 break;
537541 case MVT::f64:
5353 /// LowerArguments - This hook must be implemented to indicate how we should
5454 /// lower the arguments for the specified function, into the specified DAG.
5555 virtual void LowerArguments(Function &F, SelectionDAG &DAG,
56 SmallVectorImpl &ArgValues);
56 SmallVectorImpl &ArgValues,
57 DebugLoc dl);
5758
5859 /// LowerCallTo - This hook lowers an abstract call to a function into an
5960 /// actual call.
6162 LowerCallTo(SDValue Chain, const Type *RetTy,
6263 bool RetSExt, bool RetZExt, bool isVarArg, bool isInreg,
6364 unsigned CC, bool isTailCall,
64 SDValue Callee, ArgListTy &Args, SelectionDAG &DAG);
65 SDValue Callee, ArgListTy &Args, SelectionDAG &DAG,
66 DebugLoc dl);
6567
6668 /// LowerOperation - for custom lowering specific ops
6769 /// (currently, only "ret void")
171171 PIC16TargetLowering::MakePIC16Libcall(PIC16ISD::PIC16Libcall Call,
172172 MVT RetVT, const SDValue *Ops,
173173 unsigned NumOps, bool isSigned,
174 SelectionDAG &DAG) {
174 SelectionDAG &DAG, DebugLoc dl) {
175175
176176 TargetLowering::ArgListTy Args;
177177 Args.reserve(NumOps);
189189 const Type *RetTy = RetVT.getTypeForMVT();
190190 std::pair CallInfo =
191191 LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false,
192 false, CallingConv::C, false, Callee, Args, DAG);
192 false, CallingConv::C, false, Callee, Args, DAG, dl);
193193
194194 return CallInfo.first;
195195 }
757757 SmallVector Ops(2);
758758 Ops[0] = Value;
759759 Ops[1] = Amt;
760 SDValue Call = MakePIC16Libcall(CallCode, N->getValueType(0), &Ops[0], 2, true, DAG);
760 SDValue Call = MakePIC16Libcall(CallCode, N->getValueType(0), &Ops[0], 2,
761 true, DAG, N->getDebugLoc());
761762 return Call;
762763 }
763764
167167 // Make PIC16 Libcall
168168 SDValue MakePIC16Libcall(PIC16ISD::PIC16Libcall Call, MVT RetVT,
169169 const SDValue *Ops, unsigned NumOps, bool isSigned,
170 SelectionDAG &DAG);
170 SelectionDAG &DAG, DebugLoc dl);
171171
172172 // Check if operation has a direct load operand.
173173 inline bool isDirectLoad(const SDValue Op);
12281228 SDValue Trmp = Op.getOperand(1); // trampoline
12291229 SDValue FPtr = Op.getOperand(2); // nested function
12301230 SDValue Nest = Op.getOperand(3); // 'nest' parameter value
1231 DebugLoc dl = Op.getNode()->getDebugLoc();
12311232
12321233 MVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy();
12331234 bool isPPC64 = (PtrVT == MVT::i64);
12531254 LowerCallTo(Chain, Op.getValueType().getTypeForMVT(), false, false,
12541255 false, false, CallingConv::C, false,
12551256 DAG.getExternalSymbol("__trampoline_setup", PtrVT),
1256 Args, DAG);
1257 Args, DAG, dl);
12571258
12581259 SDValue Ops[] =
12591260 { CallResult.first, CallResult.second };
7676 /// in FP registers for fastcc functions.
7777 void
7878 SparcTargetLowering::LowerArguments(Function &F, SelectionDAG &DAG,
79 SmallVectorImpl &ArgValues) {
79 SmallVectorImpl &ArgValues,
80 DebugLoc dl) {
8081 MachineFunction &MF = DAG.getMachineFunction();
8182 MachineRegisterInfo &RegInfo = MF.getRegInfo();
8283
5757 unsigned Depth = 0) const;
5858
5959 virtual void LowerArguments(Function &F, SelectionDAG &DAG,
60 SmallVectorImpl &ArgValues);
60 SmallVectorImpl &ArgValues,
61 DebugLoc dl);
6162 virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI,
6263 MachineBasicBlock *MBB);
6364
55315531 Args.push_back(Entry);
55325532 Entry.Node = Size;
55335533 Args.push_back(Entry);
5534 // FIXME provide DebugLoc info
55345535 std::pair CallResult =
55355536 LowerCallTo(Chain, Type::VoidTy, false, false, false, false,
55365537 CallingConv::C, false,
5537 DAG.getExternalSymbol(bzeroEntry, IntPtr), Args, DAG);
5538 DAG.getExternalSymbol(bzeroEntry, IntPtr), Args, DAG,
5539 DebugLoc::getUnknownLoc());
55385540 return CallResult.second;
55395541 }
55405542