-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Enable f16 in assembly on aarch64 platforms that support it #127043
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//@ only-aarch64 | ||
//@ run-pass | ||
|
||
#![feature(f16, f128)] | ||
use std::arch::asm; | ||
#[inline(never)] | ||
pub fn f32_to_f16_asm(a: f32) -> f16 { | ||
let ret: f16; | ||
unsafe { | ||
asm!( | ||
"fcvt {ret:h}, {a:s}", | ||
a = in(vreg) a, | ||
ret = lateout(vreg) ret, | ||
options(nomem, nostack), | ||
); | ||
} | ||
ret | ||
} | ||
fn main() { | ||
assert_eq!(f32_to_f16_asm(1.0 as f32), 1.0); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these
neon
labels are actually getting tested, you need to addneon
in the//@ revisions:
list at the top and make sure--cfg neon
gets passed for at least one of the tests (likerust/tests/assembly/asm/arm-types.rs
Lines 1 to 7 in 2495953
I'm not sure what combinations it makes sense to test, there's also a
fp16
target feature. Cc @workingjubilee since you did some work on neon and flagsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
neon
target feature is enabled by default onaarch64-unknown-linux-gnu
andarm64ec-pc-windows-msvc
, so there's no need to have any cfg unless it's been explicitly disabled.However, once the
cfg
is removed there might be compilation failures onarm64ec-pc-windows-msvc
due to llvm/llvm-project#94434, in which case the options are to either change thecheck!
macro to not pass/returnf16
by value or justcfg(aarch64)
thef16
test cases and leave aFIXME(f16_f128)
comment.