[codegen] add documentation for overflow
Add documentation to the icmp instruction text for both signed and unsigned overflow, making it very clear why unsigned overflow is complicated and where to find it.
This commit is contained in:
committed by
Dan Gohman
parent
e45ef24d3b
commit
9f3c5b967e
@@ -1586,8 +1586,6 @@ pub(crate) fn define(
|
|||||||
let x = &operand("x", Int);
|
let x = &operand("x", Int);
|
||||||
let y = &operand("y", Int);
|
let y = &operand("y", Int);
|
||||||
|
|
||||||
// TODO(ryzokuken): Add documentation for unsigned overflow.
|
|
||||||
// TODO(ryzokuken): Add documentation for signed overflow.
|
|
||||||
ig.push(
|
ig.push(
|
||||||
Inst::new(
|
Inst::new(
|
||||||
"icmp",
|
"icmp",
|
||||||
@@ -1597,16 +1595,21 @@ pub(crate) fn define(
|
|||||||
The condition code determines if the operands are interpreted as signed
|
The condition code determines if the operands are interpreted as signed
|
||||||
or unsigned integers.
|
or unsigned integers.
|
||||||
|
|
||||||
====== ======== =========
|
| Signed | Unsigned | Condition |
|
||||||
Signed Unsigned Condition
|
|--------|----------|-----------------------|
|
||||||
====== ======== =========
|
| eq | eq | Equal |
|
||||||
eq eq Equal
|
| ne | ne | Not equal |
|
||||||
ne ne Not equal
|
| slt | ult | Less than |
|
||||||
slt ult Less than
|
| sge | uge | Greater than or equal |
|
||||||
sge uge Greater than or equal
|
| sgt | ugt | Greater than |
|
||||||
sgt ugt Greater than
|
| sle | ule | Less than or equal |
|
||||||
sle ule Less than or equal
|
| of | * | Overflow |
|
||||||
====== ======== =========
|
| nof | * | No Overflow |
|
||||||
|
|
||||||
|
\* The unsigned version of overflow conditions have ISA-specific
|
||||||
|
semantics and thus have been kept as methods on the TargetIsa trait as
|
||||||
|
[unsigned_add_overflow_condition][isa::TargetIsa::unsigned_add_overflow_condition] and
|
||||||
|
[unsigned_sub_overflow_condition][isa::TargetIsa::unsigned_sub_overflow_condition].
|
||||||
|
|
||||||
When this instruction compares integer vectors, it returns a boolean
|
When this instruction compares integer vectors, it returns a boolean
|
||||||
vector of lane-wise comparisons.
|
vector of lane-wise comparisons.
|
||||||
|
|||||||
Reference in New Issue
Block a user