Skip to content

Commit 4d1a5ad

Browse files
committed
Introduce FuncId backend type
1 parent 29b6e0f commit 4d1a5ad

File tree

10 files changed

+16
-10
lines changed

10 files changed

+16
-10
lines changed

src/librustc_codegen_llvm/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const UNNAMED: *const c_char = EMPTY_C_STR.as_ptr();
5252

5353
impl BackendTypes for Builder<'_, 'll, 'tcx> {
5454
type Value = <CodegenCx<'ll, 'tcx> as BackendTypes>::Value;
55+
type FuncId = <CodegenCx<'ll, 'tcx> as BackendTypes>::FuncId;
5556
type BasicBlock = <CodegenCx<'ll, 'tcx> as BackendTypes>::BasicBlock;
5657
type Type = <CodegenCx<'ll, 'tcx> as BackendTypes>::Type;
5758
type Funclet = <CodegenCx<'ll, 'tcx> as BackendTypes>::Funclet;

src/librustc_codegen_llvm/common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ impl Funclet<'ll> {
8686

8787
impl BackendTypes for CodegenCx<'ll, 'tcx> {
8888
type Value = &'ll Value;
89+
type FuncId = &'ll Value;
90+
8991
type BasicBlock = &'ll BasicBlock;
9092
type Type = &'ll Type;
9193
type Funclet = Funclet<'ll>;

src/librustc_codegen_ssa/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub trait BuilderMethods<'a, 'tcx>:
8484
{
8585
fn new_block<'b>(
8686
cx: &'a Self::CodegenCx,
87-
llfn: Self::Value,
87+
llfn: Self::FuncId,
8888
name: &'b str
8989
) -> Self;
9090
/* ... */

src/librustc_codegen_ssa/mir/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
3030

3131
debug_context: FunctionDebugContext<Bx::DIScope>,
3232

33-
llfn: Bx::Value,
33+
llfn: Bx::FuncId,
3434

3535
cx: &'a Bx::CodegenCx,
3636

@@ -183,7 +183,7 @@ impl<'a, 'tcx, V: CodegenObject> LocalRef<'tcx, V> {
183183

184184
pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
185185
cx: &'a Bx::CodegenCx,
186-
llfn: Bx::Value,
186+
llfn: Bx::FuncId,
187187
mir: &'a Body<'tcx>,
188188
instance: Instance<'tcx>,
189189
sig: ty::FnSig<'tcx>,

src/librustc_codegen_ssa/traits/backend.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use syntax_pos::symbol::InternedString;
1414

1515
pub trait BackendTypes {
1616
type Value: CodegenObject;
17+
type FuncId: CodegenObject;
18+
1719
type BasicBlock: Copy;
1820
type Type: CodegenObject;
1921
type Funclet;

src/librustc_codegen_ssa/traits/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub trait BuilderMethods<'a, 'tcx>:
3434
+ HasTargetSpec
3535

3636
{
37-
fn new_block<'b>(cx: &'a Self::CodegenCx, llfn: Self::Value, name: &'b str) -> Self;
37+
fn new_block<'b>(cx: &'a Self::CodegenCx, llfn: Self::FuncId, name: &'b str) -> Self;
3838
fn with_cx(cx: &'a Self::CodegenCx) -> Self;
3939
fn build_sibling_block(&self, name: &str) -> Self;
4040
fn cx(&self) -> &Self::CodegenCx;

src/librustc_codegen_ssa/traits/debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub trait DebugInfoMethods<'tcx>: BackendTypes {
2020
&self,
2121
instance: Instance<'tcx>,
2222
sig: ty::FnSig<'tcx>,
23-
llfn: Self::Value,
23+
llfn: Self::FuncId,
2424
mir: &mir::Body<'_>,
2525
) -> FunctionDebugContext<Self::DIScope>;
2626

src/librustc_codegen_ssa/traits/declare.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ pub trait DeclareMethods<'tcx>: BackendTypes {
1717
///
1818
/// If there’s a value with the same name already declared, the function will
1919
/// update the declaration and return existing Value instead.
20-
fn declare_cfn(&self, name: &str, fn_type: Self::Type) -> Self::Value;
20+
fn declare_cfn(&self, name: &str, fn_type: Self::Type) -> Self::FuncId;
2121

2222
/// Declare a Rust function.
2323
///
2424
/// If there’s a value with the same name already declared, the function will
2525
/// update the declaration and return existing Value instead.
26-
fn declare_fn(&self, name: &str, sig: ty::PolyFnSig<'tcx>) -> Self::Value;
26+
fn declare_fn(&self, name: &str, sig: ty::PolyFnSig<'tcx>) -> Self::FuncId;
2727

2828
/// Declare a global with an intention to define it.
2929
///

src/librustc_codegen_ssa/traits/misc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ pub trait MiscMethods<'tcx>: BackendTypes {
1111
&self,
1212
) -> &RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), Self::Value>>;
1313
fn check_overflow(&self) -> bool;
14-
fn instances(&self) -> &RefCell<FxHashMap<Instance<'tcx>, Self::Value>>;
14+
fn instances(&self) -> &RefCell<FxHashMap<Instance<'tcx>, Self::FuncId>>;
1515
fn get_fn(&self, instance: Instance<'tcx>) -> Self::Value;
1616
fn eh_personality(&self) -> Self::Value;
1717
fn eh_unwind_resume(&self) -> Self::Value;
1818
fn sess(&self) -> &Session;
1919
fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>>;
2020
fn used_statics(&self) -> &RefCell<Vec<Self::Value>>;
21-
fn set_frame_pointer_elimination(&self, llfn: Self::Value);
22-
fn apply_target_cpu_attr(&self, llfn: Self::Value);
21+
fn set_frame_pointer_elimination(&self, llfn: Self::FuncId);
22+
fn apply_target_cpu_attr(&self, llfn: Self::FuncId);
2323
fn create_used_variable(&self);
2424
}

src/librustc_codegen_ssa/traits/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ pub trait HasCodegen<'tcx>:
8888
type CodegenCx: CodegenMethods<'tcx>
8989
+ BackendTypes<
9090
Value = Self::Value,
91+
FuncId = Self::FuncId,
9192
BasicBlock = Self::BasicBlock,
9293
Type = Self::Type,
9394
Funclet = Self::Funclet,

0 commit comments

Comments
 (0)