Simplified file structure

This commit is contained in:
Eduard Urbach 2024-08-07 19:39:10 +02:00
parent cacee7260a
commit a466281307
Signed by: eduard
GPG key ID: 49226B848C78F6C8
219 changed files with 453 additions and 457 deletions

View file

@ -1,30 +0,0 @@
package asm
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 len(a.Instructions) == 0 {
return false
}
last := a.Instructions[len(a.Instructions)-1]
if mnemonic == MOVE && last.Mnemonic == MOVE {
data, isRegReg := last.Data.(*RegisterRegister)
if !isRegReg {
return false
}
if data.Destination == left && data.Source == right {
return true
}
if data.Destination == right && data.Source == left {
return true
}
}
return false
}