]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_ssa/traits/write.rs
Add riscv64gc-unknown-none-elf target
[rust.git] / src / librustc_codegen_ssa / traits / write.rs
1 use crate::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
2 use crate::back::write::{CodegenContext, ModuleConfig};
3 use crate::{CompiledModule, ModuleCodegen};
4
5 use rustc::dep_graph::WorkProduct;
6 use rustc::util::time_graph::Timeline;
7 use rustc_errors::{FatalError, Handler};
8
9 pub trait WriteBackendMethods: 'static + Sized + Clone {
10     type Module: Send + Sync;
11     type TargetMachine;
12     type ModuleBuffer: ModuleBufferMethods;
13     type Context: ?Sized;
14     type ThinData: Send + Sync;
15     type ThinBuffer: ThinBufferMethods;
16
17     /// Performs fat LTO by merging all modules into a single one and returning it
18     /// for further optimization.
19     fn run_fat_lto(
20         cgcx: &CodegenContext<Self>,
21         modules: Vec<ModuleCodegen<Self::Module>>,
22         timeline: &mut Timeline,
23     ) -> Result<LtoModuleCodegen<Self>, FatalError>;
24     /// Performs thin LTO by performing necessary global analysis and returning two
25     /// lists, one of the modules that need optimization and another for modules that
26     /// can simply be copied over from the incr. comp. cache.
27     fn run_thin_lto(
28         cgcx: &CodegenContext<Self>,
29         modules: Vec<(String, Self::ThinBuffer)>,
30         cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
31         timeline: &mut Timeline,
32     ) -> Result<(Vec<LtoModuleCodegen<Self>>, Vec<WorkProduct>), FatalError>;
33     fn print_pass_timings(&self);
34     unsafe fn optimize(
35         cgcx: &CodegenContext<Self>,
36         diag_handler: &Handler,
37         module: &ModuleCodegen<Self::Module>,
38         config: &ModuleConfig,
39         timeline: &mut Timeline,
40     ) -> Result<(), FatalError>;
41     unsafe fn optimize_thin(
42         cgcx: &CodegenContext<Self>,
43         thin: &mut ThinModule<Self>,
44         timeline: &mut Timeline,
45     ) -> Result<ModuleCodegen<Self::Module>, FatalError>;
46     unsafe fn codegen(
47         cgcx: &CodegenContext<Self>,
48         diag_handler: &Handler,
49         module: ModuleCodegen<Self::Module>,
50         config: &ModuleConfig,
51         timeline: &mut Timeline,
52     ) -> Result<CompiledModule, FatalError>;
53     fn prepare_thin(
54         cgcx: &CodegenContext<Self>,
55         module: ModuleCodegen<Self::Module>
56     ) -> (String, Self::ThinBuffer);
57     fn run_lto_pass_manager(
58         cgcx: &CodegenContext<Self>,
59         llmod: &ModuleCodegen<Self::Module>,
60         config: &ModuleConfig,
61         thin: bool,
62     );
63 }
64
65 pub trait ThinBufferMethods: Send + Sync {
66     fn data(&self) -> &[u8];
67 }
68
69 pub trait ModuleBufferMethods: Send + Sync {
70     fn data(&self) -> &[u8];
71 }