1
Fork 0

removes AbiMethods

This commit is contained in:
Saleem Jaffer 2019-05-14 21:23:01 +05:30
parent e1b3c79d5c
commit 44eb607d76
8 changed files with 29 additions and 39 deletions

View file

@ -12,8 +12,8 @@ use rustc_target::abi::call::ArgType;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use rustc_target::abi::{HasDataLayout, LayoutOf}; use rustc_target::abi::{HasDataLayout, LayoutOf};
use rustc::ty::{self, Ty, Instance}; use rustc::ty::{Ty};
use rustc::ty::layout::{self, FnTypeExt}; use rustc::ty::layout::{self};
use libc::c_uint; use libc::c_uint;
@ -471,22 +471,6 @@ impl<'tcx> FnTypeLlvmExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
} }
} }
impl AbiMethods<'tcx> for CodegenCx<'ll, 'tcx> {
fn new_fn_type(&self, sig: ty::FnSig<'tcx>, extra_args: &[Ty<'tcx>]) -> FnType<'tcx, Ty<'tcx>> {
FnType::new(self, sig, extra_args)
}
fn new_vtable(
&self,
sig: ty::FnSig<'tcx>,
extra_args: &[Ty<'tcx>]
) -> FnType<'tcx, Ty<'tcx>> {
FnType::new_vtable(self, sig, extra_args)
}
fn fn_type_of_instance(&self, instance: &Instance<'tcx>) -> FnType<'tcx, Ty<'tcx>> {
FnType::of_instance(self, instance)
}
}
impl AbiBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { impl AbiBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
fn apply_attrs_callsite( fn apply_attrs_callsite(
&mut self, &mut self,

View file

@ -18,6 +18,7 @@ use rustc_codegen_ssa::traits::*;
use rustc_codegen_ssa::base::to_immediate; use rustc_codegen_ssa::base::to_immediate;
use rustc_codegen_ssa::mir::operand::{OperandValue, OperandRef}; use rustc_codegen_ssa::mir::operand::{OperandValue, OperandRef};
use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::mir::place::PlaceRef;
use rustc_target::spec::{HasTargetSpec, Target};
use std::borrow::Cow; use std::borrow::Cow;
use std::ops::{Deref, Range}; use std::ops::{Deref, Range};
use std::ptr; use std::ptr;
@ -72,6 +73,12 @@ impl ty::layout::HasParamEnv<'tcx> for Builder<'_, '_, 'tcx> {
} }
} }
impl HasTargetSpec for Builder<'_, '_, 'tcx> {
fn target_spec(&self) -> &Target {
&self.cx.target_spec()
}
}
impl ty::layout::LayoutOf for Builder<'_, '_, 'tcx> { impl ty::layout::LayoutOf for Builder<'_, '_, 'tcx> {
type Ty = Ty<'tcx>; type Ty = Ty<'tcx>;
type TyLayout = TyLayout<'tcx>; type TyLayout = TyLayout<'tcx>;

View file

@ -100,7 +100,7 @@ impl DeclareMethods<'tcx> for CodegenCx<'ll, 'tcx> {
let sig = self.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig); let sig = self.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
debug!("declare_rust_fn (after region erasure) sig={:?}", sig); debug!("declare_rust_fn (after region erasure) sig={:?}", sig);
let fty= FnType::new(self, sig, &[]); let fty = FnType::new(self, sig, &[]);
let llfn = declare_raw_fn(self, name, fty.llvm_cconv(), fty.llvm_type(self)); let llfn = declare_raw_fn(self, name, fty.llvm_cconv(), fty.llvm_type(self));
if self.layout_of(sig.output()).abi.is_uninhabited() { if self.layout_of(sig.output()).abi.is_uninhabited() {

View file

@ -1,6 +1,6 @@
use rustc::middle::lang_items; use rustc::middle::lang_items;
use rustc::ty::{self, Ty, TypeFoldable}; use rustc::ty::{self, Ty, TypeFoldable};
use rustc::ty::layout::{self, LayoutOf, HasTyCtxt}; use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, FnTypeExt};
use rustc::mir::{self, Place, PlaceBase, Static, StaticKind}; use rustc::mir::{self, Place, PlaceBase, Static, StaticKind};
use rustc::mir::interpret::InterpError; use rustc::mir::interpret::InterpError;
use rustc_target::abi::call::{ArgType, FnType, PassMode, IgnoreMode}; 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> {
ty::ParamEnv::reveal_all(), ty::ParamEnv::reveal_all(),
&sig, &sig,
); );
let fn_ty = bx.new_vtable(sig, &[]); let fn_ty = FnType::new_vtable(&bx, sig, &[]);
let vtable = args[1]; let vtable = args[1];
args = &args[..1]; args = &args[..1];
(meth::DESTRUCTOR.get_fn(&mut bx, vtable, &fn_ty), fn_ty) (meth::DESTRUCTOR.get_fn(&mut bx, vtable, &fn_ty), fn_ty)
} }
_ => { _ => {
(bx.get_fn(drop_fn), (bx.get_fn(drop_fn),
bx.fn_type_of_instance(&drop_fn)) FnType::of_instance(&bx, &drop_fn))
} }
}; };
helper.do_call(self, &mut bx, fn_ty, drop_fn, args, 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> {
// Obtain the panic entry point. // Obtain the panic entry point.
let def_id = common::langcall(bx.tcx(), Some(span), "", lang_item); let def_id = common::langcall(bx.tcx(), Some(span), "", lang_item);
let instance = ty::Instance::mono(bx.tcx(), def_id); let instance = ty::Instance::mono(bx.tcx(), def_id);
let fn_ty = bx.fn_type_of_instance(&instance); let fn_ty = FnType::of_instance(&bx, &instance);
let llfn = bx.get_fn(instance); let llfn = bx.get_fn(instance);
// Codegen the actual panic invoke/call. // Codegen the actual panic invoke/call.
@ -518,7 +518,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let fn_ty = match def { let fn_ty = match def {
Some(ty::InstanceDef::Virtual(..)) => { Some(ty::InstanceDef::Virtual(..)) => {
bx.new_vtable(sig, &extra_args) FnType::new_vtable(&bx, sig, &extra_args)
} }
Some(ty::InstanceDef::DropGlue(_, None)) => { Some(ty::InstanceDef::DropGlue(_, None)) => {
// Empty drop glue; a no-op. // Empty drop glue; a no-op.
@ -526,7 +526,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
helper.funclet_br(self, &mut bx, target); helper.funclet_br(self, &mut bx, target);
return; return;
} }
_ => bx.new_fn_type(sig, &extra_args) _ => FnType::new(&bx, sig, &extra_args)
}; };
// Emit a panic or a no-op for `panic_if_uninhabited`. // 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> {
let def_id = let def_id =
common::langcall(bx.tcx(), Some(span), "", lang_items::PanicFnLangItem); common::langcall(bx.tcx(), Some(span), "", lang_items::PanicFnLangItem);
let instance = ty::Instance::mono(bx.tcx(), def_id); let instance = ty::Instance::mono(bx.tcx(), def_id);
let fn_ty = bx.fn_type_of_instance(&instance); let fn_ty = FnType::of_instance(&bx, &instance);
let llfn = bx.get_fn(instance); let llfn = bx.get_fn(instance);
// Codegen the actual panic invoke/call. // Codegen the actual panic invoke/call.

View file

@ -1,5 +1,5 @@
use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts}; use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts};
use rustc::ty::layout::{TyLayout, HasTyCtxt}; use rustc::ty::layout::{TyLayout, HasTyCtxt, FnTypeExt};
use rustc::mir::{self, Mir}; use rustc::mir::{self, Mir};
use rustc::session::config::DebugInfo; use rustc::session::config::DebugInfo;
use rustc_mir::monomorphize::Instance; use rustc_mir::monomorphize::Instance;
@ -202,7 +202,7 @@ pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
) { ) {
assert!(!instance.substs.needs_infer()); assert!(!instance.substs.needs_infer());
let fn_ty = cx.new_fn_type(sig, &[]); let fn_ty = FnType::new(cx, sig, &[]);
debug!("fn_ty: {:?}", fn_ty); debug!("fn_ty: {:?}", fn_ty);
let mut debug_context = let mut debug_context =
cx.create_function_debug_context(instance, sig, llfn, mir); cx.create_function_debug_context(instance, sig, llfn, mir);

View file

@ -1,13 +1,7 @@
use super::BackendTypes; use super::BackendTypes;
use rustc::ty::{FnSig, Instance, Ty}; use rustc::ty::{Ty};
use rustc_target::abi::call::FnType; use rustc_target::abi::call::FnType;
pub trait AbiMethods<'tcx> {
fn new_fn_type(&self, sig: FnSig<'tcx>, extra_args: &[Ty<'tcx>]) -> FnType<'tcx, Ty<'tcx>>;
fn new_vtable(&self, sig: FnSig<'tcx>, extra_args: &[Ty<'tcx>]) -> FnType<'tcx, Ty<'tcx>>;
fn fn_type_of_instance(&self, instance: &Instance<'tcx>) -> FnType<'tcx, Ty<'tcx>>;
}
pub trait AbiBuilderMethods<'tcx>: BackendTypes { pub trait AbiBuilderMethods<'tcx>: BackendTypes {
fn apply_attrs_callsite(&mut self, ty: &FnType<'tcx, Ty<'tcx>>, callsite: Self::Value); fn apply_attrs_callsite(&mut self, ty: &FnType<'tcx, Ty<'tcx>>, callsite: Self::Value);
fn get_param(&self, index: usize) -> Self::Value; fn get_param(&self, index: usize) -> Self::Value;

View file

@ -11,6 +11,7 @@ use crate::mir::place::PlaceRef;
use crate::MemFlags; use crate::MemFlags;
use rustc::ty::Ty; use rustc::ty::Ty;
use rustc::ty::layout::{Align, Size, HasParamEnv}; use rustc::ty::layout::{Align, Size, HasParamEnv};
use rustc_target::spec::{HasTargetSpec};
use std::ops::Range; use std::ops::Range;
use std::iter::TrustedLen; use std::iter::TrustedLen;
@ -30,6 +31,7 @@ pub trait BuilderMethods<'a, 'tcx: 'a>:
+ AsmBuilderMethods<'tcx> + AsmBuilderMethods<'tcx>
+ StaticBuilderMethods<'tcx> + StaticBuilderMethods<'tcx>
+ HasParamEnv<'tcx> + HasParamEnv<'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::Value, name: &'b str) -> Self;

View file

@ -27,7 +27,7 @@ mod statics;
mod type_; mod type_;
mod write; mod write;
pub use self::abi::{AbiBuilderMethods, AbiMethods}; pub use self::abi::{AbiBuilderMethods};
pub use self::asm::{AsmBuilderMethods, AsmMethods}; pub use self::asm::{AsmBuilderMethods, AsmMethods};
pub use self::backend::{Backend, BackendTypes, ExtraBackendMethods}; pub use self::backend::{Backend, BackendTypes, ExtraBackendMethods};
pub use self::builder::{BuilderMethods, OverflowOp}; pub use self::builder::{BuilderMethods, OverflowOp};
@ -41,7 +41,8 @@ pub use self::type_::{
ArgTypeMethods, BaseTypeMethods, DerivedTypeMethods, LayoutTypeMethods, TypeMethods, ArgTypeMethods, BaseTypeMethods, DerivedTypeMethods, LayoutTypeMethods, TypeMethods,
}; };
pub use self::write::{ModuleBufferMethods, ThinBufferMethods, WriteBackendMethods}; pub use self::write::{ModuleBufferMethods, ThinBufferMethods, WriteBackendMethods};
use rustc::ty::layout::{HasParamEnv}; use rustc::ty::layout::{HasParamEnv, HasTyCtxt};
use rustc_target::spec::{HasTargetSpec};
use std::fmt; use std::fmt;
@ -56,11 +57,12 @@ pub trait CodegenMethods<'tcx>:
+ ConstMethods<'tcx> + ConstMethods<'tcx>
+ StaticMethods + StaticMethods
+ DebugInfoMethods<'tcx> + DebugInfoMethods<'tcx>
+ AbiMethods<'tcx>
+ DeclareMethods<'tcx> + DeclareMethods<'tcx>
+ AsmMethods<'tcx> + AsmMethods<'tcx>
+ PreDefineMethods<'tcx> + PreDefineMethods<'tcx>
+ HasParamEnv<'tcx> + HasParamEnv<'tcx>
+ HasTyCtxt<'tcx>
+ HasTargetSpec
{ {
} }
@ -71,11 +73,12 @@ impl<'tcx, T> CodegenMethods<'tcx> for T where
+ ConstMethods<'tcx> + ConstMethods<'tcx>
+ StaticMethods + StaticMethods
+ DebugInfoMethods<'tcx> + DebugInfoMethods<'tcx>
+ AbiMethods<'tcx>
+ DeclareMethods<'tcx> + DeclareMethods<'tcx>
+ AsmMethods<'tcx> + AsmMethods<'tcx>
+ PreDefineMethods<'tcx> + PreDefineMethods<'tcx>
+ HasParamEnv<'tcx> + HasParamEnv<'tcx>
+ HasTyCtxt<'tcx>
+ HasTargetSpec
{ {
} }