1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-28 06:30:16 +00:00

add extra optimizer step that replaces BRA by JMP if the target is external

This commit is contained in:
mrdudz 2022-05-08 13:20:18 +02:00
parent 4ddbe5f838
commit 8ec41083e9
2 changed files with 34 additions and 0 deletions

View File

@ -194,6 +194,37 @@ unsigned OptBranchDist (CodeSeg* S)
unsigned OptBranchDist2 (CodeSeg* S)
/* Change BRA to JMP if target is an external symbol */
{
unsigned Changes = 0;
/* Walk over the entries */
unsigned I = 0;
while (I < CS_GetEntryCount (S)) {
/* Get next entry */
CodeEntry* E = CS_GetEntry (S, I);
if ((CPUIsets[CPU] & (CPU_ISET_65SC02 |CPU_ISET_6502DTV)) != 0 && /* CPU has BRA */
(E->Info & OF_UBRA) != 0 && /* is a unconditional branch */
E->JumpTo == NULL) { /* target is extern */
/* BRA jumps to external symbol and must be replaced by a JMP on the 65C02 CPU */
CE_ReplaceOPC (E, OP65_JMP);
++Changes;
}
/* Next entry */
++I;
}
/* Return the number of changes made */
return Changes;
}
/*****************************************************************************/
/* Replace jumps to RTS by RTS */
/*****************************************************************************/

View File

@ -52,6 +52,9 @@
unsigned OptBranchDist (CodeSeg* S);
/* Change branches for the distance needed. */
unsigned OptBranchDist2 (CodeSeg* S);
/* If BRA points to an external symbol, change it to JMP */
unsigned OptRTSJumps1 (CodeSeg* S);
/* Replace jumps to RTS by RTS */