[llvm] [TableGen] Add support for per-write cycle tunables (PR #125870)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 12 11:26:11 PST 2025


================
@@ -1308,23 +1308,30 @@ void SubtargetEmitter::genSchedClassTables(const CodeGenProcModel &ProcModel,
       }
       ConstRecVec ValidWrites =
           ReadAdvance->getValueAsListOfDefs("ValidWrites");
-      IdxVec WriteIDs;
+      std::vector<int64_t> CycleTunables =
+          ReadAdvance->getValueAsListOfInts("CycleTunables");
+      std::vector<std::pair<unsigned, int>> WriteIDs;
+      if (CycleTunables.size() > ValidWrites.size())
+        PrintFatalError(ReadAdvance->getLoc(),
+                        "If specified, CycleTunables must have at most the "
+                        "same number of elements of ValidWrites.\n");
+      CycleTunables.resize(ValidWrites.size(), 0);
       if (ValidWrites.empty())
-        WriteIDs.push_back(0);
+        WriteIDs.push_back(std::make_pair(0, 0));
       else {
-        for (const Record *VW : ValidWrites) {
+        for (const auto [VW, CT] : zip_equal(ValidWrites, CycleTunables)) {
           unsigned WriteID = SchedModels.getSchedRWIdx(VW, /*IsRead=*/false);
           assert(WriteID != 0 &&
                  "Expected a valid SchedRW in the list of ValidWrites");
-          WriteIDs.push_back(WriteID);
+          WriteIDs.push_back(std::make_pair(WriteID, CT));
----------------
topperc wrote:

use emplace_back to avoid the make_pair

https://github.com/llvm/llvm-project/pull/125870


More information about the llvm-commits mailing list