1#![allow(non_camel_case_types)]
15
16use crate::{core_arch::simd::*, intrinsics::simd::*, mem, mem::transmute};
17
18#[cfg(test)]
19use stdarch_test::assert_instr;
20
21use super::macros::*;
22
23types! {
24 #![unstable(feature = "stdarch_powerpc", issue = "111145")]
25
26 pub struct vector_signed_char(16 x i8);
28 pub struct vector_unsigned_char(16 x u8);
30
31 pub struct vector_bool_char(16 x i8);
33 pub struct vector_signed_short(8 x i16);
35 pub struct vector_unsigned_short(8 x u16);
37 pub struct vector_bool_short(8 x i16);
39 pub struct vector_signed_int(4 x i32);
42 pub struct vector_unsigned_int(4 x u32);
44 pub struct vector_bool_int(4 x i32);
46 pub struct vector_float(4 x f32);
48}
49
50#[allow(improper_ctypes)]
51extern "C" {
52 #[link_name = "llvm.ppc.altivec.lvx"]
53 fn lvx(p: *const i8) -> vector_unsigned_int;
54
55 #[link_name = "llvm.ppc.altivec.lvebx"]
56 fn lvebx(p: *const i8) -> vector_signed_char;
57 #[link_name = "llvm.ppc.altivec.lvehx"]
58 fn lvehx(p: *const i8) -> vector_signed_short;
59 #[link_name = "llvm.ppc.altivec.lvewx"]
60 fn lvewx(p: *const i8) -> vector_signed_int;
61
62 #[link_name = "llvm.ppc.altivec.lvxl"]
63 fn lvxl(p: *const i8) -> vector_unsigned_int;
64
65 #[link_name = "llvm.ppc.altivec.stvx"]
66 fn stvx(a: vector_signed_int, p: *const i8);
67
68 #[link_name = "llvm.ppc.altivec.stvebx"]
69 fn stvebx(a: vector_signed_char, p: *const i8);
70 #[link_name = "llvm.ppc.altivec.stvehx"]
71 fn stvehx(a: vector_signed_short, p: *const i8);
72 #[link_name = "llvm.ppc.altivec.stvewx"]
73 fn stvewx(a: vector_signed_int, p: *const i8);
74
75 #[link_name = "llvm.ppc.altivec.stvxl"]
76 fn stvxl(a: vector_signed_int, p: *const i8);
77
78 #[link_name = "llvm.ppc.altivec.vperm"]
79 fn vperm(
80 a: vector_signed_int,
81 b: vector_signed_int,
82 c: vector_unsigned_char,
83 ) -> vector_signed_int;
84 #[link_name = "llvm.ppc.altivec.vmhaddshs"]
85 fn vmhaddshs(
86 a: vector_signed_short,
87 b: vector_signed_short,
88 c: vector_signed_short,
89 ) -> vector_signed_short;
90 #[link_name = "llvm.ppc.altivec.vmhraddshs"]
91 fn vmhraddshs(
92 a: vector_signed_short,
93 b: vector_signed_short,
94 c: vector_signed_short,
95 ) -> vector_signed_short;
96 #[link_name = "llvm.ppc.altivec.vmsumuhs"]
97 fn vmsumuhs(
98 a: vector_unsigned_short,
99 b: vector_unsigned_short,
100 c: vector_unsigned_int,
101 ) -> vector_unsigned_int;
102 #[link_name = "llvm.ppc.altivec.vmsumshs"]
103 fn vmsumshs(
104 a: vector_signed_short,
105 b: vector_signed_short,
106 c: vector_signed_int,
107 ) -> vector_signed_int;
108 #[link_name = "llvm.ppc.altivec.vmsumubm"]
109 fn vmsumubm(
110 a: vector_unsigned_char,
111 b: vector_unsigned_char,
112 c: vector_unsigned_int,
113 ) -> vector_unsigned_int;
114 #[link_name = "llvm.ppc.altivec.vmsummbm"]
115 fn vmsummbm(
116 a: vector_signed_char,
117 b: vector_unsigned_char,
118 c: vector_signed_int,
119 ) -> vector_signed_int;
120 #[link_name = "llvm.ppc.altivec.vmsumuhm"]
121 fn vmsumuhm(
122 a: vector_unsigned_short,
123 b: vector_unsigned_short,
124 c: vector_unsigned_int,
125 ) -> vector_unsigned_int;
126 #[link_name = "llvm.ppc.altivec.vmsumshm"]
127 fn vmsumshm(
128 a: vector_signed_short,
129 b: vector_signed_short,
130 c: vector_signed_int,
131 ) -> vector_signed_int;
132 #[link_name = "llvm.ppc.altivec.vmaddfp"]
133 fn vmaddfp(a: vector_float, b: vector_float, c: vector_float) -> vector_float;
134 #[link_name = "llvm.ppc.altivec.vnmsubfp"]
135 fn vnmsubfp(a: vector_float, b: vector_float, c: vector_float) -> vector_float;
136 #[link_name = "llvm.ppc.altivec.vsum2sws"]
137 fn vsum2sws(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int;
138 #[link_name = "llvm.ppc.altivec.vsum4ubs"]
139 fn vsum4ubs(a: vector_unsigned_char, b: vector_unsigned_int) -> vector_unsigned_int;
140 #[link_name = "llvm.ppc.altivec.vsum4sbs"]
141 fn vsum4sbs(a: vector_signed_char, b: vector_signed_int) -> vector_signed_int;
142 #[link_name = "llvm.ppc.altivec.vsum4shs"]
143 fn vsum4shs(a: vector_signed_short, b: vector_signed_int) -> vector_signed_int;
144 #[link_name = "llvm.ppc.altivec.vmuleub"]
145 fn vmuleub(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_short;
146 #[link_name = "llvm.ppc.altivec.vmulesb"]
147 fn vmulesb(a: vector_signed_char, b: vector_signed_char) -> vector_signed_short;
148 #[link_name = "llvm.ppc.altivec.vmuleuh"]
149 fn vmuleuh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_int;
150 #[link_name = "llvm.ppc.altivec.vmulesh"]
151 fn vmulesh(a: vector_signed_short, b: vector_signed_short) -> vector_signed_int;
152 #[link_name = "llvm.ppc.altivec.vmuloub"]
153 fn vmuloub(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_short;
154 #[link_name = "llvm.ppc.altivec.vmulosb"]
155 fn vmulosb(a: vector_signed_char, b: vector_signed_char) -> vector_signed_short;
156 #[link_name = "llvm.ppc.altivec.vmulouh"]
157 fn vmulouh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_int;
158 #[link_name = "llvm.ppc.altivec.vmulosh"]
159 fn vmulosh(a: vector_signed_short, b: vector_signed_short) -> vector_signed_int;
160
161 #[link_name = "llvm.ppc.altivec.vmaxsb"]
162 fn vmaxsb(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char;
163 #[link_name = "llvm.ppc.altivec.vmaxsh"]
164 fn vmaxsh(a: vector_signed_short, b: vector_signed_short) -> vector_signed_short;
165 #[link_name = "llvm.ppc.altivec.vmaxsw"]
166 fn vmaxsw(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int;
167
168 #[link_name = "llvm.ppc.altivec.vmaxub"]
169 fn vmaxub(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char;
170 #[link_name = "llvm.ppc.altivec.vmaxuh"]
171 fn vmaxuh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_short;
172 #[link_name = "llvm.ppc.altivec.vmaxuw"]
173 fn vmaxuw(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int;
174
175 #[link_name = "llvm.ppc.altivec.vminsb"]
176 fn vminsb(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char;
177 #[link_name = "llvm.ppc.altivec.vminsh"]
178 fn vminsh(a: vector_signed_short, b: vector_signed_short) -> vector_signed_short;
179 #[link_name = "llvm.ppc.altivec.vminsw"]
180 fn vminsw(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int;
181
182 #[link_name = "llvm.ppc.altivec.vminub"]
183 fn vminub(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char;
184 #[link_name = "llvm.ppc.altivec.vminuh"]
185 fn vminuh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_short;
186 #[link_name = "llvm.ppc.altivec.vminuw"]
187 fn vminuw(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int;
188
189 #[link_name = "llvm.ppc.altivec.vsubsbs"]
190 fn vsubsbs(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char;
191 #[link_name = "llvm.ppc.altivec.vsubshs"]
192 fn vsubshs(a: vector_signed_short, b: vector_signed_short) -> vector_signed_short;
193 #[link_name = "llvm.ppc.altivec.vsubsws"]
194 fn vsubsws(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int;
195
196 #[link_name = "llvm.ppc.altivec.vsububs"]
197 fn vsububs(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char;
198 #[link_name = "llvm.ppc.altivec.vsubuhs"]
199 fn vsubuhs(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_short;
200 #[link_name = "llvm.ppc.altivec.vsubuws"]
201 fn vsubuws(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int;
202
203 #[link_name = "llvm.ppc.altivec.vsubcuw"]
204 fn vsubcuw(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int;
205
206 #[link_name = "llvm.ppc.altivec.vaddcuw"]
207 fn vaddcuw(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int;
208
209 #[link_name = "llvm.ppc.altivec.vaddsbs"]
210 fn vaddsbs(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char;
211 #[link_name = "llvm.ppc.altivec.vaddshs"]
212 fn vaddshs(a: vector_signed_short, b: vector_signed_short) -> vector_signed_short;
213 #[link_name = "llvm.ppc.altivec.vaddsws"]
214 fn vaddsws(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int;
215
216 #[link_name = "llvm.ppc.altivec.vaddubs"]
217 fn vaddubs(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char;
218 #[link_name = "llvm.ppc.altivec.vadduhs"]
219 fn vadduhs(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_short;
220 #[link_name = "llvm.ppc.altivec.vadduws"]
221 fn vadduws(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int;
222
223 #[link_name = "llvm.ppc.altivec.vavgsb"]
224 fn vavgsb(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char;
225 #[link_name = "llvm.ppc.altivec.vavgsh"]
226 fn vavgsh(a: vector_signed_short, b: vector_signed_short) -> vector_signed_short;
227 #[link_name = "llvm.ppc.altivec.vavgsw"]
228 fn vavgsw(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int;
229
230 #[link_name = "llvm.ppc.altivec.vavgub"]
231 fn vavgub(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char;
232 #[link_name = "llvm.ppc.altivec.vavguh"]
233 fn vavguh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_short;
234 #[link_name = "llvm.ppc.altivec.vavguw"]
235 fn vavguw(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int;
236
237 #[link_name = "llvm.ceil.v4f32"]
238 fn vceil(a: vector_float) -> vector_float;
239
240 #[link_name = "llvm.ppc.altivec.vcmpbfp"]
241 fn vcmpbfp(a: vector_float, b: vector_float) -> vector_signed_int;
242
243 #[link_name = "llvm.ppc.altivec.vcmpequb"]
244 fn vcmpequb(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_bool_char;
245 #[link_name = "llvm.ppc.altivec.vcmpequh"]
246 fn vcmpequh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_bool_short;
247 #[link_name = "llvm.ppc.altivec.vcmpequw"]
248 fn vcmpequw(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_bool_int;
249
250 #[link_name = "llvm.ppc.altivec.vcmpneb"]
251 fn vcmpneb(a: vector_signed_char, b: vector_signed_char) -> vector_bool_char;
252 #[link_name = "llvm.ppc.altivec.vcmpneh"]
253 fn vcmpneh(a: vector_signed_short, b: vector_signed_short) -> vector_bool_short;
254 #[link_name = "llvm.ppc.altivec.vcmpnew"]
255 fn vcmpnew(a: vector_signed_int, b: vector_signed_int) -> vector_bool_int;
256
257 #[link_name = "llvm.ppc.altivec.vcmpgefp"]
258 fn vcmpgefp(a: vector_float, b: vector_float) -> vector_bool_int;
259
260 #[link_name = "llvm.ppc.altivec.vcmpgtub"]
261 fn vcmpgtub(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_bool_char;
262 #[link_name = "llvm.ppc.altivec.vcmpgtuh"]
263 fn vcmpgtuh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_bool_short;
264 #[link_name = "llvm.ppc.altivec.vcmpgtuw"]
265 fn vcmpgtuw(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_bool_int;
266
267 #[link_name = "llvm.ppc.altivec.vcmpgtsb"]
268 fn vcmpgtsb(a: vector_signed_char, b: vector_signed_char) -> vector_bool_char;
269 #[link_name = "llvm.ppc.altivec.vcmpgtsh"]
270 fn vcmpgtsh(a: vector_signed_short, b: vector_signed_short) -> vector_bool_short;
271 #[link_name = "llvm.ppc.altivec.vcmpgtsw"]
272 fn vcmpgtsw(a: vector_signed_int, b: vector_signed_int) -> vector_bool_int;
273
274 #[link_name = "llvm.ppc.altivec.vexptefp"]
275 fn vexptefp(a: vector_float) -> vector_float;
276
277 #[link_name = "llvm.floor.v4f32"]
278 fn vfloor(a: vector_float) -> vector_float;
279
280 #[link_name = "llvm.ppc.altivec.vcmpequb.p"]
281 fn vcmpequb_p(cr: i32, a: vector_unsigned_char, b: vector_unsigned_char) -> i32;
282 #[link_name = "llvm.ppc.altivec.vcmpequh.p"]
283 fn vcmpequh_p(cr: i32, a: vector_unsigned_short, b: vector_unsigned_short) -> i32;
284 #[link_name = "llvm.ppc.altivec.vcmpequw.p"]
285 fn vcmpequw_p(cr: i32, a: vector_unsigned_int, b: vector_unsigned_int) -> i32;
286
287 #[link_name = "llvm.ppc.altivec.vcmpeqfp.p"]
288 fn vcmpeqfp_p(cr: i32, a: vector_float, b: vector_float) -> i32;
289
290 #[link_name = "llvm.ppc.altivec.vcmpgtub.p"]
291 fn vcmpgtub_p(cr: i32, a: vector_unsigned_char, b: vector_unsigned_char) -> i32;
292 #[link_name = "llvm.ppc.altivec.vcmpgtuh.p"]
293 fn vcmpgtuh_p(cr: i32, a: vector_unsigned_short, b: vector_unsigned_short) -> i32;
294 #[link_name = "llvm.ppc.altivec.vcmpgtuw.p"]
295 fn vcmpgtuw_p(cr: i32, a: vector_unsigned_int, b: vector_unsigned_int) -> i32;
296 #[link_name = "llvm.ppc.altivec.vcmpgtsb.p"]
297 fn vcmpgtsb_p(cr: i32, a: vector_signed_char, b: vector_signed_char) -> i32;
298 #[link_name = "llvm.ppc.altivec.vcmpgtsh.p"]
299 fn vcmpgtsh_p(cr: i32, a: vector_signed_short, b: vector_signed_short) -> i32;
300 #[link_name = "llvm.ppc.altivec.vcmpgtsw.p"]
301 fn vcmpgtsw_p(cr: i32, a: vector_signed_int, b: vector_signed_int) -> i32;
302
303 #[link_name = "llvm.ppc.altivec.vcmpgefp.p"]
304 fn vcmpgefp_p(cr: i32, a: vector_float, b: vector_float) -> i32;
305 #[link_name = "llvm.ppc.altivec.vcmpgtfp.p"]
306 fn vcmpgtfp_p(cr: i32, a: vector_float, b: vector_float) -> i32;
307 #[link_name = "llvm.ppc.altivec.vcmpbfp.p"]
308 fn vcmpbfp_p(cr: i32, a: vector_float, b: vector_float) -> i32;
309
310 #[link_name = "llvm.ppc.altivec.vcfsx"]
311 fn vcfsx(a: vector_signed_int, b: i32) -> vector_float;
312 #[link_name = "llvm.ppc.altivec.vcfux"]
313 fn vcfux(a: vector_unsigned_int, b: i32) -> vector_float;
314
315 #[link_name = "llvm.ppc.altivec.vctsxs"]
316 fn vctsxs(a: vector_float, b: i32) -> vector_signed_int;
317 #[link_name = "llvm.ppc.altivec.vctuxs"]
318 fn vctuxs(a: vector_float, b: i32) -> vector_unsigned_int;
319
320 #[link_name = "llvm.ppc.altivec.vpkshss"]
321 fn vpkshss(a: vector_signed_short, b: vector_signed_short) -> vector_signed_char;
322 #[link_name = "llvm.ppc.altivec.vpkshus"]
323 fn vpkshus(a: vector_signed_short, b: vector_signed_short) -> vector_unsigned_char;
324 #[link_name = "llvm.ppc.altivec.vpkuhus"]
325 fn vpkuhus(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_char;
326 #[link_name = "llvm.ppc.altivec.vpkswss"]
327 fn vpkswss(a: vector_signed_int, b: vector_signed_int) -> vector_signed_short;
328 #[link_name = "llvm.ppc.altivec.vpkswus"]
329 fn vpkswus(a: vector_signed_int, b: vector_signed_int) -> vector_unsigned_short;
330 #[link_name = "llvm.ppc.altivec.vpkuwus"]
331 fn vpkuwus(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_short;
332
333 #[link_name = "llvm.ppc.altivec.vupkhsb"]
334 fn vupkhsb(a: vector_signed_char) -> vector_signed_short;
335 #[link_name = "llvm.ppc.altivec.vupklsb"]
336 fn vupklsb(a: vector_signed_char) -> vector_signed_short;
337
338 #[link_name = "llvm.ppc.altivec.vupkhsh"]
339 fn vupkhsh(a: vector_signed_short) -> vector_signed_int;
340 #[link_name = "llvm.ppc.altivec.vupklsh"]
341 fn vupklsh(a: vector_signed_short) -> vector_signed_int;
342
343 #[link_name = "llvm.ppc.altivec.mfvscr"]
344 fn mfvscr() -> vector_unsigned_short;
345
346 #[link_name = "llvm.ppc.altivec.vlogefp"]
347 fn vlogefp(a: vector_float) -> vector_float;
348
349 #[link_name = "llvm.ppc.altivec.sll"]
350 fn vsl(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int;
351 #[link_name = "llvm.ppc.altivec.slo"]
352 fn vslo(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int;
353
354 #[link_name = "llvm.ppc.altivec.srab"]
355 fn vsrab(a: vector_signed_char, b: vector_unsigned_char) -> vector_signed_char;
356 #[link_name = "llvm.ppc.altivec.srah"]
357 fn vsrah(a: vector_signed_short, b: vector_unsigned_short) -> vector_signed_short;
358 #[link_name = "llvm.ppc.altivec.sraw"]
359 fn vsraw(a: vector_signed_int, b: vector_unsigned_int) -> vector_signed_int;
360
361 #[link_name = "llvm.ppc.altivec.srl"]
362 fn vsr(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int;
363 #[link_name = "llvm.ppc.altivec.sro"]
364 fn vsro(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int;
365
366 #[link_name = "llvm.ppc.altivec.slv"]
367 fn vslv(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char;
368 #[link_name = "llvm.ppc.altivec.srv"]
369 fn vsrv(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char;
370
371 #[link_name = "llvm.ctlz.v16i8"]
372 fn vclzb(a: vector_signed_char) -> vector_signed_char;
373 #[link_name = "llvm.ctlz.v8i16"]
374 fn vclzh(a: vector_signed_short) -> vector_signed_short;
375 #[link_name = "llvm.ctlz.v4i32"]
376 fn vclzw(a: vector_signed_int) -> vector_signed_int;
377
378 #[link_name = "llvm.ppc.altivec.vrlb"]
379 fn vrlb(a: vector_signed_char, b: vector_unsigned_char) -> vector_signed_char;
380 #[link_name = "llvm.ppc.altivec.vrlh"]
381 fn vrlh(a: vector_signed_short, b: vector_unsigned_short) -> vector_signed_short;
382 #[link_name = "llvm.ppc.altivec.vrlw"]
383 fn vrlw(a: vector_signed_int, c: vector_unsigned_int) -> vector_signed_int;
384
385 #[link_name = "llvm.ppc.altivec.vrfin"]
386 fn vrfin(a: vector_float) -> vector_float;
387}
388
389impl_from! { i8x16, u8x16, i16x8, u16x8, i32x4, u32x4, f32x4 }
390
391impl_neg! { i8x16 : 0 }
392impl_neg! { i16x8 : 0 }
393impl_neg! { i32x4 : 0 }
394impl_neg! { f32x4 : 0f32 }
395
396#[macro_use]
397mod sealed {
398 use super::*;
399
400 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
401 pub trait VectorInsert {
402 type Scalar;
403 unsafe fn vec_insert<const IDX: u32>(self, s: Self::Scalar) -> Self;
404 }
405
406 const fn idx_in_vec<T, const IDX: u32>() -> u32 {
407 IDX & (16 / crate::mem::size_of::<T>() as u32)
408 }
409
410 macro_rules! impl_vec_insert {
411 ($ty:ident) => {
412 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
413 impl VectorInsert for t_t_l!($ty) {
414 type Scalar = $ty;
415 #[inline]
416 #[target_feature(enable = "altivec")]
417 unsafe fn vec_insert<const IDX: u32>(self, s: Self::Scalar) -> Self {
418 simd_insert(self, const { idx_in_vec::<Self::Scalar, IDX>() }, s)
419 }
420 }
421 };
422 }
423
424 impl_vec_insert! { i8 }
425 impl_vec_insert! { u8 }
426 impl_vec_insert! { i16 }
427 impl_vec_insert! { u16 }
428 impl_vec_insert! { i32 }
429 impl_vec_insert! { u32 }
430 impl_vec_insert! { f32 }
431
432 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
433 pub trait VectorExtract {
434 type Scalar;
435 unsafe fn vec_extract<const IDX: u32>(self) -> Self::Scalar;
436 }
437
438 macro_rules! impl_vec_extract {
439 ($ty:ident) => {
440 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
441 impl VectorExtract for t_t_l!($ty) {
442 type Scalar = $ty;
443 #[inline]
444 #[target_feature(enable = "altivec")]
445 unsafe fn vec_extract<const IDX: u32>(self) -> Self::Scalar {
446 simd_extract(self, const { idx_in_vec::<Self::Scalar, IDX>() })
447 }
448 }
449 };
450 }
451
452 impl_vec_extract! { i8 }
453 impl_vec_extract! { u8 }
454 impl_vec_extract! { i16 }
455 impl_vec_extract! { u16 }
456 impl_vec_extract! { i32 }
457 impl_vec_extract! { u32 }
458 impl_vec_extract! { f32 }
459
460 macro_rules! impl_vec_cmp {
461 ([$Trait:ident $m:ident] ($b:ident, $h:ident, $w:ident)) => {
462 impl_vec_cmp! { [$Trait $m] ($b, $b, $h, $h, $w, $w) }
463 };
464 ([$Trait:ident $m:ident] ($ub:ident, $sb:ident, $uh:ident, $sh:ident, $uw:ident, $sw:ident)) => {
465 impl_vec_trait!{ [$Trait $m] $ub (vector_unsigned_char, vector_unsigned_char) -> vector_bool_char }
466 impl_vec_trait!{ [$Trait $m] $sb (vector_signed_char, vector_signed_char) -> vector_bool_char }
467 impl_vec_trait!{ [$Trait $m] $uh (vector_unsigned_short, vector_unsigned_short) -> vector_bool_short }
468 impl_vec_trait!{ [$Trait $m] $sh (vector_signed_short, vector_signed_short) -> vector_bool_short }
469 impl_vec_trait!{ [$Trait $m] $uw (vector_unsigned_int, vector_unsigned_int) -> vector_bool_int }
470 impl_vec_trait!{ [$Trait $m] $sw (vector_signed_int, vector_signed_int) -> vector_bool_int }
471 }
472 }
473
474 macro_rules! impl_vec_any_all {
475 ([$Trait:ident $m:ident] ($b:ident, $h:ident, $w:ident)) => {
476 impl_vec_any_all! { [$Trait $m] ($b, $b, $h, $h, $w, $w) }
477 };
478 ([$Trait:ident $m:ident] ($ub:ident, $sb:ident, $uh:ident, $sh:ident, $uw:ident, $sw:ident)) => {
479 impl_vec_trait!{ [$Trait $m] $ub (vector_unsigned_char, vector_unsigned_char) -> bool }
480 impl_vec_trait!{ [$Trait $m] $sb (vector_signed_char, vector_signed_char) -> bool }
481 impl_vec_trait!{ [$Trait $m] $uh (vector_unsigned_short, vector_unsigned_short) -> bool }
482 impl_vec_trait!{ [$Trait $m] $sh (vector_signed_short, vector_signed_short) -> bool }
483 impl_vec_trait!{ [$Trait $m] $uw (vector_unsigned_int, vector_unsigned_int) -> bool }
484 impl_vec_trait!{ [$Trait $m] $sw (vector_signed_int, vector_signed_int) -> bool }
485 }
486 }
487
488 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
489 pub trait VectorLd {
490 type Result;
491 unsafe fn vec_ld(self, off: isize) -> Self::Result;
492 unsafe fn vec_ldl(self, off: isize) -> Self::Result;
493 }
494
495 macro_rules! impl_vec_ld {
496 ($fun:ident $fun_lru:ident $ty:ident) => {
497 #[inline]
498 #[target_feature(enable = "altivec")]
499 #[cfg_attr(test, assert_instr(lvx))]
500 pub unsafe fn $fun(off: isize, p: *const $ty) -> t_t_l!($ty) {
501 let addr = (p as *const i8).offset(off);
502 transmute(lvx(addr))
503 }
504
505 #[inline]
506 #[target_feature(enable = "altivec")]
507 #[cfg_attr(test, assert_instr(lvxl))]
508 pub unsafe fn $fun_lru(off: isize, p: *const $ty) -> t_t_l!($ty) {
509 let addr = (p as *const i8).offset(off);
510 transmute(lvxl(addr))
511 }
512
513 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
514 impl VectorLd for *const $ty {
515 type Result = t_t_l!($ty);
516 #[inline]
517 #[target_feature(enable = "altivec")]
518 unsafe fn vec_ld(self, off: isize) -> Self::Result {
519 $fun(off, self)
520 }
521 #[inline]
522 #[target_feature(enable = "altivec")]
523 unsafe fn vec_ldl(self, off: isize) -> Self::Result {
524 $fun_lru(off, self)
525 }
526 }
527 };
528 }
529
530 impl_vec_ld! { vec_ld_u8 vec_ldl_u8 u8 }
531 impl_vec_ld! { vec_ld_i8 vec_ldl_i8 i8 }
532
533 impl_vec_ld! { vec_ld_u16 vec_ldl_u16 u16 }
534 impl_vec_ld! { vec_ld_i16 vec_ldl_i16 i16 }
535
536 impl_vec_ld! { vec_ld_u32 vec_ldl_u32 u32 }
537 impl_vec_ld! { vec_ld_i32 vec_ldl_i32 i32 }
538
539 impl_vec_ld! { vec_ld_f32 vec_ldl_f32 f32 }
540
541 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
542 pub trait VectorLde {
543 type Result;
544 unsafe fn vec_lde(self, a: isize) -> Self::Result;
545 }
546
547 macro_rules! impl_vec_lde {
548 ($fun:ident $instr:ident $ty:ident) => {
549 #[inline]
550 #[target_feature(enable = "altivec")]
551 #[cfg_attr(test, assert_instr($instr))]
552 pub unsafe fn $fun(a: isize, b: *const $ty) -> t_t_l!($ty) {
553 let addr = (b as *const i8).offset(a);
554 transmute($instr(addr))
555 }
556
557 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
558 impl VectorLde for *const $ty {
559 type Result = t_t_l!($ty);
560 #[inline]
561 #[target_feature(enable = "altivec")]
562 unsafe fn vec_lde(self, a: isize) -> Self::Result {
563 $fun(a, self)
564 }
565 }
566 };
567 }
568
569 impl_vec_lde! { vec_lde_u8 lvebx u8 }
570 impl_vec_lde! { vec_lde_i8 lvebx i8 }
571
572 impl_vec_lde! { vec_lde_u16 lvehx u16 }
573 impl_vec_lde! { vec_lde_i16 lvehx i16 }
574
575 impl_vec_lde! { vec_lde_u32 lvewx u32 }
576 impl_vec_lde! { vec_lde_i32 lvewx i32 }
577
578 impl_vec_lde! { vec_lde_f32 lvewx f32 }
579
580 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
581 pub trait VectorSt {
582 type Target;
583 unsafe fn vec_st(self, off: isize, p: Self::Target);
584 unsafe fn vec_stl(self, off: isize, p: Self::Target);
585 }
586
587 macro_rules! impl_vec_st {
588 ($fun:ident $fun_lru:ident $ty:ident) => {
589 #[inline]
590 #[target_feature(enable = "altivec")]
591 #[cfg_attr(test, assert_instr(stvx))]
592 pub unsafe fn $fun(a: t_t_l!($ty), off: isize, p: *const $ty) {
593 let addr = (p as *const i8).offset(off);
594 stvx(transmute(a), addr)
595 }
596
597 #[inline]
598 #[target_feature(enable = "altivec")]
599 #[cfg_attr(test, assert_instr(stvxl))]
600 pub unsafe fn $fun_lru(a: t_t_l!($ty), off: isize, p: *const $ty) {
601 let addr = (p as *const i8).offset(off as isize);
602 stvxl(transmute(a), addr)
603 }
604
605 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
606 impl VectorSt for t_t_l!($ty) {
607 type Target = *const $ty;
608 #[inline]
609 #[target_feature(enable = "altivec")]
610 unsafe fn vec_st(self, off: isize, p: Self::Target) {
611 $fun(self, off, p)
612 }
613 #[inline]
614 #[target_feature(enable = "altivec")]
615 unsafe fn vec_stl(self, off: isize, p: Self::Target) {
616 $fun(self, off, p)
617 }
618 }
619 };
620 }
621
622 impl_vec_st! { vec_st_u8 vec_stl_u8 u8 }
623 impl_vec_st! { vec_st_i8 vec_stl_i8 i8 }
624
625 impl_vec_st! { vec_st_u16 vec_stl_u16 u16 }
626 impl_vec_st! { vec_st_i16 vec_stl_i16 i16 }
627
628 impl_vec_st! { vec_st_u32 vec_stl_u32 u32 }
629 impl_vec_st! { vec_st_i32 vec_stl_i32 i32 }
630
631 impl_vec_st! { vec_st_f32 vec_stl_f32 f32 }
632
633 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
634 pub trait VectorSte {
635 type Target;
636 unsafe fn vec_ste(self, off: isize, p: Self::Target);
637 }
638
639 macro_rules! impl_vec_ste {
640 ($fun:ident $instr:ident $ty:ident) => {
641 #[inline]
642 #[target_feature(enable = "altivec")]
643 #[cfg_attr(test, assert_instr($instr))]
644 pub unsafe fn $fun(a: t_t_l!($ty), off: isize, p: *const $ty) {
645 let addr = (p as *const i8).offset(off);
646 $instr(transmute(a), addr)
647 }
648
649 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
650 impl VectorSte for t_t_l!($ty) {
651 type Target = *const $ty;
652 #[inline]
653 #[target_feature(enable = "altivec")]
654 unsafe fn vec_ste(self, off: isize, p: Self::Target) {
655 $fun(self, off, p)
656 }
657 }
658 };
659 }
660
661 impl_vec_ste! { vec_ste_u8 stvebx u8 }
662 impl_vec_ste! { vec_ste_i8 stvebx i8 }
663
664 impl_vec_ste! { vec_ste_u16 stvehx u16 }
665 impl_vec_ste! { vec_ste_i16 stvehx i16 }
666
667 impl_vec_ste! { vec_ste_u32 stvewx u32 }
668 impl_vec_ste! { vec_ste_i32 stvewx i32 }
669
670 impl_vec_ste! { vec_ste_f32 stvewx f32 }
671
672 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
673 pub trait VectorXl {
674 type Result;
675 unsafe fn vec_xl(self, a: isize) -> Self::Result;
676 }
677
678 macro_rules! impl_vec_xl {
679 ($fun:ident $notpwr9:ident / $pwr9:ident $ty:ident) => {
680 #[inline]
681 #[target_feature(enable = "altivec")]
682 #[cfg_attr(
683 all(test, not(target_feature = "power9-altivec")),
684 assert_instr($notpwr9)
685 )]
686 #[cfg_attr(all(test, target_feature = "power9-altivec"), assert_instr($pwr9))]
687 pub unsafe fn $fun(a: isize, b: *const $ty) -> t_t_l!($ty) {
688 let addr = (b as *const u8).offset(a);
689
690 extern "rust-intrinsic" {
692 #[rustc_nounwind]
693 pub fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
694 }
695
696 let mut r = mem::MaybeUninit::uninit();
697
698 copy_nonoverlapping(
699 addr,
700 r.as_mut_ptr() as *mut u8,
701 mem::size_of::<t_t_l!($ty)>(),
702 );
703
704 r.assume_init()
705 }
706
707 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
708 impl VectorXl for *const $ty {
709 type Result = t_t_l!($ty);
710 #[inline]
711 #[target_feature(enable = "altivec")]
712 unsafe fn vec_xl(self, a: isize) -> Self::Result {
713 $fun(a, self)
714 }
715 }
716 };
717 }
718
719 impl_vec_xl! { vec_xl_i8 lxvd2x / lxv i8 }
720 impl_vec_xl! { vec_xl_u8 lxvd2x / lxv u8 }
721 impl_vec_xl! { vec_xl_i16 lxvd2x / lxv i16 }
722 impl_vec_xl! { vec_xl_u16 lxvd2x / lxv u16 }
723 impl_vec_xl! { vec_xl_i32 lxvd2x / lxv i32 }
724 impl_vec_xl! { vec_xl_u32 lxvd2x / lxv u32 }
725 impl_vec_xl! { vec_xl_f32 lxvd2x / lxv f32 }
726
727 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
728 pub trait VectorXst {
729 type Out;
730 unsafe fn vec_xst(self, a: isize, p: Self::Out);
731 }
732
733 macro_rules! impl_vec_xst {
734 ($fun:ident $notpwr9:ident / $pwr9:ident $ty:ident) => {
735 #[inline]
736 #[target_feature(enable = "altivec")]
737 #[cfg_attr(
738 all(test, not(target_feature = "power9-altivec")),
739 assert_instr($notpwr9)
740 )]
741 #[cfg_attr(all(test, target_feature = "power9-altivec"), assert_instr($pwr9))]
742 pub unsafe fn $fun(s: t_t_l!($ty), a: isize, b: *mut $ty) {
743 let addr = (b as *mut u8).offset(a);
744
745 extern "rust-intrinsic" {
747 #[rustc_nounwind]
748 pub fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
749 }
750
751 copy_nonoverlapping(
752 &s as *const _ as *const u8,
753 addr,
754 mem::size_of::<t_t_l!($ty)>(),
755 );
756 }
757
758 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
759 impl VectorXst for t_t_l!($ty) {
760 type Out = *mut $ty;
761 #[inline]
762 #[target_feature(enable = "altivec")]
763 unsafe fn vec_xst(self, a: isize, b: Self::Out) {
764 $fun(self, a, b)
765 }
766 }
767 };
768 }
769
770 impl_vec_xst! { vec_xst_i8 stxvd2x / stxv i8 }
771 impl_vec_xst! { vec_xst_u8 stxvd2x / stxv u8 }
772 impl_vec_xst! { vec_xst_i16 stxvd2x / stxv i16 }
773 impl_vec_xst! { vec_xst_u16 stxvd2x / stxv u16 }
774 impl_vec_xst! { vec_xst_i32 stxvd2x / stxv i32 }
775 impl_vec_xst! { vec_xst_u32 stxvd2x / stxv u32 }
776 impl_vec_xst! { vec_xst_f32 stxvd2x / stxv f32 }
777
778 test_impl! { vec_floor(a: vector_float) -> vector_float [ vfloor, vrfim / xvrspim ] }
779
780 test_impl! { vec_vexptefp(a: vector_float) -> vector_float [ vexptefp, vexptefp ] }
781
782 test_impl! { vec_vcmpgtub(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_bool_char [ vcmpgtub, vcmpgtub ] }
783 test_impl! { vec_vcmpgtuh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_bool_short [ vcmpgtuh, vcmpgtuh ] }
784 test_impl! { vec_vcmpgtuw(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_bool_int [ vcmpgtuw, vcmpgtuw ] }
785
786 test_impl! { vec_vcmpgtsb(a: vector_signed_char, b: vector_signed_char) -> vector_bool_char [ vcmpgtsb, vcmpgtsb ] }
787 test_impl! { vec_vcmpgtsh(a: vector_signed_short, b: vector_signed_short) -> vector_bool_short [ vcmpgtsh, vcmpgtsh ] }
788 test_impl! { vec_vcmpgtsw(a: vector_signed_int, b: vector_signed_int) -> vector_bool_int [ vcmpgtsw, vcmpgtsw ] }
789
790 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
791 pub trait VectorCmpGt<Other> {
792 type Result;
793 unsafe fn vec_cmpgt(self, b: Other) -> Self::Result;
794 }
795
796 impl_vec_cmp! { [VectorCmpGt vec_cmpgt] ( vec_vcmpgtub, vec_vcmpgtsb, vec_vcmpgtuh, vec_vcmpgtsh, vec_vcmpgtuw, vec_vcmpgtsw ) }
797
798 test_impl! { vec_vcmpgefp(a: vector_float, b: vector_float) -> vector_bool_int [ vcmpgefp, vcmpgefp ] }
799
800 test_impl! { vec_vcmpequb(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_bool_char [ vcmpequb, vcmpequb ] }
801 test_impl! { vec_vcmpequh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_bool_short [ vcmpequh, vcmpequh ] }
802 test_impl! { vec_vcmpequw(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_bool_int [ vcmpequw, vcmpequw ] }
803
804 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
805 pub trait VectorCmpEq<Other> {
806 type Result;
807 unsafe fn vec_cmpeq(self, b: Other) -> Self::Result;
808 }
809
810 impl_vec_cmp! { [VectorCmpEq vec_cmpeq] (vec_vcmpequb, vec_vcmpequh, vec_vcmpequw) }
811
812 macro_rules! impl_cmpne {
813 ($fun:ident ($ty:ident) -> $r:ident $([ $pwr9:ident ])? ) => {
814 #[inline]
815 #[target_feature(enable = "altivec")]
816 $( #[cfg_attr(all(test, target_feature = "power9-altivec"), assert_instr($pwr9))] )?
817 unsafe fn $fun(a: $ty, b: $ty) -> $r {
818 $( if cfg!(target_feature = "power9-altivec") {
819 transmute($pwr9(transmute(a), transmute(b)))
820 } else )? {
821 let zero = transmute(i32x4::new(0, 0, 0, 0));
822 vec_nor(vec_cmpeq(a, b), zero)
823 }
824 }
825 };
826 }
827
828 impl_cmpne! { vec_vcmpneb(vector_signed_char) -> vector_bool_char [ vcmpneb ] }
829 impl_cmpne! { vec_vcmpneh(vector_signed_short) -> vector_bool_short [ vcmpneh ] }
830 impl_cmpne! { vec_vcmpnew(vector_signed_int) -> vector_bool_int [ vcmpnew ] }
831
832 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
833 pub trait VectorCmpNe<Other> {
834 type Result;
835 unsafe fn vec_cmpne(self, b: Other) -> Self::Result;
836 }
837
838 impl_vec_cmp! { [VectorCmpNe vec_cmpne] (vec_vcmpneb, vec_vcmpneh, vec_vcmpnew) }
839
840 test_impl! { vec_vcmpbfp(a: vector_float, b: vector_float) -> vector_signed_int [vcmpbfp, vcmpbfp] }
841
842 #[inline]
843 #[target_feature(enable = "altivec")]
844 #[cfg_attr(test, assert_instr(vcmpequb.))]
845 unsafe fn vcmpequb_all(a: vector_unsigned_char, b: vector_unsigned_char) -> bool {
846 vcmpequb_p(2, a, b) != 0
847 }
848
849 #[inline]
850 #[target_feature(enable = "altivec")]
851 #[cfg_attr(test, assert_instr(vcmpequb.))]
852 unsafe fn vcmpequb_any(a: vector_unsigned_char, b: vector_unsigned_char) -> bool {
853 vcmpequb_p(1, a, b) != 0
854 }
855
856 #[inline]
857 #[target_feature(enable = "altivec")]
858 #[cfg_attr(test, assert_instr(vcmpequh.))]
859 unsafe fn vcmpequh_all(a: vector_unsigned_short, b: vector_unsigned_short) -> bool {
860 vcmpequh_p(2, a, b) != 0
861 }
862
863 #[inline]
864 #[target_feature(enable = "altivec")]
865 #[cfg_attr(test, assert_instr(vcmpequh.))]
866 unsafe fn vcmpequh_any(a: vector_unsigned_short, b: vector_unsigned_short) -> bool {
867 vcmpequh_p(1, a, b) != 0
868 }
869
870 #[inline]
871 #[target_feature(enable = "altivec")]
872 #[cfg_attr(test, assert_instr(vcmpequw.))]
873 unsafe fn vcmpequw_all(a: vector_unsigned_int, b: vector_unsigned_int) -> bool {
874 vcmpequw_p(2, a, b) != 0
875 }
876
877 #[inline]
878 #[target_feature(enable = "altivec")]
879 #[cfg_attr(test, assert_instr(vcmpequw.))]
880 unsafe fn vcmpequw_any(a: vector_unsigned_int, b: vector_unsigned_int) -> bool {
881 vcmpequw_p(1, a, b) != 0
882 }
883
884 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
885 pub trait VectorAllEq<Other> {
886 type Result;
887 unsafe fn vec_all_eq(self, b: Other) -> Self::Result;
888 }
889
890 impl_vec_any_all! { [VectorAllEq vec_all_eq] (vcmpequb_all, vcmpequh_all, vcmpequw_all) }
891
892 #[inline]
894 #[target_feature(enable = "altivec")]
895 #[cfg_attr(test, assert_instr(vcmpeqfp.))]
896 unsafe fn vcmpeqfp_all(a: vector_float, b: vector_float) -> bool {
897 vcmpeqfp_p(2, a, b) != 0
898 }
899
900 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
901 impl VectorAllEq<vector_float> for vector_float {
902 type Result = bool;
903 #[inline]
904 unsafe fn vec_all_eq(self, b: vector_float) -> Self::Result {
905 vcmpeqfp_all(self, b)
906 }
907 }
908
909 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
910 pub trait VectorAnyEq<Other> {
911 type Result;
912 unsafe fn vec_any_eq(self, b: Other) -> Self::Result;
913 }
914
915 impl_vec_any_all! { [VectorAnyEq vec_any_eq] (vcmpequb_any, vcmpequh_any, vcmpequw_any) }
916
917 #[inline]
918 #[target_feature(enable = "altivec")]
919 #[cfg_attr(test, assert_instr(vcmpeqfp.))]
920 unsafe fn vcmpeqfp_any(a: vector_float, b: vector_float) -> bool {
921 vcmpeqfp_p(1, a, b) != 0
922 }
923
924 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
925 impl VectorAnyEq<vector_float> for vector_float {
926 type Result = bool;
927 #[inline]
928 unsafe fn vec_any_eq(self, b: vector_float) -> Self::Result {
929 vcmpeqfp_any(self, b)
930 }
931 }
932
933 #[inline]
936 #[target_feature(enable = "altivec")]
937 #[cfg_attr(test, assert_instr(vcmpgtsb.))]
938 unsafe fn vcmpgesb_all(a: vector_signed_char, b: vector_signed_char) -> bool {
939 vcmpgtsb_p(0, b, a) != 0
940 }
941
942 #[inline]
943 #[target_feature(enable = "altivec")]
944 #[cfg_attr(test, assert_instr(vcmpgtsb.))]
945 unsafe fn vcmpgesb_any(a: vector_signed_char, b: vector_signed_char) -> bool {
946 vcmpgtsb_p(3, b, a) != 0
947 }
948
949 #[inline]
950 #[target_feature(enable = "altivec")]
951 #[cfg_attr(test, assert_instr(vcmpgtsh.))]
952 unsafe fn vcmpgesh_all(a: vector_signed_short, b: vector_signed_short) -> bool {
953 vcmpgtsh_p(0, b, a) != 0
954 }
955
956 #[inline]
957 #[target_feature(enable = "altivec")]
958 #[cfg_attr(test, assert_instr(vcmpgtsh.))]
959 unsafe fn vcmpgesh_any(a: vector_signed_short, b: vector_signed_short) -> bool {
960 vcmpgtsh_p(3, b, a) != 0
961 }
962
963 #[inline]
964 #[target_feature(enable = "altivec")]
965 #[cfg_attr(test, assert_instr(vcmpgtsw.))]
966 unsafe fn vcmpgesw_all(a: vector_signed_int, b: vector_signed_int) -> bool {
967 vcmpgtsw_p(0, b, a) != 0
968 }
969
970 #[inline]
971 #[target_feature(enable = "altivec")]
972 #[cfg_attr(test, assert_instr(vcmpgtsw.))]
973 unsafe fn vcmpgesw_any(a: vector_signed_int, b: vector_signed_int) -> bool {
974 vcmpgtsw_p(3, b, a) != 0
975 }
976
977 #[inline]
978 #[target_feature(enable = "altivec")]
979 #[cfg_attr(test, assert_instr(vcmpgtub.))]
980 unsafe fn vcmpgeub_all(a: vector_unsigned_char, b: vector_unsigned_char) -> bool {
981 vcmpgtub_p(0, b, a) != 0
982 }
983
984 #[inline]
985 #[target_feature(enable = "altivec")]
986 #[cfg_attr(test, assert_instr(vcmpgtub.))]
987 unsafe fn vcmpgeub_any(a: vector_unsigned_char, b: vector_unsigned_char) -> bool {
988 vcmpgtub_p(3, b, a) != 0
989 }
990
991 #[inline]
992 #[target_feature(enable = "altivec")]
993 #[cfg_attr(test, assert_instr(vcmpgtuh.))]
994 unsafe fn vcmpgeuh_all(a: vector_unsigned_short, b: vector_unsigned_short) -> bool {
995 vcmpgtuh_p(0, b, a) != 0
996 }
997
998 #[inline]
999 #[target_feature(enable = "altivec")]
1000 #[cfg_attr(test, assert_instr(vcmpgtuh.))]
1001 unsafe fn vcmpgeuh_any(a: vector_unsigned_short, b: vector_unsigned_short) -> bool {
1002 vcmpgtuh_p(3, b, a) != 0
1003 }
1004
1005 #[inline]
1006 #[target_feature(enable = "altivec")]
1007 #[cfg_attr(test, assert_instr(vcmpgtuw.))]
1008 unsafe fn vcmpgeuw_all(a: vector_unsigned_int, b: vector_unsigned_int) -> bool {
1009 vcmpgtuw_p(0, b, a) != 0
1010 }
1011
1012 #[inline]
1013 #[target_feature(enable = "altivec")]
1014 #[cfg_attr(test, assert_instr(vcmpgtuw.))]
1015 unsafe fn vcmpgeuw_any(a: vector_unsigned_int, b: vector_unsigned_int) -> bool {
1016 vcmpgtuw_p(3, b, a) != 0
1017 }
1018
1019 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1020 pub trait VectorAllGe<Other> {
1021 type Result;
1022 unsafe fn vec_all_ge(self, b: Other) -> Self::Result;
1023 }
1024
1025 impl_vec_any_all! { [VectorAllGe vec_all_ge] (
1026 vcmpgeub_all, vcmpgesb_all,
1027 vcmpgeuh_all, vcmpgesh_all,
1028 vcmpgeuw_all, vcmpgesw_all
1029 ) }
1030
1031 #[inline]
1033 #[target_feature(enable = "altivec")]
1034 #[cfg_attr(test, assert_instr(vcmpgefp.))]
1035 unsafe fn vcmpgefp_all(a: vector_float, b: vector_float) -> bool {
1036 vcmpgefp_p(2, a, b) != 0
1037 }
1038
1039 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1040 impl VectorAllGe<vector_float> for vector_float {
1041 type Result = bool;
1042 #[inline]
1043 unsafe fn vec_all_ge(self, b: vector_float) -> Self::Result {
1044 vcmpgefp_all(self, b)
1045 }
1046 }
1047
1048 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1049 pub trait VectorAnyGe<Other> {
1050 type Result;
1051 unsafe fn vec_any_ge(self, b: Other) -> Self::Result;
1052 }
1053
1054 impl_vec_any_all! { [VectorAnyGe vec_any_ge] (
1055 vcmpgeub_any, vcmpgesb_any,
1056 vcmpgeuh_any, vcmpgesh_any,
1057 vcmpgeuw_any, vcmpgesw_any
1058 ) }
1059
1060 #[inline]
1061 #[target_feature(enable = "altivec")]
1062 #[cfg_attr(test, assert_instr(vcmpgefp.))]
1063 unsafe fn vcmpgefp_any(a: vector_float, b: vector_float) -> bool {
1064 vcmpgefp_p(1, a, b) != 0
1065 }
1066
1067 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1068 impl VectorAnyGe<vector_float> for vector_float {
1069 type Result = bool;
1070 #[inline]
1071 unsafe fn vec_any_ge(self, b: vector_float) -> Self::Result {
1072 vcmpgefp_any(self, b)
1073 }
1074 }
1075
1076 #[inline]
1079 #[target_feature(enable = "altivec")]
1080 #[cfg_attr(test, assert_instr(vcmpgtsb.))]
1081 unsafe fn vcmpgtsb_all(a: vector_signed_char, b: vector_signed_char) -> bool {
1082 vcmpgtsb_p(2, a, b) != 0
1083 }
1084
1085 #[inline]
1086 #[target_feature(enable = "altivec")]
1087 #[cfg_attr(test, assert_instr(vcmpgtsb.))]
1088 unsafe fn vcmpgtsb_any(a: vector_signed_char, b: vector_signed_char) -> bool {
1089 vcmpgtsb_p(1, a, b) != 0
1090 }
1091
1092 #[inline]
1093 #[target_feature(enable = "altivec")]
1094 #[cfg_attr(test, assert_instr(vcmpgtsh.))]
1095 unsafe fn vcmpgtsh_all(a: vector_signed_short, b: vector_signed_short) -> bool {
1096 vcmpgtsh_p(2, a, b) != 0
1097 }
1098
1099 #[inline]
1100 #[target_feature(enable = "altivec")]
1101 #[cfg_attr(test, assert_instr(vcmpgtsh.))]
1102 unsafe fn vcmpgtsh_any(a: vector_signed_short, b: vector_signed_short) -> bool {
1103 vcmpgtsh_p(1, a, b) != 0
1104 }
1105
1106 #[inline]
1107 #[target_feature(enable = "altivec")]
1108 #[cfg_attr(test, assert_instr(vcmpgtsw.))]
1109 unsafe fn vcmpgtsw_all(a: vector_signed_int, b: vector_signed_int) -> bool {
1110 vcmpgtsw_p(2, a, b) != 0
1111 }
1112
1113 #[inline]
1114 #[target_feature(enable = "altivec")]
1115 #[cfg_attr(test, assert_instr(vcmpgtsw.))]
1116 unsafe fn vcmpgtsw_any(a: vector_signed_int, b: vector_signed_int) -> bool {
1117 vcmpgtsw_p(1, a, b) != 0
1118 }
1119
1120 #[inline]
1121 #[target_feature(enable = "altivec")]
1122 #[cfg_attr(test, assert_instr(vcmpgtub.))]
1123 unsafe fn vcmpgtub_all(a: vector_unsigned_char, b: vector_unsigned_char) -> bool {
1124 vcmpgtub_p(2, a, b) != 0
1125 }
1126
1127 #[inline]
1128 #[target_feature(enable = "altivec")]
1129 #[cfg_attr(test, assert_instr(vcmpgtub.))]
1130 unsafe fn vcmpgtub_any(a: vector_unsigned_char, b: vector_unsigned_char) -> bool {
1131 vcmpgtub_p(1, a, b) != 0
1132 }
1133
1134 #[inline]
1135 #[target_feature(enable = "altivec")]
1136 #[cfg_attr(test, assert_instr(vcmpgtuh.))]
1137 unsafe fn vcmpgtuh_all(a: vector_unsigned_short, b: vector_unsigned_short) -> bool {
1138 vcmpgtuh_p(2, a, b) != 0
1139 }
1140
1141 #[inline]
1142 #[target_feature(enable = "altivec")]
1143 #[cfg_attr(test, assert_instr(vcmpgtuh.))]
1144 unsafe fn vcmpgtuh_any(a: vector_unsigned_short, b: vector_unsigned_short) -> bool {
1145 vcmpgtuh_p(1, a, b) != 0
1146 }
1147
1148 #[inline]
1149 #[target_feature(enable = "altivec")]
1150 #[cfg_attr(test, assert_instr(vcmpgtuw.))]
1151 unsafe fn vcmpgtuw_all(a: vector_unsigned_int, b: vector_unsigned_int) -> bool {
1152 vcmpgtuw_p(2, a, b) != 0
1153 }
1154
1155 #[inline]
1156 #[target_feature(enable = "altivec")]
1157 #[cfg_attr(test, assert_instr(vcmpgtuw.))]
1158 unsafe fn vcmpgtuw_any(a: vector_unsigned_int, b: vector_unsigned_int) -> bool {
1159 vcmpgtuw_p(1, a, b) != 0
1160 }
1161
1162 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1163 pub trait VectorAllGt<Other> {
1164 type Result;
1165 unsafe fn vec_all_gt(self, b: Other) -> Self::Result;
1166 }
1167
1168 impl_vec_any_all! { [VectorAllGt vec_all_gt] (
1169 vcmpgtub_all, vcmpgtsb_all,
1170 vcmpgtuh_all, vcmpgtsh_all,
1171 vcmpgtuw_all, vcmpgtsw_all
1172 ) }
1173
1174 #[inline]
1176 #[target_feature(enable = "altivec")]
1177 #[cfg_attr(test, assert_instr(vcmpgtfp.))]
1178 unsafe fn vcmpgtfp_all(a: vector_float, b: vector_float) -> bool {
1179 vcmpgtfp_p(2, a, b) != 0
1180 }
1181
1182 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1183 impl VectorAllGt<vector_float> for vector_float {
1184 type Result = bool;
1185 #[inline]
1186 unsafe fn vec_all_gt(self, b: vector_float) -> Self::Result {
1187 vcmpgtfp_all(self, b)
1188 }
1189 }
1190
1191 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1192 pub trait VectorAnyGt<Other> {
1193 type Result;
1194 unsafe fn vec_any_gt(self, b: Other) -> Self::Result;
1195 }
1196
1197 impl_vec_any_all! { [VectorAnyGt vec_any_gt] (
1198 vcmpgtub_any, vcmpgtsb_any,
1199 vcmpgtuh_any, vcmpgtsh_any,
1200 vcmpgtuw_any, vcmpgtsw_any
1201 ) }
1202
1203 #[inline]
1204 #[target_feature(enable = "altivec")]
1205 #[cfg_attr(test, assert_instr(vcmpgtfp.))]
1206 unsafe fn vcmpgtfp_any(a: vector_float, b: vector_float) -> bool {
1207 vcmpgtfp_p(1, a, b) != 0
1208 }
1209
1210 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1211 impl VectorAnyGt<vector_float> for vector_float {
1212 type Result = bool;
1213 #[inline]
1214 unsafe fn vec_any_gt(self, b: vector_float) -> Self::Result {
1215 vcmpgtfp_any(self, b)
1216 }
1217 }
1218
1219 #[inline]
1222 #[target_feature(enable = "altivec")]
1223 #[cfg_attr(test, assert_instr(vcmpequb.))]
1224 unsafe fn vcmpneub_all(a: vector_unsigned_char, b: vector_unsigned_char) -> bool {
1225 vcmpequb_p(0, a, b) != 0
1226 }
1227
1228 #[inline]
1229 #[target_feature(enable = "altivec")]
1230 #[cfg_attr(test, assert_instr(vcmpequb.))]
1231 unsafe fn vcmpneub_any(a: vector_unsigned_char, b: vector_unsigned_char) -> bool {
1232 vcmpequb_p(3, a, b) != 0
1233 }
1234
1235 #[inline]
1236 #[target_feature(enable = "altivec")]
1237 #[cfg_attr(test, assert_instr(vcmpequh.))]
1238 unsafe fn vcmpneuh_all(a: vector_unsigned_short, b: vector_unsigned_short) -> bool {
1239 vcmpequh_p(0, a, b) != 0
1240 }
1241
1242 #[inline]
1243 #[target_feature(enable = "altivec")]
1244 #[cfg_attr(test, assert_instr(vcmpequh.))]
1245 unsafe fn vcmpneuh_any(a: vector_unsigned_short, b: vector_unsigned_short) -> bool {
1246 vcmpequh_p(3, a, b) != 0
1247 }
1248
1249 #[inline]
1250 #[target_feature(enable = "altivec")]
1251 #[cfg_attr(test, assert_instr(vcmpequw.))]
1252 unsafe fn vcmpneuw_all(a: vector_unsigned_int, b: vector_unsigned_int) -> bool {
1253 vcmpequw_p(0, a, b) != 0
1254 }
1255
1256 #[inline]
1257 #[target_feature(enable = "altivec")]
1258 #[cfg_attr(test, assert_instr(vcmpequw.))]
1259 unsafe fn vcmpneuw_any(a: vector_unsigned_int, b: vector_unsigned_int) -> bool {
1260 vcmpequw_p(3, a, b) != 0
1261 }
1262
1263 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1264 pub trait VectorAllNe<Other> {
1265 type Result;
1266 unsafe fn vec_all_ne(self, b: Other) -> Self::Result;
1267 }
1268
1269 impl_vec_any_all! { [VectorAllNe vec_all_ne] (vcmpneub_all, vcmpneuh_all, vcmpneuw_all) }
1270
1271 #[inline]
1273 #[target_feature(enable = "altivec")]
1274 #[cfg_attr(test, assert_instr(vcmpeqfp.))]
1275 unsafe fn vcmpnefp_all(a: vector_float, b: vector_float) -> bool {
1276 vcmpeqfp_p(0, a, b) != 0
1277 }
1278
1279 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1280 impl VectorAllNe<vector_float> for vector_float {
1281 type Result = bool;
1282 #[inline]
1283 unsafe fn vec_all_ne(self, b: vector_float) -> Self::Result {
1284 vcmpnefp_all(self, b)
1285 }
1286 }
1287
1288 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1289 pub trait VectorAnyNe<Other> {
1290 type Result;
1291 unsafe fn vec_any_ne(self, b: Other) -> Self::Result;
1292 }
1293
1294 impl_vec_any_all! { [VectorAnyNe vec_any_ne] (vcmpneub_any, vcmpneuh_any, vcmpneuw_any) }
1295
1296 #[inline]
1297 #[target_feature(enable = "altivec")]
1298 #[cfg_attr(test, assert_instr(vcmpeqfp.))]
1299 unsafe fn vcmpnefp_any(a: vector_float, b: vector_float) -> bool {
1300 vcmpeqfp_p(3, a, b) != 0
1301 }
1302
1303 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1304 impl VectorAnyNe<vector_float> for vector_float {
1305 type Result = bool;
1306 #[inline]
1307 unsafe fn vec_any_ne(self, b: vector_float) -> Self::Result {
1308 vcmpnefp_any(self, b)
1309 }
1310 }
1311
1312 test_impl! { vec_vceil(a: vector_float) -> vector_float [vceil, vrfip / xvrspip ] }
1313
1314 test_impl! { vec_vavgsb(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char [ vavgsb, vavgsb ] }
1315 test_impl! { vec_vavgsh(a: vector_signed_short, b: vector_signed_short) -> vector_signed_short [ vavgsh, vavgsh ] }
1316 test_impl! { vec_vavgsw(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int [ vavgsw, vavgsw ] }
1317 test_impl! { vec_vavgub(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char [ vavgub, vavgub ] }
1318 test_impl! { vec_vavguh(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_short [ vavguh, vavguh ] }
1319 test_impl! { vec_vavguw(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int [ vavguw, vavguw ] }
1320
1321 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1322 pub trait VectorAvg<Other> {
1323 type Result;
1324 unsafe fn vec_avg(self, b: Other) -> Self::Result;
1325 }
1326
1327 impl_vec_trait! { [VectorAvg vec_avg] 2 (vec_vavgub, vec_vavgsb, vec_vavguh, vec_vavgsh, vec_vavguw, vec_vavgsw) }
1328
1329 #[inline]
1330 #[target_feature(enable = "altivec")]
1331 #[cfg_attr(all(test, not(target_feature = "vsx")), assert_instr(vandc))]
1332 #[cfg_attr(all(test, target_feature = "vsx"), assert_instr(xxlandc))]
1333 unsafe fn andc(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char {
1334 let a = transmute(a);
1335 let b = transmute(b);
1336 transmute(simd_and(simd_xor(u8x16::splat(0xff), b), a))
1337 }
1338
1339 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1340 pub trait VectorAndc<Other> {
1341 type Result;
1342 unsafe fn vec_andc(self, b: Other) -> Self::Result;
1343 }
1344
1345 impl_vec_trait! { [VectorAndc vec_andc]+ 2b (andc) }
1346
1347 #[inline]
1348 #[target_feature(enable = "altivec")]
1349 #[cfg_attr(all(test, not(target_feature = "vsx")), assert_instr(vorc))]
1350 #[cfg_attr(all(test, target_feature = "vsx"), assert_instr(xxlorc))]
1351 unsafe fn orc(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char {
1352 let a = transmute(a);
1353 let b = transmute(b);
1354 transmute(simd_or(simd_xor(u8x16::splat(0xff), b), a))
1355 }
1356
1357 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1358 pub trait VectorOrc<Other> {
1359 type Result;
1360 unsafe fn vec_orc(self, b: Other) -> Self::Result;
1361 }
1362
1363 impl_vec_trait! { [VectorOrc vec_orc]+ 2b (orc) }
1364
1365 test_impl! { vec_vand(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char [ simd_and, vand / xxland ] }
1366
1367 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1368 pub trait VectorAnd<Other> {
1369 type Result;
1370 unsafe fn vec_and(self, b: Other) -> Self::Result;
1371 }
1372
1373 impl_vec_trait! { [VectorAnd vec_and] ~(simd_and) }
1374
1375 test_impl! { vec_vaddsbs(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char [ vaddsbs, vaddsbs ] }
1376 test_impl! { vec_vaddshs(a: vector_signed_short, b: vector_signed_short) -> vector_signed_short [ vaddshs, vaddshs ] }
1377 test_impl! { vec_vaddsws(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int [ vaddsws, vaddsws ] }
1378 test_impl! { vec_vaddubs(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char [ vaddubs, vaddubs ] }
1379 test_impl! { vec_vadduhs(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_short [ vadduhs, vadduhs ] }
1380 test_impl! { vec_vadduws(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int [ vadduws, vadduws ] }
1381
1382 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1383 pub trait VectorAdds<Other> {
1384 type Result;
1385 unsafe fn vec_adds(self, b: Other) -> Self::Result;
1386 }
1387
1388 impl_vec_trait! { [VectorAdds vec_adds] ~(vaddubs, vaddsbs, vadduhs, vaddshs, vadduws, vaddsws) }
1389
1390 test_impl! { vec_vaddcuw(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int [vaddcuw, vaddcuw] }
1391
1392 test_impl! { vec_vsubsbs(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char [ vsubsbs, vsubsbs ] }
1393 test_impl! { vec_vsubshs(a: vector_signed_short, b: vector_signed_short) -> vector_signed_short [ vsubshs, vsubshs ] }
1394 test_impl! { vec_vsubsws(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int [ vsubsws, vsubsws ] }
1395 test_impl! { vec_vsububs(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char [ vsububs, vsububs ] }
1396 test_impl! { vec_vsubuhs(a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_short [ vsubuhs, vsubuhs ] }
1397 test_impl! { vec_vsubuws(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int [ vsubuws, vsubuws ] }
1398
1399 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1400 pub trait VectorSubs<Other> {
1401 type Result;
1402 unsafe fn vec_subs(self, b: Other) -> Self::Result;
1403 }
1404
1405 impl_vec_trait! { [VectorSubs vec_subs] ~(vsububs, vsubsbs, vsubuhs, vsubshs, vsubuws, vsubsws) }
1406
1407 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1408 pub trait VectorAbs {
1409 unsafe fn vec_abs(self) -> Self;
1410 }
1411
1412 macro_rules! impl_abs {
1413 ($name:ident, $ty: ident) => {
1414 #[inline]
1415 #[target_feature(enable = "altivec")]
1416 unsafe fn $name(v: s_t_l!($ty)) -> s_t_l!($ty) {
1417 v.vec_max(-v)
1418 }
1419
1420 impl_vec_trait! { [VectorAbs vec_abs] $name (s_t_l!($ty)) }
1421 };
1422 }
1423
1424 impl_abs! { vec_abs_i8, i8x16 }
1425 impl_abs! { vec_abs_i16, i16x8 }
1426 impl_abs! { vec_abs_i32, i32x4 }
1427
1428 #[inline]
1429 #[target_feature(enable = "altivec")]
1430 unsafe fn vec_abs_f32(v: vector_float) -> vector_float {
1431 let v: u32x4 = transmute(v);
1432
1433 transmute(simd_and(v, u32x4::splat(0x7FFFFFFF)))
1434 }
1435
1436 impl_vec_trait! { [VectorAbs vec_abs] vec_abs_f32 (vector_float) }
1437
1438 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1439 pub trait VectorAbss {
1440 unsafe fn vec_abss(self) -> Self;
1441 }
1442
1443 macro_rules! impl_abss {
1444 ($name:ident, $ty: ident) => {
1445 #[inline]
1446 #[target_feature(enable = "altivec")]
1447 unsafe fn $name(v: s_t_l!($ty)) -> s_t_l!($ty) {
1448 let zero: s_t_l!($ty) = transmute(0u8.vec_splats());
1449 v.vec_max(zero.vec_subs(v))
1450 }
1451
1452 impl_vec_trait! { [VectorAbss vec_abss] $name (s_t_l!($ty)) }
1453 };
1454 }
1455
1456 impl_abss! { vec_abss_i8, i8x16 }
1457 impl_abss! { vec_abss_i16, i16x8 }
1458 impl_abss! { vec_abss_i32, i32x4 }
1459
1460 #[inline]
1461 #[target_feature(enable = "altivec")]
1462 #[cfg_attr(test, assert_instr(vspltb, IMM4 = 15))]
1463 unsafe fn vspltb<const IMM4: u32>(a: vector_signed_char) -> vector_signed_char {
1464 static_assert_uimm_bits!(IMM4, 4);
1465 let b = u8x16::splat(IMM4 as u8);
1466 vec_perm(a, a, transmute(b))
1467 }
1468
1469 #[inline]
1470 #[target_feature(enable = "altivec")]
1471 #[cfg_attr(test, assert_instr(vsplth, IMM3 = 7))]
1472 unsafe fn vsplth<const IMM3: u32>(a: vector_signed_short) -> vector_signed_short {
1473 static_assert_uimm_bits!(IMM3, 3);
1474 let b0 = IMM3 as u8 * 2;
1475 let b1 = b0 + 1;
1476 let b = u8x16::new(
1477 b0, b1, b0, b1, b0, b1, b0, b1, b0, b1, b0, b1, b0, b1, b0, b1,
1478 );
1479 vec_perm(a, a, transmute(b))
1480 }
1481
1482 #[inline]
1483 #[target_feature(enable = "altivec")]
1484 #[cfg_attr(all(test, not(target_feature = "vsx")), assert_instr(vspltw, IMM2 = 3))]
1485 #[cfg_attr(all(test, target_feature = "vsx"), assert_instr(xxspltw, IMM2 = 3))]
1486 unsafe fn vspltw<const IMM2: u32>(a: vector_signed_int) -> vector_signed_int {
1487 static_assert_uimm_bits!(IMM2, 2);
1488 let b0 = IMM2 as u8 * 4;
1489 let b1 = b0 + 1;
1490 let b2 = b0 + 2;
1491 let b3 = b0 + 3;
1492 let b = u8x16::new(
1493 b0, b1, b2, b3, b0, b1, b2, b3, b0, b1, b2, b3, b0, b1, b2, b3,
1494 );
1495 vec_perm(a, a, transmute(b))
1496 }
1497
1498 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1499 pub trait VectorSplat {
1500 unsafe fn vec_splat<const IMM: u32>(self) -> Self;
1501 }
1502
1503 macro_rules! impl_vec_splat {
1504 ($ty:ty, $fun:ident) => {
1505 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1506 impl VectorSplat for $ty {
1507 #[inline]
1508 #[target_feature(enable = "altivec")]
1509 unsafe fn vec_splat<const IMM: u32>(self) -> Self {
1510 transmute($fun::<IMM>(transmute(self)))
1511 }
1512 }
1513 };
1514 }
1515
1516 impl_vec_splat! { vector_signed_char, vspltb }
1517 impl_vec_splat! { vector_unsigned_char, vspltb }
1518 impl_vec_splat! { vector_bool_char, vspltb }
1519 impl_vec_splat! { vector_signed_short, vsplth }
1520 impl_vec_splat! { vector_unsigned_short, vsplth }
1521 impl_vec_splat! { vector_bool_short, vsplth }
1522 impl_vec_splat! { vector_signed_int, vspltw }
1523 impl_vec_splat! { vector_unsigned_int, vspltw }
1524 impl_vec_splat! { vector_bool_int, vspltw }
1525
1526 macro_rules! splat {
1527 ($name:ident, $v:ident, $r:ident [$instr_altivec:ident / $instr_pwr9:ident, $doc:literal]) => {
1528 #[doc = $doc]
1529 #[inline]
1530 #[target_feature(enable = "altivec")]
1531 #[cfg_attr(
1532 all(test, not(target_feature = "vsx")),
1533 assert_instr($instr_altivec, IMM5 = 1)
1534 )]
1535 #[cfg_attr(
1536 all(test, target_feature = "power9-vector"),
1537 assert_instr($instr_pwr9, IMM5 = 1)
1538 )]
1539 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1540 pub unsafe fn $name<const IMM5: i8>() -> s_t_l!($r) {
1541 static_assert_simm_bits!(IMM5, 5);
1542 transmute($r::splat(IMM5 as $v))
1543 }
1544 };
1545 ($name:ident, $v:ident, $r:ident [$instr:ident, $doc:literal]) => {
1546 splat! { $name, $v, $r [$instr / $instr, $doc] }
1547 };
1548 }
1549
1550 macro_rules! splats {
1551 ($name:ident, $v:ident, $r:ident) => {
1552 #[inline]
1553 #[target_feature(enable = "altivec")]
1554 unsafe fn $name(v: $v) -> s_t_l!($r) {
1555 transmute($r::splat(v))
1556 }
1557 };
1558 }
1559
1560 splats! { splats_u8, u8, u8x16 }
1561 splats! { splats_u16, u16, u16x8 }
1562 splats! { splats_u32, u32, u32x4 }
1563 splats! { splats_i8, i8, i8x16 }
1564 splats! { splats_i16, i16, i16x8 }
1565 splats! { splats_i32, i32, i32x4 }
1566 splats! { splats_f32, f32, f32x4 }
1567
1568 test_impl! { vec_splats_u8 (v: u8) -> vector_unsigned_char [splats_u8, vspltb] }
1569 test_impl! { vec_splats_u16 (v: u16) -> vector_unsigned_short [splats_u16, vsplth] }
1570 test_impl! { vec_splats_u32 (v: u32) -> vector_unsigned_int [splats_u32, vspltw / xxspltw / mtvsrws] }
1571 test_impl! { vec_splats_i8 (v: i8) -> vector_signed_char [splats_i8, vspltb] }
1572 test_impl! { vec_splats_i16 (v: i16) -> vector_signed_short [splats_i16, vsplth] }
1573 test_impl! { vec_splats_i32 (v: i32) -> vector_signed_int [splats_i32, vspltw / xxspltw / mtvsrws] }
1574 test_impl! { vec_splats_f32 (v: f32) -> vector_float [splats_f32, vspltw / xxspltw / mtvsrws] }
1575
1576 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1577 pub trait VectorSplats {
1578 type Result;
1579 unsafe fn vec_splats(self) -> Self::Result;
1580 }
1581
1582 macro_rules! impl_vec_splats {
1583 ($(($fn:ident ($ty:ty) -> $r:ty)),*) => {
1584 $(
1585 impl_vec_trait!{ [VectorSplats vec_splats] $fn ($ty) -> $r }
1586 )*
1587 }
1588 }
1589
1590 impl_vec_splats! {
1591 (vec_splats_u8 (u8) -> vector_unsigned_char),
1592 (vec_splats_i8 (i8) -> vector_signed_char),
1593 (vec_splats_u16 (u16) -> vector_unsigned_short),
1594 (vec_splats_i16 (i16) -> vector_signed_short),
1595 (vec_splats_u32 (u32) -> vector_unsigned_int),
1596 (vec_splats_i32 (i32) -> vector_signed_int),
1597 (vec_splats_f32 (f32) -> vector_float)
1598 }
1599
1600 test_impl! { vec_vsububm (a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char [simd_sub, vsububm] }
1601 test_impl! { vec_vsubuhm (a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_short [simd_sub, vsubuhm] }
1602 test_impl! { vec_vsubuwm (a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int [simd_sub, vsubuwm] }
1603
1604 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1605 pub trait VectorSub<Other> {
1606 type Result;
1607 unsafe fn vec_sub(self, b: Other) -> Self::Result;
1608 }
1609
1610 impl_vec_trait! { [VectorSub vec_sub] ~(simd_sub, simd_sub, simd_sub, simd_sub, simd_sub, simd_sub) }
1611 impl_vec_trait! { [VectorSub vec_sub] simd_sub(vector_float, vector_float) -> vector_float }
1612
1613 test_impl! { vec_vsubcuw (a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int [vsubcuw, vsubcuw] }
1614
1615 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1616 pub trait VectorSubc<Other> {
1617 type Result;
1618 unsafe fn vec_subc(self, b: Other) -> Self::Result;
1619 }
1620
1621 impl_vec_trait! {[VectorSubc vec_subc]+ vec_vsubcuw(vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_int }
1622 impl_vec_trait! {[VectorSubc vec_subc]+ vec_vsubcuw(vector_signed_int, vector_signed_int) -> vector_signed_int }
1623
1624 test_impl! { vec_vminsb (a: vector_signed_char, b: vector_signed_char) -> vector_signed_char [vminsb, vminsb] }
1625 test_impl! { vec_vminsh (a: vector_signed_short, b: vector_signed_short) -> vector_signed_short [vminsh, vminsh] }
1626 test_impl! { vec_vminsw (a: vector_signed_int, b: vector_signed_int) -> vector_signed_int [vminsw, vminsw] }
1627
1628 test_impl! { vec_vminub (a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char [vminub, vminub] }
1629 test_impl! { vec_vminuh (a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_short [vminuh, vminuh] }
1630 test_impl! { vec_vminuw (a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int [vminuw, vminuw] }
1631
1632 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1633 pub trait VectorMin<Other> {
1634 type Result;
1635 unsafe fn vec_min(self, b: Other) -> Self::Result;
1636 }
1637
1638 impl_vec_trait! { [VectorMin vec_min] ~(vminub, vminsb, vminuh, vminsh, vminuw, vminsw) }
1639
1640 test_impl! { vec_vmaxsb (a: vector_signed_char, b: vector_signed_char) -> vector_signed_char [vmaxsb, vmaxsb] }
1641 test_impl! { vec_vmaxsh (a: vector_signed_short, b: vector_signed_short) -> vector_signed_short [vmaxsh, vmaxsh] }
1642 test_impl! { vec_vmaxsw (a: vector_signed_int, b: vector_signed_int) -> vector_signed_int [vmaxsw, vmaxsw] }
1643
1644 test_impl! { vec_vmaxub (a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char [vmaxub, vmaxub] }
1645 test_impl! { vec_vmaxuh (a: vector_unsigned_short, b: vector_unsigned_short) -> vector_unsigned_short [vmaxuh, vmaxuh] }
1646 test_impl! { vec_vmaxuw (a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int [vmaxuw, vmaxuw] }
1647
1648 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1649 pub trait VectorMax<Other> {
1650 type Result;
1651 unsafe fn vec_max(self, b: Other) -> Self::Result;
1652 }
1653
1654 impl_vec_trait! { [VectorMax vec_max] ~(vmaxub, vmaxsb, vmaxuh, vmaxsh, vmaxuw, vmaxsw) }
1655
1656 #[inline]
1657 #[target_feature(enable = "altivec")]
1658 #[cfg_attr(test, assert_instr(vmuleub))]
1659 unsafe fn vec_vmuleub(
1660 a: vector_unsigned_char,
1661 b: vector_unsigned_char,
1662 ) -> vector_unsigned_short {
1663 vmuleub(a, b)
1664 }
1665 #[inline]
1666 #[target_feature(enable = "altivec")]
1667 #[cfg_attr(test, assert_instr(vmulesb))]
1668 unsafe fn vec_vmulesb(a: vector_signed_char, b: vector_signed_char) -> vector_signed_short {
1669 vmulesb(a, b)
1670 }
1671 #[inline]
1672 #[target_feature(enable = "altivec")]
1673 #[cfg_attr(test, assert_instr(vmuleuh))]
1674 unsafe fn vec_vmuleuh(
1675 a: vector_unsigned_short,
1676 b: vector_unsigned_short,
1677 ) -> vector_unsigned_int {
1678 vmuleuh(a, b)
1679 }
1680 #[inline]
1681 #[target_feature(enable = "altivec")]
1682 #[cfg_attr(test, assert_instr(vmulesh))]
1683 unsafe fn vec_vmulesh(a: vector_signed_short, b: vector_signed_short) -> vector_signed_int {
1684 vmulesh(a, b)
1685 }
1686
1687 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1688 pub trait VectorMul {
1689 unsafe fn vec_mul(self, b: Self) -> Self;
1690 }
1691
1692 #[inline]
1693 #[target_feature(enable = "altivec")]
1694 #[cfg_attr(test, assert_instr(vmuluwm))]
1695 unsafe fn vec_vmuluwm(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int {
1696 transmute(simd_mul::<i32x4>(transmute(a), transmute(b)))
1697 }
1698
1699 #[inline]
1700 #[target_feature(enable = "altivec")]
1701 #[cfg_attr(test, assert_instr(xvmulsp))]
1702 unsafe fn vec_xvmulsp(a: vector_float, b: vector_float) -> vector_float {
1703 transmute(simd_mul::<f32x4>(transmute(a), transmute(b)))
1704 }
1705
1706 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1707 impl VectorMul for vector_signed_int {
1708 #[inline]
1709 #[target_feature(enable = "altivec")]
1710 unsafe fn vec_mul(self, b: Self) -> Self {
1711 vec_vmuluwm(self, b)
1712 }
1713 }
1714
1715 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1716 impl VectorMul for vector_unsigned_int {
1717 #[inline]
1718 #[target_feature(enable = "altivec")]
1719 unsafe fn vec_mul(self, b: Self) -> Self {
1720 transmute(simd_mul::<u32x4>(transmute(self), transmute(b)))
1721 }
1722 }
1723
1724 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1725 impl VectorMul for vector_float {
1726 #[inline]
1727 #[target_feature(enable = "altivec")]
1728 unsafe fn vec_mul(self, b: Self) -> Self {
1729 vec_xvmulsp(self, b)
1730 }
1731 }
1732
1733 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1734 pub trait VectorMule<Result> {
1735 unsafe fn vec_mule(self, b: Self) -> Result;
1736 }
1737
1738 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1739 impl VectorMule<vector_unsigned_short> for vector_unsigned_char {
1740 #[inline]
1741 #[target_feature(enable = "altivec")]
1742 unsafe fn vec_mule(self, b: Self) -> vector_unsigned_short {
1743 vmuleub(self, b)
1744 }
1745 }
1746 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1747 impl VectorMule<vector_signed_short> for vector_signed_char {
1748 #[inline]
1749 #[target_feature(enable = "altivec")]
1750 unsafe fn vec_mule(self, b: Self) -> vector_signed_short {
1751 vmulesb(self, b)
1752 }
1753 }
1754 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1755 impl VectorMule<vector_unsigned_int> for vector_unsigned_short {
1756 #[inline]
1757 #[target_feature(enable = "altivec")]
1758 unsafe fn vec_mule(self, b: Self) -> vector_unsigned_int {
1759 vmuleuh(self, b)
1760 }
1761 }
1762 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1763 impl VectorMule<vector_signed_int> for vector_signed_short {
1764 #[inline]
1765 #[target_feature(enable = "altivec")]
1766 unsafe fn vec_mule(self, b: Self) -> vector_signed_int {
1767 vmulesh(self, b)
1768 }
1769 }
1770
1771 #[inline]
1772 #[target_feature(enable = "altivec")]
1773 #[cfg_attr(test, assert_instr(vmuloub))]
1774 unsafe fn vec_vmuloub(
1775 a: vector_unsigned_char,
1776 b: vector_unsigned_char,
1777 ) -> vector_unsigned_short {
1778 vmuloub(a, b)
1779 }
1780 #[inline]
1781 #[target_feature(enable = "altivec")]
1782 #[cfg_attr(test, assert_instr(vmulosb))]
1783 unsafe fn vec_vmulosb(a: vector_signed_char, b: vector_signed_char) -> vector_signed_short {
1784 vmulosb(a, b)
1785 }
1786 #[inline]
1787 #[target_feature(enable = "altivec")]
1788 #[cfg_attr(test, assert_instr(vmulouh))]
1789 unsafe fn vec_vmulouh(
1790 a: vector_unsigned_short,
1791 b: vector_unsigned_short,
1792 ) -> vector_unsigned_int {
1793 vmulouh(a, b)
1794 }
1795 #[inline]
1796 #[target_feature(enable = "altivec")]
1797 #[cfg_attr(test, assert_instr(vmulosh))]
1798 unsafe fn vec_vmulosh(a: vector_signed_short, b: vector_signed_short) -> vector_signed_int {
1799 vmulosh(a, b)
1800 }
1801
1802 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1803 pub trait VectorMulo<Result> {
1804 unsafe fn vec_mulo(self, b: Self) -> Result;
1805 }
1806
1807 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1808 impl VectorMulo<vector_unsigned_short> for vector_unsigned_char {
1809 #[inline]
1810 #[target_feature(enable = "altivec")]
1811 unsafe fn vec_mulo(self, b: Self) -> vector_unsigned_short {
1812 vmuloub(self, b)
1813 }
1814 }
1815 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1816 impl VectorMulo<vector_signed_short> for vector_signed_char {
1817 #[inline]
1818 #[target_feature(enable = "altivec")]
1819 unsafe fn vec_mulo(self, b: Self) -> vector_signed_short {
1820 vmulosb(self, b)
1821 }
1822 }
1823 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1824 impl VectorMulo<vector_unsigned_int> for vector_unsigned_short {
1825 #[inline]
1826 #[target_feature(enable = "altivec")]
1827 unsafe fn vec_mulo(self, b: Self) -> vector_unsigned_int {
1828 vmulouh(self, b)
1829 }
1830 }
1831 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1832 impl VectorMulo<vector_signed_int> for vector_signed_short {
1833 #[inline]
1834 #[target_feature(enable = "altivec")]
1835 unsafe fn vec_mulo(self, b: Self) -> vector_signed_int {
1836 vmulosh(self, b)
1837 }
1838 }
1839
1840 #[inline]
1841 #[target_feature(enable = "altivec")]
1842 #[cfg_attr(test, assert_instr(vsum4ubs))]
1843 unsafe fn vec_vsum4ubs(a: vector_unsigned_char, b: vector_unsigned_int) -> vector_unsigned_int {
1844 vsum4ubs(a, b)
1845 }
1846
1847 #[inline]
1848 #[target_feature(enable = "altivec")]
1849 #[cfg_attr(test, assert_instr(vsum4sbs))]
1850 unsafe fn vec_vsum4sbs(a: vector_signed_char, b: vector_signed_int) -> vector_signed_int {
1851 vsum4sbs(a, b)
1852 }
1853
1854 #[inline]
1855 #[target_feature(enable = "altivec")]
1856 #[cfg_attr(test, assert_instr(vsum4shs))]
1857 unsafe fn vec_vsum4shs(a: vector_signed_short, b: vector_signed_int) -> vector_signed_int {
1858 vsum4shs(a, b)
1859 }
1860
1861 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1862 pub trait VectorSum4s<Other> {
1863 unsafe fn vec_sum4s(self, b: Other) -> Other;
1864 }
1865
1866 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1867 impl VectorSum4s<vector_unsigned_int> for vector_unsigned_char {
1868 #[inline]
1869 #[target_feature(enable = "altivec")]
1870 unsafe fn vec_sum4s(self, b: vector_unsigned_int) -> vector_unsigned_int {
1871 vsum4ubs(self, b)
1872 }
1873 }
1874
1875 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1876 impl VectorSum4s<vector_signed_int> for vector_signed_char {
1877 #[inline]
1878 #[target_feature(enable = "altivec")]
1879 unsafe fn vec_sum4s(self, b: vector_signed_int) -> vector_signed_int {
1880 vsum4sbs(self, b)
1881 }
1882 }
1883
1884 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1885 impl VectorSum4s<vector_signed_int> for vector_signed_short {
1886 #[inline]
1887 #[target_feature(enable = "altivec")]
1888 unsafe fn vec_sum4s(self, b: vector_signed_int) -> vector_signed_int {
1889 vsum4shs(self, b)
1890 }
1891 }
1892
1893 #[inline]
1894 #[target_feature(enable = "altivec")]
1895 #[cfg_attr(test, assert_instr(vsum2sws))]
1896 unsafe fn vec_vsum2sws(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int {
1897 vsum2sws(a, b)
1898 }
1899
1900 #[inline]
1901 #[target_feature(enable = "altivec")]
1902 #[cfg_attr(test, assert_instr(vnmsubfp))]
1903 unsafe fn vec_vnmsubfp(a: vector_float, b: vector_float, c: vector_float) -> vector_float {
1904 vnmsubfp(a, b, c)
1905 }
1906
1907 #[inline]
1908 #[target_feature(enable = "altivec")]
1909 #[cfg_attr(test, assert_instr(vmaddfp))]
1910 unsafe fn vec_vmaddfp(a: vector_float, b: vector_float, c: vector_float) -> vector_float {
1911 vmaddfp(a, b, c)
1912 }
1913
1914 #[inline]
1915 #[target_feature(enable = "altivec")]
1916 #[cfg_attr(test, assert_instr(vmsumubm))]
1917 unsafe fn vec_vmsumubm(
1918 a: vector_unsigned_char,
1919 b: vector_unsigned_char,
1920 c: vector_unsigned_int,
1921 ) -> vector_unsigned_int {
1922 vmsumubm(a, b, c)
1923 }
1924
1925 #[inline]
1926 #[target_feature(enable = "altivec")]
1927 #[cfg_attr(test, assert_instr(vmsummbm))]
1928 unsafe fn vec_vmsummbm(
1929 a: vector_signed_char,
1930 b: vector_unsigned_char,
1931 c: vector_signed_int,
1932 ) -> vector_signed_int {
1933 vmsummbm(a, b, c)
1934 }
1935
1936 #[inline]
1937 #[target_feature(enable = "altivec")]
1938 #[cfg_attr(test, assert_instr(vmsumuhm))]
1939 unsafe fn vec_vmsumuhm(
1940 a: vector_unsigned_short,
1941 b: vector_unsigned_short,
1942 c: vector_unsigned_int,
1943 ) -> vector_unsigned_int {
1944 vmsumuhm(a, b, c)
1945 }
1946
1947 #[inline]
1948 #[target_feature(enable = "altivec")]
1949 #[cfg_attr(test, assert_instr(vmsumshm))]
1950 unsafe fn vec_vmsumshm(
1951 a: vector_signed_short,
1952 b: vector_signed_short,
1953 c: vector_signed_int,
1954 ) -> vector_signed_int {
1955 vmsumshm(a, b, c)
1956 }
1957
1958 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1959 pub trait VectorMsum<B, Other> {
1960 unsafe fn vec_msum(self, b: B, c: Other) -> Other;
1961 }
1962
1963 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1964 impl VectorMsum<vector_unsigned_char, vector_unsigned_int> for vector_unsigned_char {
1965 #[inline]
1966 #[target_feature(enable = "altivec")]
1967 unsafe fn vec_msum(
1968 self,
1969 b: vector_unsigned_char,
1970 c: vector_unsigned_int,
1971 ) -> vector_unsigned_int {
1972 vmsumubm(self, b, c)
1973 }
1974 }
1975
1976 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1977 impl VectorMsum<vector_unsigned_char, vector_signed_int> for vector_signed_char {
1978 #[inline]
1979 #[target_feature(enable = "altivec")]
1980 unsafe fn vec_msum(
1981 self,
1982 b: vector_unsigned_char,
1983 c: vector_signed_int,
1984 ) -> vector_signed_int {
1985 vmsummbm(self, b, c)
1986 }
1987 }
1988
1989 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
1990 impl VectorMsum<vector_unsigned_short, vector_unsigned_int> for vector_unsigned_short {
1991 #[inline]
1992 #[target_feature(enable = "altivec")]
1993 unsafe fn vec_msum(
1994 self,
1995 b: vector_unsigned_short,
1996 c: vector_unsigned_int,
1997 ) -> vector_unsigned_int {
1998 vmsumuhm(self, b, c)
1999 }
2000 }
2001
2002 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2003 impl VectorMsum<vector_signed_short, vector_signed_int> for vector_signed_short {
2004 #[inline]
2005 #[target_feature(enable = "altivec")]
2006 unsafe fn vec_msum(
2007 self,
2008 b: vector_signed_short,
2009 c: vector_signed_int,
2010 ) -> vector_signed_int {
2011 vmsumshm(self, b, c)
2012 }
2013 }
2014
2015 #[inline]
2016 #[target_feature(enable = "altivec")]
2017 #[cfg_attr(test, assert_instr(vmsumuhs))]
2018 unsafe fn vec_vmsumuhs(
2019 a: vector_unsigned_short,
2020 b: vector_unsigned_short,
2021 c: vector_unsigned_int,
2022 ) -> vector_unsigned_int {
2023 vmsumuhs(a, b, c)
2024 }
2025
2026 #[inline]
2027 #[target_feature(enable = "altivec")]
2028 #[cfg_attr(test, assert_instr(vmsumshs))]
2029 unsafe fn vec_vmsumshs(
2030 a: vector_signed_short,
2031 b: vector_signed_short,
2032 c: vector_signed_int,
2033 ) -> vector_signed_int {
2034 vmsumshs(a, b, c)
2035 }
2036
2037 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2038 pub trait VectorMsums<Other> {
2039 unsafe fn vec_msums(self, b: Self, c: Other) -> Other;
2040 }
2041
2042 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2043 impl VectorMsums<vector_unsigned_int> for vector_unsigned_short {
2044 #[inline]
2045 #[target_feature(enable = "altivec")]
2046 unsafe fn vec_msums(self, b: Self, c: vector_unsigned_int) -> vector_unsigned_int {
2047 vmsumuhs(self, b, c)
2048 }
2049 }
2050
2051 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2052 impl VectorMsums<vector_signed_int> for vector_signed_short {
2053 #[inline]
2054 #[target_feature(enable = "altivec")]
2055 unsafe fn vec_msums(self, b: Self, c: vector_signed_int) -> vector_signed_int {
2056 vmsumshs(self, b, c)
2057 }
2058 }
2059
2060 #[inline]
2061 #[target_feature(enable = "altivec")]
2062 #[cfg_attr(test, assert_instr(vperm))]
2063 unsafe fn vec_vperm(
2064 a: vector_signed_int,
2065 b: vector_signed_int,
2066 c: vector_unsigned_char,
2067 ) -> vector_signed_int {
2068 vperm(a, b, c)
2069 }
2070
2071 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2072 pub trait VectorPerm {
2073 unsafe fn vec_vperm(self, b: Self, c: vector_unsigned_char) -> Self;
2074 }
2075
2076 macro_rules! vector_perm {
2077 {$impl: ident} => {
2078 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2079 impl VectorPerm for $impl {
2080 #[inline]
2081 #[target_feature(enable = "altivec")]
2082 unsafe fn vec_vperm(self, b: Self, c: vector_unsigned_char) -> Self {
2083 transmute(vec_vperm(transmute(self), transmute(b), c))
2084 }
2085 }
2086 }
2087 }
2088
2089 vector_perm! { vector_signed_char }
2090 vector_perm! { vector_unsigned_char }
2091 vector_perm! { vector_bool_char }
2092
2093 vector_perm! { vector_signed_short }
2094 vector_perm! { vector_unsigned_short }
2095 vector_perm! { vector_bool_short }
2096
2097 vector_perm! { vector_signed_int }
2098 vector_perm! { vector_unsigned_int }
2099 vector_perm! { vector_bool_int }
2100
2101 vector_perm! { vector_float }
2102
2103 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2104 pub trait VectorAdd<Other> {
2105 type Result;
2106 unsafe fn vec_add(self, other: Other) -> Self::Result;
2107 }
2108
2109 #[inline]
2110 #[target_feature(enable = "altivec")]
2111 #[cfg_attr(test, assert_instr(vaddubm))]
2112 pub unsafe fn vec_add_bc_sc(a: vector_bool_char, b: vector_signed_char) -> vector_signed_char {
2113 simd_add(transmute(a), b)
2114 }
2115 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2116 impl VectorAdd<vector_signed_char> for vector_bool_char {
2117 type Result = vector_signed_char;
2118 #[inline]
2119 #[target_feature(enable = "altivec")]
2120 unsafe fn vec_add(self, other: vector_signed_char) -> Self::Result {
2121 vec_add_bc_sc(self, other)
2122 }
2123 }
2124 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2125 impl VectorAdd<vector_bool_char> for vector_signed_char {
2126 type Result = vector_signed_char;
2127 #[inline]
2128 #[target_feature(enable = "altivec")]
2129 unsafe fn vec_add(self, other: vector_bool_char) -> Self::Result {
2130 other.vec_add(self)
2131 }
2132 }
2133
2134 #[inline]
2135 #[target_feature(enable = "altivec")]
2136 #[cfg_attr(test, assert_instr(vaddubm))]
2137 pub unsafe fn vec_add_sc_sc(
2138 a: vector_signed_char,
2139 b: vector_signed_char,
2140 ) -> vector_signed_char {
2141 simd_add(a, b)
2142 }
2143 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2144 impl VectorAdd<vector_signed_char> for vector_signed_char {
2145 type Result = vector_signed_char;
2146 #[inline]
2147 #[target_feature(enable = "altivec")]
2148 unsafe fn vec_add(self, other: vector_signed_char) -> Self::Result {
2149 vec_add_sc_sc(self, other)
2150 }
2151 }
2152
2153 #[inline]
2154 #[target_feature(enable = "altivec")]
2155 #[cfg_attr(test, assert_instr(vaddubm))]
2156 pub unsafe fn vec_add_bc_uc(
2157 a: vector_bool_char,
2158 b: vector_unsigned_char,
2159 ) -> vector_unsigned_char {
2160 simd_add(transmute(a), b)
2161 }
2162 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2163 impl VectorAdd<vector_unsigned_char> for vector_bool_char {
2164 type Result = vector_unsigned_char;
2165 #[inline]
2166 #[target_feature(enable = "altivec")]
2167 unsafe fn vec_add(self, other: vector_unsigned_char) -> Self::Result {
2168 vec_add_bc_uc(self, other)
2169 }
2170 }
2171 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2172 impl VectorAdd<vector_bool_char> for vector_unsigned_char {
2173 type Result = vector_unsigned_char;
2174 #[inline]
2175 #[target_feature(enable = "altivec")]
2176 unsafe fn vec_add(self, other: vector_bool_char) -> Self::Result {
2177 other.vec_add(self)
2178 }
2179 }
2180
2181 #[inline]
2182 #[target_feature(enable = "altivec")]
2183 #[cfg_attr(test, assert_instr(vaddubm))]
2184 pub unsafe fn vec_add_uc_uc(
2185 a: vector_unsigned_char,
2186 b: vector_unsigned_char,
2187 ) -> vector_unsigned_char {
2188 simd_add(a, b)
2189 }
2190 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2191 impl VectorAdd<vector_unsigned_char> for vector_unsigned_char {
2192 type Result = vector_unsigned_char;
2193 #[inline]
2194 #[target_feature(enable = "altivec")]
2195 unsafe fn vec_add(self, other: vector_unsigned_char) -> Self::Result {
2196 vec_add_uc_uc(self, other)
2197 }
2198 }
2199
2200 #[inline]
2201 #[target_feature(enable = "altivec")]
2202 #[cfg_attr(test, assert_instr(vadduhm))]
2203 pub unsafe fn vec_add_bs_ss(
2204 a: vector_bool_short,
2205 b: vector_signed_short,
2206 ) -> vector_signed_short {
2207 let a: i16x8 = transmute(a);
2208 let a: vector_signed_short = simd_cast(a);
2209 simd_add(a, b)
2210 }
2211
2212 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2213 impl VectorAdd<vector_signed_short> for vector_bool_short {
2214 type Result = vector_signed_short;
2215 #[inline]
2216 #[target_feature(enable = "altivec")]
2217 unsafe fn vec_add(self, other: vector_signed_short) -> Self::Result {
2218 vec_add_bs_ss(self, other)
2219 }
2220 }
2221 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2222 impl VectorAdd<vector_bool_short> for vector_signed_short {
2223 type Result = vector_signed_short;
2224 #[inline]
2225 #[target_feature(enable = "altivec")]
2226 unsafe fn vec_add(self, other: vector_bool_short) -> Self::Result {
2227 other.vec_add(self)
2228 }
2229 }
2230
2231 #[inline]
2232 #[target_feature(enable = "altivec")]
2233 #[cfg_attr(test, assert_instr(vadduhm))]
2234 pub unsafe fn vec_add_ss_ss(
2235 a: vector_signed_short,
2236 b: vector_signed_short,
2237 ) -> vector_signed_short {
2238 simd_add(a, b)
2239 }
2240 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2241 impl VectorAdd<vector_signed_short> for vector_signed_short {
2242 type Result = vector_signed_short;
2243 #[inline]
2244 #[target_feature(enable = "altivec")]
2245 unsafe fn vec_add(self, other: vector_signed_short) -> Self::Result {
2246 vec_add_ss_ss(self, other)
2247 }
2248 }
2249
2250 #[inline]
2251 #[target_feature(enable = "altivec")]
2252 #[cfg_attr(test, assert_instr(vadduhm))]
2253 pub unsafe fn vec_add_bs_us(
2254 a: vector_bool_short,
2255 b: vector_unsigned_short,
2256 ) -> vector_unsigned_short {
2257 let a: i16x8 = transmute(a);
2258 let a: vector_unsigned_short = simd_cast(a);
2259 simd_add(a, b)
2260 }
2261 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2262 impl VectorAdd<vector_unsigned_short> for vector_bool_short {
2263 type Result = vector_unsigned_short;
2264 #[inline]
2265 #[target_feature(enable = "altivec")]
2266 unsafe fn vec_add(self, other: vector_unsigned_short) -> Self::Result {
2267 vec_add_bs_us(self, other)
2268 }
2269 }
2270 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2271 impl VectorAdd<vector_bool_short> for vector_unsigned_short {
2272 type Result = vector_unsigned_short;
2273 #[inline]
2274 #[target_feature(enable = "altivec")]
2275 unsafe fn vec_add(self, other: vector_bool_short) -> Self::Result {
2276 other.vec_add(self)
2277 }
2278 }
2279
2280 #[inline]
2281 #[target_feature(enable = "altivec")]
2282 #[cfg_attr(test, assert_instr(vadduhm))]
2283 pub unsafe fn vec_add_us_us(
2284 a: vector_unsigned_short,
2285 b: vector_unsigned_short,
2286 ) -> vector_unsigned_short {
2287 simd_add(a, b)
2288 }
2289
2290 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2291 impl VectorAdd<vector_unsigned_short> for vector_unsigned_short {
2292 type Result = vector_unsigned_short;
2293 #[inline]
2294 #[target_feature(enable = "altivec")]
2295 unsafe fn vec_add(self, other: vector_unsigned_short) -> Self::Result {
2296 vec_add_us_us(self, other)
2297 }
2298 }
2299
2300 #[inline]
2301 #[target_feature(enable = "altivec")]
2302 #[cfg_attr(test, assert_instr(vadduwm))]
2303 pub unsafe fn vec_add_bi_si(a: vector_bool_int, b: vector_signed_int) -> vector_signed_int {
2304 let a: i32x4 = transmute(a);
2305 let a: vector_signed_int = simd_cast(a);
2306 simd_add(a, b)
2307 }
2308 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2309 impl VectorAdd<vector_signed_int> for vector_bool_int {
2310 type Result = vector_signed_int;
2311 #[inline]
2312 #[target_feature(enable = "altivec")]
2313 unsafe fn vec_add(self, other: vector_signed_int) -> Self::Result {
2314 vec_add_bi_si(self, other)
2315 }
2316 }
2317 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2318 impl VectorAdd<vector_bool_int> for vector_signed_int {
2319 type Result = vector_signed_int;
2320 #[inline]
2321 #[target_feature(enable = "altivec")]
2322 unsafe fn vec_add(self, other: vector_bool_int) -> Self::Result {
2323 other.vec_add(self)
2324 }
2325 }
2326
2327 #[inline]
2328 #[target_feature(enable = "altivec")]
2329 #[cfg_attr(test, assert_instr(vadduwm))]
2330 pub unsafe fn vec_add_si_si(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int {
2331 simd_add(a, b)
2332 }
2333 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2334 impl VectorAdd<vector_signed_int> for vector_signed_int {
2335 type Result = vector_signed_int;
2336 #[inline]
2337 #[target_feature(enable = "altivec")]
2338 unsafe fn vec_add(self, other: vector_signed_int) -> Self::Result {
2339 vec_add_si_si(self, other)
2340 }
2341 }
2342
2343 #[inline]
2344 #[target_feature(enable = "altivec")]
2345 #[cfg_attr(test, assert_instr(vadduwm))]
2346 pub unsafe fn vec_add_bi_ui(a: vector_bool_int, b: vector_unsigned_int) -> vector_unsigned_int {
2347 let a: i32x4 = transmute(a);
2348 let a: vector_unsigned_int = simd_cast(a);
2349 simd_add(a, b)
2350 }
2351 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2352 impl VectorAdd<vector_unsigned_int> for vector_bool_int {
2353 type Result = vector_unsigned_int;
2354 #[inline]
2355 #[target_feature(enable = "altivec")]
2356 unsafe fn vec_add(self, other: vector_unsigned_int) -> Self::Result {
2357 vec_add_bi_ui(self, other)
2358 }
2359 }
2360 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2361 impl VectorAdd<vector_bool_int> for vector_unsigned_int {
2362 type Result = vector_unsigned_int;
2363 #[inline]
2364 #[target_feature(enable = "altivec")]
2365 unsafe fn vec_add(self, other: vector_bool_int) -> Self::Result {
2366 other.vec_add(self)
2367 }
2368 }
2369
2370 #[inline]
2371 #[target_feature(enable = "altivec")]
2372 #[cfg_attr(test, assert_instr(vadduwm))]
2373 pub unsafe fn vec_add_ui_ui(
2374 a: vector_unsigned_int,
2375 b: vector_unsigned_int,
2376 ) -> vector_unsigned_int {
2377 simd_add(a, b)
2378 }
2379 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2380 impl VectorAdd<vector_unsigned_int> for vector_unsigned_int {
2381 type Result = vector_unsigned_int;
2382 #[inline]
2383 #[target_feature(enable = "altivec")]
2384 unsafe fn vec_add(self, other: vector_unsigned_int) -> Self::Result {
2385 vec_add_ui_ui(self, other)
2386 }
2387 }
2388
2389 #[inline]
2390 #[target_feature(enable = "altivec")]
2391 #[cfg_attr(test, assert_instr(xvaddsp))]
2392 pub unsafe fn vec_add_float_float(a: vector_float, b: vector_float) -> vector_float {
2393 simd_add(a, b)
2394 }
2395
2396 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2397 impl VectorAdd<vector_float> for vector_float {
2398 type Result = vector_float;
2399 #[inline]
2400 #[target_feature(enable = "altivec")]
2401 unsafe fn vec_add(self, other: vector_float) -> Self::Result {
2402 vec_add_float_float(self, other)
2403 }
2404 }
2405
2406 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2407 pub trait VectorAdde {
2408 unsafe fn vec_adde(self, b: Self, c: Self) -> Self;
2409 }
2410
2411 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2412 impl VectorAdde for vector_unsigned_int {
2413 #[inline]
2414 #[target_feature(enable = "altivec")]
2415 unsafe fn vec_adde(self, b: Self, c: Self) -> Self {
2416 let mask: vector_unsigned_int = transmute(u32x4::new(1, 1, 1, 1));
2417 let carry = vec_and(c, mask);
2418 vec_add(vec_add(self, b), carry)
2419 }
2420 }
2421
2422 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2423 impl VectorAdde for vector_signed_int {
2424 #[inline]
2425 #[target_feature(enable = "altivec")]
2426 unsafe fn vec_adde(self, b: Self, c: Self) -> Self {
2427 let mask: vector_signed_int = transmute(i32x4::new(1, 1, 1, 1));
2428 let carry = vec_and(c, mask);
2429 vec_add(vec_add(self, b), carry)
2430 }
2431 }
2432
2433 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2434 pub trait VectorMladd<Other> {
2435 type Result;
2436 unsafe fn vec_mladd(self, b: Other, c: Other) -> Self::Result;
2437 }
2438
2439 #[inline]
2440 #[target_feature(enable = "altivec")]
2441 #[cfg_attr(test, assert_instr(vmladduhm))]
2442 unsafe fn mladd(
2443 a: vector_signed_short,
2444 b: vector_signed_short,
2445 c: vector_signed_short,
2446 ) -> vector_signed_short {
2447 let a: i16x8 = transmute(a);
2448 let b: i16x8 = transmute(b);
2449 let c: i16x8 = transmute(c);
2450 transmute(simd_add(simd_mul(a, b), c))
2451 }
2452
2453 macro_rules! vector_mladd {
2454 ($a: ident, $bc: ident, $d: ident) => {
2455 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2456 impl VectorMladd<$bc> for $a {
2457 type Result = $d;
2458 #[inline]
2459 #[target_feature(enable = "altivec")]
2460 unsafe fn vec_mladd(self, b: $bc, c: $bc) -> Self::Result {
2461 let a = transmute(self);
2462 let b = transmute(b);
2463 let c = transmute(c);
2464
2465 transmute(mladd(a, b, c))
2466 }
2467 }
2468 };
2469 }
2470
2471 vector_mladd! { vector_unsigned_short, vector_unsigned_short, vector_unsigned_short }
2472 vector_mladd! { vector_unsigned_short, vector_signed_short, vector_signed_short }
2473 vector_mladd! { vector_signed_short, vector_unsigned_short, vector_signed_short }
2474 vector_mladd! { vector_signed_short, vector_signed_short, vector_signed_short }
2475
2476 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2477 pub trait VectorOr<Other> {
2478 type Result;
2479 unsafe fn vec_or(self, b: Other) -> Self::Result;
2480 }
2481
2482 impl_vec_trait! { [VectorOr vec_or] ~(simd_or) }
2483
2484 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2485 pub trait VectorXor<Other> {
2486 type Result;
2487 unsafe fn vec_xor(self, b: Other) -> Self::Result;
2488 }
2489
2490 impl_vec_trait! { [VectorXor vec_xor] ~(simd_xor) }
2491
2492 macro_rules! vector_vnor {
2493 ($fun:ident $ty:ident) => {
2494 #[inline]
2495 #[target_feature(enable = "altivec")]
2496 #[cfg_attr(all(test, not(target_feature = "vsx")), assert_instr(vnor))]
2497 #[cfg_attr(all(test, target_feature = "vsx"), assert_instr(xxlnor))]
2498 pub unsafe fn $fun(a: t_t_l!($ty), b: t_t_l!($ty)) -> t_t_l!($ty) {
2499 let o = vec_splats(!0 as $ty);
2500 vec_xor(vec_or(a, b), o)
2501 }
2502 };
2503 }
2504
2505 vector_vnor! { vec_vnorsb i8 }
2506 vector_vnor! { vec_vnorsh i16 }
2507 vector_vnor! { vec_vnorsw i32 }
2508
2509 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2510 pub trait VectorNor<Other> {
2511 type Result;
2512 unsafe fn vec_nor(self, b: Other) -> Self::Result;
2513 }
2514
2515 impl_vec_trait! { [VectorNor vec_nor]+ 2b (vec_vnorsb, vec_vnorsh, vec_vnorsw) }
2516
2517 macro_rules! vector_vnand {
2518 ($fun:ident $ty:ident) => {
2519 #[inline]
2520 #[target_feature(enable = "altivec")]
2521 #[cfg_attr(all(test, not(target_feature = "vsx")), assert_instr(vnand))]
2522 #[cfg_attr(all(test, target_feature = "vsx"), assert_instr(xxlnand))]
2523 pub unsafe fn $fun(a: t_t_l!($ty), b: t_t_l!($ty)) -> t_t_l!($ty) {
2524 let o = vec_splats(!0 as $ty);
2525 vec_xor(vec_and(a, b), o)
2526 }
2527 };
2528 }
2529
2530 vector_vnand! { vec_vnandsb i8 }
2531 vector_vnand! { vec_vnandsh i16 }
2532 vector_vnand! { vec_vnandsw i32 }
2533
2534 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2535 pub trait VectorNand<Other> {
2536 type Result;
2537 unsafe fn vec_nand(self, b: Other) -> Self::Result;
2538 }
2539
2540 impl_vec_trait! { [VectorNand vec_nand]+ 2b (vec_vnandsb, vec_vnandsh, vec_vnandsw) }
2541
2542 #[inline]
2543 #[target_feature(enable = "altivec")]
2544 #[cfg_attr(all(test, not(target_feature = "vsx")), assert_instr(vsel))]
2545 #[cfg_attr(all(test, target_feature = "vsx"), assert_instr(xxsel))]
2546 pub unsafe fn vec_vsel(
2547 a: vector_signed_char,
2548 b: vector_signed_char,
2549 c: vector_signed_char,
2550 ) -> vector_signed_char {
2551 let a: i8x16 = transmute(a);
2552 let b: i8x16 = transmute(b);
2553 let c: i8x16 = transmute(c);
2554 let not_c = simd_xor(c, i8x16::splat(!0));
2555
2556 transmute(simd_or(simd_and(a, not_c), simd_and(b, c)))
2557 }
2558
2559 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2560 pub trait VectorSel<Mask> {
2561 unsafe fn vec_sel(self, b: Self, c: Mask) -> Self;
2562 }
2563
2564 macro_rules! vector_sel {
2565 ($ty: ty, $m: ty) => {
2566 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2567 impl VectorSel<$m> for $ty {
2568 #[inline]
2569 #[target_feature(enable = "altivec")]
2570 unsafe fn vec_sel(self, b: Self, c: $m) -> Self {
2571 let a = transmute(self);
2572 let b = transmute(b);
2573 let c = transmute(c);
2574
2575 transmute(vec_vsel(a, b, c))
2576 }
2577 }
2578 };
2579 ($ty: ident) => {
2580 vector_sel! { $ty, t_b!{ $ty } }
2581 vector_sel! { $ty, t_u!{ $ty } }
2582 vector_sel! { t_u!{ $ty }, t_b!{ $ty } }
2583 vector_sel! { t_u!{ $ty }, t_u!{ $ty } }
2584 vector_sel! { t_b!{ $ty }, t_b!{ $ty } }
2585 vector_sel! { t_b!{ $ty }, t_u!{ $ty } }
2586 };
2587 (- $ty: ident) => {
2588 vector_sel! { $ty, t_b!{ $ty } }
2589 vector_sel! { $ty, t_u!{ $ty } }
2590 };
2591 }
2592
2593 vector_sel! { vector_signed_char }
2594 vector_sel! { vector_signed_short }
2595 vector_sel! { vector_signed_int }
2596 vector_sel! {- vector_float }
2597
2598 #[inline]
2599 #[target_feature(enable = "altivec")]
2600 #[cfg_attr(test, assert_instr(vcfsx, IMM5 = 1))]
2601 unsafe fn vec_ctf_i32<const IMM5: i32>(a: vector_signed_int) -> vector_float {
2602 static_assert_uimm_bits!(IMM5, 5);
2603 vcfsx(a, IMM5)
2604 }
2605
2606 #[inline]
2607 #[target_feature(enable = "altivec")]
2608 #[cfg_attr(test, assert_instr(vcfux, IMM5 = 1))]
2609 unsafe fn vec_ctf_u32<const IMM5: i32>(a: vector_unsigned_int) -> vector_float {
2610 static_assert_uimm_bits!(IMM5, 5);
2611 vcfux(a, IMM5)
2612 }
2613
2614 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2615 pub trait VectorCtf {
2616 unsafe fn vec_ctf<const IMM5: i32>(self) -> vector_float;
2617 }
2618
2619 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2620 impl VectorCtf for vector_signed_int {
2621 unsafe fn vec_ctf<const IMM5: i32>(self) -> vector_float {
2622 vec_ctf_i32::<IMM5>(self)
2623 }
2624 }
2625
2626 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2627 impl VectorCtf for vector_unsigned_int {
2628 unsafe fn vec_ctf<const IMM5: i32>(self) -> vector_float {
2629 vec_ctf_u32::<IMM5>(self)
2630 }
2631 }
2632
2633 #[inline]
2634 #[target_feature(enable = "altivec")]
2635 #[cfg_attr(all(test, target_endian = "little"), assert_instr(vmrghb))]
2636 #[cfg_attr(all(test, target_endian = "big"), assert_instr(vmrglb))]
2637 unsafe fn vec_vmrglb(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char {
2638 let mergel_perm = transmute(u8x16::new(
2639 0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D, 0x0E, 0x1E,
2640 0x0F, 0x1F,
2641 ));
2642 vec_perm(a, b, mergel_perm)
2643 }
2644
2645 #[inline]
2646 #[target_feature(enable = "altivec")]
2647 #[cfg_attr(all(test, target_endian = "little"), assert_instr(vmrghh))]
2648 #[cfg_attr(all(test, target_endian = "big"), assert_instr(vmrglh))]
2649 unsafe fn vec_vmrglh(a: vector_signed_short, b: vector_signed_short) -> vector_signed_short {
2650 let mergel_perm = transmute(u8x16::new(
2651 0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D, 0x0E, 0x0F,
2652 0x1E, 0x1F,
2653 ));
2654 vec_perm(a, b, mergel_perm)
2655 }
2656
2657 #[inline]
2658 #[target_feature(enable = "altivec")]
2659 #[cfg_attr(
2660 all(test, target_endian = "little", not(target_feature = "vsx")),
2661 assert_instr(vmrghw)
2662 )]
2663 #[cfg_attr(
2664 all(test, target_endian = "little", target_feature = "vsx"),
2665 assert_instr(xxmrghw)
2666 )]
2667 #[cfg_attr(
2668 all(test, target_endian = "big", not(target_feature = "vsx")),
2669 assert_instr(vmrglw)
2670 )]
2671 #[cfg_attr(
2672 all(test, target_endian = "big", target_feature = "vsx"),
2673 assert_instr(xxmrglw)
2674 )]
2675 unsafe fn vec_vmrglw(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int {
2676 let mergel_perm = transmute(u8x16::new(
2677 0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F, 0x1C, 0x1D,
2678 0x1E, 0x1F,
2679 ));
2680 vec_perm(a, b, mergel_perm)
2681 }
2682
2683 #[inline]
2684 #[target_feature(enable = "altivec")]
2685 #[cfg_attr(all(test, target_endian = "little"), assert_instr(vmrglb))]
2686 #[cfg_attr(all(test, target_endian = "big"), assert_instr(vmrghb))]
2687 unsafe fn vec_vmrghb(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char {
2688 let mergel_perm = transmute(u8x16::new(
2689 0x00, 0x10, 0x01, 0x11, 0x02, 0x12, 0x03, 0x13, 0x04, 0x14, 0x05, 0x15, 0x06, 0x16,
2690 0x07, 0x17,
2691 ));
2692 vec_perm(a, b, mergel_perm)
2693 }
2694
2695 #[inline]
2696 #[target_feature(enable = "altivec")]
2697 #[cfg_attr(all(test, target_endian = "little"), assert_instr(vmrglh))]
2698 #[cfg_attr(all(test, target_endian = "big"), assert_instr(vmrghh))]
2699 unsafe fn vec_vmrghh(a: vector_signed_short, b: vector_signed_short) -> vector_signed_short {
2700 let mergel_perm = transmute(u8x16::new(
2701 0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13, 0x04, 0x05, 0x14, 0x15, 0x06, 0x07,
2702 0x16, 0x17,
2703 ));
2704 vec_perm(a, b, mergel_perm)
2705 }
2706
2707 #[inline]
2708 #[target_feature(enable = "altivec")]
2709 #[cfg_attr(
2710 all(test, target_endian = "little", not(target_feature = "vsx")),
2711 assert_instr(vmrglw)
2712 )]
2713 #[cfg_attr(
2714 all(test, target_endian = "little", target_feature = "vsx"),
2715 assert_instr(xxmrglw)
2716 )]
2717 #[cfg_attr(
2718 all(test, target_endian = "big", not(target_feature = "vsx")),
2719 assert_instr(vmrghw)
2720 )]
2721 #[cfg_attr(
2722 all(test, target_endian = "big", target_feature = "vsx"),
2723 assert_instr(xxmrghw)
2724 )]
2725 unsafe fn vec_vmrghw(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int {
2726 let mergel_perm = transmute(u8x16::new(
2727 0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13, 0x04, 0x05, 0x06, 0x07, 0x14, 0x15,
2728 0x16, 0x17,
2729 ));
2730 vec_perm(a, b, mergel_perm)
2731 }
2732
2733 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2734 pub trait VectorMergeh<Other> {
2735 type Result;
2736 unsafe fn vec_mergeh(self, b: Other) -> Self::Result;
2737 }
2738
2739 impl_vec_trait! { [VectorMergeh vec_mergeh]+ 2b (vec_vmrghb, vec_vmrghh, vec_vmrghw) }
2740 impl_vec_trait! { [VectorMergeh vec_mergeh]+ vec_vmrghw (vector_float, vector_float) -> vector_float }
2741
2742 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2743 pub trait VectorMergel<Other> {
2744 type Result;
2745 unsafe fn vec_mergel(self, b: Other) -> Self::Result;
2746 }
2747
2748 impl_vec_trait! { [VectorMergel vec_mergel]+ 2b (vec_vmrglb, vec_vmrglh, vec_vmrglw) }
2749 impl_vec_trait! { [VectorMergel vec_mergel]+ vec_vmrglw (vector_float, vector_float) -> vector_float }
2750
2751 #[inline]
2752 #[target_feature(enable = "altivec")]
2753 #[cfg_attr(test, assert_instr(vpkuhum))]
2754 unsafe fn vec_vpkuhum(a: vector_signed_short, b: vector_signed_short) -> vector_signed_char {
2755 let pack_perm = if cfg!(target_endian = "little") {
2756 transmute(u8x16::new(
2757 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A,
2758 0x1C, 0x1E,
2759 ))
2760 } else {
2761 transmute(u8x16::new(
2762 0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B,
2763 0x1D, 0x1F,
2764 ))
2765 };
2766
2767 transmute(vec_perm(a, b, pack_perm))
2768 }
2769
2770 #[inline]
2771 #[target_feature(enable = "altivec")]
2772 #[cfg_attr(test, assert_instr(vpkuwum))]
2773 unsafe fn vec_vpkuwum(a: vector_signed_int, b: vector_signed_int) -> vector_signed_short {
2774 let pack_perm = if cfg!(target_endian = "little") {
2775 transmute(u8x16::new(
2776 0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D, 0x10, 0x11, 0x14, 0x15, 0x18, 0x19,
2777 0x1C, 0x1D,
2778 ))
2779 } else {
2780 transmute(u8x16::new(
2781 0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F, 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B,
2782 0x1E, 0x1F,
2783 ))
2784 };
2785
2786 transmute(vec_perm(a, b, pack_perm))
2787 }
2788
2789 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2790 pub trait VectorPack<Other> {
2791 type Result;
2792 unsafe fn vec_pack(self, b: Other) -> Self::Result;
2793 }
2794
2795 impl_vec_trait! { [VectorPack vec_pack]+ vec_vpkuhum (vector_signed_short, vector_signed_short) -> vector_signed_char }
2796 impl_vec_trait! { [VectorPack vec_pack]+ vec_vpkuhum (vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_char }
2797 impl_vec_trait! { [VectorPack vec_pack]+ vec_vpkuhum (vector_bool_short, vector_bool_short) -> vector_bool_char }
2798 impl_vec_trait! { [VectorPack vec_pack]+ vec_vpkuwum (vector_signed_int, vector_signed_int) -> vector_signed_short }
2799 impl_vec_trait! { [VectorPack vec_pack]+ vec_vpkuwum (vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_short }
2800 impl_vec_trait! { [VectorPack vec_pack]+ vec_vpkuwum (vector_bool_int, vector_bool_int) -> vector_bool_short }
2801
2802 #[inline]
2803 #[target_feature(enable = "altivec")]
2804 #[cfg_attr(test, assert_instr(vpkshss))]
2805 unsafe fn vec_vpkshss(a: vector_signed_short, b: vector_signed_short) -> vector_signed_char {
2806 if cfg!(target_endian = "little") {
2807 vpkshss(b, a)
2808 } else {
2809 vpkshss(a, b)
2810 }
2811 }
2812
2813 #[inline]
2814 #[target_feature(enable = "altivec")]
2815 #[cfg_attr(test, assert_instr(vpkshus))]
2816 unsafe fn vec_vpkshus(a: vector_signed_short, b: vector_signed_short) -> vector_unsigned_char {
2817 if cfg!(target_endian = "little") {
2818 vpkshus(b, a)
2819 } else {
2820 vpkshus(a, b)
2821 }
2822 }
2823
2824 #[inline]
2825 #[target_feature(enable = "altivec")]
2826 #[cfg_attr(test, assert_instr(vpkuhus))]
2827 unsafe fn vec_vpkuhus(
2828 a: vector_unsigned_short,
2829 b: vector_unsigned_short,
2830 ) -> vector_unsigned_char {
2831 if cfg!(target_endian = "little") {
2832 vpkuhus(b, a)
2833 } else {
2834 vpkuhus(a, b)
2835 }
2836 }
2837
2838 #[inline]
2839 #[target_feature(enable = "altivec")]
2840 #[cfg_attr(test, assert_instr(vpkswss))]
2841 unsafe fn vec_vpkswss(a: vector_signed_int, b: vector_signed_int) -> vector_signed_short {
2842 if cfg!(target_endian = "little") {
2843 vpkswss(b, a)
2844 } else {
2845 vpkswss(a, b)
2846 }
2847 }
2848
2849 #[inline]
2850 #[target_feature(enable = "altivec")]
2851 #[cfg_attr(test, assert_instr(vpkswus))]
2852 unsafe fn vec_vpkswus(a: vector_signed_int, b: vector_signed_int) -> vector_unsigned_short {
2853 if cfg!(target_endian = "little") {
2854 vpkswus(b, a)
2855 } else {
2856 vpkswus(a, b)
2857 }
2858 }
2859
2860 #[inline]
2861 #[target_feature(enable = "altivec")]
2862 #[cfg_attr(test, assert_instr(vpkuwus))]
2863 unsafe fn vec_vpkuwus(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_short {
2864 if cfg!(target_endian = "little") {
2865 vpkuwus(b, a)
2866 } else {
2867 vpkuwus(a, b)
2868 }
2869 }
2870
2871 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2872 pub trait VectorPacks<Other> {
2873 type Result;
2874 unsafe fn vec_packs(self, b: Other) -> Self::Result;
2875 }
2876
2877 impl_vec_trait! { [VectorPacks vec_packs] vec_vpkshss (vector_signed_short, vector_signed_short) -> vector_signed_char }
2878 impl_vec_trait! { [VectorPacks vec_packs] vec_vpkuhus (vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_char }
2879 impl_vec_trait! { [VectorPacks vec_packs] vec_vpkswss (vector_signed_int, vector_signed_int) -> vector_signed_short }
2880 impl_vec_trait! { [VectorPacks vec_packs] vec_vpkuwus (vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_short }
2881
2882 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2883 pub trait VectorPacksu<Other> {
2884 type Result;
2885 unsafe fn vec_packsu(self, b: Other) -> Self::Result;
2886 }
2887
2888 impl_vec_trait! { [VectorPacksu vec_packsu] vec_vpkshus (vector_signed_short, vector_signed_short) -> vector_unsigned_char }
2889 impl_vec_trait! { [VectorPacksu vec_packsu] vec_vpkuhus (vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_char }
2890 impl_vec_trait! { [VectorPacksu vec_packsu] vec_vpkswus (vector_signed_int, vector_signed_int) -> vector_unsigned_short }
2891 impl_vec_trait! { [VectorPacksu vec_packsu] vec_vpkuwus (vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_short }
2892
2893 macro_rules! impl_vec_unpack {
2894 ($fun:ident ($a:ident) -> $r:ident [$little:ident, $big:ident]) => {
2895 #[inline]
2896 #[target_feature(enable = "altivec")]
2897 #[cfg_attr(all(test, target_endian = "little"), assert_instr($little))]
2898 #[cfg_attr(all(test, target_endian = "big"), assert_instr($big))]
2899 unsafe fn $fun(a: $a) -> $r {
2900 if cfg!(target_endian = "little") {
2901 $little(a)
2902 } else {
2903 $big(a)
2904 }
2905 }
2906 };
2907 }
2908
2909 impl_vec_unpack! { vec_vupkhsb (vector_signed_char) -> vector_signed_short [vupklsb, vupkhsb] }
2910 impl_vec_unpack! { vec_vupklsb (vector_signed_char) -> vector_signed_short [vupkhsb, vupklsb] }
2911 impl_vec_unpack! { vec_vupkhsh (vector_signed_short) -> vector_signed_int [vupklsh, vupkhsh] }
2912 impl_vec_unpack! { vec_vupklsh (vector_signed_short) -> vector_signed_int [vupkhsh, vupklsh] }
2913
2914 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2915 pub trait VectorUnpackh {
2916 type Result;
2917 unsafe fn vec_unpackh(self) -> Self::Result;
2918 }
2919
2920 impl_vec_trait! { [VectorUnpackh vec_unpackh] vec_vupkhsb (vector_signed_char) -> vector_signed_short }
2921 impl_vec_trait! { [VectorUnpackh vec_unpackh]+ vec_vupkhsb (vector_bool_char) -> vector_bool_short }
2922 impl_vec_trait! { [VectorUnpackh vec_unpackh] vec_vupkhsh (vector_signed_short) -> vector_signed_int }
2923 impl_vec_trait! { [VectorUnpackh vec_unpackh]+ vec_vupkhsh (vector_bool_short) -> vector_bool_int }
2924
2925 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2926 pub trait VectorUnpackl {
2927 type Result;
2928 unsafe fn vec_unpackl(self) -> Self::Result;
2929 }
2930
2931 impl_vec_trait! { [VectorUnpackl vec_unpackl] vec_vupklsb (vector_signed_char) -> vector_signed_short }
2932 impl_vec_trait! { [VectorUnpackl vec_unpackl]+ vec_vupklsb (vector_bool_char) -> vector_bool_short }
2933 impl_vec_trait! { [VectorUnpackl vec_unpackl] vec_vupklsh (vector_signed_short) -> vector_signed_int }
2934 impl_vec_trait! { [VectorUnpackl vec_unpackl]+ vec_vupklsh (vector_bool_short) -> vector_bool_int }
2935
2936 macro_rules! impl_vec_shift {
2937 ([$Trait:ident $m:ident] ($b:ident, $h:ident, $w:ident)) => {
2938 impl_vec_trait!{ [$Trait $m]+ $b (vector_unsigned_char, vector_unsigned_char) -> vector_unsigned_char }
2939 impl_vec_trait!{ [$Trait $m]+ $b (vector_signed_char, vector_unsigned_char) -> vector_signed_char }
2940 impl_vec_trait!{ [$Trait $m]+ $h (vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_short }
2941 impl_vec_trait!{ [$Trait $m]+ $h (vector_signed_short, vector_unsigned_short) -> vector_signed_short }
2942 impl_vec_trait!{ [$Trait $m]+ $w (vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_int }
2943 impl_vec_trait!{ [$Trait $m]+ $w (vector_signed_int, vector_unsigned_int) -> vector_signed_int }
2944 };
2945 }
2946
2947 macro_rules! impl_shift {
2948 ($fun:ident $intr:ident $ty:ident) => {
2949 #[inline]
2950 #[target_feature(enable = "altivec")]
2951 #[cfg_attr(test, assert_instr($fun))]
2952 unsafe fn $fun(a: t_t_l!($ty), b: t_t_l!($ty)) -> t_t_l!($ty) {
2953 let a = transmute(a);
2954 let b = simd_rem(
2955 transmute(b),
2956 <t_t_s!($ty)>::splat(mem::size_of::<$ty>() as $ty * $ty::BITS as $ty),
2957 );
2958
2959 transmute($intr(a, b))
2960 }
2961 };
2962 }
2963
2964 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2965 pub trait VectorSl<Other> {
2966 type Result;
2967 unsafe fn vec_sl(self, b: Other) -> Self::Result;
2968 }
2969
2970 impl_shift! { vslb simd_shl u8 }
2971 impl_shift! { vslh simd_shl u16 }
2972 impl_shift! { vslw simd_shl u32 }
2973
2974 impl_vec_shift! { [VectorSl vec_sl] (vslb, vslh, vslw) }
2975
2976 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2977 pub trait VectorSr<Other> {
2978 type Result;
2979 unsafe fn vec_sr(self, b: Other) -> Self::Result;
2980 }
2981
2982 impl_shift! { vsrb simd_shr u8 }
2983 impl_shift! { vsrh simd_shr u16 }
2984 impl_shift! { vsrw simd_shr u32 }
2985
2986 impl_vec_shift! { [VectorSr vec_sr] (vsrb, vsrh, vsrw) }
2987
2988 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2989 pub trait VectorSra<Other> {
2990 type Result;
2991 unsafe fn vec_sra(self, b: Other) -> Self::Result;
2992 }
2993
2994 impl_vec_shift! { [VectorSra vec_sra] (vsrab, vsrah, vsraw) }
2995
2996 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
2997 pub trait VectorSld {
2998 unsafe fn vec_sld<const UIMM4: i32>(self, b: Self) -> Self;
2999 unsafe fn vec_sldw<const UIMM2: i32>(self, b: Self) -> Self;
3000 }
3001
3002 #[inline]
3003 #[target_feature(enable = "altivec")]
3004 #[cfg_attr(test, assert_instr(vsldoi, UIMM4 = 1))]
3005 unsafe fn vsldoi<const UIMM4: i32>(
3006 a: vector_unsigned_char,
3007 b: vector_unsigned_char,
3008 ) -> vector_unsigned_char {
3009 static_assert_uimm_bits!(UIMM4, 4);
3010 let d = UIMM4 as u8;
3011 if cfg!(target_endian = "little") {
3012 let perm = u8x16::new(
3013 16 - d,
3014 17 - d,
3015 18 - d,
3016 19 - d,
3017 20 - d,
3018 21 - d,
3019 22 - d,
3020 23 - d,
3021 24 - d,
3022 25 - d,
3023 26 - d,
3024 27 - d,
3025 28 - d,
3026 29 - d,
3027 30 - d,
3028 31 - d,
3029 );
3030
3031 vec_perm(b, a, transmute(perm))
3032 } else {
3033 let perm = u8x16::new(
3034 d,
3035 d + 1,
3036 d + 2,
3037 d + 3,
3038 d + 4,
3039 d + 5,
3040 d + 6,
3041 d + 7,
3042 d + 8,
3043 d + 9,
3044 d + 10,
3045 d + 11,
3046 d + 12,
3047 d + 13,
3048 d + 14,
3049 d + 15,
3050 );
3051 vec_perm(a, b, transmute(perm))
3052 }
3053 }
3054
3055 #[inline]
3057 #[target_feature(enable = "altivec")]
3058 #[cfg_attr(test, assert_instr(xxsldwi, UIMM2 = 1))]
3059 unsafe fn xxsldwi<const UIMM2: i32>(
3060 a: vector_unsigned_char,
3061 b: vector_unsigned_char,
3062 ) -> vector_unsigned_char {
3063 static_assert_uimm_bits!(UIMM2, 2);
3064 let d = (UIMM2 << 2) as u8;
3065 if cfg!(target_endian = "little") {
3066 let perm = u8x16::new(
3067 16 - d,
3068 17 - d,
3069 18 - d,
3070 19 - d,
3071 20 - d,
3072 21 - d,
3073 22 - d,
3074 23 - d,
3075 24 - d,
3076 25 - d,
3077 26 - d,
3078 27 - d,
3079 28 - d,
3080 29 - d,
3081 30 - d,
3082 31 - d,
3083 );
3084
3085 vec_perm(b, a, transmute(perm))
3086 } else {
3087 let perm = u8x16::new(
3088 d,
3089 d + 1,
3090 d + 2,
3091 d + 3,
3092 d + 4,
3093 d + 5,
3094 d + 6,
3095 d + 7,
3096 d + 8,
3097 d + 9,
3098 d + 10,
3099 d + 11,
3100 d + 12,
3101 d + 13,
3102 d + 14,
3103 d + 15,
3104 );
3105 vec_perm(a, b, transmute(perm))
3106 }
3107 }
3108
3109 macro_rules! impl_vec_sld {
3110 ($($ty:ident),+) => { $(
3111 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
3112 impl VectorSld for $ty {
3113 #[inline]
3114 #[target_feature(enable = "altivec")]
3115 unsafe fn vec_sld<const UIMM4: i32>(self, b: Self) -> Self {
3116 transmute(vsldoi::<UIMM4>(transmute(self), transmute(b)))
3117 }
3118 #[inline]
3119 #[target_feature(enable = "altivec")]
3120 unsafe fn vec_sldw<const UIMM2: i32>(self, b: Self) -> Self {
3121 transmute(xxsldwi::<UIMM2>(transmute(self), transmute(b)))
3122 }
3123 }
3124 )+ };
3125 }
3126
3127 impl_vec_sld! { vector_bool_char, vector_signed_char, vector_unsigned_char }
3128 impl_vec_sld! { vector_bool_short, vector_signed_short, vector_unsigned_short }
3129 impl_vec_sld! { vector_bool_int, vector_signed_int, vector_unsigned_int }
3130 impl_vec_sld! { vector_float }
3131
3132 macro_rules! impl_vec_shift_long {
3133 ([$Trait:ident $m:ident] ($f:ident)) => {
3134 impl_vec_trait!{ [$Trait $m]+ $f (vector_unsigned_char, vector_unsigned_char) -> vector_unsigned_char }
3135 impl_vec_trait!{ [$Trait $m]+ $f (vector_signed_char, vector_unsigned_char) -> vector_signed_char }
3136 impl_vec_trait!{ [$Trait $m]+ $f (vector_unsigned_short, vector_unsigned_char) -> vector_unsigned_short }
3137 impl_vec_trait!{ [$Trait $m]+ $f (vector_signed_short, vector_unsigned_char) -> vector_signed_short }
3138 impl_vec_trait!{ [$Trait $m]+ $f (vector_unsigned_int, vector_unsigned_char) -> vector_unsigned_int }
3139 impl_vec_trait!{ [$Trait $m]+ $f (vector_signed_int, vector_unsigned_char) -> vector_signed_int }
3140 };
3141 }
3142
3143 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
3144 pub trait VectorSll<Other> {
3145 type Result;
3146 unsafe fn vec_sll(self, b: Other) -> Self::Result;
3147 }
3148
3149 impl_vec_shift_long! { [VectorSll vec_sll] (vsl) }
3150
3151 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
3152 pub trait VectorSrl<Other> {
3153 type Result;
3154 unsafe fn vec_srl(self, b: Other) -> Self::Result;
3155 }
3156
3157 impl_vec_shift_long! { [VectorSrl vec_srl] (vsr) }
3158
3159 macro_rules! impl_vec_shift_octect {
3160 ([$Trait:ident $m:ident] ($f:ident)) => {
3161 impl_vec_trait!{ [$Trait $m]+ $f (vector_unsigned_char, vector_signed_char) -> vector_unsigned_char }
3162 impl_vec_trait!{ [$Trait $m]+ $f (vector_signed_char, vector_signed_char) -> vector_signed_char }
3163 impl_vec_trait!{ [$Trait $m]+ $f (vector_unsigned_short, vector_signed_char) -> vector_unsigned_short }
3164 impl_vec_trait!{ [$Trait $m]+ $f (vector_signed_short, vector_signed_char) -> vector_signed_short }
3165 impl_vec_trait!{ [$Trait $m]+ $f (vector_unsigned_int, vector_signed_char) -> vector_unsigned_int }
3166 impl_vec_trait!{ [$Trait $m]+ $f (vector_signed_int, vector_signed_char) -> vector_signed_int }
3167 impl_vec_trait!{ [$Trait $m]+ $f (vector_float, vector_signed_char) -> vector_float }
3168 impl_vec_trait!{ [$Trait $m]+ $f (vector_unsigned_char, vector_unsigned_char) -> vector_unsigned_char }
3169 impl_vec_trait!{ [$Trait $m]+ $f (vector_signed_char, vector_unsigned_char) -> vector_signed_char }
3170 impl_vec_trait!{ [$Trait $m]+ $f (vector_unsigned_short, vector_unsigned_char) -> vector_unsigned_short }
3171 impl_vec_trait!{ [$Trait $m]+ $f (vector_signed_short, vector_unsigned_char) -> vector_signed_short }
3172 impl_vec_trait!{ [$Trait $m]+ $f (vector_unsigned_int, vector_unsigned_char) -> vector_unsigned_int }
3173 impl_vec_trait!{ [$Trait $m]+ $f (vector_signed_int, vector_unsigned_char) -> vector_signed_int }
3174 impl_vec_trait!{ [$Trait $m]+ $f (vector_float, vector_unsigned_char) -> vector_float }
3175 };
3176 }
3177
3178 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
3179 pub trait VectorSlo<Other> {
3180 type Result;
3181 unsafe fn vec_slo(self, b: Other) -> Self::Result;
3182 }
3183
3184 impl_vec_shift_octect! { [VectorSlo vec_slo] (vslo) }
3185
3186 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
3187 pub trait VectorSro<Other> {
3188 type Result;
3189 unsafe fn vec_sro(self, b: Other) -> Self::Result;
3190 }
3191
3192 impl_vec_shift_octect! { [VectorSro vec_sro] (vsro) }
3193
3194 test_impl! { vec_vcntlzb(a: vector_signed_char) -> vector_signed_char [vclzb, vclzb] }
3195 test_impl! { vec_vcntlzh(a: vector_signed_short) -> vector_signed_short [vclzh, vclzh] }
3196 test_impl! { vec_vcntlzw(a: vector_signed_int) -> vector_signed_int [vclzw, vclzw] }
3197
3198 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
3199 pub trait VectorCntlz {
3200 unsafe fn vec_cntlz(self) -> Self;
3201 }
3202
3203 macro_rules! impl_vec_cntlz {
3204 ($fun:ident ($a:ty)) => {
3205 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
3206 impl VectorCntlz for $a {
3207 #[inline]
3208 #[target_feature(enable = "altivec")]
3209 unsafe fn vec_cntlz(self) -> Self {
3210 transmute($fun(transmute(self)))
3211 }
3212 }
3213 };
3214 }
3215
3216 impl_vec_cntlz! { vec_vcntlzb(vector_signed_char) }
3217 impl_vec_cntlz! { vec_vcntlzb(vector_unsigned_char) }
3218 impl_vec_cntlz! { vec_vcntlzh(vector_signed_short) }
3219 impl_vec_cntlz! { vec_vcntlzh(vector_unsigned_short) }
3220 impl_vec_cntlz! { vec_vcntlzw(vector_signed_int) }
3221 impl_vec_cntlz! { vec_vcntlzw(vector_unsigned_int) }
3222
3223 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
3224 pub trait VectorRl {
3225 type Shift;
3226 unsafe fn vec_rl(self, b: Self::Shift) -> Self;
3227 }
3228
3229 macro_rules! impl_vec_rl {
3230 ($fun:ident ($a:ident)) => {
3231 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
3232 impl VectorRl for $a {
3233 type Shift = t_u!($a);
3234 #[inline]
3235 #[target_feature(enable = "altivec")]
3236 unsafe fn vec_rl(self, b: Self::Shift) -> Self {
3237 transmute($fun(transmute(self), b))
3238 }
3239 }
3240 };
3241 }
3242
3243 test_impl! { vec_vrlb(a: vector_signed_char, b: vector_unsigned_char) -> vector_signed_char [vrlb, vrlb] }
3244 test_impl! { vec_vrlh(a: vector_signed_short, b: vector_unsigned_short) -> vector_signed_short [vrlh, vrlh] }
3245 test_impl! { vec_vrlw(a: vector_signed_int, b: vector_unsigned_int) -> vector_signed_int [vrlw, vrlw] }
3246
3247 impl_vec_rl! { vec_vrlb(vector_signed_char) }
3248 impl_vec_rl! { vec_vrlh(vector_signed_short) }
3249 impl_vec_rl! { vec_vrlw(vector_signed_int) }
3250 impl_vec_rl! { vec_vrlb(vector_unsigned_char) }
3251 impl_vec_rl! { vec_vrlh(vector_unsigned_short) }
3252 impl_vec_rl! { vec_vrlw(vector_unsigned_int) }
3253
3254 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
3255 pub trait VectorRound {
3256 unsafe fn vec_round(self) -> Self;
3257 }
3258
3259 test_impl! { vec_vrfin(a: vector_float) -> vector_float [vrfin, vrfin] }
3260
3261 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
3262 impl VectorRound for vector_float {
3263 #[inline]
3264 #[target_feature(enable = "altivec")]
3265 unsafe fn vec_round(self) -> Self {
3266 vec_vrfin(self)
3267 }
3268 }
3269}
3270
3271#[inline]
3282#[target_feature(enable = "altivec")]
3283#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3284pub unsafe fn vec_insert<T, const IDX: u32>(a: T, b: <T as sealed::VectorInsert>::Scalar) -> T
3285where
3286 T: sealed::VectorInsert,
3287{
3288 a.vec_insert::<IDX>(b)
3289}
3290
3291#[inline]
3300#[target_feature(enable = "altivec")]
3301#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3302pub unsafe fn vec_extract<T, const IDX: u32>(a: T) -> <T as sealed::VectorExtract>::Scalar
3303where
3304 T: sealed::VectorExtract,
3305{
3306 a.vec_extract::<IDX>()
3307}
3308
3309#[inline]
3311#[target_feature(enable = "altivec")]
3312#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3313pub unsafe fn vec_mergel<T, U>(a: T, b: U) -> <T as sealed::VectorMergel<U>>::Result
3314where
3315 T: sealed::VectorMergel<U>,
3316{
3317 a.vec_mergel(b)
3318}
3319
3320#[inline]
3322#[target_feature(enable = "altivec")]
3323#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3324pub unsafe fn vec_mergeh<T, U>(a: T, b: U) -> <T as sealed::VectorMergeh<U>>::Result
3325where
3326 T: sealed::VectorMergeh<U>,
3327{
3328 a.vec_mergeh(b)
3329}
3330
3331#[inline]
3333#[target_feature(enable = "altivec")]
3334#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3335pub unsafe fn vec_pack<T, U>(a: T, b: U) -> <T as sealed::VectorPack<U>>::Result
3336where
3337 T: sealed::VectorPack<U>,
3338{
3339 a.vec_pack(b)
3340}
3341
3342#[inline]
3344#[target_feature(enable = "altivec")]
3345#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3346pub unsafe fn vec_packs<T, U>(a: T, b: U) -> <T as sealed::VectorPacks<U>>::Result
3347where
3348 T: sealed::VectorPacks<U>,
3349{
3350 a.vec_packs(b)
3351}
3352
3353#[inline]
3355#[target_feature(enable = "altivec")]
3356#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3357pub unsafe fn vec_packsu<T, U>(a: T, b: U) -> <T as sealed::VectorPacksu<U>>::Result
3358where
3359 T: sealed::VectorPacksu<U>,
3360{
3361 a.vec_packsu(b)
3362}
3363
3364#[inline]
3366#[target_feature(enable = "altivec")]
3367#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3368pub unsafe fn vec_unpackh<T>(a: T) -> <T as sealed::VectorUnpackh>::Result
3369where
3370 T: sealed::VectorUnpackh,
3371{
3372 a.vec_unpackh()
3373}
3374
3375#[inline]
3377#[target_feature(enable = "altivec")]
3378#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3379pub unsafe fn vec_unpackl<T>(a: T) -> <T as sealed::VectorUnpackl>::Result
3380where
3381 T: sealed::VectorUnpackl,
3382{
3383 a.vec_unpackl()
3384}
3385
3386#[inline]
3388#[target_feature(enable = "altivec")]
3389#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3390pub unsafe fn vec_sl<T, U>(a: T, b: U) -> <T as sealed::VectorSl<U>>::Result
3391where
3392 T: sealed::VectorSl<U>,
3393{
3394 a.vec_sl(b)
3395}
3396
3397#[inline]
3399#[target_feature(enable = "altivec")]
3400#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3401pub unsafe fn vec_sr<T, U>(a: T, b: U) -> <T as sealed::VectorSr<U>>::Result
3402where
3403 T: sealed::VectorSr<U>,
3404{
3405 a.vec_sr(b)
3406}
3407
3408#[inline]
3410#[target_feature(enable = "altivec")]
3411#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3412pub unsafe fn vec_sra<T, U>(a: T, b: U) -> <T as sealed::VectorSra<U>>::Result
3413where
3414 T: sealed::VectorSra<U>,
3415{
3416 a.vec_sra(b)
3417}
3418
3419#[inline]
3433#[target_feature(enable = "altivec")]
3434#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3435pub unsafe fn vec_sld<T, const UIMM4: i32>(a: T, b: T) -> T
3436where
3437 T: sealed::VectorSld,
3438{
3439 a.vec_sld::<UIMM4>(b)
3440}
3441
3442#[inline]
3452#[target_feature(enable = "altivec")]
3453#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3454pub unsafe fn vec_sldw<T, const UIMM2: i32>(a: T, b: T) -> T
3455where
3456 T: sealed::VectorSld,
3457{
3458 a.vec_sldw::<UIMM2>(b)
3459}
3460
3461#[inline]
3467#[target_feature(enable = "altivec")]
3468#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3469pub unsafe fn vec_sll<T, U>(a: T, b: U) -> <T as sealed::VectorSll<U>>::Result
3470where
3471 T: sealed::VectorSll<U>,
3472{
3473 a.vec_sll(b)
3474}
3475
3476#[inline]
3482#[target_feature(enable = "altivec")]
3483#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3484pub unsafe fn vec_srl<T, U>(a: T, b: U) -> <T as sealed::VectorSrl<U>>::Result
3485where
3486 T: sealed::VectorSrl<U>,
3487{
3488 a.vec_srl(b)
3489}
3490
3491#[inline]
3498#[target_feature(enable = "altivec")]
3499#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3500pub unsafe fn vec_slo<T, U>(a: T, b: U) -> <T as sealed::VectorSlo<U>>::Result
3501where
3502 T: sealed::VectorSlo<U>,
3503{
3504 a.vec_slo(b)
3505}
3506
3507#[inline]
3514#[target_feature(enable = "altivec")]
3515#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3516pub unsafe fn vec_sro<T, U>(a: T, b: U) -> <T as sealed::VectorSro<U>>::Result
3517where
3518 T: sealed::VectorSro<U>,
3519{
3520 a.vec_sro(b)
3521}
3522
3523#[inline]
3535#[target_feature(enable = "power9-altivec")]
3536#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3537pub unsafe fn vec_slv(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char {
3538 vslv(a, b)
3539}
3540
3541#[inline]
3553#[target_feature(enable = "power9-altivec")]
3554#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3555pub unsafe fn vec_srv(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char {
3556 vsrv(a, b)
3557}
3558
3559#[inline]
3561#[target_feature(enable = "altivec")]
3562#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3563pub unsafe fn vec_ld<T>(off: isize, p: T) -> <T as sealed::VectorLd>::Result
3564where
3565 T: sealed::VectorLd,
3566{
3567 p.vec_ld(off)
3568}
3569
3570#[inline]
3572#[target_feature(enable = "altivec")]
3573#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3574pub unsafe fn vec_ldl<T>(off: isize, p: T) -> <T as sealed::VectorLd>::Result
3575where
3576 T: sealed::VectorLd,
3577{
3578 p.vec_ldl(off)
3579}
3580
3581#[inline]
3583#[target_feature(enable = "altivec")]
3584#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3585pub unsafe fn vec_lde<T>(off: isize, p: T) -> <T as sealed::VectorLde>::Result
3586where
3587 T: sealed::VectorLde,
3588{
3589 p.vec_lde(off)
3590}
3591
3592#[inline]
3602#[target_feature(enable = "altivec")]
3603#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3604pub unsafe fn vec_st<T>(a: T, off: isize, c: <T as sealed::VectorSt>::Target)
3605where
3606 T: sealed::VectorSt,
3607{
3608 a.vec_st(off, c)
3609}
3610
3611#[inline]
3627#[target_feature(enable = "altivec")]
3628#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3629pub unsafe fn vec_stl<T>(a: T, off: isize, c: <T as sealed::VectorSt>::Target)
3630where
3631 T: sealed::VectorSt,
3632{
3633 a.vec_stl(off, c)
3634}
3635
3636#[inline]
3653#[target_feature(enable = "altivec")]
3654#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3655pub unsafe fn vec_ste<T>(a: T, off: isize, c: <T as sealed::VectorSte>::Target)
3656where
3657 T: sealed::VectorSte,
3658{
3659 a.vec_ste(off, c)
3660}
3661
3662#[inline]
3664#[target_feature(enable = "altivec")]
3665#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3666pub unsafe fn vec_xl<T>(off: isize, p: T) -> <T as sealed::VectorXl>::Result
3667where
3668 T: sealed::VectorXl,
3669{
3670 p.vec_xl(off)
3671}
3672
3673#[inline]
3675#[target_feature(enable = "altivec")]
3676#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3677pub unsafe fn vec_xst<T>(v: T, off: isize, p: <T as sealed::VectorXst>::Out)
3678where
3679 T: sealed::VectorXst,
3680{
3681 v.vec_xst(off, p)
3682}
3683
3684#[inline]
3686#[target_feature(enable = "altivec")]
3687#[cfg_attr(test, assert_instr(vlogefp))]
3688#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3689pub unsafe fn vec_loge(a: vector_float) -> vector_float {
3690 vlogefp(a)
3691}
3692
3693#[inline]
3695#[target_feature(enable = "altivec")]
3696#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3697pub unsafe fn vec_floor(a: vector_float) -> vector_float {
3698 sealed::vec_floor(a)
3699}
3700
3701#[inline]
3703#[target_feature(enable = "altivec")]
3704#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3705pub unsafe fn vec_expte(a: vector_float) -> vector_float {
3706 sealed::vec_vexptefp(a)
3707}
3708
3709#[inline]
3711#[target_feature(enable = "altivec")]
3712#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3713pub unsafe fn vec_cmplt<T, U>(a: U, b: T) -> <T as sealed::VectorCmpGt<U>>::Result
3714where
3715 T: sealed::VectorCmpGt<U>,
3716{
3717 vec_cmpgt(b, a)
3718}
3719
3720#[inline]
3722#[target_feature(enable = "altivec")]
3723#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3724pub unsafe fn vec_cmple(a: vector_float, b: vector_float) -> vector_bool_int {
3725 vec_cmpge(b, a)
3726}
3727
3728#[inline]
3730#[target_feature(enable = "altivec")]
3731#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3732pub unsafe fn vec_cmpgt<T, U>(a: T, b: U) -> <T as sealed::VectorCmpGt<U>>::Result
3733where
3734 T: sealed::VectorCmpGt<U>,
3735{
3736 a.vec_cmpgt(b)
3737}
3738
3739#[inline]
3741#[target_feature(enable = "altivec")]
3742#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3743pub unsafe fn vec_cmpge(a: vector_float, b: vector_float) -> vector_bool_int {
3744 sealed::vec_vcmpgefp(a, b)
3745}
3746
3747#[inline]
3749#[target_feature(enable = "altivec")]
3750#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3751pub unsafe fn vec_cmpeq<T, U>(a: T, b: U) -> <T as sealed::VectorCmpEq<U>>::Result
3752where
3753 T: sealed::VectorCmpEq<U>,
3754{
3755 a.vec_cmpeq(b)
3756}
3757
3758#[inline]
3764#[target_feature(enable = "altivec")]
3765#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3766pub unsafe fn vec_cmpne<T, U>(a: T, b: U) -> <T as sealed::VectorCmpNe<U>>::Result
3767where
3768 T: sealed::VectorCmpNe<U>,
3769{
3770 a.vec_cmpne(b)
3771}
3772
3773#[inline]
3775#[target_feature(enable = "altivec")]
3776#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3777pub unsafe fn vec_cmpb(a: vector_float, b: vector_float) -> vector_signed_int {
3778 sealed::vec_vcmpbfp(a, b)
3779}
3780
3781#[inline]
3783#[target_feature(enable = "altivec")]
3784#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3785pub unsafe fn vec_ceil(a: vector_float) -> vector_float {
3786 sealed::vec_vceil(a)
3787}
3788
3789#[inline]
3791#[target_feature(enable = "altivec")]
3792#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3793pub unsafe fn vec_avg<T, U>(a: T, b: U) -> <T as sealed::VectorAvg<U>>::Result
3794where
3795 T: sealed::VectorAvg<U>,
3796{
3797 a.vec_avg(b)
3798}
3799
3800#[inline]
3802#[target_feature(enable = "altivec")]
3803#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3804pub unsafe fn vec_andc<T, U>(a: T, b: U) -> <T as sealed::VectorAndc<U>>::Result
3805where
3806 T: sealed::VectorAndc<U>,
3807{
3808 a.vec_andc(b)
3809}
3810
3811#[inline]
3819#[target_feature(enable = "altivec")]
3820#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3821pub unsafe fn vec_orc<T, U>(a: T, b: U) -> <T as sealed::VectorOrc<U>>::Result
3822where
3823 T: sealed::VectorOrc<U>,
3824{
3825 a.vec_orc(b)
3826}
3827
3828#[inline]
3830#[target_feature(enable = "altivec")]
3831#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3832pub unsafe fn vec_and<T, U>(a: T, b: U) -> <T as sealed::VectorAnd<U>>::Result
3833where
3834 T: sealed::VectorAnd<U>,
3835{
3836 a.vec_and(b)
3837}
3838
3839#[inline]
3841#[target_feature(enable = "altivec")]
3842#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3843pub unsafe fn vec_or<T, U>(a: T, b: U) -> <T as sealed::VectorOr<U>>::Result
3844where
3845 T: sealed::VectorOr<U>,
3846{
3847 a.vec_or(b)
3848}
3849
3850#[inline]
3858#[target_feature(enable = "altivec")]
3859#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3860pub unsafe fn vec_nand<T, U>(a: T, b: U) -> <T as sealed::VectorNand<U>>::Result
3861where
3862 T: sealed::VectorNand<U>,
3863{
3864 a.vec_nand(b)
3865}
3866
3867#[inline]
3869#[target_feature(enable = "altivec")]
3870#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3871pub unsafe fn vec_nor<T, U>(a: T, b: U) -> <T as sealed::VectorNor<U>>::Result
3872where
3873 T: sealed::VectorNor<U>,
3874{
3875 a.vec_nor(b)
3876}
3877
3878#[inline]
3880#[target_feature(enable = "altivec")]
3881#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3882pub unsafe fn vec_xor<T, U>(a: T, b: U) -> <T as sealed::VectorXor<U>>::Result
3883where
3884 T: sealed::VectorXor<U>,
3885{
3886 a.vec_xor(b)
3887}
3888
3889#[inline]
3891#[target_feature(enable = "altivec")]
3892#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3893pub unsafe fn vec_adds<T, U>(a: T, b: U) -> <T as sealed::VectorAdds<U>>::Result
3894where
3895 T: sealed::VectorAdds<U>,
3896{
3897 a.vec_adds(b)
3898}
3899
3900#[inline]
3902#[target_feature(enable = "altivec")]
3903#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3904pub unsafe fn vec_addc(a: vector_unsigned_int, b: vector_unsigned_int) -> vector_unsigned_int {
3905 sealed::vec_vaddcuw(a, b)
3906}
3907
3908#[inline]
3910#[target_feature(enable = "altivec")]
3911#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3912pub unsafe fn vec_abs<T>(a: T) -> T
3913where
3914 T: sealed::VectorAbs,
3915{
3916 a.vec_abs()
3917}
3918
3919#[inline]
3921#[target_feature(enable = "altivec")]
3922#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3923pub unsafe fn vec_abss<T>(a: T) -> T
3924where
3925 T: sealed::VectorAbss,
3926{
3927 a.vec_abss()
3928}
3929
3930#[inline]
3939#[target_feature(enable = "altivec")]
3940#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3941pub unsafe fn vec_rl<T>(a: T, b: <T as sealed::VectorRl>::Shift) -> T
3942where
3943 T: sealed::VectorRl,
3944{
3945 a.vec_rl(b)
3946}
3947
3948#[inline]
3960#[target_feature(enable = "altivec")]
3961#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3962pub unsafe fn vec_round<T>(a: T) -> T
3963where
3964 T: sealed::VectorRound,
3965{
3966 a.vec_round()
3967}
3968
3969#[inline]
3971#[target_feature(enable = "altivec")]
3972#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3973pub unsafe fn vec_splat<T, const IMM: u32>(a: T) -> T
3974where
3975 T: sealed::VectorSplat,
3976{
3977 a.vec_splat::<IMM>()
3978}
3979
3980splat! { vec_splat_u8, u8, u8x16 [vspltisb / xxspltib, "Vector Splat to Unsigned Byte"] }
3981splat! { vec_splat_s8, i8, i8x16 [vspltisb / xxspltib, "Vector Splat to Signed Byte"] }
3982splat! { vec_splat_u16, u16, u16x8 [vspltish, "Vector Splat to Unsigned Halfword"] }
3983splat! { vec_splat_s16, i16, i16x8 [vspltish, "Vector Splat to Signed Halfword"] }
3984splat! { vec_splat_u32, u32, u32x4 [vspltisw, "Vector Splat to Unsigned Word"] }
3985splat! { vec_splat_s32, i32, i32x4 [vspltisw, "Vector Splat to Signed Word"] }
3986
3987#[inline]
3989#[target_feature(enable = "altivec")]
3990#[unstable(feature = "stdarch_powerpc", issue = "111145")]
3991pub unsafe fn vec_splats<T>(a: T) -> <T as sealed::VectorSplats>::Result
3992where
3993 T: sealed::VectorSplats,
3994{
3995 a.vec_splats()
3996}
3997
3998#[inline]
4000#[target_feature(enable = "altivec")]
4001#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4002pub unsafe fn vec_sub<T, U>(a: T, b: U) -> <T as sealed::VectorSub<U>>::Result
4003where
4004 T: sealed::VectorSub<U>,
4005{
4006 a.vec_sub(b)
4007}
4008
4009#[inline]
4020#[target_feature(enable = "altivec")]
4021#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4022pub unsafe fn vec_subc<T, U>(a: T, b: U) -> <T as sealed::VectorSubc<U>>::Result
4023where
4024 T: sealed::VectorSubc<U>,
4025{
4026 a.vec_subc(b)
4027}
4028
4029#[inline]
4031#[target_feature(enable = "altivec")]
4032#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4033pub unsafe fn vec_subs<T, U>(a: T, b: U) -> <T as sealed::VectorSubs<U>>::Result
4034where
4035 T: sealed::VectorSubs<U>,
4036{
4037 a.vec_subs(b)
4038}
4039
4040#[inline]
4042#[target_feature(enable = "altivec")]
4043#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4044pub unsafe fn vec_min<T, U>(a: T, b: U) -> <T as sealed::VectorMin<U>>::Result
4045where
4046 T: sealed::VectorMin<U>,
4047{
4048 a.vec_min(b)
4049}
4050
4051#[inline]
4053#[target_feature(enable = "altivec")]
4054#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4055pub unsafe fn vec_max<T, U>(a: T, b: U) -> <T as sealed::VectorMax<U>>::Result
4056where
4057 T: sealed::VectorMax<U>,
4058{
4059 a.vec_max(b)
4060}
4061
4062#[inline]
4064#[target_feature(enable = "altivec")]
4065#[cfg_attr(test, assert_instr(mfvscr))]
4066#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4067pub unsafe fn vec_mfvscr() -> vector_unsigned_short {
4068 mfvscr()
4069}
4070
4071#[inline]
4073#[target_feature(enable = "altivec")]
4074#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4075pub unsafe fn vec_add<T, U>(a: T, b: U) -> <T as sealed::VectorAdd<U>>::Result
4076where
4077 T: sealed::VectorAdd<U>,
4078{
4079 a.vec_add(b)
4080}
4081
4082#[inline]
4089#[target_feature(enable = "altivec")]
4090#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4091pub unsafe fn vec_adde<T>(a: T, b: T, c: T) -> T
4092where
4093 T: sealed::VectorAdde,
4094{
4095 a.vec_adde(b, c)
4096}
4097
4098#[inline]
4100#[target_feature(enable = "altivec")]
4101#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4102pub unsafe fn vec_ctf<const IMM5: i32, T>(a: T) -> vector_float
4103where
4104 T: sealed::VectorCtf,
4105{
4106 a.vec_ctf::<IMM5>()
4107}
4108
4109#[inline]
4111#[target_feature(enable = "altivec")]
4112#[cfg_attr(test, assert_instr(vctsxs, IMM5 = 1))]
4113#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4114pub unsafe fn vec_cts<const IMM5: i32>(a: vector_float) -> vector_signed_int {
4115 static_assert_uimm_bits!(IMM5, 5);
4116
4117 vctsxs(a, IMM5)
4118}
4119
4120#[inline]
4122#[target_feature(enable = "altivec")]
4123#[cfg_attr(test, assert_instr(vctuxs, IMM5 = 1))]
4124#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4125pub unsafe fn vec_ctu<const IMM5: i32>(a: vector_float) -> vector_unsigned_int {
4126 static_assert_uimm_bits!(IMM5, 5);
4127
4128 vctuxs(a, IMM5)
4129}
4130
4131#[cfg(target_endian = "little")]
4133mod endian {
4134 use super::*;
4135 #[inline]
4137 #[target_feature(enable = "altivec")]
4138 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
4139 pub unsafe fn vec_perm<T>(a: T, b: T, c: vector_unsigned_char) -> T
4140 where
4141 T: sealed::VectorPerm,
4142 {
4143 let d = transmute(u8x16::new(
4147 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
4148 ));
4149 let c = simd_xor(c, d);
4150
4151 b.vec_vperm(a, c)
4152 }
4153
4154 #[inline]
4156 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
4157 #[target_feature(enable = "altivec")]
4158 pub unsafe fn vec_sum2s(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int {
4159 let flip = transmute(u8x16::new(
4163 4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11,
4164 ));
4165 let b = vec_perm(b, b, flip);
4166 let c = vsum2sws(a, b);
4167
4168 vec_perm(c, c, flip)
4169 }
4170
4171 #[inline]
4174 #[target_feature(enable = "altivec")]
4175 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
4176 pub unsafe fn vec_mule<T, U>(a: T, b: T) -> U
4177 where
4178 T: sealed::VectorMulo<U>,
4179 {
4180 a.vec_mulo(b)
4181 }
4182 #[inline]
4184 #[target_feature(enable = "altivec")]
4185 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
4186 pub unsafe fn vec_mulo<T, U>(a: T, b: T) -> U
4187 where
4188 T: sealed::VectorMule<U>,
4189 {
4190 a.vec_mule(b)
4191 }
4192}
4193
4194#[inline]
4202#[target_feature(enable = "altivec")]
4203#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4204pub unsafe fn vec_mul<T>(a: T, b: T) -> T
4205where
4206 T: sealed::VectorMul,
4207{
4208 a.vec_mul(b)
4209}
4210
4211#[inline]
4213#[target_feature(enable = "altivec")]
4214#[cfg_attr(test, assert_instr(vmhaddshs))]
4215#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4216pub unsafe fn vec_madds(
4217 a: vector_signed_short,
4218 b: vector_signed_short,
4219 c: vector_signed_short,
4220) -> vector_signed_short {
4221 vmhaddshs(a, b, c)
4222}
4223
4224#[inline]
4226#[target_feature(enable = "altivec")]
4227#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4228pub unsafe fn vec_mladd<T, U>(a: T, b: U, c: U) -> <T as sealed::VectorMladd<U>>::Result
4229where
4230 T: sealed::VectorMladd<U>,
4231{
4232 a.vec_mladd(b, c)
4233}
4234
4235#[inline]
4237#[target_feature(enable = "altivec")]
4238#[cfg_attr(test, assert_instr(vmhraddshs))]
4239#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4240pub unsafe fn vec_mradds(
4241 a: vector_signed_short,
4242 b: vector_signed_short,
4243 c: vector_signed_short,
4244) -> vector_signed_short {
4245 vmhraddshs(a, b, c)
4246}
4247
4248#[inline]
4250#[target_feature(enable = "altivec")]
4251#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4252pub unsafe fn vec_msum<T, B, U>(a: T, b: B, c: U) -> U
4253where
4254 T: sealed::VectorMsum<B, U>,
4255{
4256 a.vec_msum(b, c)
4257}
4258
4259#[inline]
4261#[target_feature(enable = "altivec")]
4262#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4263pub unsafe fn vec_msums<T, U>(a: T, b: T, c: U) -> U
4264where
4265 T: sealed::VectorMsums<U>,
4266{
4267 a.vec_msums(b, c)
4268}
4269
4270#[inline]
4272#[target_feature(enable = "altivec")]
4273#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4274pub unsafe fn vec_madd(a: vector_float, b: vector_float, c: vector_float) -> vector_float {
4275 vmaddfp(a, b, c)
4276}
4277
4278#[inline]
4280#[target_feature(enable = "altivec")]
4281#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4282pub unsafe fn vec_nmsub(a: vector_float, b: vector_float, c: vector_float) -> vector_float {
4283 vnmsubfp(a, b, c)
4284}
4285
4286#[inline]
4296#[target_feature(enable = "altivec")]
4297#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4298pub unsafe fn vec_sel<T, U>(a: T, b: T, c: U) -> T
4299where
4300 T: sealed::VectorSel<U>,
4301{
4302 a.vec_sel(b, c)
4303}
4304
4305#[inline]
4307#[target_feature(enable = "altivec")]
4308#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4309pub unsafe fn vec_sum4s<T, U>(a: T, b: U) -> U
4310where
4311 T: sealed::VectorSum4s<U>,
4312{
4313 a.vec_sum4s(b)
4314}
4315
4316#[inline]
4318#[target_feature(enable = "altivec")]
4319#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4320pub unsafe fn vec_all_eq<T, U>(a: T, b: U) -> <T as sealed::VectorAllEq<U>>::Result
4321where
4322 T: sealed::VectorAllEq<U>,
4323{
4324 a.vec_all_eq(b)
4325}
4326
4327#[inline]
4329#[target_feature(enable = "altivec")]
4330#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4331pub unsafe fn vec_any_eq<T, U>(a: T, b: U) -> <T as sealed::VectorAnyEq<U>>::Result
4332where
4333 T: sealed::VectorAnyEq<U>,
4334{
4335 a.vec_any_eq(b)
4336}
4337
4338#[inline]
4340#[target_feature(enable = "altivec")]
4341#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4342pub unsafe fn vec_all_ge<T, U>(a: T, b: U) -> <T as sealed::VectorAllGe<U>>::Result
4343where
4344 T: sealed::VectorAllGe<U>,
4345{
4346 a.vec_all_ge(b)
4347}
4348
4349#[inline]
4351#[target_feature(enable = "altivec")]
4352#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4353pub unsafe fn vec_any_ge<T, U>(a: T, b: U) -> <T as sealed::VectorAnyGe<U>>::Result
4354where
4355 T: sealed::VectorAnyGe<U>,
4356{
4357 a.vec_any_ge(b)
4358}
4359
4360#[inline]
4362#[target_feature(enable = "altivec")]
4363#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4364pub unsafe fn vec_all_gt<T, U>(a: T, b: U) -> <T as sealed::VectorAllGt<U>>::Result
4365where
4366 T: sealed::VectorAllGt<U>,
4367{
4368 a.vec_all_gt(b)
4369}
4370
4371#[inline]
4373#[target_feature(enable = "altivec")]
4374#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4375pub unsafe fn vec_any_gt<T, U>(a: T, b: U) -> <T as sealed::VectorAnyGt<U>>::Result
4376where
4377 T: sealed::VectorAnyGt<U>,
4378{
4379 a.vec_any_gt(b)
4380}
4381
4382#[inline]
4384#[target_feature(enable = "altivec")]
4385#[cfg_attr(test, assert_instr("vcmpbfp."))]
4386#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4387pub unsafe fn vec_all_in(a: vector_float, b: vector_float) -> bool {
4388 vcmpbfp_p(0, a, b) != 0
4389}
4390
4391#[inline]
4393#[target_feature(enable = "altivec")]
4394#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4395pub unsafe fn vec_all_le<T, U>(a: U, b: T) -> <T as sealed::VectorAllGe<U>>::Result
4396where
4397 T: sealed::VectorAllGe<U>,
4398{
4399 b.vec_all_ge(a)
4400}
4401
4402#[inline]
4404#[target_feature(enable = "altivec")]
4405#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4406pub unsafe fn vec_any_le<T, U>(a: U, b: T) -> <T as sealed::VectorAnyGe<U>>::Result
4407where
4408 T: sealed::VectorAnyGe<U>,
4409{
4410 b.vec_any_ge(a)
4411}
4412
4413#[inline]
4415#[target_feature(enable = "altivec")]
4416#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4417pub unsafe fn vec_all_lt<T, U>(a: U, b: T) -> <T as sealed::VectorAllGt<U>>::Result
4418where
4419 T: sealed::VectorAllGt<U>,
4420{
4421 b.vec_all_gt(a)
4422}
4423
4424#[inline]
4426#[target_feature(enable = "altivec")]
4427#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4428pub unsafe fn vec_any_lt<T, U>(a: U, b: T) -> <T as sealed::VectorAnyGt<U>>::Result
4429where
4430 T: sealed::VectorAnyGt<U>,
4431{
4432 b.vec_any_gt(a)
4433}
4434
4435#[inline]
4437#[target_feature(enable = "altivec")]
4438#[cfg_attr(test, assert_instr("vcmpeqfp."))]
4439#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4440pub unsafe fn vec_all_nan(a: vector_float) -> bool {
4441 vcmpeqfp_p(0, a, a) != 0
4442}
4443
4444#[inline]
4446#[target_feature(enable = "altivec")]
4447#[cfg_attr(test, assert_instr("vcmpeqfp."))]
4448#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4449pub unsafe fn vec_any_nan(a: vector_float) -> bool {
4450 vcmpeqfp_p(3, a, a) != 0
4451}
4452
4453#[inline]
4455#[target_feature(enable = "altivec")]
4456#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4457pub unsafe fn vec_all_ne<T, U>(a: T, b: U) -> <T as sealed::VectorAllNe<U>>::Result
4458where
4459 T: sealed::VectorAllNe<U>,
4460{
4461 a.vec_all_ne(b)
4462}
4463
4464#[inline]
4466#[target_feature(enable = "altivec")]
4467#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4468pub unsafe fn vec_any_ne<T, U>(a: T, b: U) -> <T as sealed::VectorAnyNe<U>>::Result
4469where
4470 T: sealed::VectorAnyNe<U>,
4471{
4472 a.vec_any_ne(b)
4473}
4474
4475#[inline]
4477#[target_feature(enable = "altivec")]
4478#[cfg_attr(test, assert_instr("vcmpgefp."))]
4479#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4480pub unsafe fn vec_all_nge(a: vector_float, b: vector_float) -> bool {
4481 vcmpgefp_p(0, a, b) != 0
4482}
4483
4484#[inline]
4486#[target_feature(enable = "altivec")]
4487#[cfg_attr(test, assert_instr("vcmpgtfp."))]
4488#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4489pub unsafe fn vec_all_ngt(a: vector_float, b: vector_float) -> bool {
4490 vcmpgtfp_p(0, a, b) != 0
4491}
4492
4493#[inline]
4495#[target_feature(enable = "altivec")]
4496#[cfg_attr(test, assert_instr("vcmpgefp."))]
4497#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4498pub unsafe fn vec_all_nle(a: vector_float, b: vector_float) -> bool {
4499 vcmpgefp_p(0, b, a) != 0
4500}
4501
4502#[inline]
4504#[target_feature(enable = "altivec")]
4505#[cfg_attr(test, assert_instr("vcmpgtfp."))]
4506#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4507pub unsafe fn vec_all_nlt(a: vector_float, b: vector_float) -> bool {
4508 vcmpgtfp_p(0, b, a) != 0
4509}
4510
4511#[inline]
4513#[target_feature(enable = "altivec")]
4514#[cfg_attr(test, assert_instr("vcmpgefp."))]
4515#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4516pub unsafe fn vec_all_numeric(a: vector_float) -> bool {
4517 vcmpgefp_p(2, a, a) != 0
4518}
4519
4520#[inline]
4522#[target_feature(enable = "altivec")]
4523#[cfg_attr(test, assert_instr("vcmpgefp."))]
4524#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4525pub unsafe fn vec_any_nge(a: vector_float, b: vector_float) -> bool {
4526 vcmpgefp_p(3, a, b) != 0
4527}
4528
4529#[inline]
4531#[target_feature(enable = "altivec")]
4532#[cfg_attr(test, assert_instr("vcmpgtfp."))]
4533#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4534pub unsafe fn vec_any_ngt(a: vector_float, b: vector_float) -> bool {
4535 vcmpgtfp_p(3, a, b) != 0
4536}
4537
4538#[inline]
4540#[target_feature(enable = "altivec")]
4541#[cfg_attr(test, assert_instr("vcmpgefp."))]
4542#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4543pub unsafe fn vec_any_nle(a: vector_float, b: vector_float) -> bool {
4544 vcmpgefp_p(3, b, a) != 0
4545}
4546
4547#[inline]
4549#[target_feature(enable = "altivec")]
4550#[cfg_attr(test, assert_instr("vcmpgtfp."))]
4551#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4552pub unsafe fn vec_any_nlt(a: vector_float, b: vector_float) -> bool {
4553 vcmpgtfp_p(3, b, a) != 0
4554}
4555
4556#[inline]
4558#[target_feature(enable = "altivec")]
4559#[cfg_attr(test, assert_instr("vcmpgefp."))]
4560#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4561pub unsafe fn vec_any_numeric(a: vector_float) -> bool {
4562 vcmpgefp_p(1, a, a) != 0
4563}
4564
4565#[inline]
4575#[target_feature(enable = "altivec")]
4576#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4577pub unsafe fn vec_cntlz<T>(a: T) -> T
4578where
4579 T: sealed::VectorCntlz,
4580{
4581 a.vec_cntlz()
4582}
4583
4584#[inline]
4586#[target_feature(enable = "altivec")]
4587#[cfg_attr(test, assert_instr("vcmpeqfp."))]
4588#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4589pub unsafe fn vec_any_out(a: vector_float) -> bool {
4590 vcmpeqfp_p(1, a, a) != 0
4591}
4592
4593#[cfg(target_endian = "big")]
4594mod endian {
4595 use super::*;
4596 #[inline]
4598 #[target_feature(enable = "altivec")]
4599 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
4600 pub unsafe fn vec_perm<T>(a: T, b: T, c: vector_unsigned_char) -> T
4601 where
4602 T: sealed::VectorPerm,
4603 {
4604 a.vec_vperm(b, c)
4605 }
4606
4607 #[inline]
4609 #[target_feature(enable = "altivec")]
4610 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
4611 pub unsafe fn vec_sum2s(a: vector_signed_int, b: vector_signed_int) -> vector_signed_int {
4612 vsum2sws(a, b)
4613 }
4614
4615 #[inline]
4617 #[target_feature(enable = "altivec")]
4618 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
4619 pub unsafe fn vec_mule<T, U>(a: T, b: T) -> U
4620 where
4621 T: sealed::VectorMule<U>,
4622 {
4623 a.vec_mule(b)
4624 }
4625 #[inline]
4627 #[target_feature(enable = "altivec")]
4628 #[unstable(feature = "stdarch_powerpc", issue = "111145")]
4629 pub unsafe fn vec_mulo<T, U>(a: T, b: T) -> U
4630 where
4631 T: sealed::VectorMulo<U>,
4632 {
4633 a.vec_mulo(b)
4634 }
4635}
4636
4637#[unstable(feature = "stdarch_powerpc", issue = "111145")]
4638pub use self::endian::*;
4639
4640#[cfg(test)]
4641mod tests {
4642 use super::*;
4643
4644 use std::mem::transmute;
4645
4646 use crate::core_arch::simd::*;
4647 use stdarch_test::simd_test;
4648
4649 macro_rules! test_vec_2 {
4650 { $name: ident, $fn:ident, $ty: ident, [$($a:expr),+], [$($b:expr),+], [$($d:expr),+] } => {
4651 test_vec_2! { $name, $fn, $ty -> $ty, [$($a),+], [$($b),+], [$($d),+] }
4652 };
4653 { $name: ident, $fn:ident, $ty: ident -> $ty_out: ident, [$($a:expr),+], [$($b:expr),+], [$($d:expr),+] } => {
4654 #[simd_test(enable = "altivec")]
4655 unsafe fn $name() {
4656 let a: s_t_l!($ty) = transmute($ty::new($($a),+));
4657 let b: s_t_l!($ty) = transmute($ty::new($($b),+));
4658
4659 let d = $ty_out::new($($d),+);
4660 let r : $ty_out = transmute($fn(a, b));
4661 assert_eq!(d, r);
4662 }
4663 };
4664 { $name: ident, $fn:ident, $ty: ident -> $ty_out: ident, [$($a:expr),+], [$($b:expr),+], $d:expr } => {
4665 #[simd_test(enable = "altivec")]
4666 unsafe fn $name() {
4667 let a: s_t_l!($ty) = transmute($ty::new($($a),+));
4668 let b: s_t_l!($ty) = transmute($ty::new($($b),+));
4669
4670 let r : $ty_out = transmute($fn(a, b));
4671 assert_eq!($d, r);
4672 }
4673 }
4674 }
4675
4676 macro_rules! test_vec_1 {
4677 { $name: ident, $fn:ident, f32x4, [$($a:expr),+], ~[$($d:expr),+] } => {
4678 #[simd_test(enable = "altivec")]
4679 unsafe fn $name() {
4680 let a: vector_float = transmute(f32x4::new($($a),+));
4681
4682 let d: vector_float = transmute(f32x4::new($($d),+));
4683 let r = transmute(vec_cmple(vec_abs(vec_sub($fn(a), d)), vec_splats(f32::EPSILON)));
4684 let e = m32x4::new(true, true, true, true);
4685 assert_eq!(e, r);
4686 }
4687 };
4688 { $name: ident, $fn:ident, $ty: ident, [$($a:expr),+], [$($d:expr),+] } => {
4689 test_vec_1! { $name, $fn, $ty -> $ty, [$($a),+], [$($d),+] }
4690 };
4691 { $name: ident, $fn:ident, $ty: ident -> $ty_out: ident, [$($a:expr),+], [$($d:expr),+] } => {
4692 #[simd_test(enable = "altivec")]
4693 unsafe fn $name() {
4694 let a: s_t_l!($ty) = transmute($ty::new($($a),+));
4695
4696 let d = $ty_out::new($($d),+);
4697 let r : $ty_out = transmute($fn(a));
4698 assert_eq!(d, r);
4699 }
4700 }
4701 }
4702
4703 #[simd_test(enable = "altivec")]
4704 unsafe fn test_vec_ld() {
4705 let pat = [
4706 u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15),
4707 u8x16::new(
4708 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
4709 ),
4710 ];
4711
4712 for off in 0..16 {
4713 let v: u8x16 = transmute(vec_ld(0, (pat.as_ptr() as *const u8).offset(off)));
4714 assert_eq!(
4715 v,
4716 u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
4717 );
4718 }
4719 for off in 16..32 {
4720 let v: u8x16 = transmute(vec_ld(0, (pat.as_ptr() as *const u8).offset(off)));
4721 assert_eq!(
4722 v,
4723 u8x16::new(16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31)
4724 );
4725 }
4726 }
4727
4728 #[simd_test(enable = "altivec")]
4729 unsafe fn test_vec_xl() {
4730 let pat = [
4731 u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15),
4732 u8x16::new(
4733 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
4734 ),
4735 ];
4736
4737 for off in 0..16 {
4738 let val: u8x16 = transmute(vec_xl(0, (pat.as_ptr() as *const u8).offset(off)));
4739 for i in 0..16 {
4740 let v = val.extract(i);
4741 assert_eq!(off as usize + i, v as usize);
4742 }
4743 }
4744 }
4745
4746 #[simd_test(enable = "altivec")]
4747 unsafe fn test_vec_xst() {
4748 let v: vector_unsigned_char = transmute(u8x16::new(
4749 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
4750 ));
4751
4752 for off in 0..16 {
4753 let mut buf = [0u8; 32];
4754 vec_xst(v, 0, (buf.as_mut_ptr() as *mut u8).offset(off));
4755 for i in 0..16 {
4756 assert_eq!(i as u8, buf[off as usize..][i]);
4757 }
4758 }
4759 }
4760
4761 #[simd_test(enable = "altivec")]
4762 unsafe fn test_vec_ldl() {
4763 let pat = [
4764 u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15),
4765 u8x16::new(
4766 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
4767 ),
4768 ];
4769
4770 for off in 0..16 {
4771 let v: u8x16 = transmute(vec_ldl(0, (pat.as_ptr() as *const u8).offset(off)));
4772 assert_eq!(
4773 v,
4774 u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
4775 );
4776 }
4777 for off in 16..32 {
4778 let v: u8x16 = transmute(vec_ldl(0, (pat.as_ptr() as *const u8).offset(off)));
4779 assert_eq!(
4780 v,
4781 u8x16::new(16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31)
4782 );
4783 }
4784 }
4785
4786 #[simd_test(enable = "altivec")]
4787 unsafe fn test_vec_lde_u8() {
4788 let pat = [u8x16::new(
4789 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
4790 )];
4791 for off in 0..16 {
4792 let v: u8x16 = transmute(vec_lde(off, pat.as_ptr() as *const u8));
4793 assert_eq!(off as u8, v.extract(off as _));
4794 }
4795 }
4796
4797 #[simd_test(enable = "altivec")]
4798 unsafe fn test_vec_lde_u16() {
4799 let pat = [u16x8::new(0, 1, 2, 3, 4, 5, 6, 7)];
4800 for off in 0..8 {
4801 let v: u16x8 = transmute(vec_lde(off * 2, pat.as_ptr() as *const u8));
4802 assert_eq!(off as u16, v.extract(off as _));
4803 }
4804 }
4805
4806 #[simd_test(enable = "altivec")]
4807 unsafe fn test_vec_lde_u32() {
4808 let pat = [u32x4::new(0, 1, 2, 3)];
4809 for off in 0..4 {
4810 let v: u32x4 = transmute(vec_lde(off * 4, pat.as_ptr() as *const u8));
4811 assert_eq!(off as u32, v.extract(off as _));
4812 }
4813 }
4814
4815 test_vec_1! { test_vec_floor, vec_floor, f32x4,
4816 [1.1, 1.9, -0.5, -0.9],
4817 [1.0, 1.0, -1.0, -1.0]
4818 }
4819
4820 test_vec_1! { test_vec_expte, vec_expte, f32x4,
4821 [0.0, 2.0, 2.0, -1.0],
4822 ~[1.0, 4.0, 4.0, 0.5]
4823 }
4824
4825 test_vec_2! { test_vec_cmpgt_i8, vec_cmpgt, i8x16 -> m8x16,
4826 [1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4827 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4828 [true, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false]
4829 }
4830
4831 test_vec_2! { test_vec_cmpgt_u8, vec_cmpgt, u8x16 -> m8x16,
4832 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4833 [0, 0, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4834 [true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false]
4835 }
4836
4837 test_vec_2! { test_vec_cmpgt_i16, vec_cmpgt, i16x8 -> m16x8,
4838 [1, -1, 0, 0, 0, 0, 0, 0],
4839 [0, 0, -1, 1, 0, 0, 0, 0],
4840 [true, false, true, false, false, false, false, false]
4841 }
4842
4843 test_vec_2! { test_vec_cmpgt_u16, vec_cmpgt, u16x8 -> m16x8,
4844 [1, 255, 0, 0, 0, 0, 0, 0],
4845 [0, 0, 255, 1, 0, 0, 0, 0],
4846 [true, true, false, false, false, false, false, false]
4847 }
4848
4849 test_vec_2! { test_vec_cmpgt_i32, vec_cmpgt, i32x4 -> m32x4,
4850 [1, -1, 0, 0],
4851 [0, -1, 0, 1],
4852 [true, false, false, false]
4853 }
4854
4855 test_vec_2! { test_vec_cmpgt_u32, vec_cmpgt, u32x4 -> m32x4,
4856 [1, 255, 0, 0],
4857 [0, 255, 0, 1],
4858 [true, false, false, false]
4859 }
4860
4861 test_vec_2! { test_vec_cmpge, vec_cmpge, f32x4 -> m32x4,
4862 [0.1, -0.1, 0.0, 0.99],
4863 [0.1, 0.0, 0.1, 1.0],
4864 [true, false, false, false]
4865 }
4866
4867 test_vec_2! { test_vec_cmpeq_i8, vec_cmpeq, i8x16 -> m8x16,
4868 [1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4869 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4870 [false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true]
4871 }
4872
4873 test_vec_2! { test_vec_cmpeq_u8, vec_cmpeq, u8x16 -> m8x16,
4874 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4875 [0, 0, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4876 [false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true]
4877 }
4878
4879 test_vec_2! { test_vec_cmpeq_i16, vec_cmpeq, i16x8 -> m16x8,
4880 [1, -1, 0, 0, 0, 0, 0, 0],
4881 [0, 0, -1, 1, 0, 0, 0, 0],
4882 [false, false, false, false, true, true, true, true]
4883 }
4884
4885 test_vec_2! { test_vec_cmpeq_u16, vec_cmpeq, u16x8 -> m16x8,
4886 [1, 255, 0, 0, 0, 0, 0, 0],
4887 [0, 0, 255, 1, 0, 0, 0, 0],
4888 [false, false, false, false, true, true, true, true]
4889 }
4890
4891 test_vec_2! { test_vec_cmpeq_i32, vec_cmpeq, i32x4 -> m32x4,
4892 [1, -1, 0, 0],
4893 [0, -1, 0, 1],
4894 [false, true, true, false]
4895 }
4896
4897 test_vec_2! { test_vec_cmpeq_u32, vec_cmpeq, u32x4 -> m32x4,
4898 [1, 255, 0, 0],
4899 [0, 255, 0, 1],
4900 [false, true, true, false]
4901 }
4902
4903 test_vec_2! { test_vec_cmpne_i8, vec_cmpne, i8x16 -> m8x16,
4904 [1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4905 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4906 [true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false]
4907 }
4908
4909 test_vec_2! { test_vec_cmpne_u8, vec_cmpne, u8x16 -> m8x16,
4910 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4911 [0, 0, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4912 [true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false]
4913 }
4914
4915 test_vec_2! { test_vec_cmpne_i16, vec_cmpne, i16x8 -> m16x8,
4916 [1, -1, 0, 0, 0, 0, 0, 0],
4917 [0, 0, -1, 1, 0, 0, 0, 0],
4918 [true, true, true, true, false, false, false, false]
4919 }
4920
4921 test_vec_2! { test_vec_cmpne_u16, vec_cmpne, u16x8 -> m16x8,
4922 [1, 255, 0, 0, 0, 0, 0, 0],
4923 [0, 0, 255, 1, 0, 0, 0, 0],
4924 [true, true, true, true, false, false, false, false]
4925 }
4926
4927 test_vec_2! { test_vec_cmpne_i32, vec_cmpne, i32x4 -> m32x4,
4928 [1, -1, 0, 0],
4929 [0, -1, 0, 1],
4930 [true, false, false, true]
4931 }
4932
4933 test_vec_2! { test_vec_cmpne_u32, vec_cmpne, u32x4 -> m32x4,
4934 [1, 255, 0, 0],
4935 [0, 255, 0, 1],
4936 [true, false, false, true]
4937 }
4938
4939 test_vec_2! { test_vec_all_eq_i8_false, vec_all_eq, i8x16 -> bool,
4940 [1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4941 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4942 false
4943 }
4944
4945 test_vec_2! { test_vec_all_eq_u8_false, vec_all_eq, u8x16 -> bool,
4946 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4947 [0, 0, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4948 false
4949 }
4950
4951 test_vec_2! { test_vec_all_eq_i16_false, vec_all_eq, i16x8 -> bool,
4952 [1, -1, 0, 0, 0, 0, 0, 0],
4953 [0, 0, -1, 1, 0, 0, 0, 0],
4954 false
4955 }
4956
4957 test_vec_2! { test_vec_all_eq_u16_false, vec_all_eq, u16x8 -> bool,
4958 [1, 255, 0, 0, 0, 0, 0, 0],
4959 [0, 0, 255, 1, 0, 0, 0, 0],
4960 false
4961 }
4962
4963 test_vec_2! { test_vec_all_eq_i32_false, vec_all_eq, i32x4 -> bool,
4964 [1, -1, 0, 0],
4965 [0, -1, 0, 1],
4966 false
4967 }
4968
4969 test_vec_2! { test_vec_all_eq_u32_false, vec_all_eq, u32x4 -> bool,
4970 [1, 255, 0, 0],
4971 [0, 255, 0, 1],
4972 false
4973 }
4974
4975 test_vec_2! { test_vec_all_eq_i8_true, vec_all_eq, i8x16 -> bool,
4976 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4977 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4978 true
4979 }
4980
4981 test_vec_2! { test_vec_all_eq_u8_true, vec_all_eq, u8x16 -> bool,
4982 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4983 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
4984 true
4985 }
4986
4987 test_vec_2! { test_vec_all_eq_i16_true, vec_all_eq, i16x8 -> bool,
4988 [1, -1, 1, 0, 0, 0, 0, 0],
4989 [1, -1, 1, 0, 0, 0, 0, 0],
4990 true
4991 }
4992
4993 test_vec_2! { test_vec_all_eq_u16_true, vec_all_eq, u16x8 -> bool,
4994 [1, 255, 1, 0, 0, 0, 0, 0],
4995 [1, 255, 1, 0, 0, 0, 0, 0],
4996 true
4997 }
4998
4999 test_vec_2! { test_vec_all_eq_i32_true, vec_all_eq, i32x4 -> bool,
5000 [1, -1, 0, 1],
5001 [1, -1, 0, 1],
5002 true
5003 }
5004
5005 test_vec_2! { test_vec_all_eq_u32_true, vec_all_eq, u32x4 -> bool,
5006 [1, 255, 0, 1],
5007 [1, 255, 0, 1],
5008 true
5009 }
5010
5011 test_vec_2! { test_vec_any_eq_i8_false, vec_any_eq, i8x16 -> bool,
5012 [1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5013 [0, 0, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
5014 false
5015 }
5016
5017 test_vec_2! { test_vec_any_eq_u8_false, vec_any_eq, u8x16 -> bool,
5018 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5019 [0, 0, 255, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
5020 false
5021 }
5022
5023 test_vec_2! { test_vec_any_eq_i16_false, vec_any_eq, i16x8 -> bool,
5024 [1, -1, 0, 0, 0, 0, 0, 0],
5025 [0, 0, -1, 1, 1, 1, 1, 1],
5026 false
5027 }
5028
5029 test_vec_2! { test_vec_any_eq_u16_false, vec_any_eq, u16x8 -> bool,
5030 [1, 255, 0, 0, 0, 0, 0, 0],
5031 [0, 0, 255, 1, 1, 1, 1, 1],
5032 false
5033 }
5034
5035 test_vec_2! { test_vec_any_eq_i32_false, vec_any_eq, i32x4 -> bool,
5036 [1, -1, 0, 0],
5037 [0, -2, 1, 1],
5038 false
5039 }
5040
5041 test_vec_2! { test_vec_any_eq_u32_false, vec_any_eq, u32x4 -> bool,
5042 [1, 2, 1, 0],
5043 [0, 255, 0, 1],
5044 false
5045 }
5046
5047 test_vec_2! { test_vec_any_eq_i8_true, vec_any_eq, i8x16 -> bool,
5048 [1, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5049 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5050 true
5051 }
5052
5053 test_vec_2! { test_vec_any_eq_u8_true, vec_any_eq, u8x16 -> bool,
5054 [0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5055 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5056 true
5057 }
5058
5059 test_vec_2! { test_vec_any_eq_i16_true, vec_any_eq, i16x8 -> bool,
5060 [0, -1, 1, 0, 0, 0, 0, 0],
5061 [1, -1, 1, 0, 0, 0, 0, 0],
5062 true
5063 }
5064
5065 test_vec_2! { test_vec_any_eq_u16_true, vec_any_eq, u16x8 -> bool,
5066 [0, 255, 1, 0, 0, 0, 0, 0],
5067 [1, 255, 1, 0, 0, 0, 0, 0],
5068 true
5069 }
5070
5071 test_vec_2! { test_vec_any_eq_i32_true, vec_any_eq, i32x4 -> bool,
5072 [0, -1, 0, 1],
5073 [1, -1, 0, 1],
5074 true
5075 }
5076
5077 test_vec_2! { test_vec_any_eq_u32_true, vec_any_eq, u32x4 -> bool,
5078 [0, 255, 0, 1],
5079 [1, 255, 0, 1],
5080 true
5081 }
5082
5083 test_vec_2! { test_vec_all_ge_i8_false, vec_all_ge, i8x16 -> bool,
5084 [1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5085 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5086 false
5087 }
5088
5089 test_vec_2! { test_vec_all_ge_u8_false, vec_all_ge, u8x16 -> bool,
5090 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5091 [0, 0, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5092 false
5093 }
5094
5095 test_vec_2! { test_vec_all_ge_i16_false, vec_all_ge, i16x8 -> bool,
5096 [1, -1, 0, 0, 0, 0, 0, 0],
5097 [0, 0, -1, 1, 0, 0, 0, 0],
5098 false
5099 }
5100
5101 test_vec_2! { test_vec_all_ge_u16_false, vec_all_ge, u16x8 -> bool,
5102 [1, 255, 0, 0, 0, 0, 0, 0],
5103 [0, 0, 255, 1, 0, 0, 0, 0],
5104 false
5105 }
5106
5107 test_vec_2! { test_vec_all_ge_i32_false, vec_all_ge, i32x4 -> bool,
5108 [1, -1, 0, 0],
5109 [0, -1, 0, 1],
5110 false
5111 }
5112
5113 test_vec_2! { test_vec_all_ge_u32_false, vec_all_ge, u32x4 -> bool,
5114 [1, 255, 0, 0],
5115 [0, 255, 1, 1],
5116 false
5117 }
5118
5119 test_vec_2! { test_vec_all_ge_i8_true, vec_all_ge, i8x16 -> bool,
5120 [0, 0, -1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
5121 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5122 true
5123 }
5124
5125 test_vec_2! { test_vec_all_ge_u8_true, vec_all_ge, u8x16 -> bool,
5126 [1, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5127 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5128 true
5129 }
5130
5131 test_vec_2! { test_vec_all_ge_i16_true, vec_all_ge, i16x8 -> bool,
5132 [1, -1, 42, 0, 0, 0, 0, 0],
5133 [1, -5, 2, 0, 0, 0, 0, 0],
5134 true
5135 }
5136
5137 test_vec_2! { test_vec_all_ge_u16_true, vec_all_ge, u16x8 -> bool,
5138 [42, 255, 1, 0, 0, 0, 0, 0],
5139 [2, 255, 1, 0, 0, 0, 0, 0],
5140 true
5141 }
5142
5143 test_vec_2! { test_vec_all_ge_i32_true, vec_all_ge, i32x4 -> bool,
5144 [1, -1, 0, 1],
5145 [0, -1, 0, 1],
5146 true
5147 }
5148
5149 test_vec_2! { test_vec_all_ge_u32_true, vec_all_ge, u32x4 -> bool,
5150 [1, 255, 0, 1],
5151 [1, 254, 0, 0],
5152 true
5153 }
5154
5155 test_vec_2! { test_vec_any_ge_i8_false, vec_any_ge, i8x16 -> bool,
5156 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5157 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
5158 false
5159 }
5160
5161 test_vec_2! { test_vec_any_ge_u8_false, vec_any_ge, u8x16 -> bool,
5162 [1, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5163 [42, 255, 255, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
5164 false
5165 }
5166
5167 test_vec_2! { test_vec_any_ge_i16_false, vec_any_ge, i16x8 -> bool,
5168 [1, -1, -2, 0, 0, 0, 0, 0],
5169 [2, 0, -1, 1, 1, 1, 1, 1],
5170 false
5171 }
5172
5173 test_vec_2! { test_vec_any_ge_u16_false, vec_any_ge, u16x8 -> bool,
5174 [1, 2, 0, 0, 0, 0, 0, 0],
5175 [2, 42, 255, 1, 1, 1, 1, 1],
5176 false
5177 }
5178
5179 test_vec_2! { test_vec_any_ge_i32_false, vec_any_ge, i32x4 -> bool,
5180 [1, -1, 0, 0],
5181 [2, 0, 1, 1],
5182 false
5183 }
5184
5185 test_vec_2! { test_vec_any_ge_u32_false, vec_any_ge, u32x4 -> bool,
5186 [1, 2, 1, 0],
5187 [4, 255, 4, 1],
5188 false
5189 }
5190
5191 test_vec_2! { test_vec_any_ge_i8_true, vec_any_ge, i8x16 -> bool,
5192 [1, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5193 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5194 true
5195 }
5196
5197 test_vec_2! { test_vec_any_ge_u8_true, vec_any_ge, u8x16 -> bool,
5198 [0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5199 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5200 true
5201 }
5202
5203 test_vec_2! { test_vec_any_ge_i16_true, vec_any_ge, i16x8 -> bool,
5204 [0, -1, 1, 0, 0, 0, 0, 0],
5205 [1, -1, 1, 0, 0, 0, 0, 0],
5206 true
5207 }
5208
5209 test_vec_2! { test_vec_any_ge_u16_true, vec_any_ge, u16x8 -> bool,
5210 [0, 255, 1, 0, 0, 0, 0, 0],
5211 [1, 255, 1, 0, 0, 0, 0, 0],
5212 true
5213 }
5214
5215 test_vec_2! { test_vec_any_ge_i32_true, vec_any_ge, i32x4 -> bool,
5216 [0, -1, 0, 1],
5217 [1, -1, 0, 1],
5218 true
5219 }
5220
5221 test_vec_2! { test_vec_any_ge_u32_true, vec_any_ge, u32x4 -> bool,
5222 [0, 255, 0, 1],
5223 [1, 255, 0, 1],
5224 true
5225 }
5226
5227 test_vec_2! { test_vec_all_gt_i8_false, vec_all_gt, i8x16 -> bool,
5228 [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5229 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5230 false
5231 }
5232
5233 test_vec_2! { test_vec_all_gt_u8_false, vec_all_gt, u8x16 -> bool,
5234 [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5235 [0, 0, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5236 false
5237 }
5238
5239 test_vec_2! { test_vec_all_gt_i16_false, vec_all_gt, i16x8 -> bool,
5240 [1, 0, 0, 0, 0, 0, 0, 0],
5241 [0, 0, -1, 1, 0, 0, 0, 0],
5242 false
5243 }
5244
5245 test_vec_2! { test_vec_all_gt_u16_false, vec_all_gt, u16x8 -> bool,
5246 [1, 0, 0, 0, 0, 0, 0, 0],
5247 [0, 0, 255, 1, 0, 0, 0, 0],
5248 false
5249 }
5250
5251 test_vec_2! { test_vec_all_gt_i32_false, vec_all_gt, i32x4 -> bool,
5252 [1, -1, 0, 0],
5253 [0, -1, 0, 1],
5254 false
5255 }
5256
5257 test_vec_2! { test_vec_all_gt_u32_false, vec_all_gt, u32x4 -> bool,
5258 [1, 255, 0, 0],
5259 [0, 255, 1, 1],
5260 false
5261 }
5262
5263 test_vec_2! { test_vec_all_gt_i8_true, vec_all_gt, i8x16 -> bool,
5264 [2, 1, -1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
5265 [0, 0, -2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
5266 true
5267 }
5268
5269 test_vec_2! { test_vec_all_gt_u8_true, vec_all_gt, u8x16 -> bool,
5270 [1, 255, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
5271 [0, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5272 true
5273 }
5274
5275 test_vec_2! { test_vec_all_gt_i16_true, vec_all_gt, i16x8 -> bool,
5276 [1, -1, 42, 1, 1, 1, 1, 1],
5277 [0, -5, 2, 0, 0, 0, 0, 0],
5278 true
5279 }
5280
5281 test_vec_2! { test_vec_all_gt_u16_true, vec_all_gt, u16x8 -> bool,
5282 [42, 255, 1, 1, 1, 1, 1, 1],
5283 [2, 254, 0, 0, 0, 0, 0, 0],
5284 true
5285 }
5286
5287 test_vec_2! { test_vec_all_gt_i32_true, vec_all_gt, i32x4 -> bool,
5288 [1, -1, 1, 1],
5289 [0, -2, 0, 0],
5290 true
5291 }
5292
5293 test_vec_2! { test_vec_all_gt_u32_true, vec_all_gt, u32x4 -> bool,
5294 [1, 255, 1, 1],
5295 [0, 254, 0, 0],
5296 true
5297 }
5298
5299 test_vec_2! { test_vec_any_gt_i8_false, vec_any_gt, i8x16 -> bool,
5300 [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5301 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
5302 false
5303 }
5304
5305 test_vec_2! { test_vec_any_gt_u8_false, vec_any_gt, u8x16 -> bool,
5306 [1, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5307 [42, 255, 255, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
5308 false
5309 }
5310
5311 test_vec_2! { test_vec_any_gt_i16_false, vec_any_gt, i16x8 -> bool,
5312 [1, -1, -2, 0, 0, 0, 0, 0],
5313 [2, 0, -1, 1, 1, 1, 1, 1],
5314 false
5315 }
5316
5317 test_vec_2! { test_vec_any_gt_u16_false, vec_any_gt, u16x8 -> bool,
5318 [1, 2, 0, 0, 0, 0, 0, 0],
5319 [2, 42, 255, 1, 1, 1, 1, 1],
5320 false
5321 }
5322
5323 test_vec_2! { test_vec_any_gt_i32_false, vec_any_gt, i32x4 -> bool,
5324 [1, -1, 0, 0],
5325 [2, 0, 1, 1],
5326 false
5327 }
5328
5329 test_vec_2! { test_vec_any_gt_u32_false, vec_any_gt, u32x4 -> bool,
5330 [1, 2, 1, 0],
5331 [4, 255, 4, 1],
5332 false
5333 }
5334
5335 test_vec_2! { test_vec_any_gt_i8_true, vec_any_gt, i8x16 -> bool,
5336 [1, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5337 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5338 true
5339 }
5340
5341 test_vec_2! { test_vec_any_gt_u8_true, vec_any_gt, u8x16 -> bool,
5342 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5343 [0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5344 true
5345 }
5346
5347 test_vec_2! { test_vec_any_gt_i16_true, vec_any_gt, i16x8 -> bool,
5348 [1, -1, 1, 0, 0, 0, 0, 0],
5349 [0, -1, 1, 0, 0, 0, 0, 0],
5350 true
5351 }
5352
5353 test_vec_2! { test_vec_any_gt_u16_true, vec_any_gt, u16x8 -> bool,
5354 [1, 255, 1, 0, 0, 0, 0, 0],
5355 [0, 255, 1, 0, 0, 0, 0, 0],
5356 true
5357 }
5358
5359 test_vec_2! { test_vec_any_gt_i32_true, vec_any_gt, i32x4 -> bool,
5360 [1, -1, 0, 1],
5361 [0, -1, 0, 1],
5362 true
5363 }
5364
5365 test_vec_2! { test_vec_any_gt_u32_true, vec_any_gt, u32x4 -> bool,
5366 [1, 255, 0, 1],
5367 [0, 255, 0, 1],
5368 true
5369 }
5370
5371 test_vec_2! { test_vec_all_in_true, vec_all_in, f32x4 -> bool,
5372 [0.0, -0.1, 0.0, 0.0],
5373 [0.1, 0.2, 0.0, 0.0],
5374 true
5375 }
5376
5377 test_vec_2! { test_vec_all_in_false, vec_all_in, f32x4 -> bool,
5378 [0.5, 0.4, -0.5, 0.8],
5379 [0.1, 0.4, -0.5, 0.8],
5380 false
5381 }
5382
5383 test_vec_2! { test_vec_all_le_i8_false, vec_all_le, i8x16 -> bool,
5384 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5385 [1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5386 false
5387 }
5388
5389 test_vec_2! { test_vec_all_le_u8_false, vec_all_le, u8x16 -> bool,
5390 [0, 0, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5391 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5392 false
5393 }
5394
5395 test_vec_2! { test_vec_all_le_i16_false, vec_all_le, i16x8 -> bool,
5396 [0, 0, -1, 1, 0, 0, 0, 0],
5397 [1, -1, 0, 0, 0, 0, 0, 0],
5398 false
5399 }
5400
5401 test_vec_2! { test_vec_all_le_u16_false, vec_all_le, u16x8 -> bool,
5402 [0, 0, 255, 1, 0, 0, 0, 0],
5403 [1, 255, 0, 0, 0, 0, 0, 0],
5404 false
5405 }
5406
5407 test_vec_2! { test_vec_all_le_i32_false, vec_all_le, i32x4 -> bool,
5408 [0, -1, 0, 1],
5409 [1, -1, 0, 0],
5410 false
5411 }
5412
5413 test_vec_2! { test_vec_all_le_u32_false, vec_all_le, u32x4 -> bool,
5414 [0, 255, 1, 1],
5415 [1, 255, 0, 0],
5416 false
5417 }
5418
5419 test_vec_2! { test_vec_all_le_i8_true, vec_all_le, i8x16 -> bool,
5420 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5421 [0, 0, -1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
5422 true
5423 }
5424
5425 test_vec_2! { test_vec_all_le_u8_true, vec_all_le, u8x16 -> bool,
5426 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5427 [1, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5428 true
5429 }
5430
5431 test_vec_2! { test_vec_all_le_i16_true, vec_all_le, i16x8 -> bool,
5432 [1, -5, 2, 0, 0, 0, 0, 0],
5433 [1, -1, 42, 0, 0, 0, 0, 0],
5434 true
5435 }
5436
5437 test_vec_2! { test_vec_all_le_u16_true, vec_all_le, u16x8 -> bool,
5438 [2, 255, 1, 0, 0, 0, 0, 0],
5439 [42, 255, 1, 0, 0, 0, 0, 0],
5440 true
5441 }
5442
5443 test_vec_2! { test_vec_all_le_i32_true, vec_all_le, i32x4 -> bool,
5444 [0, -1, 0, 1],
5445 [1, -1, 0, 1],
5446 true
5447 }
5448
5449 test_vec_2! { test_vec_all_le_u32_true, vec_all_le, u32x4 -> bool,
5450 [1, 254, 0, 0],
5451 [1, 255, 0, 1],
5452 true
5453 }
5454
5455 test_vec_2! { test_vec_any_le_i8_false, vec_any_le, i8x16 -> bool,
5456 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
5457 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5458 false
5459 }
5460
5461 test_vec_2! { test_vec_any_le_u8_false, vec_any_le, u8x16 -> bool,
5462 [42, 255, 255, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
5463 [1, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5464 false
5465 }
5466
5467 test_vec_2! { test_vec_any_le_i16_false, vec_any_le, i16x8 -> bool,
5468 [2, 0, -1, 1, 1, 1, 1, 1],
5469 [1, -1, -2, 0, 0, 0, 0, 0],
5470 false
5471 }
5472
5473 test_vec_2! { test_vec_any_le_u16_false, vec_any_le, u16x8 -> bool,
5474 [2, 42, 255, 1, 1, 1, 1, 1],
5475 [1, 2, 0, 0, 0, 0, 0, 0],
5476 false
5477 }
5478
5479 test_vec_2! { test_vec_any_le_i32_false, vec_any_le, i32x4 -> bool,
5480 [2, 0, 1, 1],
5481 [1, -1, 0, 0],
5482 false
5483 }
5484
5485 test_vec_2! { test_vec_any_le_u32_false, vec_any_le, u32x4 -> bool,
5486 [4, 255, 4, 1],
5487 [1, 2, 1, 0],
5488 false
5489 }
5490
5491 test_vec_2! { test_vec_any_le_i8_true, vec_any_le, i8x16 -> bool,
5492 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5493 [1, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5494 true
5495 }
5496
5497 test_vec_2! { test_vec_any_le_u8_true, vec_any_le, u8x16 -> bool,
5498 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5499 [0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5500 true
5501 }
5502
5503 test_vec_2! { test_vec_any_le_i16_true, vec_any_le, i16x8 -> bool,
5504 [1, -1, 1, 0, 0, 0, 0, 0],
5505 [0, -1, 1, 0, 0, 0, 0, 0],
5506 true
5507 }
5508
5509 test_vec_2! { test_vec_any_le_u16_true, vec_any_le, u16x8 -> bool,
5510 [1, 255, 1, 0, 0, 0, 0, 0],
5511 [0, 255, 1, 0, 0, 0, 0, 0],
5512 true
5513 }
5514
5515 test_vec_2! { test_vec_any_le_i32_true, vec_any_le, i32x4 -> bool,
5516 [1, -1, 0, 1],
5517 [0, -1, 0, 1],
5518 true
5519 }
5520
5521 test_vec_2! { test_vec_any_le_u32_true, vec_any_le, u32x4 -> bool,
5522 [1, 255, 0, 1],
5523 [0, 255, 0, 1],
5524 true
5525 }
5526
5527 test_vec_2! { test_vec_all_lt_i8_false, vec_all_lt, i8x16 -> bool,
5528 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5529 [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5530 false
5531 }
5532
5533 test_vec_2! { test_vec_all_lt_u8_false, vec_all_lt, u8x16 -> bool,
5534 [0, 0, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5535 [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5536 false
5537 }
5538
5539 test_vec_2! { test_vec_all_lt_i16_false, vec_all_lt, i16x8 -> bool,
5540 [0, 0, -1, 1, 0, 0, 0, 0],
5541 [1, 0, 0, 0, 0, 0, 0, 0],
5542 false
5543 }
5544
5545 test_vec_2! { test_vec_all_lt_u16_false, vec_all_lt, u16x8 -> bool,
5546 [0, 0, 255, 1, 0, 0, 0, 0],
5547 [1, 0, 0, 0, 0, 0, 0, 0],
5548 false
5549 }
5550
5551 test_vec_2! { test_vec_all_lt_i32_false, vec_all_lt, i32x4 -> bool,
5552 [0, -1, 0, 1],
5553 [1, -1, 0, 0],
5554 false
5555 }
5556
5557 test_vec_2! { test_vec_all_lt_u32_false, vec_all_lt, u32x4 -> bool,
5558 [0, 255, 1, 1],
5559 [1, 255, 0, 0],
5560 false
5561 }
5562
5563 test_vec_2! { test_vec_all_lt_i8_true, vec_all_lt, i8x16 -> bool,
5564 [0, 0, -2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
5565 [2, 1, -1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
5566 true
5567 }
5568
5569 test_vec_2! { test_vec_all_lt_u8_true, vec_all_lt, u8x16 -> bool,
5570 [0, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5571 [1, 255, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
5572 true
5573 }
5574
5575 test_vec_2! { test_vec_all_lt_i16_true, vec_all_lt, i16x8 -> bool,
5576 [0, -5, 2, 0, 0, 0, 0, 0],
5577 [1, -1, 42, 1, 1, 1, 1, 1],
5578 true
5579 }
5580
5581 test_vec_2! { test_vec_all_lt_u16_true, vec_all_lt, u16x8 -> bool,
5582 [2, 254, 0, 0, 0, 0, 0, 0],
5583 [42, 255, 1, 1, 1, 1, 1, 1],
5584 true
5585 }
5586
5587 test_vec_2! { test_vec_all_lt_i32_true, vec_all_lt, i32x4 -> bool,
5588 [0, -2, 0, 0],
5589 [1, -1, 1, 1],
5590 true
5591 }
5592
5593 test_vec_2! { test_vec_all_lt_u32_true, vec_all_lt, u32x4 -> bool,
5594 [0, 254, 0, 0],
5595 [1, 255, 1, 1],
5596 true
5597 }
5598
5599 test_vec_2! { test_vec_any_lt_i8_false, vec_any_lt, i8x16 -> bool,
5600 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
5601 [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5602 false
5603 }
5604
5605 test_vec_2! { test_vec_any_lt_u8_false, vec_any_lt, u8x16 -> bool,
5606 [42, 255, 255, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
5607 [1, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5608 false
5609 }
5610
5611 test_vec_2! { test_vec_any_lt_i16_false, vec_any_lt, i16x8 -> bool,
5612 [2, 0, -1, 1, 1, 1, 1, 1],
5613 [1, -1, -2, 0, 0, 0, 0, 0],
5614 false
5615 }
5616
5617 test_vec_2! { test_vec_any_lt_u16_false, vec_any_lt, u16x8 -> bool,
5618 [2, 42, 255, 1, 1, 1, 1, 1],
5619 [1, 2, 0, 0, 0, 0, 0, 0],
5620 false
5621 }
5622
5623 test_vec_2! { test_vec_any_lt_i32_false, vec_any_lt, i32x4 -> bool,
5624 [2, 0, 1, 1],
5625 [1, -1, 0, 0],
5626 false
5627 }
5628
5629 test_vec_2! { test_vec_any_lt_u32_false, vec_any_lt, u32x4 -> bool,
5630 [4, 255, 4, 1],
5631 [1, 2, 1, 0],
5632 false
5633 }
5634
5635 test_vec_2! { test_vec_any_lt_i8_true, vec_any_lt, i8x16 -> bool,
5636 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5637 [1, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5638 true
5639 }
5640
5641 test_vec_2! { test_vec_any_lt_u8_true, vec_any_lt, u8x16 -> bool,
5642 [0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5643 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5644 true
5645 }
5646
5647 test_vec_2! { test_vec_any_lt_i16_true, vec_any_lt, i16x8 -> bool,
5648 [0, -1, 1, 0, 0, 0, 0, 0],
5649 [1, -1, 1, 0, 0, 0, 0, 0],
5650 true
5651 }
5652
5653 test_vec_2! { test_vec_any_lt_u16_true, vec_any_lt, u16x8 -> bool,
5654 [0, 255, 1, 0, 0, 0, 0, 0],
5655 [1, 255, 1, 0, 0, 0, 0, 0],
5656 true
5657 }
5658
5659 test_vec_2! { test_vec_any_lt_i32_true, vec_any_lt, i32x4 -> bool,
5660 [0, -1, 0, 1],
5661 [1, -1, 0, 1],
5662 true
5663 }
5664
5665 test_vec_2! { test_vec_any_lt_u32_true, vec_any_lt, u32x4 -> bool,
5666 [0, 255, 0, 1],
5667 [1, 255, 0, 1],
5668 true
5669 }
5670
5671 test_vec_2! { test_vec_all_ne_i8_false, vec_all_ne, i8x16 -> bool,
5672 [1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5673 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5674 false
5675 }
5676
5677 test_vec_2! { test_vec_all_ne_u8_false, vec_all_ne, u8x16 -> bool,
5678 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5679 [0, 0, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5680 false
5681 }
5682
5683 test_vec_2! { test_vec_all_ne_i16_false, vec_all_ne, i16x8 -> bool,
5684 [1, -1, 0, 0, 0, 0, 0, 0],
5685 [0, -1, 1, 0, 0, 0, 0, 0],
5686 false
5687 }
5688
5689 test_vec_2! { test_vec_all_ne_u16_false, vec_all_ne, u16x8 -> bool,
5690 [1, 255, 0, 0, 0, 0, 0, 0],
5691 [0, 255, 0, 1, 0, 0, 0, 0],
5692 false
5693 }
5694
5695 test_vec_2! { test_vec_all_ne_i32_false, vec_all_ne, i32x4 -> bool,
5696 [1, -1, 0, 0],
5697 [0, -1, 0, 1],
5698 false
5699 }
5700
5701 test_vec_2! { test_vec_all_ne_u32_false, vec_all_ne, u32x4 -> bool,
5702 [1, 255, 0, 0],
5703 [0, 255, 0, 1],
5704 false
5705 }
5706
5707 test_vec_2! { test_vec_all_ne_i8_true, vec_all_ne, i8x16 -> bool,
5708 [0, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
5709 [1, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5710 true
5711 }
5712
5713 test_vec_2! { test_vec_all_ne_u8_true, vec_all_ne, u8x16 -> bool,
5714 [0, 254, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
5715 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5716 true
5717 }
5718
5719 test_vec_2! { test_vec_all_ne_i16_true, vec_all_ne, i16x8 -> bool,
5720 [2, -2, 0, 1, 1, 1, 1, 1],
5721 [1, -1, 1, 0, 0, 0, 0, 0],
5722 true
5723 }
5724
5725 test_vec_2! { test_vec_all_ne_u16_true, vec_all_ne, u16x8 -> bool,
5726 [0, 254, 1, 1, 0, 0, 1, 0],
5727 [1, 255, 0, 0, 1, 1, 0, 1],
5728 true
5729 }
5730
5731 test_vec_2! { test_vec_all_ne_i32_true, vec_all_ne, i32x4 -> bool,
5732 [0, -2, 0, 0],
5733 [1, -1, 1, 1],
5734 true
5735 }
5736
5737 test_vec_2! { test_vec_all_ne_u32_true, vec_all_ne, u32x4 -> bool,
5738 [1, 255, 0, 0],
5739 [0, 254, 1, 1],
5740 true
5741 }
5742
5743 test_vec_2! { test_vec_any_ne_i8_false, vec_any_ne, i8x16 -> bool,
5744 [1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5745 [1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5746 false
5747 }
5748
5749 test_vec_2! { test_vec_any_ne_u8_false, vec_any_ne, u8x16 -> bool,
5750 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5751 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5752 false
5753 }
5754
5755 test_vec_2! { test_vec_any_ne_i16_false, vec_any_ne, i16x8 -> bool,
5756 [1, -1, 0, 0, 0, 0, 0, 0],
5757 [1, -1, 0, 0, 0, 0, 0, 0],
5758 false
5759 }
5760
5761 test_vec_2! { test_vec_any_ne_u16_false, vec_any_ne, u16x8 -> bool,
5762 [1, 255, 1, 1, 1, 1, 1, 0],
5763 [1, 255, 1, 1, 1, 1, 1, 0],
5764 false
5765 }
5766
5767 test_vec_2! { test_vec_any_ne_i32_false, vec_any_ne, i32x4 -> bool,
5768 [0, -1, 1, 1],
5769 [0, -1, 1, 1],
5770 false
5771 }
5772
5773 test_vec_2! { test_vec_any_ne_u32_false, vec_any_ne, u32x4 -> bool,
5774 [1, 2, 1, 255],
5775 [1, 2, 1, 255],
5776 false
5777 }
5778
5779 test_vec_2! { test_vec_any_ne_i8_true, vec_any_ne, i8x16 -> bool,
5780 [1, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5781 [0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5782 true
5783 }
5784
5785 test_vec_2! { test_vec_any_ne_u8_true, vec_any_ne, u8x16 -> bool,
5786 [0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5787 [1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5788 true
5789 }
5790
5791 test_vec_2! { test_vec_any_ne_i16_true, vec_any_ne, i16x8 -> bool,
5792 [0, -1, 1, 0, 0, 0, 0, 0],
5793 [1, -1, 1, 0, 0, 0, 0, 0],
5794 true
5795 }
5796
5797 test_vec_2! { test_vec_any_ne_u16_true, vec_any_ne, u16x8 -> bool,
5798 [0, 255, 1, 0, 0, 0, 0, 0],
5799 [1, 255, 1, 0, 0, 0, 0, 0],
5800 true
5801 }
5802
5803 test_vec_2! { test_vec_any_ne_i32_true, vec_any_ne, i32x4 -> bool,
5804 [0, -1, 0, 1],
5805 [1, -1, 0, 1],
5806 true
5807 }
5808
5809 test_vec_2! { test_vec_any_ne_u32_true, vec_any_ne, u32x4 -> bool,
5810 [0, 255, 0, 1],
5811 [1, 255, 0, 1],
5812 true
5813 }
5814
5815 #[simd_test(enable = "altivec")]
5816 unsafe fn test_vec_cmpb() {
5817 let a: vector_float = transmute(f32x4::new(0.1, 0.5, 0.6, 0.9));
5818 let b: vector_float = transmute(f32x4::new(-0.1, 0.5, -0.6, 0.9));
5819 let d = i32x4::new(
5820 -0b10000000000000000000000000000000,
5821 0,
5822 -0b10000000000000000000000000000000,
5823 0,
5824 );
5825
5826 assert_eq!(d, transmute(vec_cmpb(a, b)));
5827 }
5828
5829 #[simd_test(enable = "altivec")]
5830 unsafe fn test_vec_ceil() {
5831 let a: vector_float = transmute(f32x4::new(0.1, 0.5, 0.6, 0.9));
5832 let d = f32x4::new(1.0, 1.0, 1.0, 1.0);
5833
5834 assert_eq!(d, transmute(vec_ceil(a)));
5835 }
5836
5837 test_vec_2! { test_vec_andc, vec_andc, i32x4,
5838 [0b11001100, 0b11001100, 0b11001100, 0b11001100],
5839 [0b00110011, 0b11110011, 0b00001100, 0b10000000],
5840 [0b11001100, 0b00001100, 0b11000000, 0b01001100] }
5841
5842 test_vec_2! { test_vec_and, vec_and, i32x4,
5843 [0b11001100, 0b11001100, 0b11001100, 0b11001100],
5844 [0b00110011, 0b11110011, 0b00001100, 0b00000000],
5845 [0b00000000, 0b11000000, 0b00001100, 0b00000000] }
5846
5847 macro_rules! test_vec_avg {
5848 { $name: ident, $ty: ident, [$($a:expr),+], [$($b:expr),+], [$($d:expr),+] } => {
5849 test_vec_2! {$name, vec_avg, $ty, [$($a),+], [$($b),+], [$($d),+] }
5850 }
5851 }
5852
5853 test_vec_avg! { test_vec_avg_i32x4, i32x4,
5854 [i32::MIN, i32::MAX, 1, -1],
5855 [-1, 1, 1, -1],
5856 [-1073741824, 1073741824, 1, -1] }
5857
5858 test_vec_avg! { test_vec_avg_u32x4, u32x4,
5859 [u32::MAX, 0, 1, 2],
5860 [2, 1, 0, 0],
5861 [2147483649, 1, 1, 1] }
5862
5863 test_vec_avg! { test_vec_avg_i16x8, i16x8,
5864 [i16::MIN, i16::MAX, 1, -1, 0, 0, 0, 0],
5865 [-1, 1, 1, -1, 0, 0, 0, 0],
5866 [-16384, 16384, 1, -1, 0, 0, 0, 0] }
5867
5868 test_vec_avg! { test_vec_avg_u16x8, u16x8,
5869 [u16::MAX, 0, 1, 2, 0, 0, 0, 0],
5870 [2, 1, 0, 0, 0, 0, 0, 0],
5871 [32769, 1, 1, 1, 0, 0, 0, 0] }
5872
5873 test_vec_avg! { test_vec_avg_i8x16, i8x16,
5874 [i8::MIN, i8::MAX, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5875 [-1, 1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5876 [-64, 64, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
5877
5878 test_vec_avg! { test_vec_avg_u8x16, u8x16,
5879 [u8::MAX, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5880 [2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5881 [129, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
5882
5883 macro_rules! test_vec_adds {
5884 { $name: ident, $ty: ident, [$($a:expr),+], [$($b:expr),+], [$($d:expr),+] } => {
5885 test_vec_2! {$name, vec_adds, $ty, [$($a),+], [$($b),+], [$($d),+] }
5886 }
5887 }
5888
5889 test_vec_adds! { test_vec_adds_i32x4, i32x4,
5890 [i32::MIN, i32::MAX, 1, -1],
5891 [-1, 1, 1, -1],
5892 [i32::MIN, i32::MAX, 2, -2] }
5893
5894 test_vec_adds! { test_vec_adds_u32x4, u32x4,
5895 [u32::MAX, 0, 1, 2],
5896 [2, 1, 0, 0],
5897 [u32::MAX, 1, 1, 2] }
5898
5899 test_vec_adds! { test_vec_adds_i16x8, i16x8,
5900 [i16::MIN, i16::MAX, 1, -1, 0, 0, 0, 0],
5901 [-1, 1, 1, -1, 0, 0, 0, 0],
5902 [i16::MIN, i16::MAX, 2, -2, 0, 0, 0, 0] }
5903
5904 test_vec_adds! { test_vec_adds_u16x8, u16x8,
5905 [u16::MAX, 0, 1, 2, 0, 0, 0, 0],
5906 [2, 1, 0, 0, 0, 0, 0, 0],
5907 [u16::MAX, 1, 1, 2, 0, 0, 0, 0] }
5908
5909 test_vec_adds! { test_vec_adds_i8x16, i8x16,
5910 [i8::MIN, i8::MAX, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5911 [-1, 1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5912 [i8::MIN, i8::MAX, 2, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
5913
5914 test_vec_adds! { test_vec_adds_u8x16, u8x16,
5915 [u8::MAX, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5916 [2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
5917 [u8::MAX, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
5918
5919 test_vec_2! { test_vec_addc, vec_addc, u32x4, [u32::MAX, 0, 0, 0], [1, 1, 1, 1], [1, 0, 0, 0] }
5920
5921 macro_rules! test_vec_abs {
5922 { $name: ident, $ty: ident, $a: expr, $d: expr } => {
5923 #[simd_test(enable = "altivec")]
5924 unsafe fn $name() {
5925 let a = vec_splats($a);
5926 let a: s_t_l!($ty) = vec_abs(a);
5927 let d = $ty::splat($d);
5928 assert_eq!(d, transmute(a));
5929 }
5930 }
5931 }
5932
5933 test_vec_abs! { test_vec_abs_i8, i8x16, -42i8, 42i8 }
5934 test_vec_abs! { test_vec_abs_i16, i16x8, -42i16, 42i16 }
5935 test_vec_abs! { test_vec_abs_i32, i32x4, -42i32, 42i32 }
5936 test_vec_abs! { test_vec_abs_f32, f32x4, -42f32, 42f32 }
5937
5938 macro_rules! test_vec_abss {
5939 { $name: ident, $ty: ident, $a: expr, $d: expr } => {
5940 #[simd_test(enable = "altivec")]
5941 unsafe fn $name() {
5942 let a = vec_splats($a);
5943 let a: s_t_l!($ty) = vec_abss(a);
5944 let d = $ty::splat($d);
5945 assert_eq!(d, transmute(a));
5946 }
5947 }
5948 }
5949
5950 test_vec_abss! { test_vec_abss_i8, i8x16, -127i8, 127i8 }
5951 test_vec_abss! { test_vec_abss_i16, i16x8, -42i16, 42i16 }
5952 test_vec_abss! { test_vec_abss_i32, i32x4, -42i32, 42i32 }
5953
5954 macro_rules! test_vec_splats {
5955 { $name: ident, $ty: ident, $a: expr } => {
5956 #[simd_test(enable = "altivec")]
5957 unsafe fn $name() {
5958 let a: s_t_l!($ty) = vec_splats($a);
5959 let d = $ty::splat($a);
5960 assert_eq!(d, transmute(a));
5961 }
5962 }
5963 }
5964
5965 test_vec_splats! { test_vec_splats_u8, u8x16, 42u8 }
5966 test_vec_splats! { test_vec_splats_u16, u16x8, 42u16 }
5967 test_vec_splats! { test_vec_splats_u32, u32x4, 42u32 }
5968 test_vec_splats! { test_vec_splats_i8, i8x16, 42i8 }
5969 test_vec_splats! { test_vec_splats_i16, i16x8, 42i16 }
5970 test_vec_splats! { test_vec_splats_i32, i32x4, 42i32 }
5971 test_vec_splats! { test_vec_splats_f32, f32x4, 42f32 }
5972
5973 macro_rules! test_vec_splat {
5974 { $name: ident, $fun: ident, $ty: ident, $a: expr, $b: expr} => {
5975 #[simd_test(enable = "altivec")]
5976 unsafe fn $name() {
5977 let a = $fun::<$a>();
5978 let d = $ty::splat($b);
5979 assert_eq!(d, transmute(a));
5980 }
5981 }
5982 }
5983
5984 test_vec_splat! { test_vec_splat_u8, vec_splat_u8, u8x16, -1, u8::MAX }
5985 test_vec_splat! { test_vec_splat_u16, vec_splat_u16, u16x8, -1, u16::MAX }
5986 test_vec_splat! { test_vec_splat_u32, vec_splat_u32, u32x4, -1, u32::MAX }
5987 test_vec_splat! { test_vec_splat_s8, vec_splat_s8, i8x16, -1, -1 }
5988 test_vec_splat! { test_vec_splat_s16, vec_splat_s16, i16x8, -1, -1 }
5989 test_vec_splat! { test_vec_splat_s32, vec_splat_s32, i32x4, -1, -1 }
5990
5991 macro_rules! test_vec_sub {
5992 { $name: ident, $ty: ident, [$($a:expr),+], [$($b:expr),+], [$($d:expr),+] } => {
5993 test_vec_2! {$name, vec_sub, $ty, [$($a),+], [$($b),+], [$($d),+] }
5994 }
5995 }
5996
5997 test_vec_sub! { test_vec_sub_f32x4, f32x4,
5998 [-1.0, 0.0, 1.0, 2.0],
5999 [2.0, 1.0, -1.0, -2.0],
6000 [-3.0, -1.0, 2.0, 4.0] }
6001
6002 test_vec_sub! { test_vec_sub_i32x4, i32x4,
6003 [-1, 0, 1, 2],
6004 [2, 1, -1, -2],
6005 [-3, -1, 2, 4] }
6006
6007 test_vec_sub! { test_vec_sub_u32x4, u32x4,
6008 [0, 0, 1, 2],
6009 [2, 1, 0, 0],
6010 [4294967294, 4294967295, 1, 2] }
6011
6012 test_vec_sub! { test_vec_sub_i16x8, i16x8,
6013 [-1, 0, 1, 2, -1, 0, 1, 2],
6014 [2, 1, -1, -2, 2, 1, -1, -2],
6015 [-3, -1, 2, 4, -3, -1, 2, 4] }
6016
6017 test_vec_sub! { test_vec_sub_u16x8, u16x8,
6018 [0, 0, 1, 2, 0, 0, 1, 2],
6019 [2, 1, 0, 0, 2, 1, 0, 0],
6020 [65534, 65535, 1, 2, 65534, 65535, 1, 2] }
6021
6022 test_vec_sub! { test_vec_sub_i8x16, i8x16,
6023 [-1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2],
6024 [2, 1, -1, -2, 2, 1, -1, -2, 2, 1, -1, -2, 2, 1, -1, -2],
6025 [-3, -1, 2, 4, -3, -1, 2, 4, -3, -1, 2, 4, -3, -1, 2, 4] }
6026
6027 test_vec_sub! { test_vec_sub_u8x16, u8x16,
6028 [0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2],
6029 [2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0],
6030 [254, 255, 1, 2, 254, 255, 1, 2, 254, 255, 1, 2, 254, 255, 1, 2] }
6031
6032 macro_rules! test_vec_subs {
6033 { $name: ident, $ty: ident, [$($a:expr),+], [$($b:expr),+], [$($d:expr),+] } => {
6034 test_vec_2! {$name, vec_subs, $ty, [$($a),+], [$($b),+], [$($d),+] }
6035 }
6036 }
6037
6038 test_vec_subs! { test_vec_subs_i32x4, i32x4,
6039 [-1, 0, 1, 2],
6040 [2, 1, -1, -2],
6041 [-3, -1, 2, 4] }
6042
6043 test_vec_subs! { test_vec_subs_u32x4, u32x4,
6044 [0, 0, 1, 2],
6045 [2, 1, 0, 0],
6046 [0, 0, 1, 2] }
6047
6048 test_vec_subs! { test_vec_subs_i16x8, i16x8,
6049 [-1, 0, 1, 2, -1, 0, 1, 2],
6050 [2, 1, -1, -2, 2, 1, -1, -2],
6051 [-3, -1, 2, 4, -3, -1, 2, 4] }
6052
6053 test_vec_subs! { test_vec_subs_u16x8, u16x8,
6054 [0, 0, 1, 2, 0, 0, 1, 2],
6055 [2, 1, 0, 0, 2, 1, 0, 0],
6056 [0, 0, 1, 2, 0, 0, 1, 2] }
6057
6058 test_vec_subs! { test_vec_subs_i8x16, i8x16,
6059 [-1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2],
6060 [2, 1, -1, -2, 2, 1, -1, -2, 2, 1, -1, -2, 2, 1, -1, -2],
6061 [-3, -1, 2, 4, -3, -1, 2, 4, -3, -1, 2, 4, -3, -1, 2, 4] }
6062
6063 test_vec_subs! { test_vec_subs_u8x16, u8x16,
6064 [0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2],
6065 [2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0],
6066 [0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2] }
6067
6068 macro_rules! test_vec_min {
6069 { $name: ident, $ty: ident, [$($a:expr),+], [$($b:expr),+], [$($d:expr),+] } => {
6070 #[simd_test(enable = "altivec")]
6071 unsafe fn $name() {
6072 let a: s_t_l!($ty) = transmute($ty::new($($a),+));
6073 let b: s_t_l!($ty) = transmute($ty::new($($b),+));
6074
6075 let d = $ty::new($($d),+);
6076 let r : $ty = transmute(vec_min(a, b));
6077 assert_eq!(d, r);
6078 }
6079 }
6080 }
6081
6082 test_vec_min! { test_vec_min_i32x4, i32x4,
6083 [-1, 0, 1, 2],
6084 [2, 1, -1, -2],
6085 [-1, 0, -1, -2] }
6086
6087 test_vec_min! { test_vec_min_u32x4, u32x4,
6088 [0, 0, 1, 2],
6089 [2, 1, 0, 0],
6090 [0, 0, 0, 0] }
6091
6092 test_vec_min! { test_vec_min_i16x8, i16x8,
6093 [-1, 0, 1, 2, -1, 0, 1, 2],
6094 [2, 1, -1, -2, 2, 1, -1, -2],
6095 [-1, 0, -1, -2, -1, 0, -1, -2] }
6096
6097 test_vec_min! { test_vec_min_u16x8, u16x8,
6098 [0, 0, 1, 2, 0, 0, 1, 2],
6099 [2, 1, 0, 0, 2, 1, 0, 0],
6100 [0, 0, 0, 0, 0, 0, 0, 0] }
6101
6102 test_vec_min! { test_vec_min_i8x16, i8x16,
6103 [-1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2],
6104 [2, 1, -1, -2, 2, 1, -1, -2, 2, 1, -1, -2, 2, 1, -1, -2],
6105 [-1, 0, -1, -2, -1, 0, -1, -2, -1, 0, -1, -2, -1, 0, -1, -2] }
6106
6107 test_vec_min! { test_vec_min_u8x16, u8x16,
6108 [0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2],
6109 [2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0],
6110 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
6111
6112 macro_rules! test_vec_max {
6113 { $name: ident, $ty: ident, [$($a:expr),+], [$($b:expr),+], [$($d:expr),+] } => {
6114 #[simd_test(enable = "altivec")]
6115 unsafe fn $name() {
6116 let a: s_t_l!($ty) = transmute($ty::new($($a),+));
6117 let b: s_t_l!($ty) = transmute($ty::new($($b),+));
6118
6119 let d = $ty::new($($d),+);
6120 let r : $ty = transmute(vec_max(a, b));
6121 assert_eq!(d, r);
6122 }
6123 }
6124 }
6125
6126 test_vec_max! { test_vec_max_i32x4, i32x4,
6127 [-1, 0, 1, 2],
6128 [2, 1, -1, -2],
6129 [2, 1, 1, 2] }
6130
6131 test_vec_max! { test_vec_max_u32x4, u32x4,
6132 [0, 0, 1, 2],
6133 [2, 1, 0, 0],
6134 [2, 1, 1, 2] }
6135
6136 test_vec_max! { test_vec_max_i16x8, i16x8,
6137 [-1, 0, 1, 2, -1, 0, 1, 2],
6138 [2, 1, -1, -2, 2, 1, -1, -2],
6139 [2, 1, 1, 2, 2, 1, 1, 2] }
6140
6141 test_vec_max! { test_vec_max_u16x8, u16x8,
6142 [0, 0, 1, 2, 0, 0, 1, 2],
6143 [2, 1, 0, 0, 2, 1, 0, 0],
6144 [2, 1, 1, 2, 2, 1, 1, 2] }
6145
6146 test_vec_max! { test_vec_max_i8x16, i8x16,
6147 [-1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2],
6148 [2, 1, -1, -2, 2, 1, -1, -2, 2, 1, -1, -2, 2, 1, -1, -2],
6149 [2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2] }
6150
6151 test_vec_max! { test_vec_max_u8x16, u8x16,
6152 [0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2],
6153 [2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0],
6154 [2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2] }
6155
6156 macro_rules! test_vec_perm {
6157 {$name:ident,
6158 $shorttype:ident, $longtype:ident,
6159 [$($a:expr),+], [$($b:expr),+], [$($c:expr),+], [$($d:expr),+]} => {
6160 #[simd_test(enable = "altivec")]
6161 unsafe fn $name() {
6162 let a: $longtype = transmute($shorttype::new($($a),+));
6163 let b: $longtype = transmute($shorttype::new($($b),+));
6164 let c: vector_unsigned_char = transmute(u8x16::new($($c),+));
6165 let d = $shorttype::new($($d),+);
6166
6167 let r: $shorttype = transmute(vec_perm(a, b, c));
6168 assert_eq!(d, r);
6169 }
6170 }
6171 }
6172
6173 test_vec_perm! {test_vec_perm_u8x16,
6174 u8x16, vector_unsigned_char,
6175 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
6176 [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115],
6177 [0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
6178 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17],
6179 [0, 1, 100, 101, 2, 3, 102, 103, 4, 5, 104, 105, 6, 7, 106, 107]}
6180 test_vec_perm! {test_vec_perm_i8x16,
6181 i8x16, vector_signed_char,
6182 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
6183 [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115],
6184 [0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
6185 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17],
6186 [0, 1, 100, 101, 2, 3, 102, 103, 4, 5, 104, 105, 6, 7, 106, 107]}
6187
6188 test_vec_perm! {test_vec_perm_m8x16,
6189 m8x16, vector_bool_char,
6190 [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
6191 [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true],
6192 [0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
6193 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17],
6194 [false, false, true, true, false, false, true, true, false, false, true, true, false, false, true, true]}
6195 test_vec_perm! {test_vec_perm_u16x8,
6196 u16x8, vector_unsigned_short,
6197 [0, 1, 2, 3, 4, 5, 6, 7],
6198 [10, 11, 12, 13, 14, 15, 16, 17],
6199 [0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
6200 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17],
6201 [0, 10, 1, 11, 2, 12, 3, 13]}
6202 test_vec_perm! {test_vec_perm_i16x8,
6203 i16x8, vector_signed_short,
6204 [0, 1, 2, 3, 4, 5, 6, 7],
6205 [10, 11, 12, 13, 14, 15, 16, 17],
6206 [0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
6207 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17],
6208 [0, 10, 1, 11, 2, 12, 3, 13]}
6209 test_vec_perm! {test_vec_perm_m16x8,
6210 m16x8, vector_bool_short,
6211 [false, false, false, false, false, false, false, false],
6212 [true, true, true, true, true, true, true, true],
6213 [0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
6214 0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17],
6215 [false, true, false, true, false, true, false, true]}
6216
6217 test_vec_perm! {test_vec_perm_u32x4,
6218 u32x4, vector_unsigned_int,
6219 [0, 1, 2, 3],
6220 [10, 11, 12, 13],
6221 [0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
6222 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17],
6223 [0, 10, 1, 11]}
6224 test_vec_perm! {test_vec_perm_i32x4,
6225 i32x4, vector_signed_int,
6226 [0, 1, 2, 3],
6227 [10, 11, 12, 13],
6228 [0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
6229 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17],
6230 [0, 10, 1, 11]}
6231 test_vec_perm! {test_vec_perm_m32x4,
6232 m32x4, vector_bool_int,
6233 [false, false, false, false],
6234 [true, true, true, true],
6235 [0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
6236 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17],
6237 [false, true, false, true]}
6238 test_vec_perm! {test_vec_perm_f32x4,
6239 f32x4, vector_float,
6240 [0.0, 1.0, 2.0, 3.0],
6241 [1.0, 1.1, 1.2, 1.3],
6242 [0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
6243 0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17],
6244 [0.0, 1.0, 1.0, 1.1]}
6245
6246 #[simd_test(enable = "altivec")]
6247 unsafe fn test_vec_madds() {
6248 let a: vector_signed_short = transmute(i16x8::new(
6249 0 * 256,
6250 1 * 256,
6251 2 * 256,
6252 3 * 256,
6253 4 * 256,
6254 5 * 256,
6255 6 * 256,
6256 7 * 256,
6257 ));
6258 let b: vector_signed_short = transmute(i16x8::new(256, 256, 256, 256, 256, 256, 256, 256));
6259 let c: vector_signed_short = transmute(i16x8::new(0, 1, 2, 3, 4, 5, 6, 7));
6260
6261 let d = i16x8::new(0, 3, 6, 9, 12, 15, 18, 21);
6262
6263 assert_eq!(d, transmute(vec_madds(a, b, c)));
6264 }
6265
6266 #[simd_test(enable = "altivec")]
6267 unsafe fn test_vec_madd_float() {
6268 let a: vector_float = transmute(f32x4::new(0.1, 0.2, 0.3, 0.4));
6269 let b: vector_float = transmute(f32x4::new(0.1, 0.2, 0.3, 0.4));
6270 let c: vector_float = transmute(f32x4::new(0.1, 0.2, 0.3, 0.4));
6271 let d = f32x4::new(
6272 0.1 * 0.1 + 0.1,
6273 0.2 * 0.2 + 0.2,
6274 0.3 * 0.3 + 0.3,
6275 0.4 * 0.4 + 0.4,
6276 );
6277
6278 assert_eq!(d, transmute(vec_madd(a, b, c)));
6279 }
6280
6281 #[simd_test(enable = "altivec")]
6282 unsafe fn test_vec_nmsub_float() {
6283 let a: vector_float = transmute(f32x4::new(0.1, 0.2, 0.3, 0.4));
6284 let b: vector_float = transmute(f32x4::new(0.1, 0.2, 0.3, 0.4));
6285 let c: vector_float = transmute(f32x4::new(0.1, 0.2, 0.3, 0.4));
6286 let d = f32x4::new(
6287 -(0.1 * 0.1 - 0.1),
6288 -(0.2 * 0.2 - 0.2),
6289 -(0.3 * 0.3 - 0.3),
6290 -(0.4 * 0.4 - 0.4),
6291 );
6292 assert_eq!(d, transmute(vec_nmsub(a, b, c)));
6293 }
6294
6295 #[simd_test(enable = "altivec")]
6296 unsafe fn test_vec_mradds() {
6297 let a: vector_signed_short = transmute(i16x8::new(
6298 0 * 256,
6299 1 * 256,
6300 2 * 256,
6301 3 * 256,
6302 4 * 256,
6303 5 * 256,
6304 6 * 256,
6305 7 * 256,
6306 ));
6307 let b: vector_signed_short = transmute(i16x8::new(256, 256, 256, 256, 256, 256, 256, 256));
6308 let c: vector_signed_short = transmute(i16x8::new(0, 1, 2, 3, 4, 5, 6, i16::MAX - 1));
6309
6310 let d = i16x8::new(0, 3, 6, 9, 12, 15, 18, i16::MAX);
6311
6312 assert_eq!(d, transmute(vec_mradds(a, b, c)));
6313 }
6314
6315 macro_rules! test_vec_mladd {
6316 {$name:ident, $sa:ident, $la:ident, $sbc:ident, $lbc:ident, $sd:ident,
6317 [$($a:expr),+], [$($b:expr),+], [$($c:expr),+], [$($d:expr),+]} => {
6318 #[simd_test(enable = "altivec")]
6319 unsafe fn $name() {
6320 let a: $la = transmute($sa::new($($a),+));
6321 let b: $lbc = transmute($sbc::new($($b),+));
6322 let c = transmute($sbc::new($($c),+));
6323 let d = $sd::new($($d),+);
6324
6325 assert_eq!(d, transmute(vec_mladd(a, b, c)));
6326 }
6327 }
6328 }
6329
6330 test_vec_mladd! { test_vec_mladd_u16x8_u16x8, u16x8, vector_unsigned_short, u16x8, vector_unsigned_short, u16x8,
6331 [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 2, 6, 12, 20, 30, 42, 56]
6332 }
6333 test_vec_mladd! { test_vec_mladd_u16x8_i16x8, u16x8, vector_unsigned_short, i16x8, vector_unsigned_short, i16x8,
6334 [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 2, 6, 12, 20, 30, 42, 56]
6335 }
6336 test_vec_mladd! { test_vec_mladd_i16x8_u16x8, i16x8, vector_signed_short, u16x8, vector_unsigned_short, i16x8,
6337 [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 2, 6, 12, 20, 30, 42, 56]
6338 }
6339 test_vec_mladd! { test_vec_mladd_i16x8_i16x8, i16x8, vector_signed_short, i16x8, vector_unsigned_short, i16x8,
6340 [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 2, 6, 12, 20, 30, 42, 56]
6341 }
6342
6343 #[simd_test(enable = "altivec")]
6344 unsafe fn test_vec_msum_unsigned_char() {
6345 let a: vector_unsigned_char =
6346 transmute(u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7));
6347 let b: vector_unsigned_char = transmute(u8x16::new(
6348 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
6349 ));
6350 let c: vector_unsigned_int = transmute(u32x4::new(0, 1, 2, 3));
6351 let d = u32x4::new(
6352 (0 + 1 + 2 + 3) * 255 + 0,
6353 (4 + 5 + 6 + 7) * 255 + 1,
6354 (0 + 1 + 2 + 3) * 255 + 2,
6355 (4 + 5 + 6 + 7) * 255 + 3,
6356 );
6357
6358 assert_eq!(d, transmute(vec_msum(a, b, c)));
6359 }
6360
6361 #[simd_test(enable = "altivec")]
6362 unsafe fn test_vec_msum_signed_char() {
6363 let a: vector_signed_char = transmute(i8x16::new(
6364 0, -1, 2, -3, 1, -1, 1, -1, 0, 1, 2, 3, 4, -5, -6, -7,
6365 ));
6366 let b: vector_unsigned_char =
6367 transmute(i8x16::new(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1));
6368 let c: vector_signed_int = transmute(u32x4::new(0, 1, 2, 3));
6369 let d = i32x4::new(
6370 (0 - 1 + 2 - 3) + 0,
6371 (0) + 1,
6372 (0 + 1 + 2 + 3) + 2,
6373 (4 - 5 - 6 - 7) + 3,
6374 );
6375
6376 assert_eq!(d, transmute(vec_msum(a, b, c)));
6377 }
6378 #[simd_test(enable = "altivec")]
6379 unsafe fn test_vec_msum_unsigned_short() {
6380 let a: vector_unsigned_short = transmute(u16x8::new(
6381 0 * 256,
6382 1 * 256,
6383 2 * 256,
6384 3 * 256,
6385 4 * 256,
6386 5 * 256,
6387 6 * 256,
6388 7 * 256,
6389 ));
6390 let b: vector_unsigned_short =
6391 transmute(u16x8::new(256, 256, 256, 256, 256, 256, 256, 256));
6392 let c: vector_unsigned_int = transmute(u32x4::new(0, 1, 2, 3));
6393 let d = u32x4::new(
6394 (0 + 1) * 256 * 256 + 0,
6395 (2 + 3) * 256 * 256 + 1,
6396 (4 + 5) * 256 * 256 + 2,
6397 (6 + 7) * 256 * 256 + 3,
6398 );
6399
6400 assert_eq!(d, transmute(vec_msum(a, b, c)));
6401 }
6402
6403 #[simd_test(enable = "altivec")]
6404 unsafe fn test_vec_msum_signed_short() {
6405 let a: vector_signed_short = transmute(i16x8::new(
6406 0 * 256,
6407 -1 * 256,
6408 2 * 256,
6409 -3 * 256,
6410 4 * 256,
6411 -5 * 256,
6412 6 * 256,
6413 -7 * 256,
6414 ));
6415 let b: vector_signed_short = transmute(i16x8::new(256, 256, 256, 256, 256, 256, 256, 256));
6416 let c: vector_signed_int = transmute(i32x4::new(0, 1, 2, 3));
6417 let d = i32x4::new(
6418 (0 - 1) * 256 * 256 + 0,
6419 (2 - 3) * 256 * 256 + 1,
6420 (4 - 5) * 256 * 256 + 2,
6421 (6 - 7) * 256 * 256 + 3,
6422 );
6423
6424 assert_eq!(d, transmute(vec_msum(a, b, c)));
6425 }
6426
6427 #[simd_test(enable = "altivec")]
6428 unsafe fn test_vec_msums_unsigned() {
6429 let a: vector_unsigned_short = transmute(u16x8::new(
6430 0 * 256,
6431 1 * 256,
6432 2 * 256,
6433 3 * 256,
6434 4 * 256,
6435 5 * 256,
6436 6 * 256,
6437 7 * 256,
6438 ));
6439 let b: vector_unsigned_short =
6440 transmute(u16x8::new(256, 256, 256, 256, 256, 256, 256, 256));
6441 let c: vector_unsigned_int = transmute(u32x4::new(0, 1, 2, 3));
6442 let d = u32x4::new(
6443 (0 + 1) * 256 * 256 + 0,
6444 (2 + 3) * 256 * 256 + 1,
6445 (4 + 5) * 256 * 256 + 2,
6446 (6 + 7) * 256 * 256 + 3,
6447 );
6448
6449 assert_eq!(d, transmute(vec_msums(a, b, c)));
6450 }
6451
6452 #[simd_test(enable = "altivec")]
6453 unsafe fn test_vec_msums_signed() {
6454 let a: vector_signed_short = transmute(i16x8::new(
6455 0 * 256,
6456 -1 * 256,
6457 2 * 256,
6458 -3 * 256,
6459 4 * 256,
6460 -5 * 256,
6461 6 * 256,
6462 -7 * 256,
6463 ));
6464 let b: vector_signed_short = transmute(i16x8::new(256, 256, 256, 256, 256, 256, 256, 256));
6465 let c: vector_signed_int = transmute(i32x4::new(0, 1, 2, 3));
6466 let d = i32x4::new(
6467 (0 - 1) * 256 * 256 + 0,
6468 (2 - 3) * 256 * 256 + 1,
6469 (4 - 5) * 256 * 256 + 2,
6470 (6 - 7) * 256 * 256 + 3,
6471 );
6472
6473 assert_eq!(d, transmute(vec_msums(a, b, c)));
6474 }
6475
6476 #[simd_test(enable = "altivec")]
6477 unsafe fn test_vec_sum2s() {
6478 let a: vector_signed_int = transmute(i32x4::new(0, 1, 2, 3));
6479 let b: vector_signed_int = transmute(i32x4::new(0, 1, 2, 3));
6480 let d = i32x4::new(0, 0 + 1 + 1, 0, 2 + 3 + 3);
6481
6482 assert_eq!(d, transmute(vec_sum2s(a, b)));
6483 }
6484
6485 #[simd_test(enable = "altivec")]
6486 unsafe fn test_vec_sum4s_unsigned_char() {
6487 let a: vector_unsigned_char =
6488 transmute(u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7));
6489 let b: vector_unsigned_int = transmute(u32x4::new(0, 1, 2, 3));
6490 let d = u32x4::new(
6491 0 + 1 + 2 + 3 + 0,
6492 4 + 5 + 6 + 7 + 1,
6493 0 + 1 + 2 + 3 + 2,
6494 4 + 5 + 6 + 7 + 3,
6495 );
6496
6497 assert_eq!(d, transmute(vec_sum4s(a, b)));
6498 }
6499 #[simd_test(enable = "altivec")]
6500 unsafe fn test_vec_sum4s_signed_char() {
6501 let a: vector_signed_char =
6502 transmute(i8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7));
6503 let b: vector_signed_int = transmute(i32x4::new(0, 1, 2, 3));
6504 let d = i32x4::new(
6505 0 + 1 + 2 + 3 + 0,
6506 4 + 5 + 6 + 7 + 1,
6507 0 + 1 + 2 + 3 + 2,
6508 4 + 5 + 6 + 7 + 3,
6509 );
6510
6511 assert_eq!(d, transmute(vec_sum4s(a, b)));
6512 }
6513 #[simd_test(enable = "altivec")]
6514 unsafe fn test_vec_sum4s_signed_short() {
6515 let a: vector_signed_short = transmute(i16x8::new(0, 1, 2, 3, 4, 5, 6, 7));
6516 let b: vector_signed_int = transmute(i32x4::new(0, 1, 2, 3));
6517 let d = i32x4::new(0 + 1 + 0, 2 + 3 + 1, 4 + 5 + 2, 6 + 7 + 3);
6518
6519 assert_eq!(d, transmute(vec_sum4s(a, b)));
6520 }
6521
6522 #[simd_test(enable = "altivec")]
6523 unsafe fn test_vec_mule_unsigned_char() {
6524 let a: vector_unsigned_char =
6525 transmute(u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7));
6526 let d = u16x8::new(0 * 0, 2 * 2, 4 * 4, 6 * 6, 0 * 0, 2 * 2, 4 * 4, 6 * 6);
6527
6528 assert_eq!(d, transmute(vec_mule(a, a)));
6529 }
6530
6531 #[simd_test(enable = "altivec")]
6532 unsafe fn test_vec_mule_signed_char() {
6533 let a: vector_signed_char = transmute(i8x16::new(
6534 0, 1, -2, 3, -4, 5, -6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
6535 ));
6536 let d = i16x8::new(0 * 0, 2 * 2, 4 * 4, 6 * 6, 0 * 0, 2 * 2, 4 * 4, 6 * 6);
6537
6538 assert_eq!(d, transmute(vec_mule(a, a)));
6539 }
6540
6541 #[simd_test(enable = "altivec")]
6542 unsafe fn test_vec_mule_unsigned_short() {
6543 let a: vector_unsigned_short = transmute(u16x8::new(0, 1, 2, 3, 4, 5, 6, 7));
6544 let d = u32x4::new(0 * 0, 2 * 2, 4 * 4, 6 * 6);
6545
6546 assert_eq!(d, transmute(vec_mule(a, a)));
6547 }
6548
6549 #[simd_test(enable = "altivec")]
6550 unsafe fn test_vec_mule_signed_short() {
6551 let a: vector_signed_short = transmute(i16x8::new(0, 1, -2, 3, -4, 5, -6, 7));
6552 let d = i32x4::new(0 * 0, 2 * 2, 4 * 4, 6 * 6);
6553
6554 assert_eq!(d, transmute(vec_mule(a, a)));
6555 }
6556
6557 #[simd_test(enable = "altivec")]
6558 unsafe fn test_vec_mulo_unsigned_char() {
6559 let a: vector_unsigned_char =
6560 transmute(u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7));
6561 let d = u16x8::new(1 * 1, 3 * 3, 5 * 5, 7 * 7, 1 * 1, 3 * 3, 5 * 5, 7 * 7);
6562
6563 assert_eq!(d, transmute(vec_mulo(a, a)));
6564 }
6565
6566 #[simd_test(enable = "altivec")]
6567 unsafe fn test_vec_mulo_signed_char() {
6568 let a: vector_signed_char = transmute(i8x16::new(
6569 0, 1, -2, 3, -4, 5, -6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
6570 ));
6571 let d = i16x8::new(1 * 1, 3 * 3, 5 * 5, 7 * 7, 1 * 1, 3 * 3, 5 * 5, 7 * 7);
6572
6573 assert_eq!(d, transmute(vec_mulo(a, a)));
6574 }
6575
6576 #[simd_test(enable = "altivec")]
6577 unsafe fn test_vec_mulo_unsigned_short() {
6578 let a: vector_unsigned_short = transmute(u16x8::new(0, 1, 2, 3, 4, 5, 6, 7));
6579 let d = u32x4::new(1 * 1, 3 * 3, 5 * 5, 7 * 7);
6580
6581 assert_eq!(d, transmute(vec_mulo(a, a)));
6582 }
6583
6584 #[simd_test(enable = "altivec")]
6585 unsafe fn test_vec_mulo_signed_short() {
6586 let a: vector_signed_short = transmute(i16x8::new(0, 1, -2, 3, -4, 5, -6, 7));
6587 let d = i32x4::new(1 * 1, 3 * 3, 5 * 5, 7 * 7);
6588
6589 assert_eq!(d, transmute(vec_mulo(a, a)));
6590 }
6591
6592 #[simd_test(enable = "altivec")]
6593 unsafe fn vec_add_i32x4_i32x4() {
6594 let x = i32x4::new(1, 2, 3, 4);
6595 let y = i32x4::new(4, 3, 2, 1);
6596 let x: vector_signed_int = transmute(x);
6597 let y: vector_signed_int = transmute(y);
6598 let z = vec_add(x, y);
6599 assert_eq!(i32x4::splat(5), transmute(z));
6600 }
6601
6602 #[simd_test(enable = "altivec")]
6603 unsafe fn vec_ctf_u32() {
6604 let v: vector_unsigned_int = transmute(u32x4::new(u32::MIN, u32::MAX, u32::MAX, 42));
6605 let v2 = vec_ctf::<1, _>(v);
6606 let r2: vector_float = transmute(f32x4::new(0.0, 2147483600.0, 2147483600.0, 21.0));
6607 let v4 = vec_ctf::<2, _>(v);
6608 let r4: vector_float = transmute(f32x4::new(0.0, 1073741800.0, 1073741800.0, 10.5));
6609 let v8 = vec_ctf::<3, _>(v);
6610 let r8: vector_float = transmute(f32x4::new(0.0, 536870900.0, 536870900.0, 5.25));
6611
6612 let check = |a, b| {
6613 let r = transmute(vec_cmple(vec_abs(vec_sub(a, b)), vec_splats(f32::EPSILON)));
6614 let e = m32x4::new(true, true, true, true);
6615 assert_eq!(e, r);
6616 };
6617
6618 check(v2, r2);
6619 check(v4, r4);
6620 check(v8, r8);
6621 }
6622
6623 #[simd_test(enable = "altivec")]
6624 unsafe fn test_vec_ctu() {
6625 let v = u32x4::new(u32::MIN, u32::MAX, u32::MAX, 42);
6626 let v2: u32x4 = transmute(vec_ctu::<1>(transmute(f32x4::new(
6627 0.0,
6628 2147483600.0,
6629 2147483600.0,
6630 21.0,
6631 ))));
6632 let v4: u32x4 = transmute(vec_ctu::<2>(transmute(f32x4::new(
6633 0.0,
6634 1073741800.0,
6635 1073741800.0,
6636 10.5,
6637 ))));
6638 let v8: u32x4 = transmute(vec_ctu::<3>(transmute(f32x4::new(
6639 0.0,
6640 536870900.0,
6641 536870900.0,
6642 5.25,
6643 ))));
6644
6645 assert_eq!(v2, v);
6646 assert_eq!(v4, v);
6647 assert_eq!(v8, v);
6648 }
6649
6650 #[simd_test(enable = "altivec")]
6651 unsafe fn vec_ctf_i32() {
6652 let v: vector_signed_int = transmute(i32x4::new(i32::MIN, i32::MAX, i32::MAX - 42, 42));
6653 let v2 = vec_ctf::<1, _>(v);
6654 let r2: vector_float =
6655 transmute(f32x4::new(-1073741800.0, 1073741800.0, 1073741800.0, 21.0));
6656 let v4 = vec_ctf::<2, _>(v);
6657 let r4: vector_float = transmute(f32x4::new(-536870900.0, 536870900.0, 536870900.0, 10.5));
6658 let v8 = vec_ctf::<3, _>(v);
6659 let r8: vector_float = transmute(f32x4::new(-268435460.0, 268435460.0, 268435460.0, 5.25));
6660
6661 let check = |a, b| {
6662 let r = transmute(vec_cmple(vec_abs(vec_sub(a, b)), vec_splats(f32::EPSILON)));
6663 println!("{:?} {:?}", a, b);
6664 let e = m32x4::new(true, true, true, true);
6665 assert_eq!(e, r);
6666 };
6667
6668 check(v2, r2);
6669 check(v4, r4);
6670 check(v8, r8);
6671 }
6672
6673 #[simd_test(enable = "altivec")]
6674 unsafe fn test_vec_cts() {
6675 let v = i32x4::new(i32::MIN, i32::MAX, i32::MAX, 42);
6676 let v2: i32x4 = transmute(vec_cts::<1>(transmute(f32x4::new(
6677 -1073741800.0,
6678 1073741800.0,
6679 1073741800.0,
6680 21.0,
6681 ))));
6682 let v4: i32x4 = transmute(vec_cts::<2>(transmute(f32x4::new(
6683 -536870900.0,
6684 536870900.0,
6685 536870900.0,
6686 10.5,
6687 ))));
6688 let v8: i32x4 = transmute(vec_cts::<3>(transmute(f32x4::new(
6689 -268435460.0,
6690 268435460.0,
6691 268435460.0,
6692 5.25,
6693 ))));
6694
6695 assert_eq!(v2, v);
6696 assert_eq!(v4, v);
6697 assert_eq!(v8, v);
6698 }
6699}