mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Remove simd_rem; Disallow simd_div for integers
This commit is contained in:
@@ -194,8 +194,7 @@ constant_utf16_cstring :: proc($literal: string) -> [^]u16 ---
|
|||||||
simd_add :: proc(a, b: #simd[N]T) -> #simd[N]T ---
|
simd_add :: proc(a, b: #simd[N]T) -> #simd[N]T ---
|
||||||
simd_sub :: proc(a, b: #simd[N]T) -> #simd[N]T ---
|
simd_sub :: proc(a, b: #simd[N]T) -> #simd[N]T ---
|
||||||
simd_mul :: proc(a, b: #simd[N]T) -> #simd[N]T ---
|
simd_mul :: proc(a, b: #simd[N]T) -> #simd[N]T ---
|
||||||
simd_div :: proc(a, b: #simd[N]T) -> #simd[N]T ---
|
simd_div :: proc(a, b: #simd[N]T) -> #simd[N]T where type_is_float(T) ---
|
||||||
simd_rem :: proc(a, b: #simd[N]T) -> #simd[N]T ---
|
|
||||||
|
|
||||||
// Keeps Odin's Behaviour
|
// Keeps Odin's Behaviour
|
||||||
// (x << y) if y <= mask else 0
|
// (x << y) if y <= mask else 0
|
||||||
|
|||||||
+1
-2
@@ -61,8 +61,7 @@ b64x8 :: #simd[8]b64
|
|||||||
add :: intrinsics.simd_add
|
add :: intrinsics.simd_add
|
||||||
sub :: intrinsics.simd_sub
|
sub :: intrinsics.simd_sub
|
||||||
mul :: intrinsics.simd_mul
|
mul :: intrinsics.simd_mul
|
||||||
div :: intrinsics.simd_div
|
div :: intrinsics.simd_div // floats only
|
||||||
rem :: intrinsics.simd_rem // integers only
|
|
||||||
|
|
||||||
// Keeps Odin's Behaviour
|
// Keeps Odin's Behaviour
|
||||||
// (x << y) if y <= mask else 0
|
// (x << y) if y <= mask else 0
|
||||||
|
|||||||
@@ -452,6 +452,13 @@ bool check_builtin_simd_operation(CheckerContext *c, Operand *operand, Ast *call
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (id == BuiltinProc_simd_div && is_type_integer(elem)) {
|
||||||
|
gbString xs = type_to_string(x.type);
|
||||||
|
error(x.expr, "'%.*s' is not supported for integer elements, got '%s'", LIT(builtin_name), xs);
|
||||||
|
gb_string_free(xs);
|
||||||
|
// don't return
|
||||||
|
}
|
||||||
|
|
||||||
operand->mode = Addressing_Value;
|
operand->mode = Addressing_Value;
|
||||||
operand->type = x.type;
|
operand->type = x.type;
|
||||||
return true;
|
return true;
|
||||||
@@ -460,7 +467,6 @@ bool check_builtin_simd_operation(CheckerContext *c, Operand *operand, Ast *call
|
|||||||
// Integer only
|
// Integer only
|
||||||
case BuiltinProc_simd_add_sat:
|
case BuiltinProc_simd_add_sat:
|
||||||
case BuiltinProc_simd_sub_sat:
|
case BuiltinProc_simd_sub_sat:
|
||||||
case BuiltinProc_simd_rem:
|
|
||||||
case BuiltinProc_simd_and:
|
case BuiltinProc_simd_and:
|
||||||
case BuiltinProc_simd_or:
|
case BuiltinProc_simd_or:
|
||||||
case BuiltinProc_simd_xor:
|
case BuiltinProc_simd_xor:
|
||||||
@@ -492,7 +498,6 @@ bool check_builtin_simd_operation(CheckerContext *c, Operand *operand, Ast *call
|
|||||||
switch (id) {
|
switch (id) {
|
||||||
case BuiltinProc_simd_add_sat:
|
case BuiltinProc_simd_add_sat:
|
||||||
case BuiltinProc_simd_sub_sat:
|
case BuiltinProc_simd_sub_sat:
|
||||||
case BuiltinProc_simd_rem:
|
|
||||||
if (!is_type_integer(elem)) {
|
if (!is_type_integer(elem)) {
|
||||||
gbString xs = type_to_string(x.type);
|
gbString xs = type_to_string(x.type);
|
||||||
error(x.expr, "'%.*s' expected a #simd type with an integer element, got '%s'", LIT(builtin_name), xs);
|
error(x.expr, "'%.*s' expected a #simd type with an integer element, got '%s'", LIT(builtin_name), xs);
|
||||||
|
|||||||
@@ -1618,6 +1618,9 @@ bool check_binary_op(CheckerContext *c, Operand *o, Token op) {
|
|||||||
if (is_type_matrix(main_type)) {
|
if (is_type_matrix(main_type)) {
|
||||||
error(op, "Operator '%.*s' is only allowed with matrix types", LIT(op.string));
|
error(op, "Operator '%.*s' is only allowed with matrix types", LIT(op.string));
|
||||||
return false;
|
return false;
|
||||||
|
} else if (is_type_simd_vector(main_type) && is_type_integer(type)) {
|
||||||
|
error(op, "Operator '%.*s' is only allowed with #simd types with integer elements", LIT(op.string));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
/*fallthrough*/
|
/*fallthrough*/
|
||||||
case Token_Mul:
|
case Token_Mul:
|
||||||
@@ -1669,6 +1672,9 @@ bool check_binary_op(CheckerContext *c, Operand *o, Token op) {
|
|||||||
if (!is_type_integer(type)) {
|
if (!is_type_integer(type)) {
|
||||||
error(op, "Operator '%.*s' is only allowed with integers", LIT(op.string));
|
error(op, "Operator '%.*s' is only allowed with integers", LIT(op.string));
|
||||||
return false;
|
return false;
|
||||||
|
} else if (is_type_simd_vector(main_type)) {
|
||||||
|
error(op, "Operator '%.*s' is only allowed with #simd types with integer elements", LIT(op.string));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user