mirror of
https://github.com/ziglang/zig.git
synced 2025-12-30 10:03:21 +00:00
Type.intAbiAlignment: update for LLVM 18 changes
This function is intended to match what the backend desires. No kink shaming.
This commit is contained in:
parent
88ada2121f
commit
7e1cba73fc
28
src/type.zig
28
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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user