[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:35 PDT 2025


================
@@ -52,6 +118,36 @@ def Ptr_PtrAddOp : Pointer_Op<"ptr_add", [
   }];
 }
 
+//===----------------------------------------------------------------------===//
+// ToPtrOp
+//===----------------------------------------------------------------------===//
+
+def Ptr_ToPtrOp : Pointer_Op<"to_ptr", [Pure]> {
+  let summary = "Casts a ptr-like value to a `!ptr.ptr` value.";
+  let description = [{
+    The `to_ptr` operation casts a ptr-like object to a `!ptr.ptr`. It's
+    important to note that:
+    - The ptr-like object cannot be a `!ptr.ptr`.
----------------
ftynse wrote:

Not for this PR, but I wonder why this restriction is needed. We could allow it and have the op fold away. This may fall out of type conversion during progressive lowering and will be annoying to handle.

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


More information about the Mlir-commits mailing list