From 5de45d4b5fa61802d1d5ae5ed8ab186655837468 Mon Sep 17 00:00:00 2001 From: spth Date: Sat, 19 Apr 2008 12:06:38 +0000 Subject: [PATCH] Implemented generic part of RFE #1880202 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5138 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCpeeph.c | 25 +++++++++++++++++++++++++ src/mcs51/main.c | 10 ++++++---- src/port.h | 2 +- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/SDCCpeeph.c b/src/SDCCpeeph.c index 7a1f3f25..075cad2a 100644 --- a/src/SDCCpeeph.c +++ b/src/SDCCpeeph.c @@ -402,6 +402,28 @@ FBYNAME (deadMove) return FALSE; } +/*-----------------------------------------------------------------*/ +/* notUsed - Check, if value in register is not read again */ +/*-----------------------------------------------------------------*/ +FBYNAME (notUsed) +{ + const char *what; + + if(cmdLine[0] != '\'') + what = hTabItemWithKey (vars, 1); + else + { + cmdLine[strlen(cmdLine) - 1] = 0; + what = cmdLine + 1; + } + + if (port->peep.notUsed) + return port->peep.notUsed (what, endPl, head); + + fprintf (stderr, "Function notUsed not initialized in port structure\n"); + return FALSE; +} + /*-----------------------------------------------------------------*/ /* operandsNotSame - check if %1 & %2 are the same */ /*-----------------------------------------------------------------*/ @@ -1200,6 +1222,9 @@ ftab[] = // sorted on the number of times used }, { "useAcallAjmp", useAcallAjmp + }, + { + "notUsed", notUsed } }; /*-----------------------------------------------------------------*/ diff --git a/src/mcs51/main.c b/src/mcs51/main.c index eeef4b25..1904e149 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -8,6 +8,7 @@ #include "main.h" #include "ralloc.h" #include "gen.h" +#include "peep.h" #include "dbuf_string.h" #include "../SDCCutil.h" @@ -723,7 +724,7 @@ PORT mcs51_port = MODEL_SMALL | MODEL_MEDIUM | MODEL_LARGE, MODEL_SMALL }, - { + { /* Assembler */ _asmCmd, NULL, "-plosgffc", /* Options with debug */ @@ -732,19 +733,20 @@ PORT mcs51_port = ".asm", NULL /* no do_assemble function */ }, - { + { /* Linker */ _linkCmd, NULL, NULL, ".rel", 1 }, - { + { /* Peephole optimizer */ _defaultRules, getInstructionSize, getRegsRead, getRegsWritten, - mcs51DeadMove + mcs51DeadMove, + 0 }, { /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */ diff --git a/src/port.h b/src/port.h index fd32518b..3363aa68 100644 --- a/src/port.h +++ b/src/port.h @@ -9,7 +9,6 @@ #include "SDCCargs.h" #include "SDCCpeeph.h" #include "dbuf.h" -#include "mcs51/peep.h" #define TARGET_ID_MCS51 1 #define TARGET_ID_GBZ80 2 @@ -136,6 +135,7 @@ typedef struct bitVect * (*getRegsRead)(lineNode *line); bitVect * (*getRegsWritten)(lineNode *line); bool (*deadMove) (const char *reg, lineNode *currPl, lineNode *head); + bool (*notUsed) (const char *reg, lineNode *currPl, lineNode *head); } peep; -- 2.47.2