mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-22 21:54:59 -07:00
Support count_ones etc with #simd
This commit is contained in:
@@ -3559,7 +3559,14 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_type_integer_like(x.type)) {
|
||||
if (is_type_simd_vector(x.type) && id != BuiltinProc_reverse_bits) {
|
||||
Type *elem = base_array_type(x.type);
|
||||
if (!is_type_integer_like(elem)) {
|
||||
gbString xts = type_to_string(x.type);
|
||||
error(x.expr, "#simd values passed to '%.*s' must have an element of an integer-like type (integer, boolean, enum, bit_set), got %s", LIT(builtin_name), xts);
|
||||
gb_string_free(xts);
|
||||
}
|
||||
} else if (!is_type_integer_like(x.type)) {
|
||||
gbString xts = type_to_string(x.type);
|
||||
error(x.expr, "Values passed to '%.*s' must be an integer-like type (integer, boolean, enum, bit_set), got %s", LIT(builtin_name), xts);
|
||||
gb_string_free(xts);
|
||||
|
||||
@@ -485,8 +485,10 @@ lbValue lb_emit_count_ones(lbProcedure *p, lbValue x, Type *type) {
|
||||
}
|
||||
|
||||
lbValue lb_emit_count_zeros(lbProcedure *p, lbValue x, Type *type) {
|
||||
i64 sz = 8*type_size_of(type);
|
||||
lbValue size = lb_const_int(p->module, type, cast(u64)sz);
|
||||
Type *elem = base_array_type(type);
|
||||
i64 sz = 8*type_size_of(elem);
|
||||
lbValue size = lb_const_int(p->module, elem, cast(u64)sz);
|
||||
size = lb_emit_conv(p, size, type);
|
||||
lbValue count = lb_emit_count_ones(p, x, type);
|
||||
return lb_emit_arith(p, Token_Sub, size, count, type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user