@@ -61,7 +61,7 @@ fn neon_get_base_and_char(ty: &VectorType) -> (u32, char, bool) {
6161 BaseType :: Sized ( BaseTypeKind :: Int , size) => ( * size, 's' , * size * lanes == 128 ) ,
6262 BaseType :: Sized ( BaseTypeKind :: UInt , size) => ( * size, 'u' , * size * lanes == 128 ) ,
6363 BaseType :: Sized ( BaseTypeKind :: Poly , size) => ( * size, 'p' , * size * lanes == 128 ) ,
64- _ => panic ! ( "Unhandled {:?}" , ty ) ,
64+ _ => panic ! ( "Unhandled {ty :?}" ) ,
6565 }
6666}
6767
@@ -73,169 +73,92 @@ pub fn make_neon_suffix(type_kind: TypeKind, suffix_kind: SuffixKind) -> String
7373 TypeKind :: Vector ( ty) => {
7474 let tuple_size = ty. tuple_size ( ) . map_or ( 0 , |t| t. to_int ( ) ) ;
7575 let ( base_size, prefix_char, requires_q) = neon_get_base_and_char ( & ty) ;
76+ let prefix_q = if requires_q { "q" } else { "" } ;
7677 let lanes = ty. lanes ( ) ;
7778 match suffix_kind {
7879 SuffixKind :: Normal => {
79- let mut str_suffix: String = String :: new ( ) ;
80- if requires_q {
81- str_suffix. push ( 'q' ) ;
82- }
83- str_suffix. push ( '_' ) ;
84- str_suffix. push ( prefix_char) ;
85- str_suffix. push_str ( base_size. to_string ( ) . as_str ( ) ) ;
80+ let mut str_suffix: String = format ! ( "{prefix_q}_{prefix_char}{base_size}" ) ;
8681 if tuple_size > 0 {
8782 str_suffix. push_str ( "_x" ) ;
8883 str_suffix. push_str ( tuple_size. to_string ( ) . as_str ( ) ) ;
8984 }
90- return str_suffix;
85+ str_suffix
9186 }
9287 SuffixKind :: NSuffix => {
93- let mut str_suffix: String = String :: new ( ) ;
94- if requires_q {
95- str_suffix. push ( 'q' ) ;
96- }
97- str_suffix. push_str ( "_n_" ) ;
98- str_suffix. push ( prefix_char) ;
99- str_suffix. push_str ( base_size. to_string ( ) . as_str ( ) ) ;
100- return str_suffix;
88+ format ! ( "{prefix_q}_n_{prefix_char}{base_size}" )
10189 }
10290
103- SuffixKind :: NoQ => format ! ( "_{}{}" , prefix_char , base_size ) ,
104- SuffixKind :: NoQNSuffix => format ! ( "_n{}{}" , prefix_char , base_size ) ,
91+ SuffixKind :: NoQ => format ! ( "_{prefix_char}{base_size}" ) ,
92+ SuffixKind :: NoQNSuffix => format ! ( "_n{prefix_char}{base_size}" ) ,
10593
10694 SuffixKind :: Unsigned => {
10795 let t = type_kind. to_string ( ) ;
10896 if t. starts_with ( "u" ) {
10997 return t;
11098 }
111- return format ! ( "u{}" , t ) ;
99+ format ! ( "u{t}" )
112100 }
113101 SuffixKind :: Lane => {
114102 if lanes == 0 {
115- panic ! ( "type {} has no lanes!" , type_kind . to_string ( ) )
103+ panic ! ( "type {type_kind } has no lanes!" )
116104 } else {
117- format ! ( "{}" , lanes )
105+ format ! ( "{lanes}" )
118106 }
119107 }
120108 SuffixKind :: Tuple => {
121109 if tuple_size == 0 {
122- panic ! ( "type {} has no lanes!" , type_kind . to_string ( ) )
110+ panic ! ( "type {type_kind } has no lanes!" )
123111 } else {
124- format ! ( "{}" , tuple_size )
112+ format ! ( "{tuple_size}" )
125113 }
126114 }
127115 SuffixKind :: Base => base_size. to_string ( ) ,
128116 SuffixKind :: NoX => {
129- let mut str_suffix: String = String :: new ( ) ;
130- if requires_q {
131- str_suffix. push ( 'q' ) ;
132- }
133- str_suffix. push ( '_' ) ;
134- str_suffix. push ( prefix_char) ;
135- str_suffix. push_str ( base_size. to_string ( ) . as_str ( ) ) ;
136- return str_suffix;
117+ format ! ( "{prefix_q}_{prefix_char}{base_size}" )
137118 }
138119 SuffixKind :: Dup => {
139- let mut str_suffix: String = String :: new ( ) ;
140- if requires_q {
141- str_suffix. push ( 'q' ) ;
142- }
143- str_suffix. push ( '_' ) ;
144- str_suffix. push_str ( "dup_" ) ;
145- str_suffix. push ( prefix_char) ;
146- str_suffix. push_str ( base_size. to_string ( ) . as_str ( ) ) ;
120+ let mut str_suffix: String = format ! ( "{prefix_q}_dup_{prefix_char}{base_size}" ) ;
147121 if tuple_size > 0 {
148122 str_suffix. push_str ( "_x" ) ;
149123 str_suffix. push_str ( tuple_size. to_string ( ) . as_str ( ) ) ;
150124 }
151- return str_suffix;
125+ str_suffix
152126 }
153127 SuffixKind :: DupNox => {
154- let mut str_suffix: String = String :: new ( ) ;
155- if requires_q {
156- str_suffix. push ( 'q' ) ;
157- }
158- str_suffix. push ( '_' ) ;
159- str_suffix. push_str ( "dup_" ) ;
160- str_suffix. push ( prefix_char) ;
161- str_suffix. push_str ( base_size. to_string ( ) . as_str ( ) ) ;
162- return str_suffix;
128+ format ! ( "{prefix_q}_dup_{prefix_char}{base_size}" )
163129 }
164130 SuffixKind :: LaneNoX => {
165- let mut str_suffix: String = String :: new ( ) ;
166- if requires_q {
167- str_suffix. push ( 'q' ) ;
168- }
169- str_suffix. push ( '_' ) ;
170- str_suffix. push_str ( "lane_" ) ;
171- str_suffix. push ( prefix_char) ;
172- str_suffix. push_str ( base_size. to_string ( ) . as_str ( ) ) ;
173- return str_suffix;
131+ format ! ( "{prefix_q}_lane_{prefix_char}{base_size}" )
174132 }
175133 SuffixKind :: LaneQNoX => {
176- let mut str_suffix: String = String :: new ( ) ;
177- if requires_q {
178- str_suffix. push ( 'q' ) ;
179- }
180- str_suffix. push ( '_' ) ;
181- str_suffix. push_str ( "laneq_" ) ;
182- str_suffix. push ( prefix_char) ;
183- str_suffix. push_str ( base_size. to_string ( ) . as_str ( ) ) ;
184- return str_suffix;
134+ format ! ( "{prefix_q}_laneq_{prefix_char}{base_size}" )
185135 }
186136 SuffixKind :: Rot270 => {
187- if requires_q {
188- return format ! ( "q_rot270_{}{}" , prefix_char, base_size. to_string( ) ) ;
189- }
190- return format ! ( "_rot270_{}{}" , prefix_char, base_size. to_string( ) ) ;
137+ format ! ( "{prefix_q}_rot270_{prefix_char}{base_size}" )
191138 }
192139 SuffixKind :: Rot270Lane => {
193- if requires_q {
194- return format ! ( "q_rot270_lane_{}{}" , prefix_char, base_size. to_string( ) ) ;
195- }
196- return format ! ( "_rot270_lane_{}{}" , prefix_char, base_size. to_string( ) ) ;
140+ format ! ( "{prefix_q}_rot270_lane_{prefix_char}{base_size}" )
197141 }
198142 SuffixKind :: Rot270LaneQ => {
199- if requires_q {
200- return format ! ( "q_rot270_laneq_{}{}" , prefix_char, base_size. to_string( ) ) ;
201- }
202- return format ! ( "_rot270_laneq_{}{}" , prefix_char, base_size. to_string( ) ) ;
143+ format ! ( "{prefix_q}_rot270_laneq_{prefix_char}{base_size}" )
203144 }
204145 SuffixKind :: Rot180 => {
205- if requires_q {
206- return format ! ( "q_rot180_{}{}" , prefix_char, base_size. to_string( ) ) ;
207- }
208- return format ! ( "_rot180_{}{}" , prefix_char, base_size. to_string( ) ) ;
146+ format ! ( "{prefix_q}_rot180_{prefix_char}{base_size}" )
209147 }
210148 SuffixKind :: Rot180Lane => {
211- if requires_q {
212- return format ! ( "q_rot180_lane_{}{}" , prefix_char, base_size. to_string( ) ) ;
213- }
214- return format ! ( "_rot180_lane_{}{}" , prefix_char, base_size. to_string( ) ) ;
149+ format ! ( "{prefix_q}_rot180_lane_{prefix_char}{base_size}" )
215150 }
216151 SuffixKind :: Rot180LaneQ => {
217- if requires_q {
218- return format ! ( "q_rot180_laneq_{}{}" , prefix_char, base_size. to_string( ) ) ;
219- }
220- return format ! ( "_rot180_laneq_{}{}" , prefix_char, base_size. to_string( ) ) ;
152+ format ! ( "{prefix_q}_rot180_laneq_{prefix_char}{base_size}" )
221153 }
222154 SuffixKind :: Rot90 => {
223- if requires_q {
224- return format ! ( "q_rot90_{}{}" , prefix_char, base_size. to_string( ) ) ;
225- }
226- return format ! ( "_rot90_{}{}" , prefix_char, base_size. to_string( ) ) ;
155+ format ! ( "{prefix_q}_rot90_{prefix_char}{base_size}" )
227156 }
228157 SuffixKind :: Rot90Lane => {
229- if requires_q {
230- return format ! ( "q_rot90_lane_{}{}" , prefix_char, base_size. to_string( ) ) ;
231- }
232- return format ! ( "_rot90_lane_{}{}" , prefix_char, base_size. to_string( ) ) ;
158+ format ! ( "{prefix_q}_rot90_lane_{prefix_char}{base_size}" )
233159 }
234160 SuffixKind :: Rot90LaneQ => {
235- if requires_q {
236- return format ! ( "q_rot90_laneq_{}{}" , prefix_char, base_size. to_string( ) ) ;
237- }
238- return format ! ( "_rot90_laneq_{}{}" , prefix_char, base_size. to_string( ) ) ;
161+ format ! ( "{prefix_q}_rot90_laneq_{prefix_char}{base_size}" )
239162 }
240163 SuffixKind :: BaseByteSize => format ! ( "{}" , base_size / 8 ) ,
241164 }
@@ -272,7 +195,7 @@ impl FromStr for SuffixKind {
272195 "base_byte_size" => Ok ( SuffixKind :: BaseByteSize ) ,
273196 "lane_nox" => Ok ( SuffixKind :: LaneNoX ) ,
274197 "laneq_nox" => Ok ( SuffixKind :: LaneQNoX ) ,
275- _ => Err ( format ! ( "unknown suffix type: {}" , s ) ) ,
198+ _ => Err ( format ! ( "unknown suffix type: {s}" ) ) ,
276199 }
277200 }
278201}
0 commit comments