@@ -23,7 +23,6 @@ extern crate rustc_target;
23
23
extern crate rustc_driver;
24
24
25
25
use std:: any:: Any ;
26
- use std:: str:: FromStr ;
27
26
28
27
use rustc_codegen_ssa:: traits:: CodegenBackend ;
29
28
use rustc_codegen_ssa:: CodegenResults ;
@@ -36,6 +35,7 @@ use rustc_session::Session;
36
35
37
36
use cranelift_codegen:: settings:: { self , Configurable } ;
38
37
38
+ pub use crate :: config:: * ;
39
39
use crate :: constant:: ConstantCx ;
40
40
use crate :: prelude:: * ;
41
41
@@ -49,6 +49,7 @@ mod cast;
49
49
mod codegen_i128;
50
50
mod common;
51
51
mod compiler_builtins;
52
+ mod config;
52
53
mod constant;
53
54
mod debuginfo;
54
55
mod discriminant;
@@ -161,53 +162,6 @@ impl<'m, 'tcx> CodegenCx<'m, 'tcx> {
161
162
}
162
163
}
163
164
164
- #[ derive( Copy , Clone , Debug ) ]
165
- pub enum CodegenMode {
166
- Aot ,
167
- Jit ,
168
- JitLazy ,
169
- }
170
-
171
- impl Default for CodegenMode {
172
- fn default ( ) -> Self {
173
- CodegenMode :: Aot
174
- }
175
- }
176
-
177
- impl FromStr for CodegenMode {
178
- type Err = String ;
179
-
180
- fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
181
- match s {
182
- "aot" => Ok ( CodegenMode :: Aot ) ,
183
- "jit" => Ok ( CodegenMode :: Jit ) ,
184
- "jit-lazy" => Ok ( CodegenMode :: JitLazy ) ,
185
- _ => Err ( format ! ( "Unknown codegen mode `{}`" , s) ) ,
186
- }
187
- }
188
- }
189
-
190
- #[ derive( Copy , Clone , Debug , Default ) ]
191
- pub struct BackendConfig {
192
- pub codegen_mode : CodegenMode ,
193
- }
194
-
195
- impl BackendConfig {
196
- fn from_opts ( opts : & [ String ] ) -> Result < Self , String > {
197
- let mut config = BackendConfig :: default ( ) ;
198
- for opt in opts {
199
- if let Some ( ( name, value) ) = opt. split_once ( '=' ) {
200
- match name {
201
- "mode" => config. codegen_mode = value. parse ( ) ?,
202
- _ => return Err ( format ! ( "Unknown option `{}`" , name) ) ,
203
- }
204
- } else {
205
- return Err ( format ! ( "Invalid option `{}`" , opt) ) ;
206
- }
207
- }
208
- Ok ( config)
209
- }
210
- }
211
165
212
166
pub struct CraneliftCodegenBackend {
213
167
pub config : Option < BackendConfig > ,
0 commit comments