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

aarch64 softfloat target: always pass floats in int registers #133102

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

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Nov 16, 2024

This is a part of #131058: on softfloat aarch64 targets, the float registers may be unavailable. And yet, LLVM will happily use them to pass float types if the corresponding target features are enabled. That's a problem as it means enabling/disabling neon instructions can change the ABI.

Other targets have a soft-float target feature that forces the use of the soft-float ABI no matter whether float registers are enabled or not; aarch64 has nothing like that.

So we follow the aarch64 softfloat ABI and treat floats like integers for extern "C" functions. For the "Rust" ABI, we do the same for scalars, and then just do something reasonable for ScalarPair that avoids the pointer indirection.

Cc @workingjubilee

@rustbot
Copy link
Collaborator

rustbot commented Nov 16, 2024

r? @Nadrieril

rustbot has assigned @Nadrieril.
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 Nov 16, 2024
@rust-log-analyzer

This comment has been minimized.

@RalfJung
Copy link
Member Author

Ah, we also have to do something for ScalarPair types. The easiest thing to do is pass them indirectly, so that's what I did for now.

@Nadrieril
Copy link
Member

r? compiler

@rustbot rustbot assigned wesleywiser and unassigned Nadrieril Nov 16, 2024
@workingjubilee
Copy link
Member

Isn't this the second target we are manufacturing a by-integer ABI for?

@RalfJung
Copy link
Member Author

RalfJung commented Nov 16, 2024 via email

@workingjubilee
Copy link
Member

x87 Rust ABI?

@RalfJung
Copy link
Member Author

RalfJung commented Nov 16, 2024

There we are returning floats by-ptr, I think? Ah maybe we only do that for floats larger than a ptr.

@workingjubilee
Copy link
Member

I am mostly musing that I should probably cross-check those cases to see if there's something that can be factored out before accepting this.

@RalfJung
Copy link
Member Author

For x86-32 we only do something with the return value, since arguments anyway never use the x87 stack.

But yeah we could probably use the same logic for both. I am just not sure what is the best way to share that logic.

@RalfJung
Copy link
Member Author

RalfJung commented Nov 17, 2024

OTOH we might want to change the x87 thing to use SSE registers if we can, so sharing the code might not be such a good idea.

Copy link
Member

@wesleywiser wesleywiser left a comment

Choose a reason for hiding this comment

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

Overall looks good to me, just a few comments.

compiler/rustc_target/src/callconv/aarch64.rs Outdated Show resolved Hide resolved
compiler/rustc_target/src/callconv/aarch64.rs Outdated Show resolved Hide resolved
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

I think this makes sense

@RalfJung
Copy link
Member Author

@bors r=davidtwco,wesleywiser

@bors
Copy link
Contributor

bors commented Nov 21, 2024

📌 Commit 666bcbd has been approved by davidtwco,wesleywiser

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 Nov 21, 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.

8 participants