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

x86-32 float return for 'Rust' ABI: treat all float types consistently #131871

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

Conversation

RalfJung
Copy link
Member

This helps with #131819: for our own ABI on x86-32, we want to never use the float registers. The previous logic only considered F32 and F64, but skipped F16 and F128. So I made the logic just apply to all float types.

@rustbot
Copy link
Collaborator

rustbot commented Oct 18, 2024

r? @cjgillot

rustbot has assigned @cjgillot.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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. labels Oct 18, 2024
@RalfJung
Copy link
Member Author

Cc @tgross35

@workingjubilee
Copy link
Member

Huh. I hadn't noticed a bunch of target-specific code has escaped rustc_target.

That will be fixed.

@workingjubilee
Copy link
Member

@RalfJung just to confirm: This winds up applying to both i586 and i686, yes?

@RalfJung
Copy link
Member Author

This winds up applying to both i586 and i686, yes?

I assume so. I didn't change that part of the logic.

@RalfJung
Copy link
Member Author

Huh. I hadn't noticed a bunch of target-specific code has escaped rustc_target.

Yeah, rustc_target does the non-Rust-ABI handling, but at some point we had to start making Rust ABI handling target-specific...

@tgross35
Copy link
Contributor

👍 for making this change

Comment on lines +706 to +708
Abi::Scalar(s) => matches!(s.primitive(), Float(_)),
Abi::ScalarPair(s1, s2) => {
matches!(s1.primitive(), Float(_)) || matches!(s2.primitive(), Float(_))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Abi::Scalar(s) => matches!(s.primitive(), Float(_)),
Abi::ScalarPair(s1, s2) => {
matches!(s1.primitive(), Float(_)) || matches!(s2.primitive(), Float(_))
Abi::Scalar(s) => matches!(s.primitive(), Float(F16 | F32 | F64)),
Abi::ScalarPair(s1, s2) => {
matches!(s1.primitive(), Float(F16 | F32 | F64)) || matches!(s2.primitive(), Float(F16 | F32 | F64))

nit: There's no need to include f128 here as the 32-bit x86 ABI already guarantees it gets passed in memory.

Copy link
Member Author

@RalfJung RalfJung Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should treat all float types uniformly here, that's more future-proof. The result is the same both ways but my code makes it more clear what happens, relying on fewer external assumptions.

We don't care about being consistent with the C ABI here, after all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I kinda agree morally with beetrees but not actually: this seems fine as-is.

I don't think it's worth spending too much time on this. While I do need to be able to read this code to refactor it, I do intend to bulldoze it.

@workingjubilee
Copy link
Member

While I do need to be able to read this code to refactor it, I do intend to bulldoze it.

And since this seems fine-ish, assuming CI doesn't find a reason to take issue with it, and I would hate to make RalfJung rebase this a bunch:

@bors r+

@bors
Copy link
Contributor

bors commented Oct 19, 2024

📌 Commit a9f6fd1 has been approved by workingjubilee

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

7 participants