no longer wrong!
This commit is contained in:
parent
e9335d3fc5
commit
cbc416dcaa
13
src/mir.rs
13
src/mir.rs
|
@ -1306,11 +1306,17 @@ pub mod liveness {
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut edges = HashSet::<(u32, u32)>::new();
|
let mut edges = HashSet::<(u32, u32)>::new();
|
||||||
|
// eprint!("intervals: [");
|
||||||
for (from, to) in intervals {
|
for (from, to) in intervals {
|
||||||
for &(other, _) in references.range(from.exclusive_start()..to.inclusive_end()) {
|
// eprint!("({from})..({to}), ");
|
||||||
|
if !mir.is_register(from.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for &(other, _) in references.range(from.exclusive_start()..to.exclusive_end()) {
|
||||||
edges.insert((from.0, other.0));
|
edges.insert((from.0, other.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// eprintln!("]");
|
||||||
|
|
||||||
let inference_graph = petgraph::graph::UnGraph::<(), ()>::from_edges(edges.into_iter());
|
let inference_graph = petgraph::graph::UnGraph::<(), ()>::from_edges(edges.into_iter());
|
||||||
|
|
||||||
|
@ -1614,6 +1620,7 @@ pub mod liveness {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Mir {
|
impl Mir {
|
||||||
|
/// returns the in/out operand, if it exists: example would be (%node = add rax, rcx) -> rax
|
||||||
fn dst_node(&self, node: NodeRef) -> Option<NodeRef> {
|
fn dst_node(&self, node: NodeRef) -> Option<NodeRef> {
|
||||||
// for each node, look at the dst node and see if it has preferred
|
// for each node, look at the dst node and see if it has preferred
|
||||||
// color, then also prefer that color.
|
// color, then also prefer that color.
|
||||||
|
@ -2463,7 +2470,7 @@ impl Mir {
|
||||||
let rhs = self.node_as_operand(&liveness, &mapping, &mut func, strings, rhs);
|
let rhs = self.node_as_operand(&liveness, &mapping, &mut func, strings, rhs);
|
||||||
|
|
||||||
writeln!(func.current_branch(), "mulss {lhs}, {rhs}")?;
|
writeln!(func.current_branch(), "mulss {lhs}, {rhs}")?;
|
||||||
if lhs.occupy_same_register(dst) {
|
if !lhs.occupy_same_register(dst) {
|
||||||
writeln!(func.current_branch(), "movss {dst}, {lhs}")?;
|
writeln!(func.current_branch(), "movss {dst}, {lhs}")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2474,7 +2481,7 @@ impl Mir {
|
||||||
let rhs = self.node_as_operand(&liveness, &mapping, &mut func, strings, rhs);
|
let rhs = self.node_as_operand(&liveness, &mapping, &mut func, strings, rhs);
|
||||||
|
|
||||||
writeln!(func.current_branch(), "divss {lhs}, {rhs}")?;
|
writeln!(func.current_branch(), "divss {lhs}, {rhs}")?;
|
||||||
if lhs.occupy_same_register(dst) {
|
if !lhs.occupy_same_register(dst) {
|
||||||
writeln!(func.current_branch(), "movss {dst}, {lhs}")?;
|
writeln!(func.current_branch(), "movss {dst}, {lhs}")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue