[Mlir-commits] [mlir] [mlir][core|ptr] Add `PtrLikeTypeInterface` and casting ops to the `ptr` dialect (PR #137469)
Fabian Mora
llvmlistbot at llvm.org
Sun Apr 27 05:07:10 PDT 2025
================
@@ -52,6 +121,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`.
+ - The memory-space of both the `ptr` and ptr-like object must match.
+ - The cast is side-effect free.
+
+ Example:
+
+ ```mlir
+ %ptr0 = ptr.to_ptr %my_ptr : !my.ptr<f32, 0> -> !ptr.ptr<0>
+ %ptr1 = ptr.to_ptr %memref : memref<f32, 0> -> !ptr.ptr<0>
+ ```
+ }];
+
+ let arguments = (ins PtrLikeTypeInterface:$ptr);
----------------
fabianmcg wrote:
Yes, those are coming in a later patch. This one only deals between ptr and ptrLike conversions.
https://github.com/llvm/llvm-project/pull/137469
More information about the Mlir-commits
mailing list