mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Remove Backend
.
It's a trait that aggregates five other traits. But consider the places that use it. - `BuilderMethods`: requires three of the five traits. - `CodegenMethods`: requires zero(!) of the five traits. - `BaseTypeMethods`: requires two of the five traits. - `LayoutTypeMethods`: requires three of the five traits. - `TypeMembershipMethods`: requires one of the five traits. This commit just removes it, which makes everything simpler.
This commit is contained in:
parent
5f98943b5a
commit
928d8e6951
@ -8,13 +8,11 @@ use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_metadata::creader::MetadataLoaderDyn;
|
||||
use rustc_metadata::EncodedMetadata;
|
||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout};
|
||||
use rustc_middle::ty::{Ty, TyCtxt};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_middle::util::Providers;
|
||||
use rustc_session::config::{self, OutputFilenames, PrintRequest};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_target::abi::call::FnAbi;
|
||||
|
||||
use super::write::WriteBackendMethods;
|
||||
use super::CodegenObject;
|
||||
@ -36,12 +34,6 @@ pub trait BackendTypes {
|
||||
type DIVariable: Copy;
|
||||
}
|
||||
|
||||
pub trait Backend<'tcx> = Sized
|
||||
+ BackendTypes
|
||||
+ HasTyCtxt<'tcx>
|
||||
+ LayoutOf<'tcx, LayoutOfResult = TyAndLayout<'tcx>>
|
||||
+ FnAbiOf<'tcx, FnAbiOfResult = &'tcx FnAbi<'tcx, Ty<'tcx>>>;
|
||||
|
||||
pub trait CodegenBackend {
|
||||
/// Locale resources for diagnostic messages - a string the content of the Fluent resource.
|
||||
/// Called before `init` so that all other functions are able to emit translatable diagnostics.
|
||||
|
@ -2,7 +2,7 @@ use std::assert_matches::assert_matches;
|
||||
use std::ops::Deref;
|
||||
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
|
||||
use rustc_middle::ty::layout::{HasParamEnv, TyAndLayout};
|
||||
use rustc_middle::ty::layout::{FnAbiOf, HasParamEnv, LayoutOf, TyAndLayout};
|
||||
use rustc_middle::ty::{Instance, Ty};
|
||||
use rustc_session::config::OptLevel;
|
||||
use rustc_span::Span;
|
||||
@ -18,7 +18,7 @@ use super::debuginfo::DebugInfoBuilderMethods;
|
||||
use super::intrinsic::IntrinsicCallMethods;
|
||||
use super::misc::MiscMethods;
|
||||
use super::type_::{ArgAbiMethods, BaseTypeMethods, LayoutTypeMethods};
|
||||
use super::{Backend, BackendTypes, CodegenMethods, StaticBuilderMethods};
|
||||
use super::{BackendTypes, CodegenMethods, StaticBuilderMethods};
|
||||
use crate::common::{
|
||||
AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind,
|
||||
};
|
||||
@ -34,7 +34,9 @@ pub enum OverflowOp {
|
||||
}
|
||||
|
||||
pub trait BuilderMethods<'a, 'tcx>:
|
||||
Backend<'tcx>
|
||||
Sized
|
||||
+ LayoutOf<'tcx, LayoutOfResult = TyAndLayout<'tcx>>
|
||||
+ FnAbiOf<'tcx, FnAbiOfResult = &'tcx FnAbi<'tcx, Ty<'tcx>>>
|
||||
+ Deref<Target = Self::CodegenCx>
|
||||
+ CoverageInfoBuilderMethods<'tcx>
|
||||
+ DebugInfoBuilderMethods
|
||||
|
@ -8,9 +8,6 @@
|
||||
//! actual codegen, while the builder stores the information about the function during codegen and
|
||||
//! is used to produce the instructions of the backend IR.
|
||||
//!
|
||||
//! Finally, a third `Backend` structure has to implement methods related to how codegen information
|
||||
//! is passed to the backend, especially for asynchronous compilation.
|
||||
//!
|
||||
//! The traits contain associated types that are backend-specific, such as the backend's value or
|
||||
//! basic blocks.
|
||||
|
||||
@ -35,7 +32,7 @@ use rustc_target::spec::HasTargetSpec;
|
||||
|
||||
pub use self::abi::AbiBuilderMethods;
|
||||
pub use self::asm::{AsmBuilderMethods, AsmMethods, GlobalAsmOperandRef, InlineAsmOperandRef};
|
||||
pub use self::backend::{Backend, BackendTypes, CodegenBackend, ExtraBackendMethods};
|
||||
pub use self::backend::{BackendTypes, CodegenBackend, ExtraBackendMethods};
|
||||
pub use self::builder::{BuilderMethods, OverflowOp};
|
||||
pub use self::consts::ConstMethods;
|
||||
pub use self::coverageinfo::CoverageInfoBuilderMethods;
|
||||
@ -52,8 +49,7 @@ pub use self::write::{ModuleBufferMethods, ThinBufferMethods, WriteBackendMethod
|
||||
|
||||
pub trait CodegenObject = Copy + PartialEq + fmt::Debug;
|
||||
|
||||
pub trait CodegenMethods<'tcx> = Backend<'tcx>
|
||||
+ TypeMethods<'tcx>
|
||||
pub trait CodegenMethods<'tcx> = TypeMethods<'tcx>
|
||||
+ MiscMethods<'tcx>
|
||||
+ ConstMethods<'tcx>
|
||||
+ StaticMethods
|
||||
|
@ -1,17 +1,15 @@
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg};
|
||||
use rustc_target::abi::{AddressSpace, Float, Integer};
|
||||
|
||||
use super::misc::MiscMethods;
|
||||
use super::{Backend, BackendTypes};
|
||||
use super::BackendTypes;
|
||||
use crate::common::TypeKind;
|
||||
use crate::mir::place::PlaceRef;
|
||||
|
||||
// This depends on `Backend` and not `BackendTypes`, because consumers will probably want to use
|
||||
// `LayoutOf` or `HasTyCtxt`. This way, they don't have to add a constraint on it themselves.
|
||||
pub trait BaseTypeMethods<'tcx>: Backend<'tcx> {
|
||||
pub trait BaseTypeMethods<'tcx>: BackendTypes + HasTyCtxt<'tcx> {
|
||||
fn type_i8(&self) -> Self::Type;
|
||||
fn type_i16(&self) -> Self::Type;
|
||||
fn type_i32(&self) -> Self::Type;
|
||||
@ -102,7 +100,11 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
|
||||
|
||||
impl<'tcx, T> DerivedTypeMethods<'tcx> for T where Self: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {}
|
||||
|
||||
pub trait LayoutTypeMethods<'tcx>: Backend<'tcx> {
|
||||
pub trait LayoutTypeMethods<'tcx>:
|
||||
BackendTypes
|
||||
+ LayoutOf<'tcx, LayoutOfResult = TyAndLayout<'tcx>>
|
||||
+ FnAbiOf<'tcx, FnAbiOfResult = &'tcx FnAbi<'tcx, Ty<'tcx>>>
|
||||
{
|
||||
/// The backend type used for a rust type when it's in memory,
|
||||
/// such as when it's stack-allocated or when it's being loaded or stored.
|
||||
fn backend_type(&self, layout: TyAndLayout<'tcx>) -> Self::Type;
|
||||
@ -146,7 +148,7 @@ pub trait LayoutTypeMethods<'tcx>: Backend<'tcx> {
|
||||
|
||||
// For backends that support CFI using type membership (i.e., testing whether a given pointer is
|
||||
// associated with a type identifier).
|
||||
pub trait TypeMembershipMethods<'tcx>: Backend<'tcx> {
|
||||
pub trait TypeMembershipMethods<'tcx>: BackendTypes {
|
||||
fn add_type_metadata(&self, _function: Self::Function, _typeid: String) {}
|
||||
fn set_type_metadata(&self, _function: Self::Function, _typeid: String) {}
|
||||
fn typeid_metadata(&self, _typeid: String) -> Option<Self::Value> {
|
||||
|
Loading…
Reference in New Issue
Block a user