Add intrinsics.simd_indices

This commit is contained in:
gingerBill
2025-05-05 11:41:54 +01:00
parent bc2a4dfe9d
commit 36945079f8
3 changed files with 53 additions and 0 deletions
+31
View File
@@ -760,6 +760,36 @@ gb_internal bool check_builtin_simd_operation(CheckerContext *c, Operand *operan
return true;
}
case BuiltinProc_simd_indices:
{
Operand x = {};
check_expr_or_type(c, &x, ce->args[0], nullptr);
if (x.mode == Addressing_Invalid) return false;
if (x.mode != Addressing_Type) {
gbString s = expr_to_string(x.expr);
error(x.expr, "'%.*s' expected a simd vector type, got '%s'", LIT(builtin_name), s);
gb_string_free(s);
return false;
}
if (!is_type_simd_vector(x.type)) {
gbString s = type_to_string(x.type);
error(x.expr, "'%.*s' expected a simd vector type, got '%s'", LIT(builtin_name), s);
gb_string_free(s);
return false;
}
Type *elem = base_array_type(x.type);
if (!is_type_numeric(elem)) {
gbString s = type_to_string(x.type);
error(x.expr, "'%.*s' expected a simd vector type with a numeric element type, got '%s'", LIT(builtin_name), s);
gb_string_free(s);
}
operand->mode = Addressing_Value;
operand->type = x.type;
return true;
}
case BuiltinProc_simd_extract:
{
Operand x = {};
@@ -2059,6 +2089,7 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
case BuiltinProc_atomic_type_is_lock_free:
case BuiltinProc_has_target_feature:
case BuiltinProc_procedure_of:
case BuiltinProc_simd_indices:
// NOTE(bill): The first arg may be a Type, this will be checked case by case
break;