diff --git a/.gitignore b/.gitignore index ef6b0f5..0441fe5 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ __pycache__ test/* !test/test_src +!test/longer-cases !test/script.gdb !test/build_* !test/run_* diff --git a/src/riscv/before_alloc.mbt b/src/riscv/before_alloc.mbt index a97e3fc..ce59226 100644 --- a/src/riscv/before_alloc.mbt +++ b/src/riscv/before_alloc.mbt @@ -13,7 +13,7 @@ fn reserve_swap_reg(cfg : @ssacfg.SsaCfg, block : @ssacfg.Block) -> Unit { match inst { Prim(bind, Math(_) | Eq | Le as op, [lhs, rhs]) as inst => if is_imm(lhs) && is_imm(rhs) { - let tmp = cfg.new_named("tmp_swap", ty=Double) + let tmp = cfg.new_named("tmp_swap", ty=lhs.get_type()) insts.push(@ssacfg.Inst::Copy(tmp, lhs)) insts.push(Prim(bind, op, [Var(tmp), rhs])) } else { diff --git a/src/riscv/extern_stub.mbt b/src/riscv/extern_stub.mbt index b1a8d47..8ad6591 100644 --- a/src/riscv/extern_stub.mbt +++ b/src/riscv/extern_stub.mbt @@ -121,6 +121,9 @@ fn generate_stub(cfg : @ssacfg.SsaCfg) -> AssemblyFunction { body.append( [ Label(stub_resolved), + Comment("Round down the stack for alignment, giving up the space"), + Li(T5, "-16"), + And(Sp, Sp, T5), Comment("Call the external function"), Jalr(T6), Comment("Put continuation at \{kont_reg}"),