mirror of
https://github.com/odin-lang/Odin.git
synced 2026-09-02 18:23:35 +00:00
i386: cap cmplx / quaternion alignment; abi test: cover a narrow member in front of complex
This commit is contained in:
@@ -4353,6 +4353,18 @@ gb_internal i64 type_align_of(Type *t) {
|
||||
}
|
||||
|
||||
|
||||
// The largest alignment the target permits. The i386 System V psABI caps every scalar at 4, unlike
|
||||
// Windows. Anything that derives its alignment from a COMPONENT rather than from its own size has
|
||||
// to be capped here too.
|
||||
gb_internal i64 type_target_max_align(void) {
|
||||
i64 max_align = build_context.max_align;
|
||||
if (build_context.metrics.arch == TargetArch_i386 &&
|
||||
build_context.metrics.os != TargetOs_windows) {
|
||||
max_align = gb_min(max_align, 4);
|
||||
}
|
||||
return max_align;
|
||||
}
|
||||
|
||||
gb_internal i64 type_align_of_internal(Type *t, TypePath *path) {
|
||||
GB_ASSERT(path != nullptr);
|
||||
if (t->failure) {
|
||||
@@ -4377,10 +4389,11 @@ gb_internal i64 type_align_of_internal(Type *t, TypePath *path) {
|
||||
case Basic_uintptr: case Basic_rawptr:
|
||||
return build_context.ptr_size;
|
||||
|
||||
// A complex aligns to one component and a quaternion to one of its four.
|
||||
case Basic_complex32: case Basic_complex64: case Basic_complex128:
|
||||
return type_size_of_internal(t, path) / 2;
|
||||
return gb_min(type_size_of_internal(t, path) / 2, type_target_max_align());
|
||||
case Basic_quaternion64: case Basic_quaternion128: case Basic_quaternion256:
|
||||
return type_size_of_internal(t, path) / 4;
|
||||
return gb_min(type_size_of_internal(t, path) / 4, type_target_max_align());
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -4531,13 +4544,7 @@ gb_internal i64 type_align_of_internal(Type *t, TypePath *path) {
|
||||
|
||||
// NOTE(bill): Things that are bigger than build_context.ptr_size, are actually comprised of smaller types
|
||||
// TODO(bill): Is this correct for 128-bit types (integers)?
|
||||
i64 max_align = build_context.max_align;
|
||||
if (build_context.metrics.arch == TargetArch_i386 &&
|
||||
build_context.metrics.os != TargetOs_windows) {
|
||||
// the i386 System V psABI aligns every scalar to at most 4, unlike Windows
|
||||
max_align = gb_min(max_align, 4);
|
||||
}
|
||||
return gb_clamp(next_pow2(type_size_of_internal(t, path)), 1, max_align);
|
||||
return gb_clamp(next_pow2(type_size_of_internal(t, path)), 1, type_target_max_align());
|
||||
}
|
||||
|
||||
gb_internal i64 *type_set_offsets_of(Slice<Entity *> const &fields, bool is_packed, bool is_raw_union, i64 min_field_align, i64 max_field_align) {
|
||||
|
||||
Reference in New Issue
Block a user