saturating arithmetic builtins: add, sub, mul, shl (#9619)

- adds 1 simple behavior tests for each
  which does integer and vector ops at
  runtime and comptime
- adds bigint_*_sat() methods for each

- use CreateIntrinsic() which accepts a
  variable number of arguments to pass
  the scale parameter

* update langref
- added case to test/compile_errors.zig given floats

- explain upstream bug in llvm.smul.fix.sat and link to #9643 in langref and commented out test cases

* sat-arithmetic: skip mul tests if arch == .wasm32 because ci is erroring with 'LLVM ERROR: Unable to expand fixed point multiplication' when compiling for wasm32
This commit is contained in:
travisstaloch
2021-09-01 11:17:45 -07:00
committed by GitHub
parent 4f0aa7d639
commit 21a5769afe
17 changed files with 613 additions and 3 deletions
+8
View File
@@ -8838,4 +8838,12 @@ pub fn addCases(ctx: *TestContext) !void {
"tmp.zig:2:9: note: declared mutable here",
"tmp.zig:3:12: note: crosses namespace boundary here",
});
ctx.objErrStage1("Issue #9619: saturating arithmetic builtins should fail to compile when given floats",
\\pub fn main() !void {
\\ _ = @addWithSaturation(@as(f32, 1.0), @as(f32, 1.0));
\\}
, &[_][]const u8{
"error: invalid operands to binary expression: 'f32' and 'f32'",
});
}