Cleared out all warnings in sdcc. Moved all unused functions into an 'Unused' section.
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 26 Jun 2001 05:16:12 +0000 (05:16 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 26 Jun 2001 05:16:12 +0000 (05:16 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@949 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/avr/gen.c
src/avr/ralloc.c
src/izt/aop.c
src/pic/ralloc.c
src/z80/ralloc.c

index 0a9bd9a359390db66920aeb36e1f587de5795a45..fe2a666f9e7b1c4ec7722cf052b1200206f935f6 100644 (file)
@@ -64,9 +64,21 @@ static char *spname;
 char *fReturnAVR[] = { "r16", "r17", "r18", "r19" };
 unsigned fAVRReturnSize = 4;   /* shared with ralloc.c */
 char **fAVRReturn = fReturnAVR;
-static short rbank = -1;
 static char *larray[4] = { "lo8", "hi8", "hlo8", "hhi8" };
+
+#if 0
+// PENDING: Unused
+static short rbank = -1;
 static char *tscr[4] = { "r0", "r1", "r24", "r25" };
+static unsigned char SLMask[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0,
+       0xE0, 0xC0, 0x80, 0x00
+};
+static unsigned char SRMask[] = { 0xFF, 0x7F, 0x3F, 0x1F, 0x0F,
+       0x07, 0x03, 0x01, 0x00
+};
+
+#endif
+
 static struct {
        short xPushed;
        short zPushed;
@@ -80,7 +92,6 @@ static struct {
 extern int avr_ptrRegReq;
 extern int avr_nRegs;
 extern FILE *codeOutFile;
-static void saverbank (int, iCode *, bool);
 #define RESULTONSTACK(x) \
                          (IC_RESULT(x) && IC_RESULT(x)->aop && \
                          IC_RESULT(x)->aop->type == AOP_STK )
@@ -96,18 +107,132 @@ static void saverbank (int, iCode *, bool);
 static lineNode *lineHead = NULL;
 static lineNode *lineCurr = NULL;
 
-static unsigned char SLMask[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0,
-       0xE0, 0xC0, 0x80, 0x00
-};
-static unsigned char SRMask[] = { 0xFF, 0x7F, 0x3F, 0x1F, 0x0F,
-       0x07, 0x03, 0x01, 0x00
-};
-
 #define LSB     0
 #define MSB16   1
 #define MSB24   2
 #define MSB32   3
 
+#if 0
+// PENDING: Unused.
+/*-----------------------------------------------------------------*/
+/* reAdjustPreg - points a register back to where it should        */
+/*-----------------------------------------------------------------*/
+static void
+reAdjustPreg (asmop * aop)
+{
+       int size;
+
+       aop->coff = 0;
+       if ((size = aop->size) <= 1)
+               return;
+       size--;
+       switch (aop->type) {
+       case AOP_X:
+       case AOP_Z:
+               emitcode ("sbiw", "%s,%d", aop->aopu.aop_ptr->name, size);
+               break;
+       }
+
+}
+
+/*-----------------------------------------------------------------*/
+/* outBitC - output a bit C                                        */
+/*-----------------------------------------------------------------*/
+static void
+outBitC (operand * result)
+{
+       emitcode ("clr", "r0");
+       emitcode ("rol", "r0");
+       outAcc (result);
+}
+
+/*-----------------------------------------------------------------*/
+/* inExcludeList - return 1 if the string is in exclude Reg list   */
+/*-----------------------------------------------------------------*/
+static bool
+inExcludeList (char *s)
+{
+       int i = 0;
+
+       if (options.excludeRegs[i] &&
+           STRCASECMP (options.excludeRegs[i], "none") == 0)
+               return FALSE;
+
+       for (i = 0; options.excludeRegs[i]; i++) {
+               if (options.excludeRegs[i] &&
+                   STRCASECMP (s, options.excludeRegs[i]) == 0)
+                       return TRUE;
+       }
+       return FALSE;
+}
+
+/*-----------------------------------------------------------------*/
+/* findLabelBackwards: walks back through the iCode chain looking  */
+/* for the given label. Returns number of iCode instructions     */
+/* between that label and given ic.          */
+/* Returns zero if label not found.          */
+/*-----------------------------------------------------------------*/
+static int
+findLabelBackwards (iCode * ic, int key)
+{
+       int count = 0;
+
+       while (ic->prev) {
+               ic = ic->prev;
+               count++;
+
+               if (ic->op == LABEL && IC_LABEL (ic)->key == key) {
+                       /* printf("findLabelBackwards = %d\n", count); */
+                       return count;
+               }
+       }
+
+       return 0;
+}
+
+/*-----------------------------------------------------------------*/
+/* addSign - complete with sign                                    */
+/*-----------------------------------------------------------------*/
+static void
+addSign (operand * result, int offset, int sign)
+{
+       int size = (getDataSize (result) - offset);
+       if (size > 0) {
+               if (sign) {
+                       emitcode ("rlc", "a");
+                       emitcode ("subb", "a,acc");
+                       while (size--)
+                               aopPut (AOP (result), "a", offset++);
+               }
+               else
+                       while (size--)
+                               aopPut (AOP (result), zero, offset++);
+       }
+}
+
+/*-----------------------------------------------------------------*/
+/* isLiteralBit - test if lit == 2^n                               */
+/*-----------------------------------------------------------------*/
+static int
+isLiteralBit (unsigned long lit)
+{
+       unsigned long pw[32] = { 1L, 2L, 4L, 8L, 16L, 32L, 64L, 128L,
+               0x100L, 0x200L, 0x400L, 0x800L,
+               0x1000L, 0x2000L, 0x4000L, 0x8000L,
+               0x10000L, 0x20000L, 0x40000L, 0x80000L,
+               0x100000L, 0x200000L, 0x400000L, 0x800000L,
+               0x1000000L, 0x2000000L, 0x4000000L, 0x8000000L,
+               0x10000000L, 0x20000000L, 0x40000000L, 0x80000000L
+       };
+       int idx;
+
+       for (idx = 0; idx < 32; idx++)
+               if (lit == pw[idx])
+                       return idx + 1;
+       return 0;
+}
+#endif // End Unused code section
+
 /*-----------------------------------------------------------------*/
 /* emitcode - writes the code into a file : for now it is simple    */
 /*-----------------------------------------------------------------*/
@@ -986,27 +1111,6 @@ aopPut (asmop * aop, char *s, int offset)
 
 }
 
-/*-----------------------------------------------------------------*/
-/* reAdjustPreg - points a register back to where it should        */
-/*-----------------------------------------------------------------*/
-static void
-reAdjustPreg (asmop * aop)
-{
-       int size;
-
-       aop->coff = 0;
-       if ((size = aop->size) <= 1)
-               return;
-       size--;
-       switch (aop->type) {
-       case AOP_X:
-       case AOP_Z:
-               emitcode ("sbiw", "%s,%d", aop->aopu.aop_ptr->name, size);
-               break;
-       }
-
-}
-
 #define AOP(op) op->aop
 #define AOP_TYPE(op) AOP(op)->type
 #define AOP_SIZE(op) AOP(op)->size
@@ -1112,17 +1216,6 @@ outAcc (operand * result)
        }
 }
 
-/*-----------------------------------------------------------------*/
-/* outBitC - output a bit C                                        */
-/*-----------------------------------------------------------------*/
-static void
-outBitC (operand * result)
-{
-       emitcode ("clr", "r0");
-       emitcode ("rol", "r0");
-       outAcc (result);
-}
-
 /*-----------------------------------------------------------------*/
 /* toBoolean - emit code for orl a,operator(sizeop)                */
 /*-----------------------------------------------------------------*/
@@ -1600,26 +1693,6 @@ resultRemat (iCode * ic)
 #define STRCASECMP strcasecmp
 #endif
 
-/*-----------------------------------------------------------------*/
-/* inExcludeList - return 1 if the string is in exclude Reg list   */
-/*-----------------------------------------------------------------*/
-static bool
-inExcludeList (char *s)
-{
-       int i = 0;
-
-       if (options.excludeRegs[i] &&
-           STRCASECMP (options.excludeRegs[i], "none") == 0)
-               return FALSE;
-
-       for (i = 0; options.excludeRegs[i]; i++) {
-               if (options.excludeRegs[i] &&
-                   STRCASECMP (s, options.excludeRegs[i]) == 0)
-                       return TRUE;
-       }
-       return FALSE;
-}
-
 /*-----------------------------------------------------------------*/
 /* genFunction - generated code for function entry                 */
 /*-----------------------------------------------------------------*/
@@ -1819,30 +1892,6 @@ genGoto (iCode * ic)
        emitcode ("rjmp", "L%05d", (IC_LABEL (ic)->key + 100));
 }
 
