[Mlir-commits] [mlir] [MLIR][CAPI][Python] Add support for querying memory effect instances (PR #213459)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Aug 5 08:17:54 PDT 2026
PragmaTwice wrote:
> Does this sound right to you?
Yah I think you are right. In the C API, for consuming a list we can just pass `size_t len, MlirSomeValue *values` as arguments. But for producing a list, it become more complicated due to lifetime issues, and the existing pattern is to pass a callback with `size_t len, MlirSomeValue *values` as parameters. The callback can be treated as a "scope" so the lifetime can be a bit easier. I've added a descrption about this callback type to PR description : )
@adam-smnk @rolfmorel Would you like to comment on changes in the Python side? Previously `effects` is a mutable input argument, and these functions will append new effects into effects list (`MemoryEffectInstancesList`), e.g.
```python
@staticmethod
def get_effects(op: ir.Operation, effects):
transform.only_reads_handle(op.op_operands, effects)
transform.produces_handle(op.results, effects)
transform.only_reads_payload(effects)
```
now it will return a new Python-native `list` and we can use `+` to concat lists and return.
```python
def get_effects(op: ir.Operation):
return (
transform.only_reads_handle(op.op_operands)
+ transform.produces_handle(op.results)
+ transform.only_reads_payload()
)
```
https://github.com/llvm/llvm-project/pull/213459
More information about the Mlir-commits
mailing list