Introduce FuncId backend type
This commit is contained in:
parent
29b6e0f0a1
commit
4d1a5ade9b
10 changed files with 16 additions and 10 deletions
|
@ -52,6 +52,7 @@ const UNNAMED: *const c_char = EMPTY_C_STR.as_ptr();
|
|||
|
||||
impl BackendTypes for Builder<'_, 'll, 'tcx> {
|
||||
type Value = <CodegenCx<'ll, 'tcx> as BackendTypes>::Value;
|
||||
type FuncId = <CodegenCx<'ll, 'tcx> as BackendTypes>::FuncId;
|
||||
type BasicBlock = <CodegenCx<'ll, 'tcx> as BackendTypes>::BasicBlock;
|
||||
type Type = <CodegenCx<'ll, 'tcx> as BackendTypes>::Type;
|
||||
type Funclet = <CodegenCx<'ll, 'tcx> as BackendTypes>::Funclet;
|
||||
|
|
|
@ -86,6 +86,8 @@ impl Funclet<'ll> {
|
|||
|
||||
impl BackendTypes for CodegenCx<'ll, 'tcx> {
|
||||
type Value = &'ll Value;
|
||||
type FuncId = &'ll Value;
|
||||
|
||||
type BasicBlock = &'ll BasicBlock;
|
||||
type Type = &'ll Type;
|
||||
type Funclet = Funclet<'ll>;
|
||||
|
|
|
@ -84,7 +84,7 @@ pub trait BuilderMethods<'a, 'tcx>:
|
|||
{
|
||||
fn new_block<'b>(
|
||||
cx: &'a Self::CodegenCx,
|
||||
llfn: Self::Value,
|
||||
llfn: Self::FuncId,
|
||||
name: &'b str
|
||||
) -> Self;
|
||||
/* ... */
|
||||
|
|
|
@ -30,7 +30,7 @@ pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
|
|||
|
||||
debug_context: FunctionDebugContext<Bx::DIScope>,
|
||||
|
||||
llfn: Bx::Value,
|
||||
llfn: Bx::FuncId,
|
||||
|
||||
cx: &'a Bx::CodegenCx,
|
||||
|
||||
|
@ -183,7 +183,7 @@ impl<'a, 'tcx, V: CodegenObject> LocalRef<'tcx, V> {
|
|||
|
||||
pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
cx: &'a Bx::CodegenCx,
|
||||
llfn: Bx::Value,
|
||||
llfn: Bx::FuncId,
|
||||
mir: &'a Body<'tcx>,
|
||||
instance: Instance<'tcx>,
|
||||
sig: ty::FnSig<'tcx>,
|
||||
|
|
|
@ -14,6 +14,8 @@ use syntax_pos::symbol::InternedString;
|
|||
|
||||
pub trait BackendTypes {
|
||||
type Value: CodegenObject;
|
||||
type FuncId: CodegenObject;
|
||||
|
||||
type BasicBlock: Copy;
|
||||
type Type: CodegenObject;
|
||||
type Funclet;
|
||||
|
|
|
@ -34,7 +34,7 @@ pub trait BuilderMethods<'a, 'tcx>:
|
|||
+ HasTargetSpec
|
||||
|
||||
{
|
||||
fn new_block<'b>(cx: &'a Self::CodegenCx, llfn: Self::Value, name: &'b str) -> Self;
|
||||
fn new_block<'b>(cx: &'a Self::CodegenCx, llfn: Self::FuncId, name: &'b str) -> Self;
|
||||
fn with_cx(cx: &'a Self::CodegenCx) -> Self;
|
||||
fn build_sibling_block(&self, name: &str) -> Self;
|
||||
fn cx(&self) -> &Self::CodegenCx;
|
||||
|
|
|
@ -20,7 +20,7 @@ pub trait DebugInfoMethods<'tcx>: BackendTypes {
|
|||
&self,
|
||||
instance: Instance<'tcx>,
|
||||
sig: ty::FnSig<'tcx>,
|
||||
llfn: Self::Value,
|
||||
llfn: Self::FuncId,
|
||||
mir: &mir::Body<'_>,
|
||||
) -> FunctionDebugContext<Self::DIScope>;
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ pub trait DeclareMethods<'tcx>: BackendTypes {
|
|||
///
|
||||
/// If there’s a value with the same name already declared, the function will
|
||||
/// update the declaration and return existing Value instead.
|
||||
fn declare_cfn(&self, name: &str, fn_type: Self::Type) -> Self::Value;
|
||||
fn declare_cfn(&self, name: &str, fn_type: Self::Type) -> Self::FuncId;
|
||||
|
||||
/// Declare a Rust function.
|
||||
///
|
||||
/// If there’s a value with the same name already declared, the function will
|
||||
/// update the declaration and return existing Value instead.
|
||||
fn declare_fn(&self, name: &str, sig: ty::PolyFnSig<'tcx>) -> Self::Value;
|
||||
fn declare_fn(&self, name: &str, sig: ty::PolyFnSig<'tcx>) -> Self::FuncId;
|
||||
|
||||
/// Declare a global with an intention to define it.
|
||||
///
|
||||
|
|
|
@ -11,14 +11,14 @@ pub trait MiscMethods<'tcx>: BackendTypes {
|
|||
&self,
|
||||
) -> &RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), Self::Value>>;
|
||||
fn check_overflow(&self) -> bool;
|
||||
fn instances(&self) -> &RefCell<FxHashMap<Instance<'tcx>, Self::Value>>;
|
||||
fn instances(&self) -> &RefCell<FxHashMap<Instance<'tcx>, Self::FuncId>>;
|
||||
fn get_fn(&self, instance: Instance<'tcx>) -> Self::Value;
|
||||
fn eh_personality(&self) -> Self::Value;
|
||||
fn eh_unwind_resume(&self) -> Self::Value;
|
||||
fn sess(&self) -> &Session;
|
||||
fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>>;
|
||||
fn used_statics(&self) -> &RefCell<Vec<Self::Value>>;
|
||||
fn set_frame_pointer_elimination(&self, llfn: Self::Value);
|
||||
fn apply_target_cpu_attr(&self, llfn: Self::Value);
|
||||
fn set_frame_pointer_elimination(&self, llfn: Self::FuncId);
|
||||
fn apply_target_cpu_attr(&self, llfn: Self::FuncId);
|
||||
fn create_used_variable(&self);
|
||||
}
|
||||
|
|
|
@ -88,6 +88,7 @@ pub trait HasCodegen<'tcx>:
|
|||
type CodegenCx: CodegenMethods<'tcx>
|
||||
+ BackendTypes<
|
||||
Value = Self::Value,
|
||||
FuncId = Self::FuncId,
|
||||
BasicBlock = Self::BasicBlock,
|
||||
Type = Self::Type,
|
||||
Funclet = Self::Funclet,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue