[PATCH] D35516: [GISel]: Split buildSources part of buildInstr separately
Aditya Nandakumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 24 09:32:18 PDT 2017
aditya_nandakumar updated this revision to Diff 107917.
aditya_nandakumar added a comment.
Add the ability to accept machine operands to the buildInstr method so it will directly call MIB.add(MO) on that.
https://reviews.llvm.org/D35516
Files:
include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
Index: include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
===================================================================
--- include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
+++ include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
@@ -70,12 +70,24 @@
return getMF().getRegInfo().createVirtualRegister(RC);
}
- unsigned getRegFromArg(unsigned Reg) { return Reg; }
+ void addUseFromArg(MachineInstrBuilder &MIB, unsigned Reg) {
+ MIB.addUse(Reg);
+ }
+
+ void addUseFromArg(MachineInstrBuilder &MIB, const MachineOperand &MO) {
+ MIB.add(MO);
+ }
- unsigned getRegFromArg(const MachineInstrBuilder &MIB) {
- return MIB->getOperand(0).getReg();
+ void addUseFromArg(MachineInstrBuilder &MIB, const MachineInstrBuilder &UseMIB) {
+ MIB.addUse(UseMIB->getOperand(0).getReg());
}
+ void buildSources(MachineInstrBuilder &MIB) { }
+ template<typename UseArgTy, typename ... UseArgsTy>
+ void buildSources(MachineInstrBuilder &MIB, UseArgTy &&Arg1, UseArgsTy &&... Args) {
+ addUseFromArg(MIB, Arg1);
+ buildSources(Args...);
+ }
public:
/// Getter for the function we currently build.
MachineFunction &getMF() {
@@ -146,9 +158,7 @@
MachineInstrBuilder buildInstr(unsigned Opc, DstTy &&Ty,
UseArgsTy &&... Args) {
auto MIB = buildInstr(Opc).addDef(getDestFromArg(Ty));
- unsigned It[] = {(getRegFromArg(Args))...};
- for (const auto &i : It)
- MIB.addUse(i);
+ buildSources(MIB, std::forward<UseArgsTy>(Args)...);
return MIB;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35516.107917.patch
Type: text/x-patch
Size: 1544 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170724/d97b8886/attachment.bin>
More information about the llvm-commits
mailing list