rustc_target/spec/targets/
mipsel_sony_psx.rs

1use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, cvs};
2
3pub(crate) fn target() -> Target {
4    Target {
5        llvm_target: "mipsel-sony-psx".into(),
6        metadata: crate::spec::TargetMetadata {
7            description: Some("MIPS (LE) Sony PlayStation 1 (PSX)".into()),
8            tier: Some(3),
9            host_tools: Some(false),
10            std: Some(false),
11        },
12        pointer_width: 32,
13        data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(),
14        arch: "mips".into(),
15
16        options: TargetOptions {
17            // The Playstation 1 is mostly bare-metal, but the BIOS does provide some a slight bit
18            // of functionality post load, so we still declare it as `cfg!(target_os = "psx")`.
19            //
20            // See <https://github.com/rust-lang/rust/pull/131168> for details.
21            os: "psx".into(),
22            vendor: "sony".into(),
23            linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
24            cpu: "mips1".into(),
25            executables: true,
26            linker: Some("rust-lld".into()),
27            relocation_model: RelocModel::Static,
28            exe_suffix: ".exe".into(),
29
30            // PSX doesn't natively support floats.
31            features: "+soft-float".into(),
32
33            // This should be 16 bits, but LLVM incorrectly tries emitting MIPS-II SYNC instructions
34            // for atomic loads and stores. This crashes rustc so we have to disable the Atomic* API
35            // until this is fixed upstream. See https://reviews.llvm.org/D122427#3420144 for more
36            // info.
37            max_atomic_width: Some(0),
38
39            // PSX does not support trap-on-condition instructions.
40            llvm_args: cvs!["-mno-check-zero-division"],
41            llvm_abiname: "o32".into(),
42            panic_strategy: PanicStrategy::Abort,
43            ..Default::default()
44        },
45    }
46}