@@ -150,7 +150,7 @@ impl std::convert::TryFrom<&'static str> for MsaIntrinsic {
150150
151151 let first_parentheses = line. find ( '(' ) ?;
152152 assert ! ( first_parentheses > first_whitespace) ;
153- let id = & line[ first_whitespace+ 1 ..first_parentheses] . trim ( ) ;
153+ let id = & line[ first_whitespace + 1 ..first_parentheses] . trim ( ) ;
154154 assert ! ( id. starts_with( "__builtin" ) ) ;
155155 let mut id_str = "_" . to_string ( ) ;
156156 id_str += & id[ 9 ..] ;
@@ -159,7 +159,7 @@ impl std::convert::TryFrom<&'static str> for MsaIntrinsic {
159159 let mut arg_tys = Vec :: new ( ) ;
160160
161161 let last_parentheses = line. find ( ')' ) ?;
162- for arg in ( & line[ first_parentheses+ 1 ..last_parentheses] ) . split ( ',' ) {
162+ for arg in ( & line[ first_parentheses + 1 ..last_parentheses] ) . split ( ',' ) {
163163 let arg = arg. trim ( ) ;
164164 arg_tys. push ( MsaTy :: from ( arg) ) ;
165165 }
@@ -169,19 +169,17 @@ impl std::convert::TryFrom<&'static str> for MsaIntrinsic {
169169 let mut instruction = instruction. to_string ( ) ;
170170 // With all underscores but the first one replaced with a `.`
171171 if let Some ( first_underscore) = instruction. find ( '_' ) {
172- let postfix = instruction[ first_underscore+ 1 ..] . replace ( '_' , "." ) ;
172+ let postfix = instruction[ first_underscore + 1 ..] . replace ( '_' , "." ) ;
173173 instruction = instruction[ 0 ..=first_underscore] . to_string ( ) ;
174174 instruction += & postfix;
175175 }
176176
177- Ok (
178- MsaIntrinsic {
179- id,
180- ret_ty,
181- arg_tys,
182- instruction,
183- }
184- )
177+ Ok ( MsaIntrinsic {
178+ id,
179+ ret_ty,
180+ arg_tys,
181+ instruction,
182+ } )
185183 }
186184}
187185
@@ -195,9 +193,8 @@ fn verify_all_signatures() {
195193 }
196194
197195 use std:: convert:: TryFrom ;
198- let intrinsic: MsaIntrinsic = TryFrom :: try_from ( line) . expect (
199- & format ! ( "failed to parse line: \" {}\" " , line)
200- ) ;
196+ let intrinsic: MsaIntrinsic =
197+ TryFrom :: try_from ( line) . expect ( & format ! ( "failed to parse line: \" {}\" " , line) ) ;
201198 assert ! ( !intrinsics. contains_key( & intrinsic. id) ) ;
202199 intrinsics. insert ( intrinsic. id . clone ( ) , intrinsic) ;
203200 }
@@ -244,67 +241,69 @@ fn matches(rust: &Function, mips: &MsaIntrinsic) -> Result<(), String> {
244241 }
245242
246243 let mut nconst = 0 ;
247- for ( i, ( rust_arg, mips_arg) )
248- in rust. arguments . iter ( ) . zip ( mips. arg_tys . iter ( ) ) . enumerate ( ) {
249- match mips_arg {
250- MsaTy :: v16i8 if * * rust_arg == v16i8 => ( ) ,
251- MsaTy :: v8i16 if * * rust_arg == v8i16 => ( ) ,
252- MsaTy :: v4i32 if * * rust_arg == v4i32 => ( ) ,
253- MsaTy :: v2i64 if * * rust_arg == v2i64 => ( ) ,
254- MsaTy :: v16u8 if * * rust_arg == v16u8 => ( ) ,
255- MsaTy :: v8u16 if * * rust_arg == v8u16 => ( ) ,
256- MsaTy :: v4u32 if * * rust_arg == v4u32 => ( ) ,
257- MsaTy :: v2u64 if * * rust_arg == v2u64 => ( ) ,
258- MsaTy :: v4f32 if * * rust_arg == v4f32 => ( ) ,
259- MsaTy :: v2f64 if * * rust_arg == v2f64 => ( ) ,
260- MsaTy :: imm0_1 |
261- MsaTy :: imm0_3 |
262- MsaTy :: imm0_7 |
263- MsaTy :: imm0_15 |
264- MsaTy :: imm0_31 |
265- MsaTy :: imm0_63 |
266- MsaTy :: imm0_255 |
267- MsaTy :: imm_n16_15 |
268- MsaTy :: imm_n512_511 |
269- MsaTy :: imm_n1024_1022 |
270- MsaTy :: imm_n2048_2044 |
271- MsaTy :: imm_n4096_4088
272- if * * rust_arg == I32 => ( ) ,
273- MsaTy :: i32 if * * rust_arg == I32 => ( ) ,
274- MsaTy :: i64 if * * rust_arg == I64 => ( ) ,
275- MsaTy :: u32 if * * rust_arg == U32 => ( ) ,
276- MsaTy :: u64 if * * rust_arg == U64 => ( ) ,
277- MsaTy :: VoidPtr if * * rust_arg == Type :: Ptr ( & U8 ) => ( ) ,
278- m => {
279- bail ! (
280- "mismatched argument \" {}\" = \" {:?}\" != \" {:?}\" " ,
281- i, m, * rust_arg
282- )
283- }
244+ for ( i, ( rust_arg, mips_arg) ) in rust. arguments . iter ( ) . zip ( mips. arg_tys . iter ( ) ) . enumerate ( ) {
245+ match mips_arg {
246+ MsaTy :: v16i8 if * * rust_arg == v16i8 => ( ) ,
247+ MsaTy :: v8i16 if * * rust_arg == v8i16 => ( ) ,
248+ MsaTy :: v4i32 if * * rust_arg == v4i32 => ( ) ,
249+ MsaTy :: v2i64 if * * rust_arg == v2i64 => ( ) ,
250+ MsaTy :: v16u8 if * * rust_arg == v16u8 => ( ) ,
251+ MsaTy :: v8u16 if * * rust_arg == v8u16 => ( ) ,
252+ MsaTy :: v4u32 if * * rust_arg == v4u32 => ( ) ,
253+ MsaTy :: v2u64 if * * rust_arg == v2u64 => ( ) ,
254+ MsaTy :: v4f32 if * * rust_arg == v4f32 => ( ) ,
255+ MsaTy :: v2f64 if * * rust_arg == v2f64 => ( ) ,
256+ MsaTy :: imm0_1
257+ | MsaTy :: imm0_3
258+ | MsaTy :: imm0_7
259+ | MsaTy :: imm0_15
260+ | MsaTy :: imm0_31
261+ | MsaTy :: imm0_63
262+ | MsaTy :: imm0_255
263+ | MsaTy :: imm_n16_15
264+ | MsaTy :: imm_n512_511
265+ | MsaTy :: imm_n1024_1022
266+ | MsaTy :: imm_n2048_2044
267+ | MsaTy :: imm_n4096_4088
268+ if * * rust_arg == I32 =>
269+ {
270+ ( )
284271 }
272+ MsaTy :: i32 if * * rust_arg == I32 => ( ) ,
273+ MsaTy :: i64 if * * rust_arg == I64 => ( ) ,
274+ MsaTy :: u32 if * * rust_arg == U32 => ( ) ,
275+ MsaTy :: u64 if * * rust_arg == U64 => ( ) ,
276+ MsaTy :: VoidPtr if * * rust_arg == Type :: Ptr ( & U8 ) => ( ) ,
277+ m => bail ! (
278+ "mismatched argument \" {}\" = \" {:?}\" != \" {:?}\" " ,
279+ i,
280+ m,
281+ * rust_arg
282+ ) ,
283+ }
285284
286- let is_const = match mips_arg {
287- MsaTy :: imm0_1 |
288- MsaTy :: imm0_3 |
289- MsaTy :: imm0_7 |
290- MsaTy :: imm0_15 |
291- MsaTy :: imm0_31 |
292- MsaTy :: imm0_63 |
293- MsaTy :: imm0_255 |
294- MsaTy :: imm_n16_15 |
295- MsaTy :: imm_n512_511 |
296- MsaTy :: imm_n1024_1022 |
297- MsaTy :: imm_n2048_2044 |
298- MsaTy :: imm_n4096_4088 => true ,
299- _ => false ,
300- } ;
301- if is_const {
302- nconst += 1 ;
303- if !rust. required_const . contains ( & i) {
304- bail ! ( "argument const mismatch" ) ;
305- }
285+ let is_const = match mips_arg {
286+ MsaTy :: imm0_1
287+ | MsaTy :: imm0_3
288+ | MsaTy :: imm0_7
289+ | MsaTy :: imm0_15
290+ | MsaTy :: imm0_31
291+ | MsaTy :: imm0_63
292+ | MsaTy :: imm0_255
293+ | MsaTy :: imm_n16_15
294+ | MsaTy :: imm_n512_511
295+ | MsaTy :: imm_n1024_1022
296+ | MsaTy :: imm_n2048_2044
297+ | MsaTy :: imm_n4096_4088 => true ,
298+ _ => false ,
299+ } ;
300+ if is_const {
301+ nconst += 1 ;
302+ if !rust. required_const . contains ( & i) {
303+ bail ! ( "argument const mismatch" ) ;
306304 }
307305 }
306+ }
308307
309308 if nconst != rust. required_const . len ( ) {
310309 bail ! ( "wrong number of const arguments" ) ;
0 commit comments