]> git.gag.com Git - fw/sdcc/commitdiff
new options: --no-c-code-in-asm and --i-code-in-asm
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 15 Feb 2003 14:31:37 +0000 (14:31 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 15 Feb 2003 14:31:37 +0000 (14:31 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2272 4a8a32a2-be11-0410-ad9d-d568d2c75423

13 files changed:
doc/sdccman.lyx
src/SDCCglobl.h
src/SDCCmain.c
src/asm.c
src/asm.h
src/ds390/gen.c
src/ds390/main.c
src/mcs51/gen.c
src/mcs51/main.c
src/pic/gen.c
src/xa51/gen.c
src/z80/gen.c
support/Util/MySystem.c

index 84368988c4ee0410bc75ee3e422eea23fec4c45a..961650e8f032473fbeec97370dbbe620305e408f 100644 (file)
@@ -2290,6 +2290,24 @@ cyclomatic complexity
 -V
 \series default 
  Shows the actual commands the compiler is executing.
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold 
+---no-c-code-in-asm
+\series default 
+ Hides your ugly and inefficient c-code from the asm file, so you can always
+ blame the compiler :).
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold 
+---i-code-in-asm
+\series default 
+ Include i-codes in the asm file.
+ Looks like noise but is most helpfull for debugging the compiler itself.
 \layout Subsubsection
 
 Intermediate Dump Options
index c9ce2630f28d8669aa8d3982f818069d5c18919a..23ae7a71b14dd7f0d87c987f82c5dfae05e70b2b 100644 (file)
@@ -255,6 +255,10 @@ struct options
     int xram_size;             /* external ram size (used only for error checking) */
        bool xram_size_set; /* since xram_size=0 is a possibility */
     int code_size;             /* code size (used only for error checking) */    
+    int verboseExec;            /* show what we are doing */
+    int noXinitOpt;             /* don't optimize initialized xdata */
+    int noCcodeInAsm;           /* hide c-code from asm */
+    int iCodeInAsm;             /* show i-code in asm */
   };
 
 /* forward definition for variables accessed globally */
@@ -297,9 +301,6 @@ extern int nlibFiles;
 extern char *libPaths[128];
 extern int nlibPaths;
 
-extern bool verboseExec;
-extern bool noXinitOpt;
-
 void parseWithComma (char **, char *);
 
 /** Creates a temporary file a'la tmpfile which avoids the bugs
index 5dbd298a654027a699cd8f874a214bb5e8a377fd..6f53e3fcaf9544cbe3871d7fa4c75b92b09ad687 100644 (file)
@@ -77,7 +77,6 @@ char *relFiles[128];
 int nrelFiles = 0;
 bool verboseExec = FALSE;
 char *preOutName;
-bool noXinitOpt = FALSE;
 
 /* uncomment JAMIN_DS390 to always override and use ds390 port
   for mcs51 work.  This is temporary, for compatibility testing. */
@@ -125,6 +124,8 @@ char DefaultExePath[128];
 #define OPTION_NO_XINIT_OPT     "--no-xinit-opt"
 #define OPTION_XRAM_SIZE       "--xram-size"
 #define OPTION_CODE_SIZE       "--code-size"
+#define OPTION_NO_CCODE_IN_ASM "--no-c-code-in-asm"
+#define OPTION_ICODE_IN_ASM    "--i-code-in-asm"
 
 static const OPTION 
 optionsTable[] = {
@@ -207,7 +208,9 @@ optionsTable[] = {
     { 0,    "--tini-libid",        NULL,"<nnnn> LibraryID used in -mTININative"},
     { 0,    "--protect-sp-update",  &options.protect_sp_update,"DS390 - will disable interrupts during ESP:SP updates"},
     { 0,    "--parms-in-bank1",            &options.parms_in_bank1,"MCS51/DS390 - use Bank1 for parameter passing"},
-    { 0,    OPTION_NO_XINIT_OPT,    &noXinitOpt, "don't memcpy initialized xram from code"},
+    { 0,    OPTION_NO_XINIT_OPT,    &options.noXinitOpt, "don't memcpy initialized xram from code"},
+    { 0,    OPTION_NO_CCODE_IN_ASM, &options.noCcodeInAsm, "don't include c-code as comments in the asm file"},
+    { 0,    OPTION_ICODE_IN_ASM,    &options.iCodeInAsm, "include i-code as comments in the asm file"},
     /* End of options */
     { 0,    NULL }
 };
index d31b0ea154e871dc96b071ae33243d187be0c732..70dbacd922b2d1a192fcfdfd930c0e0b13e4ab29 100644 (file)
--- a/src/asm.c
+++ b/src/asm.c
@@ -9,6 +9,11 @@
 #include "common.h"
 #include "asm.h"
 
+#if !defined(__BORLANDC__) && !defined(_MSC_VER)
+// for pipe and close
+#include <unistd.h>
+#endif
+
 /* A 'token' is like !blah or %24f and is under the programmers
    control. */
 #define MAX_TOKEN_LEN          64
@@ -204,7 +209,38 @@ asm_addTree (const ASM_MAPPINGS * pMappings)
 }
 
 /*-----------------------------------------------------------------*/