-/*-----------------------------------------------------------------*/
-/* findLabelBackwards: walks back through the iCode chain looking  */
-/* for the given label. Returns number of iCode instructions     */
-/* between that label and given ic.          */
-/* Returns zero if label not found.          */
-/*-----------------------------------------------------------------*/
-static int
-findLabelBackwards (iCode * ic, int key)
-{
-       int count = 0;
-
-       while (ic->prev) {
-               ic = ic->prev;
-               count++;
-
-               if (ic->op == LABEL && IC_LABEL (ic)->key == key) {
-                       /* printf("findLabelBackwards = %d\n", count); */
-                       return count;
-               }
-       }
-
-       return 0;
-}
-
 /*-----------------------------------------------------------------*/
 /* genPlusIncr :- does addition with increment if possible         */
 /*-----------------------------------------------------------------*/
@@ -2080,26 +2129,6 @@ genMinusDec (iCode * ic)
 
 }
 
-/*-----------------------------------------------------------------*/
-/* addSign - complete with sign                                    */
-/*-----------------------------------------------------------------*/
-static void
-addSign (operand * result, int offset, int sign)
-{
-       int size = (getDataSize (result) - offset);
-       if (size > 0) {
-               if (sign) {
-                       emitcode ("rlc", "a");
-                       emitcode ("subb", "a,acc");
-                       while (size--)
-                               aopPut (AOP (result), "a", offset++);
-               }
-               else
-                       while (size--)
-                               aopPut (AOP (result), zero, offset++);
-       }
-}
-
 /*-----------------------------------------------------------------*/
 /* genMinus - generates code for subtraction                       */
 /*-----------------------------------------------------------------*/
@@ -2566,28 +2595,6 @@ genOrOp (iCode * ic)
        freeAsmop (result, NULL, ic, TRUE);
 }
 
