@@ -19,6 +19,7 @@ use rustc_codegen_ssa::traits::{
1919 AsmMethods , BackendTypes , DebugInfoMethods , GlobalAsmOperandRef , MiscMethods ,
2020} ;
2121use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
22+ use rustc_hir:: def_id:: DefId ;
2223use rustc_middle:: mir;
2324use rustc_middle:: mir:: mono:: CodegenUnit ;
2425use rustc_middle:: ty:: layout:: { HasParamEnv , HasTyCtxt } ;
@@ -57,11 +58,14 @@ pub struct CodegenCx<'tcx> {
5758 /// Cache of all the builtin symbols we need
5859 pub sym : Rc < Symbols > ,
5960 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 > > ,
6165
6266 /// All `panic!(...)`s and builtin panics (from MIR `Assert`s) call into one
6367 /// 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 > > ,
6569
6670 /// `core::fmt::Arguments::new_{v1,const}` instances (for Rust 2021 panics).
6771 pub fmt_args_new_fn_ids : RefCell < FxHashSet < Word > > ,
@@ -72,18 +76,15 @@ pub struct CodegenCx<'tcx> {
7276 pub fmt_rt_arg_new_fn_ids_to_ty_and_spec : RefCell < FxHashMap < Word , ( Ty < ' tcx > , char ) > > ,
7377
7478 /// 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 > > ,
7680 /// 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 > > ,
7882
7983 /// Some runtimes (e.g. intel-compute-runtime) disallow atomics on i8 and i16, even though it's allowed by the spec.
8084 /// This enables/disables them.
8185 pub i8_i16_atomics_allowed : bool ,
8286
8387 pub codegen_args : CodegenArgs ,
84-
85- /// Information about the SPIR-V target.
86- pub target : SpirvTarget ,
8788}
8889
8990impl < ' tcx > CodegenCx < ' tcx > {
@@ -190,15 +191,14 @@ impl<'tcx> CodegenCx<'tcx> {
190191 vtables : Default :: default ( ) ,
191192 ext_inst : Default :: default ( ) ,
192193 zombie_decorations : Default :: default ( ) ,
193- target,
194194 sym,
195195 instruction_table : InstructionTable :: new ( ) ,
196196 libm_intrinsics : Default :: default ( ) ,
197- panic_entry_point_ids : Default :: default ( ) ,
197+ panic_entry_points : Default :: default ( ) ,
198198 fmt_args_new_fn_ids : Default :: default ( ) ,
199199 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 ( ) ,
202202 i8_i16_atomics_allowed : false ,
203203 codegen_args,
204204 }
@@ -296,7 +296,6 @@ pub enum SpirvMetadata {
296296}
297297
298298pub struct CodegenArgs {
299- pub module_output_type : ModuleOutputType ,
300299 pub disassemble : bool ,
301300 pub disassemble_fn : Option < String > ,
302301 pub disassemble_entry : Option < String > ,
@@ -554,8 +553,6 @@ impl CodegenArgs {
554553 std:: process:: exit ( 1 ) ;
555554 }
556555
557- let module_output_type =
558- matches. opt_get_default ( "module-output" , ModuleOutputType :: Single ) ?;
559556 let disassemble = matches. opt_present ( "disassemble" ) ;
560557 let disassemble_fn = matches. opt_str ( "disassemble-fn" ) ;
561558 let disassemble_entry = matches. opt_str ( "disassemble-entry" ) ;
@@ -617,9 +614,9 @@ impl CodegenArgs {
617614 . collect ( ) ,
618615
619616 abort_strategy : matches. opt_str ( "abort-strategy" ) ,
617+ module_output_type : matches. opt_get_default ( "module-output" , Default :: default ( ) ) ?,
620618
621619 // FIXME(eddyb) deduplicate between `CodegenArgs` and `linker::Options`.
622- emit_multiple_modules : module_output_type == ModuleOutputType :: Multiple ,
623620 spirv_metadata,
624621 keep_link_exports : false ,
625622
@@ -639,7 +636,6 @@ impl CodegenArgs {
639636 } ;
640637
641638 Ok ( Self {
642- module_output_type,
643639 disassemble,
644640 disassemble_fn,
645641 disassemble_entry,
@@ -781,8 +777,9 @@ impl CodegenArgs {
781777 }
782778}
783779
784- #[ derive( Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
780+ #[ derive( Debug , Default , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
785781pub enum ModuleOutputType {
782+ #[ default]
786783 Single ,
787784 Multiple ,
788785}
0 commit comments