Fixed register allocation on function calls

This commit is contained in:
2025-02-05 22:49:39 +01:00
parent 5d38a4980a
commit 12894dbcc5
5 changed files with 40 additions and 67 deletions

View File

@ -12,22 +12,6 @@ func (f *Function) CompileNew(root *expression.Expression) error {
typ := f.Types[structName]
f.SaveRegister(f.CPU.Input[0])
f.RegisterNumber(asm.MOVE, f.CPU.Input[0], typ.Size())
for _, register := range f.CPU.General {
if f.RegisterIsUsed(register) {
f.Register(asm.PUSH, register)
}
}
f.Call("mem.alloc")
for i := len(f.CPU.General) - 1; i >= 0; i-- {
register := f.CPU.General[i]
if f.RegisterIsUsed(register) {
f.Register(asm.POP, register)
}
}
f.CallSafe(f.Functions["mem.alloc"], f.CPU.Input[:1])
return nil
}