Implemented a basic optimization
This commit is contained in:
parent
58d3aaf21d
commit
6102ab466a
8 changed files with 48 additions and 14 deletions
|
@ -47,6 +47,13 @@ func NewFunction(name string, file *fs.File, body token.List) *Function {
|
|||
func (f *Function) Compile() {
|
||||
defer close(f.finished)
|
||||
f.assembler.Label(asm.LABEL, f.Name)
|
||||
|
||||
for _, register := range f.cpu.Input {
|
||||
if f.cpu.IsUsed(register) {
|
||||
f.SaveRegister(register)
|
||||
}
|
||||
}
|
||||
|
||||
f.err = f.CompileTokens(f.Body)
|
||||
f.assembler.Return()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue