mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-13 06:41:26 -07:00
Add #row_major matrix[R, C]T
As well as `#column_major matrix[R, C]T` as an alias for just `matrix[R, C]T`. This is because some libraries require a row_major internal layout but still want to be used with row or major oriented vectors.
This commit is contained in:
@@ -1464,14 +1464,16 @@ gb_internal lbValue lb_emit_matrix_epi(lbProcedure *p, lbValue s, isize row, isi
|
||||
Type *t = s.type;
|
||||
GB_ASSERT(is_type_pointer(t));
|
||||
Type *mt = base_type(type_deref(t));
|
||||
if (column == 0) {
|
||||
GB_ASSERT_MSG(is_type_matrix(mt) || is_type_array_like(mt), "%s", type_to_string(mt));
|
||||
return lb_emit_epi(p, s, row);
|
||||
} else if (row == 0 && is_type_array_like(mt)) {
|
||||
return lb_emit_epi(p, s, column);
|
||||
|
||||
if (!mt->Matrix.is_row_major) {
|
||||
if (column == 0) {
|
||||
GB_ASSERT_MSG(is_type_matrix(mt) || is_type_array_like(mt), "%s", type_to_string(mt));
|
||||
return lb_emit_epi(p, s, row);
|
||||
} else if (row == 0 && is_type_array_like(mt)) {
|
||||
return lb_emit_epi(p, s, column);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GB_ASSERT_MSG(is_type_matrix(mt), "%s", type_to_string(mt));
|
||||
|
||||
isize offset = matrix_indices_to_offset(mt, row, column);
|
||||
@@ -1491,7 +1493,13 @@ gb_internal lbValue lb_emit_matrix_ep(lbProcedure *p, lbValue s, lbValue row, lb
|
||||
row = lb_emit_conv(p, row, t_int);
|
||||
column = lb_emit_conv(p, column, t_int);
|
||||
|
||||
LLVMValueRef index = LLVMBuildAdd(p->builder, row.value, LLVMBuildMul(p->builder, column.value, stride_elems, ""), "");
|
||||
LLVMValueRef index = nullptr;
|
||||
|
||||
if (mt->Matrix.is_row_major) {
|
||||
index = LLVMBuildAdd(p->builder, column.value, LLVMBuildMul(p->builder, row.value, stride_elems, ""), "");
|
||||
} else {
|
||||
index = LLVMBuildAdd(p->builder, row.value, LLVMBuildMul(p->builder, column.value, stride_elems, ""), "");
|
||||
}
|
||||
|
||||
LLVMValueRef indices[2] = {
|
||||
LLVMConstInt(lb_type(p->module, t_int), 0, false),
|
||||
|
||||
Reference in New Issue
Block a user