-/* printCLine - try to find the c-code for this lineno             */
+/* printILine - return the readable i-code for this ic             */
+/*                                                                 */
+/* iCodePrint wants a file stream so we need a pipe to fool it     */
+/*-----------------------------------------------------------------*/
+static char verbalICode[1024];
+
+char *printILine (iCode *ic) {
+  int filedes[2];
+  FILE *pipeStream;
+  iCodeTable *icTab=getTableEntry(ic->op);
+  
+  assert(pipe(filedes)!=-1); // forget it
+
+  // stuff the pipe with the readable icode
+  pipeStream=fdopen(filedes[1],"w");
+  icTab->iCodePrint(pipeStream, ic, icTab->printName);
+  // it really needs an extra push
+  fflush(pipeStream);
+  // now swallow it
+  pipeStream=fdopen(filedes[0],"r");
+  fgets(verbalICode, sizeof(verbalICode), pipeStream);
+  // clean up the mess, we'll return here for all icodes!!
+  assert(!close (filedes[0]));
+  assert(!close (filedes[1]));
+  // kill the trailing NL
+  verbalICode[strlen(verbalICode)-1]='\0';
+  // and throw it up
+  return verbalICode;
+}
+
+/*-----------------------------------------------------------------*/
+/* printCLine - return the c-code for this lineno                  */
 /*-----------------------------------------------------------------*/
 static FILE *inFile=NULL;
 static char inLineString[1024];
index 3ae8fc6a5a8bd033265fab8eb72376f2cf45cf59..e46344aed442e9d3a09b7f741b9c129ccd1769f5 100644 (file)
--- a/src/asm.h
+++ b/src/asm.h
@@ -35,5 +35,6 @@ void asm_addTree (const ASM_MAPPINGS * pMappings);
 
 char *FileBaseName (char *fileFullName);
 
+char *printILine (iCode *ic);
 char *printCLine (char *srcFile, int lineno);
 #endif
index e87d5855ccf18034aac3d953728d615003680457..6b5cb9c6b09179b17746e60628ff32fa03be46bd 100644 (file)
@@ -12543,10 +12543,15 @@ gen390Code (iCode * lic)
                        ic->level, ic->block);
              _G.debugLine = 0;
            }
-         emitcode ("", ";\t%s:%d: %s", ic->filename, ic->lineno, 
-                   printCLine(ic->filename, ic->lineno));
+         if (!options.noCcodeInAsm) {
+           emitcode ("", ";\t%s:%d: %s", ic->filename, ic->lineno, 
+                     printCLine(ic->filename, ic->lineno));
+         }
          cln = ic->lineno;
        }
+      if (options.iCodeInAsm) {
+       emitcode("", ";ic:%d: %s", ic->key, printILine(ic));
+      }
       /* if the result is marked as
          spilt and rematerializable or code for
          this has already been generated then
index 5698771c6981013b25ac533c37f0eaa9d60819aa..e0fabb359144da39d82090ccb115278f5819aa2c 100644 (file)
@@ -118,6 +118,10 @@ _ds390_parseOptions (int *pargc, char **argv, int *i)
 static void
 _ds390_finaliseOptions (void)
 {
+  if (options.noXinitOpt) {
+    port->genXINIT=0;
+  }
+
   /* Hack-o-matic: if we are using the flat24 model,
    * adjust pointer sizes.
    */
index 0daad8e21d17fdcabd22d9efc3be83d2f62380c6..1df46f84607a980952cb2a735e2901526edf5524 100644 (file)
@@ -8919,10 +8919,15 @@ gen51Code (iCode * lic)
                        ic->level, ic->block);
              _G.debugLine = 0;
            }
