* src/SDCC.y, src/SDCCast.c, src/SDCCcse.c, src/SDCCglue.c, src/SDCCicode.c,
[fw/sdcc] / src / SDCCopt.c
index 9a88fdf28eaf0d61bbc74d00d232465893b6874b..1adb1461301fca7b0cd207fdcd76ca8d114830fb 100644 (file)
@@ -72,7 +72,7 @@ cnvToFcall (iCode * ic, eBBlock * ebp)
       bitVectUnSetBit (OP_USES (left), ic->key);
   if (IS_SYMOP (right))
       bitVectUnSetBit (OP_USES (right), ic->key);
-  
+
   if (IS_FLOAT (operandType (right))) {
     switch (ic->op)
       {
@@ -143,7 +143,7 @@ cnvToFcall (iCode * ic, eBBlock * ebp)
         break;
       }
   }
-  
+
 
   /* if float support routines NOT compiled as reentrant */
   if (!options.float_rent)
@@ -240,9 +240,9 @@ cnvToFcall (iCode * ic, eBBlock * ebp)
         if(!SPEC_EXTR(func->etype)) {
             memmap *seg = SPEC_OCLS(OP_SYMBOL(IC_LEFT(newic))->etype);
 
-                SPEC_EXTR(func->etype) = 1;
-                seg = SPEC_OCLS( func->etype );
-                addSet(&seg->syms, func);
+            SPEC_EXTR(func->etype) = 1;
+            seg = SPEC_OCLS( func->etype );
+            addSet(&seg->syms, func);
         }
   }
 
@@ -290,7 +290,7 @@ found:
   if (!options.float_rent)
     {
       /* first one */
-      if (IS_REGPARM (FUNC_ARGS(func->type)->etype)) 
+      if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
         {
           newic = newiCode (SEND, IC_RIGHT (ic), NULL);
           newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
@@ -331,16 +331,16 @@ found:
     FUNC_HASFCALL (currFunc->type) = 1;
 
   if(TARGET_IS_PIC16 || TARGET_IS_PIC) {
-       /* normally these functions aren't marked external, so we can use their
-        * _extern field to marked as already added to symbol table */
-
-       if(!SPEC_EXTR(func->etype)) {
-           memmap *seg = SPEC_OCLS(OP_SYMBOL(IC_LEFT(newic))->etype);
-               
-               SPEC_EXTR(func->etype) = 1;
-               seg = SPEC_OCLS( func->etype );
-               addSet(&seg->syms, func);
-       }
+        /* normally these functions aren't marked external, so we can use their
+         * _extern field to marked as already added to symbol table */
+
+        if(!SPEC_EXTR(func->etype)) {
+            memmap *seg = SPEC_OCLS(OP_SYMBOL(IC_LEFT(newic))->etype);
+
+            SPEC_EXTR(func->etype) = 1;
+            seg = SPEC_OCLS( func->etype );
+            addSet(&seg->syms, func);
+        }
   }
 
   addiCodeToeBBlock (ebp, newic, ip);
@@ -350,7 +350,7 @@ found:
 /*----------------------------------------------------------------------*/
 /* cnvToFixed16x16Cast - converts casts to fixed16x16 to function calls */
 /*----------------------------------------------------------------------*/
-static void 
+static void
 cnvToFixed16x16Cast (iCode * ic, eBBlock * ebp)
 {
   iCode *ip, *newic;
@@ -367,13 +367,13 @@ cnvToFixed16x16Cast (iCode * ic, eBBlock * ebp)
   for (bwd = 0; bwd < 3; bwd++)
     {
       for (su = 0; su < 2; su++)
-       {
-         if (compareType (type, __multypes[bwd][su]) == 1)
-           {
-             func = __fp16x16conv[0][bwd][su];
-             goto found;
-           }
-       }
+        {
+          if (compareType (type, __multypes[bwd][su]) == 1)
+            {
+              func = __fp16x16conv[0][bwd][su];
+              goto found;
+            }
+        }
     }
   assert (0);
 found:
@@ -535,7 +535,7 @@ found:
 /*--------------------------------------------------------------------------*/
 /* cnvFromFixed16x16Cast - converts casts from fixed16x16 to function calls */
 /*--------------------------------------------------------------------------*/
-static void 
+static void
 cnvFromFixed16x16Cast (iCode * ic, eBBlock * ebp)
 {
   iCode *ip, *newic;
@@ -561,13 +561,13 @@ cnvFromFixed16x16Cast (iCode * ic, eBBlock * ebp)
             }
         }
     }
-    
+
   if (compareType (type, floatType) == 1)
     {
       func = __fp16x16conv[1][3][0];
       goto found;
     }
-    
+
   assert (0);
 found:
 
@@ -616,16 +616,16 @@ found:
     FUNC_HASFCALL (currFunc->type) = 1;
 
   if(TARGET_IS_PIC16 || TARGET_IS_PIC) {
-       /* normally these functions aren't marked external, so we can use their
-        * _extern field to marked as already added to symbol table */
-
-       if(!SPEC_EXTR(func->etype)) {
-           memmap *seg = SPEC_OCLS(OP_SYMBOL(IC_LEFT(newic))->etype);
-               
-               SPEC_EXTR(func->etype) = 1;
-               seg = SPEC_OCLS( func->etype );
-               addSet(&seg->syms, func);
-       }
+        /* normally these functions aren't marked external, so we can use their
+         * _extern field to marked as already added to symbol table */
+
+        if(!SPEC_EXTR(func->etype)) {
+            memmap *seg = SPEC_OCLS(OP_SYMBOL(IC_LEFT(newic))->etype);
+
+                SPEC_EXTR(func->etype) = 1;
+                seg = SPEC_OCLS( func->etype );
+                addSet(&seg->syms, func);
+        }
   }
 
   addiCodeToeBBlock (ebp, newic, ip);
@@ -805,10 +805,10 @@ convertToFcall (eBBlock ** ebbs, int count)
                 cnvFromFloatCast (ic, ebbs[i]);
               else if (IS_FLOAT (operandType (IC_LEFT (ic))))
                 cnvToFloatCast (ic, ebbs[i]);
-             if (IS_FIXED16X16 (operandType (IC_RIGHT (ic))))
-               cnvFromFixed16x16Cast (ic, ebbs[i]);
-             else if (IS_FIXED16X16 (operandType (IC_LEFT (ic))))
-               cnvToFixed16x16Cast (ic, ebbs[i]);
+              if (IS_FIXED16X16 (operandType (IC_RIGHT (ic))))
+                cnvFromFixed16x16Cast (ic, ebbs[i]);
+              else if (IS_FIXED16X16 (operandType (IC_LEFT (ic))))
+                cnvToFixed16x16Cast (ic, ebbs[i]);
             }
 
           // Easy special case which avoids function call: modulo by a literal power
