aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-03-20 10:23:57 +0000
committergingerBill <bill@gingerbill.org>2024-03-20 10:23:57 +0000
commit3bff922b6f066966c550cf6298ab3f2a564f6c5e (patch)
treeb1ae84eabf928454460bff2bfe047a00a92e9b9f /src/llvm_backend_expr.cpp
parent56004c56fcac6318b059c2028cbf6fec6820a132 (diff)
`m[i]` on `#row_major` matrices will reduce the i-th row-vector
Diffstat (limited to 'src/llvm_backend_expr.cpp')
-rw-r--r--src/llvm_backend_expr.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp
index 6eb8fdcc6..06bf9fe1e 100644
--- a/src/llvm_backend_expr.cpp
+++ b/src/llvm_backend_expr.cpp
@@ -3990,7 +3990,13 @@ gb_internal lbAddr lb_build_addr_index_expr(lbProcedure *p, Ast *expr) {
}
lbValue index = lb_build_expr(p, ie->index);
index = lb_emit_conv(p, index, t_int);
- lbValue elem = lb_emit_matrix_ep(p, matrix, lb_const_int(p->module, t_int, 0), index);
+
+ lbValue elem = {};
+ if (t->Matrix.is_row_major) {
+ elem = lb_emit_matrix_ep(p, matrix, index, lb_const_int(p->module, t_int, 0));
+ } else {
+ elem = lb_emit_matrix_ep(p, matrix, lb_const_int(p->module, t_int, 0), index);
+ }
elem = lb_emit_conv(p, elem, alloc_type_pointer(type_of_expr(expr)));
auto index_tv = type_and_value_of_expr(ie->index);