[llvm] [VPlan] Use parameter packs to avoid unary/binary/ternary matchers. NFC (PR #152272)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 6 13:53:45 PDT 2025


================
@@ -200,15 +200,11 @@ template <typename Ops_t, unsigned Opcode, bool Commutative,
 struct Recipe_match {
   Ops_t Ops;
 
-  Recipe_match() : Ops() {
-    static_assert(std::tuple_size<Ops_t>::value == 0 &&
-                  "constructor can only be used with zero operands");
-  }
-  Recipe_match(Ops_t Ops) : Ops(Ops) {}
-  template <typename A_t, typename B_t>
-  Recipe_match(A_t A, B_t B) : Ops({A, B}) {
-    static_assert(std::tuple_size<Ops_t>::value == 2 &&
-                  "constructor can only be used for binary matcher");
+  template <typename... OpTy> Recipe_match(OpTy... Ops) : Ops(Ops...) {
+    static_assert(std::tuple_size<Ops_t>::value == sizeof...(Ops) &&
+                  "number of operands in constructor doesn't match Ops_t");
+    static_assert(!(Commutative && std::tuple_size<Ops_t>::value != 2) &&
----------------
artagnon wrote:

```suggestion
    static_assert((!Commutative || std::tuple_size<Ops_t>::value == 2) &&
```

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


More information about the llvm-commits mailing list