rename MirPassSet
to MirSuite
This seems like a better noun.
This commit is contained in:
parent
2b32cb90c7
commit
e89a321dff
4 changed files with 49 additions and 49 deletions
|
@ -94,7 +94,7 @@ pub fn default_name<T: ?Sized>() -> Cow<'static, str> {
|
|||
pub trait MirCtxt<'a, 'tcx: 'a> {
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx>;
|
||||
fn def_id(&self) -> DefId;
|
||||
fn pass_set(&self) -> MirPassSet;
|
||||
fn suite(&self) -> MirSuite;
|
||||
fn pass_num(&self) -> MirPassIndex;
|
||||
fn source(&self) -> MirSource;
|
||||
fn read_previous_mir(&self) -> Ref<'tcx, Mir<'tcx>>;
|
||||
|
@ -102,7 +102,7 @@ pub trait MirCtxt<'a, 'tcx: 'a> {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct MirPassSet(pub usize);
|
||||
pub struct MirSuite(pub usize);
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct MirPassIndex(pub usize);
|
||||
|
@ -174,36 +174,36 @@ impl<T: MirPass> DefIdPass for T {
|
|||
#[derive(Clone)]
|
||||
pub struct Passes {
|
||||
pass_hooks: Vec<Rc<PassHook>>,
|
||||
sets: Vec<Vec<Rc<DefIdPass>>>,
|
||||
suites: Vec<Vec<Rc<DefIdPass>>>,
|
||||
}
|
||||
|
||||
/// The number of "pass sets" that we have:
|
||||
/// The number of "pass suites" that we have:
|
||||
///
|
||||
/// - ready for constant evaluation
|
||||
/// - unopt
|
||||
/// - optimized
|
||||
pub const MIR_PASS_SETS: usize = 3;
|
||||
pub const MIR_SUITES: usize = 3;
|
||||
|
||||
/// Run the passes we need to do constant qualification and evaluation.
|
||||
pub const MIR_CONST: MirPassSet = MirPassSet(0);
|
||||
pub const MIR_CONST: MirSuite = MirSuite(0);
|
||||
|
||||
/// Run the passes we need to consider the MIR validated and ready for borrowck etc.
|
||||
pub const MIR_VALIDATED: MirPassSet = MirPassSet(1);
|
||||
pub const MIR_VALIDATED: MirSuite = MirSuite(1);
|
||||
|
||||
/// Run the passes we need to consider the MIR *optimized*.
|
||||
pub const MIR_OPTIMIZED: MirPassSet = MirPassSet(2);
|
||||
pub const MIR_OPTIMIZED: MirSuite = MirSuite(2);
|
||||
|
||||
impl<'a, 'tcx> Passes {
|
||||
pub fn new() -> Passes {
|
||||
Passes {
|
||||
pass_hooks: Vec::new(),
|
||||
sets: (0..MIR_PASS_SETS).map(|_| Vec::new()).collect(),
|
||||
suites: (0..MIR_SUITES).map(|_| Vec::new()).collect(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Pushes a built-in pass.
|
||||
pub fn push_pass<T: DefIdPass + 'static>(&mut self, set: MirPassSet, pass: T) {
|
||||
self.sets[set.0].push(Rc::new(pass));
|
||||
pub fn push_pass<T: DefIdPass + 'static>(&mut self, suite: MirSuite, pass: T) {
|
||||
self.suites[suite.0].push(Rc::new(pass));
|
||||
}
|
||||
|
||||
/// Pushes a pass hook.
|
||||
|
@ -211,12 +211,12 @@ impl<'a, 'tcx> Passes {
|
|||
self.pass_hooks.push(Rc::new(hook));
|
||||
}
|
||||
|
||||
pub fn len_passes(&self, set: MirPassSet) -> usize {
|
||||
self.sets[set.0].len()
|
||||
pub fn len_passes(&self, suite: MirSuite) -> usize {
|
||||
self.suites[suite.0].len()
|
||||
}
|
||||
|
||||
pub fn pass(&self, set: MirPassSet, pass: MirPassIndex) -> &DefIdPass {
|
||||
&*self.sets[set.0][pass.0]
|
||||
pub fn pass(&self, suite: MirSuite, pass: MirPassIndex) -> &DefIdPass {
|
||||
&*self.suites[suite.0][pass.0]
|
||||
}
|
||||
|
||||
pub fn hooks(&self) -> &[Rc<PassHook>] {
|
||||
|
|
|
@ -16,7 +16,7 @@ use middle::const_val;
|
|||
use middle::privacy::AccessLevels;
|
||||
use middle::region::RegionMaps;
|
||||
use mir;
|
||||
use mir::transform::{MirPassSet, MirPassIndex};
|
||||
use mir::transform::{MirSuite, MirPassIndex};
|
||||
use session::CompileResult;
|
||||
use ty::{self, CrateInherentImpls, Ty, TyCtxt};
|
||||
use ty::item_path;
|
||||
|
@ -102,7 +102,7 @@ impl<'tcx> Key for (DefId, &'tcx Substs<'tcx>) {
|
|||
}
|
||||
}
|
||||
|
||||
impl Key for (MirPassSet, DefId) {
|
||||
impl Key for (MirSuite, DefId) {
|
||||
fn map_crate(&self) -> CrateNum {
|
||||
self.1.map_crate()
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ impl Key for (MirPassSet, DefId) {
|
|||
}
|
||||
}
|
||||
|
||||
impl Key for (MirPassSet, MirPassIndex, DefId) {
|
||||
impl Key for (MirSuite, MirPassIndex, DefId) {
|
||||
fn map_crate(&self) -> CrateNum {
|
||||
self.2.map_crate()
|
||||
}
|
||||
|
@ -337,14 +337,14 @@ impl<'tcx> QueryDescription for queries::is_item_mir_available<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> QueryDescription for queries::mir_pass_set<'tcx> {
|
||||
fn describe(_: TyCtxt, (pass_set, _): (MirPassSet, DefId)) -> String {
|
||||
format!("MIR passes #{}.*", pass_set.0)
|
||||
impl<'tcx> QueryDescription for queries::mir_suite<'tcx> {
|
||||
fn describe(_: TyCtxt, (suite, _): (MirSuite, DefId)) -> String {
|
||||
format!("MIR passes #{}.*", suite.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> QueryDescription for queries::mir_pass<'tcx> {
|
||||
fn describe(_: TyCtxt, (pass_set, pass_num, _): (MirPassSet, MirPassIndex, DefId)) -> String {
|
||||
fn describe(_: TyCtxt, (pass_set, pass_num, _): (MirSuite, MirPassIndex, DefId)) -> String {
|
||||
format!("MIR pass #{}.{}", pass_set.0, pass_num.0)
|
||||
}
|
||||
}
|
||||
|
@ -592,12 +592,12 @@ define_maps! { <'tcx>
|
|||
/// applied to it. This is mostly an "intermediate" query. Normally, you would
|
||||
/// prefer to use `optimized_mir(def_id)`, which will fetch the MIR after all
|
||||
/// optimizations and so forth.
|
||||
[] mir_pass_set: mir_pass_set((MirPassSet, DefId)) -> &'tcx RefCell<mir::Mir<'tcx>>,
|
||||
[] mir_suite: mir_suite((MirSuite, DefId)) -> &'tcx RefCell<mir::Mir<'tcx>>,
|
||||
|
||||
/// Fetch the MIR for a given def-id after a given pass has been executed. This is
|
||||
/// **only** intended to be used by the `mir_pass_set` provider -- if you are using it
|
||||
/// **only** intended to be used by the `mir_suite` provider -- if you are using it
|
||||
/// manually, you're doing it wrong.
|
||||
[] mir_pass: mir_pass((MirPassSet, MirPassIndex, DefId)) -> &'tcx RefCell<mir::Mir<'tcx>>,
|
||||
[] mir_pass: mir_pass((MirSuite, MirPassIndex, DefId)) -> &'tcx RefCell<mir::Mir<'tcx>>,
|
||||
|
||||
/// MIR after our optimization passes have run. This is MIR that is ready
|
||||
/// for trans. This is also the only query that can fetch non-local MIR, at present.
|
||||
|
@ -701,10 +701,10 @@ fn mir_keys(_: CrateNum) -> DepNode<DefId> {
|
|||
DepNode::MirKeys
|
||||
}
|
||||
|
||||
fn mir_pass_set((_pass_set, def_id): (MirPassSet, DefId)) -> DepNode<DefId> {
|
||||
fn mir_suite((_suite, def_id): (MirSuite, DefId)) -> DepNode<DefId> {
|
||||
DepNode::Mir(def_id)
|
||||
}
|
||||
|
||||
fn mir_pass((_pass_set, _pass_num, def_id): (MirPassSet, MirPassIndex, DefId)) -> DepNode<DefId> {
|
||||
fn mir_pass((_suite, _pass_num, def_id): (MirSuite, MirPassIndex, DefId)) -> DepNode<DefId> {
|
||||
DepNode::Mir(def_id)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::mir::Mir;
|
||||
use rustc::mir::transform::{MirCtxt, MirPassIndex, MirPassSet, MirSource, MIR_OPTIMIZED};
|
||||
use rustc::mir::transform::{MirCtxt, MirPassIndex, MirSuite, MirSource, MIR_OPTIMIZED};
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc::ty::maps::Providers;
|
||||
use std::cell::{Ref, RefCell};
|
||||
|
@ -34,14 +34,14 @@ pub fn provide(providers: &mut Providers) {
|
|||
self::qualify_consts::provide(providers);
|
||||
*providers = Providers {
|
||||
optimized_mir,
|
||||
mir_pass_set,
|
||||
mir_suite,
|
||||
mir_pass,
|
||||
..*providers
|
||||
};
|
||||
}
|
||||
|
||||
fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx RefCell<Mir<'tcx>> {
|
||||
let mir = tcx.mir_pass_set((MIR_OPTIMIZED, def_id));
|
||||
let mir = tcx.mir_suite((MIR_OPTIMIZED, def_id));
|
||||
|
||||
// "lock" the ref cell into read mode; after this point,
|
||||
// there ought to be no more changes to the MIR.
|
||||
|
@ -50,23 +50,23 @@ fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx
|
|||
mir
|
||||
}
|
||||
|
||||
fn mir_pass_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
(pass_set, def_id): (MirPassSet, DefId))
|
||||
fn mir_suite<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
(suite, def_id): (MirSuite, DefId))
|
||||
-> &'tcx RefCell<Mir<'tcx>>
|
||||
{
|
||||
let passes = &tcx.mir_passes;
|
||||
let len = passes.len_passes(pass_set);
|
||||
assert!(len > 0, "no passes in {:?}", pass_set);
|
||||
tcx.mir_pass((pass_set, MirPassIndex(len - 1), def_id))
|
||||
let len = passes.len_passes(suite);
|
||||
assert!(len > 0, "no passes in {:?}", suite);
|
||||
tcx.mir_pass((suite, MirPassIndex(len - 1), def_id))
|
||||
}
|
||||
|
||||
fn mir_pass<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
(pass_set, pass_num, def_id): (MirPassSet, MirPassIndex, DefId))
|
||||
(suite, pass_num, def_id): (MirSuite, MirPassIndex, DefId))
|
||||
-> &'tcx RefCell<Mir<'tcx>>
|
||||
{
|
||||
let passes = &tcx.mir_passes;
|
||||
let pass = passes.pass(pass_set, pass_num);
|
||||
let mir_ctxt = MirCtxtImpl { tcx, pass_num, pass_set, def_id };
|
||||
let pass = passes.pass(suite, pass_num);
|
||||
let mir_ctxt = MirCtxtImpl { tcx, pass_num, suite, def_id };
|
||||
|
||||
for hook in passes.hooks() {
|
||||
hook.on_mir_pass(&mir_ctxt, None);
|
||||
|
@ -84,7 +84,7 @@ fn mir_pass<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
struct MirCtxtImpl<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
pass_num: MirPassIndex,
|
||||
pass_set: MirPassSet,
|
||||
suite: MirSuite,
|
||||
def_id: DefId
|
||||
}
|
||||
|
||||
|
@ -93,8 +93,8 @@ impl<'a, 'tcx> MirCtxt<'a, 'tcx> for MirCtxtImpl<'a, 'tcx> {
|
|||
self.tcx
|
||||
}
|
||||
|
||||
fn pass_set(&self) -> MirPassSet {
|
||||
self.pass_set
|
||||
fn suite(&self) -> MirSuite {
|
||||
self.suite
|
||||
}
|
||||
|
||||
fn pass_num(&self) -> MirPassIndex {
|
||||
|
@ -116,12 +116,12 @@ impl<'a, 'tcx> MirCtxt<'a, 'tcx> for MirCtxtImpl<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn steal_previous_mir(&self) -> &'tcx RefCell<Mir<'tcx>> {
|
||||
let MirPassSet(pass_set) = self.pass_set;
|
||||
let MirSuite(suite) = self.suite;
|
||||
let MirPassIndex(pass_num) = self.pass_num;
|
||||
if pass_num > 0 {
|
||||
self.tcx.mir_pass((MirPassSet(pass_set), MirPassIndex(pass_num - 1), self.def_id))
|
||||
} else if pass_set > 0 {
|
||||
self.tcx.mir_pass_set((MirPassSet(pass_set - 1), self.def_id))
|
||||
self.tcx.mir_pass((MirSuite(suite), MirPassIndex(pass_num - 1), self.def_id))
|
||||
} else if suite > 0 {
|
||||
self.tcx.mir_suite((MirSuite(suite - 1), self.def_id))
|
||||
} else {
|
||||
self.tcx.mir_build(self.def_id)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
use rustc::hir;
|
||||
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc::mir::*;
|
||||
use rustc::mir::transform::{MirPassSet, MirPassIndex, MirSource};
|
||||
use rustc::mir::transform::{MirSuite, MirPassIndex, MirSource};
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::indexed_vec::{Idx};
|
||||
|
@ -39,7 +39,7 @@ const ALIGN: usize = 40;
|
|||
/// that can appear in the pass-name or the `item_path_str` for the given
|
||||
/// node-id. If any one of the substrings match, the data is dumped out.
|
||||
pub fn dump_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
pass_num: Option<(MirPassSet, MirPassIndex)>,
|
||||
pass_num: Option<(MirSuite, MirPassIndex)>,
|
||||
pass_name: &str,
|
||||
disambiguator: &Display,
|
||||
source: MirSource,
|
||||
|
@ -77,7 +77,7 @@ pub fn dump_enabled<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
}
|
||||
|
||||
fn dump_matched_mir_node<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
pass_num: Option<(MirPassSet, MirPassIndex)>,
|
||||
pass_num: Option<(MirSuite, MirPassIndex)>,
|
||||
pass_name: &str,
|
||||
node_path: &str,
|
||||
disambiguator: &Display,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue