authorgravatar for vesim809@pm.meMaciej 'vesim' Kuliński <vesim809@pm.me> 2025-07-21 13:02:27+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-26 07:50:06+02:00
logff859088e409f3fcf7c4f52e58ec4e6e9f7f1c4e
treea4de53d27594d23fb8cb61364d745feb1e11bd0b
parent99b2b61516b7ee9c4cd31ebe88161dd7191c2e0d

std.Target: add vita os

Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>

4 files changed, 37 insertions(+), 2 deletions(-)

lib/std/Target.zig+31-1
......@@ -55,6 +55,7 @@ pub const Os = struct {
5555 ps3,
5656 ps4,
5757 ps5,
58 vita,
5859
5960 emscripten,
6061 wasi,
......@@ -198,6 +199,8 @@ pub const Os = struct {
198199
199200 .@"3ds",
200201
202 .vita,
203
201204 .wasi,
202205
203206 .amdhsa,
......@@ -607,6 +610,7 @@ pub const Os = struct {
607610 .max = .{ .major = 2, .minor = 11, .patch = 0 },
608611 },
609612 },
613
610614 .@"3ds" => .{
611615 .semver = .{
612616 // These signify release versions (https://www.3dbrew.org/wiki/NCCH/Extended_Header#ARM11_Kernel_Capabilities)
......@@ -618,6 +622,15 @@ pub const Os = struct {
618622 .max = .{ .major = 2, .minor = 58, .patch = 0 }, // 11.17.0-50
619623 },
620624 },
625
626 .vita => .{
627 .semver = .{
628 // 1.3 is the first public release
629 .min = .{ .major = 1, .minor = 3, .patch = 0 },
630 .max = .{ .major = 3, .minor = 60, .patch = 0 },
631 },
632 },
633
621634 .wasi => .{
622635 .semver = .{
623636 .min = .{ .major = 0, .minor = 1, .patch = 0 },
......@@ -876,6 +889,7 @@ pub const Abi = enum {
876889 .windows => .gnu,
877890 .uefi => .msvc,
878891 .@"3ds" => .eabihf,
892 .vita => .eabihf,
879893 .wasi, .emscripten => .musl,
880894
881895 .contiki,
......@@ -1863,9 +1877,14 @@ pub const Cpu = struct {
18631877 .amdgcn => &amdgcn.cpu.gfx906,
18641878 .arm => switch (os.tag) {
18651879 .@"3ds" => &arm.cpu.mpcore,
1880 .vita => &arm.cpu.cortex_a9,
1881 else => &arm.cpu.baseline,
1882 },
1883 .thumb => switch (os.tag) {
1884 .vita => &arm.cpu.cortex_a9,
18661885 else => &arm.cpu.baseline,
18671886 },
1868 .armeb, .thumb, .thumbeb => &arm.cpu.baseline,
1887 .armeb, .thumbeb => &arm.cpu.baseline,
18691888 .aarch64 => switch (os.tag) {
18701889 .driverkit, .macos => &aarch64.cpu.apple_m1,
18711890 .ios, .tvos => &aarch64.cpu.apple_a7,
......@@ -2079,6 +2098,7 @@ pub fn requiresLibC(target: *const Target) bool {
20792098 .amdhsa,
20802099 .ps4,
20812100 .ps5,
2101 .vita,
20822102 .mesa3d,
20832103 .contiki,
20842104 .amdpal,
......@@ -2208,6 +2228,7 @@ pub const DynamicLinker = struct {
22082228 .ps3,
22092229 .ps4,
22102230 .ps5,
2231 .vita,
22112232 => .none,
22122233 };
22132234 }
......@@ -2579,6 +2600,8 @@ pub const DynamicLinker = struct {
25792600
25802601 .@"3ds",
25812602
2603 .vita,
2604
25822605 .emscripten,
25832606 .wasi,
25842607
......@@ -3111,6 +3134,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
31113134 .longlong, .ulonglong, .double => return 64,
31123135 .longdouble => return 80,
31133136 },
3137 .vita => switch (c_type) {
3138 .char => return 8,
3139 .short, .ushort => return 16,
3140 .int, .uint, .float => return 32,
3141 .long, .ulong => return 64,
3142 .longlong, .ulonglong, .double, .longdouble => return 64,
3143 },
31143144
31153145 .ps3,
31163146 .contiki,
src/Compilation.zig+2
......@@ -6927,8 +6927,10 @@ pub fn addCCArgs(
69276927 },
69286928 }
69296929
6930 // Homebrew targets without LLVM support; use communities's preferred macros.
69306931 switch (target.os.tag) {
69316932 .@"3ds" => try argv.append("-D__3DS__"),
6933 .vita => try argv.append("-D__vita__"),
69326934 else => {},
69336935 }
69346936
src/codegen/llvm.zig+2-1
......@@ -200,7 +200,6 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8
200200 .freebsd => "freebsd",
201201 .fuchsia => "fuchsia",
202202 .linux => "linux",
203 .ps3 => "lv2",
204203 .netbsd => "netbsd",
205204 .openbsd => "openbsd",
206205 .solaris, .illumos => "solaris",
......@@ -213,8 +212,10 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8
213212 .nvcl => "nvcl",
214213 .amdhsa => "amdhsa",
215214 .opencl => "unknown", // https://llvm.org/docs/SPIRVUsage.html#target-triples
215 .ps3 => "lv2",
216216 .ps4 => "ps4",
217217 .ps5 => "ps5",
218 .vita => "unknown", // LLVM doesn't know about this target
218219 .mesa3d => "mesa3d",
219220 .amdpal => "amdpal",
220221 .hermit => "hermit",
test/llvm_targets.zig+2
......@@ -70,6 +70,7 @@ const targets = [_]std.Target.Query{
7070 .{ .cpu_arch = .arm, .os_tag = .rtems, .abi = .eabihf },
7171 // .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabi },
7272 // .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabihf },
73 .{ .cpu_arch = .arm, .os_tag = .vita, .abi = .eabihf },
7374
7475 .{ .cpu_arch = .armeb, .os_tag = .freestanding, .abi = .eabi },
7576 .{ .cpu_arch = .armeb, .os_tag = .freestanding, .abi = .eabihf },
......@@ -263,6 +264,7 @@ const targets = [_]std.Target.Query{
263264 .{ .cpu_arch = .thumb, .os_tag = .linux, .abi = .musleabihf },
264265 .{ .cpu_arch = .thumb, .os_tag = .rtems, .abi = .eabi },
265266 .{ .cpu_arch = .thumb, .os_tag = .rtems, .abi = .eabihf },
267 .{ .cpu_arch = .thumb, .os_tag = .vita, .abi = .eabihf },
266268 .{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .gnu },
267269 .{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .itanium },
268270 .{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .msvc },