]>
Commit | Line | Data |
---|---|---|
1 | use crate::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule}; | |
2 | use crate::back::write::{CodegenContext, FatLtoInput, ModuleConfig}; | |
3 | use crate::{CompiledModule, ModuleCodegen}; | |
4 | ||
5 | use rustc_errors::{DiagCtxt, FatalError}; | |
6 | use rustc_middle::dep_graph::WorkProduct; | |
7 | ||
8 | pub trait WriteBackendMethods: 'static + Sized + Clone { | |
9 | type Module: Send + Sync; | |
10 | type TargetMachine; | |
11 | type TargetMachineError; | |
12 | type ModuleBuffer: ModuleBufferMethods; | |
13 | type ThinData: Send + Sync; | |
14 | type ThinBuffer: ThinBufferMethods; | |
15 | ||
16 | /// Merge all modules into main_module and returning it | |
17 | fn run_link( | |
18 | cgcx: &CodegenContext<Self>, | |
19 | dcx: &DiagCtxt, | |
20 | modules: Vec<ModuleCodegen<Self::Module>>, | |
21 | ) -> Result<ModuleCodegen<Self::Module>, FatalError>; | |
22 | /// Performs fat LTO by merging all modules into a single one and returning it | |
23 | /// for further optimization. | |
24 | fn run_fat_lto( | |
25 | cgcx: &CodegenContext<Self>, | |
26 | modules: Vec<FatLtoInput<Self>>, | |
27 | cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>, | |
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)>, | |
35 | cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>, | |
36 | ) -> Result<(Vec<LtoModuleCodegen<Self>>, Vec<WorkProduct>), FatalError>; | |
37 | fn print_pass_timings(&self); | |
38 | fn print_statistics(&self); | |
39 | unsafe fn optimize( | |
40 | cgcx: &CodegenContext<Self>, | |
41 | dcx: &DiagCtxt, | |
42 | module: &ModuleCodegen<Self::Module>, | |
43 | config: &ModuleConfig, | |
44 | ) -> Result<(), FatalError>; | |
45 | fn optimize_fat( | |
46 | cgcx: &CodegenContext<Self>, | |
47 | llmod: &mut ModuleCodegen<Self::Module>, | |
48 | ) -> Result<(), FatalError>; | |
49 | unsafe fn optimize_thin( | |
50 | cgcx: &CodegenContext<Self>, | |
51 | thin: ThinModule<Self>, | |
52 | ) -> Result<ModuleCodegen<Self::Module>, FatalError>; | |
53 | unsafe fn codegen( | |
54 | cgcx: &CodegenContext<Self>, | |
55 | dcx: &DiagCtxt, | |
56 | module: ModuleCodegen<Self::Module>, | |
57 | config: &ModuleConfig, | |
58 | ) -> Result<CompiledModule, FatalError>; | |
59 | fn prepare_thin(module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer); | |
60 | fn serialize_module(module: ModuleCodegen<Self::Module>) -> (String, Self::ModuleBuffer); | |
61 | } | |
62 | ||
63 | pub trait ThinBufferMethods: Send + Sync { | |
64 | fn data(&self) -> &[u8]; | |
65 | } | |
66 | ||
67 | pub trait ModuleBufferMethods: Send + Sync { | |
68 | fn data(&self) -> &[u8]; | |
69 | } |