Skip to content

Commit 44eb607

Browse files
committed
removes AbiMethods
1 parent e1b3c79 commit 44eb607

File tree

8 files changed

+29
-39
lines changed

8 files changed

+29
-39
lines changed

src/librustc_codegen_llvm/abi.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use rustc_target::abi::call::ArgType;
1212
use rustc_codegen_ssa::traits::*;
1313

1414
use rustc_target::abi::{HasDataLayout, LayoutOf};
15-
use rustc::ty::{self, Ty, Instance};
16-
use rustc::ty::layout::{self, FnTypeExt};
15+
use rustc::ty::{Ty};
16+
use rustc::ty::layout::{self};
1717

1818
use libc::c_uint;
1919

@@ -471,22 +471,6 @@ impl<'tcx> FnTypeLlvmExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
471471
}
472472
}
473473

474-
impl AbiMethods<'tcx> for CodegenCx<'ll, 'tcx> {
475-
fn new_fn_type(&self, sig: ty::FnSig<'tcx>, extra_args: &[Ty<'tcx>]) -> FnType<'tcx, Ty<'tcx>> {
476-
FnType::new(self, sig, extra_args)
477-
}
478-
fn new_vtable(
479-
&self,
480-
sig: ty::FnSig<'tcx>,
481-
extra_args: &[Ty<'tcx>]
482-
) -> FnType<'tcx, Ty<'tcx>> {
483-
FnType::new_vtable(self, sig, extra_args)
484-
}
485-
fn fn_type_of_instance(&self, instance: &Instance<'tcx>) -> FnType<'tcx, Ty<'tcx>> {
486-
FnType::of_instance(self, instance)
487-
}
488-
}
489-
490474
impl AbiBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
491475
fn apply_attrs_callsite(
492476
&mut self,

src/librustc_codegen_llvm/builder.rs

+7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_codegen_ssa::traits::*;
1818
use rustc_codegen_ssa::base::to_immediate;
1919
use rustc_codegen_ssa::mir::operand::{OperandValue, OperandRef};
2020
use rustc_codegen_ssa::mir::place::PlaceRef;
21+
use rustc_target::spec::{HasTargetSpec, Target};
2122
use std::borrow::Cow;
2223
use std::ops::{Deref, Range};
2324
use std::ptr;
@@ -72,6 +73,12 @@ impl ty::layout::HasParamEnv<'tcx> for Builder<'_, '_, 'tcx> {
7273
}
7374
}
7475

76+
impl HasTargetSpec for Builder<'_, '_, 'tcx> {
77+
fn target_spec(&self) -> &Target {
78+
&self.cx.target_spec()
79+
}
80+
}
81+
7582
impl ty::layout::LayoutOf for Builder<'_, '_, 'tcx> {
7683
type Ty = Ty<'tcx>;
7784
type TyLayout = TyLayout<'tcx>;

src/librustc_codegen_llvm/declare.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl DeclareMethods<'tcx> for CodegenCx<'ll, 'tcx> {
100100
let sig = self.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
101101
debug!("declare_rust_fn (after region erasure) sig={:?}", sig);
102102

103-
let fty= FnType::new(self, sig, &[]);
103+
let fty = FnType::new(self, sig, &[]);
104104
let llfn = declare_raw_fn(self, name, fty.llvm_cconv(), fty.llvm_type(self));
105105

