Skip to content
Merged
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
8 changes: 8 additions & 0 deletions src/float/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ intrinsics! {
extend(a)
}

#[avr_skip]
#[aapcs_on_arm]
#[apple_f16_arg_abi]
#[cfg(f16_enabled)]
pub extern "C" fn __extendhfdf2(a: f16) -> f64 {
extend(a)
}

#[avr_skip]
#[aapcs_on_arm]
#[ppc_alias = __extendhfkf2]
Expand Down
3 changes: 2 additions & 1 deletion testcrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ no-sys-f128 = ["no-sys-f128-int-convert", "no-sys-f16-f128-convert"]
# Some platforms have some f128 functions but everything except integer conversions
no-sys-f128-int-convert = []
no-sys-f16-f128-convert = []
no-sys-f16-f64-convert = []
# Skip tests that rely on f16 symbols being available on the system
no-sys-f16 = []
no-sys-f16 = ["no-sys-f16-f64-convert"]

# Enable report generation without bringing in more dependencies by default
benchmarking-reports = ["criterion/plotters", "criterion/html_reports"]
Expand Down
23 changes: 23 additions & 0 deletions testcrate/benches/float_extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,28 @@ float_bench! {
],
}

#[cfg(f16_enabled)]
float_bench! {
name: extend_f16_f64,
sig: (a: f16) -> f64,
crate_fn: extend::__extendhfdf2,
sys_fn: __extendhfdf2,
sys_available: not(feature = "no-sys-f16-f64-convert"),
asm: [
#[cfg(target_arch = "aarch64")] {
let ret: f64;
asm!(
"fcvt {ret:d}, {a:h}",
a = in(vreg) a,
ret = lateout(vreg) ret,
options(nomem, nostack, pure),
);

ret
};
],
}

#[cfg(all(f16_enabled, f128_enabled))]
float_bench! {
name: extend_f16_f128,
Expand Down Expand Up @@ -93,6 +115,7 @@ pub fn float_extend() {
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
{
extend_f16_f32(&mut criterion);
extend_f16_f64(&mut criterion);

#[cfg(f128_enabled)]
extend_f16_f128(&mut criterion);
Expand Down
2 changes: 1 addition & 1 deletion testcrate/benches/float_trunc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ float_bench! {
sig: (a: f64) -> f16,
crate_fn: trunc::__truncdfhf2,
sys_fn: __truncdfhf2,
sys_available: not(feature = "no-sys-f16"),
sys_available: not(feature = "no-sys-f16-f64-convert"),
asm: [
#[cfg(target_arch = "aarch64")] {
let ret: f16;
Expand Down
11 changes: 11 additions & 0 deletions testcrate/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ enum Feature {
NoSysF128,
NoSysF128IntConvert,
NoSysF16,
NoSysF16F64Convert,
NoSysF16F128Convert,
}

Expand Down Expand Up @@ -66,16 +67,26 @@ fn main() {
|| target.arch == "wasm64"
{
features.insert(Feature::NoSysF16);
features.insert(Feature::NoSysF16F64Convert);
features.insert(Feature::NoSysF16F128Convert);
}

// These platforms are missing either `__extendhfdf2` or `__truncdfhf2`.
if target.vendor == "apple" || target.os == "windows" {
features.insert(Feature::NoSysF16F64Convert);
}

for feature in features {
let (name, warning) = match feature {
Feature::NoSysF128 => ("no-sys-f128", "using apfloat fallback for f128"),
Feature::NoSysF128IntConvert => (
"no-sys-f128-int-convert",
"using apfloat fallback for f128 <-> int conversions",
),
Feature::NoSysF16F64Convert => (
"no-sys-f16-f64-convert",
"using apfloat fallback for f16 <-> f64 conversions",
),
Feature::NoSysF16F128Convert => (
"no-sys-f16-f128-convert",
"using apfloat fallback for f16 <-> f128 conversions",
Expand Down
2 changes: 2 additions & 0 deletions testcrate/tests/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ mod extend {
extend,
f16 => f32, Half => Single, __extendhfsf2, not(feature = "no-sys-f16");
f16 => f32, Half => Single, __gnu_h2f_ieee, not(feature = "no-sys-f16");
f16 => f64, Half => Double, __extendhfdf2, not(feature = "no-sys-f16-f64-convert");
f16 => f128, Half => Quad, __extendhftf2, not(feature = "no-sys-f16-f128-convert");
f32 => f128, Single => Quad, __extendsftf2, not(feature = "no-sys-f128");
f64 => f128, Double => Quad, __extenddftf2, not(feature = "no-sys-f128");
Expand Down Expand Up @@ -340,6 +341,7 @@ mod trunc {
trunc,
f32 => f16, Single => Half, __truncsfhf2, not(feature = "no-sys-f16");
f32 => f16, Single => Half, __gnu_f2h_ieee, not(feature = "no-sys-f16");
f64 => f16, Double => Half, __truncdfhf2, not(feature = "no-sys-f16-f64-convert");
f128 => f16, Quad => Half, __trunctfhf2, not(feature = "no-sys-f16-f128-convert");
f128 => f32, Quad => Single, __trunctfsf2, not(feature = "no-sys-f128");
f128 => f64, Quad => Double, __trunctfdf2, not(feature = "no-sys-f128");
Expand Down