@@ -14,6 +14,25 @@ cfg_if::cfg_if! {
14
14
#[ derive( Default , Clone , Copy , PartialEq , Debug ) ]
15
15
#[ repr( C , align( 16 ) ) ]
16
16
pub struct f32x4( m128) ;
17
+ } else if #[ cfg( all( feature = "simd" , target_feature = "simd128" ) ) ] {
18
+ use core:: arch:: wasm32:: * ;
19
+
20
+ // repr(transparent) allows for directly passing the v128 on the WASM stack.
21
+ #[ derive( Clone , Copy , Debug ) ]
22
+ #[ repr( transparent) ]
23
+ pub struct f32x4( v128) ;
24
+
25
+ impl Default for f32x4 {
26
+ fn default ( ) -> Self {
27
+ Self :: splat( 0.0 )
28
+ }
29
+ }
30
+
31
+ impl PartialEq for f32x4 {
32
+ fn eq( & self , other: & Self ) -> bool {
33
+ u32x4_all_true( f32x4_eq( self . 0 , other. 0 ) )
34
+ }
35
+ }
17
36
} else {
18
37
#[ derive( Default , Clone , Copy , PartialEq , Debug ) ]
19
38
#[ repr( C , align( 16 ) ) ]
@@ -33,6 +52,8 @@ impl f32x4 {
33
52
cfg_if:: cfg_if! {
34
53
if #[ cfg( all( feature = "simd" , target_feature = "sse" ) ) ] {
35
54
Self ( max_m128( self . 0 , rhs. 0 ) )
55
+ } else if #[ cfg( all( feature = "simd" , target_feature = "simd128" ) ) ] {
56
+ Self ( f32x4_max( self . 0 , rhs. 0 ) )
36
57
} else {
37
58
Self ( [
38
59
self . 0 [ 0 ] . max( rhs. 0 [ 0 ] ) ,
@@ -48,6 +69,8 @@ impl f32x4 {
48
69
cfg_if:: cfg_if! {
49
70
if #[ cfg( all( feature = "simd" , target_feature = "sse" ) ) ] {
50
71
Self ( min_m128( self . 0 , rhs. 0 ) )
72
+ } else if #[ cfg( all( feature = "simd" , target_feature = "simd128" ) ) ] {
73
+ Self ( f32x4_min( self . 0 , rhs. 0 ) )
51
74
} else {
52
75
Self ( [
53
76
self . 0 [ 0 ] . min( rhs. 0 [ 0 ] ) ,
@@ -79,6 +102,8 @@ impl core::ops::Add for f32x4 {
79
102
cfg_if:: cfg_if! {
80
103
if #[ cfg( all( feature = "simd" , target_feature = "sse" ) ) ] {
81
104
Self ( add_m128( self . 0 , rhs. 0 ) )
105
+ } else if #[ cfg( all( feature = "simd" , target_feature = "simd128" ) ) ] {
106
+ Self ( f32x4_add( self . 0 , rhs. 0 ) )
82
107
} else {
83
108
Self ( [
84
109
self . 0 [ 0 ] + rhs. 0 [ 0 ] ,
@@ -104,6 +129,8 @@ impl core::ops::Sub for f32x4 {
104
129
cfg_if:: cfg_if! {
105
130
if #[ cfg( all( feature = "simd" , target_feature = "sse" ) ) ] {
106
131
Self ( sub_m128( self . 0 , rhs. 0 ) )
132
+ } else if #[ cfg( all( feature = "simd" , target_feature = "simd128" ) ) ] {
133
+ Self ( f32x4_sub( self . 0 , rhs. 0 ) )
107
134
} else {
108
135
Self ( [
109
136
self . 0 [ 0 ] - rhs. 0 [ 0 ] ,
@@ -123,6 +150,8 @@ impl core::ops::Mul for f32x4 {
123
150
cfg_if:: cfg_if! {
124
151
if #[ cfg( all( feature = "simd" , target_feature = "sse" ) ) ] {
125
152
Self ( mul_m128( self . 0 , rhs. 0 ) )
153
+ } else if #[ cfg( all( feature = "simd" , target_feature = "simd128" ) ) ] {
154
+ Self ( f32x4_mul( self . 0 , rhs. 0 ) )
126
155
} else {
127
156
Self ( [
128
157
self . 0 [ 0 ] * rhs. 0 [ 0 ] ,
0 commit comments