authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-01 18:17:03-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-08 19:37:29-07:00
log7e1cba73fc5dce195af2c5cc6a2a1427710ed3ed
tree94f49bd9bce095342e25a410fb59813a3e707f38
parent88ada2121ffd13a77ef8d38e7cf10509eb45853a

Type.intAbiAlignment: update for LLVM 18 changes

This function is intended to match what the backend desires. No kink shaming.

1 files changed, 24 insertions(+), 4 deletions(-)

src/type.zig+24-4
......@@ -1540,10 +1540,30 @@ pub const Type = struct {
15401540 }
15411541
15421542 pub fn intAbiAlignment(bits: u16, target: Target, use_llvm: bool) Alignment {
1543 return Alignment.fromByteUnits(@min(
1544 std.math.ceilPowerOfTwoPromote(u16, @as(u16, @intCast((@as(u17, bits) + 7) / 8))),
1545 maxIntAlignment(target, use_llvm),
1546 ));
1543 return switch (target.cpu.arch) {
1544 .x86 => switch (bits) {
1545 0 => .none,
1546 1...8 => .@"1",
1547 9...16 => .@"2",
1548 17...127 => .@"4",
1549 else => .@"16",
1550 },
1551 .x86_64 => switch (bits) {
1552 0 => .none,
1553 1...8 => .@"1",
1554 9...16 => .@"2",
1555 17...32 => .@"4",
1556 33...64 => .@"8",
1557 else => switch (target_util.zigBackend(target, use_llvm)) {
1558 .stage2_x86_64 => .@"8",
1559 else => .@"16",
1560 },
1561 },
1562 else => return Alignment.fromByteUnits(@min(
1563 std.math.ceilPowerOfTwoPromote(u16, @as(u16, @intCast((@as(u17, bits) + 7) / 8))),
1564 maxIntAlignment(target, use_llvm),
1565 )),
1566 };
15471567 }
15481568
15491569 pub fn maxIntAlignment(target: std.Target, use_llvm: bool) u16 {