[llvm] 594d57e - [TableGen] New RegUnitSet(Name) constructor. NFC.

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 15 03:36:24 PST 2024


Author: Jay Foad
Date: 2024-02-15T11:35:52Z
New Revision: 594d57e07a92e3a2cefb262114db2608989f874d

URL: https://github.com/llvm/llvm-project/commit/594d57e07a92e3a2cefb262114db2608989f874d
DIFF: https://github.com/llvm/llvm-project/commit/594d57e07a92e3a2cefb262114db2608989f874d.diff

LOG: [TableGen] New RegUnitSet(Name) constructor. NFC.

Added: 
    

Modified: 
    llvm/utils/TableGen/CodeGenRegisters.cpp
    llvm/utils/TableGen/CodeGenRegisters.h

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/CodeGenRegisters.cpp b/llvm/utils/TableGen/CodeGenRegisters.cpp
index 5890f0f40e4059..40af0d3077b2de 100644
--- a/llvm/utils/TableGen/CodeGenRegisters.cpp
+++ b/llvm/utils/TableGen/CodeGenRegisters.cpp
@@ -1954,11 +1954,12 @@ void CodeGenRegBank::pruneUnitSets() {
       SuperSetIDs.push_back(SubIdx);
   }
   // Populate PrunedUnitSets with each equivalence class's superset.
-  std::vector<RegUnitSet> PrunedUnitSets(SuperSetIDs.size());
+  std::vector<RegUnitSet> PrunedUnitSets;
+  PrunedUnitSets.reserve(SuperSetIDs.size());
   for (unsigned i = 0, e = SuperSetIDs.size(); i != e; ++i) {
     unsigned SuperIdx = SuperSetIDs[i];
-    PrunedUnitSets[i].Name = RegUnitSets[SuperIdx].Name;
-    PrunedUnitSets[i].Units = std::move(RegUnitSets[SuperIdx].Units);
+    PrunedUnitSets.emplace_back(RegUnitSets[SuperIdx].Name);
+    PrunedUnitSets.back().Units = std::move(RegUnitSets[SuperIdx].Units);
   }
   RegUnitSets = std::move(PrunedUnitSets);
 }
@@ -1980,8 +1981,7 @@ void CodeGenRegBank::computeRegUnitSets() {
       continue;
 
     // Compute a sorted list of units in this class.
-    RegUnitSet RUSet;
-    RUSet.Name = RC.getName();
+    RegUnitSet RUSet(RC.getName());
     RC.buildRegUnitSet(*this, RUSet.Units);
 
     // Find an existing RegUnitSet.
@@ -2032,9 +2032,8 @@ void CodeGenRegBank::computeRegUnitSets() {
       if (Intersection.empty())
         continue;
 
-      RegUnitSet RUSet;
-      RUSet.Name =
-          RegUnitSets[Idx].Name + "_with_" + RegUnitSets[SearchIdx].Name;
+      RegUnitSet RUSet(RegUnitSets[Idx].Name + "_with_" +
+                       RegUnitSets[SearchIdx].Name);
       std::set_union(RegUnitSets[Idx].Units.begin(),
                      RegUnitSets[Idx].Units.end(),
                      RegUnitSets[SearchIdx].Units.begin(),

diff  --git a/llvm/utils/TableGen/CodeGenRegisters.h b/llvm/utils/TableGen/CodeGenRegisters.h
index 61e8e7c857e921..c34f376ea99db3 100644
--- a/llvm/utils/TableGen/CodeGenRegisters.h
+++ b/llvm/utils/TableGen/CodeGenRegisters.h
@@ -546,7 +546,7 @@ struct RegUnitSet {
   unsigned Weight = 0; // Cache the sum of all unit weights.
   unsigned Order = 0;  // Cache the sort key.
 
-  RegUnitSet() = default;
+  RegUnitSet(std::string Name) : Name(Name) {}
 };
 
 // Base vector for identifying TopoSigs. The contents uniquely identify a


        


More information about the llvm-commits mailing list