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 {...@@ -1821,7 +1821,7 @@ pub const Target = struct {
1821 .wasm64,1821 .wasm64,
1822 => 8,1822 => 8,
18231823
1824 .x86 => return switch (target.os.tag) {1824 .x86 => if (target.ofmt == .c) 16 else return switch (target.os.tag) {
1825 .windows, .uefi => 8,1825 .windows, .uefi => 8,
1826 else => 4,1826 else => 4,
1827 },1827 },
test/behavior/align.zig+12-4
...@@ -65,9 +65,6 @@ test "alignment and size of structs with 128-bit fields" {...@@ -65,9 +65,6 @@ test "alignment and size of structs with 128-bit fields" {
65 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO65 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
66 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO66 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
71 const A = struct {68 const A = struct {
72 x: u128,69 x: u128,
73 };70 };
...@@ -107,7 +104,18 @@ test "alignment and size of structs with 128-bit fields" {...@@ -107,7 +104,18 @@ test "alignment and size of structs with 128-bit fields" {
107 .u129_size = 24,104 .u129_size = 24,
108 },105 },
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) {
111 .windows => .{119 .windows => .{
112 .a_align = 8,120 .a_align = 8,
113 .a_size = 16,121 .a_size = 16,