[PATCH] D54648: [TableGen] Emit more variant transitions

Evandro Menezes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 16 13:34:30 PST 2018


evandro created this revision.
evandro added a reviewer: andreadb.
Herald added a subscriber: llvm-commits.

`llvm-mca` relies on the predicates to be based on `MCSchedPredicate` in order to resolve the scheduling for variant instructions. Otherwise, it aborts the building of the instruction model early. However, the scheduling model emitter gives up unless all processors use only such predicates.

In order to allow more processors to be used with `llvm-mca`, this patch emits scheduling transitions if any processors uses these predicates. The transition emitted for the processors using legacy predicates is the one specified with `NoSchedPred`, which is based on `MCSchedPredicate`.


Repository:
  rL LLVM

https://reviews.llvm.org/D54648

Files:
  llvm/utils/TableGen/SubtargetEmitter.cpp


Index: llvm/utils/TableGen/SubtargetEmitter.cpp
===================================================================
--- llvm/utils/TableGen/SubtargetEmitter.cpp
+++ llvm/utils/TableGen/SubtargetEmitter.cpp
@@ -1504,9 +1504,9 @@
       continue;
 
     if (OnlyExpandMCInstPredicates) {
-      // Ignore this variant scheduling class if transitions don't uses any
+      // Ignore this variant scheduling class if no transitions use any
       // MCSchedPredicate definitions.
-      if (!all_of(SC.Transitions, [](const CodeGenSchedTransition &T) {
+      if (!any_of(SC.Transitions, [](const CodeGenSchedTransition &T) {
             return hasMCSchedPredicates(T);
           }))
         continue;
@@ -1560,6 +1560,7 @@
     PE.setExpandForMC(OnlyExpandMCInstPredicates);
     for (unsigned PI : ProcIndices) {
       OS << "    ";
+
       // Emit a guard on the processor ID.
       if (PI != 0) {
         OS << (OnlyExpandMCInstPredicates
@@ -1573,11 +1574,19 @@
       for (const CodeGenSchedTransition &T : SC.Transitions) {
         if (PI != 0 && !count(T.ProcIndices, PI))
           continue;
+
+        // Emit only transitions based on MCSchedPredicate, if it's the case.
+        // At least, the transition specified by NoSchedPred is emitted, since
+        // this class is based on MCSchedPredicate.
+        if (OnlyExpandMCInstPredicates && !hasMCSchedPredicates(T))
+          continue;
+
         PE.setIndentLevel(3);
         emitPredicates(T, SchedModels.getSchedClass(T.ToClassIdx), PE, OS);
       }
 
       OS << "    }\n";
+
       if (PI == 0)
         break;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54648.174443.patch
Type: text/x-patch
Size: 1600 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181116/797a4ac3/attachment.bin>


More information about the llvm-commits mailing list