[Mlir-commits] [mlir] [mlir][bufferization] Support custom types (1/N) (PR #142986)
Andrei Golubev
llvmlistbot at llvm.org
Tue Jul 1 01:24:18 PDT 2025
================
@@ -739,6 +740,19 @@ AliasingValueList unknownGetAliasingValues(OpOperand &opOperand);
/// This is the default implementation of
/// BufferizableOpInterface::hasTensorSemantics
bool defaultHasTensorSemantics(Operation *op);
+
+/// This is a helper function used when buffer type is guaranteed to be memref.
+/// It performs two actions: failure state checking and an explicit llvm::cast<>
+/// from the buffer-like type interface to a BaseMemRefType. This allows easier
+/// management of differences in C++ types at the API boundaries. Valid buffer
+/// type is casted to the memref type. Otherwise, the failure state is
+/// propagated i.e. asMemRefType(mlir::failure()) returns mlir::failure().
+FailureOr<BaseMemRefType> asMemRefType(FailureOr<BufferLikeType> bufferType);
----------------
andrey-golubev wrote:
Yes, ideally, I want to get rid of this once there's a direct support of Buffer-Like (even if it's "always a memref"). The [follow-up patch](https://github.com/llvm/llvm-project/pull/144867) already removes some of the instances. It is a bridge code that exists to have less boilerplate between BufferLike <-> BaseMemrefType conversions in C++, which is why it's in `detail` - it's not really intended to be used (and there are no promises on API / usability of the function).
Long term, if it turns out to be useful, we can promote it to a "public" function, right now it seems to be an implementation detail related to bufferization.
https://github.com/llvm/llvm-project/pull/142986
More information about the Mlir-commits
mailing list