@@ -5,19 +5,19 @@ mod intrinsic;
5
5
mod json_parser;
6
6
mod types;
7
7
8
- use std:: fs:: { self , File } ;
8
+ use std:: fs:: File ;
9
9
10
10
use rayon:: prelude:: * ;
11
11
12
12
use crate :: common:: cli:: ProcessedCli ;
13
+ use crate :: common:: compile_c:: CppCompilation ;
13
14
use crate :: common:: gen_c:: { write_main_cpp, write_mod_cpp} ;
14
15
use crate :: common:: gen_rust:: {
15
16
compile_rust_programs, write_bin_cargo_toml, write_lib_cargo_toml, write_lib_rs, write_main_rs,
16
17
} ;
17
18
use crate :: common:: intrinsic:: Intrinsic ;
18
19
use crate :: common:: intrinsic_helpers:: TypeKind ;
19
20
use crate :: common:: { SupportedArchitectureTest , chunk_info} ;
20
- use config:: { AARCH_CONFIGURATIONS , F16_FORMATTING_DEF , POLY128_OSTREAM_DEF , build_notices} ;
21
21
use intrinsic:: ArmIntrinsicType ;
22
22
use json_parser:: get_neon_intrinsics;
23
23
@@ -65,24 +65,40 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
65
65
}
66
66
}
67
67
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
+ }
69
79
70
80
fn build_c_file ( & self ) -> bool {
71
81
let c_target = "aarch64" ;
72
82
73
- let ( chunk_size, chunk_count) = chunk_info ( self . intrinsics . len ( ) ) ;
83
+ let ( chunk_size, chunk_count) = chunk_info ( self . intrinsics ( ) . len ( ) ) ;
74
84
75
- let cpp_compiler_wrapped = compile :: build_cpp_compilation ( & self . cli_options ) ;
85
+ let cpp_compiler_wrapped = self . cpp_compilation ( ) ;
76
86
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 ( )
80
89
. par_chunks ( chunk_size)
81
90
. enumerate ( )
82
91
. map ( |( i, chunk) | {
83
92
let c_filename = format ! ( "c_programs/mod_{i}.cpp" ) ;
84
93
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 ( ) ;
86
102
87
103
// compile this cpp file into a .o file.
88
104
//
@@ -103,8 +119,8 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
103
119
write_main_cpp (
104
120
& mut file,
105
121
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 ( ) ) ,
108
124
)
109
125
. unwrap ( ) ;
110
126
@@ -149,7 +165,7 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
149
165
write_main_rs (
150
166
& mut main_rs,
151
167
chunk_count,
152
- AARCH_CONFIGURATIONS ,
168
+ Self :: PLATFORM_RUST_CFGS ,
153
169
"" ,
154
170
self . intrinsics . iter ( ) . map ( |i| i. name . as_str ( ) ) ,
155
171
)
@@ -159,7 +175,6 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
159
175
let toolchain = self . cli_options . toolchain . as_deref ( ) ;
160
176
let linker = self . cli_options . linker . as_deref ( ) ;
161
177
162
- let notice = & build_notices ( "// " ) ;
163
178
self . intrinsics
164
179
. par_chunks ( chunk_size)
165
180
. enumerate ( )
@@ -170,9 +185,14 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
170
185
trace ! ( "generating `{rust_filename}`" ) ;
171
186
let mut file = File :: create ( rust_filename) ?;
172
187
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
+ ) ?;
176
196
177
197
let toml_filename = format ! ( "rust_programs/mod_{i}/Cargo.toml" ) ;
178
198
trace ! ( "generating `{toml_filename}`" ) ;
0 commit comments