mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-14 02:33:53 +00:00
Simplify LowerCallTo by using a callsite.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45198 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
481dc721c3
commit
6f74b48862
@ -499,9 +499,7 @@ public:
|
|||||||
unsigned Opc);
|
unsigned Opc);
|
||||||
bool isExportableFromCurrentBlock(Value *V, const BasicBlock *FromBB);
|
bool isExportableFromCurrentBlock(Value *V, const BasicBlock *FromBB);
|
||||||
void ExportFromCurrentBlock(Value *V);
|
void ExportFromCurrentBlock(Value *V);
|
||||||
void LowerCallTo(Instruction &I, const Type *CalledValueTy,
|
void LowerCallTo(CallSite CS, SDOperand Callee, bool IsTailCall,
|
||||||
const ParamAttrsList *PAL, unsigned CallingConv,
|
|
||||||
bool IsTailCall, SDOperand Callee, unsigned OpIdx,
|
|
||||||
MachineBasicBlock *LandingPad = NULL);
|
MachineBasicBlock *LandingPad = NULL);
|
||||||
|
|
||||||
// Terminator instructions.
|
// Terminator instructions.
|
||||||
@ -1452,11 +1450,7 @@ void SelectionDAGLowering::visitInvoke(InvokeInst &I) {
|
|||||||
if (isa<InlineAsm>(I.getCalledValue()))
|
if (isa<InlineAsm>(I.getCalledValue()))
|
||||||
visitInlineAsm(&I);
|
visitInlineAsm(&I);
|
||||||
else
|
else
|
||||||
LowerCallTo(I, I.getCalledValue()->getType(), I.getParamAttrs(),
|
LowerCallTo(&I, getValue(I.getOperand(0)), false, LandingPad);
|
||||||
I.getCallingConv(),
|
|
||||||
false,
|
|
||||||
getValue(I.getOperand(0)),
|
|
||||||
3, LandingPad);
|
|
||||||
|
|
||||||
// If the value of the invoke is used outside of its defining block, make it
|
// If the value of the invoke is used outside of its defining block, make it
|
||||||
// available as a virtual register.
|
// available as a virtual register.
|
||||||
@ -2922,39 +2916,35 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SelectionDAGLowering::LowerCallTo(Instruction &I,
|
void SelectionDAGLowering::LowerCallTo(CallSite CS, SDOperand Callee,
|
||||||
const Type *CalledValueTy,
|
|
||||||
const ParamAttrsList *Attrs,
|
|
||||||
unsigned CallingConv,
|
|
||||||
bool IsTailCall,
|
bool IsTailCall,
|
||||||
SDOperand Callee, unsigned OpIdx,
|
|
||||||
MachineBasicBlock *LandingPad) {
|
MachineBasicBlock *LandingPad) {
|
||||||
const PointerType *PT = cast<PointerType>(CalledValueTy);
|
const PointerType *PT = cast<PointerType>(CS.getCalledValue()->getType());
|
||||||
const FunctionType *FTy = cast<FunctionType>(PT->getElementType());
|
const FunctionType *FTy = cast<FunctionType>(PT->getElementType());
|
||||||
MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
|
MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
|
||||||
unsigned BeginLabel = 0, EndLabel = 0;
|
unsigned BeginLabel = 0, EndLabel = 0;
|
||||||
|
|
||||||
TargetLowering::ArgListTy Args;
|
TargetLowering::ArgListTy Args;
|
||||||
TargetLowering::ArgListEntry Entry;
|
TargetLowering::ArgListEntry Entry;
|
||||||
Args.reserve(I.getNumOperands());
|
Args.reserve(CS.arg_size());
|
||||||
for (unsigned i = OpIdx, e = I.getNumOperands(); i != e; ++i) {
|
for (CallSite::arg_iterator i = CS.arg_begin(), e = CS.arg_end();
|
||||||
Value *Arg = I.getOperand(i);
|
i != e; ++i) {
|
||||||
SDOperand ArgNode = getValue(Arg);
|
SDOperand ArgNode = getValue(*i);
|
||||||
Entry.Node = ArgNode; Entry.Ty = Arg->getType();
|
Entry.Node = ArgNode; Entry.Ty = (*i)->getType();
|
||||||
|
|
||||||
unsigned attrInd = i - OpIdx + 1;
|
unsigned attrInd = i - CS.arg_begin() + 1;
|
||||||
Entry.isSExt = Attrs && Attrs->paramHasAttr(attrInd, ParamAttr::SExt);
|
Entry.isSExt = CS.paramHasAttr(attrInd, ParamAttr::SExt);
|
||||||
Entry.isZExt = Attrs && Attrs->paramHasAttr(attrInd, ParamAttr::ZExt);
|
Entry.isZExt = CS.paramHasAttr(attrInd, ParamAttr::ZExt);
|
||||||
Entry.isInReg = Attrs && Attrs->paramHasAttr(attrInd, ParamAttr::InReg);
|
Entry.isInReg = CS.paramHasAttr(attrInd, ParamAttr::InReg);
|
||||||
Entry.isSRet = Attrs && Attrs->paramHasAttr(attrInd, ParamAttr::StructRet);
|
Entry.isSRet = CS.paramHasAttr(attrInd, ParamAttr::StructRet);
|
||||||
Entry.isNest = Attrs && Attrs->paramHasAttr(attrInd, ParamAttr::Nest);
|
Entry.isNest = CS.paramHasAttr(attrInd, ParamAttr::Nest);
|
||||||
Entry.isByVal = Attrs && Attrs->paramHasAttr(attrInd, ParamAttr::ByVal);
|
Entry.isByVal = CS.paramHasAttr(attrInd, ParamAttr::ByVal);
|
||||||
Args.push_back(Entry);
|
Args.push_back(Entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MarkTryRange = LandingPad ||
|
bool MarkTryRange = LandingPad ||
|
||||||
// C++ requires special handling of 'nounwind' calls.
|
// C++ requires special handling of 'nounwind' calls.
|
||||||
(Attrs && Attrs->paramHasAttr(0, ParamAttr::NoUnwind));
|
(CS.doesNotThrow());
|
||||||
|
|
||||||
if (MarkTryRange && ExceptionHandling && MMI) {
|
if (MarkTryRange && ExceptionHandling && MMI) {
|
||||||
// Insert a label before the invoke call to mark the try range. This can be
|
// Insert a label before the invoke call to mark the try range. This can be
|
||||||
@ -2963,14 +2953,14 @@ void SelectionDAGLowering::LowerCallTo(Instruction &I,
|
|||||||
DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),
|
DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),
|
||||||
DAG.getConstant(BeginLabel, MVT::i32)));
|
DAG.getConstant(BeginLabel, MVT::i32)));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<SDOperand,SDOperand> Result =
|
std::pair<SDOperand,SDOperand> Result =
|
||||||
TLI.LowerCallTo(getRoot(), I.getType(),
|
TLI.LowerCallTo(getRoot(), CS.getType(),
|
||||||
Attrs && Attrs->paramHasAttr(0, ParamAttr::SExt),
|
CS.paramHasAttr(0, ParamAttr::SExt),
|
||||||
FTy->isVarArg(), CallingConv, IsTailCall,
|
FTy->isVarArg(), CS.getCallingConv(), IsTailCall,
|
||||||
Callee, Args, DAG);
|
Callee, Args, DAG);
|
||||||
if (I.getType() != Type::VoidTy)
|
if (CS.getType() != Type::VoidTy)
|
||||||
setValue(&I, Result.first);
|
setValue(CS.getInstruction(), Result.first);
|
||||||
DAG.setRoot(Result.second);
|
DAG.setRoot(Result.second);
|
||||||
|
|
||||||
if (MarkTryRange && ExceptionHandling && MMI) {
|
if (MarkTryRange && ExceptionHandling && MMI) {
|
||||||
@ -2980,7 +2970,7 @@ void SelectionDAGLowering::LowerCallTo(Instruction &I,
|
|||||||
DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),
|
DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),
|
||||||
DAG.getConstant(EndLabel, MVT::i32)));
|
DAG.getConstant(EndLabel, MVT::i32)));
|
||||||
|
|
||||||
// Inform MachineModuleInfo of range.
|
// Inform MachineModuleInfo of range.
|
||||||
MMI->addInvoke(LandingPad, BeginLabel, EndLabel);
|
MMI->addInvoke(LandingPad, BeginLabel, EndLabel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3061,11 +3051,7 @@ void SelectionDAGLowering::visitCall(CallInst &I) {
|
|||||||
else
|
else
|
||||||
Callee = DAG.getExternalSymbol(RenameFn, TLI.getPointerTy());
|
Callee = DAG.getExternalSymbol(RenameFn, TLI.getPointerTy());
|
||||||
|
|
||||||
LowerCallTo(I, I.getCalledValue()->getType(), I.getParamAttrs(),
|
LowerCallTo(&I, Callee, I.isTailCall());
|
||||||
I.getCallingConv(),
|
|
||||||
I.isTailCall(),
|
|
||||||
Callee,
|
|
||||||
1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user