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, Intrinsic, Ty};
5use rustc_session::{PointerAuthSchema, Session};
6
7use super::BackendTypes;
8
9pub trait MiscCodegenMethods<'tcx>: BackendTypes {
10    fn vtables(
11        &self,
12    ) -> &RefCell<FxHashMap<(Ty<'tcx>, Option<ty::ExistentialTraitRef<'tcx>>), Self::Value>>;
13    fn apply_vcall_visibility_metadata(
14        &self,
15        _trait_hierarchy: &[ty::ExistentialTraitRef<'tcx>],
16        _vtable: Self::Value,
17    ) {
18    }
19    fn get_fn(&self, instance: Instance<'tcx>) -> Self::Function;
20    fn get_fn_addr(
21        &self,
22        instance: Instance<'tcx>,
23        pointer_auth_schema: Option<&PointerAuthSchema>,
24    ) -> Self::Value;
25    fn eh_personality(&self) -> Self::Function;
26    fn sess(&self) -> &Session;
27    fn set_frame_pointer_type(&self, llfn: Self::Function);
28    fn apply_target_cpu_attr(&self, llfn: Self::Function);
29    /// Applies the compilation's optimization attributes to a function that no item produced,
30    /// such as the C entry shim.
31    fn apply_default_optimisation_attrs(&self, _llfn: Self::Function) {}
32    /// Declares the extern "C" main function for the entry point. Returns None if the symbol
33    /// already exists.
34    fn declare_c_main(&self, fn_type: Self::FunctionSignature) -> Option<Self::Function>;
35
36    /// Whether `codegen_intrinsic_call` expects to always have a `place_value`
37    /// when emitting code for the intrinsic `name`.
38    ///
39    /// This is discouraged, but here for now to simplify migration to using OperandValues
40    fn intrinsic_call_expects_place_always(&self, name: Intrinsic) -> bool;
41}