-/*-----------------------------------------------------------------*/
-/* isLiteralBit - test if lit == 2^n                               */
-/*-----------------------------------------------------------------*/
-static int
-isLiteralBit (unsigned long lit)
-{
-       unsigned long pw[32] = { 1L, 2L, 4L, 8L, 16L, 32L, 64L, 128L,
-               0x100L, 0x200L, 0x400L, 0x800L,
-               0x1000L, 0x2000L, 0x4000L, 0x8000L,
-               0x10000L, 0x20000L, 0x40000L, 0x80000L,
-               0x100000L, 0x200000L, 0x400000L, 0x800000L,
-               0x1000000L, 0x2000000L, 0x4000000L, 0x8000000L,
-               0x10000000L, 0x20000000L, 0x40000000L, 0x80000000L
-       };
-       int idx;
-
-       for (idx = 0; idx < 32; idx++)
-               if (lit == pw[idx])
-                       return idx + 1;
-       return 0;
-}
-
 enum {
        AVR_AND = 0, AVR_OR, AVR_XOR
 };
@@ -4919,8 +4926,11 @@ genCast (iCode * ic)
        }
        else {
                /* we need to extend the sign :{ */
+                // PENDING: Does nothing on avr
+#if 0
                char *l = aopGet (AOP (right), AOP_SIZE (right) - 1);
                MOVA (l);
+#endif
                emitcode ("rlc", "a");
                emitcode ("subb", "a,acc");
                while (size--)
@@ -4992,7 +5002,8 @@ genDjnz (iCode * ic, iCode * ifx)
 static char *recvregs[8] = {
        "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23"
 };
-static recvCnt = 0;
+
+static int recvCnt = 0;
 
 /*-----------------------------------------------------------------*/
 /* genReceive - generate code for a receive iCode                  */
index 9d93111cd5127c6f732fb71e6e81ba02658fed09..5e42b7ad7692b5245fd9a8675ef4006181b894b6 100644 (file)
@@ -95,6 +95,343 @@ int avr_fReg = 0;           /* first allocatable register */
 
 static void spillThis (symbol *);
 
+#if 0
+// PENDING: Unused
+/*-----------------------------------------------------------------*/
+/* findAssignToSym : scanning backwards looks for first assig found */
+/*-----------------------------------------------------------------*/
+static iCode *
+findAssignToSym (operand * op, iCode * ic)
+{
+       iCode *dic;
+
+       for (dic = ic->prev; dic; dic = dic->prev) {
+
+               /* if definition by assignment */
+               if (dic->op == '=' &&
+                   !POINTER_SET (dic) && IC_RESULT (dic)->key == op->key
+/*          &&  IS_TRUE_SYMOP(IC_RIGHT(dic)) */
+                       ) {
+
+                       /* we are interested only if defined in far space */
+                       /* or in stack space in case of + & - */
+
+                       /* if assigned to a non-symbol then return
+                          true */
+                       if (!IS_SYMOP (IC_RIGHT (dic)))
+                               break;
+
+                       /* if the symbol is in far space then
+                          we should not */
+                       if (isOperandInFarSpace (IC_RIGHT (dic)))
+                               return NULL;
+
+                       /* for + & - operations make sure that
+                          if it is on the stack it is the same
+                          as one of the three operands */
+                       if ((ic->op == '+' || ic->op == '-') &&
+                           OP_SYMBOL (IC_RIGHT (dic))->onStack) {
+
+                               if (IC_RESULT (ic)->key != IC_RIGHT (dic)->key
+                                   && IC_LEFT (ic)->key !=
+                                   IC_RIGHT (dic)->key
+                                   && IC_RIGHT (ic)->key !=
+                                   IC_RIGHT (dic)->key) return NULL;
+                       }
+
+                       break;
+
+               }
+
+               /* if we find an usage then we cannot delete it */
+               if (IC_LEFT (dic) && IC_LEFT (dic)->key == op->key)
+                       return NULL;
+
+               if (IC_RIGHT (dic) && IC_RIGHT (dic)->key == op->key)
+                       return NULL;
+
+               if (POINTER_SET (dic) && IC_RESULT (dic)->key == op->key)
+                       return NULL;
+       }
+
+       /* now make sure that the right side of dic
+          is not defined between ic & dic */
+       if (dic) {
+               iCode *sic = dic->next;
+
+               for (; sic != ic; sic = sic->next)
+                       if (IC_RESULT (sic) &&
+                           IC_RESULT (sic)->key == IC_RIGHT (dic)->key)
+                               return NULL;
+       }
+
+       return dic;
+
+
+}
+
+/*-----------------------------------------------------------------*/
+/* packForPush - hueristics to reduce iCode for pushing            */
+/*-----------------------------------------------------------------*/
+static void
+packForPush (iCode * ic, eBBlock * ebp)
+{
+       iCode *dic;
+
+       if (ic->op != IPUSH || !IS_ITEMP (IC_LEFT (ic)))
+               return;
+
+       /* must have only definition & one usage */
+       if (bitVectnBitsOn (OP_DEFS (IC_LEFT (ic))) != 1 ||
+           bitVectnBitsOn (OP_USES (IC_LEFT (ic))) != 1)
+               return;
+
+       /* find the definition */
+       if (!(dic = hTabItemWithKey (iCodehTab,
+                                    bitVectFirstBit (OP_DEFS
+                                                     (IC_LEFT (ic))))))
+                       return;
+
+       if (dic->op != '=' || POINTER_SET (dic))
+               return;
+
+       /* we now we know that it has one & only one def & use
+          and the that the definition is an assignment */
+       IC_LEFT (ic) = IC_RIGHT (dic);
+
+       remiCodeFromeBBlock (ebp, dic);
+       hTabDeleteItem (&iCodehTab, dic->key, dic, DELETE_ITEM, NULL);
+}
+
+/*-----------------------------------------------------------------*/
+/* packRegsForSupport :- reduce some registers for support calls   */
+/*-----------------------------------------------------------------*/
+static int
+packRegsForSupport (iCode * ic, eBBlock * ebp)
+{
+       int change = 0;
+       /* for the left & right operand :- look to see if the
+          left was assigned a true symbol in far space in that
+          case replace them */
+       if (IS_ITEMP (IC_LEFT (ic)) &&
+           OP_SYMBOL (IC_LEFT (ic))->liveTo <= ic->seq) {
+               iCode *dic = findAssignToSym (IC_LEFT (ic), ic);
+               iCode *sic;
+
+               if (!dic)
+                       goto right;
+
+               /* found it we need to remove it from the
+                  block */
+               for (sic = dic; sic != ic; sic = sic->next)
+                       bitVectUnSetBit (sic->rlive, IC_LEFT (ic)->key);
+
+               IC_LEFT (ic)->operand.symOperand =
+                       IC_RIGHT (dic)->operand.symOperand;
+               IC_LEFT (ic)->key = IC_RIGHT (dic)->operand.symOperand->key;
+               remiCodeFromeBBlock (ebp, dic);
+               hTabDeleteItem (&iCodehTab, dic->key, dic, DELETE_ITEM, NULL);
+               change++;
+       }
+
+       /* do the same for the right operand */
+      right:
+       if (!change &&
+           IS_ITEMP (IC_RIGHT (ic)) &&
+           OP_SYMBOL (IC_RIGHT (ic))->liveTo <= ic->seq) {
+               iCode *dic = findAssignToSym (IC_RIGHT (ic), ic);
+               iCode *sic;
+
+               if (!dic)
+                       return change;
+
+               /* if this is a subtraction & the result
+                  is a true symbol in far space then don't pack */
+               if (ic->op == '-' && IS_TRUE_SYMOP (IC_RESULT (dic))) {
+                       sym_link *etype =
+                               getSpec (operandType (IC_RESULT (dic)));
+                       if (IN_FARSPACE (SPEC_OCLS (etype)))
+                               return change;
+               }
+               /* found it we need to remove it from the
+                  block */
+               for (sic = dic; sic != ic; sic = sic->next)
+                       bitVectUnSetBit (sic->rlive, IC_RIGHT (ic)->key);
+
+               IC_RIGHT (ic)->operand.symOperand =
+                       IC_RIGHT (dic)->operand.symOperand;
+               IC_RIGHT (ic)->key = IC_RIGHT (dic)->operand.symOperand->key;
+
+               remiCodeFromeBBlock (ebp, dic);
+               hTabDeleteItem (&iCodehTab, dic->key, dic, DELETE_ITEM, NULL);
+               change++;
+       }
+
+       return change;
+}
+
+/*-----------------------------------------------------------------*/
+/* farSpacePackable - returns the packable icode for far variables */
+/*-----------------------------------------------------------------*/
+static iCode *
+farSpacePackable (iCode * ic)
+{
+       iCode *dic;
+
+       /* go thru till we find a definition for the
+          symbol on the right */
+       for (dic = ic->prev; dic; dic = dic->prev) {
+
+               /* if the definition is a call then no */
+               if ((dic->op == CALL || dic->op == PCALL) &&
+                   IC_RESULT (dic)->key == IC_RIGHT (ic)->key) {
+                       return NULL;
+               }
+
+               /* if shift by unknown amount then not */
+               if ((dic->op == LEFT_OP || dic->op == RIGHT_OP) &&
+                   IC_RESULT (dic)->key == IC_RIGHT (ic)->key)
+                       return NULL;
+
+               /* if pointer get and size > 1 */
+               if (POINTER_GET (dic) &&
+                   getSize (aggrToPtr (operandType (IC_LEFT (dic)), FALSE)) >
+                   1) return NULL;
+
+               if (POINTER_SET (dic) &&
+                   getSize (aggrToPtr (operandType (IC_RESULT (dic)), FALSE))
+                   > 1)
+                       return NULL;
+
+               /* if any three is a true symbol in far space */
+               if (IC_RESULT (dic) &&
+                   IS_TRUE_SYMOP (IC_RESULT (dic)) &&
+                   isOperandInFarSpace (IC_RESULT (dic)))
+                       return NULL;
+
+               if (IC_RIGHT (dic) &&
+                   IS_TRUE_SYMOP (IC_RIGHT (dic)) &&
+                   isOperandInFarSpace (IC_RIGHT (dic)) &&
+                   !isOperandEqual (IC_RIGHT (dic), IC_RESULT (ic)))
+                       return NULL;
+
+               if (IC_LEFT (dic) &&
+                   IS_TRUE_SYMOP (IC_LEFT (dic)) &&
+                   isOperandInFarSpace (IC_LEFT (dic)) &&
+                   !isOperandEqual (IC_LEFT (dic), IC_RESULT (ic)))
+                       return NULL;
+
+               if (isOperandEqual (IC_RIGHT (ic), IC_RESULT (dic))) {
+                       if ((dic->op == LEFT_OP ||
+                            dic->op == RIGHT_OP ||
+                            dic->op == '-') &&
+                           IS_OP_LITERAL (IC_RIGHT (dic))) return NULL;
+                       else
+                               return dic;
+               }
+       }
+
+       return NULL;
+}
+
+/*-----------------------------------------------------------------*/
+/* rematStr - returns the rematerialized string for a remat var    */
+/*-----------------------------------------------------------------*/
+static char *
+rematStr (symbol * sym)
+{
+       char *s = buffer;
+       iCode *ic = sym->rematiCode;
+
+       while (1) {
+
+               /* if plus or minus print the right hand side */
+               if (ic->op == '+' || ic->op == '-') {
+                       sprintf (s, "0x%04x %c ",
+                                (int) operandLitValue (IC_RIGHT (ic)),
+                                ic->op);
+                       s += strlen (s);
+                       ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
+                       continue;
+               }
+
+               /* we reached the end */
+               sprintf (s, "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
+               break;
+       }
+
+       return buffer;
+}
+
+/*-----------------------------------------------------------------*/
+/* isSpiltOnStack - returns true if the spil location is on stack  */
+/*-----------------------------------------------------------------*/
+static bool
+isSpiltOnStack (symbol * sym)
+{
+       sym_link *etype;
+
+       if (!sym)
+               return FALSE;
+
+       if (!sym->isspilt)
+               return FALSE;
+
+
+       if (!sym->usl.spillLoc)
+               return FALSE;
+
+       etype = getSpec (sym->usl.spillLoc->type);
+       if (IN_STACK (etype))
+               return TRUE;
+
+       return FALSE;
+}
+
+/*-----------------------------------------------------------------*/
+/* spillLRWithPtrReg :- will spil those live ranges which use PTR  */
+/*-----------------------------------------------------------------*/
+static void
+spillLRWithPtrReg (symbol * forSym)
+{
+       symbol *lrsym;
+       regs *X, *Z, *X1, *Z1;
+       int k;
+
+       if (!_G.regAssigned || bitVectIsZero (_G.regAssigned))
+               return;
+
+       X = avr_regWithIdx (R26_IDX);
+       X1= avr_regWithIdx (R27_IDX);
+       Z = avr_regWithIdx (R30_IDX);
+       Z1= avr_regWithIdx (R31_IDX);
+
+       /* for all live ranges */
+       for (lrsym = hTabFirstItem (liveRanges, &k); lrsym;
+            lrsym = hTabNextItem (liveRanges, &k)) {
+               int j;
+
+               /* if no registers assigned to it or
+                  spilt */
+               /* if it does not overlap with this then 
+                  not need to spill it */
+
+               if (lrsym->isspilt || !lrsym->nRegs ||
+                   (lrsym->liveTo < forSym->liveFrom)) continue;
+
+               /* go thru the registers : if it is either
+                  r0 or r1 then spil it */
+               for (j = 0; j < lrsym->nRegs; j++)
+                       if (lrsym->regs[j] == X || lrsym->regs[j] == Z ||
+                           lrsym->regs[j] == X1 || lrsym->regs[j] == Z1) {
+                               spillThis (lrsym);
+                               break;
+                       }
+       }
+
+}
+#endif
+
 /*-----------------------------------------------------------------*/
 /* allocReg - allocates register of given type                     */
 /*-----------------------------------------------------------------*/
@@ -442,49 +779,6 @@ DEFSETFUNC (isFree)
        return 0;
 }
 
-/*-----------------------------------------------------------------*/
-/* spillLRWithPtrReg :- will spil those live ranges which use PTR  */
-/*-----------------------------------------------------------------*/
-static void
-spillLRWithPtrReg (symbol * forSym)
-{
-       symbol *lrsym;
-       regs *X, *Z, *X1, *Z1;
-       int k;
-
-       if (!_G.regAssigned || bitVectIsZero (_G.regAssigned))
-               return;
-
-       X = avr_regWithIdx (R26_IDX);
-       X1= avr_regWithIdx (R27_IDX);
-       Z = avr_regWithIdx (R30_IDX);
-       Z1= avr_regWithIdx (R31_IDX);
-
-       /* for all live ranges */
-       for (lrsym = hTabFirstItem (liveRanges, &k); lrsym;
-            lrsym = hTabNextItem (liveRanges, &k)) {
-               int j;
-
-               /* if no registers assigned to it or
-                  spilt */
-               /* if it does not overlap with this then 
-                  not need to spill it */
-
-               if (lrsym->isspilt || !lrsym->nRegs ||
-                   (lrsym->liveTo < forSym->liveFrom)) continue;
-
-               /* go thru the registers : if it is either
-                  r0 or r1 then spil it */
-               for (j = 0; j < lrsym->nRegs; j++)
-                       if (lrsym->regs[j] == X || lrsym->regs[j] == Z ||
-                           lrsym->regs[j] == X1 || lrsym->regs[j] == Z1) {
-                               spillThis (lrsym);
-                               break;
-                       }
-       }
-
-}
-
 /*-----------------------------------------------------------------*/
 /* createStackSpil - create a location on the stack to spil        */
 /*-----------------------------------------------------------------*/
@@ -570,31 +864,6 @@ createStackSpil (symbol * sym)
        return sym;
 }
 
