[llvm] r297426 - [GlobalISel] Use ImmutableCallSite instead of templates. NFC.
Ahmed Bougacha via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 9 16:25:44 PST 2017
Author: ab
Date: Thu Mar 9 18:25:44 2017
New Revision: 297426
URL: http://llvm.org/viewvc/llvm-project?rev=297426&view=rev
Log:
[GlobalISel] Use ImmutableCallSite instead of templates. NFC.
ImmutableCallSite abstracts away CallInst and InvokeInst. Use it!
Modified:
llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h
llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp
llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h?rev=297426&r1=297425&r2=297426&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h Thu Mar 9 18:25:44 2017
@@ -177,11 +177,10 @@ public:
return false;
}
- /// This hook must be implemented to lower the given call instruction,
- /// including argument and return value marshalling.
+ /// Lower the given call instruction, including argument and return value
+ /// marshalling.
///
- /// \p CI is either a CallInst or InvokeInst reference (other instantiations
- /// will fail at link time).
+ /// \p CI is the call/invoke instruction.
///
/// \p ResReg is a register where the call's return value should be stored (or
/// 0 if there is no return value).
@@ -195,8 +194,7 @@ public:
/// range of an immediate jump.
///
/// \return true if the lowering succeeded, false otherwise.
- template <typename CallInstTy>
- bool lowerCall(MachineIRBuilder &MIRBuilder, const CallInstTy &CI,
+ bool lowerCall(MachineIRBuilder &MIRBuilder, ImmutableCallSite CS,
unsigned ResReg, ArrayRef<unsigned> ArgRegs,
std::function<unsigned()> GetCalleeReg) const;
};
Modified: llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp?rev=297426&r1=297425&r2=297426&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp Thu Mar 9 18:25:44 2017
@@ -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,
Modified: llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp?rev=297426&r1=297425&r2=297426&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp Thu Mar 9 18:25:44 2017
@@ -749,7 +749,7 @@ bool IRTranslator::translateCall(const U
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
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;
More information about the llvm-commits
mailing list