106106
if self.layout_of(sig.output()).abi.is_uninhabited() {

src/librustc_codegen_ssa/mir/block.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc::middle::lang_items;
22
use rustc::ty::{self, Ty, TypeFoldable};
3-
use rustc::ty::layout::{self, LayoutOf, HasTyCtxt};
3+
use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, FnTypeExt};
44
use rustc::mir::{self, Place, PlaceBase, Static, StaticKind};
55
use rustc::mir::interpret::InterpError;
66
use rustc_target::abi::call::{ArgType, FnType, PassMode, IgnoreMode};
@@ -334,14 +334,14 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
334334
ty::ParamEnv::reveal_all(),
335335
&sig,
336336
);
337-
let fn_ty = bx.new_vtable(sig, &[]);
337+
let fn_ty = FnType::new_vtable(&bx, sig, &[]);
338338
let vtable = args[1];
339339
args = &args[..1];
340340
(meth::DESTRUCTOR.get_fn(&mut bx, vtable, &fn_ty), fn_ty)
341341
}
342342
_ => {
343343
(bx.get_fn(drop_fn),
344-
bx.fn_type_of_instance(&drop_fn))
344+
FnType::of_instance(&bx, &drop_fn))
345345
}
346346
};
347347
helper.do_call(self, &mut bx, fn_ty, drop_fn, args,
@@ -439,7 +439,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
439439
// Obtain the panic entry point.
440440
let def_id = common::langcall(bx.tcx(), Some(span), "", lang_item);
441441
let instance = ty::Instance::mono(bx.tcx(), def_id);
442-
let fn_ty = bx.fn_type_of_instance(&instance);
442+
let fn_ty = FnType::of_instance(&bx, &instance);
443443
let llfn = bx.get_fn(instance);
444444

445445
// Codegen the actual panic invoke/call.
@@ -518,15 +518,15 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
518518

519519
let fn_ty = match def {
520520
Some(ty::InstanceDef::Virtual(..)) => {
521-
bx.new_vtable(sig, &extra_args)
521+
FnType::new_vtable(&bx, sig, &extra_args)
522522
}
523523
Some(ty::InstanceDef::DropGlue(_, None)) => {
524524
// Empty drop glue; a no-op.
525525
let &(_, target) = destination.as_ref().unwrap();
526526
helper.funclet_br(self, &mut bx, target);
527527
return;
528528
}
529-
_ => bx.new_fn_type(sig, &extra_args)
529+
_ => FnType::new(&bx, sig, &extra_args)
530530
};
531531

532532
// Emit a panic or a no-op for `panic_if_uninhabited`.
@@ -556,7 +556,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
556556
let def_id =
557557
common::langcall(bx.tcx(), Some(span), "", lang_items::PanicFnLangItem);
558558
let instance = ty::Instance::mono(bx.tcx(), def_id);
559-
let fn_ty = bx.fn_type_of_instance(&instance);
559+
let fn_ty = FnType::of_instance(&bx, &instance);
560560
let llfn = bx.get_fn(instance);
561561

562562
// Codegen the actual panic invoke/call.

src/librustc_codegen_ssa/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts};
2-
use rustc::ty::layout::{TyLayout, HasTyCtxt};
2+
use rustc::ty::layout::{TyLayout, HasTyCtxt, FnTypeExt};
33
use rustc::mir::{self, Mir};
44
use rustc::session::config::DebugInfo;
55
use rustc_mir::monomorphize::Instance;
@@ -202,7 +202,7 @@ pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
202202
) {
203203
assert!(!instance.substs.needs_infer());
204204

205-
let fn_ty = cx.new_fn_type(sig, &[]);
205+
let fn_ty = FnType::new(cx, sig, &[]);
206206
debug!("fn_ty: {:?}", fn_ty);
207207
let mut debug_context =
208208
cx.create_function_debug_context(instance, sig, llfn, mir);

src/librustc_codegen_ssa/traits/abi.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
use super::BackendTypes;
2-
use rustc::ty::{FnSig, Instance, Ty};
2+
use rustc::ty::{Ty};
33
use rustc_target::abi::call::FnType;
44

5-
pub trait AbiMethods<'tcx> {
6-
fn new_fn_type(&self, sig: FnSig<'tcx>, extra_args: &[Ty<'tcx>]) -> FnType<'tcx, Ty<'tcx>>;
7-
fn new_vtable(&self, sig: FnSig<'tcx>, extra_args: &[Ty<'tcx>]) -> FnType<'tcx, Ty<'tcx>>;
8-
fn fn_type_of_instance(&self, instance: &Instance<'tcx>) -> FnType<'tcx, Ty<'tcx>>;
9-
}
10-
115
pub trait AbiBuilderMethods<'tcx>: BackendTypes {
126
fn apply_attrs_callsite(&mut self, ty: &FnType<'tcx, Ty<'tcx>>, callsite: Self::Value);
137
fn get_param(&self, index: usize) -> Self::Value;

src/librustc_codegen_ssa/traits/builder.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use crate::mir::place::PlaceRef;
1111
use crate::MemFlags;
1212
use rustc::ty::Ty;
1313
use rustc::ty::layout::{Align, Size, HasParamEnv};
14+
use rustc_target::spec::{HasTargetSpec};
1415
use std::ops::Range;
1516
use std::iter::TrustedLen;
1617

@@ -30,6 +31,7 @@ pub trait BuilderMethods<'a, 'tcx: 'a>:
3031
+ AsmBuilderMethods<'tcx>
3132
+ StaticBuilderMethods<'tcx>
3233
+ HasParamEnv<'tcx>
34+
+ HasTargetSpec
3335

3436
{
3537
fn new_block<'b>(cx: &'a Self::CodegenCx, llfn: Self::Value, name: &'b str) -> Self;

src/librustc_codegen_ssa/traits/mod.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mod statics;
2727
mod type_;
2828
mod write;
2929

30-
pub use self::abi::{AbiBuilderMethods, AbiMethods};
30+
pub use self::abi::{AbiBuilderMethods};
3131
pub use self::asm::{AsmBuilderMethods, AsmMethods};
3232
pub use self::backend::{Backend, BackendTypes, ExtraBackendMethods};
3333
pub use self::builder::{BuilderMethods, OverflowOp};
@@ -41,7 +41,8 @@ pub use self::type_::{
4141
ArgTypeMethods, BaseTypeMethods, DerivedTypeMethods, LayoutTypeMethods, TypeMethods,
4242
};
4343
pub use self::write::{ModuleBufferMethods, ThinBufferMethods, WriteBackendMethods};
44-
use rustc::ty::layout::{HasParamEnv};
44+
use rustc::ty::layout::{HasParamEnv, HasTyCtxt};
45+
use rustc_target::spec::{HasTargetSpec};
4546

4647

4748
use std::fmt;
@@ -56,11 +57,12 @@ pub trait CodegenMethods<'tcx>:
5657
+ ConstMethods<'tcx>
5758
+ StaticMethods
5859
+ DebugInfoMethods<'tcx>
59-
+ AbiMethods<'tcx>
6060
+ DeclareMethods<'tcx>
6161
+ AsmMethods<'tcx>
6262
+ PreDefineMethods<'tcx>
6363
+ HasParamEnv<'tcx>
64+
+ HasTyCtxt<'tcx>
65+
+ HasTargetSpec
6466
{
6567
}
6668

@@ -71,11 +73,12 @@ impl<'tcx, T> CodegenMethods<'tcx> for T where
7173
+ ConstMethods<'tcx>
7274
+ StaticMethods
7375
+ DebugInfoMethods<'tcx>
74-
+ AbiMethods<'tcx>
7576
+ DeclareMethods<'tcx>
7677
+ AsmMethods<'tcx>
7778
+ PreDefineMethods<'tcx>
7879
+ HasParamEnv<'tcx>
80+
+ HasTyCtxt<'tcx>
81+
+ HasTargetSpec
7982
{
8083
}
8184

0 commit comments

Comments
 (0)