[Mlir-commits] [mlir] [mlir][core|ptr] Add `PtrLikeTypeInterface` and casting ops to the `ptr` dialect (PR #137469)

Mehdi Amini llvmlistbot at llvm.org
Sun Apr 27 03:53:34 PDT 2025


================
@@ -63,6 +64,54 @@ def Ptr_PtrType : Ptr_Type<"Ptr", "ptr", [
       return $_get(memorySpace.getContext(), memorySpace);
     }]>
   ];
+  let extraClassDeclaration = [{
+    // `PtrLikeTypeInterface` interface methods.
+    /// Returns `Type()` as this pointer type is opaque.
+    Type getElementType() const {
+      return Type();
+    }
+    /// Clones the pointer with specified memory space or returns failure
+    /// if an `elementType` was specified or if the memory space doesn't
+    /// implement `MemorySpaceAttrInterface`.
+    FailureOr<PtrLikeTypeInterface> clonePtrWith(Attribute memorySpace,
----------------
joker-eph wrote:

```suggestion
    FailureOr<PtrLikeTypeInterface> clonePtrWith(MemorySpaceAttrInterface memorySpace,
```

Why not encode this in the type system?

https://github.com/llvm/llvm-project/pull/137469


More information about the Mlir-commits mailing list