Skip to main content

rustc_codegen_ssa/traits/
misc.rs

1use std::cell::RefCell;
2
3use rustc_data_structures::fx::FxHashMap;
4use rustc_middle::ty::{self, Instance, Ty};
5use rustc_session::{PointerAuthSchema, Session};
6use rustc_span::Symbol;
7
8use super::BackendTypes;
9
10pub trait MiscCodegenMethods<'tcx>: BackendTypes {
11    fn vtables(
12        &self,
13    ) -> &RefCell<FxHashMap<(Ty<'tcx>, Option<ty::ExistentialTraitRef<'tcx>>), Self::Value>>;
14    fn apply_vcall_visibility_metadata(
15        &self,
16        _ty: Ty<'tcx>,
17        _poly_trait_ref: Option<ty::ExistentialTraitRef<'tcx>>,
18        _vtable: Self::Value,
19    ) {
20    }
21    fn get_fn(&self, instance: Instance<'tcx>) -> Self::Function;
22    fn get_fn_addr(
23        &self,
24        instance: Instance<'tcx>,
25        pointer_auth_schema: Option<&PointerAuthSchema>,
26    ) -> Self::Value;
27    fn eh_personality(&self) -> Self::Function;
28    fn sess(&self) -> &Session;
29    fn set_frame_pointer_type(&self, llfn: Self::Function);
30    fn apply_target_cpu_attr(&self, llfn: Self::Function);
31    /// Declares the extern "C" main function for the entry point. Returns None if the symbol
32    /// already exists.
33    fn declare_c_main(&self, fn_type: Self::FunctionSignature) -> Option<Self::Function>;
34
35    /// Whether `codegen_intrinsic_call` expects to always have a `place_value`
36    /// when emitting code for the intrinsic `name`.
37    ///
38    /// This is discouraged, but here for now to simplify migration to using OperandValues
39    fn intrinsic_call_expects_place_always(&self, name: Symbol) -> bool;
40}