rename MirPassSet to MirSuite

This seems like a better noun.
This commit is contained in:
Niko Matsakis 2017-04-28 04:49:09 -04:00
parent 2b32cb90c7
commit e89a321dff
4 changed files with 49 additions and 49 deletions

View file

@ -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>] {

View file

@ -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)
}