[TargetParser][Mips] Add the mips64r5900el-ps2-elf triple #20

Merged
techwritescode merged 1 commit from ps2-triple into r5900-ee 2026-10-15 22:08:27 +00:00

PS2-194: lets LLVM parse the PS2 EE toolchain's own name, mips64r5900el-ps2-elf (GNU spelling), and makes the triple imply the R5900 and the n32 ABI. Stacked on #18, so this PR also contains #18's commit; merge #18 first.

Piece Change
Arch mips64r5900el parses as mips64el with a new MipsSubArch_r5900, and prints back the same way
Vendor new ps2 vendor (Triple::PS2), in the vendor slot as GNU spells it, so Triple("mips64r5900el-ps2-elf") works without normalising, and the clang driver picks the same toolchain as for mips64el-unknown-elf
isPS2() mips64el with vendor ps2, following isPS4()/isPS5()
isABIN32() true for isPS2(), so clang's ABI and data layout, MipsABIInfo and lld (#18) all see n32 from the triple
Default CPU MipsSubArch_r5900 makes r5900 the default in the clang driver and in selectMipsCPU, so LTO code generation produces R5900 objects without --plugin-opt=mcpu=

Precedent: the PS4/PS5 triples (x86_64-scei-ps4, isPS4()), the MIPS r6 sub-architecture (mipsisa64r6el, which sets the default CPU) and the PSP's mipsallegrexel arch name.

No GNU or Linux environment is involved, so none of the glibc assumptions that gnuabin32 would bring apply. Compared with --target=mips64el-unknown-elf -mcpu=r5900 -mabi=n32, the sdk-core bench ELF is identical apart from the .comment string.

Tests:

  • TripleTest: parse, isPS2, isABIN32, normalise. All 32 TripleTest tests pass, as does the rest of TargetParserTests.
  • New: clang/test/Driver/mips-ps2.c (-target-cpu r5900, -target-abi n32, _ABIN32, _MIPS_ARCH_R5900) and llvm/test/MC/Mips/r5900-ps2-triple.s (ELF32, abi2, 5900 with no -mcpu).
  • lld/test/ELF/lto/mips-n32.ll: a PS2-triple bitcode case.
  • lit: CodeGen/Mips, MC/Mips, MC/Disassembler/Mips and lld/ELF have no failures. The clang Driver/Preprocessor failures in this dev build are all unknown target triple 'unknown': the build has no default target.

Still to do: the console rig run for the LTO bench built with this triple. The rig service was down; it will be reported on PS2-194.

🤖 Generated with Claude Code

