fixing more stuff

This commit is contained in:
Jakub Doka 2024-11-10 10:28:02 +01:00
parent 42a713aeae
commit 5dce4df2a1
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
2 changed files with 18 additions and 8 deletions

View file

@ -191,13 +191,10 @@ impl Nodes {
fn fix_loops(&mut self) { fn fix_loops(&mut self) {
'o: for l in self[LOOPS].outputs.clone() { 'o: for l in self[LOOPS].outputs.clone() {
let mut cursor = self[l].inputs[1]; let mut cursor = self[l].inputs[1];
let depth = self.loop_depth(cursor);
while cursor != l { while cursor != l {
if self[cursor].kind == Kind::If if self[cursor].kind == Kind::If
&& self[cursor] && self[cursor].outputs.iter().any(|&b| self.loop_depth(b) < depth)
.outputs
.clone()
.into_iter()
.any(|b| self.loop_depth(b) < self.loop_depth(cursor))
{ {
continue 'o; continue 'o;
} }
@ -261,6 +258,14 @@ impl Nodes {
return; return;
} }
if node == NEVER {
std::dbg!();
}
if self[node].kind == Kind::Loop {
std::dbg!(&self[node]);
}
for &n in self[node].outputs.iter() { for &n in self[node].outputs.iter() {
self.collect_rpo(n, rpo, visited); self.collect_rpo(n, rpo, visited);
} }
@ -269,6 +274,7 @@ impl Nodes {
} }
fn push_up(&mut self, rpo: &mut Vec<Nid>, visited: &mut BitSet) { fn push_up(&mut self, rpo: &mut Vec<Nid>, visited: &mut BitSet) {
std::dbg!();
debug_assert!(rpo.is_empty()); debug_assert!(rpo.is_empty());
self.collect_rpo(VOID, rpo, visited); self.collect_rpo(VOID, rpo, visited);
@ -1342,7 +1348,11 @@ impl Nodes {
fn modify_input(&mut self, target: Nid, inp_index: usize, with: Nid) -> Nid { fn modify_input(&mut self, target: Nid, inp_index: usize, with: Nid) -> Nid {
self.remove_node_lookup(target); self.remove_node_lookup(target);
debug_assert_ne!(self[target].inputs[inp_index], with, "{:?}", self[target]); debug_assert_ne!(
self[target].inputs[inp_index], with,
"{:?} {:?}",
self[target], self[with]
);
if self[target].is_not_gvnd() && (self[target].kind != Kind::Phi || with == 0) { if self[target].is_not_gvnd() && (self[target].kind != Kind::Phi || with == 0) {
let prev = self[target].inputs[inp_index]; let prev = self[target].inputs[inp_index];
@ -4223,7 +4233,7 @@ impl<'a> Codegen<'a> {
let index = self.ci.nodes[out].inputs.iter().position(|&p| p == n).unwrap(); let index = self.ci.nodes[out].inputs.iter().position(|&p| p == n).unwrap();
self.ci.nodes.modify_input(out, index, self.ci.nodes[n].inputs[0]); self.ci.nodes.modify_input(out, index, self.ci.nodes[n].inputs[0]);
} else { } else {
if !self.ci.nodes[out].kind.is_pinned() { if !self.ci.nodes[out].kind.is_pinned() && self.ci.nodes[out].inputs[0] != pin {
out = self.ci.nodes.modify_input(out, 0, pin); out = self.ci.nodes.modify_input(out, 0, pin);
} }
let index = let index =

View file

@ -337,7 +337,7 @@ impl HbvmBackend {
let Arg::Value(ty) = arg else { continue }; let Arg::Value(ty) = arg else { continue };
let Some(loc) = parama.next(ty, tys) else { continue }; let Some(loc) = parama.next(ty, tys) else { continue };
let mut arg = *allocs.next().unwrap(); let arg = *allocs.next().unwrap();
let (rg, size) = match loc { let (rg, size) = match loc {
PLoc::Reg(rg, size) if ty.loc(tys) == Loc::Stack => (rg, size), PLoc::Reg(rg, size) if ty.loc(tys) == Loc::Stack => (rg, size),
PLoc::WideReg(rg, size) => (rg, size), PLoc::WideReg(rg, size) => (rg, size),