diff options
| author | gingerBill <bill@gingerbill.org> | 2022-08-24 13:07:41 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-08-24 13:07:41 +0100 |
| commit | aeacf3a9d8a1f6aa36d5c1315e1d8529bb985847 (patch) | |
| tree | 935f950fa5dd1690dc57df3001410928bd5d1e3a /src | |
| parent | 4ba486baa2d1414393dff0d7ddaff777f4592cbd (diff) | |
Correct max alignment handling throughout the llvm backend
Diffstat (limited to 'src')
| -rw-r--r-- | src/build_settings.cpp | 22 | ||||
| -rw-r--r-- | src/llvm_abi.cpp | 2 | ||||
| -rw-r--r-- | src/llvm_backend_expr.cpp | 6 | ||||
| -rw-r--r-- | src/llvm_backend_general.cpp | 5 | ||||
| -rw-r--r-- | src/llvm_backend_stmt.cpp | 2 | ||||
| -rw-r--r-- | src/types.cpp | 2 |
6 files changed, 22 insertions, 17 deletions
diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 3ad4dd3e3..3f6be3c48 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -428,12 +428,13 @@ gb_global TargetMetrics target_essence_amd64 = { str_lit("x86_64-pc-none-elf"), }; + gb_global TargetMetrics target_freestanding_wasm32 = { TargetOs_freestanding, TargetArch_wasm32, 4, 8, 16, str_lit("wasm32-freestanding-js"), - str_lit(""), + str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"), }; gb_global TargetMetrics target_js_wasm32 = { @@ -441,15 +442,7 @@ gb_global TargetMetrics target_js_wasm32 = { TargetArch_wasm32, 4, 8, 16, str_lit("wasm32-js-js"), - str_lit(""), -}; - -gb_global TargetMetrics target_js_wasm64 = { - TargetOs_js, - TargetArch_wasm64, - 8, 8, 16, - str_lit("wasm64-js-js"), - str_lit(""), + str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"), }; gb_global TargetMetrics target_wasi_wasm32 = { @@ -457,6 +450,15 @@ gb_global TargetMetrics target_wasi_wasm32 = { TargetArch_wasm32, 4, 8, 16, str_lit("wasm32-wasi-js"), + str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"), +}; + + +gb_global TargetMetrics target_js_wasm64 = { + TargetOs_js, + TargetArch_wasm64, + 8, 8, 16, + str_lit("wasm64-js-js"), str_lit(""), }; diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index 2ee8dc673..4bdc31077 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -294,7 +294,7 @@ i64 lb_alignof(LLVMTypeRef type) { i64 elem_size = lb_sizeof(elem); i64 count = LLVMGetVectorSize(type); i64 size = count * elem_size; - return gb_clamp(next_pow2(size), 1, build_context.max_align); + return gb_clamp(next_pow2(size), 1, build_context.max_simd_align); } } diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index dd66943d7..7d81d1407 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -137,7 +137,7 @@ lbValue lb_emit_unary_arith(lbProcedure *p, TokenKind op, lbValue x, Type *type) lbAddr res_addr = lb_add_local(p, type, nullptr, false, 0, true); lbValue res = lb_addr_get_ptr(p, res_addr); - bool inline_array_arith = type_size_of(type) <= build_context.max_align; + bool inline_array_arith = lb_can_try_to_inline_array_arith(type); i32 count = cast(i32)get_array_type_count(tl); @@ -436,7 +436,7 @@ lbValue lb_emit_arith_array(lbProcedure *p, TokenKind op, lbValue lhs, lbValue r return direct_vector_res; } - bool inline_array_arith = type_size_of(type) <= build_context.max_align; + bool inline_array_arith = lb_can_try_to_inline_array_arith(type); if (inline_array_arith) { auto dst_ptrs = slice_make<lbValue>(temporary_allocator(), n); @@ -2303,7 +2303,7 @@ lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue ri cmp_op = Token_And; } - bool inline_array_arith = type_size_of(tl) <= build_context.max_align; + bool inline_array_arith = lb_can_try_to_inline_array_arith(tl); i32 count = 0; switch (tl->kind) { case Type_Array: count = cast(i32)tl->Array.count; break; diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index 071986458..6f98458fa 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -591,6 +591,9 @@ bool lb_try_update_alignment(lbValue ptr, unsigned alignment) { return lb_try_update_alignment(ptr.value, alignment); } +bool lb_can_try_to_inline_array_arith(Type *t) { + return type_size_of(t) <= build_context.max_simd_align; +} bool lb_try_vector_cast(lbModule *m, lbValue ptr, LLVMTypeRef *vector_type_) { Type *array_type = base_type(type_deref(ptr.type)); @@ -599,7 +602,7 @@ bool lb_try_vector_cast(lbModule *m, lbValue ptr, LLVMTypeRef *vector_type_) { Type *elem_type = base_array_type(array_type); // TODO(bill): Determine what is the correct limit for doing vector arithmetic - if (type_size_of(array_type) <= build_context.max_align && + if (lb_can_try_to_inline_array_arith(array_type) && is_type_valid_vector_elem(elem_type)) { // Try to treat it like a vector if possible bool possible = false; diff --git a/src/llvm_backend_stmt.cpp b/src/llvm_backend_stmt.cpp index e55fae3a7..175c4c537 100644 --- a/src/llvm_backend_stmt.cpp +++ b/src/llvm_backend_stmt.cpp @@ -1796,7 +1796,7 @@ void lb_build_assign_stmt_array(lbProcedure *p, TokenKind op, lbAddr const &lhs, lbValue rhs = lb_emit_conv(p, value, lhs_type); - bool inline_array_arith = type_size_of(array_type) <= build_context.max_align; + bool inline_array_arith = lb_can_try_to_inline_array_arith(array_type); if (lhs.kind == lbAddr_Swizzle) { diff --git a/src/types.cpp b/src/types.cpp index aa4a3c4a1..b7cb4dd2c 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -1428,7 +1428,7 @@ i64 matrix_align_of(Type *t, struct TypePath *tp) { } GB_ASSERT(min_alignment >= elem_align); - i64 align = gb_min(min_alignment, build_context.max_align); + i64 align = gb_min(min_alignment, build_context.max_simd_align); return align; } |