Moved register state to scopes
This commit is contained in:
parent
3bd5b20af3
commit
545c8dd4f6
22 changed files with 230 additions and 129 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue