diff options
| author | gingerBill <bill@gingerbill.org> | 2022-05-26 11:02:02 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-05-26 11:02:02 +0100 |
| commit | 0fd43c1a0b697ea919efdeef42427694f32692bf (patch) | |
| tree | 58512075dc550dc40483660c3fc6365b6269f115 /src/check_builtin.cpp | |
| parent | 06337129d8de636ad00e8ea64218d48c67514611 (diff) | |
Add simd.{sqrt, ceil, floor, trunc, nearest}
Diffstat (limited to 'src/check_builtin.cpp')
| -rw-r--r-- | src/check_builtin.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 40933fcaa..74c28f4d2 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -886,6 +886,32 @@ bool check_builtin_simd_operation(CheckerContext *c, Operand *operand, Ast *call return true; } + case BuiltinProc_simd_sqrt: + case BuiltinProc_simd_ceil: + case BuiltinProc_simd_floor: + case BuiltinProc_simd_trunc: + case BuiltinProc_simd_nearest: + { + 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 boolean type", LIT(builtin_name)); + return false; + } + Type *elem = base_array_type(x.type); + if (!is_type_float(elem)) { + gbString x_str = type_to_string(x.type); + error(x.expr, "'%.*s' expected a simd vector floating point type, got '%s'", LIT(builtin_name), x_str); + gb_string_free(x_str); + return false; + } + + operand->mode = Addressing_Value; + operand->type = x.type; + return true; + } + default: GB_PANIC("Unhandled simd intrinsic: %.*s", LIT(builtin_name)); |