* src/SDCCmain.c: removed option -C since SDCC compiler doesn't know
[fw/sdcc] / src / pic / ralloc.c
index 4d1ab9349fa58c9c9e91632da3e694f533f31a07..5f9ff8c1ea329b5b789eb57b5d8ecb0623fcb09c 100644 (file)
 #include "gen.h"
 
 
-#if defined(__BORLANDC__) || defined(_MSC_VER)
-#define STRCASECMP stricmp
 #define FENTRY2                        1 ? (void)0 : printf 
-#else
-#define STRCASECMP strcasecmp
-//#define FENTRY2(fmt,...)     do { fprintf (stderr, "%s:%d: called.\n", __FUNCTION__, __LINE__); fprintf (stderr, fmt, ## __VA_ARGS__); } while (0)
-#define FENTRY2                        1 ? (void)0 : printf 
-#endif
 
 /* this should go in SDCCicode.h, but it doesn't. */
 #define IS_REF(op)       (IS_SYMOP(op) && op->operand.symOperand->isref == 1)
@@ -95,14 +88,14 @@ int Gstack_size = 0;
 
 
 static void spillThis (symbol *);
-static int debug = 1;
+static int debug = 0;  // should be 0 when committed, creates .d files
 static FILE *debugF = NULL;
 /*-----------------------------------------------------------------*/
 /* debugLog - open a file for debugging information                */
 /*-----------------------------------------------------------------*/
 //static void debugLog(char *inst,char *fmt, ...)
 static void
-       debugLog (char *fmt,...)
+debugLog (char *fmt,...)
 {
        static int append = 0;  // First time through, open the file without append.
 
@@ -125,41 +118,29 @@ static void
                        werror (E_FILE_OPEN_ERR, buffer);
                        exit (1);
                }
-               append = 1;             // Next time debubLog is called, we'll append the debug info
+               append = 1;             // Next time debugLog is called, we'll append the debug info
 
        }
 
        va_start (ap, fmt);
-
        vsprintf (buffer, fmt, ap);
+       va_end (ap);
 
        fprintf (debugF, "%s", buffer);
        //if (options.verbose) fprintf (stderr, "%s: %s", __FUNCTION__, buffer);
-       /*
-       while (isspace((unsigned char)*bufferP)) bufferP++;
-
-       if (bufferP && *bufferP) 
-               lineCurr = (lineCurr ?
-               connectLine(lineCurr,newLineNode(lb)) :
-               (lineHead = newLineNode(lb)));
-       lineCurr->isInline = _G.inLine;
-       lineCurr->isDebug  = _G.debugLine;
-       */
-       va_end (ap);
-
 }
  
 static void
-       debugNewLine (void)
+debugNewLine (void)
 {
        if (debugF)
                fputc ('\n', debugF);
 }
  /*-----------------------------------------------------------------*/
- /* debugLogClose - closes the debug log file (if opened)           */
+ /* pic14_debugLogClose - closes the debug log file (if opened)           */
  /*-----------------------------------------------------------------*/
-static void
-       debugLogClose (void)
+void
+pic14_debugLogClose (void)
 {
        if (debugF)
        {
@@ -170,20 +151,20 @@ static void
 #define AOP(op) op->aop
  
 static char *
-       debugAopGet (char *str, operand * op)
+debugAopGet (char *str, operand * op)
 {
-        if (str)
-               debugLog (str);
+       if (!debug) return NULL;
+
+        if (str) debugLog (str);
 
        printOperand (op, debugF);
        debugNewLine ();
 
        return NULL;
-
 }
 
 static char *
-       decodeOp (unsigned int op)
+decodeOp (unsigned int op)
 {
 
        if (op < 128 && op > ' ')
@@ -3647,10 +3628,11 @@ packForPush (iCode * ic, eBBlock * ebp)
 
 void printSymType(char * str, sym_link *sl)
 {
-       debugLog ("    %s Symbol type: ",str);
-       printTypeChain( sl, debugF);
-       debugLog ("\n");
-       
+       if (debug) {
+               debugLog ("    %s Symbol type: ",str);
+               printTypeChain( sl, debugF);
+               debugLog ("\n");
+       }
 }
 
 /*-----------------------------------------------------------------*/
@@ -3662,7 +3644,8 @@ void isData(sym_link *sl)
 {
        FILE *of = stderr;
        
-       if(!sl)
+       // avoid garbage `data' and `sfr' output
+       if(!sl || !debugF)
                return;
        
        if(debugF)
@@ -4176,6 +4159,6 @@ pic14_assignRegisters (ebbIndex * ebbi)
        //pic14_freeAllRegs ();
        
        debugLog ("leaving\n<><><><><><><><><><><><><><><><><>\n");
-       debugLogClose ();
+       pic14_debugLogClose ();
        return;
 }