[clang] [CIR] Upstream pointer subtraction handling (PR #163306)

Shawn K via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 15 15:27:25 PDT 2025


================
@@ -4044,6 +4044,37 @@ def CIR_ExpectOp : CIR_Op<"expect", [
   }];
 }
 
+//===----------------------------------------------------------------------===//
+// PtrDiffOp
+//===----------------------------------------------------------------------===//
+
+def CIR_PtrDiffOp : CIR_Op<"ptr_diff", [Pure, SameTypeOperands]> {
+  let summary = "Pointer subtraction arithmetic";
+  let description = [{
+    The cir.ptr_diff operation computes the difference between two pointers that
+    have the same element type
+
+    The result reflects the ABI-defined size of the pointed-to type. For example,
+    subtracting two !cir.ptr<!u64i> values may yield 1, representing an 8-byte
----------------
kimsh02 wrote:

Okay, I think I'm starting to understand things more. So, thats why we have`cir::MissingFeatures::llvmLoweringPtrDiffConsidersPointee`.

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


More information about the cfe-commits mailing list