From e4da9cc927c18eadcf74e9f1f892fd540b84f424 Mon Sep 17 00:00:00 2001 From: Jakub Doka Date: Thu, 14 Nov 2024 21:50:10 +0100 Subject: [PATCH] adding regalloc, fixing needless semicolon insertion --- lang/src/fmt.rs | 2 +- lang/src/son/hbvm/my_regalloc.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lang/src/fmt.rs b/lang/src/fmt.rs index caad9ec1..e8c18628 100644 --- a/lang/src/fmt.rs +++ b/lang/src/fmt.rs @@ -149,7 +149,7 @@ impl<'a> Formatter<'a> { if let Some(expr) = list.get(i + 1) && 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(";")?; } if preserve_newlines(&self.source[..expr.posi() as usize]) > 1 { diff --git a/lang/src/son/hbvm/my_regalloc.rs b/lang/src/son/hbvm/my_regalloc.rs index ad335698..3d8feab4 100644 --- a/lang/src/son/hbvm/my_regalloc.rs +++ b/lang/src/son/hbvm/my_regalloc.rs @@ -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())); self.emit(instrs::cp(r, *alloc_buf.last().unwrap())) }