[llvm] [TableGen] Introduce MatcherList to manage a linked list of Matchers. NFC (PR #177875)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 25 11:55:46 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-tablegen

Author: Craig Topper (topperc)

<details>
<summary>Changes</summary>

The previous memory management involved passing around references to the std::unique_ptr next pointer in each Matcher. Scopes and SwitchOpcode/SwitchType did not use std::unique_ptr internally, but would sometimes need to have the pointers to their children moved to temporary std::unique_ptrs that may be modified and then put back into the Scope/Switch. Other code used manual deletion.

This patch introduces a MatcherList object that encapsulates list management and ownership. The interface is based on std::forward_list using the libcxx implementation for reference.

Once a Matcher is added to a MatcherList it can only be in that list or spliced into another list. This ensures it is always owned by a list that will be responsible for deleting it.

Scope and SwitchOpcode/Type children are now MatcherLists rather than Matcher*. A nice side effect of this is that we no longer need a Size field in each Matcher to store the size of Scope/Switch children during emission. This field was only used for the Matcher that the Scope/Switch children pointed to. Now we can store it in the MatcherList instead.

There is no change to the generated output.

There's still a little bit of cleanup that can be done. For example, renaming "TheMatcher" and merging FactorScope and FactorNodes together. This patch is large enough so these will be follow ups.

---

Patch is 63.76 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/177875.diff


6 Files Affected:

- (modified) llvm/utils/TableGen/DAGISelEmitter.cpp (+8-8) 
- (modified) llvm/utils/TableGen/DAGISelMatcher.cpp (+15-61) 
- (modified) llvm/utils/TableGen/DAGISelMatcher.h (+277-59) 
- (modified) llvm/utils/TableGen/DAGISelMatcherEmitter.cpp (+43-48) 
- (modified) llvm/utils/TableGen/DAGISelMatcherGen.cpp (+14-17) 
- (modified) llvm/utils/TableGen/DAGISelMatcherOpt.cpp (+224-203) 


``````````diff
diff --git a/llvm/utils/TableGen/DAGISelEmitter.cpp b/llvm/utils/TableGen/DAGISelEmitter.cpp
index dc66967584f71..a7deaa1dd5dfd 100644
--- a/llvm/utils/TableGen/DAGISelEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelEmitter.cpp
@@ -193,26 +193,26 @@ void DAGISelEmitter::run(raw_ostream &OS) {
 
   // Convert each variant of each pattern into a Matcher.
   Timer.startTimer("Convert to matchers");
-  SmallVector<Matcher *, 0> PatternMatchers;
+  SmallVector<MatcherList, 0> PatternMatchers;
   for (const PatternToMatch *PTM : Patterns) {
     for (unsigned Variant = 0;; ++Variant) {
-      if (Matcher *M = ConvertPatternToMatcher(*PTM, Variant, CGP))
-        PatternMatchers.push_back(M);
-      else
+      MatcherList ML = ConvertPatternToMatcher(*PTM, Variant, CGP);
+      if (ML.empty())
         break;
+      PatternMatchers.push_back(std::move(ML));
     }
   }
 
-  std::unique_ptr<Matcher> TheMatcher =
-      std::make_unique<ScopeMatcher>(std::move(PatternMatchers));
+  MatcherList Matchers;
+  Matchers.push_front(new ScopeMatcher(std::move(PatternMatchers)));
 
   Timer.startTimer("Optimize matchers");
-  OptimizeMatcher(TheMatcher, CGP);
+  OptimizeMatcher(Matchers, CGP);
 
   // Matcher->dump();
 
   Timer.startTimer("Emit matcher table");
-  EmitMatcherTable(TheMatcher.get(), CGP, OS);
+  EmitMatcherTable(Matchers, CGP, OS);
 }
 
 static TableGen::Emitter::OptClass<DAGISelEmitter>
diff --git a/llvm/utils/TableGen/DAGISelMatcher.cpp b/llvm/utils/TableGen/DAGISelMatcher.cpp
index 0178998ab1ae2..05c6384409f10 100644
--- a/llvm/utils/TableGen/DAGISelMatcher.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcher.cpp
@@ -17,48 +17,10 @@ using namespace llvm;
 
 void Matcher::anchor() {}
 
-void Matcher::dump() const { print(errs()); }
-
-void Matcher::print(raw_ostream &OS, indent Indent) const {
-  printImpl(OS, Indent);
-  if (Next)
-    return Next->print(OS, Indent);
-}
-
-void Matcher::printOne(raw_ostream &OS) const { printImpl(OS, indent(0)); }
-
-/// unlinkNode - Unlink the specified node from this chain.  If Other == this,
-/// we unlink the next pointer and return it.  Otherwise we unlink Other from
-/// the list and return this.
-Matcher *Matcher::unlinkNode(Matcher *Other) {
-  if (this == Other)
-    return takeNext();
-
-  // Scan until we find the predecessor of Other.
-  Matcher *Cur = this;
-  for (; Cur && Cur->getNext() != Other; Cur = Cur->getNext())
-    /*empty*/;
-
-  if (!Cur)
-    return nullptr;
-  Cur->takeNext();
-  Cur->setNext(Other->takeNext());
-  return this;
-}
-
-/// canMoveBefore - Return true if this matcher is the same as Other, or if
-/// we can move this matcher past all of the nodes in-between Other and this
-/// node.  Other must be equal to or before this.
-bool Matcher::canMoveBefore(const Matcher *Other) const {
-  for (;; Other = Other->getNext()) {
-    assert(Other && "Other didn't come before 'this'?");
-    if (this == Other)
-      return true;
+void Matcher::dump() const { printOne(errs()); }
 
-    // We have to be able to move this node across the Other node.
-    if (!canMoveBeforeNode(Other))
-      return false;
-  }
+void Matcher::printOne(raw_ostream &OS, indent Indent) const {
+  printImpl(OS, indent(0));
 }
 
 /// canMoveBeforeNode - Return true if it is safe to move the current matcher
@@ -76,21 +38,6 @@ bool Matcher::canMoveBeforeNode(const Matcher *Other) const {
   return false;
 }
 
-ScopeMatcher::~ScopeMatcher() {
-  for (Matcher *C : Children)
-    delete C;
-}
-
-SwitchOpcodeMatcher::~SwitchOpcodeMatcher() {
-  for (auto &C : Cases)
-    delete C.second;
-}
-
-SwitchTypeMatcher::~SwitchTypeMatcher() {
-  for (auto &C : Cases)
-    delete C.second;
-}
-
 CheckPredicateMatcher::CheckPredicateMatcher(const TreePredicateFn &pred,
                                              ArrayRef<unsigned> Ops)
     : Matcher(CheckPredicate), Pred(pred.getOrigPatFragRecord()),
@@ -113,11 +60,11 @@ unsigned CheckPredicateMatcher::getOperandNo(unsigned i) const {
 
 void ScopeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
   OS << Indent << "Scope\n";
-  for (const Matcher *C : Children) {
-    if (!C)
+  for (const MatcherList &C : Children) {
+    if (C.empty())
       OS << Indent + 1 << "NULL POINTER\n";
     else
-      C->print(OS, Indent + 2);
+      C.print(OS, Indent + 2);
   }
 }
 
@@ -174,7 +121,7 @@ void SwitchOpcodeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
   OS << Indent << "SwitchOpcode: {\n";
   for (const auto &C : Cases) {
     OS << Indent << "case " << C.first->getEnumName() << ":\n";
-    C.second->print(OS, Indent + 2);
+    C.second.print(OS, Indent + 2);
   }
   OS << Indent << "}\n";
 }
@@ -187,7 +134,7 @@ void SwitchTypeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
   OS << Indent << "SwitchType: {\n";
   for (const auto &C : Cases) {
     OS << Indent << "case " << getEnumName(C.first) << ":\n";
-    C.second->print(OS, Indent + 2);
+    C.second.print(OS, Indent + 2);
   }
   OS << Indent << "}\n";
 }
@@ -447,3 +394,10 @@ bool CheckChild2CondCodeMatcher::isContradictoryImpl(const Matcher *M) const {
     return CCCCM->getCondCodeName() != getCondCodeName();
   return false;
 }
+
+void MatcherList::print(raw_ostream &OS, indent Indent) const {
+  for (const Matcher *M : *this)
+    M->printOne(OS, Indent);
+}
+
+void MatcherList::dump() const { print(errs()); }
diff --git a/llvm/utils/TableGen/DAGISelMatcher.h b/llvm/utils/TableGen/DAGISelMatcher.h
index 40de956a3646b..99d030741e6f7 100644
--- a/llvm/utils/TableGen/DAGISelMatcher.h
+++ b/llvm/utils/TableGen/DAGISelMatcher.h
@@ -26,6 +26,7 @@ class CodeGenRegister;
 class CodeGenDAGPatterns;
 class CodeGenInstruction;
 class Matcher;
+class MatcherList;
 class PatternToMatch;
 class raw_ostream;
 class ComplexPattern;
@@ -34,21 +35,25 @@ class SDNodeInfo;
 class TreePredicateFn;
 class TreePattern;
 
-Matcher *ConvertPatternToMatcher(const PatternToMatch &Pattern,
-                                 unsigned Variant,
-                                 const CodeGenDAGPatterns &CGP);
-void OptimizeMatcher(std::unique_ptr<Matcher> &Matcher,
-                     const CodeGenDAGPatterns &CGP);
-void EmitMatcherTable(Matcher *Matcher, const CodeGenDAGPatterns &CGP,
+MatcherList ConvertPatternToMatcher(const PatternToMatch &Pattern,
+                                    unsigned Variant,
+                                    const CodeGenDAGPatterns &CGP);
+void OptimizeMatcher(MatcherList &ML, const CodeGenDAGPatterns &CGP);
+void EmitMatcherTable(MatcherList &ML, const CodeGenDAGPatterns &CGP,
                       raw_ostream &OS);
 
+/// Base class that holds a pointer to the next entry in the MatcherList.
+/// Separated from Matcher so that we can have an instance of it in
+/// MatcherList.
+class MatcherBase {
+  friend class MatcherList;
+
+  MatcherBase *Next = nullptr;
+};
+
 /// Matcher - Base class for all the DAG ISel Matcher representation
 /// nodes.
-class Matcher {
-  // The next matcher node that is executed after this one.  Null if this is
-  // the last stage of a match.
-  std::unique_ptr<Matcher> Next;
-  size_t Size = 0; // Size in bytes of matcher and all its children (if any).
+class Matcher : public MatcherBase {
   virtual void anchor();
 
 public:
@@ -107,17 +112,8 @@ class Matcher {
 public:
   virtual ~Matcher() = default;
 
-  unsigned getSize() const { return Size; }
-  void setSize(unsigned sz) { Size = sz; }
   KindTy getKind() const { return Kind; }
 
-  Matcher *getNext() { return Next.get(); }
-  const Matcher *getNext() const { return Next.get(); }
-  void setNext(Matcher *C) { Next.reset(C); }
-  Matcher *takeNext() { return Next.release(); }
-
-  std::unique_ptr<Matcher> &getNextPtr() { return Next; }
-
   bool isEqual(const Matcher *M) const {
     if (getKind() != M->getKind())
       return false;
@@ -159,16 +155,6 @@ class Matcher {
            getKind() == RecordChild;
   }
 
-  /// unlinkNode - Unlink the specified node from this chain.  If Other ==
-  /// this, we unlink the next pointer and return it.  Otherwise we unlink
-  /// Other from the list and return this.
-  Matcher *unlinkNode(Matcher *Other);
-
-  /// canMoveBefore - Return true if this matcher is the same as Other, or if
-  /// we can move this matcher past all of the nodes in-between Other and this
-  /// node.  Other must be equal to or before this.
-  bool canMoveBefore(const Matcher *Other) const;
-
   /// canMoveBeforeNode - Return true if it is safe to move the current
   /// matcher across the specified one.
   bool canMoveBeforeNode(const Matcher *Other) const;
@@ -185,8 +171,7 @@ class Matcher {
     return Other->isContradictoryImpl(this);
   }
 
-  void print(raw_ostream &OS, indent Indent = indent(0)) const;
-  void printOne(raw_ostream &OS) const;
+  void printOne(raw_ostream &OS, indent Indent = indent(0)) const;
   void dump() const;
 
 protected:
@@ -195,34 +180,265 @@ class Matcher {
   virtual bool isContradictoryImpl(const Matcher *M) const { return false; }
 };
 
+/// Manages a singly linked list of Matcher objects. Interface based on
+/// std::forward_list. Once a Matcher is added to a list, it cannot be removed.
+/// It can only be erased or spliced to another position in this list or another
+/// list.
+class MatcherList {
+  MatcherBase BeforeBegin;
+
+  // Emitted size of all of the nodes in this list.
+  unsigned Size = 0;
+
+public:
+  MatcherList() = default;
+  MatcherList(const MatcherList &RHS) = delete;
+  MatcherList(MatcherList &&RHS) {
+    splice_after(before_begin(), RHS);
+    RHS.Size = 0;
+  }
+  ~MatcherList() { clear(); }
+
+  MatcherList &operator=(const MatcherList &) = delete;
+  MatcherList &operator=(MatcherList &&RHS) {
+    clear();
+    splice_after(before_begin(), RHS);
+    Size = RHS.Size;
+    RHS.Size = 0;
+    return *this;
+  }
+
+  void clear() {
+    for (MatcherBase *P = BeforeBegin.Next; P != nullptr;) {
+      MatcherBase *Next = P->Next;
+      delete static_cast<Matcher *>(P);
+      P = Next;
+    }
+    BeforeBegin.Next = nullptr;
+    Size = 0;
+  }
+
+  class iterator {
+    friend class MatcherList;
+
+    MatcherBase *Pointer;
+
+    explicit iterator(MatcherBase *P) { Pointer = P; }
+
+  public:
+    using iterator_category = std::forward_iterator_tag;
+    using value_type = Matcher *;
+    using difference_type = std::ptrdiff_t;
+    using pointer = value_type *;
+    using reference = value_type &;
+
+    iterator &operator++() {
+      Pointer = Pointer->Next;
+      return *this;
+    }
+
+    iterator operator++(int) {
+      iterator Tmp(*this);
+      Pointer = Pointer->Next;
+      return Tmp;
+    }
+
+    Matcher *operator*() const { return static_cast<Matcher *>(Pointer); }
+
+    Matcher *operator->() const { return operator*(); }
+
+    bool operator==(const iterator &X) const { return Pointer == X.Pointer; }
+    bool operator!=(const iterator &X) const { return !operator==(X); }
+  };
+
+  class const_iterator {
+    friend class MatcherList;
+
+    const MatcherBase *Pointer;
+
+    explicit const_iterator(const MatcherBase *P) { Pointer = P; }
+
+  public:
+    using iterator_category = std::forward_iterator_tag;
+    using value_type = Matcher *;
+    using difference_type = std::ptrdiff_t;
+    using pointer = value_type *;
+    using reference = value_type &;
+
+    const_iterator(iterator I) : Pointer(I.Pointer) {}
+
+    const_iterator &operator++() {
+      Pointer = Pointer->Next;
+      return *this;
+    }
+
+    const_iterator operator++(int) {
+      const_iterator Tmp(*this);
+      Pointer = Pointer->Next;
+      return Tmp;
+    }
+
+    const Matcher *operator*() const {
+      return static_cast<const Matcher *>(Pointer);
+    }
+
+    const Matcher *operator->() const { return operator*(); }
+
+    bool operator==(const const_iterator &X) const {
+      return Pointer == X.Pointer;
+    }
+    bool operator!=(const const_iterator &X) const { return !operator==(X); }
+  };
+
+  /// Return an iterator before the first Matcher in the list. This iterator
+  /// cannot be dereferenced. Incrementing returns the iterator to begin().
+  iterator before_begin() { return iterator(&BeforeBegin); }
+  const_iterator before_begin() const { return const_iterator(&BeforeBegin); }
+
+  iterator begin() { return iterator(BeforeBegin.Next); }
+  const_iterator begin() const { return const_iterator(BeforeBegin.Next); }
+
+  iterator end() { return iterator(nullptr); }
+  const_iterator end() const { return const_iterator(nullptr); }
+
+  Matcher *front() { return *begin(); }
+  const Matcher *front() const { return *begin(); }
+
+  bool empty() const { return BeforeBegin.Next == nullptr; }
+
+  void push_front(Matcher *M) { insert_after(before_begin(), M); }
+
+  /// Delete the first Matcher from the list.
+  void pop_front() {
+    assert(Size == 0 && "Should not modify list once size is set");
+    assert(!empty());
+    Matcher *N = *std::next(before_begin());
+    before_begin()->Next = N->Next;
+    delete N;
+  }
+
+  /// Insert the matcher \p N into this list after \p Pos.
+  iterator insert_after(iterator Pos, Matcher *N) {
+    assert(Size == 0 && "Should not modify list once size is set");
+    N->Next = Pos->Next;
+    Pos->Next = N;
+    return iterator(N);
+  }
+
+  /// Insert Matchers in the range [F, L) into this list.
+  template <class InIt> iterator insert_after(iterator Pos, InIt F, InIt L) {
+    MatcherBase *R = *Pos;
+    if (F != L) {
+      MatcherBase *First = *F;
+      MatcherBase *Last = First;
+
+      // Link the Matchers together.
+      for (++F; F != L; ++F, Last = Last->Next)
+        Last->Next = *F;
+
+      // Insert them into the list.
+      Last->Next = R->Next;
+      R->Next = First;
+      R = Last;
+    }
+
+    return iterator(R);
+  }
+
+  /// Insert multiple matchers into this list.
+  iterator insert_after(iterator Pos, std::initializer_list<Matcher *> IL) {
+    return insert_after(Pos, IL.begin(), IL.end());
+  }
+
+  /// Erase the Matcher after \p Pos.
+  iterator erase_after(iterator Pos) {
+    assert(Size == 0 && "Should not modify list once size is set");
+    Matcher *N = *std::next(Pos);
+    Pos->Next = N->Next;
+    delete N;
+    return iterator(Pos->Next);
+  }
+
+  iterator erase_after(iterator F, iterator L) {
+    Matcher *E = *L;
+    if (F != L) {
+      Matcher *N = *std::next(F);
+      if (N != E) {
+        F->Next = E;
+        do {
+          Matcher *Tmp = static_cast<Matcher *>(N->Next);
+          delete N;
+          N = Tmp;
+        } while (N != E);
+      }
+    }
+    return iterator(E);
+  }
+
+  /// Splice the contents of list \p X after \p Pos in this list.
+  void splice_after(iterator Pos, MatcherList &X) {
+    assert(Size == 0 && "Should not modify list once size is set");
+    if (!X.empty()) {
+      if (Pos->Next != nullptr) {
+        auto LM1 = X.before_begin();
+        while (LM1->Next != nullptr)
+          ++LM1;
+        LM1->Next = Pos->Next;
+      }
+      Pos->Next = X.before_begin()->Next;
+      X.before_begin()->Next = nullptr;
+    }
+  }
+
+  /// Splice the Matcher after \p I into this list after \p Pos.
+  void splice_after(iterator Pos, MatcherList &, iterator I) {
+    assert(Size == 0 && "Should not modify list once size is set");
+    auto LM1 = std::next(I);
+    if (Pos != I && Pos != LM1) {
+      I->Next = LM1->Next;
+      LM1->Next = Pos->Next;
+      Pos->Next = LM1.Pointer;
+    }
+  }
+
+  /// Splice the Matchers in the range (\p F, \p L) into this list after \p Pos.
+  void splice_after(iterator Pos, MatcherList &, iterator F, iterator L) {
+    assert(Size == 0 && "Should not modify list once size is set");
+    if (F != L && Pos != F) {
+      auto LM1 = F;
+      while (std::next(LM1) != L)
+        ++LM1;
+      if (F != LM1) {
+        LM1->Next = Pos->Next;
+        Pos->Next = F->Next;
+        F->Next = L.Pointer;
+      }
+    }
+  }
+
+  void setSize(unsigned Sz) { Size = Sz; }
+  unsigned getSize() const { return Size; }
+
+  void print(raw_ostream &OS, indent Indent = indent(0)) const;
+  void dump() const;
+};
+
 /// ScopeMatcher - This attempts to match each of its children to find the first
 /// one that successfully matches.  If one child fails, it tries the next child.
 /// If none of the children match then this check fails.  It never has a 'next'.
 class ScopeMatcher : public Matcher {
-  SmallVector<Matcher *, 4> Children;
+  SmallVector<MatcherList, 4> Children;
 
 public:
-  ScopeMatcher(SmallVectorImpl<Matcher *> &&children)
+  ScopeMatcher(SmallVectorImpl<MatcherList> &&children)
       : Matcher(Scope), Children(std::move(children)) {}
-  ~ScopeMatcher() override;
 
   unsigned getNumChildren() const { return Children.size(); }
 
-  Matcher *getChild(unsigned i) { return Children[i]; }
-  const Matcher *getChild(unsigned i) const { return Children[i]; }
-
-  void resetChild(unsigned i, Matcher *N) {
-    delete Children[i];
-    Children[i] = N;
-  }
-
-  Matcher *takeChild(unsigned i) {
-    Matcher *Res = Children[i];
-    Children[i] = nullptr;
-    return Res;
-  }
+  MatcherList &getChild(unsigned i) { return Children[i]; }
+  const MatcherList &getChild(unsigned i) const { return Children[i]; }
 
-  SmallVectorImpl<Matcher *> &getChildren() { return Children; }
+  SmallVectorImpl<MatcherList> &getChildren() { return Children; }
 
   static bool classof(const Matcher *N) { return N->getKind() == Scope; }
 
@@ -486,21 +702,22 @@ class CheckOpcodeMatcher : public Matcher {
 /// then the match fails.  This is semantically equivalent to a Scope node where
 /// every child does a CheckOpcode, but is much faster.
 class SwitchOpcodeMatcher : public Matcher {
-  SmallVector<std::pair<const SDNodeInfo *, Matcher *>, 8> Cases;
+  SmallVector<std::pair<const SDNodeInfo *, MatcherList>, 8> Cases;
 
 public:
   SwitchOpcodeMatcher(
-      SmallVectorImpl<std::pair<const SDNodeInfo *, Matcher *>> &&cases)
+      SmallVectorImpl<std::pair<const SDNodeInfo *, MatcherList>> &&cases)
       : Matcher(SwitchOpcode), Cases(std::move(cases)) {}
-  ~SwitchOpcodeMatcher() override;
 
   static bool classof(const Matcher *N) { return N->getKind() == SwitchOpcode; }
 
   unsigned getNumCases() const { return Cases.size(); }
 
   const SDNodeInfo &getCaseOpcode(unsigned i) const { return *Cases[i].first; }
-  Matcher *getCaseMatcher(unsigned i) { return Cases[i].second; }
-  const Matcher *getCaseMatcher(unsigned i) const { return Cases[i].second; }
+  MatcherList &getCaseMatcher(unsigned i) { return Cases[i].second; }
+  const MatcherList &getCaseMatcher(unsigned i) const {
+    return Cases[i].second;
+  }
 
 private:
   void printImpl(raw_ostream &OS, indent Indent) const override;
@@ -535,20 +752,21 @@ class CheckTypeMatcher : public Matcher {
 /// then the match fails.  This is semantically equivalent to a Scope node where
 /// every child does a CheckType, but is much faster.
 class SwitchTypeMatcher : public Matcher {
-  SmallVector<std::pair<MVT, Matcher *>, 8> Cases;
+  SmallVector<std::pair<MVT, MatcherList>, 8> Cases;
 
 public:
-  SwitchTypeMatcher(SmallVectorImpl<std::pair<MVT, Matcher *>> &&cases)
+  SwitchTypeMatcher(SmallVectorImpl<std::pair<MVT, MatcherList>> &&cases)
       : Matcher(SwitchType), Cases(std::move(cases)) {}
-  ~SwitchTypeMatcher() override;
 
   static bool classof(const Matcher *N) { return N->getKind() == SwitchType; }
 
   unsigned getNumCases() const { return Cases.size(); }
 
   MVT getCaseType(unsigned i) const { return Cases[i].first; }
-  Matcher *getCaseMatcher(unsigned i) { return Cases[i].second; }
-  const Matcher *getCaseMatcher(unsigned i) const { return Cases[i].second; }
+  MatcherList &getCaseMatcher(unsigned i) { return Cases[i].second; }
+  const MatcherList &getCaseMatcher(unsigned i) const {
+    return Cases[i].second;
+  }
 
 private:
   void printImpl(raw_ostream &OS, indent Indent) const override;
diff --git a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
index 0ab19d686714f..356b73f0b460a 100644
--- a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -84,7 +84,8 @@ class MatcherTableEmitter {
   }
 
 public:
-  MatcherTableEmitter(const Matcher *TheMatcher, const CodeGenDAGPatterns &cgp)
+  MatcherTableEmitter(const MatcherList &TheMatcher,
+                      const CodeGenDAGPatterns &cgp)
       : CGP(cgp), OpcodeCounts(Matcher::HighestKind + 1, 0) {
     /...
[truncated]

``````````

</details>


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


More information about the llvm-commits mailing list