diff options
| author | gingerBill <bill@gingerbill.org> | 2024-08-05 13:13:19 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-08-05 13:13:19 +0100 |
| commit | 9a01a13914e9b1f577399fed7ed09132306946b1 (patch) | |
| tree | a39f9d56eb4ea86e586d768bdbf74c85054f5359 /src/check_builtin.cpp | |
| parent | eeb92e2644a8241b6dc6950f6a2712d5164ea4e3 (diff) | |
Add `simd_reduce_any` and `simd_reduce_all`
Diffstat (limited to 'src/check_builtin.cpp')
| -rw-r--r-- | src/check_builtin.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index b96337326..73a90ed62 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -775,6 +775,29 @@ gb_internal bool check_builtin_simd_operation(CheckerContext *c, Operand *operan return true; } + case BuiltinProc_simd_reduce_any: + case BuiltinProc_simd_reduce_all: + { + Operand x = {}; + check_expr(c, &x, ce->args[0]); if (x.mode == Addressing_Invalid) return false; + + if (!is_type_simd_vector(x.type)) { + error(x.expr, "'%.*s' expected a simd vector type", LIT(builtin_name)); + return false; + } + Type *elem = base_array_type(x.type); + if (!is_type_boolean(elem)) { + gbString xs = type_to_string(x.type); + error(x.expr, "'%.*s' expected a #simd type with a boolean element, got '%s'", LIT(builtin_name), xs); + gb_string_free(xs); + return false; + } + + operand->mode = Addressing_Value; + operand->type = t_untyped_bool; + return true; + } + case BuiltinProc_simd_shuffle: { |