diff options
| author | gingerBill <bill@gingerbill.org> | 2024-05-20 10:15:21 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-05-20 10:15:21 +0100 |
| commit | 5473758467610e8d18581f0dab11dd5f5c416484 (patch) | |
| tree | 65d27fe3b3fd4c2dad8cb44a534d7ab0e9dfda47 /src/check_builtin.cpp | |
| parent | 8eb7fe185921a2572ef0d88968489b52b8efa8c5 (diff) | |
Add intrinsics `type_is_matrix_row_major` & `type_is_matrix_column_major`
Diffstat (limited to 'src/check_builtin.cpp')
| -rw-r--r-- | src/check_builtin.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 4636d810a..5400f83f6 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -5221,6 +5221,34 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As operand->type = t_untyped_bool; break; + + case BuiltinProc_type_is_matrix_row_major: + case BuiltinProc_type_is_matrix_column_major: + { + Operand op = {}; + Type *bt = check_type(c, ce->args[0]); + Type *type = base_type(bt); + if (type == nullptr || type == t_invalid) { + error(ce->args[0], "Expected a type for '%.*s'", LIT(builtin_name)); + return false; + } + if (type->kind != Type_Matrix) { + gbString s = type_to_string(bt); + error(ce->args[0], "Expected a matrix type for '%.*s', got '%s'", LIT(builtin_name), s); + gb_string_free(s); + return false; + } + + if (id == BuiltinProc_type_is_matrix_row_major) { + operand->value = exact_value_bool(bt->Matrix.is_row_major == true); + } else { + operand->value = exact_value_bool(bt->Matrix.is_row_major == false); + } + operand->mode = Addressing_Constant; + operand->type = t_untyped_bool; + break; + } + case BuiltinProc_type_has_field: { Operand op = {}; |