[Mlir-commits] [mlir] [MLIR][Python] Impl XOpInterface(s) from Python, with X=Transform and X=MemoryEffects (PR #176920)
Rolf Morel
llvmlistbot at llvm.org
Wed Jan 28 05:24:56 PST 2026
================
@@ -1044,6 +1049,9 @@ MLIR_CAPI_EXPORTED bool mlirValueIsABlockArgument(MlirValue value);
/// Returns 1 if the value is an operation result, 0 otherwise.
MLIR_CAPI_EXPORTED bool mlirValueIsAOpResult(MlirValue value);
+/// Cast the value to an OpResult. Asserts if the value is not an op result.
+MLIR_CAPI_EXPORTED MlirOpResult mlirValueToOpResult(MlirValue value);
----------------
rolfmorel wrote:
This is a way to leverage C's (limited) type system.
As `transform::producesHandle` really asks for `OpResult`s, I have the same ask on `mlirTransformProducesHandle`. Functions like `mlirValueToOpResult` allow us to encode the invariant into the type system at the time we know it/want to perform the check for it. Rather than changing the APIs to just accept `Value`s everywhere and (doubly) performing the check at the last second.
> If we have this API, then we should also have MlirBlockArgument?
I agree. Though this PR doesn't add it as the PR's tests do not/don't have a need to exercise that code. IMHO, `mlirBlockArgumentGetArgNumber` should be changed to use `MlirBlockArgument`, though in a separate PR.
https://github.com/llvm/llvm-project/pull/176920
More information about the Mlir-commits
mailing list