[PATCH] D72428: TableGen/GlobalISel: Address fixme

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 8 17:01:08 PST 2020


arsenm created this revision.
arsenm added reviewers: dsanders, paquette, aemerson, aditya_nandakumar.
Herald added subscribers: Petar.Avramovic, rovka, wdng.
Herald added a project: LLVM.

Don't call computeAvailableFunctionFeatures for every instruction.


https://reviews.llvm.org/D72428

Files:
  llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h
  llvm/utils/TableGen/GlobalISelEmitter.cpp


Index: llvm/utils/TableGen/GlobalISelEmitter.cpp
===================================================================
--- llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -5200,9 +5200,16 @@
                });
 
   SubtargetFeatureInfo::emitComputeAvailableFeatures(
-      Target.getName(), "InstructionSelector", "computeAvailableModuleFeatures",
+    Target.getName(), "InstructionSelector", "computeAvailableModuleFeatures",
       ModuleFeatures, OS);
 
+
+  OS << "void " << Target.getName() << "InstructionSelector"
+    "::setupGeneratedPerFunctionState(MachineFunction &MF) {\n"
+    "  AvailableFunctionFeatures = computeAvailableFunctionFeatures("
+    "(const " << Target.getName() << "Subtarget*)&MF.getSubtarget(), &MF);\n"
+    "}\n";
+
   if (Target.getName() == "X86" || Target.getName() == "AArch64") {
     // TODO: Implement PGSO.
     OS << "static bool shouldOptForSize(const MachineFunction *MF) {\n";
@@ -5354,10 +5361,6 @@
         "&CoverageInfo) const {\n"
      << "  MachineFunction &MF = *I.getParent()->getParent();\n"
      << "  MachineRegisterInfo &MRI = MF.getRegInfo();\n"
-     << "  // FIXME: This should be computed on a per-function basis rather "
-        "than per-insn.\n"
-     << "  AvailableFunctionFeatures = computeAvailableFunctionFeatures(&STI, "
-        "&MF);\n"
      << "  const PredicateBitset AvailableFeatures = getAvailableFeatures();\n"
      << "  NewMIVector OutMIs;\n"
      << "  State.MIs.clear();\n"
@@ -5393,6 +5396,7 @@
      << "computeAvailableFunctionFeatures(const " << Target.getName()
      << "Subtarget *Subtarget,\n"
      << "                                 const MachineFunction *MF) const;\n"
+     << "void setupGeneratedPerFunctionState(MachineFunction &MF) override;\n"
      << "#endif // ifdef GET_GLOBALISEL_PREDICATES_DECL\n";
 
   OS << "#ifdef GET_GLOBALISEL_PREDICATES_INIT\n"
Index: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h
===================================================================
--- llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h
+++ llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h
@@ -398,6 +398,10 @@
   GISelKnownBits *KnownBits = nullptr;
   MachineFunction *MF = nullptr;
 
+  virtual void setupGeneratedPerFunctionState(MachineFunction &MF) {
+    llvm_unreachable("TableGen should have emitted implementation");
+  }
+
   /// Setup per-MF selector state.
   virtual void setupMF(MachineFunction &mf,
                        GISelKnownBits &KB,
@@ -405,6 +409,7 @@
     CoverageInfo = &covinfo;
     KnownBits = &KB;
     MF = &mf;
+    setupGeneratedPerFunctionState(mf);
   }
 
 protected:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72428.236934.patch
Type: text/x-patch
Size: 2686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200109/4b199312/attachment.bin>


More information about the llvm-commits mailing list