Fixed register allocation on function calls
This commit is contained in:
parent
f76f0a1e4b
commit
64bd2bae59
5 changed files with 40 additions and 67 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue