aboutsummaryrefslogtreecommitdiff
path: root/src/BuiltinFn.zig
diff options
context:
space:
mode:
authortravisstaloch <twostepted@gmail.com>2021-09-01 11:17:45 -0700
committerGitHub <noreply@github.com>2021-09-01 14:17:45 -0400
commit21a5769afefb47553391ae1ef801f64a58253c33 (patch)
tree8f6d1a219c881c1fc34f839421fc000c1fe8d527 /src/BuiltinFn.zig
parent4f0aa7d639e099b18df583cb984412037fbb1dbe (diff)
downloadzig-21a5769afefb47553391ae1ef801f64a58253c33.tar.gz
zig-21a5769afefb47553391ae1ef801f64a58253c33.zip
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
Diffstat (limited to 'src/BuiltinFn.zig')
-rw-r--r--src/BuiltinFn.zig32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/BuiltinFn.zig b/src/BuiltinFn.zig
index 8f23ec86d7..e415d27a3a 100644
--- a/src/BuiltinFn.zig
+++ b/src/BuiltinFn.zig
@@ -2,6 +2,7 @@ const std = @import("std");
pub const Tag = enum {
add_with_overflow,
+ add_with_saturation,
align_cast,
align_of,
as,
@@ -65,6 +66,7 @@ pub const Tag = enum {
wasm_memory_grow,
mod,
mul_with_overflow,
+ mul_with_saturation,
panic,
pop_count,
ptr_cast,
@@ -79,10 +81,12 @@ pub const Tag = enum {
set_runtime_safety,
shl_exact,
shl_with_overflow,
+ shl_with_saturation,
shr_exact,
shuffle,
size_of,
splat,
+ sub_with_saturation,
reduce,
src,
sqrt,
@@ -528,6 +532,34 @@ pub const list = list: {
},
},
.{
+ "@addWithSaturation",
+ .{
+ .tag = .add_with_saturation,
+ .param_count = 2,
+ },
+ },
+ .{
+ "@subWithSaturation",
+ .{
+ .tag = .sub_with_saturation,
+ .param_count = 2,
+ },
+ },
+ .{
+ "@mulWithSaturation",
+ .{
+ .tag = .mul_with_saturation,
+ .param_count = 2,
+ },
+ },
+ .{
+ "@shlWithSaturation",
+ .{
+ .tag = .shl_with_saturation,
+ .param_count = 2,
+ },
+ },
+ .{
"@memcpy",
.{
.tag = .memcpy,