rustc_codegen_ssa/traits/statics.rs
1use rustc_abi::Align;
2use rustc_hir::def_id::DefId;
3
4use super::BackendTypes;
5
6pub trait StaticCodegenMethods: BackendTypes {
7 fn static_addr_of(&self, cv: Self::Value, align: Align, kind: Option<&str>) -> Self::Value;
8 fn codegen_static(&self, def_id: DefId);
9
10 /// Mark the given global value as "used", to prevent the compiler and linker from potentially
11 /// removing a static variable that may otherwise appear unused.
12 fn add_used_global(&self, global: Self::Value);
13
14 /// Same as add_used_global(), but only prevent the compiler from potentially removing an
15 /// otherwise unused symbol. The linker is still permitted to drop it.
16 ///
17 /// This corresponds to the documented semantics of the `#[used]` attribute, although
18 /// on some targets (non-ELF), we may use `add_used_global` for `#[used]` statics
19 /// instead.
20 fn add_compiler_used_global(&self, global: Self::Value);
21}
22
23pub trait StaticBuilderMethods: BackendTypes {
24 fn get_static(&mut self, def_id: DefId) -> Self::Value;
25}