rustc_target/spec/targets/
mipsel_sony_psx.rs

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