1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-18 00:07:21 +00:00

Added optimization for complax.

git-svn-id: svn://svn.cc65.org/cc65/trunk@5771 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2012-07-07 19:54:24 +00:00
parent 49905d74bd
commit 3365220827
3 changed files with 70 additions and 0 deletions

View File

@ -601,6 +601,7 @@ static OptFunc DOptCmp6 = { OptCmp6, "OptCmp6", 100, 0,
static OptFunc DOptCmp7 = { OptCmp7, "OptCmp7", 85, 0, 0, 0, 0, 0 };
static OptFunc DOptCmp8 = { OptCmp8, "OptCmp8", 50, 0, 0, 0, 0, 0 };
static OptFunc DOptCmp9 = { OptCmp9, "OptCmp9", 85, 0, 0, 0, 0, 0 };
static OptFunc DOptComplAX1 = { OptComplAX1, "OptComplAX1", 65, 0, 0, 0, 0, 0 };
static OptFunc DOptCondBranches1= { OptCondBranches1,"OptCondBranches1", 80, 0, 0, 0, 0, 0 };
static OptFunc DOptCondBranches2= { OptCondBranches2,"OptCondBranches2", 0, 0, 0, 0, 0, 0 };
static OptFunc DOptDeadCode = { OptDeadCode, "OptDeadCode", 100, 0, 0, 0, 0, 0 };
@ -698,6 +699,7 @@ static OptFunc* OptFuncs[] = {
&DOptCmp7,
&DOptCmp8,
&DOptCmp9,
&DOptComplAX1,
&DOptCondBranches1,
&DOptCondBranches2,
&DOptDeadCode,
@ -1088,6 +1090,7 @@ static unsigned RunOptGroup3 (CodeSeg* S)
C += RunOptFunc (S, &DOptStackOps, 3);
C += RunOptFunc (S, &DOptShift1, 1);
C += RunOptFunc (S, &DOptShift4, 1);
C += RunOptFunc (S, &DOptComplAX1, 1);
C += RunOptFunc (S, &DOptSub1, 1);
C += RunOptFunc (S, &DOptSub2, 1);
C += RunOptFunc (S, &DOptSub3, 1);

View File

@ -557,3 +557,54 @@ unsigned OptNegAX2 (CodeSeg* S)
/*****************************************************************************/
/* complax optimizations */
/*****************************************************************************/
unsigned OptComplAX1 (CodeSeg* S)
/* Search for a call to complax and replace it by
*
* eor #$FF
*
* if X isn't used later.
*/
{
unsigned Changes = 0;
unsigned I;
/* Walk over the entries */
I = 0;
while (I < CS_GetEntryCount (S)) {
/* Get next entry */
CodeEntry* E = CS_GetEntry (S, I);
/* Check if this is a call to negax, and if X isn't used later */
if (CE_IsCallTo (E, "complax") && !RegXUsed (S, I+1)) {
CodeEntry* X;
/* Add replacement code behind */
X = NewCodeEntry (OP65_EOR, AM65_IMM, "$FF", 0, E->LI);
CS_InsertEntry (S, X, I+1);
/* Delete the call to negax */
CS_DelEntry (S, I);
/* We had changes */
++Changes;
}
/* Next entry */
++I;
}
/* Return the number of changes made */
return Changes;
}

View File

@ -164,6 +164,22 @@ unsigned OptNegAX2 (CodeSeg* S);
/*****************************************************************************/
/* complax optimizations */
/*****************************************************************************/
unsigned OptComplAX1 (CodeSeg* S);
/* Search for a call to complax and replace it by
*
* eor #$FF
*
* if X isn't used later.
*/
/* End of coptneg.h */
#endif