Optimize decaxn
git-svn-id: svn://svn.cc65.org/cc65/trunk@3726 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2001-2003 Ullrich von Bassewitz */
|
/* (C) 2001-2006 Ullrich von Bassewitz */
|
||||||
/* R<>merstra<72>e 52 */
|
/* R<>merstra<72>e 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
@@ -1868,6 +1868,7 @@ static OptFunc DOptStore4 = { OptStore4, "OptStore4", 50, 0,
|
|||||||
static OptFunc DOptStoreLoad = { OptStoreLoad, "OptStoreLoad", 0, 0, 0, 0, 0, 0 };
|
static OptFunc DOptStoreLoad = { OptStoreLoad, "OptStoreLoad", 0, 0, 0, 0, 0, 0 };
|
||||||
static OptFunc DOptSub1 = { OptSub1, "OptSub1", 100, 0, 0, 0, 0, 0 };
|
static OptFunc DOptSub1 = { OptSub1, "OptSub1", 100, 0, 0, 0, 0, 0 };
|
||||||
static OptFunc DOptSub2 = { OptSub2, "OptSub2", 100, 0, 0, 0, 0, 0 };
|
static OptFunc DOptSub2 = { OptSub2, "OptSub2", 100, 0, 0, 0, 0, 0 };
|
||||||
|
static OptFunc DOptSub3 = { OptSub3, "OptSub3", 100, 0, 0, 0, 0, 0 };
|
||||||
static OptFunc DOptTest1 = { OptTest1, "OptTest1", 100, 0, 0, 0, 0, 0 };
|
static OptFunc DOptTest1 = { OptTest1, "OptTest1", 100, 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 };
|
||||||
@@ -1941,6 +1942,7 @@ static OptFunc* OptFuncs[] = {
|
|||||||
&DOptStoreLoad,
|
&DOptStoreLoad,
|
||||||
&DOptSub1,
|
&DOptSub1,
|
||||||
&DOptSub2,
|
&DOptSub2,
|
||||||
|
&DOptSub3,
|
||||||
&DOptTest1,
|
&DOptTest1,
|
||||||
&DOptTransfers1,
|
&DOptTransfers1,
|
||||||
&DOptTransfers2,
|
&DOptTransfers2,
|
||||||
@@ -2245,6 +2247,7 @@ static unsigned RunOptGroup3 (CodeSeg* S)
|
|||||||
C += RunOptFunc (S, &DOptNegA2, 1);
|
C += RunOptFunc (S, &DOptNegA2, 1);
|
||||||
C += RunOptFunc (S, &DOptSub1, 1);
|
C += RunOptFunc (S, &DOptSub1, 1);
|
||||||
C += RunOptFunc (S, &DOptSub2, 1);
|
C += RunOptFunc (S, &DOptSub2, 1);
|
||||||
|
C += RunOptFunc (S, &DOptSub3, 1);
|
||||||
C += RunOptFunc (S, &DOptAdd5, 1);
|
C += RunOptFunc (S, &DOptAdd5, 1);
|
||||||
C += RunOptFunc (S, &DOptAdd6, 1);
|
C += RunOptFunc (S, &DOptAdd6, 1);
|
||||||
C += RunOptFunc (S, &DOptStackOps, 1);
|
C += RunOptFunc (S, &DOptStackOps, 1);
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2001 Ullrich von Bassewitz */
|
/* (C) 2001-2006, Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -33,6 +33,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* common */
|
||||||
|
#include "chartype.h"
|
||||||
|
|
||||||
/* cc65 */
|
/* cc65 */
|
||||||
#include "codeent.h"
|
#include "codeent.h"
|
||||||
#include "codeinfo.h"
|
#include "codeinfo.h"
|
||||||
@@ -175,4 +178,56 @@ unsigned OptSub2 (CodeSeg* S)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned OptSub3 (CodeSeg* S)
|
||||||
|
/* Search for a call to decaxn and replace it by an 8 bit sub if the X register
|
||||||
|
* is not used later.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
unsigned Changes = 0;
|
||||||
|
|
||||||
|
/* Walk over the entries */
|
||||||
|
unsigned I = 0;
|
||||||
|
while (I < CS_GetEntryCount (S)) {
|
||||||
|
|
||||||
|
CodeEntry* E;
|
||||||
|
|
||||||
|
/* Get next entry */
|
||||||
|
E = CS_GetEntry (S, I);
|
||||||
|
|
||||||
|
/* Check for the sequence */
|
||||||
|
if (E->OPC == OP65_JSR &&
|
||||||
|
strncmp (E->Arg, "decax", 5) == 0 &&
|
||||||
|
IsDigit (E->Arg[5]) &&
|
||||||
|
E->Arg[6] == '\0' &&
|
||||||
|
!RegXUsed (S, I+1)) {
|
||||||
|
|
||||||
|
CodeEntry* X;
|
||||||
|
const char* Arg;
|
||||||
|
|
||||||
|
/* Insert new code behind the sequence */
|
||||||
|
X = NewCodeEntry (OP65_SEC, AM65_IMP, 0, 0, E->LI);
|
||||||
|
CS_InsertEntry (S, X, I+1);
|
||||||
|
|
||||||
|
Arg = MakeHexArg (E->Arg[5] - '0');
|
||||||
|
X = NewCodeEntry (OP65_SBC, AM65_IMM, Arg, 0, E->LI);
|
||||||
|
CS_InsertEntry (S, X, I+2);
|
||||||
|
|
||||||
|
/* Delete the old code */
|
||||||
|
CS_DelEntry (S, I);
|
||||||
|
|
||||||
|
/* Remember, we had changes */
|
||||||
|
++Changes;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Next entry */
|
||||||
|
++I;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the number of changes made */
|
||||||
|
return Changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2001 Ullrich von Bassewitz */
|
/* (C) 2001-2006, Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -78,6 +78,11 @@ unsigned OptSub2 (CodeSeg* S);
|
|||||||
* sta yy
|
* sta yy
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
unsigned OptSub3 (CodeSeg* S);
|
||||||
|
/* Search for a call to decaxn and replace it by an 8 bit sub if the X register
|
||||||
|
* is not used later.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of coptsub.h */
|
/* End of coptsub.h */
|
||||||
|
|||||||
Reference in New Issue
Block a user