10
10
11
11
use std:: arch:: aarch64:: { self , float32x2_t, float32x4_t, int32x2_t, int32x4_t} ;
12
12
use std:: arch:: aarch64:: { uint32x2_t, uint32x4_t} ;
13
- use std:: intrinsics:: simd:: * ;
14
13
use std:: f32;
15
14
use std:: fmt:: { self , Debug , Formatter } ;
15
+ use std:: intrinsics:: simd:: * ;
16
16
use std:: mem;
17
17
use std:: ops:: { Add , BitAnd , BitOr , Div , Index , IndexMut , Mul , Not , Shr , Sub } ;
18
18
@@ -201,7 +201,6 @@ impl IndexMut<usize> for F32x2 {
201
201
}
202
202
}
203
203
204
-
205
204
impl Add < F32x2 > for F32x2 {
206
205
type Output = F32x2 ;
207
206
#[ inline]
@@ -352,7 +351,7 @@ impl F32x4 {
352
351
353
352
#[ inline]
354
353
pub fn concat_xy_xy ( self , other : F32x4 ) -> F32x4 {
355
- unsafe { F32x4 ( simd_shuffle4 ! ( self . 0 , other. 0 , [ 0 , 1 , 2 , 3 ] ) ) }
354
+ unsafe { F32x4 ( simd_shuffle4 ! ( self . 0 , other. 0 , [ 0 , 1 , 4 , 5 ] ) ) }
356
355
}
357
356
358
357
#[ inline]
@@ -365,6 +364,11 @@ impl F32x4 {
365
364
unsafe { F32x4 ( simd_shuffle4 ! ( self . 0 , other. 0 , [ 2 , 3 , 6 , 7 ] ) ) }
366
365
}
367
366
367
+ #[ inline]
368
+ pub fn concat_wz_yx ( self , other : F32x4 ) -> F32x4 {
369
+ unsafe { F32x4 ( simd_shuffle4 ! ( self . 0 , other. 0 , [ 3 , 2 , 5 , 4 ] ) ) }
370
+ }
371
+
368
372
// Conversions
369
373
370
374
/// Converts these packed floats to integers via rounding.
@@ -832,13 +836,22 @@ impl BitOr<U32x2> for U32x2 {
832
836
}
833
837
}
834
838
835
-
836
839
// Four 32-bit unsigned integers
837
840
838
841
#[ derive( Clone , Copy ) ]
839
842
pub struct U32x4 ( pub uint32x4_t ) ;
840
843
841
844
impl U32x4 {
845
+ #[ inline]
846
+ pub fn new ( a : u32 , b : u32 , c : u32 , d : u32 ) -> U32x4 {
847
+ unsafe { U32x4 ( mem:: transmute ( [ a, b, c, d] ) ) }
848
+ }
849
+
850
+ #[ inline]
851
+ pub fn splat ( x : u32 ) -> U32x4 {
852
+ U32x4 :: new ( x, x, x, x)
853
+ }
854
+
842
855
/// Returns true if all four booleans in this vector are true.
843
856
///
844
857
/// The result is *undefined* if all four values in this vector are not booleans. A boolean is
@@ -856,6 +869,20 @@ impl U32x4 {
856
869
pub fn all_false ( & self ) -> bool {
857
870
unsafe { aarch64:: vmaxvq_u32 ( self . 0 ) == 0 }
858
871
}
872
+
873
+ // Packed comparisons
874
+
875
+ #[ inline]
876
+ pub fn packed_eq ( self , other : U32x4 ) -> U32x4 {
877
+ unsafe { U32x4 ( simd_eq ( self . 0 , other. 0 ) ) }
878
+ }
879
+ }
880
+
881
+ impl Debug for U32x4 {
882
+ #[ inline]
883
+ fn fmt ( & self , f : & mut Formatter ) -> Result < ( ) , fmt:: Error > {
884
+ write ! ( f, "<{}, {}, {}, {}>" , self [ 0 ] , self [ 1 ] , self [ 2 ] , self [ 3 ] )
885
+ }
859
886
}
860
887
861
888
impl Index < usize > for U32x4 {
@@ -870,6 +897,13 @@ impl Index<usize> for U32x4 {
870
897
}
871
898
}
872
899
900
+ impl PartialEq for U32x4 {
901
+ #[ inline]
902
+ fn eq ( & self , other : & U32x4 ) -> bool {
903
+ self . packed_eq ( * other) . all_true ( )
904
+ }
905
+ }
906
+
873
907
extern "C" {
874
908
#[ link_name = "llvm.fabs.v2f32" ]
875
909
fn fabs_v2f32 ( a : float32x2_t ) -> float32x2_t ;
0 commit comments