diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-05-01 16:23:47 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-05-08 19:37:29 -0700 |
| commit | 6730b366a059a83d64f66644bf49d69cb31a6a08 (patch) | |
| tree | 90f233e92abac089dd3e6848e941898a2743f923 /src/codegen | |
| parent | 6986d2aca900bdda30f541baf9b06fb29688fe97 (diff) | |
| download | zig-6730b366a059a83d64f66644bf49d69cb31a6a08.tar.gz zig-6730b366a059a83d64f66644bf49d69cb31a6a08.zip | |
LLVM backend: no more signext on aarch64
Clang doesn't do it, so Zig must not do it in order to match the C ABI.
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/llvm.zig | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 2d3c7de2e2..bddfb2701e 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -11563,28 +11563,31 @@ fn ccAbiPromoteInt( .Int, .Enum, .ErrorSet => ty.intInfo(mod), else => return null, }; - if (int_info.bits <= 16) return int_info.signedness; - switch (target.cpu.arch) { - .riscv64 => { - if (int_info.bits == 32) { - // LLVM always signextends 32 bit ints, unsure if bug. - return .signed; - } - if (int_info.bits < 64) { - return int_info.signedness; - } + return switch (target.cpu.arch) { + .riscv64 => switch (int_info.bits) { + 0...16 => int_info.signedness, + 32 => .signed, // LLVM always signextends 32 bit ints, unsure if bug. + 17...31, 33...63 => int_info.signedness, + else => null, }, + .sparc64, .powerpc64, .powerpc64le, - => { - if (int_info.bits < 64) { - return int_info.signedness; - } + => switch (int_info.bits) { + 0...63 => int_info.signedness, + else => null, }, - else => {}, - } - return null; + + .aarch64, + .aarch64_be, + => null, + + else => switch (int_info.bits) { + 0...16 => int_info.signedness, + else => null, + }, + }; } /// This is the one source of truth for whether a type is passed around as an LLVM pointer, |
