llvm-project
fff4a464 - [MLIR][ODS][NVVM] Add EnumAttrIsOneOf/IsNoneOf constraints and use them in NVVM fence ops (#182662)

Commit
3 days ago
[MLIR][ODS][NVVM] Add EnumAttrIsOneOf/IsNoneOf constraints and use them in NVVM fence ops (#182662) Add `EnumAttrIsOneOf` and `EnumAttrIsNoneOf` to `EnumAttr.td`, a generic `AttrConstraint`s that restrict an `EnumAttr` to an allowlist or denylist of cases respectively. These are the enum analogs of the existing `IntIsOneOf` constraint for integer attributes. `EnumAttrIsOneOf` restricts the attribute to a closed set of permitted cases. `EnumAttrIsNoneOf` excludes specific cases while allowing all others, which is more ergonomic when the disallowed set is smaller than the allowed set and more future-proof when new enum cases are added. This replaces hand-written verifier logic with ODS-generated verification, eliminating the `FenceSyncRestrictOp` verifier entirely and simplifying both `FenceProxyOp` and `FenceProxySyncRestrictOp` verifiers. It can also be parameterized through base class hierarchies, allowing derived ops to specify their own allowed subsets: ``` class MyBase<string mnemonic, list<EnumCase> allowed> : NVVM_Op<mnemonic>, Arguments<(ins ConfinedAttr<MyEnumAttr, [EnumAttrIsOneOf<MyEnumAttr, allowed>]>:$kind)>; def Op1 : MyBase<"op1", [CaseA, CaseB]>; def Op2 : MyBase<"op2", [CaseB, CaseC, CaseD]>; ```
Author
Parents
Loading