mirror of
https://github.com/KarolS/millfork.git
synced 2025-02-06 17:30:05 +00:00
Z80: Various optimizations, mostly from z80heaven
This commit is contained in:
parent
debeb8a609
commit
466f6e4fea
@ -374,6 +374,14 @@ object AlwaysGoodI80Optimizations {
|
|||||||
Nil
|
Nil
|
||||||
},
|
},
|
||||||
|
|
||||||
|
(Elidable & HasOpcode(ADD) & Has8BitImmediate(1) & DoesntMatterWhatItDoesWithFlagsOtherThanSZ) ~~> { _ =>
|
||||||
|
List(ZLine.register(INC, A))
|
||||||
|
},
|
||||||
|
|
||||||
|
(Elidable & HasOpcode(SUB) & Has8BitImmediate(1) & DoesntMatterWhatItDoesWithFlagsOtherThanSZ) ~~> { _ =>
|
||||||
|
List(ZLine.register(DEC, A))
|
||||||
|
},
|
||||||
|
|
||||||
(Elidable & HasOpcode(ADD_16) & HasRegisters(TwoRegisters(ZRegister.HL, ZRegister.BC)) & HasRegister(ZRegister.BC, 1) & DoesntMatterWhatItDoesWithFlags) ~~> { (code, ctx) =>
|
(Elidable & HasOpcode(ADD_16) & HasRegisters(TwoRegisters(ZRegister.HL, ZRegister.BC)) & HasRegister(ZRegister.BC, 1) & DoesntMatterWhatItDoesWithFlags) ~~> { (code, ctx) =>
|
||||||
List(ZLine.register(ZOpcode.INC_16, ZRegister.HL))
|
List(ZLine.register(ZOpcode.INC_16, ZRegister.HL))
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package millfork.assembly.z80.opt
|
package millfork.assembly.z80.opt
|
||||||
|
|
||||||
import millfork.assembly.AssemblyOptimization
|
import millfork.assembly.AssemblyOptimization
|
||||||
import millfork.assembly.z80.{ZLine, ZOpcode}
|
import millfork.assembly.z80._
|
||||||
import millfork.node.ZRegister
|
import millfork.node.ZRegister
|
||||||
import ZOpcode._
|
import ZOpcode._
|
||||||
import ZRegister._
|
import ZRegister._
|
||||||
@ -23,6 +23,29 @@ object LaterI80Optimizations {
|
|||||||
(Elidable & HasOpcode(CP) & Has8BitImmediate(0) & DoesntMatterWhatItDoesWithFlagsOtherThanSZ) ~~> { _ =>
|
(Elidable & HasOpcode(CP) & Has8BitImmediate(0) & DoesntMatterWhatItDoesWithFlagsOtherThanSZ) ~~> { _ =>
|
||||||
List(ZLine.register(OR, A))
|
List(ZLine.register(OR, A))
|
||||||
},
|
},
|
||||||
|
(Elidable & HasOpcode(CP) & Has8BitImmediate(1) & DoesntMatterWhatItDoesWithFlagsOtherThanSZ & DoesntMatterWhatItDoesWith(A)) ~~> { _ =>
|
||||||
|
List(ZLine.register(DEC, A))
|
||||||
|
},
|
||||||
|
(Elidable & HasOpcode(CP) & Has8BitImmediate(255) & DoesntMatterWhatItDoesWithFlagsOtherThanSZ & DoesntMatterWhatItDoesWith(A)) ~~> { _ =>
|
||||||
|
List(ZLine.register(INC, A))
|
||||||
|
},
|
||||||
|
|
||||||
|
(Elidable & HasOpcodeIn(Set(JP, JR)) & HasRegisters(IfFlagClear(ZFlag.C)) & MatchParameter(0)) ~
|
||||||
|
(Elidable & HasOpcode(INC) & HasRegisterParam(A) & DoesntMatterWhatItDoesWithFlags) ~
|
||||||
|
(HasOpcode(LABEL) & MatchParameter(0)) ~~> (code => List(ZLine.imm8(ADC, 0), code.last)),
|
||||||
|
|
||||||
|
(Elidable & HasOpcodeIn(Set(JP, JR)) & HasRegisters(IfFlagSet(ZFlag.C)) & MatchParameter(0)) ~
|
||||||
|
(Elidable & HasOpcode(INC) & HasRegisterParam(A) & DoesntMatterWhatItDoesWithFlags) ~
|
||||||
|
(HasOpcode(LABEL) & MatchParameter(0)) ~~> (code => List(ZLine.implied(CCF), ZLine.imm8(ADC, 0), code.last)),
|
||||||
|
|
||||||
|
(Elidable & HasOpcodeIn(Set(JP, JR)) & HasRegisters(IfFlagClear(ZFlag.C)) & MatchParameter(0)) ~
|
||||||
|
(Elidable & HasOpcode(DEC) & HasRegisterParam(A) & DoesntMatterWhatItDoesWithFlags) ~
|
||||||
|
(HasOpcode(LABEL) & MatchParameter(0)) ~~> (code => List(ZLine.imm8(SBC, 0), code.last)),
|
||||||
|
|
||||||
|
(Elidable & HasOpcodeIn(Set(JP, JR)) & HasRegisters(IfFlagSet(ZFlag.C)) & MatchParameter(0)) ~
|
||||||
|
(Elidable & HasOpcode(DEC) & HasRegisterParam(A) & DoesntMatterWhatItDoesWithFlags) ~
|
||||||
|
(HasOpcode(LABEL) & MatchParameter(0)) ~~> (code => List(ZLine.implied(CCF), ZLine.imm8(SBC, 0), code.last)),
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val FreeHL = new RuleBasedAssemblyOptimization("Free HL (later)",
|
val FreeHL = new RuleBasedAssemblyOptimization("Free HL (later)",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user