aboutsummaryrefslogtreecommitdiff
path: root/src/check_builtin.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-05-25 21:17:21 +0100
committergingerBill <bill@gingerbill.org>2022-05-25 21:17:21 +0100
commit1549d01bf76e8c5e13626e57b1f976330a9cdd50 (patch)
treef57a02094dc02bed45d6d814b094a24b75939ae0 /src/check_builtin.cpp
parentb168bf9460491a101f3a7d41c28500a45898ecbf (diff)
Restrict `swizzle` to a power of two for #simd
Diffstat (limited to 'src/check_builtin.cpp')
-rw-r--r--src/check_builtin.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp
index 64b2ebfce..69e584827 100644
--- a/src/check_builtin.cpp
+++ b/src/check_builtin.cpp
@@ -694,6 +694,36 @@ bool check_builtin_simd_operation(CheckerContext *c, Operand *operand, Ast *call
return true;
}
break;
+
+ // case BuiltinProc_simd_rotate_left:
+ // {
+ // 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_integer(elem) && !is_type_float(elem)) {
+ // gbString xs = type_to_string(x.type);
+ // error(x.expr, "'%.*s' expected a #simd type with an integer or floating-point element, got '%s'", LIT(builtin_name), xs);
+ // gb_string_free(xs);
+ // return false;
+ // }
+
+ // Operand offset = {};
+ // check_expr_with_type_hint(c, &offset, ce->args[1]); if (x.mode == Addressing_Invalid) { return false; }
+ // convert_to_typed(c, &offset, t_int);
+ // if (offset.mode != Addressing_Constant) {
+ // error(offset.expr, "'%.*s' expected a constant integer for the offset", LIT(builtin_name));
+ // return false;
+ // }
+
+ // operand->mode = Addressing_Value;
+ // operand->type = x.type;
+ // return true
+ // }
default:
GB_PANIC("Unhandled simd intrinsic: %.*s", LIT(builtin_name));
}
@@ -1749,6 +1779,11 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
operand->mode = Addressing_Value;
}
+ if (is_type_simd_vector(type) && !is_power_of_two(arg_count)) {
+ error(call, "'swizzle' with a #simd vector must have a power of two arguments, got %lld", cast(long long)arg_count);
+ return false;
+ }
+
operand->type = determine_swizzle_array_type(original_type, type_hint, arg_count);
break;
}