11use super :: intrinsic:: ArmIntrinsicType ;
2- use crate :: common:: cli:: Language ;
3- use crate :: common:: indentation:: Indentation ;
42use crate :: common:: intrinsic_helpers:: { IntrinsicType , IntrinsicTypeDefinition , Sign , TypeKind } ;
53
64impl IntrinsicTypeDefinition for ArmIntrinsicType {
@@ -20,19 +18,8 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
2018 }
2119 }
2220
23- fn c_single_vector_type ( & self ) -> String {
24- if let ( Some ( bit_len) , Some ( simd_len) ) = ( self . bit_len , self . simd_len ) {
25- format ! (
26- "{prefix}{bit_len}x{simd_len}_t" ,
27- prefix = self . kind. c_prefix( )
28- )
29- } else {
30- unreachable ! ( "Shouldn't be called on this type" )
31- }
32- }
33-
3421 /// Determines the load function for this type.
35- fn get_load_function ( & self , language : Language ) -> String {
22+ fn get_load_function ( & self ) -> String {
3623 if let IntrinsicType {
3724 kind : k,
3825 bit_len : Some ( bl) ,
@@ -47,16 +34,13 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
4734 ""
4835 } ;
4936
50- let choose_workaround = language == Language :: C && self . target . contains ( "v7" ) ;
5137 format ! (
5238 "vld{len}{quad}_{type}{size}" ,
5339 type = match k {
5440 TypeKind :: Int ( Sign :: Unsigned ) => "u" ,
5541 TypeKind :: Int ( Sign :: Signed ) => "s" ,
5642 TypeKind :: Float => "f" ,
57- // The ACLE doesn't support 64-bit polynomial loads on Armv7
58- // if armv7 and bl == 64, use "s", else "p"
59- TypeKind :: Poly => if choose_workaround && * bl == 64 { "s" } else { "p" } ,
43+ TypeKind :: Poly => "p" ,
6044 x => todo!( "get_load_function TypeKind: {x:#?}" ) ,
6145 } ,
6246 size = bl,
@@ -67,97 +51,6 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
6751 todo ! ( "get_load_function IntrinsicType: {self:#?}" )
6852 }
6953 }
70-
71- /// Determines the get lane function for this type.
72- fn get_lane_function ( & self ) -> String {
73- if let IntrinsicType {
74- kind : k,
75- bit_len : Some ( bl) ,
76- simd_len,
77- ..
78- } = & self . data
79- {
80- let quad = if ( simd_len. unwrap_or ( 1 ) * bl) > 64 {
81- "q"
82- } else {
83- ""
84- } ;
85- format ! (
86- "vget{quad}_lane_{type}{size}" ,
87- type = match k {
88- TypeKind :: Int ( Sign :: Unsigned ) => "u" ,
89- TypeKind :: Int ( Sign :: Signed ) => "s" ,
90- TypeKind :: Float => "f" ,
91- TypeKind :: Poly => "p" ,
92- x => todo!( "get_load_function TypeKind: {x:#?}" ) ,
93- } ,
94- size = bl,
95- quad = quad,
96- )
97- } else {
98- todo ! ( "get_lane_function IntrinsicType: {self:#?}" )
99- }
100- }
101-
102- /// Generates a std::cout for the intrinsics results that will match the
103- /// rust debug output format for the return type. The generated line assumes
104- /// there is an int i in scope which is the current pass number.
105- fn print_result_c ( & self , indentation : Indentation , additional : & str ) -> String {
106- let lanes = if self . num_vectors ( ) > 1 {
107- ( 0 ..self . num_vectors ( ) )
108- . map ( |vector| {
109- format ! (
110- r#""{ty}(" << {lanes} << ")""# ,
111- ty = self . c_single_vector_type( ) ,
112- lanes = ( 0 ..self . num_lanes( ) )
113- . map( move |idx| -> std:: string:: String {
114- let lane_fn = self . get_lane_function( ) ;
115- let final_cast = self . generate_final_type_cast( ) ;
116- format!(
117- "{final_cast}{lane_fn}(__return_value.val[{vector}], {idx})"
118- )
119- } )
120- . collect:: <Vec <_>>( )
121- . join( r#" << ", " << "# )
122- )
123- } )
124- . collect :: < Vec < _ > > ( )
125- . join ( r#" << ", " << "# )
126- } else if self . num_lanes ( ) > 1 {
127- ( 0 ..self . num_lanes ( ) )
128- . map ( |idx| -> std:: string:: String {
129- let lane_fn = self . get_lane_function ( ) ;
130- let final_cast = self . generate_final_type_cast ( ) ;
131- format ! ( "{final_cast}{lane_fn}(__return_value, {idx})" )
132- } )
133- . collect :: < Vec < _ > > ( )
134- . join ( r#" << ", " << "# )
135- } else {
136- format ! (
137- "{promote}cast<{cast}>(__return_value)" ,
138- cast = match self . kind( ) {
139- TypeKind :: Float if self . inner_size( ) == 16 => "float16_t" . to_string( ) ,
140- TypeKind :: Float if self . inner_size( ) == 32 => "float" . to_string( ) ,
141- TypeKind :: Float if self . inner_size( ) == 64 => "double" . to_string( ) ,
142- TypeKind :: Int ( Sign :: Signed ) => format!( "int{}_t" , self . inner_size( ) ) ,
143- TypeKind :: Int ( Sign :: Unsigned ) => format!( "uint{}_t" , self . inner_size( ) ) ,
144- TypeKind :: Poly => format!( "poly{}_t" , self . inner_size( ) ) ,
145- ty => todo!( "print_result_c - Unknown type: {ty:#?}" ) ,
146- } ,
147- promote = self . generate_final_type_cast( ) ,
148- )
149- } ;
150-
151- format ! (
152- r#"{indentation}std::cout << "Result {additional}-" << i+1 << ": {ty}" << std::fixed << std::setprecision(150) << {lanes} << "{close}" << std::endl;"# ,
153- ty = if self . is_simd( ) {
154- format!( "{}(" , self . c_type( ) )
155- } else {
156- String :: from( "" )
157- } ,
158- close = if self . is_simd( ) { ")" } else { "" } ,
159- )
160- }
16154}
16255
16356impl ArmIntrinsicType {
0 commit comments