Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_abi/src/layout/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
| Primitive::Float(Float::F16 | Float::F32 | Float::F64 | Float::F128) => {
Some(primitive)
}
Primitive::Pointer(..) => None,
Primitive::Pointer(..) | Primitive::Float(Float::F16B) => None,
}
} else {
None
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,10 @@ impl Integer {
#[cfg_attr(feature = "nightly", derive(StableHash))]
pub enum Float {
F16,
/// `f16b`. This is not a builtin type in Rust (it is exposed as a lang item),
/// but it is a builtin type in LLVM so needs to be explicitly represented
/// in the backend.
F16B,
Comment thread
Jamesbarford marked this conversation as resolved.
F32,
F64,
F128,
Expand All @@ -1415,6 +1419,7 @@ impl Float {

match self {
F16 => Size::from_bits(16),
F16B => Size::from_bits(16),
F32 => Size::from_bits(32),
F64 => Size::from_bits(64),
F128 => Size::from_bits(128),
Expand All @@ -1426,7 +1431,7 @@ impl Float {
let dl = cx.data_layout();

AbiAlign::new(match self {
F16 => dl.f16_align,
F16 | F16B => dl.f16_align,
F32 => dl.f32_align,
F64 => dl.f64_align,
F128 => dl.f128_align,
Expand All @@ -1438,6 +1443,7 @@ impl Float {

match self {
F16 => "f16",
F16B => "f16b",
F32 => "f32",
F64 => "f64",
F128 => "f128",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_attr_ir/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ language_item_table! {
PartialEq, sym::eq, eq_trait, Target::Trait, GenericRequirement::Exact(1);
PartialOrd, sym::partial_ord, partial_ord_trait, Target::Trait, GenericRequirement::Exact(1);
CVoid, sym::c_void, c_void, Target::Enum, GenericRequirement::None;
F16B, sym::f16b, f16b, Target::Struct, GenericRequirement::Exact(0);

Type, sym::type_info, type_struct, Target::Struct, GenericRequirement::None;
TypeGeneric, sym::type_info_generic, type_generic, Target::Enum, GenericRequirement::None;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_cranelift/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub(crate) fn scalar_to_clif_type(tcx: TyCtxt<'_>, scalar: Scalar) -> Type {
},
Primitive::Float(float) => match float {
Float::F16 => types::F16,
Float::F16B => bug!("f16b is not supported by the Cranelift codegen backend"),
Float::F32 => types::F32,
Float::F64 => types::F64,
Float::F128 => types::F128,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_cranelift/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
// available in Cranelift.
has_reliable_f16: has_reliable_f16_f128,
has_reliable_f16_math: has_reliable_f16_f128,
has_reliable_f16b: false,
has_reliable_f128: has_reliable_f16_f128,
has_reliable_f128_math,
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_gcc/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ pub fn compile_codegen_unit(
// -fsyntax-only), forbid the compilation when get_target_info() is called on a
// context.
let f16_type_supported = target_info.supports_target_dependent_type(CType::Float16);
let f16b_type_supported = target_info.supports_target_dependent_type(CType::BFloat16);
let f32_type_supported = target_info.supports_target_dependent_type(CType::Float32);
let f64_type_supported = target_info.supports_target_dependent_type(CType::Float64);
let f128_type_supported = target_info.supports_target_dependent_type(CType::Float128);
Expand All @@ -225,6 +226,7 @@ pub fn compile_codegen_unit(
tcx,
u128_type_supported,
f16_type_supported,
f16b_type_supported,
f32_type_supported,
f64_type_supported,
f128_type_supported,
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_gcc/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub struct CodegenCx<'gcc, 'tcx> {

pub supports_128bit_integers: bool,
pub supports_f16_type: bool,
pub supports_f16b_type: bool,
pub supports_f32_type: bool,
pub supports_f64_type: bool,
pub supports_f128_type: bool,
Expand Down Expand Up @@ -141,6 +142,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
tcx: TyCtxt<'tcx>,
supports_128bit_integers: bool,
supports_f16_type: bool,
supports_f16b_type: bool,
supports_f32_type: bool,
supports_f64_type: bool,
supports_f128_type: bool,
Expand Down Expand Up @@ -277,6 +279,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {

supports_128bit_integers,
supports_f16_type,
supports_f16b_type,
supports_f32_type,
supports_f64_type,
supports_f128_type,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_gcc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,13 +553,15 @@ fn target_config(sess: &Session, target_info: &LockedTargetInfo) -> TargetConfig
);

let has_reliable_f16 = target_info.supports_target_dependent_type(CType::Float16);
let has_reliable_f16b = target_info.supports_target_dependent_type(CType::BFloat16);
let has_reliable_f128 = target_info.supports_target_dependent_type(CType::Float128);

TargetConfig {
internal_target_features,
// There are no known bugs with GCC support for f16 or f128
has_reliable_f16,
has_reliable_f16_math: has_reliable_f16,
has_reliable_f16b,
has_reliable_f128,
has_reliable_f128_math: has_reliable_f128,
}
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_codegen_gcc/src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ impl<'gcc, 'tcx> BaseTypeCodegenMethods for CodegenCx<'gcc, 'tcx> {
bug!("unsupported float width 16")
}

fn type_f16b(&self) -> Type<'gcc> {
#[cfg(feature = "master")]
if self.supports_f16b_type {
return self.context.new_c_type(CType::BFloat16);
}
bug!("unsupported type bfloat16")
}

fn type_f32(&self) -> Type<'gcc> {
#[cfg(feature = "master")]
if self.supports_f32_type {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ impl LlvmType for Reg {
},
Primitive::Float(float) => match float {
Float::F16 => cx.type_f16(),
Float::F16B => cx.type_f16b(),
Float::F32 => cx.type_f32(),
Float::F64 => cx.type_f64(),
Float::F128 => cx.type_f128(),
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,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`")
}

@folkertdev folkertdev Aug 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

View changes since the review

Primitive::Float(Float::F32) => {
// c_double is actually f32 on avr.
if self.cx().sess().target.arch != Arch::Avr {
Expand Down
16 changes: 16 additions & 0 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,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,
};
Expand Down Expand Up @@ -390,6 +391,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, _) => {
major >= 21

@nikic nikic Aug 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't LLVM 21 the minimum version anyway?

View changes since the review

}
_ => false,
};

cfg.has_reliable_f128 = match (target_arch, target_os) {
// Unsupported https://github.com/llvm/llvm-project/issues/121122
(Arch::AmdGpu, _) => false,
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_llvm/src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ impl<'ll, CX: Borrow<SCx<'ll>>> BaseTypeCodegenMethods for GenericCx<'ll, CX> {
unsafe { llvm::LLVMHalfTypeInContext(self.llcx()) }
}

fn type_f16b(&self) -> &'ll Type {
unsafe { llvm::LLVMBFloatTypeInContext(self.llcx()) }
}

fn type_f32(&self) -> &'ll Type {
unsafe { llvm::LLVMFloatTypeInContext(self.llcx()) }
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/va_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn get_param_type_alignment<'ll, 'tcx>(
Integer::I128 => return Align::EIGHT,
},
Primitive::Float(float) => match float {
Float::F16 | Float::F32 => unreachable!(),
Float::F16 | Float::F16B | Float::F32 => unreachable!(),
Float::F64 => { /* fall through */ }
Float::F128 => return Align::from_bytes(16).unwrap(),
},
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ pub struct TargetConfig {
pub has_reliable_f16: bool,
/// Option for `cfg(target_has_reliable_f16_math)`, true if `f16` math calls work.
pub has_reliable_f16_math: bool,
/// Option for `cfg(target_has_reliable_f16b)`, presently true if both the ABI
/// and LLVM version supports `f16b`.
pub has_reliable_f16b: bool,
Comment thread
folkertdev marked this conversation as resolved.
/// Option for `cfg(target_has_reliable_f128)`, true if `f128` basic arithmetic works.
pub has_reliable_f128: bool,
/// Option for `cfg(target_has_reliable_f128_math)`, true if `f128` math calls work.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ fn wasm_primitive(primitive: Primitive, ptr_type: &'static str) -> &'static str
Integer::I128 => "i64, i64",
},
Primitive::Float(float) => match float {
Float::F16B => bug!("`f16b` unsupported on wasm"),
Float::F16 | Float::F32 => "f32",
Float::F64 => "f64",
Float::F128 => "i64, i64",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/traits/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub trait CodegenBackend {
// support the float types, rather than accidentally quietly skipping all tests.
has_reliable_f16: true,
has_reliable_f16_math: true,
has_reliable_f16b: true,
has_reliable_f128: true,
has_reliable_f128_math: true,
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_ssa/src/traits/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub trait BaseTypeCodegenMethods: BackendTypes {
fn type_isize(&self) -> Self::Type;

fn type_f16(&self) -> Self::Type;
fn type_f16b(&self) -> Self::Type;
fn type_f32(&self) -> Self::Type;
fn type_f64(&self) -> Self::Type;
fn type_f128(&self) -> Self::Type;
Expand Down Expand Up @@ -67,6 +68,7 @@ pub trait DerivedTypeCodegenMethods<'tcx>:
use Float::*;
match f {
F16 => self.type_f16(),
F16B => self.type_f16b(),
F32 => self.type_f32(),
F64 => self.type_f64(),
F128 => self.type_f128(),
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ const GATED_CFGS: &[GatedCfg] = &[
sym::cfg_target_has_reliable_f16_f128,
Features::cfg_target_has_reliable_f16_f128,
),
(
sym::target_has_reliable_f16b,
sym::cfg_target_has_reliable_f16b,
Features::cfg_target_has_reliable_f16b,
),
(
sym::target_has_reliable_f128,
sym::cfg_target_has_reliable_f16_f128,
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ declare_features! (
(unstable, anonymous_lifetime_in_impl_trait, "1.63.0", None),
/// Allows checking whether or not the backend correctly supports unstable float types.
(internal, cfg_target_has_reliable_f16_f128, "1.88.0", None),
/// Allows checking whether or not the backend correctly supports the unstable `f16b` type.
(internal, cfg_target_has_reliable_f16b, "CURRENT_RUSTC_VERSION", None),
/// Allows checking whether or not the target might have thread support.
(internal, cfg_target_has_threads, "CURRENT_RUSTC_VERSION", None),
/// Allows identifying the `compiler_builtins` crate.
Expand Down Expand Up @@ -545,6 +547,8 @@ declare_features! (
(unstable, f128, "1.78.0", Some(116909)),
/// Allow using 16-bit (half precision) floating point numbers.
(unstable, f16, "1.78.0", Some(116909)),
/// Allow using bfloat16 floating point numbers.
(unstable, f16b, "CURRENT_RUSTC_VERSION", Some(160630)),
/// Allows the use of `#[ffi_const]` on foreign functions.
(unstable, ffi_const, "1.45.0", Some(58328)),
/// Allows the use of `#[ffi_pure]` on foreign functions.
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,8 @@ fn check_scalable_vector(tcx: TyCtxt<'_>, span: Span, def_id: LocalDefId, scalab
// bools
match element_ty.kind() {
ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Bool => (),
// We need to treat a `bfloat` (`f16b`) as a primitive scalar
ty::Adt(def, _) if tcx.is_lang_item(def.did(), LangItem::F16B) => (),
_ => {
let mut err = tcx.dcx().struct_span_err(
span,
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_interface/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ pub(crate) fn add_configuration(
if tf_cfg.has_reliable_f16_math {
cfg.insert((sym::target_has_reliable_f16_math, None));
}
if tf_cfg.has_reliable_f16b {
cfg.insert((sym::target_has_reliable_f16b, None));
}
if tf_cfg.has_reliable_f128 {
cfg.insert((sym::target_has_reliable_f128, None));
}
Expand Down Expand Up @@ -401,6 +404,7 @@ impl CodegenBackend for DummyCodegenBackend {
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,
}
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ impl abi::Float {
use abi::Float::*;
match *self {
F16 => tcx.types.f16,
F16B => Ty::new_adt(
tcx,
tcx.adt_def(tcx.require_lang_item(LangItem::F16B, DUMMY_SP)),
ty::List::empty(),
),
F32 => tcx.types.f32,
F64 => tcx.types.f64,
F128 => tcx.types.f128,
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_public/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ pub enum IntegerLength {
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize)]
pub enum FloatLength {
F16,
F16B,
F32,
F64,
F128,
Expand All @@ -373,7 +374,7 @@ impl IntegerLength {
impl FloatLength {
pub fn bits(self) -> usize {
match self {
FloatLength::F16 => 16,
FloatLength::F16 | FloatLength::F16B => 16,
FloatLength::F32 => 32,
FloatLength::F64 => 64,
FloatLength::F128 => 128,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_public/src/unstable/convert/stable/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::Float {
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
match self {
rustc_abi::Float::F16 => FloatLength::F16,
rustc_abi::Float::F16B => FloatLength::F16B,
rustc_abi::Float::F32 => FloatLength::F32,
rustc_abi::Float::F64 => FloatLength::F64,
rustc_abi::Float::F128 => FloatLength::F128,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_session/src/config/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ pub(crate) fn disallow_cfgs(sess: &Session, user_cfgs: &Cfg) {
| (sym::target_has_atomic_load_store, Some(_))
| (sym::target_has_reliable_f16, None | Some(_))
| (sym::target_has_reliable_f16_math, None | Some(_))
| (sym::target_has_reliable_f16b, None | Some(_))
| (sym::target_has_reliable_f128, None | Some(_))
| (sym::target_has_reliable_f128_math, None | Some(_))
| (sym::target_thread_local, None) => disallow(cfg, "--target"),
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ symbols! {
begin_panic,
bench,
bevy_ecs,
bfloat,
bikeshed,
bikeshed_guaranteed_no_drop,
bin,
Expand Down Expand Up @@ -599,6 +600,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,
Expand Down Expand Up @@ -944,6 +946,7 @@ symbols! {
external_doc,
f16,
f16_nan,
f16b,
f16c_target_feature,
f32,
f32_nan,
Expand Down Expand Up @@ -2106,6 +2109,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,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_target/src/callconv/mips64.rs

@bjorn3 bjorn3 Aug 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the calling convention of other targets?

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe only these files were changed because they have an exhaustive match on Float.

However, my version of abi-cafe found two interesting failures: GCC and Clang are inconsistent on aarch64 and armv7

// callee, compiled with GCC 12
#include <inttypes.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>

typedef struct Many1 {
    __bf16 f0;
} Many1;

void struct_in_1(Many1 arg0) {
    printf("%d", arg0.f0);
}
// caller, compiled with clang 23
#include <inttypes.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>

typedef struct Many1 {
    __bf16 f0;
} Many1;

void struct_in_1(Many1 arg0);

void do_test(void) {
    {
        Many1 arg0 = { .f0 = (((union { uint16_t bits; __bf16 value; }){ .bits = 49600 }).value) };

        printf("%d", arg0.f0);
        struct_in_1(arg0);

    }
}

hits

    func struct_in_1's values differed
      values (native-endian hex bytes):
        expect: C0 C1
        caller: C0 C1
        callee: 04 00
      the value was arg0.f0: rustarithmeticty(f16b)
      whose arg was arg0: Many1

The current Rust implementation matches clang, and is hence incompatible with GCC


armv7 with hardware floats also runs into incompatibilities

[target.armv7-unknown-linux-gnueabihf."f16::conv_c::repr_c::clang-nightly_calls_distro-gcc"]
busted = "check"

[target.armv7-unknown-linux-gnueabihf."f16::conv_c::repr_c::distro-gcc_calls_clang-nightly"]
busted = "check"

[target.armv7-unknown-linux-gnueabihf."f16b::conv_c::repr_c::clang-nightly_calls_distro-gcc"]
busted = "check"

[target.armv7-unknown-linux-gnueabihf."f16b::conv_c::repr_c::distro-gcc_calls_clang-nightly"]
busted = "check"

Finally, you can let this ICE on many targets, e.g. mips, powerpc, s390x, sparc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can also (e.g. on loongarch64 https://godbolt.org/z/Y3hdhG4e6) emit a __truncsfbf2 libcall that is not provided (probably needs to be added to compiler-builtins).


I think the ICEs are probably a blocker? That needs a mechanism similar to has_reliable_f128.

@Jamesbarford Jamesbarford Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes I added it because of the exhaustive match statement in mips64.rs and sparc64.rs I've removed it; 40d3f6e and put in a panic!(...).

With regard to has_reliable_f128, are you envisaging a has_reliable_f16b entry on TargetConfig?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With regard to has_reliable_f128, are you envisaging a has_reliable_f16b entry on TargetConfig?

Exactly

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's your take on those ABI mismatches? We should track that somewhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not particularly certain what mips64 should do.

It doesn't, at least to my knowledge, have hardware support. Given we aren't implementing scalar arithmetic and an f16b can only be created through a bit pattern or vendor intrinsics, I can't immediately see a practical application? Hence a panic! seems like a pragmatic choice for the time being.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No comment on whether this is the right approach, but always use span_bug! or at least bug! where possible in the compiler, rather than panic. It gives much more useful info.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can't use those custom macros in rustc_target because they are defined in rustc_middle, and that crate depends on rustc_target.

@Jamesbarford Jamesbarford Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It doesn't seem possible to use in compiler/rustc_target, however elsewhere I have strived to use it when available.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ where
match float {
// C does not have the f16 type
Float::F16 => None,
// No `f16b` type
Float::F16B => panic!("`f16b` unsupported on mips64"),
Float::F32 => Some(Reg::f32()),
Float::F64 => Some(Reg::f64()),
Float::F128 => Some(Reg::f128()),
Expand Down
Loading
Loading