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
use crate::*;
crate trait MulAddE {
fn mul_adde(self, y: Self, z: Self) -> Self;
}
#[cfg(not(target_arch = "s390x"))]
#[allow(improper_ctypes)]
extern "C" {
#[link_name = "llvm.fmuladd.v2f32"]
fn fmuladd_v2f32(x: f32x2, y: f32x2, z: f32x2) -> f32x2;
#[link_name = "llvm.fmuladd.v4f32"]
fn fmuladd_v4f32(x: f32x4, y: f32x4, z: f32x4) -> f32x4;
#[link_name = "llvm.fmuladd.v8f32"]
fn fmuladd_v8f32(x: f32x8, y: f32x8, z: f32x8) -> f32x8;
#[link_name = "llvm.fmuladd.v16f32"]
fn fmuladd_v16f32(x: f32x16, y: f32x16, z: f32x16) -> f32x16;
#[link_name = "llvm.fmuladd.v2f64"]
fn fmuladd_v2f64(x: f64x2, y: f64x2, z: f64x2) -> f64x2;
#[link_name = "llvm.fmuladd.v4f64"]
fn fmuladd_v4f64(x: f64x4, y: f64x4, z: f64x4) -> f64x4;
#[link_name = "llvm.fmuladd.v8f64"]
fn fmuladd_v8f64(x: f64x8, y: f64x8, z: f64x8) -> f64x8;
}
macro_rules! impl_mul_adde {
($id:ident : $fn:ident) => {
impl MulAddE for $id {
#[inline]
fn mul_adde(self, y: Self, z: Self) -> Self {
#[cfg(not(target_arch = "s390x"))]
{
use crate::mem::transmute;
unsafe { transmute($fn(transmute(self), transmute(y), transmute(z))) }
}
#[cfg(target_arch = "s390x")]
{
self * y + z
}
}
}
};
}
impl_mul_adde!(f32x2: fmuladd_v2f32);
impl_mul_adde!(f32x4: fmuladd_v4f32);
impl_mul_adde!(f32x8: fmuladd_v8f32);
impl_mul_adde!(f32x16: fmuladd_v16f32);
impl_mul_adde!(f64x2: fmuladd_v2f64);
impl_mul_adde!(f64x4: fmuladd_v4f64);
impl_mul_adde!(f64x8: fmuladd_v8f64);