-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable f16 in assembly on aarch64 platforms that support it
Signed-off-by: rongfu.leng <lenronfu@gmail.com>
- Loading branch information
1 parent
003a902
commit a1d89bd
Showing
4 changed files
with
26 additions
and
1 deletion.
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 | ||
|
||
#![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() { | ||
f32_to_f16_asm(1.0); | ||
} |