| ... | @@ -12600,46 +12600,76 @@ fn iterateParamTypes(object: *Object, pt: Zcu.PerThread, fn_info: InternPool.Key | ... | @@ -12600,46 +12600,76 @@ fn iterateParamTypes(object: *Object, pt: Zcu.PerThread, fn_info: InternPool.Key |
| 12600 | }; | 12600 | }; |
| 12601 | } | 12601 | } |
| 12602 | | 12602 | |
| | 12603 | /// This function deliberately does not handle `_BitInt` because it typically |
| | 12604 | /// has different ABI than regular integer types, and there is no currently no |
| | 12605 | /// way to determine whether a Zig integer type is meant to represent e.g. `int` |
| | 12606 | /// or `_BitInt(32)`. |
| 12603 | fn ccAbiPromoteInt(cc: std.builtin.CallingConvention, zcu: *Zcu, ty: Type) ?std.builtin.Signedness { | 12607 | fn ccAbiPromoteInt(cc: std.builtin.CallingConvention, zcu: *Zcu, ty: Type) ?std.builtin.Signedness { |
| 12604 | const target = zcu.getTarget(); | | |
| 12605 | switch (cc) { | 12608 | switch (cc) { |
| 12606 | .auto, .@"inline", .async => return null, | 12609 | .auto, .@"inline", .async => return null, |
| 12607 | else => {}, | 12610 | else => {}, |
| 12608 | } | 12611 | } |
| | 12612 | |
| 12609 | const int_info = switch (ty.zigTypeTag(zcu)) { | 12613 | const int_info = switch (ty.zigTypeTag(zcu)) { |
| 12610 | .bool => Type.u1.intInfo(zcu), | 12614 | .bool => Type.u1.intInfo(zcu), |
| 12611 | else => if (ty.isAbiInt(zcu)) ty.intInfo(zcu) else return null, | 12615 | else => if (ty.isAbiInt(zcu)) ty.intInfo(zcu) else return null, |
| 12612 | }; | 12616 | }; |
| 12613 | return switch (target.os.tag) { | 12617 | assert(int_info.bits >= 0); |
| 12614 | .driverkit, .ios, .maccatalyst, .macos, .watchos, .tvos, .visionos => switch (int_info.bits) { | | |
| 12615 | 0...16 => int_info.signedness, | | |
| 12616 | else => null, | | |
| 12617 | }, | | |
| 12618 | else => switch (target.cpu.arch) { | | |
| 12619 | .loongarch64, .riscv64, .riscv64be => switch (int_info.bits) { | | |
| 12620 | 0...16 => int_info.signedness, | | |
| 12621 | 32 => .signed, // LLVM always signextends 32 bit ints, unsure if bug. | | |
| 12622 | 17...31, 33...63 => int_info.signedness, | | |
| 12623 | else => null, | | |
| 12624 | }, | | |
| 12625 | | 12618 | |
| 12626 | .sparc64, | 12619 | const target = zcu.getTarget(); |
| 12627 | .powerpc64, | 12620 | return switch (target.cpu.arch) { |
| 12628 | .powerpc64le, | 12621 | .aarch64, |
| 12629 | .s390x, | 12622 | .aarch64_be, |
| 12630 | => switch (int_info.bits) { | 12623 | => switch (target.os.tag) { |
| 12631 | 0...63 => int_info.signedness, | 12624 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => switch (int_info.bits) { |
| | 12625 | 8, 16 => int_info.signedness, |
| 12632 | else => null, | 12626 | else => null, |
| 12633 | }, | 12627 | }, |
| | 12628 | else => null, |
| | 12629 | }, |
| | 12630 | |
| | 12631 | .avr, |
| | 12632 | => switch (int_info.bits) { |
| | 12633 | 8 => int_info.signedness, |
| | 12634 | else => null, |
| | 12635 | }, |
| 12634 | | 12636 | |
| 12635 | .aarch64, | 12637 | .lanai, |
| 12636 | .aarch64_be, | 12638 | => null, |
| 12637 | => null, | | |
| 12638 | | 12639 | |
| 12639 | else => switch (int_info.bits) { | 12640 | .loongarch64, |
| 12640 | 0...16 => int_info.signedness, | 12641 | .riscv64, |
| 12641 | else => null, | 12642 | .riscv64be, |
| 12642 | }, | 12643 | => switch (int_info.bits) { |
| | 12644 | 8, 16 => int_info.signedness, |
| | 12645 | 32 => .signed, |
| | 12646 | else => null, |
| | 12647 | }, |
| | 12648 | |
| | 12649 | .mips, |
| | 12650 | .mipsel, |
| | 12651 | .mips64, |
| | 12652 | .mips64el, |
| | 12653 | => switch (int_info.bits) { |
| | 12654 | 8, 16, 64 => int_info.signedness, |
| | 12655 | // https://github.com/llvm/llvm-project/issues/179088 |
| | 12656 | // 32 => .signed, |
| | 12657 | else => null, |
| | 12658 | }, |
| | 12659 | |
| | 12660 | .powerpc64, |
| | 12661 | .powerpc64le, |
| | 12662 | .s390x, |
| | 12663 | .sparc64, |
| | 12664 | .ve, |
| | 12665 | => switch (int_info.bits) { |
| | 12666 | 8, 16, 32 => int_info.signedness, |
| | 12667 | else => null, |
| | 12668 | }, |
| | 12669 | |
| | 12670 | else => switch (int_info.bits) { |
| | 12671 | 8, 16 => int_info.signedness, |
| | 12672 | else => null, |
| 12643 | }, | 12673 | }, |
| 12644 | }; | 12674 | }; |
| 12645 | } | 12675 | } |