1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::ir::prelude::*;
use rayon::prelude::*;
pub trait Pass {
fn run_on_module(ctx: &PassContext, module: &mut Module) -> bool {
module
.par_units_mut()
.map(|mut unit| Self::run_on_unit(ctx, &mut unit))
.reduce(|| false, |a, b| a || b)
}
fn run_on_unit(ctx: &PassContext, data: &mut UnitBuilder) -> bool {
Self::run_on_cfg(ctx, data)
}
fn run_on_cfg(ctx: &PassContext, unit: &mut UnitBuilder) -> bool {
let mut modified = false;
let insts: Vec<_> = unit.all_insts().collect();
for inst in insts {
modified |= Self::run_on_inst(ctx, inst, unit);
}
modified
}
#[allow(unused_variables)]
fn run_on_inst(ctx: &PassContext, inst: Inst, unit: &mut UnitBuilder) -> bool {
false
}
}
pub struct PassContext;