diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-09-28 15:45:58 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-09-28 16:12:24 -0700 |
| commit | 79bc5891c1c4cde0592fe1b10b6c9a85914155cf (patch) | |
| tree | 92999a5e04df045c03d63e4d02e53ad796c70911 /src/Air.zig | |
| parent | 1e805df81d51a338eefaff0535e5f1cca9e22028 (diff) | |
| download | zig-79bc5891c1c4cde0592fe1b10b6c9a85914155cf.tar.gz zig-79bc5891c1c4cde0592fe1b10b6c9a85914155cf.zip | |
stage2: more arithmetic support
* AIR: add `mod` instruction for modulus division
- Implement for LLVM backend
* Sema: implement `@mod`, `@rem`, and `%`.
* Sema: fix comptime switch evaluation
* Sema: implement comptime shift left
* Sema: fix the logic inside analyzeArithmetic to handle all the
nuances between the different mathematical operations.
- Implement comptime wrapping operations
Diffstat (limited to 'src/Air.zig')
| -rw-r--r-- | src/Air.zig | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Air.zig b/src/Air.zig index b4552f9d7b..b5d19127a0 100644 --- a/src/Air.zig +++ b/src/Air.zig @@ -69,10 +69,16 @@ pub const Inst = struct { /// is the same as both operands. /// Uses the `bin_op` field. div, - /// Integer or float remainder. - /// Both operands are guaranteed to be the same type, and the result type is the same as both operands. + /// Integer or float remainder division. + /// Both operands are guaranteed to be the same type, and the result type + /// is the same as both operands. /// Uses the `bin_op` field. rem, + /// Integer or float modulus division. + /// Both operands are guaranteed to be the same type, and the result type + /// is the same as both operands. + /// Uses the `bin_op` field. + mod, /// Add an offset to a pointer, returning a new pointer. /// The offset is in element type units, not bytes. /// Wrapping is undefined behavior. @@ -568,6 +574,7 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index) Type { .mulwrap, .div, .rem, + .mod, .bit_and, .bit_or, .xor, |
