@@ -372,27 +372,29 @@ def CIR_ObjSizeOp : CIR_Op<"objsize", [Pure]> {
372
372
//===----------------------------------------------------------------------===//
373
373
374
374
def CIR_PtrDiffOp : CIR_Op<"ptr_diff", [Pure, SameTypeOperands]> {
375
-
376
375
let summary = "Pointer subtraction arithmetic";
377
376
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.
380
384
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:
385
386
386
387
```mlir
387
- %7 = " cir.ptr_diff"( %0, %1) : !cir.ptr<!u64i> -> !u64i
388
+ %7 = cir.ptr_diff %0, %1 : !cir.ptr<!u64i> -> !u64i
388
389
```
389
390
}];
390
391
391
- let results = (outs CIR_AnyFundamentalIntType:$result);
392
392
let arguments = (ins CIR_PointerType:$lhs, CIR_PointerType:$rhs);
393
+ let results = (outs CIR_AnyFundamentalIntType:$result);
393
394
394
395
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
396
398
}];
397
399
}
398
400
0 commit comments