[PATCH] D81862: [gicombiner] Allow generated CombinerHelpers to have additional arguments
Daniel Sanders via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 16 14:21:52 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG28ebdf1a02eb: [gicombiner] Allow generated CombinerHelpers to have additional arguments (authored by dsanders).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81862/new/
https://reviews.llvm.org/D81862
Files:
llvm/include/llvm/Target/GlobalISel/Combine.td
llvm/utils/TableGen/GICombinerEmitter.cpp
Index: llvm/utils/TableGen/GICombinerEmitter.cpp
===================================================================
--- llvm/utils/TableGen/GICombinerEmitter.cpp
+++ llvm/utils/TableGen/GICombinerEmitter.cpp
@@ -841,6 +841,13 @@
OS << Indent << "return false;\n";
}
+static void emitAdditionalHelperMethodArguments(raw_ostream &OS,
+ Record *Combiner) {
+ for (Record *Arg : Combiner->getValueAsListOfDefs("AdditionalArguments"))
+ OS << ",\n " << Arg->getValueAsString("Type")
+ << Arg->getValueAsString("Name");
+}
+
void GICombinerEmitter::run(raw_ostream &OS) {
gatherRules(Rules, Combiner->getValueAsListOfDefs("Rules"));
if (StopAfterParse) {
@@ -901,9 +908,10 @@
<< " bool tryCombineAll(\n"
<< " GISelChangeObserver &Observer,\n"
<< " MachineInstr &MI,\n"
- << " MachineIRBuilder &B,\n"
- << " CombinerHelper &Helper) const;\n"
- << "};\n\n";
+ << " MachineIRBuilder &B";
+ emitAdditionalHelperMethodArguments(OS, Combiner);
+ OS << ") const;\n";
+ OS << "};\n\n";
emitNameMatcher(OS);
@@ -958,8 +966,9 @@
OS << "bool " << getClassName() << "::tryCombineAll(\n"
<< " GISelChangeObserver &Observer,\n"
<< " MachineInstr &MI,\n"
- << " MachineIRBuilder &B,\n"
- << " CombinerHelper &Helper) const {\n"
+ << " MachineIRBuilder &B";
+ emitAdditionalHelperMethodArguments(OS, Combiner);
+ OS << ") const {\n"
<< " MachineBasicBlock *MBB = MI.getParent();\n"
<< " MachineFunction *MF = MBB->getParent();\n"
<< " MachineRegisterInfo &MRI = MF->getRegInfo();\n"
Index: llvm/include/llvm/Target/GlobalISel/Combine.td
===================================================================
--- llvm/include/llvm/Target/GlobalISel/Combine.td
+++ llvm/include/llvm/Target/GlobalISel/Combine.td
@@ -27,6 +27,11 @@
let Rules = rules;
}
+class GICombinerHelperArg<string type, string name> {
+ string Type = type;
+ string Name = name;
+}
+
// Declares a combiner helper class
class GICombinerHelper<string classname, list<GICombine> rules>
: GICombineGroup<rules> {
@@ -35,6 +40,9 @@
// The name of a run-time compiler option that will be generated to disable
// specific rules within this combiner.
string DisableRuleOption = ?;
+ // Any additional arguments that should be appended to the tryCombine*().
+ list<GICombinerHelperArg> AdditionalArguments =
+ [GICombinerHelperArg<"CombinerHelper &", "Helper">];
}
class GICombineRule<dag defs, dag match, dag apply> : GICombine {
/// Defines the external interface of the match rule. This includes:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81862.271201.patch
Type: text/x-patch
Size: 2674 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200616/b7471363/attachment.bin>
More information about the llvm-commits
mailing list