diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 1b0c617598d346dba09599feb5b47649a916b71a..36c7c522fb9f2f44cde417a5b6f554eef2536b0c 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -53,6 +53,7 @@ pub const Os = struct { ps3, ps4, ps5, + psp, vita, emscripten, @@ -194,6 +195,7 @@ pub const Os = struct { .@"3ds", + .psp, .vita, .wasi, @@ -612,6 +614,13 @@ pub const Os = struct { }, }, + .psp => .{ + .semver = .{ + .min = .{ .major = 1, .minor = 0, .patch = 0 }, + .max = .{ .major = 6, .minor = 61, .patch = 0 }, + }, + }, + .vita => .{ .semver = .{ // 1.3 is the first public release @@ -919,6 +928,7 @@ pub const Abi = enum { .tvos, .visionos, .watchos, + .psp, .ps3, .ps4, .ps5, @@ -2023,7 +2033,10 @@ pub const Cpu = struct { .lanai => &lanai.cpu.v11, // clang does not have a generic lanai model. .loongarch64 => &loongarch.cpu.la64v1_0, .m68k => &m68k.cpu.M68000, - .mips, .mipsel => &mips.cpu.mips32r2, + .mips, .mipsel => switch (os.tag) { + .psp => &mips.cpu.mips2, // mips2 with some custom instructions, no trap instructions + else => &mips.cpu.mips32r2, + }, .mips64, .mips64el => &mips.cpu.mips64r2, .msp430 => &msp430.cpu.msp430, .nvptx, .nvptx64 => &nvptx.cpu.sm_52, @@ -2204,6 +2217,7 @@ pub fn requiresLibC(target: *const Target) bool { .amdhsa, .ps4, .ps5, + .psp, .vita, .mesa3d, .contiki, @@ -2379,6 +2393,7 @@ pub const DynamicLinker = struct { .ps3, .ps4, .ps5, + .psp, .vita, => .none, }; @@ -2783,6 +2798,7 @@ pub const DynamicLinker = struct { .@"3ds", + .psp, .vita, .emscripten, @@ -3338,7 +3354,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 { .longlong, .ulonglong, .double => return 64, .longdouble => return 80, }, - .vita => switch (c_type) { + .psp, .vita => switch (c_type) { .char => return 8, .short, .ushort => return 16, .int, .uint, .float => return 32, diff --git a/lib/std/heap.zig b/lib/std/heap.zig index ef91461edf43390807048a79ce2883607e1e6c18..9bf1aeffbb1ae7774b85f7b34ab2b44f56091433 100644 --- a/lib/std/heap.zig +++ b/lib/std/heap.zig @@ -805,6 +805,11 @@ const page_size_min_default: ?usize = switch (builtin.os.tag) { .x86, .x86_64 => 16 << 10, else => null, }, + .psp => switch (builtin.cpu.arch) { + // minimum block allocation by testing sceKernel + .mips, .mipsel => 1 << 8, // 256 + else => null, + }, // system/lib/libc/musl/arch/emscripten/bits/limits.h .emscripten => 64 << 10, .linux => switch (builtin.cpu.arch) { @@ -963,6 +968,11 @@ const page_size_max_default: ?usize = switch (builtin.os.tag) { .x86, .x86_64 => 16 << 10, else => null, }, + .psp => switch (builtin.cpu.arch) { + // minimum block allocation by testing sceKernel + .mips, .mipsel => 1 << 8, // 256 + else => null, + }, // system/lib/libc/musl/arch/emscripten/bits/limits.h .emscripten => 64 << 10, .linux => switch (builtin.cpu.arch) { diff --git a/lib/std/start.zig b/lib/std/start.zig index fd195af8a54b73dd1a8442e7fcf3cee04f31c9f2..f6b4064ebdf258330870d30020e78e02a9d4be01 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -65,7 +65,7 @@ comptime { // case it's not required to provide an entrypoint such as main. if (!@hasDecl(root, start_sym_name) and @hasDecl(root, "main")) @export(&wasm_freestanding_start, .{ .name = start_sym_name }); } else switch (native_os) { - .other, .freestanding, .@"3ds", .vita => {}, + .other, .freestanding, .@"3ds", .psp, .vita => {}, else => if (!@hasDecl(root, start_sym_name)) @export(&_start, .{ .name = start_sym_name }), } } diff --git a/src/Compilation.zig b/src/Compilation.zig index 53a287499062332d4501a60a00676f2b42a7fe1d..00ddd0001ef167651f6fcfd61682879158f5439a 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -6420,6 +6420,7 @@ fn addCommonCCArgs( .illumos => try argv.append("__illumos__"), // Homebrew targets without LLVM support; use communities's preferred macros. .@"3ds" => try argv.append("-D__3DS__"), + .psp => try argv.append("-D__PSP__"), .vita => try argv.append("-D__vita__"), else => {}, } diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index ec9d176fe5f34181c5bcc1f71042747e986360fd..8c359b95873b1a7d4c62917be6c6d19aa00fb19c 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -247,6 +247,7 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8 .opengl, .other, .plan9, + .psp, .vita, => "unknown", };