[Mlir-commits] [mlir] [mlir][ptr] Add `ptr.ptr_diff` operation (PR #157354)
Mehdi Amini
llvmlistbot at llvm.org
Mon Sep 15 07:33:00 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.
----------------
joker-eph wrote:
Be mindful that C is a language with signed type, while we're operating in a signless IR here.
https://github.com/llvm/llvm-project/pull/157354
More information about the Mlir-commits
mailing list