1
1
#![ cfg_attr( feature = "as_crate" , no_std) ] // We are std!
2
2
#![ cfg_attr(
3
3
feature = "as_crate" ,
4
- feature( platform_intrinsics ) ,
4
+ feature( core_intrinsics ) ,
5
5
feature( portable_simd) ,
6
6
allow( internal_features)
7
7
) ]
@@ -10,6 +10,8 @@ use core::simd;
10
10
#[ cfg( feature = "as_crate" ) ]
11
11
use core_simd:: simd;
12
12
13
+ use core:: intrinsics:: simd as intrinsics;
14
+
13
15
use simd:: { LaneCount , Simd , SupportedLaneCount } ;
14
16
15
17
#[ cfg( feature = "as_crate" ) ]
@@ -22,28 +24,6 @@ use experimental as sealed;
22
24
23
25
use crate :: sealed:: Sealed ;
24
26
25
- // "platform intrinsics" are essentially "codegen intrinsics"
26
- // each of these may be scalarized and lowered to a libm call
27
- extern "platform-intrinsic" {
28
- // ceil
29
- fn simd_ceil < T > ( x : T ) -> T ;
30
-
31
- // floor
32
- fn simd_floor < T > ( x : T ) -> T ;
33
-
34
- // round
35
- fn simd_round < T > ( x : T ) -> T ;
36
-
37
- // trunc
38
- fn simd_trunc < T > ( x : T ) -> T ;
39
-
40
- // fsqrt
41
- fn simd_fsqrt < T > ( x : T ) -> T ;
42
-
43
- // fma
44
- fn simd_fma < T > ( x : T , y : T , z : T ) -> T ;
45
- }
46
-
47
27
/// This trait provides a possibly-temporary implementation of float functions
48
28
/// that may, in the absence of hardware support, canonicalize to calling an
49
29
/// operating system's `math.h` dynamically-loaded library (also known as a
@@ -74,43 +54,43 @@ pub trait StdFloat: Sealed + Sized {
74
54
#[ inline]
75
55
#[ must_use = "method returns a new vector and does not mutate the original value" ]
76
56
fn mul_add ( self , a : Self , b : Self ) -> Self {
77
- unsafe { simd_fma ( self , a, b) }
57
+ unsafe { intrinsics :: simd_fma ( self , a, b) }
78
58
}
79
59
80
60
/// Produces a vector where every lane has the square root value
81
61
/// of the equivalently-indexed lane in `self`
82
62
#[ inline]
83
63
#[ must_use = "method returns a new vector and does not mutate the original value" ]
84
64
fn sqrt ( self ) -> Self {
85
- unsafe { simd_fsqrt ( self ) }
65
+ unsafe { intrinsics :: simd_fsqrt ( self ) }
86
66
}
87
67
88
68
/// Returns the smallest integer greater than or equal to each lane.
89
69
#[ must_use = "method returns a new vector and does not mutate the original value" ]
90
70
#[ inline]
91
71
fn ceil ( self ) -> Self {
92
- unsafe { simd_ceil ( self ) }
72
+ unsafe { intrinsics :: simd_ceil ( self ) }
93
73
}
94
74
95
75
/// Returns the largest integer value less than or equal to each lane.
96
76
#[ must_use = "method returns a new vector and does not mutate the original value" ]
97
77
#[ inline]
98
78
fn floor ( self ) -> Self {
99
- unsafe { simd_floor ( self ) }
79
+ unsafe { intrinsics :: simd_floor ( self ) }
100
80
}
101
81
102
82
/// Rounds to the nearest integer value. Ties round toward zero.
103
83
#[ must_use = "method returns a new vector and does not mutate the original value" ]
104
84
#[ inline]
105
85
fn round ( self ) -> Self {
106
- unsafe { simd_round ( self ) }
86
+ unsafe { intrinsics :: simd_round ( self ) }
107
87
}
108
88
109
89
/// Returns the floating point's integer value, with its fractional part removed.
110
90
#[ must_use = "method returns a new vector and does not mutate the original value" ]
111
91
#[ inline]
112
92
fn trunc ( self ) -> Self {
113
- unsafe { simd_trunc ( self ) }
93
+ unsafe { intrinsics :: simd_trunc ( self ) }
114
94
}
115
95
116
96
/// Returns the floating point's fractional value, with its integer part removed.
0 commit comments