diff options
Diffstat (limited to 'src/check_builtin.cpp')
| -rw-r--r-- | src/check_builtin.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index ea902387b..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: { @@ -3488,9 +3521,12 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As case ExactValue_Integer: mp_abs(&operand->value.value_integer, &operand->value.value_integer); break; - case ExactValue_Float: - operand->value.value_float = gb_abs(operand->value.value_float); + case ExactValue_Float: { + u64 abs = bit_cast<u64>(operand->value.value_float); + abs &= 0x7FFFFFFFFFFFFFFF; + operand->value.value_float = bit_cast<f64>(abs); break; + } case ExactValue_Complex: { f64 r = operand->value.value_complex->real; f64 i = operand->value.value_complex->imag; @@ -5544,6 +5580,9 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As // NOTE(bill): Is this even correct? new_type->Union.node = operand->expr; new_type->Union.scope = bt->Union.scope; + if (bt->Union.kind == UnionType_no_nil) { + new_type->Union.kind = UnionType_no_nil; + } operand->type = new_type; } |