Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add v9 and leoncasa target feature to sparc #132552

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Nov 3, 2024

This adds the following two unstable target features:

In LLVM 19, LLVM emits EM_SPARC32PLUS if the v9 feature is enabled (llvm/llvm-project@fb7f65b)
My understanding is that (some) use of the v9 feature may eventually be replaced by the v8plus feature in LLVM 20 (llvm/llvm-project@aca971d), but there is no other good way in the current LLVM 19.

cc @thejpster @glaubitz

r? workingjubilee

@rustbot label +O-SPARC +A-target-feature

Footnotes

  1. Atomic CAS instruction

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. O-SPARC Target: SPARC processors labels Nov 3, 2024
@taiki-e taiki-e changed the title Add v9 and hasleoncasa target feature to sparc Add v9 and leoncasa target feature to sparc Nov 3, 2024
@rustbot rustbot added the A-target-feature Area: Enabling/disabling target features like AVX, Neon, etc. label Nov 3, 2024
@glaubitz
Copy link
Contributor

glaubitz commented Nov 3, 2024

@koachan
Copy link

koachan commented Nov 3, 2024

I'm not very familiar with Rust, but from what I can tell it looks okay.

Also, a word on this:

My understanding is that (some) use of the v9 feature may eventually be replaced by the v8plus feature in LLVM 20 (llvm/llvm-project@aca971d), but there is no other good way in the current LLVM 19.

v8plus is a purely ABI flag, intended to signal that the G and O registers are 64-bit. It is separated in LLVM because we want to be GCC-compatible and so need to cater to a particular usecase in which V9 instructions are desired, but all registers are to be kept 32-bit (effectively banning instructions like CASXA which needs 64-bit registers to operate).
If Rust doesn't want to do this, it could always set (or delete) v9 and v8plus together...

@taiki-e
Copy link
Member Author

taiki-e commented Nov 3, 2024

v8plus is a purely ABI flag, intended to signal that the G and O registers are 64-bit. It is separated in LLVM because we want to be GCC-compatible and so need to cater to a particular usecase in which V9 instructions are desired, but all registers are to be kept 32-bit (effectively banning instructions like CASXA which needs 64-bit registers to operate). If Rust doesn't want to do this, it could always set (or delete) v9 and v8plus together...

Thanks for the clarification. I think separating v8plus from v9 is the correct behavior (eventually) for Rust as well, as we do not want the ABI to be changed by -C target-cpu (-mtune).

However, we are using LLVM 19 which ties v9 and v8plus together and need a way to fix a bug in rustc that incorrectly always uses EM_SPARC32PLUS (#130172).

In #131222 we are trying to adopt the same approach as in LLVM 19, but actually adding the v8plus feature and mapping them to the v9 feature in LLVM 19 may be a better way here. (The implementation of it is in 0849356 and even if we merge the LLVM 19's approach, we will probably need it when updating to LLVM 20.)

@bors
Copy link
Contributor

bors commented Nov 5, 2024

☔ The latest upstream changes (presumably #129884) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-target-feature Area: Enabling/disabling target features like AVX, Neon, etc. O-SPARC Target: SPARC processors S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants