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

@ -4,19 +4,12 @@ import (
"git.akyoto.dev/cli/q/src/build/ast"
"git.akyoto.dev/cli/q/src/build/cpu"
"git.akyoto.dev/cli/q/src/build/expression"
"git.akyoto.dev/cli/q/src/build/token"
)
// UsesRegister returns true if evaluating the expression would write or read the given register.
func (f *Function) UsesRegister(expr *expression.Expression, register cpu.Register) bool {
if expr.IsLeaf() {
if expr.Token.Kind == token.Number {
return false
}
name := expr.Token.Text()
variable := f.variables[name]
return register == variable.Register
return false
}
if ast.IsFunctionCall(expr) {