[Mlir-commits] [mlir] [MLIR][ODS][NVVM] Add EnumAttrIsOneOf constraint and use it in NVVM fence ops (PR #182662)

Pradeep Kumar llvmlistbot at llvm.org
Sun Feb 22 15:15:17 PST 2026


================
@@ -750,4 +750,21 @@ class ConstantEnumCase<Attr attribute, string case>
     "attribute must be one of 'EnumAttr' or 'EnumInfo'";
 }
 
+/// Attribute constraint restricting the enum attribute to a subset of allowed
+/// cases. `enumAttr` is the `EnumAttr` attribute and `allowedCases` is a list
+/// of `EnumCase`s that are permitted.
+///
+/// Example:
+/// ```
+/// ConfinedAttr<MyEnumAttr, [EnumAttrIsOneOf<MyEnumAttr, [CaseA, CaseB]>]>
+/// ```
+class EnumAttrIsOneOf<EnumAttr enumAttr, list<EnumCase> allowedCases>
+  : AttrConstraint<
+      Or<!foreach(case, allowedCases,
+        CPred<"::llvm::cast<" # enumAttr.cppNamespace # "::"
----------------
schwarzschild-radius wrote:

Maybe we can static_cast this to an unsigned?

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


More information about the Mlir-commits mailing list