[llvm] [TableGen] Only store direct superclasses in Record (PR #123072)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 17 01:53:08 PST 2025


================
@@ -1718,15 +1719,30 @@ class Record {
   ArrayRef<AssertionInfo> getAssertions() const { return Assertions; }
   ArrayRef<DumpInfo> getDumps() const { return Dumps; }
 
-  ArrayRef<std::pair<const Record *, SMRange>> getSuperClasses() const {
-    return SuperClasses;
+  /// Append all superclasses in post-order to \p Classes.
+  void getSuperClasses(std::vector<const Record *> &Classes) const {
+    for (const auto &[SC, R] : DirectSuperClasses) {
+      SC->getSuperClasses(Classes);
+      Classes.push_back(SC);
+    }
+  }
+
+  /// Return all superclasses in post-order.
+  std::vector<const Record *> getSuperClasses() const {
+    std::vector<const Record *> Classes;
+    getSuperClasses(Classes);
+    return Classes;
   }
 
   /// Determine whether this record has the specified direct superclass.
-  bool hasDirectSuperClass(const Record *SuperClass) const;
+  bool hasDirectSuperClass(const Record *SuperClass) const {
+    return is_contained(make_first_range(DirectSuperClasses), SuperClass);
+  }
 
-  /// Append the direct superclasses of this record to Classes.
-  void getDirectSuperClasses(SmallVectorImpl<const Record *> &Classes) const;
+  /// Return the direct superclasses of this record.
+  ArrayRef<std::pair<const Record *, SMRange>> getDirectSuperClasses() const {
----------------
jayfoad wrote:

> It looks like no clients currently make use of the returned `SMRange`.

`CodeGenRegisters` uses it, but it looks like it is just trying to clone a Record, and there may be better ways to reimplement that.

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


More information about the llvm-commits mailing list