forked from AbleOS/holey-bytes
Removing some clones and fixing parent scoping in case of globals
Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
parent
c553c3d9e9
commit
c5d5301b7b
|
@ -31,6 +31,7 @@ use {
|
|||
},
|
||||
hashbrown::hash_map,
|
||||
hbbytecode::DisasmError,
|
||||
std::panic,
|
||||
};
|
||||
|
||||
pub const VOID: Nid = 0;
|
||||
|
@ -183,8 +184,7 @@ impl Nodes {
|
|||
|
||||
for l in self[LOOPS].outputs.clone() {
|
||||
if !seen.get(l) {
|
||||
self[l].outputs.push(NEVER);
|
||||
self[NEVER].inputs.push(l);
|
||||
self.bind(l, NEVER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -412,13 +412,13 @@ impl Nodes {
|
|||
return;
|
||||
}
|
||||
|
||||
for usage in self[node].outputs.clone() {
|
||||
for &usage in self[node].outputs.iter() {
|
||||
if self.is_forward_edge(usage, node) && self[node].kind == Kind::Stre {
|
||||
self.push_down(usage, visited, antideps, scheds, antidep_bounds);
|
||||
}
|
||||
}
|
||||
|
||||
for usage in self[node].outputs.clone() {
|
||||
for &usage in self[node].outputs.iter() {
|
||||
if self.is_forward_edge(usage, node) {
|
||||
self.push_down(usage, visited, antideps, scheds, antidep_bounds);
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ impl Nodes {
|
|||
return min;
|
||||
}
|
||||
|
||||
for out in self[self[load].inputs[2]].outputs.clone() {
|
||||
for &out in self[self[load].inputs[2]].outputs.iter() {
|
||||
match self[out].kind {
|
||||
Kind::Stre => {
|
||||
let mut cursor = scheds[out as usize];
|
||||
|
@ -1069,6 +1069,48 @@ impl Nodes {
|
|||
return Some(self.new_node(ty, K::BinOp { op }, [ctrl, a, new_rhs], tys));
|
||||
}
|
||||
|
||||
//if op == T::Add
|
||||
// && self[rhs].kind == (K::BinOp { op: T::Mul })
|
||||
// && let &[_, mul_lhs, mul_rhs] = self[rhs].inputs.as_slice()
|
||||
// && self[mul_lhs].kind == K::Phi
|
||||
// && let &[phi_ctrl, phi_lhs, phi_rhs] = self[mul_lhs].inputs.as_slice()
|
||||
// && phi_rhs != VOID
|
||||
// && self[phi_ctrl].kind == K::Loop
|
||||
// && self[phi_rhs].kind == (K::BinOp { op: T::Add })
|
||||
// && self[phi_rhs].inputs[1] == mul_lhs
|
||||
//{
|
||||
// debug_assert_eq!(
|
||||
// self[mul_lhs].outputs.len(),
|
||||
// 1,
|
||||
// "{:?}",
|
||||
// self[mul_lhs]
|
||||
// .outputs
|
||||
// .iter()
|
||||
// .map(|&n| (
|
||||
// &self[n].kind,
|
||||
// self[n].inputs.iter().position(|&n| n == mul_lhs)
|
||||
// ))
|
||||
// .collect::<Vec<_>>()
|
||||
// );
|
||||
|
||||
// let init_shift = self.new_node(
|
||||
// self[rhs].ty,
|
||||
// K::BinOp { op: T::Mul },
|
||||
// [ctrl, phi_lhs, mul_rhs],
|
||||
// tys,
|
||||
// );
|
||||
// let init =
|
||||
// self.new_node(ty, K::BinOp { op: T::Add }, [ctrl, lhs, init_shift], tys);
|
||||
// let new_value = self.new_node_nop(ty, K::Phi, [phi_ctrl, init, 0]);
|
||||
// let next = self.new_node(
|
||||
// ty,
|
||||
// Kind::BinOp { op: T::Add },
|
||||
// [ctrl, new_value, mul_rhs],
|
||||
// tys,
|
||||
// );
|
||||
// return Some(self.modify_input(new_value, 2, next));
|
||||
//}
|
||||
|
||||
if changed {
|
||||
return Some(self.new_node(ty, self[target].kind, [ctrl, lhs, rhs], tys));
|
||||
}
|
||||
|
@ -1976,7 +2018,7 @@ impl Nodes {
|
|||
return;
|
||||
}
|
||||
|
||||
let node = self[nd].clone();
|
||||
let node = &self[nd];
|
||||
for &i in &node.inputs[1..] {
|
||||
let dom = self.idom(i, scheds);
|
||||
debug_assert!(
|
||||
|
@ -5462,12 +5504,12 @@ impl<'a> Codegen<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn eval_global(&mut self, file: Module, name: Ident, expr: &Expr) -> ty::Id {
|
||||
fn eval_global(&mut self, file: Module, parent: ty::Id, name: Ident, expr: &Expr) -> ty::Id {
|
||||
self.ct.activate();
|
||||
|
||||
let gid = self.tys.ins.globals.push(GlobalData { file, name, ..Default::default() });
|
||||
|
||||
self.pool.push_ci(file, self.ci.parent, None, self.tys.tasks.len(), &mut self.ci);
|
||||
self.pool.push_ci(file, parent, None, self.tys.tasks.len(), &mut self.ci);
|
||||
let prev_err_len = self.errors.borrow().len();
|
||||
|
||||
self.expr(&(Expr::Return { pos: expr.pos(), val: Some(expr) }));
|
||||
|
@ -5766,7 +5808,7 @@ impl<'a> Codegen<'a> {
|
|||
_ if sc.alloc_const
|
||||
&& let Some(name) = sc.name =>
|
||||
{
|
||||
self.eval_global(sc.file, name, expr)
|
||||
self.eval_global(sc.file, sc.parent, name, expr)
|
||||
}
|
||||
_ if sc.alloc_const => {
|
||||
ty::Id::from(self.eval_const(sc.file, sc.parent, expr, ty::Id::TYPE))
|
||||
|
|
Loading…
Reference in a new issue