Skip to content

Commit 5fdb148

Browse files
committed
simplify macro
1 parent bab4baa commit 5fdb148

1 file changed

Lines changed: 13 additions & 46 deletions

File tree

  • crates/core_arch/src/powerpc

crates/core_arch/src/powerpc/vsx.rs

Lines changed: 13 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -174,63 +174,30 @@ mod sealed {
174174
vec_mergeeo! { vector_float, mergee, mergeo }
175175
}
176176

177-
// Macro to implement VectorCmpEq trait for vector types.
178-
macro_rules! impl_vec_cmpeq {
179-
($vec_ty:ident, $result_ty:ident, $mask_ty:ident, $instr:ident) => {
180-
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
181-
impl crate::core_arch::powerpc::altivec::sealed::VectorCmpEq<$vec_ty> for $vec_ty {
182-
type Result = $result_ty;
183-
#[inline]
184-
#[target_feature(enable = "vsx")]
185-
#[cfg_attr(test, assert_instr($instr))]
186-
unsafe fn vec_cmpeq(self, b: $vec_ty) -> Self::Result {
187-
let result: $mask_ty = simd_eq(self, b);
188-
transmute(result)
189-
}
190-
}
191-
};
192-
}
193-
impl_vec_cmpeq!(vector_float, vector_bool_int, m32x4, xvcmpeqsp);
194-
impl_vec_cmpeq!(vector_double, vector_bool_long, m64x2, xvcmpeqdp);
195-
196-
// Macro to implement VectorCmpGt trait for vector types.
197-
macro_rules! impl_vec_cmpgt {
198-
($vec_ty:ident, $result_ty:ident, $mask_ty:ident, $instr:ident) => {
199-
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
200-
impl crate::core_arch::powerpc::altivec::sealed::VectorCmpGt<$vec_ty> for $vec_ty {
201-
type Result = $result_ty;
202-
#[inline]
203-
#[target_feature(enable = "vsx")]
204-
#[cfg_attr(test, assert_instr($instr))]
205-
unsafe fn vec_cmpgt(self, b: $vec_ty) -> Self::Result {
206-
let result: $mask_ty = simd_gt(self, b);
207-
transmute(result)
208-
}
209-
}
210-
};
211-
}
212-
impl_vec_cmpgt!(vector_float, vector_bool_int, m32x4, xvcmpgtsp);
213-
impl_vec_cmpgt!(vector_double, vector_bool_long, m64x2, xvcmpgtdp);
214-
215-
// Macro to implement VectorCmpGe trait for vector types.
216-
macro_rules! impl_vec_cmpge {
217-
($vec_ty:ident, $result_ty:ident, $mask_ty:ident, $instr:ident) => {
177+
// Macro to implement VectorCmp* traits for vector types.
178+
macro_rules! impl_vsx_cmp {
179+
($trait_name:ident, $method_name:ident, $simd_op:ident, $vec_ty:ident, $result_ty:ident, $mask_ty:ident, $instr:ident) => {
218180
#[cfg(target_feature = "vsx")]
219181
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
220-
impl crate::core_arch::powerpc::altivec::sealed::VectorCmpGe<$vec_ty> for $vec_ty {
182+
impl crate::core_arch::powerpc::altivec::sealed::$trait_name<$vec_ty> for $vec_ty {
221183
type Result = $result_ty;
222184
#[inline]
223185
#[target_feature(enable = "vsx")]
224186
#[cfg_attr(test, assert_instr($instr))]
225-
unsafe fn vec_cmpge(self, b: $vec_ty) -> Self::Result {
226-
let result: $mask_ty = simd_ge(self, b);
187+
unsafe fn $method_name(self, b: $vec_ty) -> Self::Result {
188+
let result: $mask_ty = $simd_op(self, b);
227189
transmute(result)
228190
}
229191
}
230192
};
231193
}
232-
impl_vec_cmpge!(vector_float, vector_bool_int, m32x4, xvcmpgesp);
233-
impl_vec_cmpge!(vector_double, vector_bool_long, m64x2, xvcmpgedp);
194+
195+
impl_vsx_cmp!(VectorCmpEq, vec_cmpeq, simd_eq, vector_float, vector_bool_int, m32x4, xvcmpeqsp);
196+
impl_vsx_cmp!(VectorCmpEq, vec_cmpeq, simd_eq, vector_double, vector_bool_long, m64x2, xvcmpeqdp);
197+
impl_vsx_cmp!(VectorCmpGt, vec_cmpgt, simd_gt, vector_float, vector_bool_int, m32x4, xvcmpgtsp);
198+
impl_vsx_cmp!(VectorCmpGt, vec_cmpgt, simd_gt, vector_double, vector_bool_long, m64x2, xvcmpgtdp);
199+
impl_vsx_cmp!(VectorCmpGe, vec_cmpge, simd_ge, vector_float, vector_bool_int, m32x4, xvcmpgesp);
200+
impl_vsx_cmp!(VectorCmpGe, vec_cmpge, simd_ge, vector_double, vector_bool_long, m64x2, xvcmpgedp);
234201

235202
/// Vector permute.
236203
#[inline]

0 commit comments

Comments
 (0)