[Mlir-commits] [mlir] [mlir][ptr] Add `ptr.ptr_diff` operation (PR #157354)
Fabian Mora
llvmlistbot at llvm.org
Mon Sep 15 09:26:25 PDT 2025
================
@@ -415,6 +415,63 @@ def Ptr_PtrAddOp : Pointer_Op<"ptr_add", [
}];
}
+//===----------------------------------------------------------------------===//
+// PtrDiffOp
+//===----------------------------------------------------------------------===//
+
+def Ptr_PtrDiffOp : Pointer_Op<"ptr_diff", [
+ Pure, AllTypesMatch<["lhs", "rhs"]>, SameOperandsAndResultShape
+ ]> {
+ let summary = "Pointer difference operation";
+ let description = [{
+ The `ptr_diff` operation computes the difference between two pointers,
+ returning an integer or index value representing the number of bytes
+ between them. This difference is always computed using signed arithmetic.
----------------
fabianmcg wrote:
Removed the comment because I already have the phrase:
```
The final result will be sign-extended or truncated to
fit the result type as necessary.
```
in the description.
https://github.com/llvm/llvm-project/pull/157354
More information about the Mlir-commits
mailing list