|
1 | 1 | macro_rules! implement {
|
2 | 2 | {
|
3 | 3 | impl $type:ident {
|
4 |
| - int_type = $int_type:ident, |
5 |
| - floor = $floor_intrinsic:literal, |
6 |
| - ceil = $ceil_intrinsic:literal, |
7 |
| - round = $round_intrinsic:literal, |
8 |
| - trunc = $trunc_intrinsic:literal, |
| 4 | + int_type = $int_type:ident |
9 | 5 | }
|
10 | 6 | } => {
|
11 | 7 | mod $type {
|
12 |
| - #[allow(improper_ctypes)] |
13 |
| - extern "C" { |
14 |
| - #[link_name = $floor_intrinsic] |
15 |
| - fn floor_intrinsic(x: crate::$type) -> crate::$type; |
16 |
| - #[link_name = $ceil_intrinsic] |
17 |
| - fn ceil_intrinsic(x: crate::$type) -> crate::$type; |
18 |
| - #[link_name = $round_intrinsic] |
19 |
| - fn round_intrinsic(x: crate::$type) -> crate::$type; |
20 |
| - #[link_name = $trunc_intrinsic] |
21 |
| - fn trunc_intrinsic(x: crate::$type) -> crate::$type; |
22 |
| - } |
23 |
| - |
24 | 8 | impl crate::$type {
|
25 | 9 | /// Returns the largest integer less than or equal to each lane.
|
26 | 10 | #[must_use = "method returns a new vector and does not mutate the original value"]
|
27 | 11 | #[inline]
|
28 | 12 | pub fn floor(self) -> Self {
|
29 |
| - unsafe { floor_intrinsic(self) } |
| 13 | + unsafe { crate::intrinsics::simd_floor(self) } |
30 | 14 | }
|
31 | 15 |
|
32 | 16 | /// Returns the smallest integer greater than or equal to each lane.
|
33 | 17 | #[must_use = "method returns a new vector and does not mutate the original value"]
|
34 | 18 | #[inline]
|
35 | 19 | pub fn ceil(self) -> Self {
|
36 |
| - unsafe { ceil_intrinsic(self) } |
37 |
| - } |
38 |
| - |
39 |
| - /// Returns the nearest integer to each lane. Round half-way cases away from 0.0. |
40 |
| - #[must_use = "method returns a new vector and does not mutate the original value"] |
41 |
| - #[inline] |
42 |
| - pub fn round(self) -> Self { |
43 |
| - unsafe { round_intrinsic(self) } |
44 |
| - } |
45 |
| - |
46 |
| - /// Returns the integer part of each lane. |
47 |
| - #[must_use = "method returns a new vector and does not mutate the original value"] |
48 |
| - #[inline] |
49 |
| - pub fn trunc(self) -> Self { |
50 |
| - unsafe { trunc_intrinsic(self) } |
51 |
| - } |
52 |
| - |
53 |
| - /// Returns the fractional part of each lane. |
54 |
| - #[must_use = "method returns a new vector and does not mutate the original value"] |
55 |
| - #[inline] |
56 |
| - pub fn fract(self) -> Self { |
57 |
| - self - self.trunc() |
| 20 | + unsafe { crate::intrinsics::simd_ceil(self) } |
58 | 21 | }
|
59 | 22 |
|
60 | 23 | /// Rounds toward zero and converts to the same-width integer type, assuming that
|
@@ -84,70 +47,42 @@ macro_rules! implement {
|
84 | 47 |
|
85 | 48 | implement! {
|
86 | 49 | impl f32x2 {
|
87 |
| - int_type = i32x2, |
88 |
| - floor = "llvm.floor.v2f32", |
89 |
| - ceil = "llvm.ceil.v2f32", |
90 |
| - round = "llvm.round.v2f32", |
91 |
| - trunc = "llvm.trunc.v2f32", |
| 50 | + int_type = i32x2 |
92 | 51 | }
|
93 | 52 | }
|
94 | 53 |
|
95 | 54 | implement! {
|
96 | 55 | impl f32x4 {
|
97 |
| - int_type = i32x4, |
98 |
| - floor = "llvm.floor.v4f32", |
99 |
| - ceil = "llvm.ceil.v4f32", |
100 |
| - round = "llvm.round.v4f32", |
101 |
| - trunc = "llvm.trunc.v4f32", |
| 56 | + int_type = i32x4 |
102 | 57 | }
|
103 | 58 | }
|
104 | 59 |
|
105 | 60 | implement! {
|
106 | 61 | impl f32x8 {
|
107 |
| - int_type = i32x8, |
108 |
| - floor = "llvm.floor.v8f32", |
109 |
| - ceil = "llvm.ceil.v8f32", |
110 |
| - round = "llvm.round.v8f32", |
111 |
| - trunc = "llvm.trunc.v8f32", |
| 62 | + int_type = i32x8 |
112 | 63 | }
|
113 | 64 | }
|
114 | 65 |
|
115 | 66 | implement! {
|
116 | 67 | impl f32x16 {
|
117 |
| - int_type = i32x16, |
118 |
| - floor = "llvm.floor.v16f32", |
119 |
| - ceil = "llvm.ceil.v16f32", |
120 |
| - round = "llvm.round.v16f32", |
121 |
| - trunc = "llvm.trunc.v16f32", |
| 68 | + int_type = i32x16 |
122 | 69 | }
|
123 | 70 | }
|
124 | 71 |
|
125 | 72 | implement! {
|
126 | 73 | impl f64x2 {
|
127 |
| - int_type = i64x2, |
128 |
| - floor = "llvm.floor.v2f64", |
129 |
| - ceil = "llvm.ceil.v2f64", |
130 |
| - round = "llvm.round.v2f64", |
131 |
| - trunc = "llvm.trunc.v2f64", |
| 74 | + int_type = i64x2 |
132 | 75 | }
|
133 | 76 | }
|
134 | 77 |
|
135 | 78 | implement! {
|
136 | 79 | impl f64x4 {
|
137 |
| - int_type = i64x4, |
138 |
| - floor = "llvm.floor.v4f64", |
139 |
| - ceil = "llvm.ceil.v4f64", |
140 |
| - round = "llvm.round.v4f64", |
141 |
| - trunc = "llvm.trunc.v4f64", |
| 80 | + int_type = i64x4 |
142 | 81 | }
|
143 | 82 | }
|
144 | 83 |
|
145 | 84 | implement! {
|
146 | 85 | impl f64x8 {
|
147 |
| - int_type = i64x8, |
148 |
| - floor = "llvm.floor.v8f64", |
149 |
| - ceil = "llvm.ceil.v8f64", |
150 |
| - round = "llvm.round.v8f64", |
151 |
| - trunc = "llvm.trunc.v8f64", |
| 86 | + int_type = i64x8 |
152 | 87 | }
|
153 | 88 | }
|
0 commit comments