diff options
| author | gingerBill <bill@gingerbill.org> | 2022-05-25 22:04:47 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-05-25 22:04:47 +0100 |
| commit | 10e4de3c015de149008d0dc573e391af99d82574 (patch) | |
| tree | 144e7ce8b9097191e3baeb5690fb5700f998af05 /src/check_builtin.cpp | |
| parent | 8ac12886ed90298f3de1e4685153b90bb67fd6db (diff) | |
Add `intrinsics.simd_reduce_*`
Diffstat (limited to 'src/check_builtin.cpp')
| -rw-r--r-- | src/check_builtin.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 69e584827..a499937b2 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -695,6 +695,56 @@ bool check_builtin_simd_operation(CheckerContext *c, Operand *operand, Ast *call } break; + case BuiltinProc_simd_reduce_add_ordered: + case BuiltinProc_simd_reduce_mul_ordered: + case BuiltinProc_simd_reduce_min: + case BuiltinProc_simd_reduce_max: + { + 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_integer(elem) && !is_type_float(elem)) { + gbString xs = type_to_string(x.type); + error(x.expr, "'%.*s' expected a #simd type with an integer or floating-point element, got '%s'", LIT(builtin_name), xs); + gb_string_free(xs); + return false; + } + + operand->mode = Addressing_Value; + operand->type = base_array_type(x.type); + return true; + } + + case BuiltinProc_simd_reduce_and: + case BuiltinProc_simd_reduce_or: + case BuiltinProc_simd_reduce_xor: + { + 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_integer(elem)) { + gbString xs = type_to_string(x.type); + error(x.expr, "'%.*s' expected a #simd type with an integer element, got '%s'", LIT(builtin_name), xs); + gb_string_free(xs); + return false; + } + + operand->mode = Addressing_Value; + operand->type = base_array_type(x.type); + return true; + } + + // case BuiltinProc_simd_rotate_left: // { // Operand x = {}; |