adding regalloc, fixing needless semicolon insertion

This commit is contained in:
Jakub Doka 2024-11-14 21:50:10 +01:00
parent 454b0ffd1c
commit e4da9cc927
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
2 changed files with 5 additions and 2 deletions

View file

@ -149,7 +149,7 @@ impl<'a> Formatter<'a> {
if let Some(expr) = list.get(i + 1) if let Some(expr) = list.get(i + 1)
&& let Some(rest) = self.source.get(expr.posi() as usize..) && let Some(rest) = self.source.get(expr.posi() as usize..)
{ {
if insert_needed_semicolon(rest) { if sep.is_empty() && insert_needed_semicolon(rest) {
f.write_str(";")?; f.write_str(";")?;
} }
if preserve_newlines(&self.source[..expr.posi() as usize]) > 1 { if preserve_newlines(&self.source[..expr.posi() as usize]) > 1 {

View file

@ -240,7 +240,10 @@ impl HbvmBackend {
}; };
} }
if let Some(PLoc::Ref(r, ..)) = ret { if node.ty.loc(tys) == Loc::Stack
&& let Some(PLoc::Reg(r, ..) | PLoc::WideReg(r, ..) | PLoc::Ref(r, ..)) =
ret
{
alloc_buf.push(atr(*node.inputs.last().unwrap())); alloc_buf.push(atr(*node.inputs.last().unwrap()));
self.emit(instrs::cp(r, *alloc_buf.last().unwrap())) self.emit(instrs::cp(r, *alloc_buf.last().unwrap()))
} }