authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-01 16:23:47-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-08 19:37:29-07:00
log6730b366a059a83d64f66644bf49d69cb31a6a08
tree90f233e92abac089dd3e6848e941898a2743f923
parent6986d2aca900bdda30f541baf9b06fb29688fe97

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.

1 files changed, 20 insertions(+), 17 deletions(-)

src/codegen/llvm.zig+20-17
...@@ -11563,28 +11563,31 @@ fn ccAbiPromoteInt(...@@ -11563,28 +11563,31 @@ fn ccAbiPromoteInt(
11563 .Int, .Enum, .ErrorSet => ty.intInfo(mod),11563 .Int, .Enum, .ErrorSet => ty.intInfo(mod),
11564 else => return null,11564 else => return null,
11565 };11565 };
11566 if (int_info.bits <= 16) return int_info.signedness;11566 return switch (target.cpu.arch) {
11567 switch (target.cpu.arch) {11567 .riscv64 => switch (int_info.bits) {
11568 .riscv64 => {11568 0...16 => int_info.signedness,
11569 if (int_info.bits == 32) {11569 32 => .signed, // LLVM always signextends 32 bit ints, unsure if bug.
11570 // LLVM always signextends 32 bit ints, unsure if bug.11570 17...31, 33...63 => int_info.signedness,
11571 return .signed;11571 else => null,
11572 }
11573 if (int_info.bits < 64) {
11574 return int_info.signedness;
11575 }
11576 },11572 },
11573
11577 .sparc64,11574 .sparc64,
11578 .powerpc64,11575 .powerpc64,
11579 .powerpc64le,11576 .powerpc64le,
11580 => {11577 => switch (int_info.bits) {
11581 if (int_info.bits < 64) {11578 0...63 => int_info.signedness,
11582 return int_info.signedness;11579 else => null,
11583 }
11584 },11580 },
11585 else => {},11581
11586 }11582 .aarch64,
11587 return null;11583 .aarch64_be,
11584 => null,
11585
11586 else => switch (int_info.bits) {
11587 0...16 => int_info.signedness,
11588 else => null,
11589 },
11590 };
11588}11591}
1158911592
11590/// This is the one source of truth for whether a type is passed around as an LLVM pointer,11593/// This is the one source of truth for whether a type is passed around as an LLVM pointer,