Skip to content

Commit 2dfc447

Browse files
lu-zeroAmanieu
authored andcommitted
Move the altivec macros in a stand alone files
1 parent cf3deea commit 2dfc447

File tree

3 files changed

+92
-90
lines changed

3 files changed

+92
-90
lines changed

crates/core_arch/src/powerpc/altivec.rs

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -337,96 +337,6 @@ impl_neg! { f32x4 : 0f32 }
337337
mod sealed {
338338
use super::*;
339339

340-
macro_rules! test_impl {
341-
($fun:ident ($($v:ident : $ty:ty),*) -> $r:ty [$call:ident, $instr:ident]) => {
342-
#[inline]
343-
#[target_feature(enable = "altivec")]
344-
#[cfg_attr(test, assert_instr($instr))]
345-
pub unsafe fn $fun ($($v : $ty),*) -> $r {
346-
$call ($($v),*)
347-
}
348-
};
349-
($fun:ident ($($v:ident : $ty:ty),*) -> $r:ty [$call:ident, $instr_altivec:ident / $instr_vsx:ident]) => {
350-
#[inline]
351-
#[target_feature(enable = "altivec")]
352-
#[cfg_attr(all(test, not(target_feature="vsx")), assert_instr($instr_altivec))]
353-
#[cfg_attr(all(test, target_feature="vsx"), assert_instr($instr_vsx))]
354-
pub unsafe fn $fun ($($v : $ty),*) -> $r {
355-
$call ($($v),*)
356-
}
357-
}
358-
359-
}
360-
361-
#[allow(unknown_lints, unused_macro_rules)]
362-
macro_rules! impl_vec_trait {
363-
([$Trait:ident $m:ident] $fun:ident ($a:ty)) => {
364-
impl $Trait for $a {
365-
#[inline]
366-
#[target_feature(enable = "altivec")]
367-
unsafe fn $m(self) -> Self {
368-
$fun(transmute(self))
369-
}
370-
}
371-
};
372-
([$Trait:ident $m:ident] $fun:ident ($a:ty) -> $r:ty) => {
373-
impl $Trait for $a {
374-
type Result = $r;
375-
#[inline]
376-
#[target_feature(enable = "altivec")]
377-
unsafe fn $m(self) -> Self::Result {
378-
$fun(transmute(self))
379-
}
380-
}
381-
};
382-
([$Trait:ident $m:ident] 1 ($ub:ident, $sb:ident, $uh:ident, $sh:ident, $uw:ident, $sw:ident, $sf: ident)) => {
383-
impl_vec_trait!{ [$Trait $m] $ub (vector_unsigned_char) -> vector_unsigned_char }
384-
impl_vec_trait!{ [$Trait $m] $sb (vector_signed_char) -> vector_signed_char }
385-
impl_vec_trait!{ [$Trait $m] $uh (vector_unsigned_short) -> vector_unsigned_short }
386-
impl_vec_trait!{ [$Trait $m] $sh (vector_signed_short) -> vector_signed_short }
387-
impl_vec_trait!{ [$Trait $m] $uw (vector_unsigned_int) -> vector_unsigned_int }
388-
impl_vec_trait!{ [$Trait $m] $sw (vector_signed_int) -> vector_signed_int }
389-
impl_vec_trait!{ [$Trait $m] $sf (vector_float) -> vector_float }
390-
};
391-
([$Trait:ident $m:ident] $fun:ident ($a:ty, $b:ty) -> $r:ty) => {
392-
impl $Trait<$b> for $a {
393-
type Result = $r;
394-
#[inline]
395-
#[target_feature(enable = "altivec")]
396-
unsafe fn $m(self, b: $b) -> Self::Result {
397-
$fun(transmute(self), transmute(b))
398-
}
399-
}
400-
};
401-
([$Trait:ident $m:ident] $fun:ident ($a:ty, ~$b:ty) -> $r:ty) => {
402-
impl_vec_trait!{ [$Trait $m] $fun ($a, $a) -> $r }
403-
impl_vec_trait!{ [$Trait $m] $fun ($a, $b) -> $r }
404-
impl_vec_trait!{ [$Trait $m] $fun ($b, $a) -> $r }
405-
};
406-
([$Trait:ident $m:ident] ~($ub:ident, $sb:ident, $uh:ident, $sh:ident, $uw:ident, $sw:ident)) => {
407-
impl_vec_trait!{ [$Trait $m] $ub (vector_unsigned_char, ~vector_bool_char) -> vector_unsigned_char }
408-
impl_vec_trait!{ [$Trait $m] $sb (vector_signed_char, ~vector_bool_char) -> vector_signed_char }
409-
impl_vec_trait!{ [$Trait $m] $uh (vector_unsigned_short, ~vector_bool_short) -> vector_unsigned_short }
410-
impl_vec_trait!{ [$Trait $m] $sh (vector_signed_short, ~vector_bool_short) -> vector_signed_short }
411-
impl_vec_trait!{ [$Trait $m] $uw (vector_unsigned_int, ~vector_bool_int) -> vector_unsigned_int }
412-
impl_vec_trait!{ [$Trait $m] $sw (vector_signed_int, ~vector_bool_int) -> vector_signed_int }
413-
};
414-
([$Trait:ident $m:ident] ~($fn:ident)) => {
415-
impl_vec_trait!{ [$Trait $m] ~($fn, $fn, $fn, $fn, $fn, $fn) }
416-
};
417-
([$Trait:ident $m:ident] 2 ($ub:ident, $sb:ident, $uh:ident, $sh:ident, $uw:ident, $sw:ident)) => {
418-
impl_vec_trait!{ [$Trait $m] $ub (vector_unsigned_char, vector_unsigned_char) -> vector_unsigned_char }
419-
impl_vec_trait!{ [$Trait $m] $sb (vector_signed_char, vector_signed_char) -> vector_signed_char }
420-
impl_vec_trait!{ [$Trait $m] $uh (vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_short }
421-
impl_vec_trait!{ [$Trait $m] $sh (vector_signed_short, vector_signed_short) -> vector_signed_short }
422-
impl_vec_trait!{ [$Trait $m] $uw (vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_int }
423-
impl_vec_trait!{ [$Trait $m] $sw (vector_signed_int, vector_signed_int) -> vector_signed_int }
424-
};
425-
([$Trait:ident $m:ident] 2 ($fn:ident)) => {
426-
impl_vec_trait!{ [$Trait $m] ($fn, $fn, $fn, $fn, $fn, $fn) }
427-
}
428-
}
429-
430340
macro_rules! impl_vec_cmp {
431341
([$Trait:ident $m:ident] ($b:ident, $h:ident, $w:ident)) => {
432342
impl_vec_cmp! { [$Trait $m] ($b, $b, $h, $h, $w, $w) }
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
macro_rules! test_impl {
2+
($fun:ident ($($v:ident : $ty:ty),*) -> $r:ty [$call:ident, $instr:ident]) => {
3+
#[inline]
4+
#[target_feature(enable = "altivec")]
5+
#[cfg_attr(test, assert_instr($instr))]
6+
pub unsafe fn $fun ($($v : $ty),*) -> $r {
7+
$call ($($v),*)
8+
}
9+
};
10+
($fun:ident ($($v:ident : $ty:ty),*) -> $r:ty [$call:ident, $instr_altivec:ident / $instr_vsx:ident]) => {
11+
#[inline]
12+
#[target_feature(enable = "altivec")]
13+
#[cfg_attr(all(test, not(target_feature="vsx")), assert_instr($instr_altivec))]
14+
#[cfg_attr(all(test, target_feature="vsx"), assert_instr($instr_vsx))]
15+
pub unsafe fn $fun ($($v : $ty),*) -> $r {
16+
$call ($($v),*)
17+
}
18+
}
19+
}
20+
21+
#[allow(unknown_lints, unused_macro_rules)]
22+
macro_rules! impl_vec_trait {
23+
([$Trait:ident $m:ident] $fun:ident ($a:ty)) => {
24+
impl $Trait for $a {
25+
#[inline]
26+
#[target_feature(enable = "altivec")]
27+
unsafe fn $m(self) -> Self {
28+
$fun(transmute(self))
29+
}
30+
}
31+
};
32+
([$Trait:ident $m:ident] $fun:ident ($a:ty) -> $r:ty) => {
33+
impl $Trait for $a {
34+
type Result = $r;
35+
#[inline]
36+
#[target_feature(enable = "altivec")]
37+
unsafe fn $m(self) -> Self::Result {
38+
$fun(transmute(self))
39+
}
40+
}
41+
};
42+
([$Trait:ident $m:ident] 1 ($ub:ident, $sb:ident, $uh:ident, $sh:ident, $uw:ident, $sw:ident, $sf: ident)) => {
43+
impl_vec_trait!{ [$Trait $m] $ub (vector_unsigned_char) -> vector_unsigned_char }
44+
impl_vec_trait!{ [$Trait $m] $sb (vector_signed_char) -> vector_signed_char }
45+
impl_vec_trait!{ [$Trait $m] $uh (vector_unsigned_short) -> vector_unsigned_short }
46+
impl_vec_trait!{ [$Trait $m] $sh (vector_signed_short) -> vector_signed_short }
47+
impl_vec_trait!{ [$Trait $m] $uw (vector_unsigned_int) -> vector_unsigned_int }
48+
impl_vec_trait!{ [$Trait $m] $sw (vector_signed_int) -> vector_signed_int }
49+
impl_vec_trait!{ [$Trait $m] $sf (vector_float) -> vector_float }
50+
};
51+
([$Trait:ident $m:ident] $fun:ident ($a:ty, $b:ty) -> $r:ty) => {
52+
impl $Trait<$b> for $a {
53+
type Result = $r;
54+
#[inline]
55+
#[target_feature(enable = "altivec")]
56+
unsafe fn $m(self, b: $b) -> Self::Result {
57+
$fun(transmute(self), transmute(b))
58+
}
59+
}
60+
};
61+
([$Trait:ident $m:ident] $fun:ident ($a:ty, ~$b:ty) -> $r:ty) => {
62+
impl_vec_trait!{ [$Trait $m] $fun ($a, $a) -> $r }
63+
impl_vec_trait!{ [$Trait $m] $fun ($a, $b) -> $r }
64+
impl_vec_trait!{ [$Trait $m] $fun ($b, $a) -> $r }
65+
};
66+
([$Trait:ident $m:ident] ~($ub:ident, $sb:ident, $uh:ident, $sh:ident, $uw:ident, $sw:ident)) => {
67+
impl_vec_trait!{ [$Trait $m] $ub (vector_unsigned_char, ~vector_bool_char) -> vector_unsigned_char }
68+
impl_vec_trait!{ [$Trait $m] $sb (vector_signed_char, ~vector_bool_char) -> vector_signed_char }
69+
impl_vec_trait!{ [$Trait $m] $uh (vector_unsigned_short, ~vector_bool_short) -> vector_unsigned_short }
70+
impl_vec_trait!{ [$Trait $m] $sh (vector_signed_short, ~vector_bool_short) -> vector_signed_short }
71+
impl_vec_trait!{ [$Trait $m] $uw (vector_unsigned_int, ~vector_bool_int) -> vector_unsigned_int }
72+
impl_vec_trait!{ [$Trait $m] $sw (vector_signed_int, ~vector_bool_int) -> vector_signed_int }
73+
};
74+
([$Trait:ident $m:ident] ~($fn:ident)) => {
75+
impl_vec_trait!{ [$Trait $m] ~($fn, $fn, $fn, $fn, $fn, $fn) }
76+
};
77+
([$Trait:ident $m:ident] 2 ($ub:ident, $sb:ident, $uh:ident, $sh:ident, $uw:ident, $sw:ident)) => {
78+
impl_vec_trait!{ [$Trait $m] $ub (vector_unsigned_char, vector_unsigned_char) -> vector_unsigned_char }
79+
impl_vec_trait!{ [$Trait $m] $sb (vector_signed_char, vector_signed_char) -> vector_signed_char }
80+
impl_vec_trait!{ [$Trait $m] $uh (vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_short }
81+
impl_vec_trait!{ [$Trait $m] $sh (vector_signed_short, vector_signed_short) -> vector_signed_short }
82+
impl_vec_trait!{ [$Trait $m] $uw (vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_int }
83+
impl_vec_trait!{ [$Trait $m] $sw (vector_signed_int, vector_signed_int) -> vector_signed_int }
84+
};
85+
([$Trait:ident $m:ident] 2 ($fn:ident)) => {
86+
impl_vec_trait!{ [$Trait $m] ($fn, $fn, $fn, $fn, $fn, $fn) }
87+
}
88+
}

crates/core_arch/src/powerpc/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
//! PowerPC intrinsics
2+
3+
#[macro_use]
4+
mod macros;
5+
26
#[cfg(any(target_feature = "altivec", doc))]
37
mod altivec;
48
#[cfg(any(target_feature = "altivec", doc))]

0 commit comments

Comments
 (0)