-
-
Notifications
You must be signed in to change notification settings - Fork 15.7k
core::num::f16b Rust's 16bit Brain Float
#160859
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
base: main
Are you sure you want to change the base?
Changes from all commits
d8c7488
b3053ed
7815ae0
5557bc2
73621dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -338,6 +338,9 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { | |
| Primitive::Float(Float::F16) => { | ||
| bug!("the va_arg intrinsic does not support `f16`") | ||
| } | ||
| Primitive::Float(Float::F16B) => { | ||
| bug!("the va_arg intrinsic does not support `f16b`") | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well we could support this actually, it doesn't participate in argument promotion. Idk if it's useful. |
||
| Primitive::Float(Float::F32) => { | ||
| // c_double is actually f32 on avr. | ||
| if self.cx().sess().target.arch != Arch::Avr { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -372,6 +372,7 @@ pub(crate) fn target_config(sess: &Session) -> TargetConfig { | |||||
| internal_target_features, | ||||||
| has_reliable_f16: true, | ||||||
| has_reliable_f16_math: true, | ||||||
| has_reliable_f16b: true, | ||||||
| has_reliable_f128: true, | ||||||
| has_reliable_f128_math: true, | ||||||
| }; | ||||||
|
|
@@ -409,6 +410,21 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { | |||||
| _ => true, | ||||||
| }; | ||||||
|
|
||||||
| // The heuristic for evaluating to true is twofold, namely; | ||||||
| // | ||||||
| // 1. Can LLVM compile an IR snippet containing `fpext bfloat %<var> to float` | ||||||
| // 2. Does the documentation indicate `bf16` support, can be seen in the | ||||||
| // tracking issue; <https://github.com/rust-lang/rust/issues/160630> | ||||||
| cfg.has_reliable_f16b = match (target_arch, target_os) { | ||||||
| // This is similar to <https://github.com/llvm/llvm-project/issues/94434>, however | ||||||
| // does not work until LLVM 23 on Windows. | ||||||
| (Arch::Arm64EC, _) => major >= 23, | ||||||
| (Arch::AArch64, _) | (Arch::X86_64, _) | (Arch::RiscV64, _) | (Arch::LoongArch64, _) => { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplification nit
Suggested change
|
||||||
| true | ||||||
| } | ||||||
| _ => false, | ||||||
| }; | ||||||
|
|
||||||
| cfg.has_reliable_f128 = match (target_arch, target_os) { | ||||||
| // Unsupported https://github.com/llvm/llvm-project/issues/121122 | ||||||
| (Arch::AmdGpu, _) => false, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -543,6 +543,7 @@ symbols! { | |
| begin_panic, | ||
| bench, | ||
| bevy_ecs, | ||
| bfloat, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this actually used anymore or can it be deleted? |
||
| bikeshed, | ||
| bikeshed_guaranteed_no_drop, | ||
| bin, | ||
|
|
@@ -621,6 +622,7 @@ symbols! { | |
| cfg_target_has_atomic, | ||
| cfg_target_has_atomic_equal_alignment, | ||
| cfg_target_has_reliable_f16_f128, | ||
| cfg_target_has_reliable_f16b, | ||
| cfg_target_has_threads, | ||
| cfg_target_object_format, | ||
| cfg_target_thread_local, | ||
|
|
@@ -957,6 +959,7 @@ symbols! { | |
| external_doc, | ||
| f16, | ||
| f16_nan, | ||
| f16b, | ||
| f16c_target_feature, | ||
| f32, | ||
| f32_nan, | ||
|
|
@@ -2121,6 +2124,7 @@ symbols! { | |
| target_has_atomic_primitive_alignment, | ||
| target_has_reliable_f16, | ||
| target_has_reliable_f16_math, | ||
| target_has_reliable_f16b, | ||
| target_has_reliable_f128, | ||
| target_has_reliable_f128_math, | ||
| target_has_threads, | ||
|
|
||
|
folkertdev marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,8 @@ where | |||||||
| match float { | ||||||||
| // C does not have the f16 type | ||||||||
| Float::F16 => None, | ||||||||
| // No `f16b` type | ||||||||
| Float::F16B => unreachable!("`f16b` unsupported on mips64"), | ||||||||
|
Comment on lines
+34
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
nit but the panic message is clear enough I think |
||||||||
| Float::F32 => Some(Reg::f32()), | ||||||||
| Float::F64 => Some(Reg::f64()), | ||||||||
| Float::F128 => Some(Reg::f128()), | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.