-         emitcode ("", "; %s:%d: %s", ic->filename, ic->lineno, 
-                   printCLine(ic->filename, ic->lineno));
+         if (!options.noCcodeInAsm) {
+           emitcode ("", ";%s:%d: %s", ic->filename, ic->lineno, 
+                     printCLine(ic->filename, ic->lineno));
+         }
          cln = ic->lineno;
        }
+      if (options.iCodeInAsm) {
+       emitcode("", ";ic:%d: %s", ic->key, printILine(ic));
+      }
       /* if the result is marked as
          spilt and rematerializable or code for
          this has already been generated then
index ed2b53ba72bea7ca6aa74d79888a766cc3821707..aeac05d2a19463acbb8f356cf213cb0a3176ccb4 100644 (file)
@@ -105,7 +105,7 @@ _mcs51_parseOptions (int *pargc, char **argv, int *i)
 static void
 _mcs51_finaliseOptions (void)
 {
-  if (noXinitOpt /* || options.model==MODEL_SMALL */) {
+  if (options.noXinitOpt) {
     port->genXINIT=0;
   }
 
index 6ca5e3ecbb338e8929f783732a851e7ebdd3d0d0..665d8b2724af83e456c843ab0480ed98b5a27dc6 100644 (file)
@@ -9954,13 +9954,18 @@ void genpic14Code (iCode *lic)
              pic14_emitcode ("", ";\t%s:%d: %s", ic->filename, ic->lineno, 
              printCLine(ic->filename, ic->lineno));
            */
-           addpCode2pBlock(pb,
-                           newpCodeCSource(ic->lineno, 
-                                           ic->filename, 
-                                           printCLine(ic->filename, ic->lineno)));
+           if (!options.noCcodeInAsm) {
+             addpCode2pBlock(pb,
+                             newpCodeCSource(ic->lineno, 
+                                             ic->filename, 
+                                             printCLine(ic->filename, ic->lineno)));
+           }
 
            cln = ic->lineno ;
        }
+
+       // if you want printILine too, look at ../mcs51/gen.c, i don't understand this :)
+
        /* if the result is marked as
           spilt and rematerializable or code for
           this has already been generated then
index 49ada9502543cddf153ce20f8c4dc122cece1d7b..f16b6132ad264fd8cf0e849b5055f18459d17b30 100755 (executable)
@@ -1936,10 +1936,16 @@ void genXA51Code (iCode * lic) {
                  ic->level, ic->block);
        _G.debugLine = 0;
       }
-      emitcode ("", ";\t%s:%d: %s", ic->filename, ic->lineno, 
-               printCLine(ic->filename, ic->lineno));
+      if (!options.noCcodeInAsm) {
+       emitcode ("", ";\t%s:%d: %s", ic->filename, ic->lineno, 
+                 printCLine(ic->filename, ic->lineno));
+      }
       cln = ic->lineno;
     }
+    if (options.iCodeInAsm) {
+      emitcode("", ";ic:%d: %s", ic->key, printILine(ic));
+    }
+    
     /* if the result is marked as
        spilt and rematerializable or code for
        this has already been generated then
index 60e46b11d00da2a1614411a8f3ca74095ff53b08..4a9f8b25e766a8e14bc183e86e513ff28ce616ac 100644 (file)
@@ -7248,10 +7248,15 @@ genZ80Code (iCode * lic)
 
       if (cln != ic->lineno)
        {
-         emit2 ("; %s:%d: %s", ic->filename, ic->lineno,
-                printCLine(ic->filename, ic->lineno));
+         if (!options.noCcodeInAsm) {
+           emit2 (";%s:%d: %s", ic->filename, ic->lineno,
+                  printCLine(ic->filename, ic->lineno));
+         }
          cln = ic->lineno;
        }
+      if (options.iCodeInAsm) {
+       emit2 (";ic:%d: %s", ic->key, printILine(ic));
+      }
       /* if the result is marked as
          spilt and rematerializable or code for
          this has already been generated then
index e18646b211fa94adf5bd0cf261c5e82020f6c174..a574b85c201a0f747b66d34cf4af07e89f4e3642 100644 (file)
@@ -78,7 +78,7 @@ my_system (const char *cmd)
       i++;
     }
 
-  if (verboseExec)
+  if (options.verboseExec)
     {
       printf ("+ %s\n", cmdLine ? cmdLine : cmd);
     }