1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-23 23:30:22 +00:00

Optimizer shouldn't remove LDA's before TSR and TRB

This commit is contained in:
Karol Stasiak 2018-03-03 14:31:06 +01:00
parent 6ed5d51260
commit 35f06d5486
3 changed files with 11 additions and 6 deletions

View File

@ -13,6 +13,8 @@ object OpcodeClasses {
ADC_W, AND_W, BIT_W, CMP_W, EOR_W, ORA_W, PHA_W, SBC_W, STA_W,
TAX, TAY,
SAX, SBX, ANC, DCP, ISC, RRA, RLA, SRE, SLO, LXA, XAA, AHX, TAS,
TSB, TRB,
TSB_W, TRB_W,
TAZ, TAB,
HuSAX, SAY, TAM,
TCD, TCS, XBA,
@ -24,6 +26,7 @@ object OpcodeClasses {
val ReadsAHAlways = Set(
ADC_W, AND_W, BIT_W, CMP_W, EOR_W, ORA_W, PHA_W, SBC_W, STA_W,
TCD, TCS, XBA,
TSB_W, TRB_W,
)
val ReadsAHIfImplied = Set(
DEC_W, INC_W, ROL_W, ROR_W, ASL_W, LSR_W,
@ -113,6 +116,8 @@ object OpcodeClasses {
val ChangesIZ = Set(
DEZ, INZ, TAZ, LDZ,
)
val ChangesDirectPageRegister = Set(XCE, PLD, TCD)
val ChangesDataBankRegister = Set(XCE, PLB, MVN, MVP)
val ChangesS = Set(
PHA, PLA,
PHA_W, PLA_W,

View File

@ -82,14 +82,14 @@ object Opcode extends Enumeration {
// 65CE02:
CPZ, LDZ, DEZ, INZ,
PHW,
// DEW, INW, ASW, ROW, // aliases for DEC_W, INC_W, ASL_W, ROL_W (?)
// DEW, INW, ASW, ROW, // aliases for DEC_W, INC_W, ASL_W, ROR_W (?)
NEG, ASR,
TAZ, TZA, PHZ, PLZ,
TSY, TYS,
TAB, TBA,
// CLE, SEE,
CLE, SEE, // no idea what these do
BSR,
// MAP,
MAP, // also called AUG
//HuC6280:
CLA, CLX, CLY,
@ -99,13 +99,13 @@ object Opcode extends Enumeration {
// ST0, ST1, ST2,
// BSR, // the same as on 65CE02
TAM, TMA,
// TAI, TIA, TDD, TIN, TII, // memcpy instructions
TAI, TIA, TDD, TIN, TII, // memcpy instructions
TST,
//65816:
BRL,
COP,
// MVN, MVP,
MVN, MVP, // memcpy instructions
PEA, PEI, PER,
PHB, PHD, PHK, PLB, PLD, // there's no PLK for the same reason Intel removed POP CS from 80186
REP, SEP,

View File

@ -37,7 +37,7 @@ object CmosOptimizations {
(Elidable & HasOpcode(AND) & MatchImmediate(1)) ~
(Elidable & HasOpcode(STA) & HasAddrModeIn(Set(Absolute, ZeroPage)) & MatchParameter(0) & DoesntMatterWhatItDoesWith(State.A, State.Z, State.N)) ~~> { code =>
List(
code(1).copy(opcode = Opcode.LDA, parameter = CompoundConstant(MathOperator.Exor, NumericConstant(255, 1), code(1).parameter)),
code(1).copy(opcode = Opcode.LDA, parameter = CompoundConstant(MathOperator.Exor, NumericConstant(255, 1), code(1).parameter).quickSimplify),
code.head.copy(opcode = TRB))
},
)