authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-23 19:35:54+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-10-23 19:35:54+02:00
log70206af4829964420d7902488c66ba0edc37ba76
tree217d18cc05cd69c06e4f9f367a6ca2c3492e5c6d
parente5fcc8192da248b890b5f3c8eb65ddec010ba0ef
parent07d764dc301d4547a6dab131cd6b687fef3278c7
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #25640 from alexrp/std-target-more-arches

`std.Target`: add tags and info for alpha, hppa, microblaze, sh + some bonus commits

25 files changed, 1318 insertions(+), 284 deletions(-)

lib/std/Target.zig+375-151
......@@ -72,6 +72,7 @@ pub const Os = struct {
7272
7373 // LLVM tags deliberately omitted:
7474 // - bridgeos
75 // - cheriotrtos
7576 // - darwin
7677 // - kfreebsd
7778 // - nacl
......@@ -732,6 +733,7 @@ pub const Os = struct {
732733};
733734
734735pub const aarch64 = @import("Target/aarch64.zig");
736pub const alpha = @import("Target/generic.zig");
735737pub const amdgcn = @import("Target/amdgcn.zig");
736738pub const arc = @import("Target/arc.zig");
737739pub const arm = @import("Target/arm.zig");
......@@ -739,10 +741,12 @@ pub const avr = @import("Target/avr.zig");
739741pub const bpf = @import("Target/bpf.zig");
740742pub const csky = @import("Target/csky.zig");
741743pub const hexagon = @import("Target/hexagon.zig");
744pub const hppa = @import("Target/generic.zig");
742745pub const kalimba = @import("Target/generic.zig");
743746pub const lanai = @import("Target/lanai.zig");
744747pub const loongarch = @import("Target/loongarch.zig");
745748pub const m68k = @import("Target/m68k.zig");
749pub const microblaze = @import("Target/generic.zig");
746750pub const mips = @import("Target/mips.zig");
747751pub const msp430 = @import("Target/msp430.zig");
748752pub const nvptx = @import("Target/nvptx.zig");
......@@ -751,6 +755,7 @@ pub const powerpc = @import("Target/powerpc.zig");
751755pub const propeller = @import("Target/propeller.zig");
752756pub const riscv = @import("Target/riscv.zig");
753757pub const s390x = @import("Target/s390x.zig");
758pub const sh = @import("Target/generic.zig");
754759pub const sparc = @import("Target/sparc.zig");
755760pub const spirv = @import("Target/spirv.zig");
756761pub const ve = @import("Target/ve.zig");
......@@ -800,14 +805,22 @@ pub const Abi = enum {
800805 // - coreclr
801806 // - domain
802807 // - geometry
808 // - gnueabit64
809 // - gnueabihft64
803810 // - gnuf64
811 // - gnut64
804812 // - hull
805813 // - intersection
806814 // - library
815 // - llvm
807816 // - mesh
808817 // - miss
818 // - mlibc
819 // - mtia
820 // - pauthtest
809821 // - pixel
810822 // - raygeneration
823 // - rootsignature
811824 // - vertex
812825
813826 pub fn default(arch: Cpu.Arch, os_tag: Os.Tag) Abi {
......@@ -816,13 +829,16 @@ pub const Abi = enum {
816829 // Soft float is usually a sane default for freestanding.
817830 .arm,
818831 .armeb,
819 .thumb,
820 .thumbeb,
821832 .csky,
833 .hppa,
822834 .mips,
823835 .mipsel,
824836 .powerpc,
825837 .powerpcle,
838 .sh,
839 .sheb,
840 .thumb,
841 .thumbeb,
826842 => .eabi,
827843 else => .none,
828844 },
......@@ -837,20 +853,34 @@ pub const Abi = enum {
837853 .linux => switch (arch) {
838854 .arm,
839855 .armeb,
840 .thumb,
841 .thumbeb,
842856 .powerpc,
843857 .powerpcle,
858 .thumb,
859 .thumbeb,
844860 => .musleabihf,
845 // Soft float tends to be more common for CSKY and MIPS.
846 .csky,
847 => .gnueabi, // No musl support.
848861 .mips,
849862 .mipsel,
850863 => .musleabi,
851864 .mips64,
852865 .mips64el,
853866 => .muslabi64,
867
868 // No musl support.
869 .arc,
870 .arceb,
871 => .gnu,
872 .csky,
873 => .gnueabi,
874 .hppa,
875 .sh,
876 .sheb,
877 => .gnueabihf,
878
879 // No glibc or musl support.
880 .xtensa,
881 .xtensaeb,
882 => .none,
883
854884 else => .musl,
855885 },
856886 .rtems => switch (arch) {
......@@ -1044,18 +1074,21 @@ pub const ObjectFormat = enum {
10441074
10451075pub fn toElfMachine(target: *const Target) std.elf.EM {
10461076 return switch (target.cpu.arch) {
1077 .aarch64, .aarch64_be => .AARCH64,
1078 .alpha => .ALPHA,
10471079 .amdgcn => .AMDGPU,
1048 .arc => .ARC_COMPACT,
1080 .arc, .arceb => .ARC_COMPACT,
10491081 .arm, .armeb, .thumb, .thumbeb => .ARM,
1050 .aarch64, .aarch64_be => .AARCH64,
10511082 .avr => .AVR,
1052 .bpfel, .bpfeb => .BPF,
1083 .bpfeb, .bpfel => .BPF,
10531084 .csky => .CSKY,
10541085 .hexagon => .QDSP6,
1086 .hppa, .hppa64 => .PARISC,
10551087 .kalimba => .CSR_KALIMBA,
10561088 .lanai => .LANAI,
10571089 .loongarch32, .loongarch64 => .LOONGARCH,
10581090 .m68k => .@"68K",
1091 .microblaze, .microblazeel => .MICROBLAZE,
10591092 .mips, .mips64, .mipsel, .mips64el => .MIPS,
10601093 .msp430 => .MSP430,
10611094 .or1k => .OR1K,
......@@ -1064,13 +1097,14 @@ pub fn toElfMachine(target: *const Target) std.elf.EM {
10641097 .propeller => .PROPELLER,
10651098 .riscv32, .riscv32be, .riscv64, .riscv64be => .RISCV,
10661099 .s390x => .S390,
1100 .sh, .sheb => .SH,
10671101 .sparc => if (target.cpu.has(.sparc, .v9)) .SPARC32PLUS else .SPARC,
10681102 .sparc64 => .SPARCV9,
10691103 .ve => .VE,
10701104 .x86 => .@"386",
10711105 .x86_64 => .X86_64,
10721106 .xcore => .XCORE,
1073 .xtensa => .XTENSA,
1107 .xtensa, .xtensaeb => .XTENSA,
10741108
10751109 .nvptx,
10761110 .nvptx64,
......@@ -1084,54 +1118,63 @@ pub fn toElfMachine(target: *const Target) std.elf.EM {
10841118
10851119pub fn toCoffMachine(target: *const Target) std.coff.IMAGE.FILE.MACHINE {
10861120 return switch (target.cpu.arch) {
1121 .alpha => .ALPHA64,
10871122 .arm => .ARM,
10881123 .thumb => .ARMNT,
10891124 .aarch64 => .ARM64,
10901125 .loongarch32 => .LOONGARCH32,
10911126 .loongarch64 => .LOONGARCH64,
1127 .mips => .R3000BE,
1128 .mipsel => .R3000,
1129 .mips64el => .R4000,
1130 .powerpcle => .POWERPC,
10921131 .riscv32 => .RISCV32,
10931132 .riscv64 => .RISCV64,
1133 .sh => .SH3,
10941134 .x86 => .I386,
10951135 .x86_64 => .AMD64,
10961136
1137 .aarch64_be,
10971138 .amdgcn,
10981139 .arc,
1140 .arceb,
10991141 .armeb,
1100 .thumbeb,
1101 .aarch64_be,
11021142 .avr,
1103 .bpfel,
11041143 .bpfeb,
1144 .bpfel,
11051145 .csky,
11061146 .hexagon,
1147 .hppa,
1148 .hppa64,
11071149 .kalimba,
11081150 .lanai,
11091151 .m68k,
1110 .mips,
1111 .mipsel,
1152 .microblaze,
1153 .microblazeel,
11121154 .mips64,
1113 .mips64el,
11141155 .msp430,
1115 .or1k,
11161156 .nvptx,
11171157 .nvptx64,
1158 .or1k,
11181159 .powerpc,
1119 .powerpcle,
11201160 .powerpc64,
11211161 .powerpc64le,
1162 .propeller,
11221163 .riscv32be,
11231164 .riscv64be,
11241165 .s390x,
1166 .sheb,
11251167 .sparc,
11261168 .sparc64,
11271169 .spirv32,
11281170 .spirv64,
1171 .thumbeb,
11291172 .ve,
11301173 .wasm32,
11311174 .wasm64,
11321175 .xcore,
11331176 .xtensa,
1134 .propeller,
1177 .xtensaeb,
11351178 => .UNKNOWN,
11361179 };
11371180}
......@@ -1300,32 +1343,36 @@ pub const Cpu = struct {
13001343 };
13011344
13021345 pub const Arch = enum {
1346 aarch64,
1347 aarch64_be,
1348 alpha,
13031349 amdgcn,
13041350 arc,
1351 arceb,
13051352 arm,
13061353 armeb,
1307 thumb,
1308 thumbeb,
1309 aarch64,
1310 aarch64_be,
13111354 avr,
1312 bpfel,
13131355 bpfeb,
1356 bpfel,
13141357 csky,
13151358 hexagon,
1359 hppa,
1360 hppa64,
13161361 kalimba,
13171362 lanai,
13181363 loongarch32,
13191364 loongarch64,
13201365 m68k,
1366 microblaze,
1367 microblazeel,
13211368 mips,
13221369 mipsel,
13231370 mips64,
13241371 mips64el,
13251372 msp430,
1326 or1k,
13271373 nvptx,
13281374 nvptx64,
1375 or1k,
13291376 powerpc,
13301377 powerpcle,
13311378 powerpc64,
......@@ -1336,10 +1383,14 @@ pub const Cpu = struct {
13361383 riscv64,
13371384 riscv64be,
13381385 s390x,
1386 sh,
1387 sheb,
13391388 sparc,
13401389 sparc64,
13411390 spirv32,
13421391 spirv64,
1392 thumb,
1393 thumbeb,
13431394 ve,
13441395 wasm32,
13451396 wasm64,
......@@ -1347,14 +1398,13 @@ pub const Cpu = struct {
13471398 x86_64,
13481399 xcore,
13491400 xtensa,
1401 xtensaeb,
13501402
13511403 // LLVM tags deliberately omitted:
13521404 // - aarch64_32
13531405 // - amdil
13541406 // - amdil64
13551407 // - dxil
1356 // - le32
1357 // - le64
13581408 // - r600
13591409 // - hsail
13601410 // - hsail64
......@@ -1372,18 +1422,21 @@ pub const Cpu = struct {
13721422 /// For a given family tag, it is guaranteed that an `std.Target.<tag>` namespace exists
13731423 /// containing CPU model and feature data.
13741424 pub const Family = enum {
1425 aarch64,
1426 alpha,
13751427 amdgcn,
13761428 arc,
13771429 arm,
1378 aarch64,
13791430 avr,
13801431 bpf,
13811432 csky,
13821433 hexagon,
1434 hppa,
13831435 kalimba,
13841436 lanai,
13851437 loongarch,
13861438 m68k,
1439 microblaze,
13871440 mips,
13881441 msp430,
13891442 nvptx,
......@@ -1392,6 +1445,7 @@ pub const Cpu = struct {
13921445 propeller,
13931446 riscv,
13941447 s390x,
1448 sh,
13951449 sparc,
13961450 spirv,
13971451 ve,
......@@ -1403,18 +1457,21 @@ pub const Cpu = struct {
14031457
14041458 pub inline fn family(arch: Arch) Family {
14051459 return switch (arch) {
1460 .aarch64, .aarch64_be => .aarch64,
1461 .alpha => .alpha,
14061462 .amdgcn => .amdgcn,
1407 .arc => .arc,
1463 .arc, .arceb => .arc,
14081464 .arm, .armeb, .thumb, .thumbeb => .arm,
1409 .aarch64, .aarch64_be => .aarch64,
14101465 .avr => .avr,
1411 .bpfel, .bpfeb => .bpf,
1466 .bpfeb, .bpfel => .bpf,
14121467 .csky => .csky,
14131468 .hexagon => .hexagon,
1469 .hppa, .hppa64 => .hppa,
14141470 .kalimba => .kalimba,
14151471 .lanai => .lanai,
14161472 .loongarch32, .loongarch64 => .loongarch,
14171473 .m68k => .m68k,
1474 .microblaze, .microblazeel => .microblaze,
14181475 .mips, .mipsel, .mips64, .mips64el => .mips,
14191476 .msp430 => .msp430,
14201477 .or1k => .or1k,
......@@ -1423,13 +1480,14 @@ pub const Cpu = struct {
14231480 .propeller => .propeller,
14241481 .riscv32, .riscv32be, .riscv64, .riscv64be => .riscv,
14251482 .s390x => .s390x,
1483 .sh, .sheb => .sh,
14261484 .sparc, .sparc64 => .sparc,
14271485 .spirv32, .spirv64 => .spirv,
14281486 .ve => .ve,
14291487 .wasm32, .wasm64 => .wasm,
14301488 .x86, .x86_64 => .x86,
14311489 .xcore => .xcore,
1432 .xtensa => .xtensa,
1490 .xtensa, .xtensaeb => .xtensa,
14331491 };
14341492 }
14351493
......@@ -1462,6 +1520,20 @@ pub const Cpu = struct {
14621520 };
14631521 }
14641522
1523 pub inline fn isArc(arch: Arch) bool {
1524 return switch (arch) {
1525 .arc, .arceb => true,
1526 else => false,
1527 };
1528 }
1529
1530 pub inline fn isHppa(arch: Arch) bool {
1531 return switch (arch) {
1532 .hppa, .hppa64 => true,
1533 else => false,
1534 };
1535 }
1536
14651537 pub inline fn isWasm(arch: Arch) bool {
14661538 return switch (arch) {
14671539 .wasm32, .wasm64 => true,
......@@ -1494,6 +1566,13 @@ pub const Cpu = struct {
14941566 };
14951567 }
14961568
1569 pub inline fn isMicroblaze(arch: Arch) bool {
1570 return switch (arch) {
1571 .microblaze, .microblazeel => true,
1572 else => false,
1573 };
1574 }
1575
14971576 pub inline fn isMIPS(arch: Arch) bool {
14981577 return arch.isMIPS32() or arch.isMIPS64();
14991578 }
......@@ -1544,6 +1623,13 @@ pub const Cpu = struct {
15441623 };
15451624 }
15461625
1626 pub inline fn isSh(arch: Arch) bool {
1627 return switch (arch) {
1628 .sh, .sheb => true,
1629 else => false,
1630 };
1631 }
1632
15471633 pub inline fn isBpf(arch: Arch) bool {
15481634 return switch (arch) {
15491635 .bpfel, .bpfeb => true,
......@@ -1558,6 +1644,13 @@ pub const Cpu = struct {
15581644 };
15591645 }
15601646
1647 pub inline fn isXtensa(arch: Arch) bool {
1648 return switch (arch) {
1649 .xtensa, .xtensaeb => true,
1650 else => false,
1651 };
1652 }
1653
15611654 pub fn parseCpuModel(arch: Arch, cpu_name: []const u8) !*const Cpu.Model {
15621655 for (arch.allCpuModels()) |cpu| {
15631656 if (std.mem.eql(u8, cpu_name, cpu.name)) {
......@@ -1569,44 +1662,46 @@ pub const Cpu = struct {
15691662
15701663 pub fn endian(arch: Arch) std.builtin.Endian {
15711664 return switch (arch) {
1572 .avr,
1573 .arm,
15741665 .aarch64,
1575 .amdgcn,
1666 .alpha,
1667 .arm,
1668 .arc,
1669 .avr,
15761670 .bpfel,
15771671 .csky,
1578 .xtensa,
15791672 .hexagon,
15801673 .kalimba,
1674 .loongarch32,
1675 .loongarch64,
1676 .microblazeel,
15811677 .mipsel,
15821678 .mips64el,
15831679 .msp430,
1584 .nvptx,
1585 .nvptx64,
15861680 .powerpcle,
15871681 .powerpc64le,
1682 .propeller,
15881683 .riscv32,
15891684 .riscv64,
1590 .x86,
1591 .x86_64,
1685 .sh,
1686 .thumb,
1687 .ve,
15921688 .wasm32,
15931689 .wasm64,
1690 .x86,
1691 .x86_64,
15941692 .xcore,
1595 .thumb,
1596 .ve,
1597 // GPU bitness is opaque. For now, assume little endian.
1598 .spirv32,
1599 .spirv64,
1600 .loongarch32,
1601 .loongarch64,
1602 .arc,
1603 .propeller,
1693 .xtensa,
16041694 => .little,
16051695
1606 .armeb,
16071696 .aarch64_be,
1697 .arceb,
1698 .armeb,
16081699 .bpfeb,
1700 .hppa,
1701 .hppa64,
1702 .lanai,
16091703 .m68k,
1704 .microblaze,
16101705 .mips,
16111706 .mips64,
16121707 .or1k,
......@@ -1614,12 +1709,21 @@ pub const Cpu = struct {
16141709 .powerpc64,
16151710 .riscv32be,
16161711 .riscv64be,
1712 .s390x,
1713 .sheb,
16171714 .thumbeb,
16181715 .sparc,
16191716 .sparc64,
1620 .lanai,
1621 .s390x,
1717 .xtensaeb,
16221718 => .big,
1719
1720 // GPU endianness is opaque. For now, assume little endian.
1721 .amdgcn,
1722 .nvptx,
1723 .nvptx64,
1724 .spirv32,
1725 .spirv64,
1726 => .little,
16231727 };
16241728 }
16251729
......@@ -1683,6 +1787,7 @@ pub const Cpu = struct {
16831787 => unreachable,
16841788
16851789 .x86_64_sysv,
1790 .x86_64_x32,
16861791 .x86_64_win,
16871792 .x86_64_regcall_v3_sysv,
16881793 .x86_64_regcall_v4_win,
......@@ -1709,6 +1814,9 @@ pub const Cpu = struct {
17091814 .aarch64_vfabi_sve,
17101815 => &.{ .aarch64, .aarch64_be },
17111816
1817 .alpha_osf,
1818 => &.{.alpha},
1819
17121820 .arm_aapcs,
17131821 .arm_aapcs_vfp,
17141822 .arm_interrupt,
......@@ -1755,7 +1863,7 @@ pub const Cpu = struct {
17551863
17561864 .arc_sysv,
17571865 .arc_interrupt,
1758 => &.{.arc},
1866 => &.{ .arc, .arceb },
17591867
17601868 .avr_gnu,
17611869 .avr_builtin,
......@@ -1774,6 +1882,12 @@ pub const Cpu = struct {
17741882 .hexagon_sysv_hvx,
17751883 => &.{.hexagon},
17761884
1885 .hppa_elf,
1886 => &.{.hppa},
1887
1888 .hppa64_elf,
1889 => &.{.hppa64},
1890
17771891 .lanai_sysv,
17781892 => &.{.lanai},
17791893
......@@ -1789,7 +1903,12 @@ pub const Cpu = struct {
17891903 .m68k_interrupt,
17901904 => &.{.m68k},
17911905
1906 .microblaze_std,
1907 .microblaze_interrupt,
1908 => &.{ .microblaze, .microblazeel },
1909
17921910 .msp430_eabi,
1911 .msp430_interrupt,
17931912 => &.{.msp430},
17941913
17951914 .or1k_sysv,
......@@ -1802,6 +1921,11 @@ pub const Cpu = struct {
18021921 .s390x_sysv_vx,
18031922 => &.{.s390x},
18041923
1924 .sh_gnu,
1925 .sh_renesas,
1926 .sh_interrupt,
1927 => &.{ .sh, .sheb },
1928
18051929 .ve_sysv,
18061930 => &.{.ve},
18071931
......@@ -1811,7 +1935,7 @@ pub const Cpu = struct {
18111935
18121936 .xtensa_call0,
18131937 .xtensa_windowed,
1814 => &.{.xtensa},
1938 => &.{ .xtensa, .xtensaeb },
18151939
18161940 .amdgcn_device,
18171941 .amdgcn_kernel,
......@@ -2104,6 +2228,21 @@ pub fn requiresLibC(target: *const Target) bool {
21042228 };
21052229}
21062230
2231/// The places where a user can specify an address space attribute
2232pub const AddressSpaceContext = enum {
2233 /// A function is specified to be placed in a certain address space.
2234 function,
2235 /// A (global) variable is specified to be placed in a certain address space. In contrast to
2236 /// `.constant`, these values (and thus the address space they will be placed in) are required
2237 /// to be mutable.
2238 variable,
2239 /// A (global) constant value is specified to be placed in a certain address space. In contrast
2240 /// to `.variable`, values placed in this address space are not required to be mutable.
2241 constant,
2242 /// A pointer is ascripted to point into a certain address space.
2243 pointer,
2244};
2245
21072246/// Returns whether this target supports `address_space`. If `context` is `null`, this
21082247/// function simply answers the general question of whether the target has any concept
21092248/// of `address_space`; if non-`null`, the function additionally checks whether
......@@ -2111,7 +2250,7 @@ pub fn requiresLibC(target: *const Target) bool {
21112250pub fn supportsAddressSpace(
21122251 target: Target,
21132252 address_space: std.builtin.AddressSpace,
2114 context: ?std.builtin.AddressSpace.Context,
2253 context: ?AddressSpaceContext,
21152254) bool {
21162255 const arch = target.cpu.arch;
21172256
......@@ -2343,7 +2482,10 @@ pub const DynamicLinker = struct {
23432482
23442483 .aarch64,
23452484 .aarch64_be,
2485 .hexagon,
23462486 .m68k,
2487 .microblaze,
2488 .microblazeel,
23472489 .powerpc64,
23482490 .powerpc64le,
23492491 .s390x,
......@@ -2379,6 +2521,17 @@ pub const DynamicLinker = struct {
23792521 else => return none,
23802522 }}),
23812523
2524 .sh,
2525 .sheb,
2526 => |arch| initFmt("/lib/ld-musl-{t}{s}.so.1", .{
2527 arch,
2528 switch (abi) {
2529 .musleabi => "-nofpu",
2530 .musleabihf => "",
2531 else => return none,
2532 },
2533 }),
2534
23822535 .riscv32,
23832536 .riscv64,
23842537 => |arch| if (abi == .musl) initFmt("/lib/ld-musl-{s}{s}.so.1", .{
......@@ -2392,6 +2545,7 @@ pub const DynamicLinker = struct {
23922545 }) else none,
23932546
23942547 .x86 => if (abi == .musl) init("/lib/ld-musl-i386.so.1") else none,
2548
23952549 .x86_64 => initFmt("/lib/ld-musl-{s}.so.1", .{switch (abi) {
23962550 .musl => "x86_64",
23972551 .muslx32 => "x32",
......@@ -2402,9 +2556,10 @@ pub const DynamicLinker = struct {
24022556 }
24032557 else if (abi.isGnu())
24042558 switch (cpu.arch) {
2405 // TODO: `eb` architecture support.
24062559 // TODO: `700` ABI support.
2407 .arc => if (abi == .gnu) init("/lib/ld-linux-arc.so.2") else none,
2560 .arc,
2561 .arceb,
2562 => |arch| if (abi == .gnu) initFmt("/lib/ld-linux-{t}.so.2", .{arch}) else none,
24082563
24092564 .arm,
24102565 .armeb,
......@@ -2434,7 +2589,13 @@ pub const DynamicLinker = struct {
24342589 else => return none,
24352590 }}),
24362591
2437 .m68k => if (abi == .gnu) init("/lib/ld.so.1") else none,
2592 .hppa,
2593 .m68k,
2594 .microblaze,
2595 .microblazeel,
2596 .xtensa,
2597 .xtensaeb,
2598 => if (abi == .gnu) init("/lib/ld.so.1") else none,
24382599
24392600 .mips,
24402601 .mipsel,
......@@ -2464,6 +2625,7 @@ pub const DynamicLinker = struct {
24642625 => init("/lib/ld.so.1"),
24652626 else => none,
24662627 },
2628
24672629 .powerpc64,
24682630 .powerpc64le,
24692631 => if (abi == .gnu) init("/lib64/ld64.so.2") else none,
......@@ -2486,18 +2648,28 @@ pub const DynamicLinker = struct {
24862648
24872649 .s390x => if (abi == .gnu) init("/lib/ld64.so.1") else none,
24882650
2489 .sparc => if (abi == .gnu) init("/lib/ld-linux.so.2") else none,
2651 .sh,
2652 .sheb,
2653 => switch (abi) {
2654 .gnueabi,
2655 .gnueabihf,
2656 => init("/lib/ld-linux.so.2"),
2657 else => none,
2658 },
2659
2660 .alpha,
2661 .sparc,
2662 .x86,
2663 => if (abi == .gnu) init("/lib/ld-linux.so.2") else none,
2664
24902665 .sparc64 => if (abi == .gnu) init("/lib64/ld-linux.so.2") else none,
24912666
2492 .x86 => if (abi == .gnu) init("/lib/ld-linux.so.2") else none,
24932667 .x86_64 => switch (abi) {
24942668 .gnu => init("/lib64/ld-linux-x86-64.so.2"),
24952669 .gnux32 => init("/libx32/ld-linux-x32.so.2"),
24962670 else => none,
24972671 },
24982672
2499 .xtensa => if (abi == .gnu) init("/lib/ld.so.1") else none,
2500
25012673 else => none,
25022674 }
25032675 else
......@@ -2664,52 +2836,61 @@ pub fn ptrBitWidth_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) u16 {
26642836 => 16,
26652837
26662838 .arc,
2839 .arceb,
26672840 .arm,
26682841 .armeb,
26692842 .csky,
26702843 .hexagon,
2844 .hppa,
2845 .kalimba,
2846 .lanai,
2847 .loongarch32,
26712848 .m68k,
2849 .microblaze,
2850 .microblazeel,
26722851 .mips,
26732852 .mipsel,
2853 .nvptx,
26742854 .or1k,
26752855 .powerpc,
26762856 .powerpcle,
2857 .propeller,
26772858 .riscv32,
26782859 .riscv32be,
2860 .sh,
2861 .sheb,
2862 .sparc,
2863 .spirv32,
26792864 .thumb,
26802865 .thumbeb,
2866 .wasm32,
26812867 .x86,
26822868 .xcore,
2683 .nvptx,
2684 .kalimba,
2685 .lanai,
2686 .wasm32,
2687 .sparc,
2688 .spirv32,
2689 .loongarch32,
26902869 .xtensa,
2691 .propeller,
2870 .xtensaeb,
26922871 => 32,
26932872
26942873 .aarch64,
26952874 .aarch64_be,
2875 .alpha,
2876 .amdgcn,
2877 .bpfeb,
2878 .bpfel,
2879 .hppa64,
2880 .loongarch64,
26962881 .mips64,
26972882 .mips64el,
2883 .nvptx64,
26982884 .powerpc64,
26992885 .powerpc64le,
27002886 .riscv64,
27012887 .riscv64be,
2702 .x86_64,
2703 .nvptx64,
2704 .wasm64,
2705 .amdgcn,
2706 .bpfel,
2707 .bpfeb,
2708 .sparc64,
27092888 .s390x,
2710 .ve,
2889 .sparc64,
27112890 .spirv64,
2712 .loongarch64,
2891 .ve,
2892 .wasm64,
2893 .x86_64,
27132894 => 64,
27142895 };
27152896}
......@@ -2727,17 +2908,20 @@ pub fn stackAlignment(target: *const Target) u16 {
27272908 => return 4,
27282909 .arm,
27292910 .armeb,
2730 .thumb,
2731 .thumbeb,
2911 .hppa,
27322912 .lanai,
27332913 .mips,
27342914 .mipsel,
27352915 .sparc,
2916 .thumb,
2917 .thumbeb,
27362918 => return 8,
27372919 .aarch64,
27382920 .aarch64_be,
2921 .alpha,
27392922 .bpfeb,
27402923 .bpfel,
2924 .hppa64,
27412925 .loongarch32,
27422926 .loongarch64,
27432927 .mips64,
......@@ -2765,6 +2949,24 @@ pub fn stackAlignment(target: *const Target) u16 {
27652949 return @divExact(target.ptrBitWidth(), 8);
27662950}
27672951
2952pub const StackGrowth = enum {
2953 down,
2954 up,
2955};
2956
2957pub fn stackGrowth(target: *const Target) StackGrowth {
2958 // Strictly speaking, most architectures don't inherently define the stack growth direction; you
2959 // could quite easily argue that it is in fact a property of the ABI. However, that's just not
2960 // really how it plays out in the real world. And besides, we have no mechanism for indicating
2961 // a different stack growth ABI, nor a compelling use case for creating such a mechanism.
2962 return switch (target.cpu.arch) {
2963 .hppa,
2964 .hppa64,
2965 => .up,
2966 else => .down,
2967 };
2968}
2969
27682970/// Default signedness of `char` for the native C compiler for this target
27692971/// Note that char signedness is implementation-defined and many compilers provide
27702972/// an option to override the default signedness e.g. GCC's -funsigned-char / -fsigned-char
......@@ -2772,13 +2974,12 @@ pub fn cCharSignedness(target: *const Target) std.builtin.Signedness {
27722974 if (target.os.tag.isDarwin() or target.os.tag == .windows or target.os.tag == .uefi) return .signed;
27732975
27742976 return switch (target.cpu.arch) {
2775 .arm,
2776 .armeb,
2777 .thumb,
2778 .thumbeb,
27792977 .aarch64,
27802978 .aarch64_be,
2979 .arm,
2980 .armeb,
27812981 .arc,
2982 .arceb,
27822983 .csky,
27832984 .hexagon,
27842985 .msp430,
......@@ -2791,8 +2992,11 @@ pub fn cCharSignedness(target: *const Target) std.builtin.Signedness {
27912992 .riscv32be,
27922993 .riscv64,
27932994 .riscv64be,
2995 .thumb,
2996 .thumbeb,
27942997 .xcore,
27952998 .xtensa,
2999 .xtensaeb,
27963000 => .unsigned,
27973001 else => .signed,
27983002 };
......@@ -2903,6 +3107,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
29033107 else => return 128,
29043108 },
29053109
3110 .alpha,
29063111 .riscv32,
29073112 .riscv32be,
29083113 .riscv64,
......@@ -2946,18 +3151,6 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
29463151 .wasi,
29473152 .emscripten,
29483153 => switch (target.cpu.arch) {
2949 .msp430 => switch (c_type) {
2950 .char => return 8,
2951 .short, .ushort, .int, .uint => return 16,
2952 .long, .ulong, .float => return 32,
2953 .longlong, .ulonglong, .double, .longdouble => return 64,
2954 },
2955 .avr => switch (c_type) {
2956 .char => return 8,
2957 .short, .ushort, .int, .uint => return 16,
2958 .long, .ulong, .float, .double, .longdouble => return 32,
2959 .longlong, .ulonglong => return 64,
2960 },
29613154 .mips64, .mips64el => switch (c_type) {
29623155 .char => return 8,
29633156 .short, .ushort => return 16,
......@@ -3024,6 +3217,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
30243217 },
30253218 },
30263219
3220 .alpha,
30273221 .riscv32,
30283222 .riscv32be,
30293223 .riscv64,
......@@ -3213,35 +3407,44 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
32133407 => 2,
32143408
32153409 .arc,
3410 .arceb,
32163411 .csky,
3412 .kalimba,
3413 .microblaze,
3414 .microblazeel,
3415 .or1k,
3416 .propeller,
3417 .sh,
3418 .sheb,
32173419 .x86,
32183420 .xcore,
3219 .or1k,
3220 .kalimba,
32213421 .xtensa,
3222 .propeller,
3422 .xtensaeb,
32233423 => 4,
32243424
3425 .amdgcn,
32253426 .arm,
32263427 .armeb,
3227 .thumb,
3228 .thumbeb,
3229 .amdgcn,
3230 .bpfel,
32313428 .bpfeb,
3429 .bpfel,
32323430 .hexagon,
3431 .hppa,
3432 .lanai,
32333433 .m68k,
32343434 .mips,
32353435 .mipsel,
3236 .sparc,
3237 .lanai,
32383436 .nvptx,
32393437 .nvptx64,
32403438 .s390x,
3439 .sparc,
3440 .thumb,
3441 .thumbeb,
32413442 => 8,
32423443
32433444 .aarch64,
32443445 .aarch64_be,
3446 .alpha,
3447 .hppa64,
32453448 .loongarch32,
32463449 .loongarch64,
32473450 .mips64,
......@@ -3257,10 +3460,10 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
32573460 .sparc64,
32583461 .spirv32,
32593462 .spirv64,
3260 .x86_64,
32613463 .ve,
32623464 .wasm32,
32633465 .wasm64,
3466 .x86_64,
32643467 => 16,
32653468
32663469 .avr,
......@@ -3272,7 +3475,7 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
32723475pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
32733476 // Overrides for unusual alignments
32743477 switch (target.cpu.arch) {
3275 .arc => switch (c_type) {
3478 .arc, .arceb => switch (c_type) {
32763479 .longdouble => return 4,
32773480 else => {},
32783481 },
......@@ -3310,36 +3513,45 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
33103513 @as(u16, switch (target.cpu.arch) {
33113514 .msp430 => 2,
33123515
3516 .arc,
3517 .arceb,
33133518 .csky,
3314 .xcore,
3315 .or1k,
33163519 .kalimba,
3317 .xtensa,
3520 .microblaze,
3521 .microblazeel,
3522 .or1k,
33183523 .propeller,
3524 .sh,
3525 .sheb,
3526 .xcore,
3527 .xtensa,
3528 .xtensaeb,
33193529 => 4,
33203530
3321 .arc,
3531 .amdgcn,
33223532 .arm,
33233533 .armeb,
3324 .thumb,
3325 .thumbeb,
3326 .amdgcn,
3327 .bpfel,
33283534 .bpfeb,
3535 .bpfel,
33293536 .hexagon,
3330 .x86,
3537 .hppa,
3538 .lanai,
33313539 .m68k,
33323540 .mips,
33333541 .mipsel,
3334 .sparc,
3335 .lanai,
33363542 .nvptx,
33373543 .nvptx64,
33383544 .s390x,
3545 .sparc,
3546 .thumb,
3547 .thumbeb,
3548 .x86,
33393549 => 8,
33403550
33413551 .aarch64,
33423552 .aarch64_be,
3553 .alpha,
3554 .hppa64,
33433555 .loongarch32,
33443556 .loongarch64,
33453557 .mips64,
......@@ -3355,10 +3567,10 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
33553567 .sparc64,
33563568 .spirv32,
33573569 .spirv64,
3358 .x86_64,
33593570 .ve,
33603571 .wasm32,
33613572 .wasm64,
3573 .x86_64,
33623574 => 16,
33633575
33643576 .avr,
......@@ -3373,32 +3585,49 @@ pub fn cMaxIntAlignment(target: *const Target) u16 {
33733585
33743586 .msp430 => 2,
33753587
3376 .xcore,
3588 .arc,
3589 .arceb,
3590 .csky,
3591 .kalimba,
3592 .microblaze,
3593 .microblazeel,
3594 .or1k,
33773595 .propeller,
3596 .sh,
3597 .sheb,
3598 .xcore,
33783599 => 4,
33793600
3380 .amdgcn,
33813601 .arm,
33823602 .armeb,
3383 .thumb,
3384 .thumbeb,
3385 .lanai,
33863603 .hexagon,
3604 .hppa,
3605 .lanai,
3606 .loongarch32,
3607 .m68k,
33873608 .mips,
33883609 .mipsel,
3389 .or1k,
33903610 .powerpc,
33913611 .powerpcle,
33923612 .riscv32,
33933613 .riscv32be,
33943614 .s390x,
3615 .sparc,
3616 .thumb,
3617 .thumbeb,
3618 .x86,
3619 .xtensa,
3620 .xtensaeb,
33953621 => 8,
33963622
3397 // Even LLVMABIAlignmentOfType(i128) agrees on these targets.
33983623 .aarch64,
33993624 .aarch64_be,
3625 .alpha,
3626 .amdgcn,
34003627 .bpfel,
34013628 .bpfeb,
3629 .hppa64,
3630 .loongarch64,
34023631 .mips64,
34033632 .mips64el,
34043633 .nvptx,
......@@ -3407,26 +3636,13 @@ pub fn cMaxIntAlignment(target: *const Target) u16 {
34073636 .powerpc64le,
34083637 .riscv64,
34093638 .riscv64be,
3410 .sparc,
34113639 .sparc64,
3412 .wasm32,
3413 .wasm64,
3414 .x86,
3415 .x86_64,
3416 => 16,
3417
3418 // Below this comment are unverified but based on the fact that C requires
3419 // int128_t to be 16 bytes aligned, it's a safe default.
3420 .arc,
3421 .csky,
3422 .kalimba,
3423 .loongarch32,
3424 .loongarch64,
3425 .m68k,
34263640 .spirv32,
34273641 .spirv64,
34283642 .ve,
3429 .xtensa,
3643 .wasm32,
3644 .wasm64,
3645 .x86_64,
34303646 => 16,
34313647 };
34323648}
......@@ -3435,24 +3651,28 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
34353651 return switch (target.cpu.arch) {
34363652 .x86_64 => switch (target.os.tag) {
34373653 .windows, .uefi => .{ .x86_64_win = .{} },
3438 else => .{ .x86_64_sysv = .{} },
3654 else => switch (target.abi) {
3655 .gnuabin32, .muslabin32 => .{ .x86_64_x32 = .{} },
3656 else => .{ .x86_64_sysv = .{} },
3657 },
34393658 },
34403659 .x86 => switch (target.os.tag) {
34413660 .windows, .uefi => .{ .x86_win = .{} },
34423661 else => .{ .x86_sysv = .{} },
34433662 },
3444 .aarch64, .aarch64_be => if (target.os.tag.isDarwin()) cc: {
3445 break :cc .{ .aarch64_aapcs_darwin = .{} };
3446 } else switch (target.os.tag) {
3663 .aarch64, .aarch64_be => if (target.os.tag.isDarwin())
3664 .{ .aarch64_aapcs_darwin = .{} }
3665 else switch (target.os.tag) {
34473666 .windows => .{ .aarch64_aapcs_win = .{} },
34483667 else => .{ .aarch64_aapcs = .{} },
34493668 },
3669 .alpha => .{ .alpha_osf = .{} },
34503670 .arm, .armeb, .thumb, .thumbeb => switch (target.abi.float()) {
34513671 .soft => .{ .arm_aapcs = .{} },
34523672 .hard => .{ .arm_aapcs_vfp = .{} },
34533673 },
34543674 .mips64, .mips64el => switch (target.abi) {
3455 .gnuabin32 => .{ .mips64_n32 = .{} },
3675 .gnuabin32, .muslabin32 => .{ .mips64_n32 = .{} },
34563676 else => .{ .mips64_n64 = .{} },
34573677 },
34583678 .mips, .mipsel => .{ .mips_o32 = .{} },
......@@ -3470,11 +3690,13 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
34703690 else => .{ .powerpc_sysv = .{} },
34713691 },
34723692 .wasm32, .wasm64 => .{ .wasm_mvp = .{} },
3473 .arc => .{ .arc_sysv = .{} },
3693 .arc, .arceb => .{ .arc_sysv = .{} },
34743694 .avr => .avr_gnu,
34753695 .bpfel, .bpfeb => .{ .bpf_std = .{} },
34763696 .csky => .{ .csky_sysv = .{} },
34773697 .hexagon => .{ .hexagon_sysv = .{} },
3698 .hppa => .{ .hppa_elf = .{} },
3699 .hppa64 => .{ .hppa64_elf = .{} },
34783700 .kalimba => null,
34793701 .lanai => .{ .lanai_sysv = .{} },
34803702 .loongarch64 => .{ .loongarch64_lp64 = .{} },
......@@ -3483,13 +3705,15 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
34833705 .{ .m68k_gnu = .{} }
34843706 else
34853707 .{ .m68k_sysv = .{} },
3708 .microblaze, .microblazeel => .{ .microblaze_std = .{} },
34863709 .msp430 => .{ .msp430_eabi = .{} },
34873710 .or1k => .{ .or1k_sysv = .{} },
34883711 .propeller => .{ .propeller_sysv = .{} },
34893712 .s390x => .{ .s390x_sysv = .{} },
3713 .sh, .sheb => .{ .sh_gnu = .{} },
34903714 .ve => .{ .ve_sysv = .{} },
34913715 .xcore => .{ .xcore_xs1 = .{} },
3492 .xtensa => .{ .xtensa_call0 = .{} },
3716 .xtensa, .xtensaeb => .{ .xtensa_windowed = .{} },
34933717 .amdgcn => .{ .amdgcn_device = .{} },
34943718 .nvptx, .nvptx64 => .nvptx_device,
34953719 .spirv32, .spirv64 => .spirv_device,
lib/std/Thread.zig+70
......@@ -1235,6 +1235,18 @@ const LinuxThreadImpl = struct {
12351235 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
12361236 [len] "r" (self.mapped.len),
12371237 : .{ .memory = true }),
1238 .alpha => asm volatile (
1239 \\ ldi $0, 73 # SYS_munmap
1240 \\ mov %[ptr], $16
1241 \\ mov %[len], $17
1242 \\ callsys
1243 \\ ldi $0, 1 # SYS_exit
1244 \\ ldi $16, 0
1245 \\ callsys
1246 :
1247 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
1248 [len] "r" (self.mapped.len),
1249 : .{ .memory = true }),
12381250 .hexagon => asm volatile (
12391251 \\ r6 = #215 // SYS_munmap
12401252 \\ r0 = %[ptr]
......@@ -1247,6 +1259,42 @@ const LinuxThreadImpl = struct {
12471259 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
12481260 [len] "r" (self.mapped.len),
12491261 : .{ .memory = true }),
1262 .hppa => asm volatile (
1263 \\ ldi 91, %%r20 /* SYS_munmap */
1264 \\ copy %[ptr], %%r26
1265 \\ copy %[len], %%r25
1266 \\ ble 0x100(%%sr2, %%r0)
1267 \\ ldi 1, %%r20 /* SYS_exit */
1268 \\ ldi 0, %%r26
1269 \\ ble 0x100(%%sr2, %%r0)
1270 :
1271 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
1272 [len] "r" (self.mapped.len),
1273 : .{ .memory = true }),
1274 .m68k => asm volatile (
1275 \\ move.l #91, %%d0 // SYS_munmap
1276 \\ move.l %[ptr], %%d1
1277 \\ move.l %[len], %%d2
1278 \\ trap #0
1279 \\ move.l #1, %%d0 // SYS_exit
1280 \\ move.l #0, %%d1
1281 \\ trap #0
1282 :
1283 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
1284 [len] "r" (self.mapped.len),
1285 : .{ .memory = true }),
1286 .microblaze, .microblazeel => asm volatile (
1287 \\ ori r12, r0, 91 # SYS_munmap
1288 \\ ori r5, %[ptr], 0
1289 \\ ori r6, %[len], 0
1290 \\ brki r14, 0x8
1291 \\ ori r12, r0, 1 # SYS_exit
1292 \\ or r5, r0, r0
1293 \\ brki r14, 0x8
1294 :
1295 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
1296 [len] "r" (self.mapped.len),
1297 : .{ .memory = true }),
12501298 // We set `sp` to the address of the current function as a workaround for a Linux
12511299 // kernel bug that caused syscalls to return EFAULT if the stack pointer is invalid.
12521300 // The bug was introduced in 46e12c07b3b9603c60fc1d421ff18618241cb081 and fixed in
......@@ -1335,6 +1383,28 @@ const LinuxThreadImpl = struct {
13351383 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
13361384 [len] "r" (self.mapped.len),
13371385 : .{ .memory = true }),
1386 .sh, .sheb => asm volatile (
1387 \\ mov #91, r3 ! SYS_munmap
1388 \\ mov %[ptr], r4
1389 \\ mov %[len], r5
1390 \\ trapa #31
1391 \\ or r0, r0
1392 \\ or r0, r0
1393 \\ or r0, r0
1394 \\ or r0, r0
1395 \\ or r0, r0
1396 \\ mov #1, r3 ! SYS_exit
1397 \\ mov #0, r4
1398 \\ trapa #31
1399 \\ or r0, r0
1400 \\ or r0, r0
1401 \\ or r0, r0
1402 \\ or r0, r0
1403 \\ or r0, r0
1404 :
1405 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
1406 [len] "r" (self.mapped.len),
1407 : .{ .memory = true }),
13381408 .sparc => asm volatile (
13391409 \\ # See sparc64 comments below.
13401410 \\ 1:
lib/std/atomic.zig+11
......@@ -419,6 +419,7 @@ pub fn cacheLineForCpu(cpu: std.Target.Cpu) u16 {
419419 .aarch64,
420420 .aarch64_be,
421421 .arc,
422 .arceb,
422423 .powerpc64,
423424 .powerpc64le,
424425 => 128,
......@@ -432,20 +433,29 @@ pub fn cacheLineForCpu(cpu: std.Target.Cpu) u16 {
432433 // - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mipsle.go#L7
433434 // - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mips64x.go#L9
434435 // - https://github.com/torvalds/linux/blob/3a7e02c040b130b5545e4b115aada7bacd80a2b6/arch/sparc/include/asm/cache.h#L14
436 // - https://github.com/torvalds/linux/blob/3a7e02c040b130b5545e4b115aada7bacd80a2b6/arch/microblaze/include/asm/cache.h#L15
437 // - https://github.com/torvalds/linux/blob/3a7e02c040b130b5545e4b115aada7bacd80a2b6/arch/sh/include/cpu-sh4/cpu/cache.h#L10
435438 .arm,
436439 .armeb,
437440 .thumb,
438441 .thumbeb,
442 .microblaze,
443 .microblazeel,
439444 .mips,
440445 .mipsel,
441446 .mips64,
442447 .mips64el,
448 .sh,
449 .sheb,
443450 .sparc,
444451 .sparc64,
445452 => 32,
446453
447454 // - https://github.com/torvalds/linux/blob/3a7e02c040b130b5545e4b115aada7bacd80a2b6/arch/m68k/include/asm/cache.h#L10
448455 // - https://github.com/torvalds/linux/blob/3a7e02c040b130b5545e4b115aada7bacd80a2b6/arch/openrisc/include/asm/cache.h#L24
456 // - https://github.com/torvalds/linux/blob/3a7e02c040b130b5545e4b115aada7bacd80a2b6/arch/parisc/include/asm/cache.h#L16
457 .hppa,
458 .hppa64,
449459 .m68k,
450460 .or1k,
451461 => 16,
......@@ -468,6 +478,7 @@ pub fn cacheLineForCpu(cpu: std.Target.Cpu) u16 {
468478 // - https://github.com/golang/go/blob/19e923182e590ae6568c2c714f20f32512aeb3e3/src/internal/cpu/cpu_riscv64.go#L7
469479 // - https://github.com/torvalds/linux/blob/3a7e02c040b130b5545e4b115aada7bacd80a2b6/arch/xtensa/variants/csp/include/variant/core.h#L209
470480 // - https://github.com/torvalds/linux/blob/3a7e02c040b130b5545e4b115aada7bacd80a2b6/arch/csky/Kconfig#L183
481 // - https://github.com/torvalds/linux/blob/3a7e02c040b130b5545e4b115aada7bacd80a2b6/arch/alpha/include/asm/cache.h#L11
471482 // - https://www.xmos.com/download/The-XMOS-XS3-Architecture.pdf
472483 else => 64,
473484 };
lib/std/builtin.zig+85-18
......@@ -204,6 +204,7 @@ pub const CallingConvention = union(enum(u8)) {
204204
205205 // Calling conventions for the `x86_64` architecture.
206206 x86_64_sysv: CommonOptions,
207 x86_64_x32: CommonOptions,
207208 x86_64_win: CommonOptions,
208209 x86_64_regcall_v3_sysv: CommonOptions,
209210 x86_64_regcall_v4_win: CommonOptions,
......@@ -229,6 +230,9 @@ pub const CallingConvention = union(enum(u8)) {
229230 aarch64_vfabi: CommonOptions,
230231 aarch64_vfabi_sve: CommonOptions,
231232
233 /// The standard `alpha` calling convention.
234 alpha_osf: CommonOptions,
235
232236 // Calling convetions for the `arm`, `armeb`, `thumb`, and `thumbeb` architectures.
233237 /// ARM Architecture Procedure Call Standard
234238 arm_aapcs: CommonOptions,
......@@ -275,7 +279,7 @@ pub const CallingConvention = union(enum(u8)) {
275279 /// The standard `wasm32` and `wasm64` calling convention, as specified in the WebAssembly Tool Conventions.
276280 wasm_mvp: CommonOptions,
277281
278 /// The standard `arc` calling convention.
282 /// The standard `arc`/`arceb` calling convention.
279283 arc_sysv: CommonOptions,
280284 arc_interrupt: ArcInterruptOptions,
281285
......@@ -296,6 +300,12 @@ pub const CallingConvention = union(enum(u8)) {
296300 hexagon_sysv: CommonOptions,
297301 hexagon_sysv_hvx: CommonOptions,
298302
303 /// The standard `hppa` calling convention.
304 hppa_elf: CommonOptions,
305
306 /// The standard `hppa64` calling convention.
307 hppa64_elf: CommonOptions,
308
299309 /// The standard `lanai` calling convention.
300310 lanai_sysv: CommonOptions,
301311
......@@ -311,8 +321,13 @@ pub const CallingConvention = union(enum(u8)) {
311321 m68k_rtd: CommonOptions,
312322 m68k_interrupt: CommonOptions,
313323
324 /// The standard `microblaze`/`microblazeel` calling convention.
325 microblaze_std: CommonOptions,
326 microblaze_interrupt: MicroblazeInterruptOptions,
327
314328 /// The standard `msp430` calling convention.
315329 msp430_eabi: CommonOptions,
330 msp430_interrupt: CommonOptions,
316331
317332 /// The standard `or1k` calling convention.
318333 or1k_sysv: CommonOptions,
......@@ -324,6 +339,11 @@ pub const CallingConvention = union(enum(u8)) {
324339 s390x_sysv: CommonOptions,
325340 s390x_sysv_vx: CommonOptions,
326341
342 // Calling conventions for the `sh`/`sheb` architecture.
343 sh_gnu: CommonOptions,
344 sh_renesas: CommonOptions,
345 sh_interrupt: ShInterruptOptions,
346
327347 /// The standard `ve` calling convention.
328348 ve_sysv: CommonOptions,
329349
......@@ -331,7 +351,7 @@ pub const CallingConvention = union(enum(u8)) {
331351 xcore_xs1: CommonOptions,
332352 xcore_xs2: CommonOptions,
333353
334 // Calling conventions for the `xtensa` architecture.
354 // Calling conventions for the `xtensa`/`xtensaeb` architecture.
335355 xtensa_call0: CommonOptions,
336356 xtensa_windowed: CommonOptions,
337357
......@@ -403,6 +423,25 @@ pub const CallingConvention = union(enum(u8)) {
403423 };
404424 };
405425
426 /// Options for the `microblaze_interrupt` calling convention.
427 pub const MicroblazeInterruptOptions = struct {
428 /// The boundary the stack is aligned to when the function is called.
429 /// `null` means the default for this calling convention.
430 incoming_stack_alignment: ?u64 = null,
431 type: InterruptType = .regular,
432
433 pub const InterruptType = enum(u2) {
434 /// User exception; return with `rtsd`.
435 user,
436 /// Regular interrupt; return with `rtid`.
437 regular,
438 /// Fast interrupt; return with `rtid`.
439 fast,
440 /// Software breakpoint; return with `rtbd`.
441 breakpoint,
442 };
443 };
444
406445 /// Options for the `mips_interrupt` and `mips64_interrupt` calling conventions.
407446 pub const MipsInterruptOptions = struct {
408447 /// The boundary the stack is aligned to when the function is called.
......@@ -438,6 +477,25 @@ pub const CallingConvention = union(enum(u8)) {
438477 };
439478 };
440479
480 /// Options for the `sh_interrupt` calling convention.
481 pub const ShInterruptOptions = struct {
482 /// The boundary the stack is aligned to when the function is called.
483 /// `null` means the default for this calling convention.
484 incoming_stack_alignment: ?u64 = null,
485 save: SaveBehavior = .full,
486
487 pub const SaveBehavior = enum(u3) {
488 /// Save only fpscr (if applicable).
489 fpscr,
490 /// Save only high-numbered registers, i.e. r0 through r7 are *not* saved.
491 high,
492 /// Save all registers normally.
493 full,
494 /// Save all registers using the CPU's fast register bank.
495 bank,
496 };
497 };
498
441499 /// Returns the array of `std.Target.Cpu.Arch` to which this `CallingConvention` applies.
442500 /// Asserts that `cc` is not `.auto`, `.@"async"`, `.naked`, or `.@"inline"`.
443501 pub fn archs(cc: CallingConvention) []const std.Target.Cpu.Arch {
......@@ -459,21 +517,6 @@ pub const CallingConvention = union(enum(u8)) {
459517/// This data structure is used by the Zig language code generation and
460518/// therefore must be kept in sync with the compiler implementation.
461519pub const AddressSpace = enum(u5) {
462 /// The places where a user can specify an address space attribute
463 pub const Context = enum {
464 /// A function is specified to be placed in a certain address space.
465 function,
466 /// A (global) variable is specified to be placed in a certain address space.
467 /// In contrast to .constant, these values (and thus the address space they will be
468 /// placed in) are required to be mutable.
469 variable,
470 /// A (global) constant value is specified to be placed in a certain address space.
471 /// In contrast to .variable, values placed in this address space are not required to be mutable.
472 constant,
473 /// A pointer is ascripted to point into a certain address space.
474 pointer,
475 };
476
477520 // CPU address spaces.
478521 generic,
479522 gs,
......@@ -858,6 +901,13 @@ pub const VaListAarch64 = extern struct {
858901 __vr_offs: c_int,
859902};
860903
904/// This data structure is used by the Zig language code generation and
905/// therefore must be kept in sync with the compiler implementation.
906pub const VaListAlpha = extern struct {
907 __base: *anyopaque,
908 __offset: c_int,
909};
910
861911/// This data structure is used by the Zig language code generation and
862912/// therefore must be kept in sync with the compiler implementation.
863913pub const VaListArm = extern struct {
......@@ -891,6 +941,16 @@ pub const VaListS390x = extern struct {
891941 __overflow_area_pointer: *anyopaque,
892942};
893943
944/// This data structure is used by the Zig language code generation and
945/// therefore must be kept in sync with the compiler implementation.
946pub const VaListSh = extern struct {
947 __va_next_o: *anyopaque,
948 __va_next_o_limit: *anyopaque,
949 __va_next_fp: *anyopaque,
950 __va_next_fp_limit: *anyopaque,
951 __va_next_stack: *anyopaque,
952};
953
894954/// This data structure is used by the Zig language code generation and
895955/// therefore must be kept in sync with the compiler implementation.
896956pub const VaListX86_64 = extern struct {
......@@ -920,14 +980,19 @@ pub const VaList = switch (builtin.cpu.arch) {
920980 .x86,
921981 => *u8,
922982 .arc,
983 .arceb,
923984 .avr,
924985 .bpfel,
925986 .bpfeb,
926987 .csky,
988 .hppa,
989 .hppa64,
927990 .lanai,
928991 .loongarch32,
929992 .loongarch64,
930993 .m68k,
994 .microblaze,
995 .microblazeel,
931996 .mips,
932997 .mipsel,
933998 .mips64,
......@@ -952,6 +1017,7 @@ pub const VaList = switch (builtin.cpu.arch) {
9521017 .stage2_llvm => @compileError("disabled due to miscompilations"),
9531018 },
9541019 },
1020 .alpha => VaListAlpha,
9551021 .arm, .armeb, .thumb, .thumbeb => VaListArm,
9561022 .hexagon => if (builtin.target.abi.isMusl()) VaListHexagon else *u8,
9571023 .powerpc, .powerpcle => switch (builtin.os.tag) {
......@@ -959,6 +1025,7 @@ pub const VaList = switch (builtin.cpu.arch) {
9591025 else => VaListPowerPc,
9601026 },
9611027 .s390x => VaListS390x,
1028 .sh, .sheb => VaListSh, // This is wrong for `sh_renesas`: https://github.com/ziglang/zig/issues/24692#issuecomment-3150779829
9621029 .x86_64 => switch (builtin.os.tag) {
9631030 .uefi, .windows => switch (builtin.zig_backend) {
9641031 else => *u8,
......@@ -966,7 +1033,7 @@ pub const VaList = switch (builtin.cpu.arch) {
9661033 },
9671034 else => VaListX86_64,
9681035 },
969 .xtensa => VaListXtensa,
1036 .xtensa, .xtensaeb => VaListXtensa,
9701037 else => @compileError("VaList not supported for this target yet"),
9711038};
9721039
lib/std/builtin/assembly.zig+317-2
......@@ -779,7 +779,7 @@ pub const Clobbers = switch (@import("builtin").cpu.arch) {
779779 lr: bool = false,
780780 sr: bool = false,
781781 },
782 .xtensa => packed struct {
782 .xtensa, .xtensaeb => packed struct {
783783 /// Whether the inline assembly code may perform stores to memory
784784 /// addresses other than those derived from input pointer provenance.
785785 memory: bool = false,
......@@ -1591,7 +1591,7 @@ pub const Clobbers = switch (@import("builtin").cpu.arch) {
15911591 vr30: bool = false,
15921592 vr31: bool = false,
15931593 },
1594 .arc => packed struct {
1594 .arc, .arceb => packed struct {
15951595 /// Whether the inline assembly code may perform stores to memory
15961596 /// addresses other than those derived from input pointer provenance.
15971597 memory: bool = false,
......@@ -2197,6 +2197,321 @@ pub const Clobbers = switch (@import("builtin").cpu.arch) {
21972197 msa_map: bool = false,
21982198 msa_unmap: bool = false,
21992199 },
2200 .alpha => packed struct {
2201 /// Whether the inline assembly code may perform stores to memory
2202 /// addresses other than those derived from input pointer provenance.
2203 memory: bool = false,
2204
2205 r0: bool = false,
2206 r1: bool = false,
2207 r2: bool = false,
2208 r3: bool = false,
2209 r4: bool = false,
2210 r5: bool = false,
2211 r6: bool = false,
2212 r7: bool = false,
2213 r8: bool = false,
2214 r9: bool = false,
2215 r10: bool = false,
2216 r11: bool = false,
2217 r12: bool = false,
2218 r13: bool = false,
2219 r14: bool = false,
2220 r15: bool = false,
2221 r16: bool = false,
2222 r17: bool = false,
2223 r18: bool = false,
2224 r19: bool = false,
2225 r20: bool = false,
2226 r21: bool = false,
2227 r22: bool = false,
2228 r23: bool = false,
2229 r24: bool = false,
2230 r25: bool = false,
2231 r26: bool = false,
2232 r27: bool = false,
2233 r28: bool = false,
2234 r29: bool = false,
2235 r30: bool = false,
2236
2237 f0: bool = false,
2238 f1: bool = false,
2239 f2: bool = false,
2240 f3: bool = false,
2241 f4: bool = false,
2242 f5: bool = false,
2243 f6: bool = false,
2244 f7: bool = false,
2245 f8: bool = false,
2246 f9: bool = false,
2247 f10: bool = false,
2248 f11: bool = false,
2249 f12: bool = false,
2250 f13: bool = false,
2251 f14: bool = false,
2252 f15: bool = false,
2253 f16: bool = false,
2254 f17: bool = false,
2255 f18: bool = false,
2256 f19: bool = false,
2257 f20: bool = false,
2258 f21: bool = false,
2259 f22: bool = false,
2260 f23: bool = false,
2261 f24: bool = false,
2262 f25: bool = false,
2263 f26: bool = false,
2264 f27: bool = false,
2265 f28: bool = false,
2266 f29: bool = false,
2267 f30: bool = false,
2268 },
2269 .hppa, .hppa64 => packed struct {
2270 /// Whether the inline assembly code may perform stores to memory
2271 /// addresses other than those derived from input pointer provenance.
2272 memory: bool = false,
2273
2274 sar: bool = false,
2275
2276 r1: bool = false,
2277 r2: bool = false,
2278 r3: bool = false,
2279 r4: bool = false,
2280 r5: bool = false,
2281 r6: bool = false,
2282 r7: bool = false,
2283 r8: bool = false,
2284 r9: bool = false,
2285 r10: bool = false,
2286 r11: bool = false,
2287 r12: bool = false,
2288 r13: bool = false,
2289 r14: bool = false,
2290 r15: bool = false,
2291 r16: bool = false,
2292 r17: bool = false,
2293 r18: bool = false,
2294 r19: bool = false,
2295 r20: bool = false,
2296 r21: bool = false,
2297 r22: bool = false,
2298 r23: bool = false,
2299 r24: bool = false,
2300 r25: bool = false,
2301 r26: bool = false,
2302 r27: bool = false,
2303 r28: bool = false,
2304 r29: bool = false,
2305 r30: bool = false,
2306 r31: bool = false,
2307
2308 fr4: bool = false,
2309 fr5: bool = false,
2310 fr6: bool = false,
2311 fr7: bool = false,
2312 fr8: bool = false,
2313 fr9: bool = false,
2314 fr10: bool = false,
2315 fr11: bool = false,
2316 fr12: bool = false,
2317 fr13: bool = false,
2318 fr14: bool = false,
2319 fr15: bool = false,
2320 fr16: bool = false,
2321 fr17: bool = false,
2322 fr18: bool = false,
2323 fr19: bool = false,
2324 fr20: bool = false,
2325 fr21: bool = false,
2326 fr22: bool = false,
2327 fr23: bool = false,
2328 fr24: bool = false,
2329 fr25: bool = false,
2330 fr26: bool = false,
2331 fr27: bool = false,
2332 fr28: bool = false,
2333 fr29: bool = false,
2334 fr30: bool = false,
2335 fr31: bool = false,
2336
2337 fr4r: bool = false,
2338 fr5r: bool = false,
2339 fr6r: bool = false,
2340 fr7r: bool = false,
2341 fr8r: bool = false,
2342 fr9r: bool = false,
2343 fr10r: bool = false,
2344 fr11r: bool = false,
2345 fr12r: bool = false,
2346 fr13r: bool = false,
2347 fr14r: bool = false,
2348 fr15r: bool = false,
2349 fr16r: bool = false,
2350 fr17r: bool = false,
2351 fr18r: bool = false,
2352 fr19r: bool = false,
2353 fr20r: bool = false,
2354 fr21r: bool = false,
2355 fr22r: bool = false,
2356 fr23r: bool = false,
2357 fr24r: bool = false,
2358 fr25r: bool = false,
2359 fr26r: bool = false,
2360 fr27r: bool = false,
2361 fr28r: bool = false,
2362 fr29r: bool = false,
2363 fr30r: bool = false,
2364 fr31r: bool = false,
2365 },
2366 .microblaze, .microblazeel => packed struct {
2367 /// Whether the inline assembly code may perform stores to memory
2368 /// addresses other than those derived from input pointer provenance.
2369 memory: bool = false,
2370
2371 rmsr: bool = false,
2372
2373 r1: bool = false,
2374 r2: bool = false,
2375 r3: bool = false,
2376 r4: bool = false,
2377 r5: bool = false,
2378 r6: bool = false,
2379 r7: bool = false,
2380 r8: bool = false,
2381 r9: bool = false,
2382 r10: bool = false,
2383 r11: bool = false,
2384 r12: bool = false,
2385 r13: bool = false,
2386 r14: bool = false,
2387 r15: bool = false,
2388 r16: bool = false,
2389 r17: bool = false,
2390 r18: bool = false,
2391 r19: bool = false,
2392 r20: bool = false,
2393 r21: bool = false,
2394 r22: bool = false,
2395 r23: bool = false,
2396 r24: bool = false,
2397 r25: bool = false,
2398 r26: bool = false,
2399 r27: bool = false,
2400 r28: bool = false,
2401 r29: bool = false,
2402 r30: bool = false,
2403 r31: bool = false,
2404 },
2405 .sh, .sheb => packed struct {
2406 /// Whether the inline assembly code may perform stores to memory
2407 /// addresses other than those derived from input pointer provenance.
2408 memory: bool = false,
2409
2410 sr: bool = false,
2411 gbr: bool = false,
2412 pr: bool = false,
2413
2414 r0: bool = false,
2415 r1: bool = false,
2416 r2: bool = false,
2417 r3: bool = false,
2418 r4: bool = false,
2419 r5: bool = false,
2420 r6: bool = false,
2421 r7: bool = false,
2422 r8: bool = false,
2423 r9: bool = false,
2424 r10: bool = false,
2425 r11: bool = false,
2426 r12: bool = false,
2427 r13: bool = false,
2428 r14: bool = false,
2429 r15: bool = false,
2430
2431 mach: bool = false,
2432 macl: bool = false,
2433
2434 fr0: bool = false,
2435 fr1: bool = false,
2436 fr2: bool = false,
2437 fr3: bool = false,
2438 fr4: bool = false,
2439 fr5: bool = false,
2440 fr6: bool = false,
2441 fr7: bool = false,
2442 fr8: bool = false,
2443 fr9: bool = false,
2444 fr10: bool = false,
2445 fr11: bool = false,
2446 fr12: bool = false,
2447 fr13: bool = false,
2448 fr14: bool = false,
2449 fr15: bool = false,
2450
2451 dr0: bool = false,
2452 dr2: bool = false,
2453 dr4: bool = false,
2454 dr6: bool = false,
2455 dr8: bool = false,
2456 dr10: bool = false,
2457 dr12: bool = false,
2458 dr14: bool = false,
2459
2460 fv0: bool = false,
2461 fv4: bool = false,
2462 fv8: bool = false,
2463 fv12: bool = false,
2464
2465 xf0: bool = false,
2466 xf1: bool = false,
2467 xf2: bool = false,
2468 xf3: bool = false,
2469 xf4: bool = false,
2470 xf5: bool = false,
2471 xf6: bool = false,
2472 xf7: bool = false,
2473 xf8: bool = false,
2474 xf9: bool = false,
2475 xf10: bool = false,
2476 xf11: bool = false,
2477 xf12: bool = false,
2478 xf13: bool = false,
2479 xf14: bool = false,
2480 xf15: bool = false,
2481
2482 xd0: bool = false,
2483 xd2: bool = false,
2484 xd4: bool = false,
2485 xd6: bool = false,
2486 xd8: bool = false,
2487 xd10: bool = false,
2488 xd12: bool = false,
2489 xd14: bool = false,
2490
2491 xmtrx: bool = false,
2492
2493 fpul: bool = false,
2494 fpscr: bool = false,
2495
2496 ms: bool = false,
2497 me: bool = false,
2498
2499 rs: bool = false,
2500 re: bool = false,
2501
2502 a0: bool = false,
2503 a0g: bool = false,
2504 a1: bool = false,
2505 a1g: bool = false,
2506 m0: bool = false,
2507 m1: bool = false,
2508 x0: bool = false,
2509 x1: bool = false,
2510 y0: bool = false,
2511 y1: bool = false,
2512
2513 dsr: bool = false,
2514 },
22002515 else => packed struct {
22012516 /// Whether the inline assembly code may perform stores to memory
22022517 /// addresses other than those derived from input pointer provenance.
lib/std/debug.zig+22-3
......@@ -872,13 +872,18 @@ const StackIterator = union(enum) {
872872 };
873873
874874 const fp_usability: FpUsability = switch (builtin.target.cpu.arch) {
875 .alpha,
875876 .avr,
876877 .csky,
878 .microblaze,
879 .microblazeel,
877880 .mips,
878881 .mipsel,
879882 .mips64,
880883 .mips64el,
881884 .msp430,
885 .sh,
886 .sheb,
882887 .xcore,
883888 => .useless,
884889 .hexagon,
......@@ -969,11 +974,15 @@ const StackIterator = union(enum) {
969974 const ra_ptr: *const usize = @ptrFromInt(ra_addr);
970975 const bp = applyOffset(bp_ptr.*, stack_bias) orelse return .end;
971976
972 // The stack grows downards, so `bp > fp` should always hold. If it doesn't, this
973 // frame is invalid, so we'll treat it as though it we reached end of stack. The
977 // If the stack grows downwards, `bp > fp` should always hold; conversely, if it
978 // grows upwards, `bp < fp` should always hold. If that is not the case, this
979 // frame is invalid, so we'll treat it as though we reached end of stack. The
974980 // exception is address 0, which is a graceful end-of-stack signal, in which case
975981 // *this* return address is valid and the *next* iteration will be the last.
976 if (bp != 0 and bp <= fp) return .end;
982 if (bp != 0 and switch (comptime builtin.target.stackGrowth()) {
983 .down => bp <= fp,
984 .up => bp >= fp,
985 }) return .end;
977986
978987 it.fp = bp;
979988 const ra = stripInstructionPtrAuthCode(ra_ptr.*);
......@@ -985,6 +994,11 @@ const StackIterator = union(enum) {
985994
986995 /// Offset of the saved base pointer (previous frame pointer) wrt the frame pointer.
987996 const fp_to_bp_offset = off: {
997 // On 32-bit PA-RISC, the base pointer is the final word of the frame marker.
998 if (native_arch == .hppa) break :off -1 * @sizeOf(usize);
999 // On 64-bit PA-RISC, the frame marker was shrunk significantly; now there's just the return
1000 // address followed by the base pointer.
1001 if (native_arch == .hppa64) break :off -1 * @sizeOf(usize);
9881002 // On LoongArch and RISC-V, the frame pointer points to the top of the saved register area,
9891003 // in which the base pointer is the first word.
9901004 if (native_arch.isLoongArch() or native_arch.isRISCV()) break :off -2 * @sizeOf(usize);
......@@ -999,6 +1013,11 @@ const StackIterator = union(enum) {
9991013
10001014 /// Offset of the saved return address wrt the frame pointer.
10011015 const fp_to_ra_offset = off: {
1016 // On 32-bit PA-RISC, the return address sits in the middle-ish of the frame marker.
1017 if (native_arch == .hppa) break :off -5 * @sizeOf(usize);
1018 // On 64-bit PA-RISC, the frame marker was shrunk significantly; now there's just the return
1019 // address followed by the base pointer.
1020 if (native_arch == .hppa64) break :off -2 * @sizeOf(usize);
10021021 // On LoongArch and RISC-V, the frame pointer points to the top of the saved register area,
10031022 // in which the return address is the second word.
10041023 if (native_arch.isLoongArch() or native_arch.isRISCV()) break :off -1 * @sizeOf(usize);
lib/std/debug/Dwarf.zig+3-3
......@@ -1430,7 +1430,7 @@ pub fn compactUnwindToDwarfRegNumber(unwind_reg_number: u3) !u16 {
14301430pub fn ipRegNum(arch: std.Target.Cpu.Arch) ?u16 {
14311431 return switch (arch) {
14321432 .aarch64, .aarch64_be => 32,
1433 .arc => 160,
1433 .arc, .arceb => 160,
14341434 .arm, .armeb, .thumb, .thumbeb => 15,
14351435 .csky => 64,
14361436 .hexagon => 76,
......@@ -1453,7 +1453,7 @@ pub fn ipRegNum(arch: std.Target.Cpu.Arch) ?u16 {
14531453pub fn fpRegNum(arch: std.Target.Cpu.Arch) u16 {
14541454 return switch (arch) {
14551455 .aarch64, .aarch64_be => 29,
1456 .arc => 27,
1456 .arc, .arceb => 27,
14571457 .arm, .armeb, .thumb, .thumbeb => 11,
14581458 .csky => 14,
14591459 .hexagon => 30,
......@@ -1476,7 +1476,7 @@ pub fn fpRegNum(arch: std.Target.Cpu.Arch) u16 {
14761476pub fn spRegNum(arch: std.Target.Cpu.Arch) u16 {
14771477 return switch (arch) {
14781478 .aarch64, .aarch64_be => 31,
1479 .arc => 28,
1479 .arc, .arceb => 28,
14801480 .arm, .armeb, .thumb, .thumbeb => 13,
14811481 .csky => 14,
14821482 .hexagon => 29,
lib/std/debug/SelfInfo/Elf.zig+1-1
......@@ -102,7 +102,7 @@ pub const can_unwind: bool = s: {
102102 .x86,
103103 .x86_64,
104104 },
105 // Not supported yet: arm/armeb/thumb/thumbeb, xtensa
105 // Not supported yet: arm/armeb/thumb/thumbeb, xtensa/xtensaeb
106106 .linux => &.{
107107 .aarch64,
108108 .aarch64_be,
lib/std/debug/cpu_context.zig+104-4
......@@ -5,7 +5,7 @@ pub const Native = if (@hasDecl(root, "debug") and @hasDecl(root.debug, "CpuCont
55 root.debug.CpuContext
66else switch (native_arch) {
77 .aarch64, .aarch64_be => Aarch64,
8 .arc => Arc,
8 .arc, .arceb => Arc,
99 .arm, .armeb, .thumb, .thumbeb => Arm,
1010 .csky => Csky,
1111 .hexagon => Hexagon,
......@@ -36,7 +36,7 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native {
3636 const uc: *const signal_ucontext_t = @ptrCast(@alignCast(ctx_ptr));
3737
3838 // Deal with some special cases first.
39 if (native_arch == .arc and native_os == .linux) {
39 if (native_arch.isArc() and native_os == .linux) {
4040 var native: Native = .{
4141 .r = [_]u32{ uc.mcontext.r31, uc.mcontext.r30, 0, uc.mcontext.r28 } ++
4242 uc.mcontext.r27_26 ++
......@@ -1492,6 +1492,21 @@ const X86_64 = struct {
14921492/// as unsigned everywhere even if that's not how they're declared in the C headers.
14931493const signal_ucontext_t = switch (native_os) {
14941494 .linux => switch (native_arch) {
1495 // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/alpha/include/asm/ucontext.h
1496 .alpha => extern struct {
1497 _flags: u64,
1498 _link: ?*signal_ucontext_t,
1499 _osf_sigmask: u64,
1500 _stack: std.os.linux.stack_t,
1501 // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/alpha/include/uapi/asm/sigcontext.h
1502 mcontext: extern struct {
1503 _onstack: i64,
1504 _mask: i64,
1505 pc: u64,
1506 _ps: i64,
1507 r: [32]u64,
1508 },
1509 },
14951510 // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/arm64/include/uapi/asm/ucontext.h
14961511 .aarch64,
14971512 .aarch64_be,
......@@ -1553,6 +1568,7 @@ const signal_ucontext_t = switch (native_os) {
15531568 },
15541569 // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/include/uapi/asm-generic/ucontext.h
15551570 .arc,
1571 .arceb,
15561572 .csky,
15571573 .hexagon,
15581574 .m68k,
......@@ -1565,13 +1581,14 @@ const signal_ucontext_t = switch (native_os) {
15651581 .x86,
15661582 .x86_64,
15671583 .xtensa,
1584 .xtensaeb,
15681585 => extern struct {
15691586 _flags: usize,
15701587 _link: ?*signal_ucontext_t,
15711588 _stack: std.os.linux.stack_t,
15721589 mcontext: switch (native_arch) {
15731590 // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/arc/include/uapi/asm/sigcontext.h
1574 .arc => extern struct {
1591 .arc, .arceb => extern struct {
15751592 _pad1: u32,
15761593 _bta: u32,
15771594 _lp: extern struct {
......@@ -1616,6 +1633,21 @@ const signal_ucontext_t = switch (native_os) {
16161633 _ugp: u32,
16171634 pc: u32,
16181635 },
1636 // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/parisc/include/uapi/asm/sigcontext.h
1637 .hppa => extern struct {
1638 _flags: u32,
1639 _psw: u32,
1640 r1_19: [19]u32,
1641 r20: u32,
1642 r21: u32,
1643 r22: u32,
1644 r23_29: [7]u32,
1645 r30: u32,
1646 r31: u32,
1647 _fr: [32]f64,
1648 _iasq: [2]u32,
1649 iaoq: [2]u32,
1650 },
16191651 // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/m68k/include/asm/ucontext.h
16201652 .m68k => extern struct {
16211653 _version: i32,
......@@ -1623,6 +1655,11 @@ const signal_ucontext_t = switch (native_os) {
16231655 a: [8]u32,
16241656 pc: u32,
16251657 },
1658 // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/microblaze/include/uapi/asm/sigcontext.h
1659 .microblaze, .microblazeel => extern struct {
1660 r: [32]u32,
1661 pc: u32,
1662 },
16261663 // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/mips/include/uapi/asm/sigcontext.h
16271664 .mips, .mipsel => extern struct {
16281665 _regmask: u32,
......@@ -1652,6 +1689,13 @@ const signal_ucontext_t = switch (native_os) {
16521689 },
16531690 r: [16]u64,
16541691 },
1692 // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/sh/include/uapi/asm/sigcontext.h
1693 .sh, .sheb => extern struct {
1694 _oldmask: u32,
1695 r: [16]u32,
1696 pc: u32,
1697 pr: u32,
1698 },
16551699 // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/x86/include/uapi/asm/sigcontext.h
16561700 .x86 => extern struct {
16571701 _gs: u32,
......@@ -1691,7 +1735,7 @@ const signal_ucontext_t = switch (native_os) {
16911735 rip: u64,
16921736 },
16931737 // https://github.com/torvalds/linux/blob/cd5a0afbdf8033dc83786315d63f8b325bdba2fd/arch/xtensa/include/uapi/asm/sigcontext.h
1694 .xtensa => extern struct {
1738 .xtensa, .xtensaeb => extern struct {
16951739 pc: u32,
16961740 _ps: u32,
16971741 _l: extern struct {
......@@ -1948,6 +1992,7 @@ const signal_ucontext_t = switch (native_os) {
19481992 _err: i32,
19491993 eip: u32,
19501994 },
1995 // https://github.com/illumos/illumos-gate/blob/d4ce137bba3bd16823db6374d9e9a643264ce245/usr/src/uts/intel/sys/mcontext.h
19511996 .x86_64 => extern struct {
19521997 r15: u64,
19531998 r14: u64,
......@@ -1984,6 +2029,14 @@ const signal_ucontext_t = switch (native_os) {
19842029 x: [30]u64,
19852030 },
19862031 },
2032 // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/alpha/include/signal.h
2033 .alpha => extern struct {
2034 _cookie: i64,
2035 _mask: i64,
2036 pc: u64,
2037 _ps: i64,
2038 r: [32]u64,
2039 },
19872040 // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/arm/include/signal.h
19882041 .arm => extern struct {
19892042 _cookie: i32,
......@@ -1995,6 +2048,22 @@ const signal_ucontext_t = switch (native_os) {
19952048 pc: u32,
19962049 },
19972050 },
2051 // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/hppa/include/signal.h
2052 .hppa => extern struct {
2053 _unused: u32,
2054 _mask: i32,
2055 _fp: u32,
2056 iaoq: [2]u32,
2057 _resv: [2]u32,
2058 r22: u32,
2059 r21: u32,
2060 r30: u32,
2061 r20: u32,
2062 _sar: u32,
2063 r1_19: [19]u32,
2064 r23_29: [7]u32,
2065 r31: u32,
2066 },
19982067 // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/mips64/include/signal.h
19992068 .mips64, .mips64el => extern struct {
20002069 _cookie: i64,
......@@ -2034,6 +2103,18 @@ const signal_ucontext_t = switch (native_os) {
20342103 },
20352104 // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/sparc64/include/signal.h
20362105 .sparc64 => @compileError("sparc64-openbsd ucontext_t missing"),
2106 // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/sh/include/signal.h
2107 .sh, .sheb => extern struct {
2108 pc: u32,
2109 _sr: i32,
2110 _gbr: i32,
2111 _macl: i32,
2112 _mach: i32,
2113 pr: u32,
2114 r13_0: [14]u32,
2115 r15: u32,
2116 r14: u32,
2117 },
20372118 // https://github.com/openbsd/src/blob/42468faed8369d07ae49ae02dd71ec34f59b66cd/sys/arch/i386/include/signal.h
20382119 .x86 => extern struct {
20392120 mcontext: extern struct {
......@@ -2100,6 +2181,12 @@ const signal_ucontext_t = switch (native_os) {
21002181 sp: u64,
21012182 pc: u64,
21022183 },
2184 // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/arch/alpha/include/mcontext.h
2185 .alpha => extern struct {
2186 r: [32]u64,
2187 pc: u64,
2188 },
2189 // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/arch/arm/include/mcontext.h
21032190 .arm, .armeb => extern struct {
21042191 r: [15]u32 align(8),
21052192 pc: u32,
......@@ -2118,6 +2205,7 @@ const signal_ucontext_t = switch (native_os) {
21182205 _cause: i32,
21192206 pc: u32,
21202207 },
2208 // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/arch/mips/include/mcontext.h
21212209 .mips64, .mips64el => @compileError("https://github.com/ziglang/zig/issues/23765#issuecomment-2880386178"),
21222210 // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/arch/powerpc/include/mcontext.h
21232211 .powerpc => extern struct {
......@@ -2129,6 +2217,18 @@ const signal_ucontext_t = switch (native_os) {
21292217 // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/arch/sparc/include/mcontext.h
21302218 .sparc => @compileError("sparc-netbsd mcontext_t missing"),
21312219 .sparc64 => @compileError("sparc64-netbsd mcontext_t missing"),
2220 // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/arch/sh3/include/mcontext.h
2221 .sh, .sheb => extern struct {
2222 _gbr: i32,
2223 pc: u32,
2224 _sr: i32,
2225 _macl: i32,
2226 _mach: i32,
2227 pr: u32,
2228 r14: u32,
2229 r13_0: [14]u32,
2230 r15: u32,
2231 },
21322232 // https://github.com/NetBSD/src/blob/861008c62187bf7bc0aac4d81e52ed6eee4d0c74/sys/arch/i386/include/mcontext.h
21332233 .x86 => extern struct {
21342234 _gs: i32,
lib/std/heap.zig+22-4
......@@ -739,8 +739,10 @@ const page_size_min_default: ?usize = switch (builtin.os.tag) {
739739 .x86, .x86_64 => 4 << 10,
740740 .thumb, .thumbeb, .arm, .armeb => 4 << 10,
741741 .aarch64, .aarch64_be => 4 << 10,
742 .hppa => 4 << 10,
742743 .mips, .mipsel, .mips64, .mips64el => 4 << 10,
743744 .powerpc, .powerpc64, .powerpc64le, .powerpcle => 4 << 10,
745 .sh, .sheb => 4 << 10,
744746 .sparc => 4 << 10,
745747 .sparc64 => 8 << 10,
746748 .riscv32, .riscv64 => 4 << 10,
......@@ -754,11 +756,14 @@ const page_size_min_default: ?usize = switch (builtin.os.tag) {
754756 },
755757 .openbsd => switch (builtin.cpu.arch) {
756758 // OpenBSD/sys/arch/*
759 .alpha => 8 << 10,
760 .hppa => 4 << 10,
757761 .x86, .x86_64 => 4 << 10,
758762 .thumb, .thumbeb, .arm, .armeb, .aarch64, .aarch64_be => 4 << 10,
759763 .mips64, .mips64el => 4 << 10,
760764 .powerpc, .powerpc64, .powerpc64le, .powerpcle => 4 << 10,
761765 .riscv64 => 4 << 10,
766 .sh, .sheb => 4 << 10,
762767 .sparc64 => 8 << 10,
763768 else => null,
764769 },
......@@ -824,22 +829,26 @@ const page_size_min_default: ?usize = switch (builtin.os.tag) {
824829 .emscripten => 64 << 10,
825830 .linux => switch (builtin.cpu.arch) {
826831 // Linux/arch/*/Kconfig
827 .arc => 4 << 10,
832 .alpha => 8 << 10,
833 .arc, .arceb => 4 << 10,
828834 .thumb, .thumbeb, .arm, .armeb => 4 << 10,
829835 .aarch64, .aarch64_be => 4 << 10,
830836 .csky => 4 << 10,
831837 .hexagon => 4 << 10,
838 .hppa => 4 << 10,
832839 .loongarch32, .loongarch64 => 4 << 10,
833840 .m68k => 4 << 10,
841 .microblaze, .microblazeel => 4 << 10,
834842 .mips, .mipsel, .mips64, .mips64el => 4 << 10,
835843 .or1k => 8 << 10,
836844 .powerpc, .powerpc64, .powerpc64le, .powerpcle => 4 << 10,
837845 .riscv32, .riscv64 => 4 << 10,
838846 .s390x => 4 << 10,
847 .sh, .sheb => 4 << 10,
839848 .sparc => 4 << 10,
840849 .sparc64 => 8 << 10,
841850 .x86, .x86_64 => 4 << 10,
842 .xtensa => 4 << 10,
851 .xtensa, .xtensaeb => 4 << 10,
843852 else => null,
844853 },
845854 .freestanding, .other => switch (builtin.cpu.arch) {
......@@ -888,8 +897,10 @@ const page_size_max_default: ?usize = switch (builtin.os.tag) {
888897 .x86, .x86_64 => 4 << 10,
889898 .thumb, .thumbeb, .arm, .armeb => 4 << 10,
890899 .aarch64, .aarch64_be => 64 << 10,
900 .hppa => 4 << 10,
891901 .mips, .mipsel, .mips64, .mips64el => 16 << 10,
892902 .powerpc, .powerpc64, .powerpc64le, .powerpcle => 16 << 10,
903 .sh, .sheb => 4 << 10,
893904 .sparc => 8 << 10,
894905 .sparc64 => 8 << 10,
895906 .riscv32, .riscv64 => 4 << 10,
......@@ -902,11 +913,14 @@ const page_size_max_default: ?usize = switch (builtin.os.tag) {
902913 },
903914 .openbsd => switch (builtin.cpu.arch) {
904915 // OpenBSD/sys/arch/*
916 .alpha => 8 << 10,
917 .hppa => 4 << 10,
905918 .x86, .x86_64 => 4 << 10,
906919 .thumb, .thumbeb, .arm, .armeb, .aarch64, .aarch64_be => 4 << 10,
907920 .mips64, .mips64el => 16 << 10,
908921 .powerpc, .powerpc64, .powerpc64le, .powerpcle => 4 << 10,
909922 .riscv64 => 4 << 10,
923 .sh, .sheb => 4 << 10,
910924 .sparc64 => 8 << 10,
911925 else => null,
912926 },
......@@ -972,22 +986,26 @@ const page_size_max_default: ?usize = switch (builtin.os.tag) {
972986 .emscripten => 64 << 10,
973987 .linux => switch (builtin.cpu.arch) {
974988 // Linux/arch/*/Kconfig
975 .arc => 16 << 10,
989 .alpha => 8 << 10,
990 .arc, .arceb => 16 << 10,
976991 .thumb, .thumbeb, .arm, .armeb => 4 << 10,
977992 .aarch64, .aarch64_be => 64 << 10,
978993 .csky => 4 << 10,
979994 .hexagon => 256 << 10,
995 .hppa => 64 << 10,
980996 .loongarch32, .loongarch64 => 64 << 10,
981997 .m68k => 8 << 10,
998 .microblaze, .microblazeel => 4 << 10,
982999 .mips, .mipsel, .mips64, .mips64el => 64 << 10,
9831000 .or1k => 8 << 10,
9841001 .powerpc, .powerpc64, .powerpc64le, .powerpcle => 256 << 10,
9851002 .riscv32, .riscv64 => 4 << 10,
9861003 .s390x => 4 << 10,
1004 .sh, .sheb => 64 << 10,
9871005 .sparc => 4 << 10,
9881006 .sparc64 => 8 << 10,
9891007 .x86, .x86_64 => 4 << 10,
990 .xtensa => 4 << 10,
1008 .xtensa, .xtensaeb => 4 << 10,
9911009 else => null,
9921010 },
9931011 .freestanding => switch (builtin.cpu.arch) {
lib/std/os/linux.zig+8-3
......@@ -116,7 +116,7 @@ pub const SECCOMP = @import("linux/seccomp.zig");
116116
117117pub const syscalls = @import("linux/syscalls.zig");
118118pub const SYS = switch (native_arch) {
119 .arc => syscalls.Arc,
119 .arc, .arceb => syscalls.Arc,
120120 .aarch64, .aarch64_be => syscalls.Arm64,
121121 .arm, .armeb, .thumb, .thumbeb => syscalls.Arm,
122122 .csky => syscalls.CSky,
......@@ -141,7 +141,7 @@ pub const SYS = switch (native_arch) {
141141 .gnux32, .muslx32 => syscalls.X32,
142142 else => syscalls.X64,
143143 },
144 .xtensa => syscalls.Xtensa,
144 .xtensa, .xtensaeb => syscalls.Xtensa,
145145 else => @compileError("The Zig Standard Library is missing syscall definitions for the target CPU architecture"),
146146};
147147
......@@ -3686,7 +3686,7 @@ pub const PROT = struct {
36863686 pub const EXEC = 0x4;
36873687 /// page may be used for atomic ops
36883688 pub const SEM = switch (native_arch) {
3689 .mips, .mipsel, .mips64, .mips64el, .xtensa => 0x10,
3689 .mips, .mipsel, .mips64, .mips64el, .xtensa, .xtensaeb => 0x10,
36903690 else => 0x8,
36913691 };
36923692 /// mprotect flag: extend change to start of growsdown vma
......@@ -6161,6 +6161,7 @@ pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t {
61616161
61626162pub const MINSIGSTKSZ = switch (native_arch) {
61636163 .arc,
6164 .arceb,
61646165 .arm,
61656166 .armeb,
61666167 .csky,
......@@ -6181,6 +6182,7 @@ pub const MINSIGSTKSZ = switch (native_arch) {
61816182 .x86,
61826183 .x86_64,
61836184 .xtensa,
6185 .xtensaeb,
61846186 => 2048,
61856187 .loongarch64,
61866188 .sparc,
......@@ -6196,6 +6198,7 @@ pub const MINSIGSTKSZ = switch (native_arch) {
61966198};
61976199pub const SIGSTKSZ = switch (native_arch) {
61986200 .arc,
6201 .arceb,
61996202 .arm,
62006203 .armeb,
62016204 .csky,
......@@ -6216,6 +6219,7 @@ pub const SIGSTKSZ = switch (native_arch) {
62166219 .x86,
62176220 .x86_64,
62186221 .xtensa,
6222 .xtensaeb,
62196223 => 8192,
62206224 .aarch64,
62216225 .aarch64_be,
......@@ -9740,6 +9744,7 @@ pub const AUDIT = struct {
97409744 .armeb, .thumbeb => .ARMEB,
97419745 .aarch64 => .AARCH64,
97429746 .arc => .ARCV2,
9747 .arceb => .ARCV2BE,
97439748 .csky => .CSKY,
97449749 .hexagon => .HEXAGON,
97459750 .loongarch32 => .LOONGARCH32,
lib/std/os/linux/tls.zig+47-7
......@@ -46,7 +46,7 @@ const Variant = enum {
4646 /// -------------------------------------^-------------
4747 /// `-- The TP register points here.
4848 ///
49 /// The offset (which can be zero) is applied to the TP only; there is never physical gap
49 /// The offset (which can be zero) is applied to the TP only; there is never a physical gap
5050 /// between the ABI TCB and the TLS blocks. This implies that we only need to align the TP.
5151 ///
5252 /// The first (and only) word in the ABI TCB points to the DTV.
......@@ -63,12 +63,19 @@ const Variant = enum {
6363};
6464
6565const current_variant: Variant = switch (native_arch) {
66 .aarch64,
67 .aarch64_be,
68 .alpha,
6669 .arc,
70 .arceb,
6771 .arm,
6872 .armeb,
69 .aarch64,
70 .aarch64_be,
7173 .csky,
74 .hppa,
75 .microblaze,
76 .microblazeel,
77 .sh,
78 .sheb,
7279 .thumb,
7380 .thumbeb,
7481 => .I_original,
......@@ -133,18 +140,22 @@ const current_dtv_offset = switch (native_arch) {
133140/// Per-thread storage for the ELF TLS ABI.
134141const AbiTcb = switch (current_variant) {
135142 .I_original, .I_modified => switch (native_arch) {
136 // ARM EABI mandates enough space for two pointers: the first one points to the DTV as
137 // usual, while the second one is unspecified.
138143 .aarch64,
139144 .aarch64_be,
145 .alpha,
140146 .arm,
141147 .armeb,
148 .hppa,
149 .microblaze,
150 .microblazeel,
151 .sh,
152 .sheb,
142153 .thumb,
143154 .thumbeb,
144155 => extern struct {
145156 /// This is offset by `current_dtv_offset`.
146157 dtv: usize,
147 reserved: ?*anyopaque,
158 _reserved: ?*anyopaque,
148159 },
149160 else => extern struct {
150161 /// This is offset by `current_dtv_offset`.
......@@ -243,7 +254,15 @@ pub fn setThreadPointer(addr: usize) void {
243254 : [addr] "r" (addr),
244255 );
245256 },
246 .arc => {
257 .alpha => {
258 asm volatile (
259 \\ lda a0, %[addr]
260 \\ wruniq
261 :
262 : [addr] "r" (addr),
263 );
264 },
265 .arc, .arceb => {
247266 // We apparently need to both set r25 (TP) *and* inform the kernel...
248267 asm volatile (
249268 \\ mov r25, %[addr]
......@@ -268,6 +287,13 @@ pub fn setThreadPointer(addr: usize) void {
268287 : [addr] "r" (addr),
269288 );
270289 },
290 .hppa => {
291 asm volatile (
292 \\ ble 0xe0(%%sr2, %%r0)
293 :
294 : [addr] "={r26}" (addr),
295 : .{ .r29 = true });
296 },
271297 .loongarch32, .loongarch64 => {
272298 asm volatile (
273299 \\ move $tp, %[addr]
......@@ -286,6 +312,13 @@ pub fn setThreadPointer(addr: usize) void {
286312 const rc = @call(.always_inline, linux.syscall1, .{ .set_thread_area, addr });
287313 assert(rc == 0);
288314 },
315 .microblaze, .microblazeel => {
316 asm volatile (
317 \\ ori r21, %[addr], 0
318 :
319 : [addr] "r" (addr),
320 );
321 },
289322 .or1k => {
290323 asm volatile (
291324 \\ l.ori r10, %[addr], 0
......@@ -317,6 +350,13 @@ pub fn setThreadPointer(addr: usize) void {
317350 : [addr] "r" (addr),
318351 : .{ .r0 = true });
319352 },
353 .sh, .sheb => {
354 asm volatile (
355 \\ ldc gbr, %[addr]
356 :
357 : [addr] "r" (addr),
358 );
359 },
320360 .sparc, .sparc64 => {
321361 asm volatile (
322362 \\ mov %[addr], %%g7
lib/std/pie.zig+35-2
......@@ -3,6 +3,7 @@ const builtin = @import("builtin");
33const elf = std.elf;
44const assert = std.debug.assert;
55
6const R_ALPHA_RELATIVE = 27;
67const R_AMD64_RELATIVE = 8;
78const R_386_RELATIVE = 8;
89const R_ARC_RELATIVE = 56;
......@@ -12,28 +13,33 @@ const R_CSKY_RELATIVE = 9;
1213const R_HEXAGON_RELATIVE = 35;
1314const R_LARCH_RELATIVE = 3;
1415const R_68K_RELATIVE = 22;
16const R_MICROBLAZE_REL = 16;
1517const R_MIPS_RELATIVE = 128;
1618const R_OR1K_RELATIVE = 21;
1719const R_PPC_RELATIVE = 22;
1820const R_RISCV_RELATIVE = 3;
1921const R_390_RELATIVE = 12;
22const R_SH_RELATIVE = 165;
2023const R_SPARC_RELATIVE = 22;
2124
2225const R_RELATIVE = switch (builtin.cpu.arch) {
2326 .x86 => R_386_RELATIVE,
2427 .x86_64 => R_AMD64_RELATIVE,
25 .arc => R_ARC_RELATIVE,
28 .arc, .arceb => R_ARC_RELATIVE,
2629 .arm, .armeb, .thumb, .thumbeb => R_ARM_RELATIVE,
2730 .aarch64, .aarch64_be => R_AARCH64_RELATIVE,
31 .alpha => R_ALPHA_RELATIVE,
2832 .csky => R_CSKY_RELATIVE,
2933 .hexagon => R_HEXAGON_RELATIVE,
3034 .loongarch32, .loongarch64 => R_LARCH_RELATIVE,
3135 .m68k => R_68K_RELATIVE,
36 .microblaze, .microblazeel => R_MICROBLAZE_REL,
3237 .mips, .mipsel, .mips64, .mips64el => R_MIPS_RELATIVE,
3338 .or1k => R_OR1K_RELATIVE,
3439 .powerpc, .powerpcle, .powerpc64, .powerpc64le => R_PPC_RELATIVE,
3540 .riscv32, .riscv32be, .riscv64, .riscv64be => R_RISCV_RELATIVE,
3641 .s390x => R_390_RELATIVE,
42 .sh, .sheb => R_SH_RELATIVE,
3743 .sparc, .sparc64 => R_SPARC_RELATIVE,
3844 else => @compileError("Missing R_RELATIVE definition for this target"),
3945};
......@@ -58,7 +64,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
5864 \\ lea _DYNAMIC(%%rip), %[ret]
5965 : [ret] "=r" (-> [*]const elf.Dyn),
6066 ),
61 .arc => asm volatile (
67 .arc, .arceb => asm volatile (
6268 \\ .weak _DYNAMIC
6369 \\ .hidden _DYNAMIC
6470 \\ add %[ret], pcl, _DYNAMIC@pcl
......@@ -83,6 +89,15 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
8389 \\ add %[ret], %[ret], #:lo12:_DYNAMIC
8490 : [ret] "=r" (-> [*]const elf.Dyn),
8591 ),
92 // The compiler is not required to load the GP register, so do it ourselves.
93 .alpha => asm volatile (
94 \\ br $29, 1f
95 \\1:
96 \\ ldgp $29, 0($29)
97 \\ ldq %[ret], -0x8000($29)
98 : [ret] "=r" (-> [*]const elf.Dyn),
99 :
100 : .{ .r26 = true }),
86101 // The CSKY ABI requires the gb register to point to the GOT. Additionally, the first
87102 // entry in the GOT is defined to hold the address of _DYNAMIC.
88103 .csky => asm volatile (
......@@ -118,6 +133,10 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
118133 \\ lea (%[ret], %%pc), %[ret]
119134 : [ret] "=r" (-> [*]const elf.Dyn),
120135 ),
136 .microblaze, .microblazeel => asm volatile (
137 \\ lwi %[ret], r20, 0
138 : [ret] "=r" (-> [*]const elf.Dyn),
139 ),
121140 .mips, .mipsel => asm volatile (
122141 \\ .weak _DYNAMIC
123142 \\ .hidden _DYNAMIC
......@@ -206,6 +225,20 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
206225 \\ 2:
207226 : [ret] "=a" (-> [*]const elf.Dyn),
208227 ),
228 .sh, .sheb => asm volatile (
229 \\ .weak _DYNAMIC
230 \\ .hidden _DYNAMIC
231 \\ mova 1f, r0
232 \\ mov.l 1f, %[ret]
233 \\ add r0, %[ret]
234 \\ bra 2f
235 \\1:
236 \\ .balign 4
237 \\ .long DYNAMIC - .
238 \\2:
239 : [ret] "=r" (-> [*]const elf.Dyn),
240 :
241 : .{ .r0 = true }),
209242 // The compiler does not necessarily have any obligation to load the `l7` register (pointing
210243 // to the GOT), so do it ourselves just in case.
211244 .sparc, .sparc64 => asm volatile (
lib/std/start.zig+43-3
......@@ -195,13 +195,15 @@ fn _start() callconv(.naked) noreturn {
195195 // This is the first userspace frame. Prevent DWARF-based unwinders from unwinding further. We
196196 // prevent FP-based unwinders from unwinding further by zeroing the register below.
197197 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (switch (native_arch) {
198 .arc => ".cfi_undefined blink",
199 .arm, .armeb, .thumb, .thumbeb => "", // https://github.com/llvm/llvm-project/issues/115891
200198 .aarch64, .aarch64_be => ".cfi_undefined lr",
199 .alpha => ".cfi_undefined $26",
200 .arc, .arceb => ".cfi_undefined blink",
201 .arm, .armeb, .thumb, .thumbeb => "", // https://github.com/llvm/llvm-project/issues/115891
201202 .csky => ".cfi_undefined lr",
202203 .hexagon => ".cfi_undefined r31",
203204 .loongarch32, .loongarch64 => ".cfi_undefined 1",
204205 .m68k => ".cfi_undefined %%pc",
206 .microblaze, .microblazeel => ".cfi_undefined r15",
205207 .mips, .mipsel, .mips64, .mips64el => ".cfi_undefined $ra",
206208 .or1k => ".cfi_undefined r9",
207209 .powerpc, .powerpcle, .powerpc64, .powerpc64le => ".cfi_undefined lr",
......@@ -210,6 +212,7 @@ fn _start() callconv(.naked) noreturn {
210212 else
211213 ".cfi_undefined ra",
212214 .s390x => ".cfi_undefined %%r14",
215 .sh, .sheb => ".cfi_undefined pr",
213216 .sparc, .sparc64 => ".cfi_undefined %%i7",
214217 .x86 => ".cfi_undefined %%eip",
215218 .x86_64 => ".cfi_undefined %%rip",
......@@ -253,7 +256,19 @@ fn _start() callconv(.naked) noreturn {
253256 \\ and sp, x0, #-16
254257 \\ b %[posixCallMainAndExit]
255258 ,
256 .arc =>
259 .alpha =>
260 // $15 = FP, $26 = LR, $29 = GP, $30 = SP
261 \\ br $29, 1f
262 \\1:
263 \\ ldgp $29, 0($29)
264 \\ mov 0, $15
265 \\ mov 0, $26
266 \\ mov $30, $16
267 \\ ldi $1, -16
268 \\ and $30, $30, $1
269 \\ jsr $26, %[posixCallMainAndExit]
270 ,
271 .arc, .arceb =>
257272 // ARC v1 and v2 had a very low stack alignment requirement of 4; v3 increased it to 16.
258273 \\ mov fp, 0
259274 \\ mov blink, 0
......@@ -333,6 +348,16 @@ fn _start() callconv(.naked) noreturn {
333348 \\ lea %[posixCallMainAndExit] - . - 8, %%a0
334349 \\ jsr (%%pc, %%a0)
335350 ,
351 .microblaze, .microblazeel =>
352 // r1 = SP, r15 = LR, r19 = FP, r20 = GP
353 \\ ori r15, r0, r0
354 \\ ori r19, r0, r0
355 \\ mfs r20, rpc
356 \\ addik r20, r20, _GLOBAL_OFFSET_TABLE_ + 8
357 \\ ori r5, r1, r0
358 \\ andi r1, r1, -4
359 \\ brlid r15, %[posixCallMainAndExit]
360 ,
336361 .mips, .mipsel =>
337362 \\ move $fp, $zero
338363 \\ bal 1f
......@@ -431,6 +456,21 @@ fn _start() callconv(.naked) noreturn {
431456 \\ stg %%r0, 0(%%r15)
432457 \\ jg %[posixCallMainAndExit]
433458 ,
459 .sh, .sheb =>
460 // r14 = FP, r15 = SP, pr = LR
461 \\ mov #0, r0
462 \\ lds r0, pr
463 \\ mov r0, r14
464 \\ mov r15, r4
465 \\ mov #-4, r0
466 \\ and r0, r15
467 \\ mov.l 2f, r1
468 \\1:
469 \\ bsrf r1
470 \\2:
471 \\ .balign 4
472 \\ .long %[posixCallMainAndExit]@PCREL - (1b + 4 - .)
473 ,
434474 .sparc =>
435475 // argc is stored after a register window (16 registers * 4 bytes).
436476 // i7 = LR
lib/std/zig/system.zig+23-11
......@@ -100,10 +100,14 @@ pub fn getExternalExecutor(
100100 else => bad_result,
101101 },
102102 inline .aarch64_be,
103 .alpha,
103104 .armeb,
104105 .hexagon,
106 .hppa,
105107 .loongarch64,
106108 .m68k,
109 .microblaze,
110 .microblazeel,
107111 .mips,
108112 .mipsel,
109113 .mips64,
......@@ -114,26 +118,34 @@ pub fn getExternalExecutor(
114118 .powerpc64le,
115119 .riscv32,
116120 .s390x,
121 .sh,
122 .sheb,
117123 .sparc,
118124 .sparc64,
119125 .thumb,
120126 .thumbeb,
121127 .xtensa,
128 .xtensaeb,
122129 => |t| switch (candidate.os.tag) {
123130 .linux,
124 => .{ .qemu = switch (t) {
125 .powerpc => "qemu-ppc",
126 .powerpc64 => "qemu-ppc64",
127 .powerpc64le => "qemu-ppc64le",
128 .mips64, .mips64el => switch (candidate.abi) {
129 .gnuabin32, .muslabin32 => if (t == .mips64el) "qemu-mipsn32el" else "qemu-mipsn32",
131 => .{
132 .qemu = switch (t) {
133 .powerpc => "qemu-ppc",
134 .powerpc64 => "qemu-ppc64",
135 .powerpc64le => "qemu-ppc64le",
136 .mips64, .mips64el => switch (candidate.abi) {
137 .gnuabin32, .muslabin32 => if (t == .mips64el) "qemu-mipsn32el" else "qemu-mipsn32",
138 else => "qemu-" ++ @tagName(t),
139 },
140 // TODO: Actually check the SuperH version.
141 .sh => "qemu-sh4",
142 .sheb => "qemu-sh4eb",
143 .sparc => if (candidate.cpu.has(.sparc, .v8plus)) "qemu-sparc32plus" else "qemu-sparc",
144 .thumb => "qemu-arm",
145 .thumbeb => "qemu-armeb",
130146 else => "qemu-" ++ @tagName(t),
131147 },
132 .sparc => if (candidate.cpu.has(.sparc, .v8plus)) "qemu-sparc32plus" else "qemu-sparc",
133 .thumb => "qemu-arm",
134 .thumbeb => "qemu-armeb",
135 else => "qemu-" ++ @tagName(t),
136 } },
148 },
137149 else => bad_result,
138150 },
139151 else => bad_result,
src/InternPool.zig+18
......@@ -12960,6 +12960,11 @@ const PackedCallingConvention = packed struct(u18) {
1296012960 .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0),
1296112961 .extra = @intFromEnum(pl.type),
1296212962 },
12963 std.builtin.CallingConvention.MicroblazeInterruptOptions => .{
12964 .tag = tag,
12965 .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0),
12966 .extra = @intFromEnum(pl.type),
12967 },
1296312968 std.builtin.CallingConvention.MipsInterruptOptions => .{
1296412969 .tag = tag,
1296512970 .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0),
......@@ -12970,6 +12975,11 @@ const PackedCallingConvention = packed struct(u18) {
1297012975 .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0),
1297112976 .extra = @intFromEnum(pl.mode),
1297212977 },
12978 std.builtin.CallingConvention.ShInterruptOptions => .{
12979 .tag = tag,
12980 .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0),
12981 .extra = @intFromEnum(pl.save),
12982 },
1297312983 else => comptime unreachable,
1297412984 },
1297512985 };
......@@ -12997,6 +13007,10 @@ const PackedCallingConvention = packed struct(u18) {
1299713007 .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(),
1299813008 .type = @enumFromInt(cc.extra),
1299913009 },
13010 std.builtin.CallingConvention.MicroblazeInterruptOptions => .{
13011 .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(),
13012 .type = @enumFromInt(cc.extra),
13013 },
1300013014 std.builtin.CallingConvention.MipsInterruptOptions => .{
1300113015 .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(),
1300213016 .mode = @enumFromInt(cc.extra),
......@@ -13005,6 +13019,10 @@ const PackedCallingConvention = packed struct(u18) {
1300513019 .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(),
1300613020 .mode = @enumFromInt(cc.extra),
1300713021 },
13022 std.builtin.CallingConvention.ShInterruptOptions => .{
13023 .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(),
13024 .save = @enumFromInt(cc.extra),
13025 },
1300813026 else => comptime unreachable,
1300913027 },
1301013028 ),
src/Sema.zig+25-3
......@@ -9035,6 +9035,7 @@ pub fn handleExternLibName(
90359035/// functions or there are no more other calling conventions that support variadic functions.
90369036const calling_conventions_supporting_var_args = [_]std.builtin.CallingConvention.Tag{
90379037 .x86_64_sysv,
9038 .x86_64_x32,
90389039 .x86_64_win,
90399040 .x86_sysv,
90409041 .x86_win,
......@@ -9043,8 +9044,10 @@ const calling_conventions_supporting_var_args = [_]std.builtin.CallingConvention
90439044 .aarch64_aapcs_win,
90449045 .aarch64_vfabi,
90459046 .aarch64_vfabi_sve,
9047 .alpha_osf,
90469048 .arm_aapcs,
90479049 .arm_aapcs_vfp,
9050 .microblaze_std,
90489051 .mips64_n64,
90499052 .mips64_n32,
90509053 .mips_o32,
......@@ -9068,6 +9071,8 @@ const calling_conventions_supporting_var_args = [_]std.builtin.CallingConvention
90689071 .csky_sysv,
90699072 .hexagon_sysv,
90709073 .hexagon_sysv_hvx,
9074 .hppa_elf,
9075 .hppa64_elf,
90719076 .lanai_sysv,
90729077 .loongarch64_lp64,
90739078 .loongarch32_ilp32,
......@@ -9078,6 +9083,8 @@ const calling_conventions_supporting_var_args = [_]std.builtin.CallingConvention
90789083 .or1k_sysv,
90799084 .s390x_sysv,
90809085 .s390x_sysv_vx,
9086 .sh_gnu,
9087 .sh_renesas,
90819088 .ve_sysv,
90829089 .xcore_xs1,
90839090 .xcore_xs2,
......@@ -9128,10 +9135,13 @@ fn callConvIsCallable(cc: std.builtin.CallingConvention.Tag) bool {
91289135 .avr_signal,
91299136 .csky_interrupt,
91309137 .m68k_interrupt,
9138 .microblaze_interrupt,
91319139 .mips_interrupt,
91329140 .mips64_interrupt,
9141 .msp430_interrupt,
91339142 .riscv32_interrupt,
91349143 .riscv64_interrupt,
9144 .sh_interrupt,
91359145 .x86_interrupt,
91369146 .x86_64_interrupt,
91379147
......@@ -9287,13 +9297,16 @@ fn funcCommon(
92879297 },
92889298 .arc_interrupt,
92899299 .arm_interrupt,
9300 .microblaze_interrupt,
92909301 .mips64_interrupt,
92919302 .mips_interrupt,
92929303 .riscv64_interrupt,
92939304 .riscv32_interrupt,
9305 .sh_interrupt,
92949306 .avr_interrupt,
92959307 .csky_interrupt,
92969308 .m68k_interrupt,
9309 .msp430_interrupt,
92979310 .avr_signal,
92989311 => return sema.fail(block, param_src, "parameters are not allowed with '{s}' calling convention", .{@tagName(cc)}),
92999312 else => {},
......@@ -9517,10 +9530,13 @@ fn finishFunc(
95179530 .mips_interrupt,
95189531 .riscv64_interrupt,
95199532 .riscv32_interrupt,
9533 .sh_interrupt,
95209534 .arc_interrupt,
95219535 .avr_interrupt,
95229536 .csky_interrupt,
95239537 .m68k_interrupt,
9538 .microblaze_interrupt,
9539 .msp430_interrupt,
95249540 .avr_signal,
95259541 => if (return_type.zigTypeTag(zcu) != .void and return_type.zigTypeTag(zcu) != .noreturn) {
95269542 return sema.fail(block, ret_ty_src, "function with calling convention '{s}' must return 'void' or 'noreturn'", .{@tagName(cc_resolved)});
......@@ -30047,12 +30063,18 @@ fn callconvCoerceAllowed(
3004730063 std.builtin.CallingConvention.ArmInterruptOptions => {
3004830064 if (src_data.type != dest_data.type) return false;
3004930065 },
30066 std.builtin.CallingConvention.MicroblazeInterruptOptions => {
30067 if (src_data.type != dest_data.type) return false;
30068 },
3005030069 std.builtin.CallingConvention.MipsInterruptOptions => {
3005130070 if (src_data.mode != dest_data.mode) return false;
3005230071 },
3005330072 std.builtin.CallingConvention.RiscvInterruptOptions => {
3005430073 if (src_data.mode != dest_data.mode) return false;
3005530074 },
30075 std.builtin.CallingConvention.ShInterruptOptions => {
30076 if (src_data.save != dest_data.save) return false;
30077 },
3005630078 else => comptime unreachable,
3005730079 }
3005830080 },
......@@ -36495,7 +36517,7 @@ fn resolveAddressSpace(
3649536517 block: *Block,
3649636518 src: LazySrcLoc,
3649736519 zir_ref: Zir.Inst.Ref,
36498 ctx: std.builtin.AddressSpace.Context,
36520 ctx: std.Target.AddressSpaceContext,
3649936521) !std.builtin.AddressSpace {
3650036522 const air_ref = try sema.resolveInst(zir_ref);
3650136523 return sema.analyzeAsAddressSpace(block, src, air_ref, ctx);
......@@ -36506,7 +36528,7 @@ pub fn analyzeAsAddressSpace(
3650636528 block: *Block,
3650736529 src: LazySrcLoc,
3650836530 air_ref: Air.Inst.Ref,
36509 ctx: std.builtin.AddressSpace.Context,
36531 ctx: std.Target.AddressSpaceContext,
3651036532) !std.builtin.AddressSpace {
3651136533 const pt = sema.pt;
3651236534 const addrspace_ty = try sema.getBuiltinType(src, .AddressSpace);
......@@ -37631,7 +37653,7 @@ pub fn resolveNavPtrModifiers(
3763137653 };
3763237654
3763337655 const @"addrspace": std.builtin.AddressSpace = as: {
37634 const addrspace_ctx: std.builtin.AddressSpace.Context = switch (zir_decl.kind) {
37656 const addrspace_ctx: std.Target.AddressSpaceContext = switch (zir_decl.kind) {
3763537657 .@"var" => .variable,
3763637658 else => switch (nav_ty.zigTypeTag(zcu)) {
3763737659 .@"fn" => .function,
src/Zcu.zig+14-51
......@@ -3836,61 +3836,17 @@ pub fn atomicPtrAlignment(
38363836) AtomicPtrAlignmentError!Alignment {
38373837 const target = zcu.getTarget();
38383838 const max_atomic_bits: u16 = switch (target.cpu.arch) {
3839 .avr,
3840 .msp430,
3841 => 16,
3842
3843 .arc,
3844 .arm,
3845 .armeb,
3846 .hexagon,
3847 .m68k,
3848 .mips,
3849 .mipsel,
3850 .nvptx,
3851 .or1k,
3852 .powerpc,
3853 .powerpcle,
3854 .riscv32,
3855 .riscv32be,
3856 .sparc,
3857 .thumb,
3858 .thumbeb,
3859 .x86,
3860 .xcore,
3861 .kalimba,
3862 .lanai,
3863 .wasm32,
3864 .csky,
3865 .spirv32,
3866 .loongarch32,
3867 .xtensa,
3868 .propeller,
3869 => 32,
3870
3871 .amdgcn,
3872 .bpfel,
3873 .bpfeb,
3874 .mips64,
3875 .mips64el,
3876 .nvptx64,
3877 .powerpc64,
3878 .powerpc64le,
3879 .riscv64,
3880 .riscv64be,
3881 .sparc64,
3882 .s390x,
3883 .wasm64,
3884 .ve,
3885 .spirv64,
3886 .loongarch64,
3887 => 64,
3888
38893839 .aarch64,
38903840 .aarch64_be,
38913841 => 128,
38923842
3893 .x86_64 => if (target.cpu.has(.x86, .cx16)) 128 else 64,
3843 .mips64,
3844 .mips64el,
3845 => 64, // N32 should be 64, not 32.
3846
3847 .x86_64 => if (target.cpu.has(.x86, .cx16)) 128 else 64, // x32 should be 64 or 128, not 32.
3848
3849 else => target.ptrBitWidth(),
38943850 };
38953851
38963852 if (ty.toIntern() == .bool_type) return .none;
......@@ -4470,6 +4426,7 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu
44704426 .riscv32_ilp32_v,
44714427 .m68k_rtd,
44724428 .m68k_interrupt,
4429 .msp430_interrupt,
44734430 => |opts| opts.incoming_stack_alignment == null,
44744431
44754432 .arm_aapcs_vfp,
......@@ -4481,6 +4438,9 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu
44814438 .arm_interrupt,
44824439 => |opts| opts.incoming_stack_alignment == null,
44834440
4441 .microblaze_interrupt,
4442 => |opts| opts.incoming_stack_alignment == null,
4443
44844444 .mips_interrupt,
44854445 .mips64_interrupt,
44864446 => |opts| opts.incoming_stack_alignment == null,
......@@ -4489,6 +4449,9 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu
44894449 .riscv64_interrupt,
44904450 => |opts| opts.incoming_stack_alignment == null,
44914451
4452 .sh_interrupt,
4453 => |opts| opts.incoming_stack_alignment == null,
4454
44924455 .x86_sysv,
44934456 .x86_win,
44944457 .x86_stdcall,
src/codegen/c.zig+16
......@@ -8092,6 +8092,13 @@ fn toCallingConvention(cc: std.builtin.CallingConvention, zcu: *Zcu) ?[]const u8
80928092
80938093 .avr_signal => "signal",
80948094
8095 .microblaze_interrupt => |opts| switch (opts.type) {
8096 .user => "save_volatiles",
8097 .regular => "interrupt_handler",
8098 .fast => "fast_interrupt",
8099 .breakpoint => "break_handler",
8100 },
8101
80958102 .mips_interrupt,
80968103 .mips64_interrupt,
80978104 => |opts| switch (opts.mode) {
......@@ -8106,11 +8113,20 @@ fn toCallingConvention(cc: std.builtin.CallingConvention, zcu: *Zcu) ?[]const u8
81068113 inline else => |m| "interrupt(\"" ++ @tagName(m) ++ "\")",
81078114 },
81088115
8116 .sh_renesas => "renesas",
8117 .sh_interrupt => |opts| switch (opts.save) {
8118 .fpscr => "trapa_handler", // Implies `interrupt_handler`.
8119 .high => "interrupt_handler, nosave_low_regs",
8120 .full => "interrupt_handler",
8121 .bank => "interrupt_handler, resbank",
8122 },
8123
81098124 .m68k_rtd => "m68k_rtd",
81108125
81118126 .avr_interrupt,
81128127 .csky_interrupt,
81138128 .m68k_interrupt,
8129 .msp430_interrupt,
81148130 .x86_interrupt,
81158131 .x86_64_interrupt,
81168132 => "interrupt",
src/codegen/llvm.zig+39
......@@ -106,9 +106,18 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8
106106 .wasm64 => "wasm64",
107107 .ve => "ve",
108108
109 .alpha,
110 .arceb,
111 .hppa,
112 .hppa64,
109113 .kalimba,
114 .microblaze,
115 .microblazeel,
110116 .or1k,
111117 .propeller,
118 .sh,
119 .sheb,
120 .xtensaeb,
112121 => unreachable, // Gated by hasLlvmSupport().
113122 };
114123
......@@ -473,9 +482,18 @@ pub fn dataLayout(target: *const std.Target) []const u8 {
473482 .loongarch64 => "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128",
474483 .xtensa => "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32",
475484
485 .alpha,
486 .arceb,
487 .hppa,
488 .hppa64,
476489 .kalimba,
490 .microblaze,
491 .microblazeel,
477492 .or1k,
478493 .propeller,
494 .sh,
495 .sheb,
496 .xtensaeb,
479497 => unreachable, // Gated by hasLlvmSupport().
480498 };
481499}
......@@ -11819,6 +11837,8 @@ pub fn toLlvmCallConv(cc: std.builtin.CallingConvention, target: *const std.Targ
1181911837 std.builtin.CallingConvention.ArcInterruptOptions,
1182011838 std.builtin.CallingConvention.ArmInterruptOptions,
1182111839 std.builtin.CallingConvention.RiscvInterruptOptions,
11840 std.builtin.CallingConvention.ShInterruptOptions,
11841 std.builtin.CallingConvention.MicroblazeInterruptOptions,
1182211842 std.builtin.CallingConvention.MipsInterruptOptions,
1182311843 std.builtin.CallingConvention.CommonOptions,
1182411844 => .{ pl.incoming_stack_alignment, 0 },
......@@ -11882,6 +11902,7 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: *const s
1188211902 .avr_interrupt => .avr_intrcc,
1188311903 .m68k_rtd => .m68k_rtdcc,
1188411904 .m68k_interrupt => .m68k_intrcc,
11905 .msp430_interrupt => .msp430_intrcc,
1188511906 .amdgcn_kernel => .amdgpu_kernel,
1188611907 .amdgcn_cs => .amdgpu_cs,
1188711908 .nvptx_device => .ptx_device,
......@@ -11901,9 +11922,13 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: *const s
1190111922 .x86_sysv,
1190211923 .x86_win,
1190311924 .x86_thiscall_mingw,
11925 .x86_64_x32,
1190411926 .aarch64_aapcs,
1190511927 .aarch64_aapcs_darwin,
1190611928 .aarch64_aapcs_win,
11929 .alpha_osf,
11930 .microblaze_std,
11931 .microblaze_interrupt,
1190711932 .mips64_n64,
1190811933 .mips64_n32,
1190911934 .mips_o32,
......@@ -11926,6 +11951,8 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: *const s
1192611951 .csky_sysv,
1192711952 .hexagon_sysv,
1192811953 .hexagon_sysv_hvx,
11954 .hppa_elf,
11955 .hppa64_elf,
1192911956 .lanai_sysv,
1193011957 .loongarch64_lp64,
1193111958 .loongarch32_ilp32,
......@@ -11936,6 +11963,9 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: *const s
1193611963 .propeller_sysv,
1193711964 .s390x_sysv,
1193811965 .s390x_sysv_vx,
11966 .sh_gnu,
11967 .sh_renesas,
11968 .sh_interrupt,
1193911969 .ve_sysv,
1194011970 .xcore_xs1,
1194111971 .xcore_xs2,
......@@ -13107,9 +13137,18 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
1310713137 },
1310813138
1310913139 // LLVM does does not have a backend for these.
13140 .alpha,
13141 .arceb,
13142 .hppa,
13143 .hppa64,
1311013144 .kalimba,
13145 .microblaze,
13146 .microblazeel,
1311113147 .or1k,
1311213148 .propeller,
13149 .sh,
13150 .sheb,
13151 .xtensaeb,
1311313152 => unreachable,
1311413153 }
1311513154}
src/link/Dwarf.zig+5
......@@ -3905,6 +3905,8 @@ fn updateLazyType(
39053905
39063906 .m68k_rtd => .LLVM_M68kRTD,
39073907
3908 .sh_renesas => .GNU_renesas_sh,
3909
39083910 .amdgcn_kernel => .LLVM_OpenCLKernel,
39093911 .nvptx_kernel,
39103912 .spirv_kernel,
......@@ -3917,12 +3919,15 @@ fn updateLazyType(
39173919 .mips_interrupt,
39183920 .riscv64_interrupt,
39193921 .riscv32_interrupt,
3922 .sh_interrupt,
39203923 .arc_interrupt,
39213924 .avr_builtin,
39223925 .avr_signal,
39233926 .avr_interrupt,
39243927 .csky_interrupt,
39253928 .m68k_interrupt,
3929 .microblaze_interrupt,
3930 .msp430_interrupt,
39263931 => .normal,
39273932
39283933 else => .nocall,
src/target.zig+21-3
......@@ -216,9 +216,18 @@ pub fn hasLlvmSupport(target: *const std.Target, ofmt: std.Target.ObjectFormat)
216216 => false,
217217
218218 // No LLVM backend exists.
219 .alpha,
220 .arceb,
221 .hppa,
222 .hppa64,
219223 .kalimba,
224 .microblaze,
225 .microblazeel,
220226 .or1k,
221227 .propeller,
228 .sh,
229 .sheb,
230 .xtensaeb,
222231 => false,
223232 };
224233}
......@@ -711,18 +720,26 @@ pub fn minFunctionAlignment(target: *const std.Target) Alignment {
711720 .csky,
712721 .m68k,
713722 .msp430,
723 .sh,
724 .sheb,
714725 .s390x,
715726 .xcore,
716727 => .@"2",
728 .aarch64,
729 .aarch64_be,
730 .alpha,
717731 .arc,
732 .arceb,
718733 .arm,
719734 .armeb,
720 .aarch64,
721 .aarch64_be,
722735 .hexagon,
736 .hppa,
737 .hppa64,
723738 .lanai,
724739 .loongarch32,
725740 .loongarch64,
741 .microblaze,
742 .microblazeel,
726743 .mips,
727744 .mipsel,
728745 .powerpc,
......@@ -732,9 +749,10 @@ pub fn minFunctionAlignment(target: *const std.Target) Alignment {
732749 .sparc,
733750 .sparc64,
734751 .xtensa,
752 .xtensaeb,
735753 => .@"4",
736 .bpfel,
737754 .bpfeb,
755 .bpfel,
738756 .mips64,
739757 .mips64el,
740758 => .@"8",
test/cases/compile_errors/invalid_variadic_function.zig+2-2
......@@ -12,6 +12,6 @@ comptime {
1212// target=x86_64-linux
1313//
1414// :1:8: error: variadic function does not support 'auto' calling convention
15// :1:8: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win'
15// :1:8: note: supported calling conventions: 'x86_64_sysv', 'x86_64_x32', 'x86_64_win'
1616// :2:16: error: variadic function does not support 'inline' calling convention
17// :2:16: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win'
17// :2:16: note: supported calling conventions: 'x86_64_sysv', 'x86_64_x32', 'x86_64_win'
test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig+1-1
......@@ -15,4 +15,4 @@ comptime {
1515// target=x86_64-linux
1616//
1717// :1:13: error: variadic function does not support 'auto' calling convention
18// :1:13: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win'
18// :1:13: note: supported calling conventions: 'x86_64_sysv', 'x86_64_x32', 'x86_64_win'
test/tests.zig+11-12
......@@ -40,7 +40,7 @@ const test_targets = blk: {
4040 // getBaselineCpuFeatures calls populateDependencies which has a O(N ^ 2) algorithm
4141 // (where N is roughly 160, which technically makes it O(1), but it adds up to a
4242 // lot of branches)
43 @setEvalBranchQuota(50000);
43 @setEvalBranchQuota(60000);
4444 break :blk [_]TestTarget{
4545 // Native Targets
4646
......@@ -397,16 +397,15 @@ const test_targets = blk: {
397397 }) catch unreachable,
398398 .link_libc = true,
399399 },
400 // Currently crashes in qemu-hexagon.
401 // .{
402 // .target = std.Target.Query.parse(.{
403 // .arch_os_abi = "hexagon-linux-musl",
404 // .cpu_features = "baseline+long_calls",
405 // }) catch unreachable,
406 // .linkage = .dynamic,
407 // .link_libc = true,
408 // .extra_target = true,
409 // },
400 .{
401 .target = std.Target.Query.parse(.{
402 .arch_os_abi = "hexagon-linux-musl",
403 .cpu_features = "baseline+long_calls",
404 }) catch unreachable,
405 .linkage = .dynamic,
406 .link_libc = true,
407 .extra_target = true,
408 },
410409
411410 .{
412411 .target = .{
......@@ -1551,7 +1550,7 @@ const CAbiTarget = struct {
15511550};
15521551
15531552const c_abi_targets = blk: {
1554 @setEvalBranchQuota(20000);
1553 @setEvalBranchQuota(30000);
15551554 break :blk [_]CAbiTarget{
15561555 // Native Targets
15571556