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::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(&self, instance: Instance<'tcx>) -> Self::Value;
23    fn eh_personality(&self) -> Self::Function;
24    fn sess(&self) -> &Session;
25    fn set_frame_pointer_type(&self, llfn: Self::Function);
26    fn apply_target_cpu_attr(&self, llfn: Self::Function);
27    /// Declares the extern "C" main function for the entry point. Returns None if the symbol
28    /// already exists.
29    fn declare_c_main(&self, fn_type: Self::FunctionSignature) -> Option<Self::Function>;
30
31    /// Whether `codegen_intrinsic_call` expects to always have a `place_value`
32    /// when emitting code for the intrinsic `name`.
33    ///
34    /// This is discouraged, but here for now to simplify migration to using OperandValues
35    fn intrinsic_call_expects_place_always(&self, name: Symbol) -> bool;
36}