-/*-----------------------------------------------------------------*/
-/* isSpiltOnStack - returns true if the spil location is on stack  */
-/*-----------------------------------------------------------------*/
-static bool
-isSpiltOnStack (symbol * sym)
-{
-       sym_link *etype;
-
-       if (!sym)
-               return FALSE;
-
-       if (!sym->isspilt)
-               return FALSE;
-
-
-       if (!sym->usl.spillLoc)
-               return FALSE;
-
-       etype = getSpec (sym->usl.spillLoc->type);
-       if (IN_STACK (etype))
-               return TRUE;
-
-       return FALSE;
-}
-
 /*-----------------------------------------------------------------*/
 /* spillThis - spils a specific operand                            */
 /*-----------------------------------------------------------------*/
@@ -1345,51 +1614,23 @@ createRegMask (eBBlock ** ebbs, int count)
                                if (!sym->nRegs || sym->isspilt)
                                        continue;
 
-                               /* for all the registers allocated to it */
-                               for (k = 0; k < sym->nRegs; k++) {
-                                       if (sym->regs[k]) {
-                                               ic->rMask = bitVectSetBit (ic-> rMask, sym->regs[k]->rIdx);
-                                               /* special case for X & Z registers */
-                                               if (k == R26_IDX || k == R27_IDX) 
-                                                       ic->rMask = bitVectSetBit (ic->rMask, X_IDX);
-                                               if (k == R30_IDX || k == R31_IDX) 
-                                                       ic->rMask = bitVectSetBit (ic->rMask, Z_IDX);
-                                       }
-                               }
-                       }
-               }
-       }
-}
-
-/*-----------------------------------------------------------------*/
-/* rematStr - returns the rematerialized string for a remat var    */
-/*-----------------------------------------------------------------*/
-static char *
-rematStr (symbol * sym)
-{
-       char *s = buffer;
-       iCode *ic = sym->rematiCode;
-
-       while (1) {
-
-               /* if plus or minus print the right hand side */
-               if (ic->op == '+' || ic->op == '-') {
-                       sprintf (s, "0x%04x %c ",
-                                (int) operandLitValue (IC_RIGHT (ic)),
-                                ic->op);
-                       s += strlen (s);
-                       ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
-                       continue;
-               }
-
-               /* we reached the end */
-               sprintf (s, "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
-               break;
+                               /* for all the registers allocated to it */
+                               for (k = 0; k < sym->nRegs; k++) {
+                                       if (sym->regs[k]) {
+                                               ic->rMask = bitVectSetBit (ic-> rMask, sym->regs[k]->rIdx);
+                                               /* special case for X & Z registers */
+                                               if (k == R26_IDX || k == R27_IDX) 
+                                                       ic->rMask = bitVectSetBit (ic->rMask, X_IDX);
+                                               if (k == R30_IDX || k == R31_IDX) 
+                                                       ic->rMask = bitVectSetBit (ic->rMask, Z_IDX);
+                                       }
+                               }
+                       }
+               }
        }
