init
This commit is contained in:
32
src/cfg.rs
32
src/cfg.rs
@@ -33,7 +33,7 @@ pub struct CFGInfo {
|
||||
}
|
||||
|
||||
impl CFGInfo {
|
||||
pub fn new<F: Function>(f: &F) -> Result<CFGInfo, RegAllocError> {
|
||||
pub fn new<F: Function>(f: &F, needs_loop_depth: bool) -> Result<CFGInfo, RegAllocError> {
|
||||
let postorder = postorder::calculate(f.num_blocks(), f.entry_block(), |block| {
|
||||
f.block_succs(block)
|
||||
});
|
||||
@@ -98,22 +98,24 @@ impl CFGInfo {
|
||||
}
|
||||
|
||||
let mut approx_loop_depth = vec![];
|
||||
let mut backedge_stack: SmallVec<[usize; 4]> = smallvec![];
|
||||
let mut cur_depth = 0;
|
||||
for block in 0..f.num_blocks() {
|
||||
if backedge_in[block] > 0 {
|
||||
cur_depth += 1;
|
||||
backedge_stack.push(backedge_in[block]);
|
||||
}
|
||||
if needs_loop_depth {
|
||||
let mut backedge_stack: SmallVec<[usize; 4]> = smallvec![];
|
||||
let mut cur_depth = 0;
|
||||
for block in 0..f.num_blocks() {
|
||||
if backedge_in[block] > 0 {
|
||||
cur_depth += 1;
|
||||
backedge_stack.push(backedge_in[block]);
|
||||
}
|
||||
|
||||
approx_loop_depth.push(cur_depth);
|
||||
approx_loop_depth.push(cur_depth);
|
||||
|
||||
while backedge_stack.len() > 0 && backedge_out[block] > 0 {
|
||||
backedge_out[block] -= 1;
|
||||
*backedge_stack.last_mut().unwrap() -= 1;
|
||||
if *backedge_stack.last().unwrap() == 0 {
|
||||
cur_depth -= 1;
|
||||
backedge_stack.pop();
|
||||
while backedge_stack.len() > 0 && backedge_out[block] > 0 {
|
||||
backedge_out[block] -= 1;
|
||||
*backedge_stack.last_mut().unwrap() -= 1;
|
||||
if *backedge_stack.last().unwrap() == 0 {
|
||||
cur_depth -= 1;
|
||||
backedge_stack.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user