Merge HasCodegen
into BuilderMethods
.
It has `Backend` and `Deref` boudns, plus an associated type `CodegenCx`, and it has a single use. This commit "inlines" it into `BuilderMethods`, which makes the complicated backend trait situation a little simpler.
This commit is contained in:
parent
47830edc33
commit
5f98943b5a
@ -14,8 +14,8 @@
|
||||
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
|
||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||
use rustc_codegen_ssa::traits::{
|
||||
BackendTypes, BaseTypeMethods, BuilderMethods, ConstMethods, HasCodegen, LayoutTypeMethods,
|
||||
OverflowOp, StaticBuilderMethods,
|
||||
BackendTypes, BaseTypeMethods, BuilderMethods, ConstMethods, LayoutTypeMethods, OverflowOp,
|
||||
StaticBuilderMethods,
|
||||
};
|
||||
use rustc_codegen_ssa::MemFlags;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
@ -460,10 +460,6 @@ pub fn overflow_call(
|
||||
}
|
||||
}
|
||||
|
||||
impl<'gcc, 'tcx> HasCodegen<'tcx> for Builder<'_, 'gcc, 'tcx> {
|
||||
type CodegenCx = CodegenCx<'gcc, 'tcx>;
|
||||
}
|
||||
|
||||
impl<'tcx> HasTyCtxt<'tcx> for Builder<'_, '_, 'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
self.cx.tcx()
|
||||
@ -531,6 +527,8 @@ fn set_rvalue_location<'a, 'gcc, 'tcx>(
|
||||
}
|
||||
|
||||
impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||
type CodegenCx = CodegenCx<'gcc, 'tcx>;
|
||||
|
||||
fn build(cx: &'a CodegenCx<'gcc, 'tcx>, block: Block<'gcc>) -> Builder<'a, 'gcc, 'tcx> {
|
||||
Builder::with_cx(cx, block)
|
||||
}
|
||||
|
@ -124,10 +124,6 @@ fn deref(&self) -> &Self::Target {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ll, 'tcx> HasCodegen<'tcx> for Builder<'_, 'll, 'tcx> {
|
||||
type CodegenCx = CodegenCx<'ll, 'tcx>;
|
||||
}
|
||||
|
||||
macro_rules! builder_methods_for_value_instructions {
|
||||
($($name:ident($($arg:ident),*) => $llvm_capi:ident),+ $(,)?) => {
|
||||
$(fn $name(&mut self, $($arg: &'ll Value),*) -> &'ll Value {
|
||||
@ -139,6 +135,8 @@ macro_rules! builder_methods_for_value_instructions {
|
||||
}
|
||||
|
||||
impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
type CodegenCx = CodegenCx<'ll, 'tcx>;
|
||||
|
||||
fn build(cx: &'a CodegenCx<'ll, 'tcx>, llbb: &'ll BasicBlock) -> Self {
|
||||
let bx = Builder::with_cx(cx);
|
||||
unsafe {
|
||||
|
@ -1,4 +1,5 @@
|
||||
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};
|
||||
@ -17,7 +18,7 @@
|
||||
use super::intrinsic::IntrinsicCallMethods;
|
||||
use super::misc::MiscMethods;
|
||||
use super::type_::{ArgAbiMethods, BaseTypeMethods, LayoutTypeMethods};
|
||||
use super::{HasCodegen, StaticBuilderMethods};
|
||||
use super::{Backend, BackendTypes, CodegenMethods, StaticBuilderMethods};
|
||||
use crate::common::{
|
||||
AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind,
|
||||
};
|
||||
@ -33,7 +34,8 @@ pub enum OverflowOp {
|
||||
}
|
||||
|
||||
pub trait BuilderMethods<'a, 'tcx>:
|
||||
HasCodegen<'tcx>
|
||||
Backend<'tcx>
|
||||
+ Deref<Target = Self::CodegenCx>
|
||||
+ CoverageInfoBuilderMethods<'tcx>
|
||||
+ DebugInfoBuilderMethods
|
||||
+ ArgAbiMethods<'tcx>
|
||||
@ -44,6 +46,18 @@ pub trait BuilderMethods<'a, 'tcx>:
|
||||
+ HasParamEnv<'tcx>
|
||||
+ HasTargetSpec
|
||||
{
|
||||
type CodegenCx: CodegenMethods<'tcx>
|
||||
+ BackendTypes<
|
||||
Value = Self::Value,
|
||||
Function = Self::Function,
|
||||
BasicBlock = Self::BasicBlock,
|
||||
Type = Self::Type,
|
||||
Funclet = Self::Funclet,
|
||||
DIScope = Self::DIScope,
|
||||
DILocation = Self::DILocation,
|
||||
DIVariable = Self::DIVariable,
|
||||
>;
|
||||
|
||||
fn build(cx: &'a Self::CodegenCx, llbb: Self::BasicBlock) -> Self;
|
||||
|
||||
fn cx(&self) -> &Self::CodegenCx;
|
||||
|
@ -63,19 +63,3 @@ pub trait CodegenMethods<'tcx> = Backend<'tcx>
|
||||
+ HasParamEnv<'tcx>
|
||||
+ HasTyCtxt<'tcx>
|
||||
+ HasTargetSpec;
|
||||
|
||||
pub trait HasCodegen<'tcx>:
|
||||
Backend<'tcx> + std::ops::Deref<Target = <Self as HasCodegen<'tcx>>::CodegenCx>
|
||||
{
|
||||
type CodegenCx: CodegenMethods<'tcx>
|
||||
+ BackendTypes<
|
||||
Value = Self::Value,
|
||||
Function = Self::Function,
|
||||
BasicBlock = Self::BasicBlock,
|
||||
Type = Self::Type,
|
||||
Funclet = Self::Funclet,
|
||||
DIScope = Self::DIScope,
|
||||
DILocation = Self::DILocation,
|
||||
DIVariable = Self::DIVariable,
|
||||
>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user