aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_general.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-10-19 11:24:26 +0100
committergingerBill <bill@gingerbill.org>2021-10-19 11:24:26 +0100
commit243e2e2b8a7566087375178a66b25b5d9ac9a356 (patch)
treed82f6499edb8a1056c19479c59e6390f294887e7 /src/llvm_backend_general.cpp
parent35111b39b88bb12d61e1dc67ed0161109be3f865 (diff)
Basic support for matrix*vector, vector*matrix operations
Diffstat (limited to 'src/llvm_backend_general.cpp')
-rw-r--r--src/llvm_backend_general.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp
index ee8f220ef..63a63349a 100644
--- a/src/llvm_backend_general.cpp
+++ b/src/llvm_backend_general.cpp
@@ -1937,7 +1937,7 @@ LLVMTypeRef lb_type_internal(lbModule *m, Type *type) {
i64 elem_size = type_size_of(type->Matrix.elem);
GB_ASSERT(elem_size > 0);
i64 elem_count = size/elem_size;
- GB_ASSERT(elem_count > 0);
+ GB_ASSERT_MSG(elem_count > 0, "%s", type_to_string(type));
m->internal_type_level -= 1;
@@ -2611,8 +2611,10 @@ lbAddr lb_add_local(lbProcedure *p, Type *type, Entity *e, bool zero_init, i32 p
LLVMTypeRef llvm_type = lb_type(p->module, type);
LLVMValueRef ptr = LLVMBuildAlloca(p->builder, llvm_type, name);
- // unsigned alignment = 16; // TODO(bill): Make this configurable
- unsigned alignment = cast(unsigned)lb_alignof(llvm_type);
+ unsigned alignment = cast(unsigned)gb_max(type_align_of(type), lb_alignof(llvm_type));
+ if (is_type_matrix(type)) {
+ alignment *= 2; // NOTE(bill): Just in case
+ }
LLVMSetAlignment(ptr, alignment);
LLVMPositionBuilderAtEnd(p->builder, p->curr_block->block);