diff options
| author | Travis Staloch <twostepted@gmail.com> | 2021-09-02 13:50:24 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-09-28 17:02:43 -0700 |
| commit | 29f41896ed9d99e82a88f4b63efa182ca0d2f93c (patch) | |
| tree | 1e6eb1159df89f79b04f050da662653925c77b1c /src/Air.zig | |
| parent | 79bc5891c1c4cde0592fe1b10b6c9a85914155cf (diff) | |
| download | zig-29f41896ed9d99e82a88f4b63efa182ca0d2f93c.tar.gz zig-29f41896ed9d99e82a88f4b63efa182ca0d2f93c.zip | |
sat-arithmetic: add operator support
- adds initial support for the operators +|, -|, *|, <<|, +|=, -|=, *|=, <<|=
- uses operators in addition to builtins in behavior test
- adds binOpExt() and assignBinOpExt() to AstGen.zig. these need to be audited
Diffstat (limited to 'src/Air.zig')
| -rw-r--r-- | src/Air.zig | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Air.zig b/src/Air.zig index b5d19127a0..b7d3938352 100644 --- a/src/Air.zig +++ b/src/Air.zig @@ -44,6 +44,11 @@ pub const Inst = struct { /// is the same as both operands. /// Uses the `bin_op` field. addwrap, + /// Saturating integer addition. + /// Both operands are guaranteed to be the same type, and the result type + /// is the same as both operands. + /// Uses the `bin_op` field. + addsat, /// Float or integer subtraction. For integers, wrapping is undefined behavior. /// Both operands are guaranteed to be the same type, and the result type /// is the same as both operands. @@ -54,6 +59,11 @@ pub const Inst = struct { /// is the same as both operands. /// Uses the `bin_op` field. subwrap, + /// Saturating integer subtraction. + /// Both operands are guaranteed to be the same type, and the result type + /// is the same as both operands. + /// Uses the `bin_op` field. + subsat, /// Float or integer multiplication. For integers, wrapping is undefined behavior. /// Both operands are guaranteed to be the same type, and the result type /// is the same as both operands. @@ -64,6 +74,11 @@ pub const Inst = struct { /// is the same as both operands. /// Uses the `bin_op` field. mulwrap, + /// Saturating integer multiplication. + /// Both operands are guaranteed to be the same type, and the result type + /// is the same as both operands. + /// Uses the `bin_op` field. + mulsat, /// Integer or float division. For integers, wrapping is undefined behavior. /// Both operands are guaranteed to be the same type, and the result type /// is the same as both operands. @@ -110,6 +125,9 @@ pub const Inst = struct { /// Shift left. `<<` /// Uses the `bin_op` field. shl, + /// Shift left saturating. `<<|` + /// Uses the `bin_op` field. + shl_sat, /// Bitwise XOR. `^` /// Uses the `bin_op` field. xor, @@ -568,10 +586,13 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index) Type { .add, .addwrap, + .addsat, .sub, .subwrap, + .subsat, .mul, .mulwrap, + .mulsat, .div, .rem, .mod, @@ -582,6 +603,7 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index) Type { .ptr_sub, .shr, .shl, + .shl_sat, => return air.typeOf(datas[inst].bin_op.lhs), .cmp_lt, |
