authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-01-21 13:07:27-05:00
committergravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-01-23 13:48:37-05:00
log4a330ab811f72a0b33026761b10030cb450c32ca
treeb7bfb333c8dd1baf51c69fc8f98f9cbd5bc9f217
parent0d249e558a5b88cebad0efd4dd06a5b2ac349bcf

target: use 16 byte alignment for 128-bit types on x86 and ofmt .c


2 files changed, 13 insertions(+), 5 deletions(-)

lib/std/target.zig+1-1
......@@ -1821,7 +1821,7 @@ pub const Target = struct {
18211821 .wasm64,
18221822 => 8,
18231823
1824 .x86 => return switch (target.os.tag) {
1824 .x86 => if (target.ofmt == .c) 16 else return switch (target.os.tag) {
18251825 .windows, .uefi => 8,
18261826 else => 4,
18271827 },
test/behavior/align.zig+12-4
......@@ -65,9 +65,6 @@ test "alignment and size of structs with 128-bit fields" {
6565 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
6666 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
6767
68 // https://github.com/ziglang/zig/issues/14371
69 if (builtin.zig_backend == .stage2_c and builtin.target.cpu.arch == .x86) return error.SkipZigTest;
70
7168 const A = struct {
7269 x: u128,
7370 };
......@@ -107,7 +104,18 @@ test "alignment and size of structs with 128-bit fields" {
107104 .u129_size = 24,
108105 },
109106
110 .x86 => switch (builtin.os.tag) {
107 .x86 => if (builtin.object_format == .c) .{
108 .a_align = 16,
109 .a_size = 16,
110
111 .b_align = 16,
112 .b_size = 32,
113
114 .u128_align = 16,
115 .u128_size = 16,
116 .u129_align = 16,
117 .u129_size = 32,
118 } else switch (builtin.os.tag) {
111119 .windows => .{
112120 .a_align = 8,
113121 .a_size = 16,