mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 23:32:27 +00:00
Add an isTailCall flag to LowerCallTo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21958 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d71c04199c
commit
adf6a965a3
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user