diff options
| author | gingerBill <bill@gingerbill.org> | 2022-09-01 16:11:03 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-09-01 16:11:03 +0100 |
| commit | 19ae6122c774d16c3b6cc851debf14a437e71e57 (patch) | |
| tree | a2ef1aff25442b53ba11138cd6f97a14a414cb0a /src/llvm_backend_stmt.cpp | |
| parent | b82b91ea08696535d48decef8b993f53d47087af (diff) | |
Fix #2002 (allow `array *= matrix`)
Diffstat (limited to 'src/llvm_backend_stmt.cpp')
| -rw-r--r-- | src/llvm_backend_stmt.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/llvm_backend_stmt.cpp b/src/llvm_backend_stmt.cpp index 175c4c537..9ea4ad34b 100644 --- a/src/llvm_backend_stmt.cpp +++ b/src/llvm_backend_stmt.cpp @@ -1959,8 +1959,18 @@ void lb_build_assign_stmt(lbProcedure *p, AstAssignStmt *as) { } else { lbAddr lhs = lb_build_addr(p, as->lhs[0]); lbValue value = lb_build_expr(p, as->rhs[0]); - Type *lhs_type = lb_addr_type(lhs); + + // NOTE(bill): Allow for the weird edge case of: + // array *= matrix + if (op == Token_Mul && is_type_matrix(value.type) && is_type_array(lhs_type)) { + lbValue old_value = lb_addr_load(p, lhs); + Type *type = old_value.type; + lbValue new_value = lb_emit_vector_mul_matrix(p, old_value, value, type); + lb_addr_store(p, lhs, new_value); + return; + } + if (is_type_array(lhs_type)) { lb_build_assign_stmt_array(p, op, lhs, value); return; |