@@ -372,27 +372,29 @@ def CIR_ObjSizeOp : CIR_Op<"objsize", [Pure]> {
372372//===----------------------------------------------------------------------===//
373373
374374def CIR_PtrDiffOp : CIR_Op<"ptr_diff", [Pure, SameTypeOperands]> {
375-
376375 let summary = "Pointer subtraction arithmetic";
377376 let description = [{
378- `cir.ptr_diff` performs a subtraction between two pointer types with the
379- same element type and produces a `cir::IntType` result.
377+ The cir.ptr_diff operation computes the difference between two pointers that
378+ have the same element type
379+
380+ The result reflects the ABI-defined size of the pointed-to type. For example,
381+ subtracting two !cir.ptr<!u64i> values may yield 1, representing an 8-byte
382+ difference. In contrast, for pointers to void or function types, a result of
383+ 8 corresponds to an 8-byte difference.
380384
381- Note that the result considers the pointer size according to the ABI for
382- the pointee sizes, e.g. the subtraction between two `!cir.ptr<!u64i>` might
383- yield 1, meaning 8 bytes, whereas for `void` or function type pointees,
384- yielding 8 means 8 bytes.
385+ Example:
385386
386387 ```mlir
387- %7 = " cir.ptr_diff"( %0, %1) : !cir.ptr<!u64i> -> !u64i
388+ %7 = cir.ptr_diff %0, %1 : !cir.ptr<!u64i> -> !u64i
388389 ```
389390 }];
390391
391- let results = (outs CIR_AnyFundamentalIntType:$result);
392392 let arguments = (ins CIR_PointerType:$lhs, CIR_PointerType:$rhs);
393+ let results = (outs CIR_AnyFundamentalIntType:$result);
393394
394395 let assemblyFormat = [{
395- `(` $lhs `,` $rhs `)` `:` qualified(type($lhs)) `->` qualified(type($result)) attr-dict
396+ $lhs `,` $rhs `:` qualified(type($lhs)) `->` qualified(type($result))
397+ attr-dict
396398 }];
397399}
398400
0 commit comments