-
Notifications
You must be signed in to change notification settings - Fork 214
/
Copy pathfloat_extend.rs
104 lines (93 loc) · 2.52 KB
/
float_extend.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#![allow(unused_variables)] // "unused" f16 registers
#![feature(f128)]
#![feature(f16)]
use compiler_builtins::float::extend;
use criterion::{criterion_group, criterion_main, Criterion};
use testcrate::float_bench;
float_bench! {
name: extend_f16_f32,
sig: (a: f16) -> f32,
crate_fn: extend::__extendhfsf2,
sys_fn: __extendhfsf2,
sys_available: not(feature = "no-sys-f16"),
asm: [
#[cfg(target_arch = "aarch64")] {
// FIXME(f16_f128): remove `to_bits()` after f16 asm support (rust-lang/rust/#116909)
let ret: f32;
asm!(
"fcvt {ret:s}, {a:h}",
a = in(vreg) a.to_bits(),
ret = lateout(vreg) ret,
options(nomem, nostack, pure),
);
ret
};
],
}
float_bench! {
name: extend_f16_f128,
sig: (a: f16) -> f128,
crate_fn: extend::__extendhftf2,
crate_fn_ppc: extend::__extendhfkf2,
sys_fn: __extendhftf2,
sys_fn_ppc: __extendhfkf2,
sys_available: not(feature = "no-sys-f16-f128-convert"),
asm: [],
}
float_bench! {
name: extend_f32_f64,
sig: (a: f32) -> f64,
crate_fn: extend::__extendsfdf2,
sys_fn: __extendsfdf2,
sys_available: all(),
asm: [
#[cfg(target_arch = "aarch64")] {
let ret: f64;
asm!(
"fcvt {ret:d}, {a:s}",
a = in(vreg) a,
ret = lateout(vreg) ret,
options(nomem, nostack, pure),
);
ret
};
],
}
float_bench! {
name: extend_f32_f128,
sig: (a: f32) -> f128,
crate_fn: extend::__extendsftf2,
crate_fn_ppc: extend::__extendsfkf2,
sys_fn: __extendsftf2,
sys_fn_ppc: __extendsfkf2,
sys_available: not(feature = "no-sys-f128"),
asm: [],
}
float_bench! {
name: extend_f64_f128,
sig: (a: f64) -> f128,
crate_fn: extend::__extenddftf2,
crate_fn_ppc: extend::__extenddfkf2,
sys_fn: __extenddftf2,
sys_fn_ppc: __extenddfkf2,
sys_available: not(feature = "no-sys-f128"),
asm: [],
}
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
criterion_group!(
float_extend,
extend_f16_f32,
extend_f16_f128,
extend_f32_f64,
extend_f32_f128,
extend_f64_f128,
);
// FIXME(#655): `f16` tests disabled until we can bootstrap symbols
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
criterion_group!(
float_extend,
extend_f32_f64,
extend_f32_f128,
extend_f64_f128,
);
criterion_main!(float_extend);