PS2-194: lets LLVM parse the PS2 EE toolchain's own name, `mips64r5900el-ps2-elf` (GNU spelling), and makes the triple imply the R5900 and the n32 ABI. Stacked on #18, so this PR also contains #18's commit; merge #18 first. | Piece | Change | |---|---| | Arch | `mips64r5900el` parses as `mips64el` with a new `MipsSubArch_r5900`, and prints back the same way | | Vendor | new `ps2` vendor (`Triple::PS2`), in the vendor slot as GNU spells it, so `Triple("mips64r5900el-ps2-elf")` works without normalising, and the clang driver picks the same toolchain as for `mips64el-unknown-elf` | | `isPS2()` | `mips64el` with vendor `ps2`, following `isPS4()`/`isPS5()` | | `isABIN32()` | true for `isPS2()`, so clang's ABI and data layout, `MipsABIInfo` and lld (#18) all see n32 from the triple | | Default CPU | `MipsSubArch_r5900` makes `r5900` the default in the clang driver and in `selectMipsCPU`, so LTO code generation produces R5900 objects without `--plugin-opt=mcpu=` | Precedent: the PS4/PS5 triples (`x86_64-scei-ps4`, `isPS4()`), the MIPS r6 sub-architecture (`mipsisa64r6el`, which sets the default CPU) and the PSP's `mipsallegrexel` arch name. No GNU or Linux environment is involved, so none of the glibc assumptions that `gnuabin32` would bring apply. Compared with `--target=mips64el-unknown-elf -mcpu=r5900 -mabi=n32`, the sdk-core bench ELF is identical apart from the `.comment` string. Tests: - `TripleTest`: parse, `isPS2`, `isABIN32`, normalise. All 32 TripleTest tests pass, as does the rest of `TargetParserTests`. - New: `clang/test/Driver/mips-ps2.c` (`-target-cpu r5900`, `-target-abi n32`, `_ABIN32`, `_MIPS_ARCH_R5900`) and `llvm/test/MC/Mips/r5900-ps2-triple.s` (ELF32, abi2, 5900 with no `-mcpu`). - `lld/test/ELF/lto/mips-n32.ll`: a PS2-triple bitcode case. - lit: CodeGen/Mips, MC/Mips, MC/Disassembler/Mips and lld/ELF have no failures. The clang Driver/Preprocessor failures in this dev build are all `unknown target triple 'unknown'`: the build has no default target. Still to do: the console rig run for the LTO bench built with this triple. The rig service was down; it will be reported on PS2-194. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
[lld][ELF][Mips] Link MIPS n32 bitcode as ELF32
Some checks failed
action.yml / [lld][ELF][Mips] Link MIPS n32 bitcode as ELF32 (push) Failing after 0s
release-binaries-all.yml / [lld][ELF][Mips] Link MIPS n32 bitcode as ELF32 (push) Failing after 0s
release-binaries.yml / [lld][ELF][Mips] Link MIPS n32 bitcode as ELF32 (push) Failing after 0s
release-documentation.yml / [lld][ELF][Mips] Link MIPS n32 bitcode as ELF32 (push) Failing after 0s
release-sources.yml / [lld][ELF][Mips] Link MIPS n32 bitcode as ELF32 (push) Failing after 0s
Check for private emails used in PRs / validate_email (pull_request) Has been skipped
action.yml / [lld][ELF][Mips] Link MIPS n32 bitcode as ELF32 (pull_request) Failing after 0s
Check LLVM ABI annotations / Check LLVM_ABI annotations with ids (pull_request) Has been skipped
CI Checks / Build and Test Linux (pull_request) Has been skipped
CI Checks / Build and Test Windows (pull_request) Has been skipped
CI Checks / Compute macOS Projects (pull_request) Has been skipped
CI Checks / Build and Test macOS arm64 (pull_request) Has been skipped
release-binaries-all.yml / [lld][ELF][Mips] Link MIPS n32 bitcode as ELF32 (pull_request) Failing after 0s
release-binaries.yml / [lld][ELF][Mips] Link MIPS n32 bitcode as ELF32 (pull_request) Failing after 0s
release-documentation.yml / [lld][ELF][Mips] Link MIPS n32 bitcode as ELF32 (pull_request) Failing after 0s
release-sources.yml / [lld][ELF][Mips] Link MIPS n32 bitcode as ELF32 (pull_request) Failing after 0s
Add buildbot information to first PRs from new contributors / buildbot_comment (pull_request_target) Has been skipped
Labelling new pull requests / greeter (pull_request_target) Has been cancelled
Labelling new pull requests / automate-prs-labels (pull_request_target) Has been cancelled
fc1c20144a
lld gave any 64-bit MIPS bitcode file the ELF64 kind and never saw it as
n32, so -flto failed for n32 code with "is incompatible with". Bitcode
whose triple has an n32 environment (gnuabin32, muslabin32) is now ELF32
and passes the n32 check, against -m elf32ltsmipn32 and alongside n32
objects.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
[TargetParser][Mips] Add the mips64r5900el-ps2-elf triple
Some checks failed
action.yml / [TargetParser][Mips] Add the mips64r5900el-ps2-elf triple (push) Failing after 0s
release-binaries-all.yml / [TargetParser][Mips] Add the mips64r5900el-ps2-elf triple (push) Failing after 0s
release-binaries.yml / [TargetParser][Mips] Add the mips64r5900el-ps2-elf triple (push) Failing after 0s
release-documentation.yml / [TargetParser][Mips] Add the mips64r5900el-ps2-elf triple (push) Failing after 0s
release-sources.yml / [TargetParser][Mips] Add the mips64r5900el-ps2-elf triple (push) Failing after 0s
Check for private emails used in PRs / validate_email (pull_request) Has been skipped
action.yml / [TargetParser][Mips] Add the mips64r5900el-ps2-elf triple (pull_request) Failing after 0s
Check LLVM ABI annotations / Check LLVM_ABI annotations with ids (pull_request) Has been skipped
CI Checks / Build and Test Linux (pull_request) Has been skipped
CI Checks / Build and Test Windows (pull_request) Has been skipped
CI Checks / Compute macOS Projects (pull_request) Has been skipped
CI Checks / Build and Test macOS arm64 (pull_request) Has been skipped
release-binaries-all.yml / [TargetParser][Mips] Add the mips64r5900el-ps2-elf triple (pull_request) Failing after 0s
release-binaries.yml / [TargetParser][Mips] Add the mips64r5900el-ps2-elf triple (pull_request) Failing after 0s
release-documentation.yml / [TargetParser][Mips] Add the mips64r5900el-ps2-elf triple (pull_request) Failing after 0s
release-sources.yml / [TargetParser][Mips] Add the mips64r5900el-ps2-elf triple (pull_request) Failing after 0s
Add buildbot information to first PRs from new contributors / buildbot_comment (pull_request_target) Has been skipped
Labelling new pull requests / greeter (pull_request_target) Has been cancelled
Labelling new pull requests / automate-prs-labels (pull_request_target) Has been cancelled
ca35845b7e
The PS2 Emotion Engine toolchain is named mips64r5900el-ps2-elf, as in
GNU's configuration. LLVM now parses it: mips64r5900el is mips64el with
a new MipsSubArch_r5900, and ps2 is a new vendor. isPS2() identifies the
platform, and isABIN32() is true for it, so the triple alone selects the
n32 ABI and data layout, and lld links its LTO bitcode as n32. The
r5900 sub-architecture makes the R5900 the default CPU in the clang
driver and in the backend, so LTO code generation needs no -mcpu.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

Console rig: the sdk-core bench built with --target=mips64r5900el-ps2-elf, with and without -O2 -flto (dev toolchain with #18 and #20), passes both runs, and all 9 checksums match.

Kernel Checksum
memcpy_mmi / memcpy_libc / memcpy_loop 1c984dc5
memset_mmi a1e19dc5
packet_build 67522a17
decompress a00022b0
inflate 3f62b2bb
physics 46fb9806
raster c8cb2e87

Runs: 20261015T220417-0201 (LTO) and 20261015T220425-0202 (no LTO).

Console rig: the sdk-core bench built with `--target=mips64r5900el-ps2-elf`, with and without `-O2 -flto` (dev toolchain with #18 and #20), passes both runs, and all 9 checksums match. | Kernel | Checksum | |---|---| | memcpy_mmi / memcpy_libc / memcpy_loop | 1c984dc5 | | memset_mmi | a1e19dc5 | | packet_build | 67522a17 | | decompress | a00022b0 | | inflate | 3f62b2bb | | physics | 46fb9806 | | raster | c8cb2e87 | Runs: 20261015T220417-0201 (LTO) and 20261015T220425-0202 (no LTO).
techwritescode deleted branch ps2-triple 2026-10-15 22:08:32 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ps2/llvm!20
No description provided.