From: johanknol Date: Sat, 15 Feb 2003 14:31:37 +0000 (+0000) Subject: new options: --no-c-code-in-asm and --i-code-in-asm X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=55ea92f1a4a24c9626e8c8b504874b22a10a83e3;p=fw%2Fsdcc new options: --no-c-code-in-asm and --i-code-in-asm git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2272 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/doc/sdccman.lyx b/doc/sdccman.lyx index 84368988..961650e8 100644 --- a/doc/sdccman.lyx +++ b/doc/sdccman.lyx @@ -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 diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index c9ce2630..23ae7a71 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -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 diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 5dbd298a..6f53e3fc 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -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," 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 } }; diff --git a/src/asm.c b/src/asm.c index d31b0ea1..70dbacd9 100644 --- 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 +#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]; diff --git a/src/asm.h b/src/asm.h index 3ae8fc6a..e46344ae 100644 --- 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 diff --git a/src/ds390/gen.c b/src/ds390/gen.c index e87d5855..6b5cb9c6 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -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 diff --git a/src/ds390/main.c b/src/ds390/main.c index 5698771c..e0fabb35 100644 --- a/src/ds390/main.c +++ b/src/ds390/main.c @@ -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. */ diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 0daad8e2..1df46f84 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -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 diff --git a/src/mcs51/main.c b/src/mcs51/main.c index ed2b53ba..aeac05d2 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -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; } diff --git a/src/pic/gen.c b/src/pic/gen.c index 6ca5e3ec..665d8b27 100644 --- a/src/pic/gen.c +++ b/src/pic/gen.c @@ -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 diff --git a/src/xa51/gen.c b/src/xa51/gen.c index 49ada950..f16b6132 100755 --- a/src/xa51/gen.c +++ b/src/xa51/gen.c @@ -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 diff --git a/src/z80/gen.c b/src/z80/gen.c index 60e46b11..4a9f8b25 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -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 diff --git a/support/Util/MySystem.c b/support/Util/MySystem.c index e18646b2..a574b85c 100644 --- a/support/Util/MySystem.c +++ b/support/Util/MySystem.c @@ -78,7 +78,7 @@ my_system (const char *cmd) i++; } - if (verboseExec) + if (options.verboseExec) { printf ("+ %s\n", cmdLine ? cmdLine : cmd); }