Improved variable lifetime tracking
This commit is contained in:
@ -2,6 +2,7 @@ package build
|
||||
|
||||
import (
|
||||
"git.akyoto.dev/cli/q/src/build/asm"
|
||||
"git.akyoto.dev/cli/q/src/build/config"
|
||||
"git.akyoto.dev/cli/q/src/build/cpu"
|
||||
)
|
||||
|
||||
@ -20,7 +21,7 @@ func (f *Function) SaveRegister(register cpu.Register) {
|
||||
}
|
||||
}
|
||||
|
||||
if variable == nil || variable.UsesRemaining == 0 {
|
||||
if variable == nil || variable.Alive == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
@ -30,6 +31,10 @@ func (f *Function) SaveRegister(register cpu.Register) {
|
||||
panic("no free registers")
|
||||
}
|
||||
|
||||
if config.Verbose {
|
||||
f.Logf("moving %s from %s to %s (alive: %d)", variable.Name, variable.Register, newRegister, variable.Alive)
|
||||
}
|
||||
|
||||
f.assembler.RegisterRegister(asm.MOVE, newRegister, register)
|
||||
f.cpu.Free(register)
|
||||
f.cpu.Use(newRegister)
|
||||
|
Reference in New Issue
Block a user