diff options
-rw-r--r-- | include/llvm/Target/TargetLowering.h | 4 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 11 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 7 | ||||
-rw-r--r-- | lib/Target/Alpha/AlphaISelPattern.cpp | 5 | ||||
-rw-r--r-- | lib/Target/IA64/IA64ISelPattern.cpp | 5 | ||||
-rw-r--r-- | lib/Target/PowerPC/PPC64ISelPattern.cpp | 5 | ||||
-rw-r--r-- | lib/Target/PowerPC/PPCISelPattern.cpp | 5 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelPattern.cpp | 12 |
8 files changed, 34 insertions, 20 deletions
diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 0d5637985a..4112db3b64 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -262,8 +262,8 @@ public: typedef std::vector<std::pair<SDOperand, const Type*> > ArgListTy; virtual std::pair<SDOperand, SDOperand> LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, - unsigned CallingConv, SDOperand Callee, ArgListTy &Args, - SelectionDAG &DAG) = 0; + unsigned CallingConv, bool isTailCall, SDOperand Callee, + ArgListTy &Args, SelectionDAG &DAG) = 0; /// LowerVAStart - This lowers the llvm.va_start intrinsic. If not /// implemented, this method prints a message and aborts. diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 14b4c5a4b2..91badeb2bd 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -18,6 +18,7 @@ #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/CallingConv.h" #include "llvm/Constants.h" #include <iostream> using namespace llvm; @@ -930,7 +931,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { } std::pair<SDOperand,SDOperand> CallResult = - TLI.LowerCallTo(Tmp1, Type::VoidTy, false, 0, + TLI.LowerCallTo(Tmp1, Type::VoidTy, false, CallingConv::C, false, DAG.getExternalSymbol(FnName, IntPtr), Args, DAG); Result = LegalizeOp(CallResult.second); break; @@ -1255,7 +1256,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { Args.push_back(std::make_pair(Tmp1, T)); // FIXME: should use ExpandLibCall! std::pair<SDOperand,SDOperand> CallResult = - TLI.LowerCallTo(DAG.getEntryNode(), T, false, 0, + TLI.LowerCallTo(DAG.getEntryNode(), T, false, CallingConv::C, true, DAG.getExternalSymbol(FnName, VT), Args, DAG); Result = LegalizeOp(CallResult.first); break; @@ -2107,7 +2108,8 @@ SDOperand SelectionDAGLegalize::ExpandLibCall(const char *Name, SDNode *Node, // Splice the libcall in wherever FindInputOutputChains tells us to. const Type *RetTy = MVT::getTypeForValueType(Node->getValueType(0)); std::pair<SDOperand,SDOperand> CallInfo = - TLI.LowerCallTo(InChain, RetTy, false, 0, Callee, Args, DAG); + TLI.LowerCallTo(InChain, RetTy, false, CallingConv::C, false, + Callee, Args, DAG); SpliceCallInto(CallInfo.second, OutChain); NeedsAnotherIteration = true; @@ -2204,7 +2206,8 @@ ExpandIntToFP(bool isSigned, MVT::ValueType DestTy, SDOperand Source) { const Type *RetTy = MVT::getTypeForValueType(DestTy); std::pair<SDOperand,SDOperand> CallResult = - TLI.LowerCallTo(InChain, RetTy, false, 0, Callee, Args, DAG); + TLI.LowerCallTo(InChain, RetTy, false, CallingConv::C, true, + Callee, Args, DAG); SpliceCallInto(CallResult.second, OutChain); return CallResult.first; diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 70ba42e03a..e088845daa 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -13,6 +13,7 @@ #define DEBUG_TYPE "isel" #include "llvm/CodeGen/SelectionDAGISel.h" +#include "llvm/CallingConv.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" @@ -774,7 +775,7 @@ void SelectionDAGLowering::visitCall(CallInst &I) { std::pair<SDOperand,SDOperand> Result = TLI.LowerCallTo(getRoot(), I.getType(), FTy->isVarArg(), I.getCallingConv(), - Callee, Args, DAG); + I.isTailCall(), Callee, Args, DAG); if (I.getType() != Type::VoidTy) setValue(&I, Result.first); DAG.setRoot(Result.second); @@ -799,7 +800,7 @@ void SelectionDAGLowering::visitMalloc(MallocInst &I) { Args.push_back(std::make_pair(Src, TLI.getTargetData().getIntPtrType())); std::pair<SDOperand,SDOperand> Result = - TLI.LowerCallTo(getRoot(), I.getType(), false, 0, + TLI.LowerCallTo(getRoot(), I.getType(), false, CallingConv::C, true, DAG.getExternalSymbol("malloc", IntPtr), Args, DAG); setValue(&I, Result.first); // Pointers always fit in registers @@ -812,7 +813,7 @@ void SelectionDAGLowering::visitFree(FreeInst &I) { TLI.getTargetData().getIntPtrType())); MVT::ValueType IntPtr = TLI.getPointerTy(); std::pair<SDOperand,SDOperand> Result = - TLI.LowerCallTo(getRoot(), Type::VoidTy, false, 0, + TLI.LowerCallTo(getRoot(), Type::VoidTy, false, CallingConv::C, true, DAG.getExternalSymbol("free", IntPtr), Args, DAG); DAG.setRoot(Result.second); } diff --git a/lib/Target/Alpha/AlphaISelPattern.cpp b/lib/Target/Alpha/AlphaISelPattern.cpp index 9a9e587c75..28930cefb4 100644 --- a/lib/Target/Alpha/AlphaISelPattern.cpp +++ b/lib/Target/Alpha/AlphaISelPattern.cpp @@ -119,7 +119,8 @@ namespace { /// actual call. virtual std::pair<SDOperand, SDOperand> LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, unsigned CC, - SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG); + bool isTailCall, SDOperand Callee, ArgListTy &Args, + SelectionDAG &DAG); virtual std::pair<SDOperand, SDOperand> LowerVAStart(SDOperand Chain, SelectionDAG &DAG); @@ -304,7 +305,7 @@ AlphaTargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) std::pair<SDOperand, SDOperand> AlphaTargetLowering::LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, - unsigned CallingConv, + unsigned CallingConv, bool isTailCall, SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG) { int NumBytes = 0; diff --git a/lib/Target/IA64/IA64ISelPattern.cpp b/lib/Target/IA64/IA64ISelPattern.cpp index 2005632555..f4c50c09fa 100644 --- a/lib/Target/IA64/IA64ISelPattern.cpp +++ b/lib/Target/IA64/IA64ISelPattern.cpp @@ -110,7 +110,8 @@ namespace { /// actual call. virtual std::pair<SDOperand, SDOperand> LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, unsigned CC, - SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG); + bool isTailCall, SDOperand Callee, ArgListTy &Args, + SelectionDAG &DAG); virtual std::pair<SDOperand, SDOperand> LowerVAStart(SDOperand Chain, SelectionDAG &DAG); @@ -310,7 +311,7 @@ IA64TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) { std::pair<SDOperand, SDOperand> IA64TargetLowering::LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, - unsigned CallingConv, + unsigned CallingConv, bool isTailCall, SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG) { diff --git a/lib/Target/PowerPC/PPC64ISelPattern.cpp b/lib/Target/PowerPC/PPC64ISelPattern.cpp index cfc8a5496d..ce74c58d2e 100644 --- a/lib/Target/PowerPC/PPC64ISelPattern.cpp +++ b/lib/Target/PowerPC/PPC64ISelPattern.cpp @@ -94,7 +94,8 @@ namespace { /// actual call. virtual std::pair<SDOperand, SDOperand> LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, unsigned CC, - SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG); + bool isTailCall, SDOperand Callee, ArgListTy &Args, + SelectionDAG &DAG); virtual std::pair<SDOperand, SDOperand> LowerVAStart(SDOperand Chain, SelectionDAG &DAG); @@ -237,7 +238,7 @@ PPC64TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) { std::pair<SDOperand, SDOperand> PPC64TargetLowering::LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, - unsigned CallingConv, + unsigned CallingConv, bool isTailCall, SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG) { // args_to_use will accumulate outgoing args for the ISD::CALL case in diff --git a/lib/Target/PowerPC/PPCISelPattern.cpp b/lib/Target/PowerPC/PPCISelPattern.cpp index 8a0f27b108..4eeaa24d2b 100644 --- a/lib/Target/PowerPC/PPCISelPattern.cpp +++ b/lib/Target/PowerPC/PPCISelPattern.cpp @@ -94,7 +94,8 @@ namespace { /// actual call. virtual std::pair<SDOperand, SDOperand> LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, unsigned CC, - SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG); + bool isTailCall, SDOperand Callee, ArgListTy &Args, + SelectionDAG &DAG); virtual std::pair<SDOperand, SDOperand> LowerVAStart(SDOperand Chain, SelectionDAG &DAG); @@ -281,7 +282,7 @@ PPC32TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) { std::pair<SDOperand, SDOperand> PPC32TargetLowering::LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, - unsigned CallingConv, + unsigned CallingConv, bool isTailCall, SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG) { // args_to_use will accumulate outgoing args for the ISD::CALL case in diff --git a/lib/Target/X86/X86ISelPattern.cpp b/lib/Target/X86/X86ISelPattern.cpp index a8e88818a8..cadc742ff4 100644 --- a/lib/Target/X86/X86ISelPattern.cpp +++ b/lib/Target/X86/X86ISelPattern.cpp @@ -45,6 +45,7 @@ namespace { class X86TargetLowering : public TargetLowering { int VarArgsFrameIndex; // FrameIndex for start of varargs area. int ReturnAddrIndex; // FrameIndex for return slot. + int BytesToPopOnReturn; // Number of bytes ret should pop. public: X86TargetLowering(TargetMachine &TM) : TargetLowering(TM) { // Set up the TargetLowering object. @@ -117,7 +118,8 @@ namespace { /// actual call. virtual std::pair<SDOperand, SDOperand> LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, unsigned CC, - SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG); + bool isTailCall, SDOperand Callee, ArgListTy &Args, + SelectionDAG &DAG); virtual std::pair<SDOperand, SDOperand> LowerVAStart(SDOperand Chain, SelectionDAG &DAG); @@ -154,6 +156,7 @@ X86TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) { std::pair<SDOperand, SDOperand> X86TargetLowering::LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg, unsigned CallingConv, + bool isTailCall, SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG) { assert((!isVarArg || CallingConv == CallingConv::C) && @@ -330,7 +333,8 @@ X86TargetLowering::LowerCCCCallTo(SDOperand Chain, const Type *RetTy, SDOperand TheCall = SDOperand(DAG.getCall(RetVals, Chain, Callee), 0); Chain = TheCall.getValue(RetTyVT != MVT::isVoid); Chain = DAG.getNode(ISD::CALLSEQ_END, MVT::Other, Chain, - DAG.getConstant(NumBytes, getPointerTy())); + DAG.getConstant(NumBytes, getPointerTy()), + DAG.getConstant(0, getPointerTy())); return std::make_pair(TheCall, Chain); } @@ -669,7 +673,9 @@ X86TargetLowering::LowerFastCCCallTo(SDOperand Chain, const Type *RetTy, RegValuesToPass), 0); Chain = TheCall.getValue(RetTyVT != MVT::isVoid); Chain = DAG.getNode(ISD::CALLSEQ_END, MVT::Other, Chain, - DAG.getConstant(NumBytes, getPointerTy())); + DAG.getConstant(NumBytes, getPointerTy()), + // The callee pops the arguments off the stack. + DAG.getConstant(ArgOffset, getPointerTy())); return std::make_pair(TheCall, Chain); } |