diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-05-01 18:17:03 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-05-08 19:37:29 -0700 |
| commit | 7e1cba73fc5dce195af2c5cc6a2a1427710ed3ed (patch) | |
| tree | 94f49bd9bce095342e25a410fb59813a3e707f38 /src/type.zig | |
| parent | 88ada2121ffd13a77ef8d38e7cf10509eb45853a (diff) | |
| download | zig-7e1cba73fc5dce195af2c5cc6a2a1427710ed3ed.tar.gz zig-7e1cba73fc5dce195af2c5cc6a2a1427710ed3ed.zip | |
Type.intAbiAlignment: update for LLVM 18 changes
This function is intended to match what the backend desires.
No kink shaming.
Diffstat (limited to 'src/type.zig')
| -rw-r--r-- | src/type.zig | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/type.zig b/src/type.zig index 2afff730a7..e26cfe03f0 100644 --- a/src/type.zig +++ b/src/type.zig @@ -1540,10 +1540,30 @@ pub const Type = struct { } pub fn intAbiAlignment(bits: u16, target: Target, use_llvm: bool) Alignment { - return Alignment.fromByteUnits(@min( - std.math.ceilPowerOfTwoPromote(u16, @as(u16, @intCast((@as(u17, bits) + 7) / 8))), - maxIntAlignment(target, use_llvm), - )); + return switch (target.cpu.arch) { + .x86 => switch (bits) { + 0 => .none, + 1...8 => .@"1", + 9...16 => .@"2", + 17...127 => .@"4", + else => .@"16", + }, + .x86_64 => switch (bits) { + 0 => .none, + 1...8 => .@"1", + 9...16 => .@"2", + 17...32 => .@"4", + 33...64 => .@"8", + else => switch (target_util.zigBackend(target, use_llvm)) { + .stage2_x86_64 => .@"8", + else => .@"16", + }, + }, + else => return Alignment.fromByteUnits(@min( + std.math.ceilPowerOfTwoPromote(u16, @as(u16, @intCast((@as(u17, bits) + 7) / 8))), + maxIntAlignment(target, use_llvm), + )), + }; } pub fn maxIntAlignment(target: std.Target, use_llvm: bool) u16 { |
