@@ -377,27 +377,29 @@ def CIR_ObjSizeOp : CIR_Op<"objsize", [Pure]> {
377377//===----------------------------------------------------------------------===//
378378
379379def CIR_PtrDiffOp : CIR_Op<"ptr_diff", [Pure, SameTypeOperands]> {
380-
381380 let summary = "Pointer subtraction arithmetic";
382381 let description = [{
383- `cir.ptr_diff` performs a subtraction between two pointer types with the
384- same element type and produces a `cir::IntType` result.
382+ The cir.ptr_diff operation computes the difference between two pointers that
383+ have the same element type
384+
385+ The result reflects the ABI-defined size of the pointed-to type. For example,
386+ subtracting two !cir.ptr<!u64i> values may yield 1, representing an 8-byte
387+ difference. In contrast, for pointers to void or function types, a result of
388+ 8 corresponds to an 8-byte difference.
385389
386- Note that the result considers the pointer size according to the ABI for
387- the pointee sizes, e.g. the subtraction between two `!cir.ptr<!u64i>` might
388- yield 1, meaning 8 bytes, whereas for `void` or function type pointees,
389- yielding 8 means 8 bytes.
390+ Example:
390391
391392 ```mlir
392- %7 = " cir.ptr_diff"( %0, %1) : !cir.ptr<!u64i> -> !u64i
393+ %7 = cir.ptr_diff %0, %1 : !cir.ptr<!u64i> -> !u64i
393394 ```
394395 }];
395396
396- let results = (outs CIR_AnyFundamentalIntType:$result);
397397 let arguments = (ins CIR_PointerType:$lhs, CIR_PointerType:$rhs);
398+ let results = (outs CIR_AnyFundamentalIntType:$result);
398399
399400 let assemblyFormat = [{
400- `(` $lhs `,` $rhs `)` `:` qualified(type($lhs)) `->` qualified(type($result)) attr-dict
401+ $lhs `,` $rhs `:` qualified(type($lhs)) `->` qualified(type($result))
402+ attr-dict
401403 }];
402404}
403405
0 commit comments