-
-       return buffer;
 }
 
+
 /*-----------------------------------------------------------------*/
 /* regTypeNum - computes the type & number of registers required   */
 /*-----------------------------------------------------------------*/
@@ -1490,70 +1731,6 @@ DEFSETFUNC (deallocStackSpil)
        return 0;
 }
 
-/*-----------------------------------------------------------------*/
-/* farSpacePackable - returns the packable icode for far variables */
-/*-----------------------------------------------------------------*/
-static iCode *
-farSpacePackable (iCode * ic)
-{
-       iCode *dic;
-
-       /* go thru till we find a definition for the
-          symbol on the right */
-       for (dic = ic->prev; dic; dic = dic->prev) {
-
-               /* if the definition is a call then no */
-               if ((dic->op == CALL || dic->op == PCALL) &&
-                   IC_RESULT (dic)->key == IC_RIGHT (ic)->key) {
-                       return NULL;
-               }
-
-               /* if shift by unknown amount then not */
-               if ((dic->op == LEFT_OP || dic->op == RIGHT_OP) &&
-                   IC_RESULT (dic)->key == IC_RIGHT (ic)->key)
-                       return NULL;
-
-               /* if pointer get and size > 1 */
-               if (POINTER_GET (dic) &&
-                   getSize (aggrToPtr (operandType (IC_LEFT (dic)), FALSE)) >
-                   1) return NULL;
-
-               if (POINTER_SET (dic) &&
-                   getSize (aggrToPtr (operandType (IC_RESULT (dic)), FALSE))
-                   > 1)
-                       return NULL;
-
-               /* if any three is a true symbol in far space */
-               if (IC_RESULT (dic) &&
-                   IS_TRUE_SYMOP (IC_RESULT (dic)) &&
-                   isOperandInFarSpace (IC_RESULT (dic)))
-                       return NULL;
-
-               if (IC_RIGHT (dic) &&
-                   IS_TRUE_SYMOP (IC_RIGHT (dic)) &&
-                   isOperandInFarSpace (IC_RIGHT (dic)) &&
-                   !isOperandEqual (IC_RIGHT (dic), IC_RESULT (ic)))
-                       return NULL;
-
-               if (IC_LEFT (dic) &&
-                   IS_TRUE_SYMOP (IC_LEFT (dic)) &&
-                   isOperandInFarSpace (IC_LEFT (dic)) &&
-                   !isOperandEqual (IC_LEFT (dic), IC_RESULT (ic)))
-                       return NULL;
-
-               if (isOperandEqual (IC_RIGHT (ic), IC_RESULT (dic))) {
-                       if ((dic->op == LEFT_OP ||
-                            dic->op == RIGHT_OP ||
-                            dic->op == '-') &&
-                           IS_OP_LITERAL (IC_RIGHT (dic))) return NULL;
-                       else
-                               return dic;
-               }
-       }
-
-       return NULL;
-}
-
 /*-----------------------------------------------------------------*/
 /* packRegsForAssign - register reduction for assignment           */
 /*-----------------------------------------------------------------*/
