1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-07-05 09:28:54 +00:00

Don't deduplicate non-elidable code

This commit is contained in:
Karol Stasiak 2018-10-04 23:23:04 +02:00
parent ed38b00031
commit 6b43f73f57
3 changed files with 9 additions and 9 deletions

View File

@ -51,7 +51,7 @@ class MosDeduplicate(env: Environment, options: CompilationOptions) extends Dedu
private val badAddressingModes = Set(Stack, IndexedSY, AbsoluteIndexedX, Indirect, LongIndirect)
override def isExtractable(line: AssemblyLine): Boolean =
goodOpcodes(line.opcode) && !badAddressingModes(line.addrMode)
line.elidable && goodOpcodes(line.opcode) && !badAddressingModes(line.addrMode)
override def isBadExtractedCodeHead(head: AssemblyLine): Boolean = false

View File

@ -49,13 +49,13 @@ class Z80Deduplicate(env: Environment, options: CompilationOptions) extends Dedu
)
override def isExtractable(line: ZLine): Boolean = {
alwaysGoodOpcodes(line.opcode) ||
line.elidable && (alwaysGoodOpcodes(line.opcode) ||
conditionallyGoodOpcodes(line.opcode) && (line.registers match {
case OneRegister(SP) => false
case TwoRegisters(_, SP) => false
case TwoRegisters(SP, _) => false
case _ => true
})
}))
}
override def isBadExtractedCodeHead(head: ZLine): Boolean = false

View File

@ -178,28 +178,28 @@ class AssemblySuite extends FunSuite with Matchers with AppendedClues {
| e()
| f()
| }
| noinline void a() {
| void a() {
| port = 1
| }
| noinline void b() {
| void b() {
| port_alt = 2
| }
| noinline asm void c() {
| asm void c() {
| lda #3
| sta 1
| rts
| }
| noinline asm void d() {
| asm void d() {
| lda #4
| sta port
| rts
| }
| noinline asm void e() {
| asm void e() {
| lda #5
| sta port_addr
| rts
| }
| noinline asm void f() {
| asm void f() {
| lda #6
| sta port_alt
| rts