[llvm] CodeGen: Eliminate dynamic relocations in the register superclass tables. (PR #119122)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 8 09:06:36 PST 2024


================
@@ -42,11 +42,27 @@ class VirtRegMap;
 class LiveIntervals;
 class LiveInterval;
 
+/// TargetSuperClassIterator enumerates all super-registers of RegClass.
+class TargetSuperClassIterator
+    : public iterator_adaptor_base<TargetSuperClassIterator, const unsigned *> {
+public:
+  /// Constructs an end iterator.
+  TargetSuperClassIterator() = default;
+
+  TargetSuperClassIterator(const unsigned *V) { I = V; }
+
+  const unsigned &operator*() const { return *I; }
----------------
s-barannikov wrote:

One way to do it is to move `superregclasses` to `TargetRegisterInfo` and pass the iterated class as an argument. (This is how similar `MCRegisterInfo` methods are implemented.)
Alternatively, pass `const TargetRegisterInfo &` to `superclasses` and then into the iterator constructor. Not sure if this is worse or better.

That is, it is possible, but since the main goal of this PR is to reduce the number of relocations I think it could be done separately.


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


More information about the llvm-commits mailing list