rustc_codegen_ssa/traits/
write.rs1use std::path::PathBuf;
2
3use rustc_data_structures::profiling::SelfProfilerRef;
4use rustc_errors::DiagCtxtHandle;
5use rustc_middle::dep_graph::WorkProduct;
6
7use crate::back::lto::{SerializedModule, ThinModule};
8use crate::back::write::{
9 CodegenContext, FatLtoInput, ModuleConfig, SharedEmitter, TargetMachineFactoryFn,
10};
11use crate::{CompiledModule, ModuleCodegen};
12
13pub trait WriteBackendMethods: Clone + 'static {
14 type Module: Send + Sync;
15 type TargetMachine;
16 type ModuleBuffer: ModuleBufferMethods;
17 type ThinData: Send + Sync;
18
19 fn run_and_optimize_fat_lto(
22 cgcx: &CodegenContext,
23 prof: &SelfProfilerRef,
24 shared_emitter: &SharedEmitter,
25 tm_factory: TargetMachineFactoryFn<Self>,
26 exported_symbols_for_lto: &[String],
27 each_linked_rlib_for_lto: &[PathBuf],
28 modules: Vec<FatLtoInput<Self>>,
29 ) -> ModuleCodegen<Self::Module>;
30 fn run_thin_lto(
34 cgcx: &CodegenContext,
35 prof: &SelfProfilerRef,
36 dcx: DiagCtxtHandle<'_>,
37 exported_symbols_for_lto: &[String],
38 each_linked_rlib_for_lto: &[PathBuf],
39 modules: Vec<(String, Self::ModuleBuffer)>,
40 cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
41 ) -> (Vec<ThinModule<Self>>, Vec<WorkProduct>);
42 fn print_pass_timings(&self);
43 fn print_statistics(&self);
44 fn optimize(
45 cgcx: &CodegenContext,
46 prof: &SelfProfilerRef,
47 shared_emitter: &SharedEmitter,
48 module: &mut ModuleCodegen<Self::Module>,
49 config: &ModuleConfig,
50 );
51 fn optimize_thin(
52 cgcx: &CodegenContext,
53 prof: &SelfProfilerRef,
54 shared_emitter: &SharedEmitter,
55 tm_factory: TargetMachineFactoryFn<Self>,
56 thin: ThinModule<Self>,
57 ) -> ModuleCodegen<Self::Module>;
58 fn codegen(
59 cgcx: &CodegenContext,
60 prof: &SelfProfilerRef,
61 shared_emitter: &SharedEmitter,
62 module: ModuleCodegen<Self::Module>,
63 config: &ModuleConfig,
64 ) -> CompiledModule;
65 fn serialize_module(module: Self::Module, is_thin: bool) -> Self::ModuleBuffer;
66}
67
68pub trait ModuleBufferMethods: Send + Sync {
69 fn data(&self) -> &[u8];
70}