Fixed register allocation on function calls

This commit is contained in:
Eduard Urbach 2025-02-05 22:49:39 +01:00
parent f76f0a1e4b
commit 64bd2bae59
Signed by: eduard
GPG key ID: 49226B848C78F6C8
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
}