Skip to content

Commit 00d617b

Browse files
Rename: IRAfterPass -> PostPassStatus
Also rename variants accordingly: IRAfterPass::Changed -> PostPassStatus::IRChanged IRAfterPass::Unchanged -> PostPassStatus::IRUnchanged Signed-off-by: Tomas Fabrizio Orsi <[email protected]>
1 parent 56df599 commit 00d617b

File tree

10 files changed

+47
-47
lines changed

10 files changed

+47
-47
lines changed

dialects/hir/src/transforms/spill.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use alloc::rc::Rc;
33
use midenc_hir::{
44
adt::SmallDenseMap,
55
dialects::builtin::{Function, FunctionRef, LocalVariable},
6-
pass::{pass::PassIdentifier, IRAfterPass, Pass, PassExecutionState},
6+
pass::{pass::PassIdentifier, Pass, PassExecutionState, PostPassStatus},
77
BlockRef, BuilderExt, EntityMut, Op, OpBuilder, OperationName, OperationRef, Report, Rewriter,
88
SourceSpan, Spanned, Symbol, ValueRef,
99
};
@@ -35,22 +35,22 @@ impl Pass for TransformSpills {
3535
&mut self,
3636
op: EntityMut<'_, Self::Target>,
3737
state: &mut PassExecutionState,
38-
) -> Result<IRAfterPass, Report> {
38+
) -> Result<PostPassStatus, Report> {
3939
let function = op.into_entity_ref();
4040
log::debug!(target: "insert-spills", "computing and inserting spills for {}", function.as_operation());
4141

4242
if function.is_declaration() {
4343
log::debug!(target: "insert-spills", "function has no body, no spills needed!");
4444
state.preserved_analyses_mut().preserve_all();
45-
return Ok(IRAfterPass::Unchanged);
45+
return Ok(PostPassStatus::IRUnchanged);
4646
}
4747
let mut analysis =
4848
state.analysis_manager().get_analysis_for::<SpillAnalysis, Function>()?;
4949

5050
if !analysis.has_spills() {
5151
log::debug!(target: "insert-spills", "no spills needed!");
5252
state.preserved_analyses_mut().preserve_all();
53-
return Ok(IRAfterPass::Unchanged);
53+
return Ok(PostPassStatus::IRUnchanged);
5454
}
5555

5656
// Take ownership of the spills analysis so that we can mutate the analysis state during

dialects/scf/src/transforms/cfg_to_scf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use midenc_hir::{
77
diagnostics::Severity,
88
dialects::builtin,
99
dominance::DominanceInfo,
10-
pass::{pass::PassIdentifier, IRAfterPass, Pass, PassExecutionState},
10+
pass::{pass::PassIdentifier, Pass, PassExecutionState, PostPassStatus},
1111
Builder, EntityMut, Forward, Op, Operation, OperationName, OperationRef, RawWalk, Report,
1212
SmallVec, Spanned, Type, ValueRange, ValueRef, WalkResult,
1313
};
@@ -55,7 +55,7 @@ impl Pass for LiftControlFlowToSCF {
5555
&mut self,
5656
op: EntityMut<'_, Self::Target>,
5757
state: &mut PassExecutionState,
58-
) -> Result<IRAfterPass, Report> {
58+
) -> Result<PostPassStatus, Report> {
5959
let mut transformation = ControlFlowToSCFTransformation;
6060
let mut changed = false;
6161

@@ -134,7 +134,7 @@ impl Pass for LiftControlFlowToSCF {
134134
});
135135

136136
if result.was_interrupted() {
137-
return result.into_result().map(|_| IRAfterPass::Unchanged);
137+
return result.into_result().map(|_| PostPassStatus::IRUnchanged);
138138
}
139139

140140
log::debug!(

hir-transform/src/canonicalization.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use alloc::{boxed::Box, format, rc::Rc};
22

33
use midenc_hir::{
4-
pass::{pass::PassIdentifier, IRAfterPass, OperationPass, Pass, PassExecutionState},
4+
pass::{pass::PassIdentifier, OperationPass, Pass, PassExecutionState, PostPassStatus},
55
patterns::{self, FrozenRewritePatternSet, GreedyRewriteConfig, RewritePatternSet},
66
Context, EntityMut, Operation, OperationName, Report, Spanned,
77
};
@@ -97,10 +97,10 @@ impl Pass for Canonicalizer {
9797
&mut self,
9898
op: EntityMut<'_, Self::Target>,
9999
state: &mut PassExecutionState,
100-
) -> Result<IRAfterPass, Report> {
100+
) -> Result<PostPassStatus, Report> {
101101
let Some(rewrites) = self.rewrites.as_ref() else {
102102
log::debug!("skipping canonicalization as there are no rewrite patterns to apply");
103-
return Ok(IRAfterPass::Unchanged);
103+
return Ok(PostPassStatus::IRUnchanged);
104104
};
105105
let op = {
106106
let ptr = op.as_operation_ref();

hir-transform/src/sccp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use midenc_hir::{
2-
pass::{pass::PassIdentifier, IRAfterPass, Pass, PassExecutionState},
2+
pass::{pass::PassIdentifier, Pass, PassExecutionState, PostPassStatus},
33
patterns::NoopRewriterListener,
44
BlockRef, Builder, EntityMut, OpBuilder, Operation, OperationFolder, OperationName, RegionList,
55
Report, SmallVec, ValueRef,
@@ -42,7 +42,7 @@ impl Pass for SparseConditionalConstantPropagation {
4242
&mut self,
4343
mut op: EntityMut<'_, Self::Target>,
4444
state: &mut PassExecutionState,
45-
) -> Result<IRAfterPass, Report> {
45+
) -> Result<PostPassStatus, Report> {
4646
// Run sparse constant propagation + dead code analysis
4747
let mut solver = DataFlowSolver::default();
4848
solver.load::<DeadCodeAnalysis>();
@@ -62,7 +62,7 @@ impl SparseConditionalConstantPropagation {
6262
op: &mut Operation,
6363
_state: &mut PassExecutionState,
6464
solver: &DataFlowSolver,
65-
) -> Result<IRAfterPass, Report> {
65+
) -> Result<PostPassStatus, Report> {
6666
let mut worklist = SmallVec::<[BlockRef; 8]>::default();
6767

6868
let add_to_worklist = |regions: &RegionList, worklist: &mut SmallVec<[BlockRef; 8]>| {

hir-transform/src/sink.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use midenc_hir::{
44
adt::SmallDenseMap,
55
dominance::DominanceInfo,
66
matchers::{self, Matcher},
7-
pass::{pass::PassIdentifier, IRAfterPass, Pass, PassExecutionState},
7+
pass::{pass::PassIdentifier, Pass, PassExecutionState, PostPassStatus},
88
traits::{ConstantLike, Terminator},
99
Backward, Builder, EntityMut, Forward, FxHashSet, OpBuilder, Operation, OperationName,
1010
OperationRef, ProgramPoint, RawWalk, Region, RegionBranchOpInterface,
@@ -100,7 +100,7 @@ impl Pass for ControlFlowSink {
100100
&mut self,
101101
op: EntityMut<'_, Self::Target>,
102102
state: &mut PassExecutionState,
103-
) -> Result<IRAfterPass, Report> {
103+
) -> Result<PostPassStatus, Report> {
104104
let op = op.into_entity_ref();
105105
log::debug!(target: "control-flow-sink", "sinking operations in {op}");
106106

@@ -109,7 +109,7 @@ impl Pass for ControlFlowSink {
109109

110110
let dominfo = state.analysis_manager().get_analysis::<DominanceInfo>()?;
111111

112-
let mut sunk = IRAfterPass::Unchanged;
112+
let mut sunk = PostPassStatus::IRUnchanged;
113113
operation.raw_prewalk_all::<Forward, _>(|op: OperationRef| {
114114
let regions_to_sink = {
115115
let op = op.borrow();
@@ -181,7 +181,7 @@ impl Pass for SinkOperandDefs {
181181
&mut self,
182182
op: EntityMut<'_, Self::Target>,
183183
_state: &mut PassExecutionState,
184-
) -> Result<IRAfterPass, Report> {
184+
) -> Result<PostPassStatus, Report> {
185185
let operation = op.as_operation_ref();
186186
drop(op);
187187

@@ -193,7 +193,7 @@ impl Pass for SinkOperandDefs {
193193
// then process the worklist, moving everything into position.
194194
let mut worklist = alloc::collections::VecDeque::default();
195195

196-
let mut changed = IRAfterPass::Unchanged;
196+
let mut changed = PostPassStatus::IRUnchanged;
197197
// Visit ops in "true" post-order (i.e. block bodies are visited bottom-up).
198198
operation.raw_postwalk_all::<Backward, _>(|operation: OperationRef| {
199199
// Determine if any of this operation's operands represent one of the following:
@@ -318,7 +318,7 @@ impl Pass for SinkOperandDefs {
318318
log::trace!(target: "sink-operand-defs", " rewriting operand {operand_value} as {replacement}");
319319
operand.borrow_mut().set(replacement);
320320

321-
changed = IRAfterPass::Changed;
321+
changed = PostPassStatus::IRChanged;
322322
// If no other uses of this value remain, then remove the original
323323
// operation, as it is now dead.
324324
if !operand_value.borrow().is_used() {
@@ -365,7 +365,7 @@ impl Pass for SinkOperandDefs {
365365
log::trace!(target: "sink-operand-defs", " rewriting operand {operand_value} as {replacement}");
366366
sink_state.replacements.insert(operand_value, replacement);
367367
operand.borrow_mut().set(replacement);
368-
changed = IRAfterPass::Changed;
368+
changed = PostPassStatus::IRChanged;
369369
} else {
370370
log::trace!(target: "sink-operand-defs", " defining op is a constant with no other uses, moving into place");
371371
// The original op can be moved
@@ -560,7 +560,7 @@ pub fn control_flow_sink<P, F>(
560560
dominfo: &DominanceInfo,
561561
should_move_into_region: P,
562562
move_into_region: F,
563-
) -> IRAfterPass
563+
) -> PostPassStatus
564564
where
565565
P: Fn(&Operation, &Region) -> bool,
566566
F: Fn(OperationRef, RegionRef),

hir-transform/src/spill.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use midenc_hir::{
44
adt::{SmallDenseMap, SmallSet},
55
cfg::Graph,
66
dominance::{DomTreeNode, DominanceFrontier, DominanceInfo},
7-
pass::{AnalysisManager, IRAfterPass},
7+
pass::{AnalysisManager, PostPassStatus},
88
traits::SingleRegion,
99
BlockRef, Builder, Context, FxHashMap, OpBuilder, OpOperand, Operation, OperationRef,
1010
ProgramPoint, Region, RegionBranchOpInterface, RegionBranchPoint, RegionRef, Report, Rewriter,
@@ -113,7 +113,7 @@ pub fn transform_spills(
113113
analysis: &mut SpillAnalysis,
114114
interface: &mut dyn TransformSpillsInterface,
115115
analysis_manager: AnalysisManager,
116-
) -> Result<IRAfterPass, Report> {
116+
) -> Result<PostPassStatus, Report> {
117117
assert!(
118118
op.borrow().implements::<dyn SingleRegion>(),
119119
"the spills transformation is not supported when the root op is multi-region"
@@ -252,7 +252,7 @@ pub fn transform_spills(
252252
)?;
253253
}
254254

255-
Ok(IRAfterPass::Changed)
255+
Ok(PostPassStatus::IRChanged)
256256
}
257257

258258
fn rewrite_single_block_spills(

hir/src/pass.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub use self::{
1212
analysis::{Analysis, AnalysisManager, OperationAnalysis, PreservedAnalyses},
1313
instrumentation::{PassInstrumentation, PassInstrumentor, PipelineParentInfo},
1414
manager::{IRPrintingConfig, Nesting, OpPassManager, PassDisplayMode, PassManager},
15-
pass::{IRAfterPass, OperationPass, Pass, PassExecutionState, PassIdentifier},
15+
pass::{OperationPass, Pass, PassExecutionState, PassIdentifier, PostPassStatus},
1616
registry::{PassInfo, PassPipelineInfo},
1717
specialization::PassTarget,
1818
statistics::{PassStatistic, Statistic, StatisticValue},
@@ -174,12 +174,12 @@ impl Print {
174174
}
175175
}
176176

177-
fn should_print(&self, pass: &dyn OperationPass, ir_changed: IRAfterPass) -> bool {
177+
fn should_print(&self, pass: &dyn OperationPass, ir_changed: PostPassStatus) -> bool {
178178
let pass_filter = self.pass_filter(pass);
179179

180180
// Always print, unless "only_when_modified" has been set and there have not been changes.
181181
let modification_filter =
182-
!matches!((self.only_when_modified, ir_changed), (true, IRAfterPass::Unchanged));
182+
!matches!((self.only_when_modified, ir_changed), (true, PostPassStatus::IRUnchanged));
183183

184184
pass_filter && modification_filter
185185
}
@@ -216,7 +216,7 @@ impl PassInstrumentation for Print {
216216
&mut self,
217217
pass: &dyn OperationPass,
218218
op: &OperationRef,
219-
changed: IRAfterPass,
219+
changed: PostPassStatus,
220220
) {
221221
if self.should_print(pass, changed) {
222222
log::trace!("After the {} pass", pass.name());

hir/src/pass/instrumentation.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use compact_str::CompactString;
55
use smallvec::SmallVec;
66

77
use super::OperationPass;
8-
use crate::{pass::IRAfterPass, OperationName, OperationRef};
8+
use crate::{pass::PostPassStatus, OperationName, OperationRef};
99

1010
#[allow(unused_variables)]
1111
pub trait PassInstrumentation {
@@ -27,7 +27,7 @@ pub trait PassInstrumentation {
2727
&mut self,
2828
pass: &dyn OperationPass,
2929
op: &OperationRef,
30-
changed: IRAfterPass,
30+
changed: PostPassStatus,
3131
) {
3232
}
3333
fn run_after_pass_failed(&mut self, pass: &dyn OperationPass, op: &OperationRef) {}
@@ -66,7 +66,7 @@ impl<P: ?Sized + PassInstrumentation> PassInstrumentation for Box<P> {
6666
&mut self,
6767
pass: &dyn OperationPass,
6868
op: &OperationRef,
69-
changed: IRAfterPass,
69+
changed: PostPassStatus,
7070
) {
7171
(**self).run_after_pass(pass, op, changed);
7272
}
@@ -115,7 +115,7 @@ impl PassInstrumentor {
115115
&self,
116116
pass: &dyn OperationPass,
117117
op: &OperationRef,
118-
changed: IRAfterPass,
118+
changed: PostPassStatus,
119119
) {
120120
self.instrument(|pi| pi.run_after_pass(pass, op, changed));
121121
}

hir/src/pass/manager.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use super::{
99
PassInstrumentor, PipelineParentInfo, Statistic,
1010
};
1111
use crate::{
12-
pass::{pass::PassIdentifier, IRAfterPass, Print},
12+
pass::{pass::PassIdentifier, PostPassStatus, Print},
1313
traits::IsolatedFromAbove,
1414
Context, EntityMut, OpPrintingFlags, OpRegistration, Operation, OperationName, OperationRef,
1515
Report,
@@ -987,7 +987,7 @@ impl OpToOpPassAdaptor {
987987
let in_result = if let Ok(result) = result {
988988
result
989989
} else {
990-
IRAfterPass::Unchanged
990+
PostPassStatus::IRUnchanged
991991
};
992992
if result.is_err() {
993993
instrumentor.run_after_pass_failed(pass, &op);
@@ -1014,7 +1014,7 @@ impl OpToOpPassAdaptor {
10141014
op: OperationRef,
10151015
state: &mut PassExecutionState,
10161016
verify: bool,
1017-
) -> Result<IRAfterPass, Report> {
1017+
) -> Result<PostPassStatus, Report> {
10181018
let analysis_manager = state.analysis_manager();
10191019
let instrumentor = analysis_manager.pass_instrumentor();
10201020
let parent_info = PipelineParentInfo {
@@ -1049,7 +1049,7 @@ impl OpToOpPassAdaptor {
10491049
}
10501050
}
10511051

1052-
Ok(IRAfterPass::Unchanged)
1052+
Ok(PostPassStatus::IRUnchanged)
10531053
}
10541054
}
10551055

@@ -1090,7 +1090,7 @@ impl Pass for OpToOpPassAdaptor {
10901090
&mut self,
10911091
_op: EntityMut<'_, Operation>,
10921092
_state: &mut PassExecutionState,
1093-
) -> Result<IRAfterPass, Report> {
1093+
) -> Result<PostPassStatus, Report> {
10941094
unreachable!("unexpected call to `Pass::run_on_operation` for OpToOpPassAdaptor")
10951095
}
10961096
}

hir/src/pass/pass.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub trait OperationPass {
4747
&mut self,
4848
op: OperationRef,
4949
state: &mut PassExecutionState,
50-
) -> Result<IRAfterPass, Report>;
50+
) -> Result<PostPassStatus, Report>;
5151
fn run_pipeline(
5252
&mut self,
5353
pipeline: &mut OpPassManager,
@@ -128,7 +128,7 @@ where
128128
&mut self,
129129
mut op: OperationRef,
130130
state: &mut PassExecutionState,
131-
) -> Result<IRAfterPass, Report> {
131+
) -> Result<PostPassStatus, Report> {
132132
let op = <<P as Pass>::Target as PassTarget>::into_target_mut(&mut op);
133133
<P as Pass>::run_on_operation(self, op, state)
134134
}
@@ -171,17 +171,17 @@ impl From<&String> for PassIdentifier {
171171
}
172172

173173
#[derive(Debug, PartialEq, Clone, Copy)]
174-
pub enum IRAfterPass {
175-
Unchanged,
176-
Changed,
174+
pub enum PostPassStatus {
175+
IRUnchanged,
176+
IRChanged,
177177
}
178178

179179
// NOTE: I am not sure if using a From impl
180-
impl From<bool> for IRAfterPass {
180+
impl From<bool> for PostPassStatus {
181181
fn from(ir_was_changed: bool) -> Self {
182182
match ir_was_changed {
183-
true => IRAfterPass::Changed,
184-
false => IRAfterPass::Unchanged,
183+
true => PostPassStatus::IRChanged,
184+
false => PostPassStatus::IRUnchanged,
185185
}
186186
}
187187
}
@@ -281,7 +281,7 @@ pub trait Pass: Sized + Any {
281281
&mut self,
282282
op: EntityMut<'_, Self::Target>,
283283
state: &mut PassExecutionState,
284-
) -> Result<IRAfterPass, Report>;
284+
) -> Result<PostPassStatus, Report>;
285285
/// Schedule an arbitrary pass pipeline on the provided operation.
286286
///
287287
/// This can be invoke any time in a pass to dynamic schedule more passes. The provided
@@ -386,7 +386,7 @@ where
386386
&mut self,
387387
op: EntityMut<'_, Self::Target>,
388388
state: &mut PassExecutionState,
389-
) -> Result<IRAfterPass, Report> {
389+
) -> Result<PostPassStatus, Report> {
390390
(**self).run_on_operation(op, state)
391391
}
392392

0 commit comments

Comments
 (0)