@@ -5,19 +5,19 @@ mod intrinsic;
55mod json_parser;
66mod types;
77
8- use std:: fs:: { self , File } ;
8+ use std:: fs:: File ;
99
1010use rayon:: prelude:: * ;
1111
1212use crate :: common:: cli:: ProcessedCli ;
13+ use crate :: common:: compile_c:: CppCompilation ;
1314use crate :: common:: gen_c:: { write_main_cpp, write_mod_cpp} ;
1415use crate :: common:: gen_rust:: {
1516 compile_rust_programs, write_bin_cargo_toml, write_lib_cargo_toml, write_lib_rs, write_main_rs,
1617} ;
1718use crate :: common:: intrinsic:: Intrinsic ;
1819use crate :: common:: intrinsic_helpers:: TypeKind ;
1920use crate :: common:: { SupportedArchitectureTest , chunk_info} ;
20- use config:: { AARCH_CONFIGURATIONS , F16_FORMATTING_DEF , POLY128_OSTREAM_DEF , build_notices} ;
2121use intrinsic:: ArmIntrinsicType ;
2222use json_parser:: get_neon_intrinsics;
2323
@@ -65,24 +65,40 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
6565 }
6666 }
6767
68- const PLATFORM_HEADERS : & [ & str ] = & [ "arm_neon.h" , "arm_acle.h" , "arm_fp16.h" ] ;
68+ const NOTICE : & str = config:: NOTICE ;
69+
70+ const PLATFORM_C_HEADERS : & [ & str ] = & [ "arm_neon.h" , "arm_acle.h" , "arm_fp16.h" ] ;
71+ const PLATFORM_C_DEFINITIONS : & str = config:: POLY128_OSTREAM_DEF ;
72+
73+ const PLATFORM_RUST_DEFINITIONS : & str = config:: F16_FORMATTING_DEF ;
74+ const PLATFORM_RUST_CFGS : & str = config:: AARCH_CONFIGURATIONS ;
75+
76+ fn cpp_compilation ( & self ) -> Option < CppCompilation > {
77+ compile:: build_cpp_compilation ( & self . cli_options )
78+ }
6979
7080 fn build_c_file ( & self ) -> bool {
7181 let c_target = "aarch64" ;
7282
73- let ( chunk_size, chunk_count) = chunk_info ( self . intrinsics . len ( ) ) ;
83+ let ( chunk_size, chunk_count) = chunk_info ( self . intrinsics ( ) . len ( ) ) ;
7484
75- let cpp_compiler_wrapped = compile :: build_cpp_compilation ( & self . cli_options ) ;
85+ let cpp_compiler_wrapped = self . cpp_compilation ( ) ;
7686
77- let notice = & build_notices ( "// " ) ;
78- fs:: create_dir_all ( "c_programs" ) . unwrap ( ) ;
79- self . intrinsics
87+ std:: fs:: create_dir_all ( "c_programs" ) . unwrap ( ) ;
88+ self . intrinsics ( )
8089 . par_chunks ( chunk_size)
8190 . enumerate ( )
8291 . map ( |( i, chunk) | {
8392 let c_filename = format ! ( "c_programs/mod_{i}.cpp" ) ;
8493 let mut file = File :: create ( & c_filename) . unwrap ( ) ;
85- write_mod_cpp ( & mut file, notice, c_target, Self :: PLATFORM_HEADERS , chunk) . unwrap ( ) ;
94+ write_mod_cpp (
95+ & mut file,
96+ Self :: NOTICE ,
97+ c_target,
98+ Self :: PLATFORM_C_HEADERS ,
99+ chunk,
100+ )
101+ . unwrap ( ) ;
86102
87103 // compile this cpp file into a .o file.
88104 //
@@ -103,8 +119,8 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
103119 write_main_cpp (
104120 & mut file,
105121 c_target,
106- POLY128_OSTREAM_DEF ,
107- self . intrinsics . iter ( ) . map ( |i| i. name . as_str ( ) ) ,
122+ Self :: PLATFORM_C_DEFINITIONS ,
123+ self . intrinsics ( ) . iter ( ) . map ( |i| i. name . as_str ( ) ) ,
108124 )
109125 . unwrap ( ) ;
110126
@@ -149,7 +165,7 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
149165 write_main_rs (
150166 & mut main_rs,
151167 chunk_count,
152- AARCH_CONFIGURATIONS ,
168+ Self :: PLATFORM_RUST_CFGS ,
153169 "" ,
154170 self . intrinsics . iter ( ) . map ( |i| i. name . as_str ( ) ) ,
155171 )
@@ -159,7 +175,6 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
159175 let toolchain = self . cli_options . toolchain . as_deref ( ) ;
160176 let linker = self . cli_options . linker . as_deref ( ) ;
161177
162- let notice = & build_notices ( "// " ) ;
163178 self . intrinsics
164179 . par_chunks ( chunk_size)
165180 . enumerate ( )
@@ -170,9 +185,14 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
170185 trace ! ( "generating `{rust_filename}`" ) ;
171186 let mut file = File :: create ( rust_filename) ?;
172187
173- let cfg = AARCH_CONFIGURATIONS ;
174- let definitions = F16_FORMATTING_DEF ;
175- write_lib_rs ( & mut file, architecture, notice, cfg, definitions, chunk) ?;
188+ write_lib_rs (
189+ & mut file,
190+ architecture,
191+ Self :: NOTICE ,
192+ Self :: PLATFORM_RUST_CFGS ,
193+ Self :: PLATFORM_RUST_DEFINITIONS ,
194+ chunk,
195+ ) ?;
176196
177197 let toml_filename = format ! ( "rust_programs/mod_{i}/Cargo.toml" ) ;
178198 trace ! ( "generating `{toml_filename}`" ) ;
0 commit comments