@@ -89,6 +89,14 @@ macro_rules! multiversion {
8989 AVX2x4 => unsafe { $name:: avx2x4:: $name( $( $arg_name) ,* ) } ,
9090 #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
9191 AVX2x8 => unsafe { $name:: avx2x8:: $name( $( $arg_name) ,* ) } ,
92+ #[ cfg( all( feature = "unsafe" , target_arch = "aarch64" ) ) ]
93+ Neon => $name:: neon:: $name( $( $arg_name) ,* ) ,
94+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
95+ Neonx2 => $name:: neonx2:: $name( $( $arg_name) ,* ) ,
96+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
97+ Neonx4 => $name:: neonx4:: $name( $( $arg_name) ,* ) ,
98+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
99+ Neonx8 => $name:: neonx8:: $name( $( $arg_name) ,* ) ,
92100 }
93101 }
94102 } ;
@@ -184,6 +192,42 @@ macro_rules! multiversion {
184192
185193 $crate:: multiversion!{ @helper target_feature( enable = "avx2" ) $( $tail) * }
186194 }
195+
196+ /// [`multiversion!`] neon implementation.
197+ #[ cfg( all( feature = "unsafe" , target_arch = "aarch64" ) ) ]
198+ pub mod neon {
199+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
200+ use { super :: * , $( $( $path:: ) +neon:: * ) ,* } ;
201+
202+ $( $tail) *
203+ }
204+
205+ /// [`multiversion!`] neonx2 implementation.
206+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
207+ pub mod neonx2 {
208+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
209+ use { super :: * , $( $( $path:: ) +neonx2:: * ) ,* } ;
210+
211+ $( $tail) *
212+ }
213+
214+ /// [`multiversion!`] neonx4 implementation.
215+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
216+ pub mod neonx4 {
217+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
218+ use { super :: * , $( $( $path:: ) +neonx4:: * ) ,* } ;
219+
220+ $( $tail) *
221+ }
222+
223+ /// [`multiversion!`] neonx8 implementation.
224+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
225+ pub mod neonx8 {
226+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
227+ use { super :: * , $( $( $path:: ) +neonx8:: * ) ,* } ;
228+
229+ $( $tail) *
230+ }
187231 } ;
188232
189233 // Microbenchmark for dynamic dispatch
@@ -219,6 +263,14 @@ macro_rules! multiversion {
219263 AVX2x4 => unsafe { avx2x4:: $name( ) } ,
220264 #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
221265 AVX2x8 => unsafe { avx2x8:: $name( ) } ,
266+ #[ cfg( all( feature = "unsafe" , target_arch = "aarch64" ) ) ]
267+ Neon => neon:: $name( ) ,
268+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
269+ Neonx2 => neonx2:: $name( ) ,
270+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
271+ Neonx4 => neonx4:: $name( ) ,
272+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
273+ Neonx8 => neonx8:: $name( ) ,
222274 } ) ;
223275 ( start. elapsed( ) , x)
224276 } )
@@ -395,6 +447,46 @@ macro_rules! multiversion_test {
395447
396448 unsafe { $body }
397449 }
450+
451+ #[ test]
452+ #[ cfg( all( feature = "unsafe" , target_arch = "aarch64" ) ) ]
453+ $( #[ $m] ) *
454+ fn neon( ) {
455+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
456+ use { $( $( $path:: ) +neon:: * ) ,* } ;
457+
458+ $body
459+ }
460+
461+ #[ test]
462+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
463+ $( #[ $m] ) *
464+ fn neonx2( ) {
465+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
466+ use { $( $( $path:: ) +neonx2:: * ) ,* } ;
467+
468+ $body
469+ }
470+
471+ #[ test]
472+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
473+ $( #[ $m] ) *
474+ fn neonx4( ) {
475+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
476+ use { $( $( $path:: ) +neonx4:: * ) ,* } ;
477+
478+ $body
479+ }
480+
481+ #[ test]
482+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
483+ $( #[ $m] ) *
484+ fn neonx8( ) {
485+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
486+ use { $( $( $path:: ) +neonx8:: * ) ,* } ;
487+
488+ $body
489+ }
398490 } ;
399491
400492 (
@@ -471,6 +563,40 @@ macro_rules! multiversion_test {
471563 $crate:: multiversion_test!( @expr { $( $tail) + } ) ;
472564 }
473565 }
566+
567+ #[ cfg( all( feature = "unsafe" , target_arch = "aarch64" ) ) ]
568+ {
569+ {
570+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
571+ use { $( $( $path:: ) +neon:: * ) ,* } ;
572+
573+ $crate:: multiversion_test!( @expr { $( $tail) + } ) ;
574+ }
575+
576+ #[ cfg( feature = "all-simd" ) ]
577+ {
578+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
579+ use { $( $( $path:: ) +neonx2:: * ) ,* } ;
580+
581+ $crate:: multiversion_test!( @expr { $( $tail) + } ) ;
582+ }
583+
584+ #[ cfg( feature = "all-simd" ) ]
585+ {
586+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
587+ use { $( $( $path:: ) +neonx4:: * ) ,* } ;
588+
589+ $crate:: multiversion_test!( @expr { $( $tail) + } ) ;
590+ }
591+
592+ #[ cfg( feature = "all-simd" ) ]
593+ {
594+ #[ allow( clippy:: allow_attributes, unused_imports, clippy:: wildcard_imports) ]
595+ use { $( $( $path:: ) +neonx8:: * ) ,* } ;
596+
597+ $crate:: multiversion_test!( @expr { $( $tail) + } ) ;
598+ }
599+ }
474600 } ;
475601 ( @expr $e: expr) => { $e }
476602}
@@ -536,6 +662,14 @@ versions_impl! {
536662 AVX2x4 if std:: arch:: is_x86_feature_detected!( "avx2" ) ,
537663 #[ cfg( all( feature = "unsafe" , feature = "all-simd" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
538664 AVX2x8 if std:: arch:: is_x86_feature_detected!( "avx2" ) ,
665+ #[ cfg( all( feature = "unsafe" , target_arch = "aarch64" ) ) ]
666+ Neon ,
667+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
668+ Neonx2 ,
669+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
670+ Neonx4 ,
671+ #[ cfg( all( feature = "unsafe" , feature = "all-simd" , target_arch = "aarch64" ) ) ]
672+ Neonx8 ,
539673}
540674
541675static OVERRIDE : OnceLock < Option < Version > > = OnceLock :: new ( ) ;
0 commit comments