Skip to content

Commit b7b9310

Browse files
committed
Add a test config for __gnu_h2f_ieee and __gnu_f2h_ieee
Some targets do not provide these symbols since they always use __extendhfsf and __truncsfhf. Add a configuration option for this.
1 parent 94a8f2e commit b7b9310

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

testcrate/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ no-sys-f128 = ["no-sys-f128-int-convert", "no-sys-f16-f128-convert"]
4444
no-sys-f128-int-convert = []
4545
no-sys-f16-f128-convert = []
4646
no-sys-f16-f64-convert = []
47+
no-sys-f16-gnu-convert = []
4748
# Skip tests that rely on f16 symbols being available on the system
48-
no-sys-f16 = ["no-sys-f16-f64-convert"]
49+
no-sys-f16 = ["no-sys-f16-f64-convert", "no-sys-f16-gnu-convert"]
4950

5051
# Enable report generation without bringing in more dependencies by default
5152
benchmarking-reports = ["criterion/plotters", "criterion/html_reports"]

testcrate/build.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,23 @@ enum Feature {
1212
NoSysF16,
1313
NoSysF16F64Convert,
1414
NoSysF16F128Convert,
15+
NoSysF16GnuConvert,
1516
}
1617

1718
impl Feature {
1819
fn implies(self) -> &'static [Self] {
1920
match self {
2021
Self::NoSysF128 => [Self::NoSysF128IntConvert, Self::NoSysF16F128Convert].as_slice(),
2122
Self::NoSysF128IntConvert => [].as_slice(),
22-
Self::NoSysF16 => [Self::NoSysF16F64Convert, Self::NoSysF16F128Convert].as_slice(),
23+
Self::NoSysF16 => [
24+
Self::NoSysF16F64Convert,
25+
Self::NoSysF16F128Convert,
26+
Feature::NoSysF16GnuConvert,
27+
]
28+
.as_slice(),
2329
Self::NoSysF16F64Convert => [].as_slice(),
2430
Self::NoSysF16F128Convert => [].as_slice(),
31+
Self::NoSysF16GnuConvert => [].as_slice(),
2532
}
2633
}
2734
}
@@ -84,6 +91,11 @@ fn main() {
8491
features.insert(Feature::NoSysF16F64Convert);
8592
}
8693

94+
// These platforms do not have `__gnu_f2h_ieee` or `__gnu_h2f_ieee`.
95+
if false {
96+
features.insert(Feature::NoSysF16GnuConvert);
97+
}
98+
8799
// Add implied features. Collection is required for borrows.
88100
features.extend(
89101
features
@@ -108,6 +120,10 @@ fn main() {
108120
"no-sys-f16-f128-convert",
109121
"using apfloat fallback for f16 <-> f128 conversions",
110122
),
123+
Feature::NoSysF16GnuConvert => (
124+
"no-sys-f16-gnu-convert",
125+
"using apfloat fallback for __gnu f16",
126+
),
111127
Feature::NoSysF16 => ("no-sys-f16", "using apfloat fallback for f16"),
112128
};
113129
println!("cargo:warning={warning}");

testcrate/tests/conv.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ mod extend {
310310
f_to_f! {
311311
extend,
312312
f16 => f32, Half => Single, __extendhfsf2, not(feature = "no-sys-f16");
313-
f16 => f32, Half => Single, __gnu_h2f_ieee, not(feature = "no-sys-f16");
313+
f16 => f32, Half => Single, __gnu_h2f_ieee, not(feature = "no-sys-f16-gnu-convert");
314314
f16 => f64, Half => Double, __extendhfdf2, not(feature = "no-sys-f16-f64-convert");
315315
f16 => f128, Half => Quad, __extendhftf2, not(feature = "no-sys-f16-f128-convert");
316316
f32 => f128, Single => Quad, __extendsftf2, not(feature = "no-sys-f128");
@@ -340,7 +340,7 @@ mod trunc {
340340
f_to_f! {
341341
trunc,
342342
f32 => f16, Single => Half, __truncsfhf2, not(feature = "no-sys-f16");
343-
f32 => f16, Single => Half, __gnu_f2h_ieee, not(feature = "no-sys-f16");
343+
f32 => f16, Single => Half, __gnu_f2h_ieee, not(feature = "no-sys-f16-gnu-convert");
344344
f64 => f16, Double => Half, __truncdfhf2, not(feature = "no-sys-f16-f64-convert");
345345
f128 => f16, Quad => Half, __trunctfhf2, not(feature = "no-sys-f16-f128-convert");
346346
f128 => f32, Quad => Single, __trunctfsf2, not(feature = "no-sys-f128");

0 commit comments

Comments
 (0)