diff --git a/lib/std/Build/Configuration.zig b/lib/std/Build/Configuration.zig index bdbe7303428b8e26941c03b4e469bbb038208ca5..236fa4671dcf6490a466db1b4a040d39988dabc6 100644 --- a/lib/std/Build/Configuration.zig +++ b/lib/std/Build/Configuration.zig @@ -2591,6 +2591,7 @@ pub const TargetQuery = struct { uefi, @"3ds", wiiu, + psx, ps3, ps4, ps5, @@ -2640,6 +2641,7 @@ pub const TargetQuery = struct { .uefi => .uefi, .@"3ds" => .@"3ds", .wiiu => .wiiu, + .psx => .psx, .ps3 => .ps3, .ps4 => .ps4, .ps5 => .ps5, @@ -2689,6 +2691,7 @@ pub const TargetQuery = struct { .uefi => .uefi, .@"3ds" => .@"3ds", .wiiu => .wiiu, + .psx => .psx, .ps3 => .ps3, .ps4 => .ps4, .ps5 => .ps5, diff --git a/lib/std/Target.zig b/lib/std/Target.zig index b9e967844211a1c6d640dc621dc88533bb0be91b..a75d23ca4d7530da5aaeda2c3f9c5a2056914391 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -51,6 +51,7 @@ pub const Os = struct { @"3ds", wiiu, + psx, ps3, ps4, ps5, @@ -166,6 +167,7 @@ pub const Os = struct { .plan9, .serenity, + .psx, .ps3, .ps4, .ps5, @@ -402,6 +404,7 @@ pub const Os = struct { .plan9, .serenity, + .psx, .ps3, .ps4, .ps5, @@ -949,6 +952,7 @@ pub const Abi = enum { .uefi => .msvc, .@"3ds" => .eabihf, .wiiu => .eabihf, + .psx => .eabi, .psp => .eabihf, .vita => .eabihf, .wasi, .emscripten => .musl, @@ -2098,6 +2102,7 @@ pub const Cpu = struct { .m68k => &m68k.cpu.M68030, .mips => &mips.cpu.mips32r2, .mipsel => switch (os.tag) { + .psx => &mips.cpu.r3000a, .psp => &mips.cpu.allegrex, else => &mips.cpu.mips32r2, }, @@ -2290,11 +2295,12 @@ pub fn requiresLibC(target: *const Target) bool { .freestanding, .fuchsia, .managarm, - .ps3, .rtems, .cuda, .nvcl, .amdhsa, + .psx, + .ps3, .ps4, .ps5, .psp, @@ -2475,6 +2481,7 @@ pub const DynamicLinker = struct { .opengl, .vulkan, + .psx, .ps3, .ps4, .ps5, @@ -2886,6 +2893,7 @@ pub const DynamicLinker = struct { .@"3ds", .wiiu, + .psx, .psp, .vita, @@ -3445,6 +3453,12 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 { .longlong, .ulonglong, .double, .longdouble => return 64, }, + .psx => switch (c_type) { + .char => return 8, + .short, .ushort => return 16, + .int, .uint, .long, .ulong, .float => return 32, + .longlong, .ulonglong, .double, .longdouble => return 64, + }, .ps4, .ps5 => switch (c_type) { .char => return 8, .short, .ushort => return 16, diff --git a/lib/std/Target/mips.zig b/lib/std/Target/mips.zig index 02ff2f6a9d338d52e5b188a13e4d8fbcd6673f6f..dad3a54940b45a9e9f2a7f45f8fb52cf34545f63 100644 --- a/lib/std/Target/mips.zig +++ b/lib/std/Target/mips.zig @@ -587,4 +587,13 @@ pub const cpu = struct { .p5600, }), }; + pub const r3000a: CpuModel = .{ + .name = "r3000a", + .llvm_name = null, + .features = featureSet(&[_]Feature{ + .mips1, + .notraps, + .soft_float, + }), + }; }; diff --git a/lib/std/debug.zig b/lib/std/debug.zig index ccbb38a1d6743ae0d099dac5e62ebbe6ab0c6d86..578d06fd3f5ddefdf64d8ea3af2e6b510a7513d3 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -507,7 +507,16 @@ pub fn defaultPanic(msg: []const u8, first_trace_addr: ?usize) noreturn { if (use_trap_panic) @trap(); switch (builtin.os.tag) { - .freestanding, .other, .@"3ds", .wiiu, .psp, .vita => { + .freestanding, + .other, + + .@"3ds", + .wiiu, + + .psx, + .psp, + .vita, + => { @trap(); }, .uefi => { diff --git a/lib/std/start.zig b/lib/std/start.zig index b1c9b4886fffc84c39f84c9407697d168ad5d4cc..d779042189bf3eaeb8b7e41e5dd1fa7bb53f3491 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -70,7 +70,19 @@ 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", .wiiu, .psp, .vita, .vulkan, .opengl, .opencl => {}, + .other, + .freestanding, + .vulkan, + .opengl, + .opencl, + + .@"3ds", + .wiiu, + + .psx, + .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 0a8de7e94f3b6a7dc4e47b0777a5fbe05827e2ab..c5d78866f8a97c69727b496abee4b035e5c14935 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -6354,6 +6354,7 @@ fn addCommonCCArgs( // Homebrew targets without LLVM support; use communities's preferred macros. .@"3ds" => try argv.append("-D__3DS__"), .wiiu => try argv.append("-D__WIIU__"), + .psx => try argv.append("-D__psx__"), .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 f747b6c8960513cde547e037174cee71573715e1..c00dc45b80166c02ab3e46320af00216014dfe0a 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -243,9 +243,10 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8 .opengl, .other, .plan9, + .psx, .psp, - .tios, .vita, + .tios, .wiiu, => "unknown", }; diff --git a/test/llvm_targets.zig b/test/llvm_targets.zig index ce4a2b145ab7911afe650a5d162c0bf59297a56e..9e3761b68b62c7d74090d9162530f77e57b73132 100644 --- a/test/llvm_targets.zig +++ b/test/llvm_targets.zig @@ -154,6 +154,7 @@ const targets = [_]std.Target.Query{ .{ .cpu_arch = .mipsel, .os_tag = .linux, .abi = .musleabihf }, .{ .cpu_arch = .mipsel, .os_tag = .netbsd, .abi = .eabi }, .{ .cpu_arch = .mipsel, .os_tag = .netbsd, .abi = .eabihf }, + .{ .cpu_arch = .mipsel, .os_tag = .psx, .abi = .eabi }, .{ .cpu_arch = .mipsel, .os_tag = .psp, .abi = .eabihf }, .{ .cpu_arch = .mipsel, .os_tag = .rtems, .abi = .eabi }, .{ .cpu_arch = .mipsel, .os_tag = .rtems, .abi = .eabihf }, diff --git a/tools/update_cpu_features.zig b/tools/update_cpu_features.zig index ea6a659507a972c3c95492817ac6779a4ced05ba..8ba30a61e37a3d387199fd835985771c0da94481 100644 --- a/tools/update_cpu_features.zig +++ b/tools/update_cpu_features.zig @@ -1358,6 +1358,15 @@ const targets = [_]ArchTarget{ }, }, .extra_cpus = &.{ + .{ + .llvm_name = null, + .zig_name = "r3000a", + .features = &.{ + "mips1", + "soft_float", + "notraps", + }, + }, .{ .llvm_name = null, .zig_name = "allegrex",