Add simd_reduce_any and simd_reduce_all

This commit is contained in:
gingerBill
2024-08-05 13:13:19 +01:00
parent eeb92e2644
commit 9a01a13914
5 changed files with 61 additions and 7 deletions
+23
View File
@@ -775,6 +775,29 @@ gb_internal bool check_builtin_simd_operation(CheckerContext *c, Operand *operan
return true;
}
case BuiltinProc_simd_reduce_any:
case BuiltinProc_simd_reduce_all:
{
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_boolean(elem)) {
gbString xs = type_to_string(x.type);
error(x.expr, "'%.*s' expected a #simd type with a boolean element, got '%s'", LIT(builtin_name), xs);
gb_string_free(xs);
return false;
}
operand->mode = Addressing_Value;
operand->type = t_untyped_bool;
return true;
}
case BuiltinProc_simd_shuffle:
{