Reduced usage of temporary registers

This commit is contained in:
Eduard Urbach 2024-07-10 10:48:15 +02:00
parent 3c189a025f
commit 75a8823b13
Signed by: eduard
GPG key ID: 49226B848C78F6C8
6 changed files with 13 additions and 25 deletions

View file

@ -3,6 +3,7 @@ package core
import (
"git.akyoto.dev/cli/q/src/build/asm"
"git.akyoto.dev/cli/q/src/build/ast"
"git.akyoto.dev/cli/q/src/build/config"
"git.akyoto.dev/cli/q/src/build/cpu"
"git.akyoto.dev/cli/q/src/build/errors"
"git.akyoto.dev/cli/q/src/build/expression"
@ -34,6 +35,10 @@ func (f *Function) ExpressionToRegister(node *expression.Expression, register cp
if f.UsesRegister(right, register) {
register = f.cpu.MustFindFree(f.cpu.General)
if config.Comments {
f.Comment("temporary register %s", register)
}
}
f.cpu.Reserve(register)