diff options
| author | gingerBill <bill@gingerbill.org> | 2023-07-20 01:58:46 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-07-20 01:58:46 +0100 |
| commit | 9fffa19c51e77141b396d3ac15c94fdac1552a5d (patch) | |
| tree | 6798afce1ae026e2abfd6d45004c2d2e9902c484 /src | |
| parent | b54f3d4ee9a57e0a88140ad581b8fae6ca28a11f (diff) | |
Mock out more global stuff
Diffstat (limited to 'src')
| -rw-r--r-- | src/tilde_const.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/tilde_const.cpp b/src/tilde_const.cpp index 256d3a58a..9e2eac0ca 100644 --- a/src/tilde_const.cpp +++ b/src/tilde_const.cpp @@ -397,6 +397,7 @@ gb_internal bool cg_global_const_add_region(cgModule *m, ExactValue const &value GB_ASSERT(global != nullptr); + Type *bt = base_type(type); i64 size = type_size_of(type); if (value.kind == ExactValue_Invalid) { return false; @@ -420,7 +421,6 @@ gb_internal bool cg_global_const_add_region(cgModule *m, ExactValue const &value GB_ASSERT(offset == s.len); return true; } - Type *bt = base_type(type); Type *et = bt->Array.elem; i64 elem_size = type_size_of(et); @@ -437,7 +437,6 @@ gb_internal bool cg_global_const_add_region(cgModule *m, ExactValue const &value value.kind != ExactValue_String && value.kind != ExactValue_Compound) { - Type *bt = base_type(type); Type *et = bt->Array.elem; i64 elem_size = type_size_of(et); @@ -449,15 +448,31 @@ gb_internal bool cg_global_const_add_region(cgModule *m, ExactValue const &value } else if (is_type_matrix(type) && value.kind != ExactValue_Invalid && value.kind != ExactValue_Compound) { - i64 row = type->Matrix.row_count; - i64 column = type->Matrix.column_count; + i64 row = bt->Matrix.row_count; + i64 column = bt->Matrix.column_count; GB_ASSERT(row == column); - GB_PANIC("TODO(bill): constant matrix from scalar"); + Type *elem = bt->Matrix.elem; + + i64 elem_size = type_size_of(elem); + + for (i64 i = 0; i < row; i++) { + i64 index = matrix_indices_to_offset(type, i, i); + cg_global_const_add_region(m, value, elem, global, offset+(index * elem_size)); + } + + return true; } else if (is_type_simd_vector(type) && value.kind != ExactValue_Invalid && value.kind != ExactValue_Compound) { - GB_PANIC("TODO(bill): constant vector from scalar"); + + Type *et = type->SimdVector.elem; + i64 elem_size = type_size_of(et); + + for (i64 i = 0; i < bt->SimdVector.count; i++) { + cg_global_const_add_region(m, value, et, global, offset+(i * elem_size)); + } + return true; } |