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