@@ -41,18 +41,27 @@ impl IntrinsicDefinition<ArmIntrinsicType> for Intrinsic<ArmIntrinsicType> {
41
41
/// rust debug output format for the return type. The generated line assumes
42
42
/// there is an int i in scope which is the current pass number.
43
43
fn print_result_c ( & self , indentation : Indentation , additional : & str ) -> String {
44
- let lanes = if self . results ( ) . num_vectors ( ) > 1 {
45
- ( 0 ..self . results ( ) . num_vectors ( ) )
44
+ self . results ( ) . print_result_c ( indentation, additional)
45
+ }
46
+ }
47
+
48
+ impl ArmIntrinsicType {
49
+ /// Generates a std::cout for the intrinsics results that will match the
50
+ /// rust debug output format for the return type. The generated line assumes
51
+ /// there is an int i in scope which is the current pass number.
52
+ fn print_result_c ( & self , indentation : Indentation , additional : & str ) -> String {
53
+ let lanes = if self . num_vectors ( ) > 1 {
54
+ ( 0 ..self . num_vectors ( ) )
46
55
. map ( |vector| {
47
56
format ! (
48
57
r#""{ty}(" << {lanes} << ")""# ,
49
- ty = self . results ( ) . c_single_vector_type( ) ,
50
- lanes = ( 0 ..self . results ( ) . num_lanes( ) )
58
+ ty = self . c_single_vector_type( ) ,
59
+ lanes = ( 0 ..self . num_lanes( ) )
51
60
. map( move |idx| -> std:: string:: String {
52
61
format!(
53
62
"{cast}{lane_fn}(__return_value.val[{vector}], {lane})" ,
54
- cast = self . results ( ) . c_promotion( ) ,
55
- lane_fn = self . results ( ) . get_lane_function( ) ,
63
+ cast = self . c_promotion( ) ,
64
+ lane_fn = self . get_lane_function( ) ,
56
65
lane = idx,
57
66
vector = vector,
58
67
)
@@ -63,13 +72,13 @@ impl IntrinsicDefinition<ArmIntrinsicType> for Intrinsic<ArmIntrinsicType> {
63
72
} )
64
73
. collect :: < Vec < _ > > ( )
65
74
. join ( r#" << ", " << "# )
66
- } else if self . results ( ) . num_lanes ( ) > 1 {
67
- ( 0 ..self . results ( ) . num_lanes ( ) )
75
+ } else if self . num_lanes ( ) > 1 {
76
+ ( 0 ..self . num_lanes ( ) )
68
77
. map ( |idx| -> std:: string:: String {
69
78
format ! (
70
79
"{cast}{lane_fn}(__return_value, {lane})" ,
71
- cast = self . results ( ) . c_promotion( ) ,
72
- lane_fn = self . results ( ) . get_lane_function( ) ,
80
+ cast = self . c_promotion( ) ,
81
+ lane_fn = self . get_lane_function( ) ,
73
82
lane = idx
74
83
)
75
84
} )
@@ -78,28 +87,27 @@ impl IntrinsicDefinition<ArmIntrinsicType> for Intrinsic<ArmIntrinsicType> {
78
87
} else {
79
88
format ! (
80
89
"{promote}cast<{cast}>(__return_value)" ,
81
- cast = match self . results. kind( ) {
82
- TypeKind :: Float if self . results( ) . inner_size( ) == 16 => "float16_t" . to_string( ) ,
83
- TypeKind :: Float if self . results( ) . inner_size( ) == 32 => "float" . to_string( ) ,
84
- TypeKind :: Float if self . results( ) . inner_size( ) == 64 => "double" . to_string( ) ,
85
- TypeKind :: Int ( Sign :: Signed ) => format!( "int{}_t" , self . results( ) . inner_size( ) ) ,
86
- TypeKind :: Int ( Sign :: Unsigned ) =>
87
- format!( "uint{}_t" , self . results( ) . inner_size( ) ) ,
88
- TypeKind :: Poly => format!( "poly{}_t" , self . results( ) . inner_size( ) ) ,
90
+ cast = match self . kind( ) {
91
+ TypeKind :: Float if self . inner_size( ) == 16 => "float16_t" . to_string( ) ,
92
+ TypeKind :: Float if self . inner_size( ) == 32 => "float" . to_string( ) ,
93
+ TypeKind :: Float if self . inner_size( ) == 64 => "double" . to_string( ) ,
94
+ TypeKind :: Int ( Sign :: Signed ) => format!( "int{}_t" , self . inner_size( ) ) ,
95
+ TypeKind :: Int ( Sign :: Unsigned ) => format!( "uint{}_t" , self . inner_size( ) ) ,
96
+ TypeKind :: Poly => format!( "poly{}_t" , self . inner_size( ) ) ,
89
97
ty => todo!( "print_result_c - Unknown type: {:#?}" , ty) ,
90
98
} ,
91
- promote = self . results ( ) . c_promotion( ) ,
99
+ promote = self . c_promotion( ) ,
92
100
)
93
101
} ;
94
102
95
103
format ! (
96
104
r#"{indentation}std::cout << "Result {additional}-" << i+1 << ": {ty}" << std::fixed << std::setprecision(150) << {lanes} << "{close}" << std::endl;"# ,
97
- ty = if self . results ( ) . is_simd( ) {
98
- format!( "{}(" , self . results ( ) . c_type( ) )
105
+ ty = if self . is_simd( ) {
106
+ format!( "{}(" , self . c_type( ) )
99
107
} else {
100
108
String :: from( "" )
101
109
} ,
102
- close = if self . results . is_simd( ) { ")" } else { "" } ,
110
+ close = if self . is_simd( ) { ")" } else { "" } ,
103
111
)
104
112
}
105
113
}
0 commit comments