Details
- Reviewers
- None
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
As we discussed offline, I don't think this is the appropriate level to expose through the C API. Some sort of getUses function would be more appropriate IMO.
Looking into this, it seems more difficult than initially thought to expose low-level operations to perform value replacement through the CAPI. We'd expect getUses to return OpOperands (by inheritance, IrOperand) which in turn is what we would call replace on.
Main pain points which i see here are:
- OpOperand is heavily encapsulated to protect how and who can construct an operand. https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/IR/Value.h#L265
- By the above, there's no immediate way that we can roundtrip the value through CAPI, which would require that an OpOperand can be constructed statically through an opaque pointer.
There may be a way around this if the constructors are made public. However, that design choice was made for a reason so that would not be a sound decision. Suggestions are welcome, but I don't immediately see any non-intrusive options apart from the one presented in this PR.
I'm pretty sure that OpOperand just needs to implement getAsOpaquePointer/getFromOpaquePointer and it is safe for those implementations to just cast from/to this.
clang-format not found in user’s local PATH; not linting file.