Skip to content

Commit 6ef88a2

Browse files
vesim987alexrp
andcommitted
std.Target: add vita os
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
1 parent 83f773f commit 6ef88a2

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

lib/std/Target.zig

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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,
@@ -1845,9 +1859,14 @@ pub const Cpu = struct {
18451859
.amdgcn => &amdgcn.cpu.gfx906,
18461860
.arm => switch (os.tag) {
18471861
.@"3ds" => &arm.cpu.mpcore,
1862+
.vita => &arm.cpu.cortex_a9,
1863+
else => &arm.cpu.baseline,
1864+
},
1865+
.thumb => switch (os.tag) {
1866+
.vita => &arm.cpu.cortex_a9,
18481867
else => &arm.cpu.baseline,
18491868
},
1850-
.armeb, .thumb, .thumbeb => &arm.cpu.baseline,
1869+
.armeb, .thumbeb => &arm.cpu.baseline,
18511870
.aarch64 => switch (os.tag) {
18521871
.driverkit, .macos => &aarch64.cpu.apple_m1,
18531872
.ios, .tvos => &aarch64.cpu.apple_a7,
@@ -2061,6 +2080,7 @@ pub fn requiresLibC(target: *const Target) bool {
20612080
.amdhsa,
20622081
.ps4,
20632082
.ps5,
2083+
.vita,
20642084
.mesa3d,
20652085
.contiki,
20662086
.amdpal,
@@ -2190,6 +2210,7 @@ pub const DynamicLinker = struct {
21902210
.ps3,
21912211
.ps4,
21922212
.ps5,
2213+
.vita,
21932214
=> .none,
21942215
};
21952216
}
@@ -2561,6 +2582,8 @@ pub const DynamicLinker = struct {
25612582

25622583
.@"3ds",
25632584

2585+
.vita,
2586+
25642587
.emscripten,
25652588
.wasi,
25662589

@@ -3083,6 +3106,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
30833106
.longlong, .ulonglong, .double => return 64,
30843107
.longdouble => return 80,
30853108
},
3109+
.vita => switch (c_type) {
3110+
.char => return 8,
3111+
.short, .ushort => return 16,
3112+
.int, .uint, .float => return 32,
3113+
.long, .ulong => return 64,
3114+
.longlong, .ulonglong, .double, .longdouble => return 64,
3115+
},
30863116

30873117
.ps3,
30883118
.contiki,

src/Compilation.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6924,8 +6924,10 @@ pub fn addCCArgs(
69246924
},
69256925
}
69266926

6927+
// Homebrew targets without LLVM support; use communities's preferred macros.
69276928
switch (target.os.tag) {
69286929
.@"3ds" => try argv.append("-D__3DS__"),
6930+
.vita => try argv.append("-D__vita__"),
69296931
else => {},
69306932
}
69316933

src/codegen/llvm.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8
198198
.freebsd => "freebsd",
199199
.fuchsia => "fuchsia",
200200
.linux => "linux",
201-
.ps3 => "lv2",
202201
.netbsd => "netbsd",
203202
.openbsd => "openbsd",
204203
.solaris, .illumos => "solaris",
@@ -211,8 +210,10 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8
211210
.nvcl => "nvcl",
212211
.amdhsa => "amdhsa",
213212
.opencl => "unknown", // https://llvm.org/docs/SPIRVUsage.html#target-triples
213+
.ps3 => "lv2",
214214
.ps4 => "ps4",
215215
.ps5 => "ps5",
216+
.vita => "unknown", // LLVM doesn't know about this target
216217
.mesa3d => "mesa3d",
217218
.amdpal => "amdpal",
218219
.hermit => "hermit",

test/llvm_targets.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 },
@@ -259,6 +260,7 @@ const targets = [_]std.Target.Query{
259260
.{ .cpu_arch = .thumb, .os_tag = .linux, .abi = .musleabihf },
260261
.{ .cpu_arch = .thumb, .os_tag = .rtems, .abi = .eabi },
261262
.{ .cpu_arch = .thumb, .os_tag = .rtems, .abi = .eabihf },
263+
.{ .cpu_arch = .thumb, .os_tag = .vita, .abi = .eabihf },
262264
.{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .gnu },
263265
.{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .itanium },
264266
.{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .msvc },

0 commit comments

Comments
 (0)