rustc_codegen_ssa/traits/
misc.rs1use std::cell::RefCell;
2
3use rustc_data_structures::fx::FxHashMap;
4use rustc_middle::ty::{self, Instance, Ty};
5use rustc_session::Session;
6use rustc_span::Symbol;
7
8use super::BackendTypes;
9
10#[derive(#[automatically_derived]
impl ::core::default::Default for AddressDiversity {
#[inline]
fn default() -> AddressDiversity { Self::None }
}Default)]
12pub enum AddressDiversity {
13 #[default]
15 None,
16 Real,
18 Synthetic(u64),
21}
22
23pub struct PacMetadata {
25 pub key: u32,
27 pub disc: u64,
29 pub addr_diversity: AddressDiversity,
31}
32
33impl Default for PacMetadata {
34 fn default() -> Self {
35 PacMetadata { key: 0, disc: 0, addr_diversity: AddressDiversity::default() }
36 }
37}
38
39pub trait MiscCodegenMethods<'tcx>: BackendTypes {
40 fn vtables(
41 &self,
42 ) -> &RefCell<FxHashMap<(Ty<'tcx>, Option<ty::ExistentialTraitRef<'tcx>>), Self::Value>>;
43 fn apply_vcall_visibility_metadata(
44 &self,
45 _ty: Ty<'tcx>,
46 _poly_trait_ref: Option<ty::ExistentialTraitRef<'tcx>>,
47 _vtable: Self::Value,
48 ) {
49 }
50 fn get_fn(&self, instance: Instance<'tcx>) -> Self::Function;
51 fn get_fn_addr(&self, instance: Instance<'tcx>, pac: Option<PacMetadata>) -> Self::Value;
52 fn eh_personality(&self) -> Self::Function;
53 fn sess(&self) -> &Session;
54 fn set_frame_pointer_type(&self, llfn: Self::Function);
55 fn apply_target_cpu_attr(&self, llfn: Self::Function);
56 fn declare_c_main(&self, fn_type: Self::FunctionSignature) -> Option<Self::Function>;
59
60 fn intrinsic_call_expects_place_always(&self, name: Symbol) -> bool;
65}