Skip to content

Commit

Permalink
Move DefLocation from rustc_codegen_ssa to rustc_middle
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiasko committed Oct 5, 2023
1 parent 6c348b7 commit 4357482
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
17 changes: 1 addition & 16 deletions compiler/rustc_codegen_ssa/src/mir/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>(
Expand Down Expand Up @@ -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>,
Expand Down
17 changes: 17 additions & 0 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4357482

Please sign in to comment.