Moved register state to scopes

This commit is contained in:
Eduard Urbach 2024-07-16 15:30:28 +02:00
parent 3bd5b20af3
commit 545c8dd4f6
Signed by: eduard
GPG key ID: 49226B848C78F6C8
22 changed files with 230 additions and 129 deletions

View file

@ -8,7 +8,7 @@ import (
// SaveRegister attempts to move a variable occupying this register to another register.
func (f *Function) SaveRegister(register cpu.Register) {
if !f.cpu.IsUsed(register) {
if !f.Scope().IsUsed(register) {
return
}
@ -24,8 +24,8 @@ func (f *Function) SaveRegister(register cpu.Register) {
return
}
newRegister := f.cpu.MustFindFree(f.cpu.General)
f.cpu.Reserve(newRegister)
newRegister := f.Scope().MustFindFree(f.cpu.General)
f.Scope().Reserve(newRegister)
if config.Comments {
f.Comment("save %s to %s", register, newRegister)