aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-06-08 12:41:42 +0100
committergingerBill <bill@gingerbill.org>2020-06-08 12:41:42 +0100
commit9b1cc6e94f061629d55db9f0baad46229d4fb755 (patch)
treed7dcda7d63a5515c5f249c8b432f9633300304b4 /src/check_expr.cpp
parent0ffb718a91fab5d46ca4b9887f7dac5198ba9f2d (diff)
Update logic for slice literals, backing array to be on the stack if possible (LLVM C API)
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 21487c231..c38bec9b7 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -4347,17 +4347,27 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
case BuiltinProc_swizzle: {
// swizzle :: proc(v: [N]T, ..int) -> [M]T
Type *type = base_type(operand->type);
- if (!is_type_array(type)) {
+ i64 max_count = 0;
+ Type *elem_type = nullptr;
+
+ if (!is_type_array(type) && !is_type_simd_vector(type)) {
gbString type_str = type_to_string(operand->type);
error(call,
- "You can only 'swizzle' an array, got '%s'",
+ "'swizzle' is only allowed on an array or #simd vector, got '%s'",
type_str);
gb_string_free(type_str);
return false;
}
-
- i64 max_count = type->Array.count;
- Type *elem_type = type->Array.elem;
+ if (type->kind == Type_Array) {
+ max_count = type->Array.count;
+ elem_type = type->Array.elem;
+ } else if (type->kind == Type_SimdVector) {
+ max_count = type->SimdVector.count;
+ elem_type = type->SimdVector.elem;
+ if (!build_context.use_llvm_api) {
+ error(call, "'swizzle' with #simd vector is not supported on this backend");
+ }
+ }
i64 arg_count = 0;
for_array(i, ce->args) {