aboutsummaryrefslogtreecommitdiff
path: root/src/check_builtin.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-05-26 13:45:47 +0100
committergingerBill <bill@gingerbill.org>2022-05-26 13:45:47 +0100
commit66b5a35ec352b74e66ad866640669d920e9d0849 (patch)
treeb32db42c645b4685bb6ff5cbb1f5ed5cfe823ace /src/check_builtin.cpp
parentf3f6c12a7cc6dca745ae40744a5220878ff9261e (diff)
Add `simd_to_bits`; correct fix typo causing issue with parapoly
Diffstat (limited to 'src/check_builtin.cpp')
-rw-r--r--src/check_builtin.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp
index 45c9c93c5..c432d6080 100644
--- a/src/check_builtin.cpp
+++ b/src/check_builtin.cpp
@@ -1007,6 +1007,33 @@ bool check_builtin_simd_operation(CheckerContext *c, Operand *operand, Ast *call
return true;
}
+ case BuiltinProc_simd_to_bits:
+ {
+ 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);
+ i64 count = get_array_type_count(x.type);
+ i64 sz = type_size_of(elem);
+ Type *bit_elem = nullptr;
+ switch (sz) {
+ case 1: bit_elem = t_u8; break;
+ case 2: bit_elem = t_u16; break;
+ case 4: bit_elem = t_u32; break;
+ case 8: bit_elem = t_u64; break;
+ }
+ GB_ASSERT(bit_elem != nullptr);
+
+ operand->type = alloc_type_simd_vector(count, bit_elem);
+ operand->mode = Addressing_Value;
+ return true;
+ }
+
+
default:
GB_PANIC("Unhandled simd intrinsic: %.*s", LIT(builtin_name));
}