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(
1156311563 .Int, .Enum, .ErrorSet => ty.intInfo(mod),
1156411564 else => return null,
1156511565 };
11566 if (int_info.bits <= 16) return int_info.signedness;
11567 switch (target.cpu.arch) {
11568 .riscv64 => {
11569 if (int_info.bits == 32) {
11570 // LLVM always signextends 32 bit ints, unsure if bug.
11571 return .signed;
11572 }
11573 if (int_info.bits < 64) {
11574 return int_info.signedness;
11575 }
11566 return switch (target.cpu.arch) {
11567 .riscv64 => switch (int_info.bits) {
11568 0...16 => int_info.signedness,
11569 32 => .signed, // LLVM always signextends 32 bit ints, unsure if bug.
11570 17...31, 33...63 => int_info.signedness,
11571 else => null,
1157611572 },
11573
1157711574 .sparc64,
1157811575 .powerpc64,
1157911576 .powerpc64le,
11580 => {
11581 if (int_info.bits < 64) {
11582 return int_info.signedness;
11583 }
11577 => switch (int_info.bits) {
11578 0...63 => int_info.signedness,
11579 else => null,
1158411580 },
11585 else => {},
11586 }
11587 return null;
11581
11582 .aarch64,
11583 .aarch64_be,
11584 => null,
11585
11586 else => switch (int_info.bits) {
11587 0...16 => int_info.signedness,
11588 else => null,
11589 },
11590 };
1158811591}
1158911592
1159011593/// This is the one source of truth for whether a type is passed around as an LLVM pointer,