forked from AbleOS/holey-bytes
more general tree walking algorightm was needed (probably)
Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
parent
7837eeb90d
commit
6fba7da782
|
@ -643,7 +643,7 @@ impl TokenKind {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
enum PLoc {
|
||||
Reg(Reg, u16),
|
||||
WideReg(Reg, u16),
|
||||
|
|
|
@ -121,9 +121,10 @@ impl HbvmBackend {
|
|||
|| nodes.is_hard_zero(allc)
|
||||
|| allc == MEM
|
||||
|| matches!(node.kind, Kind::Loop | Kind::Region),
|
||||
"{nid} {:?}\n{allc} {:?}",
|
||||
"{nid} {:?}\n{allc} {:?} {}",
|
||||
nodes[nid],
|
||||
nodes[allc]
|
||||
nodes[allc],
|
||||
ty::Display::new(tys, files, nodes[allc].ty)
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -712,10 +713,6 @@ impl Nodes {
|
|||
);
|
||||
self[user].inputs.iter().position(|&v| v == val).is_some_and(|v| v < 3)
|
||||
}
|
||||
//Kind::Call { .. } => {
|
||||
// self[val].kind != Kind::Load
|
||||
// || matches!(types.parama(self[val].ty).0, Some(PLoc::Ref(..)))
|
||||
//}
|
||||
Kind::Load => self[user].inputs[2] != val,
|
||||
_ => self[user].inputs[0] != val || self[user].inputs[1..].contains(&val),
|
||||
}
|
||||
|
@ -761,19 +758,22 @@ impl Nodes {
|
|||
return None.into_iter().flatten();
|
||||
}
|
||||
|
||||
Some(
|
||||
self[nid]
|
||||
.outputs
|
||||
.iter()
|
||||
.filter(move |&&n| self.is_data_dep(nid, n, types))
|
||||
.map(move |n| self.this_or_delegates(nid, n))
|
||||
.flat_map(|(p, ls)| ls.iter().map(move |l| (p, l)))
|
||||
.filter(|&(o, &n)| self.is_data_dep(o, n, types))
|
||||
.map(|(p, &n)| (self.use_block_of(p, n), n))
|
||||
.inspect(|&(_, n)| debug_assert!(self.is_unlocked(n))),
|
||||
)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
let mut uses = vec![];
|
||||
let mut to_expand = vec![nid];
|
||||
while let Some(exp) = to_expand.pop() {
|
||||
for &o in self[exp].outputs.iter() {
|
||||
if !self.is_data_dep(exp, o, types) {
|
||||
continue;
|
||||
}
|
||||
if self.is_unlocked(o) {
|
||||
uses.push((self.use_block_of(exp, o), o));
|
||||
} else {
|
||||
to_expand.push(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some(uses).into_iter().flatten()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue