forked from rust-lang/compiler-builtins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfloat_div.rs
93 lines (79 loc) · 1.98 KB
/
float_div.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
#![cfg_attr(f128_enabled, feature(f128))]
use compiler_builtins::float::div;
use criterion::{criterion_main, Criterion};
use testcrate::float_bench;
float_bench! {
name: div_f32,
sig: (a: f32, b: f32) -> f32,
crate_fn: div::__divsf3,
sys_fn: __divsf3,
sys_available: all(),
asm: [
#[cfg(target_arch = "x86_64")] {
asm!(
"divss {a}, {b}",
a = inout(xmm_reg) a,
b = in(xmm_reg) b,
options(nomem, nostack, pure)
);
a
};
#[cfg(target_arch = "aarch64")] {
asm!(
"fdiv {a:s}, {a:s}, {b:s}",
a = inout(vreg) a,
b = in(vreg) b,
options(nomem, nostack, pure)
);
a
};
],
}
float_bench! {
name: div_f64,
sig: (a: f64, b: f64) -> f64,
crate_fn: div::__divdf3,
sys_fn: __divdf3,
sys_available: all(),
asm: [
#[cfg(target_arch = "x86_64")] {
asm!(
"divsd {a}, {b}",
a = inout(xmm_reg) a,
b = in(xmm_reg) b,
options(nomem, nostack, pure)
);
a
};
#[cfg(target_arch = "aarch64")] {
asm!(
"fdiv {a:d}, {a:d}, {b:d}",
a = inout(vreg) a,
b = in(vreg) b,
options(nomem, nostack, pure)
);
a
};
],
}
#[cfg(f128_enabled)]
float_bench! {
name: div_f128,
sig: (a: f128, b: f128) -> f128,
crate_fn: div::__divtf3,
crate_fn_ppc: div::__divkf3,
sys_fn: __divtf3,
sys_fn_ppc: __divkf3,
sys_available: not(feature = "no-sys-f128"),
asm: []
}
pub fn float_div() {
let mut criterion = Criterion::default().configure_from_args();
div_f32(&mut criterion);
div_f64(&mut criterion);
#[cfg(f128_enabled)]
{
div_f128(&mut criterion);
}
}
criterion_main!(float_div);