mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-18 20:40:28 +00:00
Correct max alignment handling throughout the llvm backend
This commit is contained in:
@@ -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(""),
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user