@@ -816,7 +816,7 @@ convertToFcall (eBBlock ** ebbs, int count)
           if (ic->op == '%' && isOperandLiteral(IC_RIGHT(ic)) &&
               IS_UNSIGNED(operandType(IC_LEFT(ic))))
             {
-              unsigned litVal = abs((unsigned)operandLitValue(IC_RIGHT(ic)));
+              unsigned litVal = abs((unsigned) double2ul (operandLitValue(IC_RIGHT(ic))));
 
               /* modulo by 1: no remainder */
               if (litVal == 1)
@@ -1245,7 +1245,7 @@ killDeadCode (ebbIndex * ebbi)
                       symbol * resultsym = OP_SYMBOL (IC_RESULT (ic));
                       symbol * prereqv = resultsym->prereqv;
 
-                     if (prereqv && prereqv->reqv && (OP_SYMBOL (prereqv->reqv) == resultsym))
+                      if (prereqv && prereqv->reqv && (OP_SYMBOL (prereqv->reqv) == resultsym))
                         {
                           operand * newreqv;
 
@@ -1290,7 +1290,7 @@ killDeadCode (ebbIndex * ebbi)
             }                   /* end of all instructions */
 
           if (!ebbs[i]->sch && !ebbs[i]->noPath)
-           disconBBlock (ebbs[i], ebbi);
+            disconBBlock (ebbs[i], ebbi);
 
         }                       /* end of for all blocks */
 
@@ -1462,7 +1462,7 @@ eBBlockFromiCode (iCode * ic)
 
   /* replace the local variables with their
      register equivalents : the liveRange computation
-     along with the register allocation will determine 
+     along with the register allocation will determine
      if it finally stays in the registers */
   replaceRegEqv (ebbi);
 
@@ -1494,7 +1494,7 @@ eBBlockFromiCode (iCode * ic)
     {
       change += cseAllBlocks (ebbi, FALSE);
       if (options.dump_gcse)
-       dumpEbbsToFileExt (DUMP_GCSE, ebbi);
+        dumpEbbsToFileExt (DUMP_GCSE, ebbi);
     }
   else
     {
@@ -1524,7 +1524,7 @@ eBBlockFromiCode (iCode * ic)
       computeDataFlow (ebbi);
       change += cseAllBlocks (ebbi, FALSE);
       if (options.dump_loop)
-       dumpEbbsToFileExt (DUMP_LOOPG, ebbi);
+        dumpEbbsToFileExt (DUMP_LOOPG, ebbi);
 
       /* if loop optimizations caused a change then do
          dead code elimination once more : this will
@@ -1533,7 +1533,7 @@ eBBlockFromiCode (iCode * ic)
       killDeadCode (ebbi);
 
       if (options.dump_loop)
-       dumpEbbsToFileExt (DUMP_LOOPD, ebbi);
+        dumpEbbsToFileExt (DUMP_LOOPD, ebbi);
 
     }
 
@@ -1548,9 +1548,9 @@ eBBlockFromiCode (iCode * ic)
        && !FUNC_ISNAKED(currFunc->type)) {
         eBBlock *bp;
         // make sure all predecessors of the last block end in a return
-       for (bp=setFirstItem(ebbi->bbOrder[ebbi->count-1]->predList); 
+        for (bp=setFirstItem(ebbi->bbOrder[ebbi->count-1]->predList);
              bp;
-            bp=setNextItem(ebbi->bbOrder[ebbi->count-1]->predList)) {
+             bp=setNextItem(ebbi->bbOrder[ebbi->count-1]->predList)) {
           if (bp->ech->op != RETURN) {
             werrorfl (bp->ech->filename, bp->ech->lineno,
                       W_VOID_FUNC, currFunc->name);