Rollup merge of #137204 - nnethercote:clarify-MIR-dialects-and-phases, r=RalfJung
Clarify MIR dialects and phases I found the existing code and docs hard to understand. r? `@Zalathar`
This commit is contained in:
commit
15a0403ecf
3 changed files with 62 additions and 58 deletions
|
@ -98,20 +98,13 @@ impl<'tcx> HasLocalDecls<'tcx> for Body<'tcx> {
|
|||
}
|
||||
|
||||
impl MirPhase {
|
||||
/// Gets the index of the current MirPhase within the set of all `MirPhase`s.
|
||||
///
|
||||
/// FIXME(JakobDegen): Return a `(usize, usize)` instead.
|
||||
pub fn phase_index(&self) -> usize {
|
||||
const BUILT_PHASE_COUNT: usize = 1;
|
||||
const ANALYSIS_PHASE_COUNT: usize = 2;
|
||||
match self {
|
||||
MirPhase::Built => 1,
|
||||
MirPhase::Analysis(analysis_phase) => {
|
||||
1 + BUILT_PHASE_COUNT + (*analysis_phase as usize)
|
||||
}
|
||||
MirPhase::Runtime(runtime_phase) => {
|
||||
1 + BUILT_PHASE_COUNT + ANALYSIS_PHASE_COUNT + (*runtime_phase as usize)
|
||||
}
|
||||
/// Gets the (dialect, phase) index of the current `MirPhase`. Both numbers
|
||||
/// are 1-indexed.
|
||||
pub fn index(&self) -> (usize, usize) {
|
||||
match *self {
|
||||
MirPhase::Built => (1, 1),
|
||||
MirPhase::Analysis(analysis_phase) => (2, 1 + analysis_phase as usize),
|
||||
MirPhase::Runtime(runtime_phase) => (3, 1 + runtime_phase as usize),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue