Improved code generation

This commit is contained in:
Eduard Urbach 2024-07-09 17:00:04 +02:00
parent 6e22febc01
commit 3c189a025f
Signed by: eduard
GPG key ID: 49226B848C78F6C8
23 changed files with 201 additions and 95 deletions

View file

@ -68,16 +68,6 @@ func (a *Assembler) Call(name string) {
})
}
// Jump jumps to a position that is identified by a label.
func (a *Assembler) Jump(name string) {
a.Instructions = append(a.Instructions, Instruction{
Mnemonic: JUMP,
Data: &Label{
Name: name,
},
})
}
// Return returns back to the caller.
func (a *Assembler) Return() {
if len(a.Instructions) > 0 && a.Instructions[len(a.Instructions)-1].Mnemonic == RETURN {

View file

@ -4,10 +4,6 @@ import "git.akyoto.dev/cli/q/src/build/cpu"
// unnecessary returns true if the register/register operation can be skipped.
func (a *Assembler) unnecessary(mnemonic Mnemonic, left cpu.Register, right cpu.Register) bool {
if mnemonic == MOVE && left == right {
return true
}
if len(a.Instructions) == 0 {
return false
}