CAPI and Python Bindings Support for Value uses

I’d like to write a Python utility that traverses def-use chains. Looking at the CAPI and Python bindings, it appears that there are no CAPI methods to traverse uses of a Value. Is there any concern with adding this, or is it just a case of no one asked for it so no one implemented it?

I can’t guarantee a timeline, but this is something I’d be happy to add. I imagine at the CAPI level, I could add a wrapper like MlirOpOperand, and the basic APIs like getting a list of these from an MlirValue, querying operand index, etc. Then in Python bindings, I’d add a PyOpOperand class that uses the new CAPIs.

I don’t think there was any reason to omit this – it just wasn’t done. Contributions welcome.

1 Like

I finally got around to a very simple version of this, but it’s working for my use case. Here are a couple revisions. I’d love to hear any feedback on the approach.

CAPI: ⚙ D139596 [mlir][CAPI] Add a simple MlirOpOperand API for MlirValue uses.
Python: ⚙ D139597 [mlir][Python] Add a simple PyOpOperand iterator for PyValue uses.

1 Like