Merge jsr pushax/j?? popax into nothing or RTS
This commit is contained in:
@@ -218,6 +218,7 @@ static OptFunc DOptSub3 = { OptSub3, "OptSub3", 100, 0,
|
|||||||
static OptFunc DOptTest1 = { OptTest1, "OptTest1", 65, 0, 0, 0, 0, 0 };
|
static OptFunc DOptTest1 = { OptTest1, "OptTest1", 65, 0, 0, 0, 0, 0 };
|
||||||
static OptFunc DOptTest2 = { OptTest2, "OptTest2", 50, 0, 0, 0, 0, 0 };
|
static OptFunc DOptTest2 = { OptTest2, "OptTest2", 50, 0, 0, 0, 0, 0 };
|
||||||
static OptFunc DOptTosLoadPop = { OptTosLoadPop, "OptTosLoadPop", 50, 0, 0, 0, 0, 0 };
|
static OptFunc DOptTosLoadPop = { OptTosLoadPop, "OptTosLoadPop", 50, 0, 0, 0, 0, 0 };
|
||||||
|
static OptFunc DOptTosPushPop = { OptTosPushPop, "OptTosPushPop", 33, 0, 0, 0, 0, 0 };
|
||||||
static OptFunc DOptTransfers1 = { OptTransfers1, "OptTransfers1", 0, 0, 0, 0, 0, 0 };
|
static OptFunc DOptTransfers1 = { OptTransfers1, "OptTransfers1", 0, 0, 0, 0, 0, 0 };
|
||||||
static OptFunc DOptTransfers2 = { OptTransfers2, "OptTransfers2", 60, 0, 0, 0, 0, 0 };
|
static OptFunc DOptTransfers2 = { OptTransfers2, "OptTransfers2", 60, 0, 0, 0, 0, 0 };
|
||||||
static OptFunc DOptTransfers3 = { OptTransfers3, "OptTransfers3", 65, 0, 0, 0, 0, 0 };
|
static OptFunc DOptTransfers3 = { OptTransfers3, "OptTransfers3", 65, 0, 0, 0, 0, 0 };
|
||||||
@@ -344,11 +345,12 @@ static OptFunc* OptFuncs[] = {
|
|||||||
&DOptSub3,
|
&DOptSub3,
|
||||||
&DOptTest1,
|
&DOptTest1,
|
||||||
&DOptTest2,
|
&DOptTest2,
|
||||||
|
&DOptTosLoadPop,
|
||||||
|
&DOptTosPushPop,
|
||||||
&DOptTransfers1,
|
&DOptTransfers1,
|
||||||
&DOptTransfers2,
|
&DOptTransfers2,
|
||||||
&DOptTransfers3,
|
&DOptTransfers3,
|
||||||
&DOptTransfers4,
|
&DOptTransfers4,
|
||||||
&DOptTosLoadPop,
|
|
||||||
&DOptUnusedLoads,
|
&DOptUnusedLoads,
|
||||||
&DOptUnusedStores,
|
&DOptUnusedStores,
|
||||||
/* END SORTED_CODEOPT.SH */
|
/* END SORTED_CODEOPT.SH */
|
||||||
@@ -924,6 +926,7 @@ static unsigned RunOptGroup7 (CodeSeg* S)
|
|||||||
/* Re-optimize JSR/RTS that may now be grouped */
|
/* Re-optimize JSR/RTS that may now be grouped */
|
||||||
C += RunOptFunc (S, &DOptRTS, 1);
|
C += RunOptFunc (S, &DOptRTS, 1);
|
||||||
C += RunOptFunc (S, &DOptTosLoadPop, 5);
|
C += RunOptFunc (S, &DOptTosLoadPop, 5);
|
||||||
|
C += RunOptFunc (S, &DOptTosPushPop, 5);
|
||||||
|
|
||||||
Changes += C;
|
Changes += C;
|
||||||
/* If we had changes, we must run dead code elimination again,
|
/* If we had changes, we must run dead code elimination again,
|
||||||
|
|||||||
@@ -1201,3 +1201,54 @@ unsigned OptBinOps2 (CodeSeg* S)
|
|||||||
/* Return the number of changes made */
|
/* Return the number of changes made */
|
||||||
return Changes;
|
return Changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned OptTosPushPop(CodeSeg *S)
|
||||||
|
/* Merge jsr pushax/j?? popax */
|
||||||
|
{
|
||||||
|
unsigned Changes = 0;
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
|
/* Walk over the entries */
|
||||||
|
I = 0;
|
||||||
|
while (I < CS_GetEntryCount (S)) {
|
||||||
|
|
||||||
|
const CodeEntry* N;
|
||||||
|
|
||||||
|
/* Get the next entry */
|
||||||
|
const CodeEntry* E = CS_GetEntry (S, I);
|
||||||
|
|
||||||
|
/* Check for decspn, incspn, subysp or addysp */
|
||||||
|
if (E->OPC == OP65_JSR &&
|
||||||
|
strcmp(E->Arg, "pushax") == 0 &&
|
||||||
|
(N = CS_GetNextEntry (S, I)) != 0 &&
|
||||||
|
(N->OPC == OP65_JSR || N->OPC == OP65_JMP) &&
|
||||||
|
strcmp(N->Arg, "popax") == 0 &&
|
||||||
|
!CE_HasLabel (N)) {
|
||||||
|
|
||||||
|
/* Delete the old code */
|
||||||
|
CS_DelEntries (S, I, 2);
|
||||||
|
|
||||||
|
/* Insert an rts if jmp popax */
|
||||||
|
if (N->OPC == OP65_JMP) {
|
||||||
|
CodeEntry* X = NewCodeEntry (OP65_RTS, AM65_IMP, 0, 0, E->LI);
|
||||||
|
CS_InsertEntry (S, X, I);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Regenerate register info */
|
||||||
|
CS_GenRegInfo (S);
|
||||||
|
|
||||||
|
/* Remember we had changes */
|
||||||
|
++Changes;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
/* Next entry */
|
||||||
|
++I;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the number of changes made */
|
||||||
|
return Changes;
|
||||||
|
}
|
||||||
|
|||||||
@@ -134,7 +134,8 @@ unsigned OptBinOps2 (CodeSeg* S);
|
|||||||
unsigned OptTosLoadPop (CodeSeg* S);
|
unsigned OptTosLoadPop (CodeSeg* S);
|
||||||
/* Merge jsr ldax0sp / jsr|jmp incsp2 into jsr|jmp popax */
|
/* Merge jsr ldax0sp / jsr|jmp incsp2 into jsr|jmp popax */
|
||||||
|
|
||||||
|
unsigned OptTosPushPop(CodeSeg *S);
|
||||||
|
/* Merge jsr pushax/j?? popax */
|
||||||
|
|
||||||
/* End of coptmisc.h */
|
/* End of coptmisc.h */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user