Simplified file structure

This commit is contained in:
2024-08-07 19:39:10 +02:00
parent 1b13539b22
commit 66569446b1
219 changed files with 453 additions and 457 deletions

View File

@ -0,0 +1,29 @@
package register
import (
"slices"
"git.akyoto.dev/cli/q/src/asm"
"git.akyoto.dev/cli/q/src/cpu"
)
// SaveRegister attempts to move a variable occupying this register to another register.
func (f *Machine) SaveRegister(register cpu.Register) {
if !f.RegisterIsUsed(register) {
return
}
if slices.Contains(f.CPU.General, register) {
return
}
variable := f.VariableByRegister(register)
if variable == nil || variable.Alive == 0 {
return
}
newRegister := f.NewRegister()
f.RegisterRegister(asm.MOVE, newRegister, register)
variable.Register = newRegister
}