diff options
author | Ahmed Bougacha <ahmed.bougacha@gmail.com> | 2017-03-10 00:25:44 +0000 |
---|---|---|
committer | Ahmed Bougacha <ahmed.bougacha@gmail.com> | 2017-03-10 00:25:44 +0000 |
commit | a3782b7e75ef17565d53ee9716cfb48a0f7a40cb (patch) | |
tree | d082a560e7d2deef7ec85f1b1c91f0d2ff01db86 /lib/CodeGen | |
parent | 60bc0e71032b4eb746e8b4585e53c7cd6b867c4d (diff) | |
download | llvm-a3782b7e75ef17565d53ee9716cfb48a0f7a40cb.tar.gz |
[GlobalISel] Use ImmutableCallSite instead of templates. NFC.
ImmutableCallSite abstracts away CallInst and InvokeInst. Use it!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297426 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/GlobalISel/CallLowering.cpp | 27 | ||||
-rw-r--r-- | lib/CodeGen/GlobalISel/IRTranslator.cpp | 4 |
2 files changed, 10 insertions, 21 deletions
diff --git a/lib/CodeGen/GlobalISel/CallLowering.cpp b/lib/CodeGen/GlobalISel/CallLowering.cpp index 90427b27cd0f..e45ae4a77f29 100644 --- a/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -23,49 +23,38 @@ using namespace llvm; -template<typename CallInstTy> bool CallLowering::lowerCall( - MachineIRBuilder &MIRBuilder, const CallInstTy &CI, unsigned ResReg, + MachineIRBuilder &MIRBuilder, ImmutableCallSite CS, unsigned ResReg, ArrayRef<unsigned> ArgRegs, std::function<unsigned()> GetCalleeReg) const { - auto &DL = CI.getParent()->getParent()->getParent()->getDataLayout(); + auto &DL = CS.getParent()->getParent()->getParent()->getDataLayout(); // First step is to marshall all the function's parameters into the correct // physregs and memory locations. Gather the sequence of argument types that // we'll pass to the assigner function. SmallVector<ArgInfo, 8> OrigArgs; unsigned i = 0; - unsigned NumFixedArgs = CI.getFunctionType()->getNumParams(); - for (auto &Arg : CI.arg_operands()) { + unsigned NumFixedArgs = CS.getFunctionType()->getNumParams(); + for (auto &Arg : CS.args()) { ArgInfo OrigArg{ArgRegs[i], Arg->getType(), ISD::ArgFlagsTy{}, i < NumFixedArgs}; - setArgFlags(OrigArg, i + 1, DL, CI); + setArgFlags(OrigArg, i + 1, DL, CS); OrigArgs.push_back(OrigArg); ++i; } MachineOperand Callee = MachineOperand::CreateImm(0); - if (Function *F = CI.getCalledFunction()) + if (const Function *F = CS.getCalledFunction()) Callee = MachineOperand::CreateGA(F, 0); else Callee = MachineOperand::CreateReg(GetCalleeReg(), false); - ArgInfo OrigRet{ResReg, CI.getType(), ISD::ArgFlagsTy{}}; + ArgInfo OrigRet{ResReg, CS.getType(), ISD::ArgFlagsTy{}}; if (!OrigRet.Ty->isVoidTy()) - setArgFlags(OrigRet, AttributeSet::ReturnIndex, DL, CI); + setArgFlags(OrigRet, AttributeSet::ReturnIndex, DL, CS); return lowerCall(MIRBuilder, Callee, OrigRet, OrigArgs); } -template bool -CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const CallInst &CI, - unsigned ResReg, ArrayRef<unsigned> ArgRegs, - std::function<unsigned()> GetCalleeReg) const; - -template bool -CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, const InvokeInst &CI, - unsigned ResReg, ArrayRef<unsigned> ArgRegs, - std::function<unsigned()> GetCalleeReg) const; - template <typename FuncInfoTy> void CallLowering::setArgFlags(CallLowering::ArgInfo &Arg, unsigned OpIdx, const DataLayout &DL, diff --git a/lib/CodeGen/GlobalISel/IRTranslator.cpp b/lib/CodeGen/GlobalISel/IRTranslator.cpp index 1e8f6c222d71..b8bb71dcc2c9 100644 --- a/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -749,7 +749,7 @@ bool IRTranslator::translateCall(const User &U, MachineIRBuilder &MIRBuilder) { Args.push_back(getOrCreateVReg(*Arg)); MF->getFrameInfo().setHasCalls(true); - return CLI->lowerCall(MIRBuilder, CI, Res, Args, [&]() { + return CLI->lowerCall(MIRBuilder, &CI, Res, Args, [&]() { return getOrCreateVReg(*CI.getCalledValue()); }); } @@ -815,7 +815,7 @@ bool IRTranslator::translateInvoke(const User &U, for (auto &Arg: I.arg_operands()) Args.push_back(getOrCreateVReg(*Arg)); - if (!CLI->lowerCall(MIRBuilder, I, Res, Args, + if (!CLI->lowerCall(MIRBuilder, &I, Res, Args, [&]() { return getOrCreateVReg(*I.getCalledValue()); })) return false; |