@@ -1667,146 +1844,6 @@ packRegsForAssign (iCode * ic, eBBlock * ebp)
 
 }
 
-/*-----------------------------------------------------------------*/
-/* findAssignToSym : scanning backwards looks for first assig found */
-/*-----------------------------------------------------------------*/
-static iCode *
-findAssignToSym (operand * op, iCode * ic)
-{
-       iCode *dic;
-
-       for (dic = ic->prev; dic; dic = dic->prev) {
-
-               /* if definition by assignment */
-               if (dic->op == '=' &&
-                   !POINTER_SET (dic) && IC_RESULT (dic)->key == op->key
-/*          &&  IS_TRUE_SYMOP(IC_RIGHT(dic)) */
-                       ) {
-
-                       /* we are interested only if defined in far space */
-                       /* or in stack space in case of + & - */
-
-                       /* if assigned to a non-symbol then return
-                          true */
-                       if (!IS_SYMOP (IC_RIGHT (dic)))
-                               break;
-
-                       /* if the symbol is in far space then
-                          we should not */
-                       if (isOperandInFarSpace (IC_RIGHT (dic)))
-                               return NULL;
-
-                       /* for + & - operations make sure that
-                          if it is on the stack it is the same
-                          as one of the three operands */
-                       if ((ic->op == '+' || ic->op == '-') &&
-                           OP_SYMBOL (IC_RIGHT (dic))->onStack) {
-
-                               if (IC_RESULT (ic)->key != IC_RIGHT (dic)->key
-                                   && IC_LEFT (ic)->key !=
-                                   IC_RIGHT (dic)->key
-                                   && IC_RIGHT (ic)->key !=
-                                   IC_RIGHT (dic)->key) return NULL;
-                       }
-
-                       break;
-
-               }
-
-               /* if we find an usage then we cannot delete it */
-               if (IC_LEFT (dic) && IC_LEFT (dic)->key == op->key)
-                       return NULL;
-
-               if (IC_RIGHT (dic) && IC_RIGHT (dic)->key == op->key)
-                       return NULL;
-
-               if (POINTER_SET (dic) && IC_RESULT (dic)->key == op->key)
-                       return NULL;
-       }
-
-       /* now make sure that the right side of dic
-          is not defined between ic & dic */
-       if (dic) {
-               iCode *sic = dic->next;
-
-               for (; sic != ic; sic = sic->next)
-                       if (IC_RESULT (sic) &&
-                           IC_RESULT (sic)->key == IC_RIGHT (dic)->key)
-                               return NULL;
-       }
-
-       return dic;
-
-
-}
-
-/*-----------------------------------------------------------------*/
-/* packRegsForSupport :- reduce some registers for support calls   */
-/*-----------------------------------------------------------------*/
-static int
-packRegsForSupport (iCode * ic, eBBlock * ebp)
-{
-       int change = 0;
-       /* for the left & right operand :- look to see if the
-          left was assigned a true symbol in far space in that
-          case replace them */
-       if (IS_ITEMP (IC_LEFT (ic)) &&
-           OP_SYMBOL (IC_LEFT (ic))->liveTo <= ic->seq) {
-               iCode *dic = findAssignToSym (IC_LEFT (ic), ic);
-               iCode *sic;
-
-               if (!dic)
-                       goto right;
-
-               /* found it we need to remove it from the
-                  block */
-               for (sic = dic; sic != ic; sic = sic->next)
-                       bitVectUnSetBit (sic->rlive, IC_LEFT (ic)->key);
-
-               IC_LEFT (ic)->operand.symOperand =
-                       IC_RIGHT (dic)->operand.symOperand;
-               IC_LEFT (ic)->key = IC_RIGHT (dic)->operand.symOperand->key;
-               remiCodeFromeBBlock (ebp, dic);
-               hTabDeleteItem (&iCodehTab, dic->key, dic, DELETE_ITEM, NULL);
-               change++;
-       }
-
-       /* do the same for the right operand */
-      right:
-       if (!change &&
-           IS_ITEMP (IC_RIGHT (ic)) &&
-           OP_SYMBOL (IC_RIGHT (ic))->liveTo <= ic->seq) {
-               iCode *dic = findAssignToSym (IC_RIGHT (ic), ic);
-               iCode *sic;
-
-               if (!dic)
-                       return change;
-
-               /* if this is a subtraction & the result
-                  is a true symbol in far space then don't pack */
-               if (ic->op == '-' && IS_TRUE_SYMOP (IC_RESULT (dic))) {
-                       sym_link *etype =
-                               getSpec (operandType (IC_RESULT (dic)));
-                       if (IN_FARSPACE (SPEC_OCLS (etype)))
-                               return change;
-               }
-               /* found it we need to remove it from the
-                  block */
-               for (sic = dic; sic != ic; sic = sic->next)
-                       bitVectUnSetBit (sic->rlive, IC_RIGHT (ic)->key);
-
-               IC_RIGHT (ic)->operand.symOperand =
-                       IC_RIGHT (dic)->operand.symOperand;
-               IC_RIGHT (ic)->key = IC_RIGHT (dic)->operand.symOperand->key;
-
-               remiCodeFromeBBlock (ebp, dic);
-               hTabDeleteItem (&iCodehTab, dic->key, dic, DELETE_ITEM, NULL);
-               change++;
-       }
-
-       return change;
-}
-
 #define IS_OP_RUONLY(x) (x && IS_SYMOP(x) && OP_SYMBOL(x)->ruonly)
 
 
@@ -1952,39 +1989,6 @@ isBitwiseOptimizable (iCode * ic)
                return FALSE;
 }
 
-/*-----------------------------------------------------------------*/
-/* packForPush - hueristics to reduce iCode for pushing            */
-/*-----------------------------------------------------------------*/
-static void
-packForPush (iCode * ic, eBBlock * ebp)
-{
-       iCode *dic;
-
-       if (ic->op != IPUSH || !IS_ITEMP (IC_LEFT (ic)))
-               return;
-
-       /* must have only definition & one usage */
-       if (bitVectnBitsOn (OP_DEFS (IC_LEFT (ic))) != 1 ||
-           bitVectnBitsOn (OP_USES (IC_LEFT (ic))) != 1)
-               return;
-
-       /* find the definition */
-       if (!(dic = hTabItemWithKey (iCodehTab,
-                                    bitVectFirstBit (OP_DEFS
-                                                     (IC_LEFT (ic))))))
-                       return;
-
-       if (dic->op != '=' || POINTER_SET (dic))
-               return;
-
-       /* we now we know that it has one & only one def & use
-          and the that the definition is an assignment */
-       IC_LEFT (ic) = IC_RIGHT (dic);
-
-       remiCodeFromeBBlock (ebp, dic);
-       hTabDeleteItem (&iCodehTab, dic->key, dic, DELETE_ITEM, NULL);
-}
-
 /*-----------------------------------------------------------------*/
 /* packRegisters - does some transformations to reduce register    */
 /*                   pressure                                      */
