From 10cd3fdad4b5b2b6bec63afc7f059f4cdfcbcaf6 Mon Sep 17 00:00:00 2001 From: epetrich Date: Mon, 1 Sep 2003 02:21:06 +0000 Subject: [PATCH] * src/SDCCpeeph.c (notVolatile, notVolatileVariable): handle IFX and JUMPTABLE iCodes properly now (worked by accident before) * src/mcs51/gen.c (leftRightUseAcc), * src/ds390/gen.c (leftRightUseAcc): handle IFX and JUMPTABLE iCode properly now. Use getSize instead of nRegs since a & b aren't part of the nRegs tally. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2866 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 9 +++++++ src/SDCCpeeph.c | 60 ++++++++++++++++++++++++++++++------------- src/ds390/gen.c | 65 +++++++++++++++++++++++++++++++++++++++-------- src/mcs51/gen.c | 67 +++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 162 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index 37286e1e..ca4ef332 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2003-08-31 Erik Petrich + + * src/SDCCpeeph.c (notVolatile, notVolatileVariable): handle IFX + and JUMPTABLE iCodes properly now (worked by accident before) + * src/mcs51/gen.c (leftRightUseAcc), + * src/ds390/gen.c (leftRightUseAcc): handle IFX and JUMPTABLE + iCode properly now. Use getSize instead of nRegs since a & b + aren't part of the nRegs tally. + 2003-08-31 Vangelis Rokas * src/pic16/main.c: corrected offsets of interrupt vectors in _pic16_genIVT() * src/pic16/pcode.c: fix to disable inserting BANKSEL directive diff --git a/src/SDCCpeeph.c b/src/SDCCpeeph.c index 921642b1..a470b6d9 100644 --- a/src/SDCCpeeph.c +++ b/src/SDCCpeeph.c @@ -704,15 +704,27 @@ notVolatileVariable(char *var, lineNode *currPl, lineNode *endPl) if (cl->ic && (cl->ic!=last_ic)) { last_ic = cl->ic; - op = IC_LEFT (cl->ic); - if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) ) - return !op->isvolatile; - op = IC_RIGHT (cl->ic); - if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) ) - return !op->isvolatile; - op = IC_RESULT (cl->ic); - if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) ) - return !op->isvolatile; + switch (cl->ic->op) + { + case IFX: + op = IC_COND (cl->ic); + if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) ) + return !op->isvolatile; + case JUMPTABLE: + op = IC_JTCOND (cl->ic); + if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) ) + return !op->isvolatile; + default: + op = IC_LEFT (cl->ic); + if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) ) + return !op->isvolatile; + op = IC_RIGHT (cl->ic); + if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) ) + return !op->isvolatile; + op = IC_RESULT (cl->ic); + if (IS_SYMOP (op) && !strcmp(OP_SYMBOL (op)->rname,symname) ) + return !op->isvolatile; + } } } @@ -750,15 +762,27 @@ FBYNAME (notVolatile) { if (cl->ic) { - op = IC_LEFT (cl->ic); - if (IS_SYMOP (op) && op->isvolatile) - return FALSE; - op = IC_RIGHT (cl->ic); - if (IS_SYMOP (op) && op->isvolatile) - return FALSE; - op = IC_RESULT (cl->ic); - if (IS_SYMOP (op) && op->isvolatile) - return FALSE; + switch (cl->ic->op) + { + case IFX: + op = IC_COND (cl->ic); + if (IS_SYMOP (op) && op->isvolatile) + return FALSE; + case JUMPTABLE: + op = IC_JTCOND (cl->ic); + if (IS_SYMOP (op) && op->isvolatile) + return FALSE; + default: + op = IC_LEFT (cl->ic); + if (IS_SYMOP (op) && op->isvolatile) + return FALSE; + op = IC_RIGHT (cl->ic); + if (IS_SYMOP (op) && op->isvolatile) + return FALSE; + op = IC_RESULT (cl->ic); + if (IS_SYMOP (op) && op->isvolatile) + return FALSE; + } } } return TRUE; diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 2b93fa27..411e019f 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -444,19 +444,64 @@ pointerCode (sym_link * etype) static int leftRightUseAcc(iCode *ic) { + operand *op; + int size; + int accuseSize = 0; int accuse = 0; - if (ic && IC_LEFT (ic) && IS_SYMOP (IC_LEFT (ic)) - && OP_SYMBOL (IC_LEFT (ic)) && OP_SYMBOL (IC_LEFT (ic))->accuse) - accuse = (accuse < OP_SYMBOL (IC_LEFT (ic))->nRegs) - ? OP_SYMBOL (IC_LEFT (ic))->nRegs : accuse; - - if (ic && IC_RIGHT (ic) && IS_SYMOP (IC_RIGHT (ic)) - && OP_SYMBOL (IC_RIGHT (ic)) && OP_SYMBOL (IC_RIGHT (ic))->accuse) - accuse = (accuse < OP_SYMBOL (IC_RIGHT (ic))->nRegs) - ? OP_SYMBOL (IC_RIGHT (ic))->nRegs : accuse; + if (!ic) + { + werror (E_INTERNAL_ERROR, __FILE__, __LINE__, + "null iCode pointer"); + return 0; + } - return accuse; + if (ic->op == IFX) + { + op = IC_COND (ic); + if (IS_SYMOP (op) && OP_SYMBOL (op) && OP_SYMBOL (op)->accuse) + { + accuse = 1; + size = getSize (OP_SYMBOL (op)->type); + if (size>accuseSize) + accuseSize = size; + } + } + else if (ic->op == JUMPTABLE) + { + op = IC_JTCOND (ic); + if (IS_SYMOP (op) && OP_SYMBOL (op) && OP_SYMBOL (op)->accuse) + { + accuse = 1; + size = getSize (OP_SYMBOL (op)->type); + if (size>accuseSize) + accuseSize = size; + } + } + else + { + op = IC_LEFT (ic); + if (IS_SYMOP (op) && OP_SYMBOL (op) && OP_SYMBOL (op)->accuse) + { + accuse = 1; + size = getSize (OP_SYMBOL (op)->type); + if (size>accuseSize) + accuseSize = size; + } + op = IC_RIGHT (ic); + if (IS_SYMOP (op) && OP_SYMBOL (op) && OP_SYMBOL (op)->accuse) + { + accuse = 1; + size = getSize (OP_SYMBOL (op)->type); + if (size>accuseSize) + accuseSize = size; + } + } + + if (accuseSize) + return accuseSize; + else + return accuse; } /*-----------------------------------------------------------------*/ diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index af940699..531a7589 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -289,19 +289,64 @@ pointerCode (sym_link * etype) static int leftRightUseAcc(iCode *ic) { + operand *op; + int size; + int accuseSize = 0; int accuse = 0; + + if (!ic) + { + werror (E_INTERNAL_ERROR, __FILE__, __LINE__, + "null iCode pointer"); + return 0; + } - if (ic && IC_LEFT (ic) && IS_SYMOP (IC_LEFT (ic)) - && OP_SYMBOL (IC_LEFT (ic)) && OP_SYMBOL (IC_LEFT (ic))->accuse) - accuse = (accuse < OP_SYMBOL (IC_LEFT (ic))->nRegs) - ? OP_SYMBOL (IC_LEFT (ic))->nRegs : accuse; - - if (ic && IC_RIGHT (ic) && IS_SYMOP (IC_RIGHT (ic)) - && OP_SYMBOL (IC_RIGHT (ic)) && OP_SYMBOL (IC_RIGHT (ic))->accuse) - accuse = (accuse < OP_SYMBOL (IC_RIGHT (ic))->nRegs) - ? OP_SYMBOL (IC_RIGHT (ic))->nRegs : accuse; - - return accuse; + if (ic->op == IFX) + { + op = IC_COND (ic); + if (IS_SYMOP (op) && OP_SYMBOL (op) && OP_SYMBOL (op)->accuse) + { + accuse = 1; + size = getSize (OP_SYMBOL (op)->type); + if (size>accuseSize) + accuseSize = size; + } + } + else if (ic->op == JUMPTABLE) + { + op = IC_JTCOND (ic); + if (IS_SYMOP (op) && OP_SYMBOL (op) && OP_SYMBOL (op)->accuse) + { + accuse = 1; + size = getSize (OP_SYMBOL (op)->type); + if (size>accuseSize) + accuseSize = size; + } + } + else + { + op = IC_LEFT (ic); + if (IS_SYMOP (op) && OP_SYMBOL (op) && OP_SYMBOL (op)->accuse) + { + accuse = 1; + size = getSize (OP_SYMBOL (op)->type); + if (size>accuseSize) + accuseSize = size; + } + op = IC_RIGHT (ic); + if (IS_SYMOP (op) && OP_SYMBOL (op) && OP_SYMBOL (op)->accuse) + { + accuse = 1; + size = getSize (OP_SYMBOL (op)->type); + if (size>accuseSize) + accuseSize = size; + } + } + + if (accuseSize) + return accuseSize; + else + return accuse; } -- 2.30.2