Reduced usage of temporary registers

This commit is contained in:
2024-07-10 10:48:15 +02:00
parent 4386392844
commit d3436b13a5
6 changed files with 13 additions and 25 deletions

View File

@ -1,8 +1,6 @@
package core
import (
"fmt"
"git.akyoto.dev/cli/q/src/build/ast"
"git.akyoto.dev/cli/q/src/build/config"
"git.akyoto.dev/cli/q/src/build/errors"
@ -43,7 +41,7 @@ func (f *Function) CompileDefinition(node *ast.Define) error {
func (f *Function) AddVariable(variable *Variable) {
if config.Comments {
f.Comment(fmt.Sprintf("%s = %s (%s, %d uses)", variable.Name, variable.Value, variable.Register, variable.Alive))
f.Comment("%s = %s (%s, %d uses)", variable.Name, variable.Value, variable.Register, variable.Alive)
}
f.variables[variable.Name] = variable
@ -60,7 +58,7 @@ func (f *Function) useVariable(variable *Variable) {
if variable.Alive == 0 {
if config.Comments {
f.Comment(fmt.Sprintf("%s died (%s)", variable.Name, variable.Register))
f.Comment("%s died (%s)", variable.Name, variable.Register)
}
f.cpu.Free(variable.Register)