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> {
|
impl BackendTypes for Builder<'_, 'll, 'tcx> {
|
||||||
type Value = <CodegenCx<'ll, 'tcx> as BackendTypes>::Value;
|
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 BasicBlock = <CodegenCx<'ll, 'tcx> as BackendTypes>::BasicBlock;
|
||||||
type Type = <CodegenCx<'ll, 'tcx> as BackendTypes>::Type;
|
type Type = <CodegenCx<'ll, 'tcx> as BackendTypes>::Type;
|
||||||
type Funclet = <CodegenCx<'ll, 'tcx> as BackendTypes>::Funclet;
|
type Funclet = <CodegenCx<'ll, 'tcx> as BackendTypes>::Funclet;
|
||||||
|
|
|
@ -86,6 +86,8 @@ impl Funclet<'ll> {
|
||||||
|
|
||||||
impl BackendTypes for CodegenCx<'ll, 'tcx> {
|
impl BackendTypes for CodegenCx<'ll, 'tcx> {
|
||||||
type Value = &'ll Value;
|
type Value = &'ll Value;
|
||||||
|
type FuncId = &'ll Value;
|
||||||
|
|
||||||
type BasicBlock = &'ll BasicBlock;
|
type BasicBlock = &'ll BasicBlock;
|
||||||
type Type = &'ll Type;
|
type Type = &'ll Type;
|
||||||
type Funclet = Funclet<'ll>;
|
type Funclet = Funclet<'ll>;
|
||||||
|
|
|
@ -84,7 +84,7 @@ pub trait BuilderMethods<'a, 'tcx>:
|
||||||
{
|
{
|
||||||
fn new_block<'b>(
|
fn new_block<'b>(
|
||||||
cx: &'a Self::CodegenCx,
|
cx: &'a Self::CodegenCx,
|
||||||
llfn: Self::Value,
|
llfn: Self::FuncId,
|
||||||
name: &'b str
|
name: &'b str
|
||||||
) -> Self;
|
) -> Self;
|
||||||
/* ... */
|
/* ... */
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
|
||||||
|
|
||||||
debug_context: FunctionDebugContext<Bx::DIScope>,
|
debug_context: FunctionDebugContext<Bx::DIScope>,
|
||||||
|
|
||||||
llfn: Bx::Value,
|
llfn: Bx::FuncId,
|
||||||
|
|
||||||
cx: &'a Bx::CodegenCx,
|
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>>(
|
pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
cx: &'a Bx::CodegenCx,
|
cx: &'a Bx::CodegenCx,
|
||||||
llfn: Bx::Value,
|
llfn: Bx::FuncId,
|
||||||
mir: &'a Body<'tcx>,
|
mir: &'a Body<'tcx>,
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
sig: ty::FnSig<'tcx>,
|
sig: ty::FnSig<'tcx>,
|
||||||
|
|
|
@ -14,6 +14,8 @@ use syntax_pos::symbol::InternedString;
|
||||||
|
|
||||||
pub trait BackendTypes {
|
pub trait BackendTypes {
|
||||||
type Value: CodegenObject;
|
type Value: CodegenObject;
|
||||||
|
type FuncId: CodegenObject;
|
||||||
|
|
||||||
type BasicBlock: Copy;
|
type BasicBlock: Copy;
|
||||||
type Type: CodegenObject;
|
type Type: CodegenObject;
|
||||||
type Funclet;
|
type Funclet;
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub trait BuilderMethods<'a, 'tcx>:
|
||||||
+ HasTargetSpec
|
+ 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 with_cx(cx: &'a Self::CodegenCx) -> Self;
|
||||||
fn build_sibling_block(&self, name: &str) -> Self;
|
fn build_sibling_block(&self, name: &str) -> Self;
|
||||||
fn cx(&self) -> &Self::CodegenCx;
|
fn cx(&self) -> &Self::CodegenCx;
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub trait DebugInfoMethods<'tcx>: BackendTypes {
|
||||||
&self,
|
&self,
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
sig: ty::FnSig<'tcx>,
|
sig: ty::FnSig<'tcx>,
|
||||||
llfn: Self::Value,
|
llfn: Self::FuncId,
|
||||||
mir: &mir::Body<'_>,
|
mir: &mir::Body<'_>,
|
||||||
) -> FunctionDebugContext<Self::DIScope>;
|
) -> 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
|
/// If there’s a value with the same name already declared, the function will
|
||||||
/// update the declaration and return existing Value instead.
|
/// 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.
|
/// Declare a Rust function.
|
||||||
///
|
///
|
||||||
/// If there’s a value with the same name already declared, the function will
|
/// If there’s a value with the same name already declared, the function will
|
||||||
/// update the declaration and return existing Value instead.
|
/// 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.
|
/// Declare a global with an intention to define it.
|
||||||
///
|
///
|
||||||
|
|
|
@ -11,14 +11,14 @@ pub trait MiscMethods<'tcx>: BackendTypes {
|
||||||
&self,
|
&self,
|
||||||
) -> &RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), Self::Value>>;
|
) -> &RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), Self::Value>>;
|
||||||
fn check_overflow(&self) -> bool;
|
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 get_fn(&self, instance: Instance<'tcx>) -> Self::Value;
|
||||||
fn eh_personality(&self) -> Self::Value;
|
fn eh_personality(&self) -> Self::Value;
|
||||||
fn eh_unwind_resume(&self) -> Self::Value;
|
fn eh_unwind_resume(&self) -> Self::Value;
|
||||||
fn sess(&self) -> &Session;
|
fn sess(&self) -> &Session;
|
||||||
fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>>;
|
fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>>;
|
||||||
fn used_statics(&self) -> &RefCell<Vec<Self::Value>>;
|
fn used_statics(&self) -> &RefCell<Vec<Self::Value>>;
|
||||||
fn set_frame_pointer_elimination(&self, llfn: Self::Value);
|
fn set_frame_pointer_elimination(&self, llfn: Self::FuncId);
|
||||||
fn apply_target_cpu_attr(&self, llfn: Self::Value);
|
fn apply_target_cpu_attr(&self, llfn: Self::FuncId);
|
||||||
fn create_used_variable(&self);
|
fn create_used_variable(&self);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,7 @@ pub trait HasCodegen<'tcx>:
|
||||||
type CodegenCx: CodegenMethods<'tcx>
|
type CodegenCx: CodegenMethods<'tcx>
|
||||||
+ BackendTypes<
|
+ BackendTypes<
|
||||||
Value = Self::Value,
|
Value = Self::Value,
|
||||||
|
FuncId = Self::FuncId,
|
||||||
BasicBlock = Self::BasicBlock,
|
BasicBlock = Self::BasicBlock,
|
||||||
Type = Self::Type,
|
Type = Self::Type,
|
||||||
Funclet = Self::Funclet,
|
Funclet = Self::Funclet,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue