@@ -61,7 +61,7 @@ fn neon_get_base_and_char(ty: &VectorType) -> (u32, char, bool) {
61
61
BaseType :: Sized ( BaseTypeKind :: Int , size) => ( * size, 's' , * size * lanes == 128 ) ,
62
62
BaseType :: Sized ( BaseTypeKind :: UInt , size) => ( * size, 'u' , * size * lanes == 128 ) ,
63
63
BaseType :: Sized ( BaseTypeKind :: Poly , size) => ( * size, 'p' , * size * lanes == 128 ) ,
64
- _ => panic ! ( "Unhandled {:?}" , ty ) ,
64
+ _ => panic ! ( "Unhandled {ty :?}" ) ,
65
65
}
66
66
}
67
67
@@ -73,169 +73,92 @@ pub fn make_neon_suffix(type_kind: TypeKind, suffix_kind: SuffixKind) -> String
73
73
TypeKind :: Vector ( ty) => {
74
74
let tuple_size = ty. tuple_size ( ) . map_or ( 0 , |t| t. to_int ( ) ) ;
75
75
let ( base_size, prefix_char, requires_q) = neon_get_base_and_char ( & ty) ;
76
+ let prefix_q = if requires_q { "q" } else { "" } ;
76
77
let lanes = ty. lanes ( ) ;
77
78
match suffix_kind {
78
79
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}" ) ;
86
81
if tuple_size > 0 {
87
82
str_suffix. push_str ( "_x" ) ;
88
83
str_suffix. push_str ( tuple_size. to_string ( ) . as_str ( ) ) ;
89
84
}
90
- return str_suffix;
85
+ str_suffix
91
86
}
92
87
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}" )
101
89
}
102
90
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}" ) ,
105
93
106
94
SuffixKind :: Unsigned => {
107
95
let t = type_kind. to_string ( ) ;
108
96
if t. starts_with ( "u" ) {
109
97
return t;
110
98
}
111
- return format ! ( "u{}" , t ) ;
99
+ format ! ( "u{t}" )
112
100
}
113
101
SuffixKind :: Lane => {
114
102
if lanes == 0 {
115
- panic ! ( "type {} has no lanes!" , type_kind . to_string ( ) )
103
+ panic ! ( "type {type_kind } has no lanes!" )
116
104
} else {
117
- format ! ( "{}" , lanes )
105
+ format ! ( "{lanes}" )
118
106
}
119
107
}
120
108
SuffixKind :: Tuple => {
121
109
if tuple_size == 0 {
122
- panic ! ( "type {} has no lanes!" , type_kind . to_string ( ) )
110
+ panic ! ( "type {type_kind } has no lanes!" )
123
111
} else {
124
- format ! ( "{}" , tuple_size )
112
+ format ! ( "{tuple_size}" )
125
113
}
126
114
}
127
115
SuffixKind :: Base => base_size. to_string ( ) ,
128
116
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}" )
137
118
}
138
119
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}" ) ;
147
121
if tuple_size > 0 {
148
122
str_suffix. push_str ( "_x" ) ;
149
123
str_suffix. push_str ( tuple_size. to_string ( ) . as_str ( ) ) ;
150
124
}
151
- return str_suffix;
125
+ str_suffix
152
126
}
153
127
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}" )
163
129
}
164
130
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}" )
174
132
}
175
133
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}" )
185
135
}
186
136
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}" )
191
138
}
192
139
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}" )
197
141
}
198
142
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}" )
203
144
}
204
145
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}" )
209
147
}
210
148
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}" )
215
150
}
216
151
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}" )
221
153
}
222
154
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}" )
227
156
}
228
157
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}" )
233
159
}
234
160
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}" )
239
162
}
240
163
SuffixKind :: BaseByteSize => format ! ( "{}" , base_size / 8 ) ,
241
164
}
@@ -272,7 +195,7 @@ impl FromStr for SuffixKind {
272
195
"base_byte_size" => Ok ( SuffixKind :: BaseByteSize ) ,
273
196
"lane_nox" => Ok ( SuffixKind :: LaneNoX ) ,
274
197
"laneq_nox" => Ok ( SuffixKind :: LaneQNoX ) ,
275
- _ => Err ( format ! ( "unknown suffix type: {}" , s ) ) ,
198
+ _ => Err ( format ! ( "unknown suffix type: {s}" ) ) ,
276
199
}
277
200
}
278
201
}
0 commit comments