index a4b88cba1d1be8464ae5e93296ea3ef433b4825c..6539980c6bf1761f0ece9715f27f338e7a587aa2 100644 (file)
@@ -87,7 +87,7 @@ asmop *_newForRemat(symbol *sym)
 asmop *_newForTemporary(operand *op, iCode *ic)
 {
     symbol *sym = OP_SYMBOL(op);
-    asmop *aop;
+    asmop *aop = NULL;
 
     if (sym->regType == REG_TYPE_CND) {
        // Conditionals have no size due to being stored in carry.
index ede86abff01f0ff9d66c99668615766bb0a58a74..0e391bb83b94e6a87321f87783fa1dc94654edbc 100644 (file)
@@ -2646,7 +2646,6 @@ static void
 packForReceive (iCode * ic, eBBlock * ebp)
 {
   iCode *dic;
-  bool can_remove = 1;         // assume that we can remove temporary
 
   debugLog ("%s\n", __FUNCTION__);
   debugAopGet ("  result:", IC_RESULT (ic));
index b159923eb3e154e9476492eb220ade5f75e9fc34..76ef1194fae1a69b104e5f3686aa669de8507f17 100644 (file)
@@ -66,6 +66,9 @@ enum
 #define D(_a, _s)
 #endif
 
+#define DISABLE_PACKREGSFORSUPPORT     1
+#define DISABLE_PACKREGSFORACCUSE      1
+
 /*-----------------------------------------------------------------*/
 /* At this point we start getting processor specific although      */
 /* some routines are non-processor specific & can be reused when   */
@@ -1613,6 +1616,9 @@ findAssignToSym (operand * op, iCode * ic)
 
 }
 
+#if !DISABLE_PACKREGSFORSUPPORT
+// PENDING
+
 /*-----------------------------------------------------------------*/
 /* packRegsForSupport :- reduce some registers for support calls   */
 /*-----------------------------------------------------------------*/
@@ -1672,6 +1678,7 @@ right:
 
   return change;
 }
+#endif
 
 #define IS_OP_RUONLY(x) (x && IS_SYMOP(x) && OP_SYMBOL(x)->ruonly)
 
@@ -1826,6 +1833,9 @@ genAssign (ptr)
     ld (iy),(hl)
 */
 
+#if !DISABLE_PACKREGSFORACCUSE
+// PENDING
+
 /** Pack registers for acc use.
     When the result of this operation is small and short lived it may
     be able to be stored in the accumelator.
@@ -1955,6 +1965,7 @@ packRegsForAccUse (iCode * ic)
 accuse:
   OP_SYMBOL (IC_RESULT (ic))->accuse = ACCUSE_A;
 }
+#endif
 
 static void 
 packRegsForHLUse (iCode * ic)