OptDupLoads shouldn't silently do optimizations.
This commit is contained in:
parent
f45d2515eb
commit
ae340703f2
2 changed files with 17 additions and 5 deletions
|
@ -1147,8 +1147,9 @@ unsigned OptDupLoads (CodeSeg* S)
|
||||||
/* Get next entry */
|
/* Get next entry */
|
||||||
CodeEntry* E = CS_GetEntry (S, I);
|
CodeEntry* E = CS_GetEntry (S, I);
|
||||||
|
|
||||||
/* Assume we won't delete the entry */
|
/* Assume we won't delete or replace the entry */
|
||||||
int Delete = 0;
|
int Delete = 0;
|
||||||
|
opc_t NewOPC = OP65_INVALID;
|
||||||
|
|
||||||
/* Get a pointer to the input registers of the insn */
|
/* Get a pointer to the input registers of the insn */
|
||||||
const RegContents* In = &E->RI->In;
|
const RegContents* In = &E->RI->In;
|
||||||
|
@ -1218,7 +1219,7 @@ unsigned OptDupLoads (CodeSeg* S)
|
||||||
E->AM != AM65_ABSY &&
|
E->AM != AM65_ABSY &&
|
||||||
E->AM != AM65_ZPY) {
|
E->AM != AM65_ZPY) {
|
||||||
/* Use the A register instead */
|
/* Use the A register instead */
|
||||||
CE_ReplaceOPC (E, OP65_STA);
|
NewOPC = OP65_STA;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1242,11 +1243,11 @@ unsigned OptDupLoads (CodeSeg* S)
|
||||||
*/
|
*/
|
||||||
} else if (RegValIsKnown (In->RegY)) {
|
} else if (RegValIsKnown (In->RegY)) {
|
||||||
if (In->RegY == In->RegA) {
|
if (In->RegY == In->RegA) {
|
||||||
CE_ReplaceOPC (E, OP65_STA);
|
NewOPC = OP65_STA;
|
||||||
} else if (In->RegY == In->RegX &&
|
} else if (In->RegY == In->RegX &&
|
||||||
E->AM != AM65_ABSX &&
|
E->AM != AM65_ABSX &&
|
||||||
E->AM != AM65_ZPX) {
|
E->AM != AM65_ZPX) {
|
||||||
CE_ReplaceOPC (E, OP65_STX);
|
NewOPC = OP65_STX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1319,6 +1320,14 @@ unsigned OptDupLoads (CodeSeg* S)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
if (NewOPC != OP65_INVALID) {
|
||||||
|
/* Replace the opcode */
|
||||||
|
CE_ReplaceOPC (E, NewOPC);
|
||||||
|
|
||||||
|
/* Remember, we had changes */
|
||||||
|
++Changes;
|
||||||
|
}
|
||||||
|
|
||||||
/* Next entry */
|
/* Next entry */
|
||||||
++I;
|
++I;
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,10 @@ typedef enum {
|
||||||
OP65_TYA,
|
OP65_TYA,
|
||||||
|
|
||||||
/* Number of opcodes available */
|
/* Number of opcodes available */
|
||||||
OP65_COUNT
|
OP65_COUNT,
|
||||||
|
|
||||||
|
/* Invalid opcode */
|
||||||
|
OP65_INVALID = OP65_COUNT,
|
||||||
} opc_t;
|
} opc_t;
|
||||||
|
|
||||||
/* 65XX addressing modes */
|
/* 65XX addressing modes */
|
||||||
|
|
Loading…
Add table
Reference in a new issue