@@ -19,6 +19,7 @@ use rustc_codegen_ssa::traits::{
19
19
AsmMethods , BackendTypes , DebugInfoMethods , GlobalAsmOperandRef , MiscMethods ,
20
20
} ;
21
21
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
22
+ use rustc_hir:: def_id:: DefId ;
22
23
use rustc_middle:: mir;
23
24
use rustc_middle:: mir:: mono:: CodegenUnit ;
24
25
use rustc_middle:: ty:: layout:: { HasParamEnv , HasTyCtxt } ;
@@ -57,11 +58,14 @@ pub struct CodegenCx<'tcx> {
57
58
/// Cache of all the builtin symbols we need
58
59
pub sym : Rc < Symbols > ,
59
60
pub instruction_table : InstructionTable ,
60
- pub libm_intrinsics : RefCell < FxHashMap < Word , super :: builder:: libm_intrinsics:: LibmIntrinsic > > ,
61
+
62
+ // FIXME(eddyb) should the maps exist at all, now that the `DefId` is known
63
+ // at `call` time, and presumably its high-level details can be looked up?
64
+ pub libm_intrinsics : RefCell < FxHashMap < DefId , super :: builder:: libm_intrinsics:: LibmIntrinsic > > ,
61
65
62
66
/// All `panic!(...)`s and builtin panics (from MIR `Assert`s) call into one
63
67
/// of these lang items, which we always replace with an "abort".
64
- pub panic_entry_point_ids : RefCell < FxHashSet < Word > > ,
68
+ pub panic_entry_points : RefCell < FxHashSet < DefId > > ,
65
69
66
70
/// `core::fmt::Arguments::new_{v1,const}` instances (for Rust 2021 panics).
67
71
pub fmt_args_new_fn_ids : RefCell < FxHashSet < Word > > ,
@@ -72,18 +76,15 @@ pub struct CodegenCx<'tcx> {
72
76
pub fmt_rt_arg_new_fn_ids_to_ty_and_spec : RefCell < FxHashMap < Word , ( Ty < ' tcx > , char ) > > ,
73
77
74
78
/// Intrinsic for loading a `<T>` from a `&[u32]`. The `PassMode` is the mode of the `<T>`.
75
- pub buffer_load_intrinsic_fn_id : RefCell < FxHashMap < Word , & ' tcx PassMode > > ,
79
+ pub buffer_load_intrinsics : RefCell < FxHashMap < DefId , & ' tcx PassMode > > ,
76
80
/// Intrinsic for storing a `<T>` into a `&[u32]`. The `PassMode` is the mode of the `<T>`.
77
- pub buffer_store_intrinsic_fn_id : RefCell < FxHashMap < Word , & ' tcx PassMode > > ,
81
+ pub buffer_store_intrinsics : RefCell < FxHashMap < DefId , & ' tcx PassMode > > ,
78
82
79
83
/// Some runtimes (e.g. intel-compute-runtime) disallow atomics on i8 and i16, even though it's allowed by the spec.
80
84
/// This enables/disables them.
81
85
pub i8_i16_atomics_allowed : bool ,
82
86
83
87
pub codegen_args : CodegenArgs ,
84
-
85
- /// Information about the SPIR-V target.
86
- pub target : SpirvTarget ,
87
88
}
88
89
89
90
impl < ' tcx > CodegenCx < ' tcx > {
@@ -190,15 +191,14 @@ impl<'tcx> CodegenCx<'tcx> {
190
191
vtables : Default :: default ( ) ,
191
192
ext_inst : Default :: default ( ) ,
192
193
zombie_decorations : Default :: default ( ) ,
193
- target,
194
194
sym,
195
195
instruction_table : InstructionTable :: new ( ) ,
196
196
libm_intrinsics : Default :: default ( ) ,
197
- panic_entry_point_ids : Default :: default ( ) ,
197
+ panic_entry_points : Default :: default ( ) ,
198
198
fmt_args_new_fn_ids : Default :: default ( ) ,
199
199
fmt_rt_arg_new_fn_ids_to_ty_and_spec : Default :: default ( ) ,
200
- buffer_load_intrinsic_fn_id : Default :: default ( ) ,
201
- buffer_store_intrinsic_fn_id : Default :: default ( ) ,
200
+ buffer_load_intrinsics : Default :: default ( ) ,
201
+ buffer_store_intrinsics : Default :: default ( ) ,
202
202
i8_i16_atomics_allowed : false ,
203
203
codegen_args,
204
204
}
@@ -296,7 +296,6 @@ pub enum SpirvMetadata {
296
296
}
297
297
298
298
pub struct CodegenArgs {
299
- pub module_output_type : ModuleOutputType ,
300
299
pub disassemble : bool ,
301
300
pub disassemble_fn : Option < String > ,
302
301
pub disassemble_entry : Option < String > ,
@@ -554,8 +553,6 @@ impl CodegenArgs {
554
553
std:: process:: exit ( 1 ) ;
555
554
}
556
555
557
- let module_output_type =
558
- matches. opt_get_default ( "module-output" , ModuleOutputType :: Single ) ?;
559
556
let disassemble = matches. opt_present ( "disassemble" ) ;
560
557
let disassemble_fn = matches. opt_str ( "disassemble-fn" ) ;
561
558
let disassemble_entry = matches. opt_str ( "disassemble-entry" ) ;
@@ -617,9 +614,9 @@ impl CodegenArgs {
617
614
. collect ( ) ,
618
615
619
616
abort_strategy : matches. opt_str ( "abort-strategy" ) ,
617
+ module_output_type : matches. opt_get_default ( "module-output" , Default :: default ( ) ) ?,
620
618
621
619
// FIXME(eddyb) deduplicate between `CodegenArgs` and `linker::Options`.
622
- emit_multiple_modules : module_output_type == ModuleOutputType :: Multiple ,
623
620
spirv_metadata,
624
621
keep_link_exports : false ,
625
622
@@ -639,7 +636,6 @@ impl CodegenArgs {
639
636
} ;
640
637
641
638
Ok ( Self {
642
- module_output_type,
643
639
disassemble,
644
640
disassemble_fn,
645
641
disassemble_entry,
@@ -781,8 +777,9 @@ impl CodegenArgs {
781
777
}
782
778
}
783
779
784
- #[ derive( Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
780
+ #[ derive( Debug , Default , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
785
781
pub enum ModuleOutputType {
782
+ #[ default]
786
783
Single ,
787
784
Multiple ,
788
785
}
0 commit comments