2018-11-24 14:12:15 +01:00
|
|
|
use super::BackendTypes;
|
2020-01-05 02:37:57 +01:00
|
|
|
use rustc_hir::def_id::DefId;
|
2020-03-31 18:16:47 +02:00
|
|
|
use rustc_target::abi::Align;
|
2018-09-10 16:28:47 +02:00
|
|
|
|
2018-11-24 14:12:15 +01:00
|
|
|
pub trait StaticMethods: BackendTypes {
|
2018-09-13 14:58:19 +02:00
|
|
|
fn static_addr_of(&self, cv: Self::Value, align: Align, kind: Option<&str>) -> Self::Value;
|
|
|
|
|
fn codegen_static(&self, def_id: DefId, is_mutable: bool);
|
2020-07-02 11:27:15 -07:00
|
|
|
|
2021-08-20 21:13:18 +02:00
|
|
|
/// Mark the given global value as "used", to prevent the compiler and linker from potentially
|
|
|
|
|
/// removing a static variable that may otherwise appear unused.
|
2020-07-02 11:27:15 -07:00
|
|
|
fn add_used_global(&self, global: Self::Value);
|
2021-08-20 21:13:18 +02:00
|
|
|
|
|
|
|
|
/// Same as add_used_global(), but only prevent the compiler from potentially removing an
|
|
|
|
|
/// otherwise unused symbol. The linker is still permitted to drop it.
|
|
|
|
|
///
|
2022-02-06 13:51:11 -08:00
|
|
|
/// This corresponds to the documented semantics of the `#[used]` attribute, although
|
|
|
|
|
/// on some targets (non-ELF), we may use `add_used_global` for `#[used]` statics
|
|
|
|
|
/// instead.
|
2021-08-20 21:13:18 +02:00
|
|
|
fn add_compiler_used_global(&self, global: Self::Value);
|
2018-09-10 16:28:47 +02:00
|
|
|
}
|
2018-11-26 18:36:58 +01:00
|
|
|
|
2019-06-11 12:49:10 +03:00
|
|
|
pub trait StaticBuilderMethods: BackendTypes {
|
2018-12-02 14:35:11 +01:00
|
|
|
fn get_static(&mut self, def_id: DefId) -> Self::Value;
|
2018-11-26 18:36:58 +01:00
|
|
|
}
|