]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_codegen_ssa/src/traits/write.rs
bump version to 1.79.0+dfsg1-1~bpo12+pve2
[rustc.git] / compiler / rustc_codegen_ssa / src / traits / write.rs
CommitLineData
9fa01778 1use crate::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
add651ee 2use crate::back::write::{CodegenContext, FatLtoInput, ModuleConfig};
9fa01778 3use crate::{CompiledModule, ModuleCodegen};
a1dfa0c6 4
4b012472 5use rustc_errors::{DiagCtxt, FatalError};
ba9703b0 6use rustc_middle::dep_graph::WorkProduct;
a1dfa0c6
XL
7
8pub trait WriteBackendMethods: 'static + Sized + Clone {
9 type Module: Send + Sync;
10 type TargetMachine;
9ffffee4 11 type TargetMachineError;
a1dfa0c6 12 type ModuleBuffer: ModuleBufferMethods;
a1dfa0c6
XL
13 type ThinData: Send + Sync;
14 type ThinBuffer: ThinBufferMethods;
15
1b1a35ee
XL
16 /// Merge all modules into main_module and returning it
17 fn run_link(
18 cgcx: &CodegenContext<Self>,
4b012472 19 dcx: &DiagCtxt,
1b1a35ee
XL
20 modules: Vec<ModuleCodegen<Self::Module>>,
21 ) -> Result<ModuleCodegen<Self::Module>, FatalError>;
0731742a
XL
22 /// Performs fat LTO by merging all modules into a single one and returning it
23 /// for further optimization.
24 fn run_fat_lto(
a1dfa0c6 25 cgcx: &CodegenContext<Self>,
add651ee 26 modules: Vec<FatLtoInput<Self>>,
9fa01778 27 cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
0731742a
XL
28 ) -> Result<LtoModuleCodegen<Self>, FatalError>;
29 /// Performs thin LTO by performing necessary global analysis and returning two
30 /// lists, one of the modules that need optimization and another for modules that
31 /// can simply be copied over from the incr. comp. cache.
32 fn run_thin_lto(
33 cgcx: &CodegenContext<Self>,
34 modules: Vec<(String, Self::ThinBuffer)>,
a1dfa0c6 35 cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
a1dfa0c6
XL
36 ) -> Result<(Vec<LtoModuleCodegen<Self>>, Vec<WorkProduct>), FatalError>;
37 fn print_pass_timings(&self);
add651ee 38 fn print_statistics(&self);
a1dfa0c6
XL
39 unsafe fn optimize(
40 cgcx: &CodegenContext<Self>,
4b012472 41 dcx: &DiagCtxt,
a1dfa0c6
XL
42 module: &ModuleCodegen<Self::Module>,
43 config: &ModuleConfig,
a1dfa0c6 44 ) -> Result<(), FatalError>;
04454e1e
FG
45 fn optimize_fat(
46 cgcx: &CodegenContext<Self>,
47 llmod: &mut ModuleCodegen<Self::Module>,
48 ) -> Result<(), FatalError>;
a1dfa0c6
XL
49 unsafe fn optimize_thin(
50 cgcx: &CodegenContext<Self>,
04454e1e 51 thin: ThinModule<Self>,
a1dfa0c6
XL
52 ) -> Result<ModuleCodegen<Self::Module>, FatalError>;
53 unsafe fn codegen(
54 cgcx: &CodegenContext<Self>,
4b012472 55 dcx: &DiagCtxt,
a1dfa0c6
XL
56 module: ModuleCodegen<Self::Module>,
57 config: &ModuleConfig,
a1dfa0c6 58 ) -> Result<CompiledModule, FatalError>;
dfeec247
XL
59 fn prepare_thin(module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer);
60 fn serialize_module(module: ModuleCodegen<Self::Module>) -> (String, Self::ModuleBuffer);
a1dfa0c6
XL
61}
62
63pub trait ThinBufferMethods: Send + Sync {
64 fn data(&self) -> &[u8];
65}
66
67pub trait ModuleBufferMethods: Send + Sync {
68 fn data(&self) -> &[u8];
69}