@@ -34,15 +34,16 @@ use rustc_incremental;
34
34
use rustc_resolve:: { MakeGlobMap , Resolver } ;
35
35
use rustc_metadata:: creader:: CrateLoader ;
36
36
use rustc_metadata:: cstore:: { self , CStore } ;
37
- use rustc_trans:: back:: write;
38
37
use rustc_trans as trans;
38
+ use rustc_trans_traits:: TransCrate ;
39
39
use rustc_typeck as typeck;
40
40
use rustc_privacy;
41
41
use rustc_plugin:: registry:: Registry ;
42
42
use rustc_plugin as plugin;
43
43
use rustc_passes:: { ast_validation, no_asm, loops, consts, static_recursion, hir_stats} ;
44
44
use rustc_const_eval:: { self , check_match} ;
45
45
use super :: Compilation ;
46
+ use :: DefaultTransCrate ;
46
47
47
48
use serialize:: json;
48
49
@@ -76,7 +77,6 @@ pub fn compile_input(sess: &Session,
76
77
output : & Option < PathBuf > ,
77
78
addl_plugins : Option < Vec < String > > ,
78
79
control : & CompileController ) -> CompileResult {
79
- use rustc_trans:: back:: write:: OngoingCrateTranslation ;
80
80
use rustc:: session:: config:: CrateType ;
81
81
82
82
macro_rules! controller_entry_point {
@@ -122,7 +122,7 @@ pub fn compile_input(sess: &Session,
122
122
// We need nested scopes here, because the intermediate results can keep
123
123
// large chunks of memory alive and we want to free them as soon as
124
124
// possible to keep the peak memory usage low
125
- let ( outputs, trans, dep_graph) : ( OutputFilenames , OngoingCrateTranslation , DepGraph ) = {
125
+ let ( outputs, trans, dep_graph) = {
126
126
let krate = match phase_1_parse_input ( control, sess, input) {
127
127
Ok ( krate) => krate,
128
128
Err ( mut parse_error) => {
@@ -251,7 +251,7 @@ pub fn compile_input(sess: &Session,
251
251
tcx. print_debug_stats ( ) ;
252
252
}
253
253
254
- let trans = phase_4_translate_to_llvm ( tcx, rx) ;
254
+ let trans = phase_4_translate_to_llvm :: < DefaultTransCrate > ( tcx, rx) ;
255
255
256
256
if log_enabled ! ( :: log:: LogLevel :: Info ) {
257
257
println ! ( "Post-trans" ) ;
@@ -285,15 +285,15 @@ pub fn compile_input(sess: &Session,
285
285
sess. code_stats . borrow ( ) . print_type_sizes ( ) ;
286
286
}
287
287
288
- let ( phase5_result, trans) = phase_5_run_llvm_passes ( sess, & dep_graph, trans) ;
288
+ let ( phase5_result, trans) = phase_5_run_llvm_passes :: < DefaultTransCrate > ( sess, & dep_graph, trans) ;
289
289
290
290
controller_entry_point ! ( after_llvm,
291
291
sess,
292
292
CompileState :: state_after_llvm( input, sess, outdir, output, & trans) ,
293
293
phase5_result) ;
294
294
phase5_result?;
295
295
296
- phase_6_link_output ( sess, & trans, & outputs) ;
296
+ phase_6_link_output :: < DefaultTransCrate > ( sess, & trans, & outputs) ;
297
297
298
298
// Now that we won't touch anything in the incremental compilation directory
299
299
// any more, we can finalize it (which involves renaming it)
@@ -972,7 +972,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
972
972
mir:: provide ( & mut local_providers) ;
973
973
reachable:: provide ( & mut local_providers) ;
974
974
rustc_privacy:: provide ( & mut local_providers) ;
975
- trans :: provide_local ( & mut local_providers) ;
975
+ DefaultTransCrate :: provide_local ( & mut local_providers) ;
976
976
typeck:: provide ( & mut local_providers) ;
977
977
ty:: provide ( & mut local_providers) ;
978
978
traits:: provide ( & mut local_providers) ;
@@ -984,7 +984,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
984
984
985
985
let mut extern_providers = ty:: maps:: Providers :: default ( ) ;
986
986
cstore:: provide ( & mut extern_providers) ;
987
- trans :: provide_extern ( & mut extern_providers) ;
987
+ DefaultTransCrate :: provide_extern ( & mut extern_providers) ;
988
988
ty:: provide_extern ( & mut extern_providers) ;
989
989
traits:: provide_extern ( & mut extern_providers) ;
990
990
// FIXME(eddyb) get rid of this once we replace const_eval with miri.
@@ -1130,9 +1130,9 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
1130
1130
1131
1131
/// Run the translation phase to LLVM, after which the AST and analysis can
1132
1132
/// be discarded.
1133
- pub fn phase_4_translate_to_llvm < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1133
+ pub fn phase_4_translate_to_llvm < ' a , ' tcx , T : TransCrate > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1134
1134
rx : mpsc:: Receiver < Box < Any + Send > > )
1135
- -> write :: OngoingCrateTranslation {
1135
+ -> < T as TransCrate > :: OngoingCrateTranslation {
1136
1136
let time_passes = tcx. sess . time_passes ( ) ;
1137
1137
1138
1138
time ( time_passes,
@@ -1141,9 +1141,8 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1141
1141
1142
1142
let translation =
1143
1143
time ( time_passes, "translation" , move || {
1144
- trans :: trans_crate ( tcx, rx)
1144
+ T :: trans_crate ( tcx, rx)
1145
1145
} ) ;
1146
-
1147
1146
if tcx. sess . profile_queries ( ) {
1148
1147
profile:: dump ( "profile_queries" . to_string ( ) )
1149
1148
}
@@ -1153,15 +1152,14 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1153
1152
1154
1153
/// Run LLVM itself, producing a bitcode file, assembly file or object file
1155
1154
/// as a side effect.
1156
- #[ cfg( feature="llvm" ) ]
1157
- pub fn phase_5_run_llvm_passes ( sess : & Session ,
1155
+ pub fn phase_5_run_llvm_passes < T : TransCrate > ( sess : & Session ,
1158
1156
dep_graph : & DepGraph ,
1159
- trans : write :: OngoingCrateTranslation )
1160
- -> ( CompileResult , trans :: CrateTranslation ) {
1161
- let trans = trans . join ( sess, dep_graph) ;
1157
+ trans : < T as TransCrate > :: OngoingCrateTranslation )
1158
+ -> ( CompileResult , < T as TransCrate > :: TranslatedCrate ) {
1159
+ let trans = T :: join_trans ( trans , sess, dep_graph) ;
1162
1160
1163
1161
if sess. opts . debugging_opts . incremental_info {
1164
- write :: dump_incremental_data ( & trans) ;
1162
+ T :: dump_incremental_data ( & trans) ;
1165
1163
}
1166
1164
1167
1165
time ( sess. time_passes ( ) ,
@@ -1174,14 +1172,11 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
1174
1172
/// Run the linker on any artifacts that resulted from the LLVM run.
1175
1173
/// This should produce either a finished executable or library.
1176
1174
#[ cfg( feature="llvm" ) ]
1177
- pub fn phase_6_link_output ( sess : & Session ,
1178
- trans : & trans :: CrateTranslation ,
1175
+ pub fn phase_6_link_output < T : TransCrate > ( sess : & Session ,
1176
+ trans : & < T as TransCrate > :: TranslatedCrate ,
1179
1177
outputs : & OutputFilenames ) {
1180
1178
time ( sess. time_passes ( ) , "linking" , || {
1181
- :: rustc_trans:: back:: link:: link_binary ( sess,
1182
- trans,
1183
- outputs,
1184
- & trans. crate_name . as_str ( ) )
1179
+ T :: link_binary ( sess, trans, outputs)
1185
1180
} ) ;
1186
1181
}
1187
1182
0 commit comments