Move DefLocation from rustc_codegen_ssa to rustc_middle
This commit is contained in:
@@ -8,7 +8,7 @@ use rustc_index::bit_set::BitSet;
|
||||
use rustc_index::{IndexSlice, IndexVec};
|
||||
use rustc_middle::mir::traversal;
|
||||
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{self, Location, TerminatorKind};
|
||||
use rustc_middle::mir::{self, DefLocation, Location, TerminatorKind};
|
||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
|
||||
|
||||
pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
@@ -67,21 +67,6 @@ enum LocalKind {
|
||||
SSA(DefLocation),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
enum DefLocation {
|
||||
Argument,
|
||||
Body(Location),
|
||||
}
|
||||
|
||||
impl DefLocation {
|
||||
fn dominates(self, location: Location, dominators: &Dominators<mir::BasicBlock>) -> bool {
|
||||
match self {
|
||||
DefLocation::Argument => true,
|
||||
DefLocation::Body(def) => def.successor_within_block().dominates(location, dominators),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct LocalAnalyzer<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
|
||||
fx: &'mir FunctionCx<'a, 'tcx, Bx>,
|
||||
dominators: &'mir Dominators<mir::BasicBlock>,
|
||||
|
||||
@@ -1590,6 +1590,23 @@ impl Location {
|
||||
}
|
||||
}
|
||||
|
||||
/// `DefLocation` represents the location of a definition - either an argument or an assignment
|
||||
/// within MIR body.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum DefLocation {
|
||||
Argument,
|
||||
Body(Location),
|
||||
}
|
||||
|
||||
impl DefLocation {
|
||||
pub fn dominates(self, location: Location, dominators: &Dominators<BasicBlock>) -> bool {
|
||||
match self {
|
||||
DefLocation::Argument => true,
|
||||
DefLocation::Body(def) => def.successor_within_block().dominates(location, dominators),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
mod size_asserts {
|
||||
|
||||
Reference in New Issue
Block a user