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