================
@@ -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
----------------
andykaylor wrote:
I'm opening a can of worms here, but a more informative example would be
`_BitInt(24)`, which we currently represent in CIR as `!u24i`. We handle that
incorrectly in the incubator, treating it as a 3-byte type, though for the
purposes of target data layout it is generally going to be a 4-byte type.
https://godbolt.org/z/6zneqYzYP
See also: https://github.com/llvm/llvm-project/issues/159731
I'm not suggesting that you need to fix the associated problems in this PR. I'd
just like to see the description here changed to reflect the way the operation
should behave. I believe that
`cir::MissingFeatures::llvmLoweringPtrDiffConsidersPointee` captures the
problem.
https://github.com/llvm/llvm-project/pull/163306
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits