@@ -81,7 +81,7 @@ fn type_len(t: &str) -> usize {
81
81
"poly64x1_t" => 1 ,
82
82
"poly64x2_t" => 2 ,
83
83
"i8" | "i16" | "i32" | "i64" | "u8" | "u16" | "u32" | "u64" | "f32" | "f64" | "p8"
84
- | "p16" | "p128" => 1 ,
84
+ | "p16" | "p64" | " p128" => 1 ,
85
85
_ => panic ! ( "unknown type: {}" , t) ,
86
86
}
87
87
}
@@ -333,7 +333,7 @@ fn type_to_noq_suffix(t: &str) -> &str {
333
333
"float64x1_t" | "float64x2_t" => "_f64" ,
334
334
"poly8x8_t" | "poly8x16_t" => "_p8" ,
335
335
"poly16x4_t" | "poly16x8_t" => "_p16" ,
336
- "poly64x1_t" | "poly64x2_t" => "_p64" ,
336
+ "poly64x1_t" | "poly64x2_t" | "p64" => "_p64" ,
337
337
_ => panic ! ( "unknown type: {}" , t) ,
338
338
}
339
339
}
@@ -355,8 +355,10 @@ enum Suffix {
355
355
356
356
#[ derive( Clone , Copy ) ]
357
357
enum TargetFeature {
358
+ Default ,
358
359
ArmV7 ,
359
360
FPArmV8 ,
361
+ Crypto ,
360
362
}
361
363
362
364
fn type_to_global_type ( t : & str ) -> & str {
@@ -401,6 +403,7 @@ fn type_to_global_type(t: &str) -> &str {
401
403
"f64" => "f64" ,
402
404
"p8" => "p8" ,
403
405
"p16" => "p16" ,
406
+ "p64" => "p64" ,
404
407
"p128" => "p128" ,
405
408
_ => panic ! ( "unknown type: {}" , t) ,
406
409
}
@@ -496,6 +499,8 @@ fn type_to_ext(t: &str) -> &str {
496
499
"u64" => "v1i64" ,
497
500
"f32" => "f32" ,
498
501
"f64" => "f64" ,
502
+ "p64" => "p64" ,
503
+ "p128" => "p128" ,
499
504
/*
500
505
"poly64x1_t" => "i64x1",
501
506
"poly64x2_t" => "i64x2",
@@ -829,6 +834,7 @@ fn gen_aarch64(
829
834
) ] ,
830
835
suffix : Suffix ,
831
836
para_num : i32 ,
837
+ target : TargetFeature ,
832
838
fixed : & Vec < String > ,
833
839
multi_fn : & Vec < String > ,
834
840
) -> ( String , String ) {
@@ -855,12 +861,15 @@ fn gen_aarch64(
855
861
In2 => format ! ( "{}{}" , current_name, type_to_suffix( in_t[ 2 ] ) ) ,
856
862
In2Lane => format ! ( "{}{}" , current_name, type_to_lane_suffixes( out_t, in_t[ 2 ] ) ) ,
857
863
} ;
864
+ let current_target = match target {
865
+ Default => "neon" ,
866
+ ArmV7 => "v7" ,
867
+ FPArmV8 => "fp-armv8,v8" ,
868
+ Crypto => "neon,crypto" ,
869
+ } ;
858
870
let current_fn = if let Some ( current_fn) = current_fn. clone ( ) {
859
871
if link_aarch64. is_some ( ) {
860
- panic ! (
861
- "[{}] Can't specify link and (multi) fn at the same time." ,
862
- name
863
- )
872
+ panic ! ( "[{}] Can't specify link and fn at the same time." , name)
864
873
}
865
874
current_fn
866
875
} else if link_aarch64. is_some ( ) {
@@ -877,7 +886,24 @@ fn gen_aarch64(
877
886
let current_aarch64 = current_aarch64. clone ( ) . unwrap ( ) ;
878
887
let mut ext_c = String :: new ( ) ;
879
888
let mut ext_c_const = String :: new ( ) ;
880
- if let Some ( link_aarch64) = link_aarch64. clone ( ) {
889
+ let mut link_t: Vec < String > = vec ! [
890
+ in_t[ 0 ] . to_string( ) ,
891
+ in_t[ 1 ] . to_string( ) ,
892
+ in_t[ 2 ] . to_string( ) ,
893
+ out_t. to_string( ) ,
894
+ ] ;
895
+ if let Some ( mut link_aarch64) = link_aarch64. clone ( ) {
896
+ if link_aarch64. contains ( ":" ) {
897
+ let links: Vec < _ > = link_aarch64. split ( ':' ) . map ( |v| v. to_string ( ) ) . collect ( ) ;
898
+ assert_eq ! ( links. len( ) , 5 ) ;
899
+ link_aarch64 = links[ 0 ] . to_string ( ) ;
900
+ link_t = vec ! [
901
+ links[ 1 ] . clone( ) ,
902
+ links[ 2 ] . clone( ) ,
903
+ links[ 3 ] . clone( ) ,
904
+ links[ 4 ] . clone( ) ,
905
+ ] ;
906
+ }
881
907
let ext = type_to_ext ( in_t[ 0 ] ) ;
882
908
let ext2 = type_to_ext ( out_t) ;
883
909
let link_aarch64 = if link_aarch64. starts_with ( "llvm" ) {
@@ -898,17 +924,17 @@ fn gen_aarch64(
898
924
current_fn,
899
925
match para_num {
900
926
1 => {
901
- format!( "a: {}" , in_t [ 0 ] )
927
+ format!( "a: {}" , link_t [ 0 ] )
902
928
}
903
929
2 => {
904
- format!( "a: {}, b: {}" , in_t [ 0 ] , in_t [ 1 ] )
930
+ format!( "a: {}, b: {}" , link_t [ 0 ] , link_t [ 1 ] )
905
931
}
906
932
3 => {
907
- format!( "a: {}, b: {}, c: {}" , in_t [ 0 ] , in_t [ 1 ] , in_t [ 2 ] )
933
+ format!( "a: {}, b: {}, c: {}" , link_t [ 0 ] , link_t [ 1 ] , link_t [ 2 ] )
908
934
}
909
935
_ => unimplemented!( "unknown para_num" ) ,
910
936
} ,
911
- out_t
937
+ link_t [ 3 ]
912
938
) ;
913
939
if const_aarch64. is_some ( ) {
914
940
ext_c_const = format ! (
@@ -1003,6 +1029,11 @@ fn gen_aarch64(
1003
1029
} else {
1004
1030
String :: new ( )
1005
1031
} ;
1032
+ let trans: [ & str ; 2 ] = if link_t[ 3 ] != out_t {
1033
+ [ "transmute(" , ")" ]
1034
+ } else {
1035
+ [ "" , "" ]
1036
+ } ;
1006
1037
let call = if let Some ( const_aarch64) = const_aarch64 {
1007
1038
match para_num {
1008
1039
1 => format ! (
@@ -1038,31 +1069,33 @@ fn gen_aarch64(
1038
1069
match ( multi_calls. len ( ) , para_num, fixed. len ( ) ) {
1039
1070
( 0 , 1 , 0 ) => format ! (
1040
1071
r#"pub unsafe fn {}{}(a: {}) -> {} {{
1041
- {}{}(a)
1072
+ {}{}{} (a){}
1042
1073
}}"# ,
1043
- name, const_declare, in_t[ 0 ] , out_t, ext_c, current_fn,
1074
+ name, const_declare, in_t[ 0 ] , out_t, ext_c, trans [ 0 ] , current_fn, trans [ 1 ]
1044
1075
) ,
1045
1076
( 0 , 1 , _) => {
1046
1077
let fixed: Vec < String > = fixed. iter ( ) . take ( type_len ( in_t[ 0 ] ) ) . cloned ( ) . collect ( ) ;
1047
1078
format ! (
1048
1079
r#"pub unsafe fn {}{}(a: {}) -> {} {{
1049
1080
let b{};
1050
- {}{}(a, transmute(b))
1081
+ {}{}{} (a, transmute(b)){}
1051
1082
}}"# ,
1052
1083
name,
1053
1084
const_declare,
1054
1085
in_t[ 0 ] ,
1055
1086
out_t,
1056
1087
values( in_t[ 0 ] , & fixed) ,
1057
1088
ext_c,
1089
+ trans[ 0 ] ,
1058
1090
current_fn,
1091
+ trans[ 1 ] ,
1059
1092
)
1060
1093
}
1061
1094
( 0 , 2 , _) => format ! (
1062
1095
r#"pub unsafe fn {}{}(a: {}, b: {}) -> {} {{
1063
- {}{}(a, b)
1096
+ {}{}{} (a, b){}
1064
1097
}}"# ,
1065
- name, const_declare, in_t[ 0 ] , in_t[ 1 ] , out_t, ext_c, current_fn,
1098
+ name, const_declare, in_t[ 0 ] , in_t[ 1 ] , out_t, ext_c, trans [ 0 ] , current_fn, trans [ 1 ] ,
1066
1099
) ,
1067
1100
( 0 , 3 , _) => format ! (
1068
1101
r#"pub unsafe fn {}{}(a: {}, b: {}, c: {}) -> {} {{
@@ -1095,11 +1128,11 @@ fn gen_aarch64(
1095
1128
r#"
1096
1129
{}
1097
1130
#[inline]
1098
- #[target_feature(enable = "neon ")]
1131
+ #[target_feature(enable = "{} ")]
1099
1132
#[cfg_attr(test, assert_instr({}{}))]{}
1100
1133
{}
1101
1134
"# ,
1102
- current_comment, current_aarch64, const_assert, const_legacy, call
1135
+ current_comment, current_target , current_aarch64, const_assert, const_legacy, call
1103
1136
) ;
1104
1137
1105
1138
let test = gen_test (
@@ -1274,8 +1307,10 @@ fn gen_arm(
1274
1307
. unwrap_or_else ( || current_arm. to_string ( ) ) ;
1275
1308
1276
1309
let current_target = match target {
1310
+ Default => "v7" ,
1277
1311
ArmV7 => "v7" ,
1278
1312
FPArmV8 => "fp-armv8,v8" ,
1313
+ Crypto => "crypto" ,
1279
1314
} ;
1280
1315
1281
1316
let current_fn = if let Some ( current_fn) = current_fn. clone ( ) {
@@ -2074,7 +2109,7 @@ fn get_call(
2074
2109
}
2075
2110
}
2076
2111
if param_str. is_empty ( ) {
2077
- return fn_name
2112
+ return fn_name;
2078
2113
}
2079
2114
let fn_str = if let Some ( ( re_name, re_type) ) = re. clone ( ) {
2080
2115
format ! (
@@ -2119,7 +2154,7 @@ fn main() -> io::Result<()> {
2119
2154
Vec < String > ,
2120
2155
) > = Vec :: new ( ) ;
2121
2156
let mut multi_fn: Vec < String > = Vec :: new ( ) ;
2122
- let mut target: TargetFeature = ArmV7 ;
2157
+ let mut target: TargetFeature = Default ;
2123
2158
2124
2159
//
2125
2160
// THIS FILE IS GENERATED FORM neon.spec DO NOT CHANGE IT MANUALLY
@@ -2200,7 +2235,7 @@ mod test {
2200
2235
fixed = Vec :: new ( ) ;
2201
2236
n = None ;
2202
2237
multi_fn = Vec :: new ( ) ;
2203
- target = ArmV7 ;
2238
+ target = Default ;
2204
2239
} else if line. starts_with ( "//" ) {
2205
2240
} else if line. starts_with ( "name = " ) {
2206
2241
current_name = Some ( String :: from ( & line[ 7 ..] ) ) ;
@@ -2258,10 +2293,12 @@ mod test {
2258
2293
} else if line. starts_with ( "target = " ) {
2259
2294
target = match Some ( String :: from ( & line[ 9 ..] ) ) {
2260
2295
Some ( input) => match input. as_str ( ) {
2296
+ "v7" => ArmV7 ,
2261
2297
"fp-armv8" => FPArmV8 ,
2262
- _ => ArmV7 ,
2298
+ "crypto" => Crypto ,
2299
+ _ => Default ,
2263
2300
} ,
2264
- _ => ArmV7 ,
2301
+ _ => Default ,
2265
2302
}
2266
2303
} else if line. starts_with ( "generate " ) {
2267
2304
let line = & line[ 9 ..] ;
@@ -2341,6 +2378,7 @@ mod test {
2341
2378
& current_tests,
2342
2379
suffix,
2343
2380
para_num,
2381
+ target,
2344
2382
& fixed,
2345
2383
& multi_fn,
2346
2384
) ;
0 commit comments