Replace ldaxidx by inline code.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4016 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
33f6c85753
commit
61195d914e
3 changed files with 112 additions and 3 deletions
|
@ -996,6 +996,7 @@ static OptFunc DOptPtrLoad7 = { OptPtrLoad7, "OptPtrLoad7", 65, 0,
|
||||||
static OptFunc DOptPtrLoad8 = { OptPtrLoad8, "OptPtrLoad8", 108, 0, 0, 0, 0, 0 };
|
static OptFunc DOptPtrLoad8 = { OptPtrLoad8, "OptPtrLoad8", 108, 0, 0, 0, 0, 0 };
|
||||||
static OptFunc DOptPtrLoad9 = { OptPtrLoad9, "OptPtrLoad9", 86, 0, 0, 0, 0, 0 };
|
static OptFunc DOptPtrLoad9 = { OptPtrLoad9, "OptPtrLoad9", 86, 0, 0, 0, 0, 0 };
|
||||||
static OptFunc DOptPtrLoad10 = { OptPtrLoad10, "OptPtrLoad10", 100, 0, 0, 0, 0, 0 };
|
static OptFunc DOptPtrLoad10 = { OptPtrLoad10, "OptPtrLoad10", 100, 0, 0, 0, 0, 0 };
|
||||||
|
static OptFunc DOptPtrLoad11 = { OptPtrLoad11, "OptPtrLoad11", 190, 0, 0, 0, 0, 0 };
|
||||||
static OptFunc DOptPtrStore1 = { OptPtrStore1, "OptPtrStore1", 100, 0, 0, 0, 0, 0 };
|
static OptFunc DOptPtrStore1 = { OptPtrStore1, "OptPtrStore1", 100, 0, 0, 0, 0, 0 };
|
||||||
static OptFunc DOptPtrStore2 = { OptPtrStore2, "OptPtrStore2", 40, 0, 0, 0, 0, 0 };
|
static OptFunc DOptPtrStore2 = { OptPtrStore2, "OptPtrStore2", 40, 0, 0, 0, 0, 0 };
|
||||||
static OptFunc DOptPush1 = { OptPush1, "OptPush1", 65, 0, 0, 0, 0, 0 };
|
static OptFunc DOptPush1 = { OptPush1, "OptPush1", 65, 0, 0, 0, 0, 0 };
|
||||||
|
@ -1063,6 +1064,7 @@ static OptFunc* OptFuncs[] = {
|
||||||
&DOptPrecalc,
|
&DOptPrecalc,
|
||||||
&DOptPtrLoad1,
|
&DOptPtrLoad1,
|
||||||
&DOptPtrLoad10,
|
&DOptPtrLoad10,
|
||||||
|
&DOptPtrLoad11,
|
||||||
&DOptPtrLoad2,
|
&DOptPtrLoad2,
|
||||||
&DOptPtrLoad3,
|
&DOptPtrLoad3,
|
||||||
&DOptPtrLoad4,
|
&DOptPtrLoad4,
|
||||||
|
@ -1346,6 +1348,8 @@ static unsigned RunOptGroup1 (CodeSeg* S)
|
||||||
Changes += RunOptFunc (S, &DOptPtrLoad7, 1);
|
Changes += RunOptFunc (S, &DOptPtrLoad7, 1);
|
||||||
Changes += RunOptFunc (S, &DOptPtrLoad8, 1);
|
Changes += RunOptFunc (S, &DOptPtrLoad8, 1);
|
||||||
Changes += RunOptFunc (S, &DOptPtrLoad9, 1);
|
Changes += RunOptFunc (S, &DOptPtrLoad9, 1);
|
||||||
|
Changes += RunOptFunc (S, &DOptPtrLoad10, 1);
|
||||||
|
Changes += RunOptFunc (S, &DOptPtrLoad11, 1);
|
||||||
Changes += RunOptFunc (S, &DOptNegAX1, 1);
|
Changes += RunOptFunc (S, &DOptNegAX1, 1);
|
||||||
Changes += RunOptFunc (S, &DOptNegAX2, 1);
|
Changes += RunOptFunc (S, &DOptNegAX2, 1);
|
||||||
Changes += RunOptFunc (S, &DOptNegAX3, 1);
|
Changes += RunOptFunc (S, &DOptNegAX3, 1);
|
||||||
|
@ -1397,7 +1401,6 @@ static unsigned RunOptGroup3 (CodeSeg* S)
|
||||||
do {
|
do {
|
||||||
C = 0;
|
C = 0;
|
||||||
|
|
||||||
C += RunOptFunc (S, &DOptPtrLoad10, 1);
|
|
||||||
C += RunOptFunc (S, &DOptNegA1, 1);
|
C += RunOptFunc (S, &DOptNegA1, 1);
|
||||||
C += RunOptFunc (S, &DOptNegA2, 1);
|
C += RunOptFunc (S, &DOptNegA2, 1);
|
||||||
C += RunOptFunc (S, &DOptSub1, 1);
|
C += RunOptFunc (S, &DOptSub1, 1);
|
||||||
|
|
|
@ -929,7 +929,7 @@ unsigned OptPtrLoad10 (CodeSeg* S)
|
||||||
*
|
*
|
||||||
* stx ptr1+1
|
* stx ptr1+1
|
||||||
* sta ptr1
|
* sta ptr1
|
||||||
* ldy ...
|
* ldy ...
|
||||||
* ldx #$00
|
* ldx #$00
|
||||||
* lda (ptr1),y
|
* lda (ptr1),y
|
||||||
*
|
*
|
||||||
|
@ -988,3 +988,87 @@ unsigned OptPtrLoad10 (CodeSeg* S)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned OptPtrLoad11 (CodeSeg* S)
|
||||||
|
/* Search for the sequence
|
||||||
|
*
|
||||||
|
* ldy ...
|
||||||
|
* jsr ldaxidx
|
||||||
|
*
|
||||||
|
* and replace it by:
|
||||||
|
*
|
||||||
|
* ldy ...
|
||||||
|
* sta ptr1
|
||||||
|
* stx ptr1+1
|
||||||
|
* lda (ptr1),y
|
||||||
|
* tax
|
||||||
|
* dey
|
||||||
|
* lda (ptr1),y
|
||||||
|
*
|
||||||
|
* This step must be executed *after* OptPtrLoad9! While code size increases
|
||||||
|
* by more than 200%, inlining will greatly improve visibility for the
|
||||||
|
* optimizer, so often part of the code gets improved later. So we will mark
|
||||||
|
* the step with less than 200% so it gets executed when -Oi is in effect.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
unsigned Changes = 0;
|
||||||
|
|
||||||
|
/* Walk over the entries */
|
||||||
|
unsigned I = 0;
|
||||||
|
while (I < CS_GetEntryCount (S)) {
|
||||||
|
|
||||||
|
CodeEntry* L[2];
|
||||||
|
|
||||||
|
/* Get next entry */
|
||||||
|
L[0] = CS_GetEntry (S, I);
|
||||||
|
|
||||||
|
/* Check for the sequence */
|
||||||
|
if (L[0]->OPC == OP65_LDY &&
|
||||||
|
CS_GetEntries (S, L+1, I+1, 1) &&
|
||||||
|
CE_IsCallTo (L[1], "ldaxidx") &&
|
||||||
|
!CE_HasLabel (L[1])) {
|
||||||
|
|
||||||
|
CodeEntry* X;
|
||||||
|
|
||||||
|
/* Store the high byte */
|
||||||
|
X = NewCodeEntry (OP65_STA, AM65_ZP, "ptr1", 0, L[0]->LI);
|
||||||
|
CS_InsertEntry (S, X, I+1);
|
||||||
|
|
||||||
|
/* Store the low byte */
|
||||||
|
X = NewCodeEntry (OP65_STX, AM65_ZP, "ptr1+1", 0, L[0]->LI);
|
||||||
|
CS_InsertEntry (S, X, I+2);
|
||||||
|
|
||||||
|
/* lda (ptr1),y */
|
||||||
|
X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "ptr1", 0, L[1]->LI);
|
||||||
|
CS_InsertEntry (S, X, I+3);
|
||||||
|
|
||||||
|
/* tax */
|
||||||
|
X = NewCodeEntry (OP65_TAX, AM65_IMP, 0, 0, L[1]->LI);
|
||||||
|
CS_InsertEntry (S, X, I+4);
|
||||||
|
|
||||||
|
/* dey */
|
||||||
|
X = NewCodeEntry (OP65_DEY, AM65_IMP, 0, 0, L[1]->LI);
|
||||||
|
CS_InsertEntry (S, X, I+5);
|
||||||
|
|
||||||
|
/* lda (ptr1),y */
|
||||||
|
X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "ptr1", 0, L[1]->LI);
|
||||||
|
CS_InsertEntry (S, X, I+6);
|
||||||
|
|
||||||
|
/* Delete the call to ldaxidx */
|
||||||
|
CS_DelEntry (S, I+7);
|
||||||
|
|
||||||
|
/* Remember, we had changes */
|
||||||
|
++Changes;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Next entry */
|
||||||
|
++I;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the number of changes made */
|
||||||
|
return Changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ unsigned OptPtrLoad3 (CodeSeg* S);
|
||||||
* ldy xxx
|
* ldy xxx
|
||||||
* ldx #$00
|
* ldx #$00
|
||||||
* lda label,y
|
* lda label,y
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned OptPtrLoad4 (CodeSeg* S);
|
unsigned OptPtrLoad4 (CodeSeg* S);
|
||||||
/* Search for the sequence:
|
/* Search for the sequence:
|
||||||
|
@ -263,6 +263,28 @@ unsigned OptPtrLoad10 (CodeSeg* S);
|
||||||
* This step must be executed *after* OptPtrLoad1!
|
* This step must be executed *after* OptPtrLoad1!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
unsigned OptPtrLoad11 (CodeSeg* S);
|
||||||
|
/* Search for the sequence
|
||||||
|
*
|
||||||
|
* ldy ...
|
||||||
|
* jsr ldaxidx
|
||||||
|
*
|
||||||
|
* and replace it by:
|
||||||
|
*
|
||||||
|
* ldy ...
|
||||||
|
* sta ptr1
|
||||||
|
* stx ptr1+1
|
||||||
|
* lda (ptr1),y
|
||||||
|
* tax
|
||||||
|
* dey
|
||||||
|
* lda (ptr1),y
|
||||||
|
*
|
||||||
|
* This step must be executed *after* OptPtrLoad9! While code size increases
|
||||||
|
* by more than 200%, inlining will greatly improve visibility for the
|
||||||
|
* optimizer, so often part of the code gets improved later. So we will mark
|
||||||
|
* the step with less than 200% so it gets executed when -Oi is in effect.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of coptptrload.h */
|
/* End of coptptrload.h */
|
||||||
|
|
Loading…
Add table
Reference in a new issue