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
4 changed files with 22 additions and 28 deletions
|
@ -14,8 +14,8 @@ use rustc_codegen_ssa::common::{
|
||||||
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
|
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
|
||||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||||
use rustc_codegen_ssa::traits::{
|
use rustc_codegen_ssa::traits::{
|
||||||
BackendTypes, BaseTypeMethods, BuilderMethods, ConstMethods, HasCodegen, LayoutTypeMethods,
|
BackendTypes, BaseTypeMethods, BuilderMethods, ConstMethods, LayoutTypeMethods, OverflowOp,
|
||||||
OverflowOp, StaticBuilderMethods,
|
StaticBuilderMethods,
|
||||||
};
|
};
|
||||||
use rustc_codegen_ssa::MemFlags;
|
use rustc_codegen_ssa::MemFlags;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
|
@ -460,10 +460,6 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gcc, 'tcx> HasCodegen<'tcx> for Builder<'_, 'gcc, 'tcx> {
|
|
||||||
type CodegenCx = CodegenCx<'gcc, 'tcx>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> HasTyCtxt<'tcx> for Builder<'_, '_, 'tcx> {
|
impl<'tcx> HasTyCtxt<'tcx> for Builder<'_, '_, 'tcx> {
|
||||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||||
self.cx.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> {
|
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> {
|
fn build(cx: &'a CodegenCx<'gcc, 'tcx>, block: Block<'gcc>) -> Builder<'a, 'gcc, 'tcx> {
|
||||||
Builder::with_cx(cx, block)
|
Builder::with_cx(cx, block)
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,10 +124,6 @@ impl<'ll, 'tcx> Deref for Builder<'_, 'll, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ll, 'tcx> HasCodegen<'tcx> for Builder<'_, 'll, 'tcx> {
|
|
||||||
type CodegenCx = CodegenCx<'ll, 'tcx>;
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! builder_methods_for_value_instructions {
|
macro_rules! builder_methods_for_value_instructions {
|
||||||
($($name:ident($($arg:ident),*) => $llvm_capi:ident),+ $(,)?) => {
|
($($name:ident($($arg:ident),*) => $llvm_capi:ident),+ $(,)?) => {
|
||||||
$(fn $name(&mut self, $($arg: &'ll Value),*) -> &'ll Value {
|
$(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> {
|
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 {
|
fn build(cx: &'a CodegenCx<'ll, 'tcx>, llbb: &'ll BasicBlock) -> Self {
|
||||||
let bx = Builder::with_cx(cx);
|
let bx = Builder::with_cx(cx);
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::assert_matches::assert_matches;
|
use std::assert_matches::assert_matches;
|
||||||
|
use std::ops::Deref;
|
||||||
|
|
||||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
|
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
|
||||||
use rustc_middle::ty::layout::{HasParamEnv, TyAndLayout};
|
use rustc_middle::ty::layout::{HasParamEnv, TyAndLayout};
|
||||||
|
@ -17,7 +18,7 @@ use super::debuginfo::DebugInfoBuilderMethods;
|
||||||
use super::intrinsic::IntrinsicCallMethods;
|
use super::intrinsic::IntrinsicCallMethods;
|
||||||
use super::misc::MiscMethods;
|
use super::misc::MiscMethods;
|
||||||
use super::type_::{ArgAbiMethods, BaseTypeMethods, LayoutTypeMethods};
|
use super::type_::{ArgAbiMethods, BaseTypeMethods, LayoutTypeMethods};
|
||||||
use super::{HasCodegen, StaticBuilderMethods};
|
use super::{Backend, BackendTypes, CodegenMethods, StaticBuilderMethods};
|
||||||
use crate::common::{
|
use crate::common::{
|
||||||
AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind,
|
AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind,
|
||||||
};
|
};
|
||||||
|
@ -33,7 +34,8 @@ pub enum OverflowOp {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait BuilderMethods<'a, 'tcx>:
|
pub trait BuilderMethods<'a, 'tcx>:
|
||||||
HasCodegen<'tcx>
|
Backend<'tcx>
|
||||||
|
+ Deref<Target = Self::CodegenCx>
|
||||||
+ CoverageInfoBuilderMethods<'tcx>
|
+ CoverageInfoBuilderMethods<'tcx>
|
||||||
+ DebugInfoBuilderMethods
|
+ DebugInfoBuilderMethods
|
||||||
+ ArgAbiMethods<'tcx>
|
+ ArgAbiMethods<'tcx>
|
||||||
|
@ -44,6 +46,18 @@ pub trait BuilderMethods<'a, 'tcx>:
|
||||||
+ HasParamEnv<'tcx>
|
+ HasParamEnv<'tcx>
|
||||||
+ HasTargetSpec
|
+ 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 build(cx: &'a Self::CodegenCx, llbb: Self::BasicBlock) -> Self;
|
||||||
|
|
||||||
fn cx(&self) -> &Self::CodegenCx;
|
fn cx(&self) -> &Self::CodegenCx;
|
||||||
|
|
|
@ -63,19 +63,3 @@ pub trait CodegenMethods<'tcx> = Backend<'tcx>
|
||||||
+ HasParamEnv<'tcx>
|
+ HasParamEnv<'tcx>
|
||||||
+ HasTyCtxt<'tcx>
|
+ HasTyCtxt<'tcx>
|
||||||
+ HasTargetSpec;
|
+ 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…
Add table
Add a link
Reference in a new issue