@@ -232,7 +232,7 @@ fn build_notices(line_prefix: &str) -> String {
232
232
)
233
233
}
234
234
235
- fn build_c ( notices : & str , intrinsics : & Vec < Intrinsic > , compiler : & str , a32 : bool ) -> bool {
235
+ fn build_c ( notices : & str , intrinsics : & Vec < Intrinsic > , compiler : Option < & str > , a32 : bool ) -> bool {
236
236
let _ = std:: fs:: create_dir ( "c_programs" ) ;
237
237
intrinsics
238
238
. par_iter ( )
@@ -242,13 +242,16 @@ fn build_c(notices: &str, intrinsics: &Vec<Intrinsic>, compiler: &str, a32: bool
242
242
243
243
let c_code = generate_c_program ( notices, & [ "arm_neon.h" , "arm_acle.h" ] , & i, a32) ;
244
244
file. write_all ( c_code. into_bytes ( ) . as_slice ( ) ) . unwrap ( ) ;
245
- compile_c ( & c_filename, & i, compiler, a32)
245
+ match compiler {
246
+ None => true ,
247
+ Some ( compiler) => compile_c ( & c_filename, & i, compiler, a32) ,
248
+ }
246
249
} )
247
250
. find_any ( |x| !x)
248
251
. is_none ( )
249
252
}
250
253
251
- fn build_rust ( notices : & str , intrinsics : & [ Intrinsic ] , toolchain : & str , a32 : bool ) -> bool {
254
+ fn build_rust ( notices : & str , intrinsics : & [ Intrinsic ] , toolchain : Option < & str > , a32 : bool ) -> bool {
252
255
intrinsics. iter ( ) . for_each ( |i| {
253
256
let rust_dir = format ! ( r#"rust_programs/{}"# , i. name) ;
254
257
let _ = std:: fs:: create_dir_all ( & rust_dir) ;
@@ -296,6 +299,11 @@ path = "{intrinsic}/main.rs""#,
296
299
)
297
300
. unwrap ( ) ;
298
301
302
+ let toolchain = match toolchain {
303
+ None => return true ,
304
+ Some ( t) => t,
305
+ } ;
306
+
299
307
let output = Command :: new ( "sh" )
300
308
. current_dir ( "rust_programs" )
301
309
. arg ( "-c" )
@@ -356,6 +364,10 @@ struct Cli {
356
364
/// Run tests for A32 instrinsics instead of A64
357
365
#[ arg( long) ]
358
366
a32 : bool ,
367
+
368
+ /// Regenerate test programs, but don't build or run them
369
+ #[ arg( long) ]
370
+ generate_only : bool ,
359
371
}
360
372
361
373
fn main ( ) {
@@ -364,8 +376,6 @@ fn main() {
364
376
let args: Cli = clap:: Parser :: parse ( ) ;
365
377
366
378
let filename = args. input ;
367
- let toolchain = args. toolchain . map_or_else ( String :: new, |t| format ! ( "+{t}" ) ) ;
368
- let cpp_compiler = args. cppcompiler ;
369
379
let c_runner = args. runner . unwrap_or_else ( String :: new) ;
370
380
let skip = if let Some ( filename) = args. skip {
371
381
let data = std:: fs:: read_to_string ( & filename) . expect ( "Failed to open file" ) ;
@@ -403,18 +413,29 @@ fn main() {
403
413
. collect :: < Vec < _ > > ( ) ;
404
414
intrinsics. dedup ( ) ;
405
415
416
+ let ( toolchain, cpp_compiler) = if args. generate_only {
417
+ ( None , None )
418
+ } else {
419
+ (
420
+ Some ( args. toolchain . map_or_else ( String :: new, |t| format ! ( "+{t}" ) ) ) ,
421
+ Some ( args. cppcompiler ) ,
422
+ )
423
+ } ;
424
+
406
425
let notices = build_notices ( "// " ) ;
407
426
408
- if !build_c ( & notices, & intrinsics, & cpp_compiler, a32) {
427
+ if !build_c ( & notices, & intrinsics, cpp_compiler. as_deref ( ) , a32) {
409
428
std:: process:: exit ( 2 ) ;
410
429
}
411
430
412
- if !build_rust ( & notices, & intrinsics, & toolchain, a32) {
431
+ if !build_rust ( & notices, & intrinsics, toolchain. as_deref ( ) , a32) {
413
432
std:: process:: exit ( 3 ) ;
414
433
}
415
434
416
- if !compare_outputs ( & intrinsics, & toolchain, & c_runner, a32) {
417
- std:: process:: exit ( 1 )
435
+ if let Some ( ref toolchain) = toolchain {
436
+ if !compare_outputs ( & intrinsics, toolchain, & c_runner, a32) {
437
+ std:: process:: exit ( 1 )
438
+ }
418
439
}
419
440
}
420
441
0 commit comments