[Mlir-commits] [mlir] [mlir][IR] Add builtin `TokenType` (PR #195640)
Jacques Pienaar
llvmlistbot at llvm.org
Mon Jun 1 02:04:06 PDT 2026
================
@@ -165,8 +165,24 @@ class SameBuildabilityAs<Type type, code builder> {
code builderCall = !if(!empty(type.builderCall), "", builder);
}
-// Any type at all.
-def AnyType : Type<CPred<"true">, "any type">;
+// Whether a type is the builtin `TokenType`.
+def IsTokenTypePred : CPred<"::llvm::isa<::mlir::TokenType>($_self)">;
----------------
jpienaar wrote:
Funnily below the more invasive approach is actually what's used (e.g., type is hardcoded into verifier).
Which made me wonder over weekend: why not let AnyType still be AnyType and allow any type? E.g., if you have AnyType then Token is still only allowed if TokenProducer/TokenConsumer is set, for those one can also explicitly have AnyTypeExceptToken for type constraints. No op would still silently start accepting a token, it would fail when passed where not expected.
What is the gap wrt this approach? We don't insert many more checks, we do have an opening where a user now adds this trait to an op that has AnyType specified and they are opt-ing in _without_ considering semantics. But we can't guard much against folks not correctly specifying semantics.
https://github.com/llvm/llvm-project/pull/195640
More information about the Mlir-commits
mailing list