mirror of
https://github.com/cc65/cc65.git
synced 2025-01-16 13:31:16 +00:00
More optimizations
git-svn-id: svn://svn.cc65.org/cc65/trunk@842 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
185bb4875f
commit
7da0da3cad
@ -67,6 +67,10 @@ struct FuncInfo {
|
|||||||
|
|
||||||
static const FuncInfo FuncInfoTable[] = {
|
static const FuncInfo FuncInfoTable[] = {
|
||||||
{ "addysp", REG_Y, REG_NONE },
|
{ "addysp", REG_Y, REG_NONE },
|
||||||
|
{ "aslax1", REG_AX, REG_AX },
|
||||||
|
{ "aslax2", REG_AX, REG_AX },
|
||||||
|
{ "aslax3", REG_AX, REG_AX },
|
||||||
|
{ "aslax4", REG_AX, REG_AX },
|
||||||
{ "bnega", REG_A, REG_AX },
|
{ "bnega", REG_A, REG_AX },
|
||||||
{ "bnegax", REG_AX, REG_AX },
|
{ "bnegax", REG_AX, REG_AX },
|
||||||
{ "bnegeax", REG_AX, REG_AX },
|
{ "bnegeax", REG_AX, REG_AX },
|
||||||
@ -122,6 +126,10 @@ static const FuncInfo FuncInfoTable[] = {
|
|||||||
{ "pusheax", REG_AX, REG_Y },
|
{ "pusheax", REG_AX, REG_Y },
|
||||||
{ "pushw0sp", REG_NONE, REG_AXY },
|
{ "pushw0sp", REG_NONE, REG_AXY },
|
||||||
{ "pushwysp", REG_Y, REG_AXY },
|
{ "pushwysp", REG_Y, REG_AXY },
|
||||||
|
{ "shlax1", REG_AX, REG_AX },
|
||||||
|
{ "shlax2", REG_AX, REG_AX },
|
||||||
|
{ "shlax3", REG_AX, REG_AX },
|
||||||
|
{ "shlax4", REG_AX, REG_AX },
|
||||||
{ "shrax1", REG_AX, REG_AX },
|
{ "shrax1", REG_AX, REG_AX },
|
||||||
{ "shrax2", REG_AX, REG_AX },
|
{ "shrax2", REG_AX, REG_AX },
|
||||||
{ "shrax3", REG_AX, REG_AX },
|
{ "shrax3", REG_AX, REG_AX },
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
#include "abend.h"
|
#include "abend.h"
|
||||||
|
#include "chartype.h"
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "xsprintf.h"
|
#include "xsprintf.h"
|
||||||
|
|
||||||
@ -809,6 +810,60 @@ static unsigned OptAdd3 (CodeSeg* S)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Optimize shifts */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static unsigned OptShift1 (CodeSeg* S)
|
||||||
|
/* A call to the shlaxN routine may get replaced by one or more asl insns
|
||||||
|
* if the value of X is not used later.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
unsigned Changes = 0;
|
||||||
|
|
||||||
|
/* Walk over the entries */
|
||||||
|
unsigned I = 0;
|
||||||
|
while (I < CS_GetEntryCount (S)) {
|
||||||
|
|
||||||
|
/* Get next entry */
|
||||||
|
CodeEntry* E = CS_GetEntry (S, I);
|
||||||
|
|
||||||
|
/* Check for the sequence */
|
||||||
|
if (E->OPC == OP65_JSR &&
|
||||||
|
(strncmp (E->Arg, "shlax", 5) == 0 ||
|
||||||
|
strncmp (E->Arg, "aslax", 5) == 0) &&
|
||||||
|
strlen (E->Arg) == 6 &&
|
||||||
|
IsDigit (E->Arg[5]) &&
|
||||||
|
!RegXUsed (S, I+1)) {
|
||||||
|
|
||||||
|
/* Insert shift insns */
|
||||||
|
unsigned Count = E->Arg[5] - '0';
|
||||||
|
while (Count--) {
|
||||||
|
CodeEntry* X = NewCodeEntry (OP65_ASL, AM65_ACC, "a", 0, E->LI);
|
||||||
|
CS_InsertEntry (S, X, I+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Delete the call to shlax */
|
||||||
|
CS_DelEntry (S, I);
|
||||||
|
|
||||||
|
/* Remember, we had changes */
|
||||||
|
++Changes;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Next entry */
|
||||||
|
++I;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the number of changes made */
|
||||||
|
return Changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Optimizations for compares */
|
/* Optimizations for compares */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -2278,6 +2333,8 @@ static OptFunc OptFuncs [] = {
|
|||||||
OptEntry (OptAdd1, optPre),
|
OptEntry (OptAdd1, optPre),
|
||||||
OptEntry (OptAdd2, optPre),
|
OptEntry (OptAdd2, optPre),
|
||||||
OptEntry (OptAdd3, optMain),
|
OptEntry (OptAdd3, optMain),
|
||||||
|
/* Optimize shifts */
|
||||||
|
OptEntry (OptShift1, optPre),
|
||||||
/* Optimize jump cascades */
|
/* Optimize jump cascades */
|
||||||
OptEntry (OptJumpCascades, optMain),
|
OptEntry (OptJumpCascades, optMain),
|
||||||
/* Remove dead jumps */
|
/* Remove dead jumps */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user