[Mlir-commits] [mlir] [mlir][core|ptr] Add `PtrLikeTypeInterface` and casting ops to the `ptr` dialect (PR #137469)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Thu Jun 5 14:02:36 PDT 2025
================
@@ -110,6 +110,55 @@ def MemRefElementTypeInterface : TypeInterface<"MemRefElementTypeInterface"> {
}];
}
+//===----------------------------------------------------------------------===//
+// PtrLikeTypeInterface
+//===----------------------------------------------------------------------===//
+
+def PtrLikeTypeInterface : TypeInterface<"PtrLikeTypeInterface"> {
+ let cppNamespace = "::mlir";
+ let description = [{
+ A ptr-like type represents an object storing a memory address. This object
+ is constituted by:
+ - A memory address called the base pointer. The base pointer is an
+ indivisible object.
+ - Optional metadata about the pointer. For example, the size of the memory
+ region associated with the pointer.
+
+ Furthermore, all ptr-like types have two properties:
+ - The memory space associated with the address held by the pointer.
+ - An optional element type. If the element type is not specified, the
+ pointer is considered opaque.
+ }];
+ let methods = [
+ InterfaceMethod<[{
+ Returns the memory space of this ptr-like type.
+ }],
+ "::mlir::Attribute", "getMemorySpace">,
+ InterfaceMethod<[{
+ Returns the element type of this ptr-like type. Note: this method can
+ return `::mlir::Type()`, in which case the pointer is considered opaque.
+ }],
+ "::mlir::Type", "getElementType">,
+ InterfaceMethod<[{
+ Returns whether this ptr-like type has non-empty metadata.
+ }],
+ "bool", "hasPtrMetadata">,
----------------
ftynse wrote:
Nit for bikeshedding, not blocking for PR: are we afraid of empty metadata because that would be equivalent to having a value of `void` type?
https://github.com/llvm/llvm-project/pull/137469
More information about the Mlir-commits
mailing list