diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-02-24 14:04:07 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-24 14:04:07 +0000 |
| commit | 0781526b35434086e4350bf9d9dd2aec1f8a953e (patch) | |
| tree | 3dd2dbcf5e79128d18fce8d80f2e21f66fbf5925 /src/check_builtin.cpp | |
| parent | ef016d957ba5fdaab55ee1f52a3a1160c6024652 (diff) | |
| parent | 4afedbc051e92647c9003d33b1a231330fe3b025 (diff) | |
Merge pull request #4466 from Barinzaya/simd_extract_msbs
SIMD Extract MSbs/LSbs Intrinsics
Diffstat (limited to 'src/check_builtin.cpp')
| -rw-r--r-- | src/check_builtin.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 5aa4cf027..023aeff73 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -888,6 +888,39 @@ gb_internal bool check_builtin_simd_operation(CheckerContext *c, Operand *operan return true; } + case BuiltinProc_simd_extract_lsbs: + case BuiltinProc_simd_extract_msbs: + { + Operand x = {}; + check_expr(c, &x, ce->args[0]); if (x.mode == Addressing_Invalid) return false; + + if (!is_type_simd_vector(x.type)) { + gbString xs = type_to_string(x.type); + error(x.expr, "'%.*s' expected a simd vector type, got '%s'", LIT(builtin_name), xs); + gb_string_free(xs); + return false; + } + + Type *elem = base_array_type(x.type); + if (!is_type_integer_like(elem)) { + gbString xs = type_to_string(x.type); + error(x.expr, "'%.*s' expected a #simd type with integer or boolean elements, got '%s'", LIT(builtin_name), xs); + gb_string_free(xs); + return false; + } + + i64 num_elems = get_array_type_count(x.type); + + Type *result_type = alloc_type_bit_set(); + result_type->BitSet.elem = t_int; + result_type->BitSet.lower = 0; + result_type->BitSet.upper = num_elems - 1; + + operand->mode = Addressing_Value; + operand->type = result_type; + return true; + } + case BuiltinProc_simd_shuffle: { |