+2004-07-27 Maarten Brock <sourceforge.brock AT dse.nl>
+
+ * added lib/calloc.c, lib/free.c, lib/realloc.c, include/stddef.h
+ * updated lib/malloc.c, lib/libsdcc.lib, lib/Makefile.in, include/malloc.h
+ * src/SDCC.lex (doPragma): added pragma disable_warning <nnn>
+ * src/SDCCmain.c (parseCmdLine): added option --disable-warning <nnn>
+ * src/ds390/gen.c (genPlusIncr): fixed bug when incrementing generic pointers
+ * support/Util/SDCCerr.c (vwerror): suppress disabled warnings and output
+ error/warning numbers,
+ added function setWarningDisabled()
+ * support/Util/SDCCerr.h: added setWarningDisabled() and MAX_ERROR_WARNING
+ * support/regression/ports/mcs51-stack-auto/spec.mk: added dependencies
+ _memcmp.c _memmove.c calloc.c realloc.c free.c
+ * support/regression/tests/malloc.c: added tests for new functionality
+ * support/regression/tests/zeropad.c: added tests for truncated initializers
+ and initialized char arrays starting with '\x0'
+ * src/mcs51/peeph.def: fixed regression, added peephole 177.f
+
2004-07-26 Bernhard Held <bernhard AT bernhardheld.de>
* support/valdiag/tests/overflow.c: fixed warning on (1 >> 40)
2004-07-26 Frieder Ferlemann <Frieder.Ferlemann AT web.de>
* doc/sdccman.lyx: updated example in section "Absolute Addressing"
- * src/mcs51/peeph.def: added contributed fix for "bug" #995347 as
+ * src/mcs51/peeph.def: added contributed fix for "bug" #995347 as
peephole 177.e. Thanks to anonymous
2004-07-25 Vangelis Rokas <vrokas AT otenet.gr>
P_EXCLUDE,
P_NOIV,
P_LOOPREV,
- P_OVERLAY_ /* I had a strange conflict with P_OVERLAY while */
+ P_OVERLAY_, /* I had a strange conflict with P_OVERLAY while */
/* cross-compiling for MINGW32 with gcc 3.2 */
+ P_DISABLEWARN
};
static void doPragma(int op, char *cp)
{
+ int i;
+
switch (op) {
case P_SAVE:
{
case P_OVERLAY_:
break; /* notyet */
+
+ case P_DISABLEWARN:
+ if (sscanf(cp, "%d", &i) && (i<MAX_ERROR_WARNING))
+ {
+ setWarningDisabled(i);
+ }
+ break;
}
}
{ "noiv", P_NOIV, 0 },
{ "overlay", P_OVERLAY_, 0 },
{ "less_pedantic", P_LESSPEDANTIC, 0 },
+ { "disable_warning",P_DISABLEWARN, 0 },
/*
* The following lines are deprecated pragmas,
/* REMOVE ME!!! */
extern int yyparse (void);
-FILE *srcFile; /* source file */
-char *fullSrcFileName; /* full name for the source file; */
- /* can be NULL while c1mode or linking without compiling */
-char *fullDstFileName; /* full name for the output file; */
- /* only given by -o, otherwise NULL */
-char *dstFileName; /* destination file name without extension */
-char *dstPath = ""; /* path for the output files; */
- /* "" is equivalent with cwd */
-char *moduleNameBase; /* module name base is source file without path and extension */
+FILE *srcFile; /* source file */
+char *fullSrcFileName; /* full name for the source file; */
+ /* can be NULL while c1mode or linking without compiling */
+char *fullDstFileName; /* full name for the output file; */
+ /* only given by -o, otherwise NULL */
+char *dstFileName; /* destination file name without extension */
+char *dstPath = ""; /* path for the output files; */
+ /* "" is equivalent with cwd */
+char *moduleNameBase; /* module name base is source file without path and extension */
/* can be NULL while linking without compiling */
-char *moduleName; /* module name is same as module name base, but with all */
- /* non-alphanumeric characters replaced with underscore */
+char *moduleName; /* module name is same as module name base, but with all */
+ /* non-alphanumeric characters replaced with underscore */
int currRegBank = 0;
int RegBankUsed[4] = {1, 0, 0, 0}; /*JCF: Reg Bank 0 used by default*/
struct optimize optimize;
char scratchFileName[PATH_MAX];
char buffer[PATH_MAX * 2];
-#define OPTION_HELP "-help"
-
-#define LENGTH(_a) (sizeof(_a)/sizeof(*(_a)))
-
-#define OPTION_STACK_8BIT "--stack-8bit"
-#define OPTION_OUT_FMT_IHX "--out-fmt-ihx"
-#define OPTION_LARGE_MODEL "--model-large"
-#define OPTION_MEDIUM_MODEL "--model-medium"
-#define OPTION_SMALL_MODEL "--model-small"
-#define OPTION_FLAT24_MODEL "--model-flat24"
-#define OPTION_DUMP_ALL "--dumpall"
-#define OPTION_PEEP_FILE "--peep-file"
-#define OPTION_LIB_PATH "--lib-path"
-#define OPTION_XSTACK_LOC "--xstack-loc"
-#define OPTION_CALLEE_SAVES "--callee-saves"
-#define OPTION_STACK_LOC "--stack-loc"
-#define OPTION_XRAM_LOC "--xram-loc"
-#define OPTION_IRAM_SIZE "--iram-size"
-#define OPTION_VERSION "--version"
-#define OPTION_DATA_LOC "--data-loc"
-#define OPTION_CODE_LOC "--code-loc"
-#define OPTION_IDATA_LOC "--idata-loc"
+#define OPTION_HELP "-help"
+
+#define LENGTH(_a) (sizeof(_a)/sizeof(*(_a)))
+
+#define OPTION_STACK_8BIT "--stack-8bit"
+#define OPTION_OUT_FMT_IHX "--out-fmt-ihx"
+#define OPTION_LARGE_MODEL "--model-large"
+#define OPTION_MEDIUM_MODEL "--model-medium"
+#define OPTION_SMALL_MODEL "--model-small"
+#define OPTION_FLAT24_MODEL "--model-flat24"
+#define OPTION_DUMP_ALL "--dumpall"
+#define OPTION_PEEP_FILE "--peep-file"
+#define OPTION_LIB_PATH "--lib-path"
+#define OPTION_XSTACK_LOC "--xstack-loc"
+#define OPTION_CALLEE_SAVES "--callee-saves"
+#define OPTION_STACK_LOC "--stack-loc"
+#define OPTION_XRAM_LOC "--xram-loc"
+#define OPTION_IRAM_SIZE "--iram-size"
+#define OPTION_VERSION "--version"
+#define OPTION_DATA_LOC "--data-loc"
+#define OPTION_CODE_LOC "--code-loc"
+#define OPTION_IDATA_LOC "--idata-loc"
#define OPTION_NO_LABEL_OPT "--nolabelopt"
-#define OPTION_NO_LOOP_INV "--noinvariant"
-#define OPTION_NO_LOOP_IND "--noinduction"
-#define OPTION_LESS_PEDANTIC "--less-pedantic"
-#define OPTION_NO_GCSE "--nogcse"
-#define OPTION_SHORT_IS_8BITS "--short-is-8bits"
-#define OPTION_TINI_LIBID "--tini-libid"
+#define OPTION_NO_LOOP_INV "--noinvariant"
+#define OPTION_NO_LOOP_IND "--noinduction"
+#define OPTION_LESS_PEDANTIC "--less-pedantic"
+#define OPTION_DISABLE_WARNING "--disable-warning"
+#define OPTION_NO_GCSE "--nogcse"
+#define OPTION_SHORT_IS_8BITS "--short-is-8bits"
+#define OPTION_TINI_LIBID "--tini-libid"
#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"
+#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"
#define OPTION_PRINT_SEARCH_DIRS "--print-search-dirs"
#define OPTION_MSVC_ERROR_STYLE "--vc"
#define OPTION_USE_STDOUT "--use-stdout"
-#define OPTION_STACK_SIZE "--stack-size"
-#define OPTION_PACK_IRAM "--pack-iram"
-#define OPTION_NO_PEEP_COMMENTS "--no-peep-comments"
+#define OPTION_STACK_SIZE "--stack-size"
+#define OPTION_PACK_IRAM "--pack-iram"
+#define OPTION_NO_PEEP_COMMENTS "--no-peep-comments"
static const OPTION
optionsTable[] = {
{ 0, "--nostdinc", &options.nostdinc, "Do not include the standard include directory in the search path" },
{ 0, "--verbose", &options.verbose, "Trace calls to the preprocessor, assembler, and linker" },
{ 0, OPTION_LESS_PEDANTIC, NULL, "Disable some of the more pedantic warnings" },
- { 0, OPTION_SHORT_IS_8BITS, NULL, "Make short 8bits (for old times sake)" },
+ { 0, OPTION_DISABLE_WARNING, NULL, "<nnnn> Disable specific warning" },
+ { 0, OPTION_SHORT_IS_8BITS, NULL, "Make short 8bits (for old times sake)" },
{ 0, "--profile", &options.profile, "On supported ports, generate extra profiling information" },
{ 0, "--fommit-frame-pointer", &options.ommitFramePtr, "Leave out the frame pointer." },
{ 0, "--all-callee-saves", &options.all_callee_saves, "callee will always save registers used" },
#if !OPT_DISABLE_DS390
{ 0, "--use-accelerator", &options.useAccelerator,"generate code for DS390 Arithmetic Accelerator"},
#endif
- { 0, "--stack-probe", &options.stack_probe,"insert call to function __stack_probe at each function prologue"},
+ { 0, "--stack-probe", &options.stack_probe,"insert call to function __stack_probe at each function prologue"},
#if !OPT_DISABLE_TININative
- { 0, "--tini-libid", NULL,"<nnnn> LibraryID used in -mTININative"},
+ { 0, "--tini-libid", NULL,"<nnnn> LibraryID used in -mTININative"},
#endif
#if !OPT_DISABLE_DS390
{ 0, "--protect-sp-update", &options.protect_sp_update,"DS390 - will disable interrupts during ESP:SP updates"},
#endif
#if !OPT_DISABLE_DS390 || !OPT_DISABLE_MCS51
- { 0, "--parms-in-bank1", &options.parms_in_bank1,"MCS51/DS390 - use Bank1 for parameter passing"},
- { 0, OPTION_STACK_SIZE, NULL,"MCS51/DS390 - Tells the linker to allocate this space for stack"},
- { 0, OPTION_PACK_IRAM, &options.pack_iram,"MCS51/DS390 - Tells the linker to pack variables in internal ram"},
+ { 0, "--parms-in-bank1", &options.parms_in_bank1,"MCS51/DS390 - use Bank1 for parameter passing"},
+ { 0, OPTION_STACK_SIZE, NULL,"MCS51/DS390 - Tells the linker to allocate this space for stack"},
+ { 0, OPTION_PACK_IRAM, &options.pack_iram,"MCS51/DS390 - Tells the linker to pack variables in internal ram"},
#endif
{ 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"},
const char *message;
} UNSUPPORTEDOPT;
-static const UNSUPPORTEDOPT
+static const UNSUPPORTEDOPT
unsupportedOptTable[] = {
- { 'X', NULL, "use --xstack-loc instead" },
- { 'x', NULL, "use --xstack instead" },
- { 'i', NULL, "use --idata-loc instead" },
- { 'r', NULL, "use --xdata-loc instead" },
- { 's', NULL, "use --code-loc instead" },
- { 'Y', NULL, "use -I instead" }
+ { 'X', NULL, "use --xstack-loc instead" },
+ { 'x', NULL, "use --xstack instead" },
+ { 'i', NULL, "use --idata-loc instead" },
+ { 'r', NULL, "use --xdata-loc instead" },
+ { 's', NULL, "use --code-loc instead" },
+ { 'Y', NULL, "use -I instead" }
};
/** List of all default constant macros.
&xa51_port,
#endif
#if !OPT_DISABLE_DS400
- &ds400_port,
+ &ds400_port,
#endif
#if !OPT_DISABLE_HC08
&hc08_port,
for (i = 0; i < NUM_PORTS; i++)
{
if (!strcmp (_ports[i]->target, name))
- {
- port = _ports[i];
- return;
- }
+ {
+ port = _ports[i];
+ return;
+ }
}
/* Error - didnt find */
werror (E_UNKNOWN_TARGET, name);
exit (1);
}
-/* Override the default processor with the one specified
+/* Override the default processor with the one specified
* on the command line */
static void
_setProcessor (char *_processor)
for (i = 0; i < NUM_PORTS; i++)
{
if (_ports[i]->magic != PORT_MAGIC)
- {
- /* Uncomment this line to debug which port is causing the problem
- * (the target name is close to the beginning of the port struct
- * and probably can be accessed just fine). */
- fprintf(stderr,"%s :",_ports[i]->target);
- wassertl (0, "Port definition structure is incomplete");
- }
+ {
+ /* Uncomment this line to debug which port is causing the problem
+ * (the target name is close to the beginning of the port struct
+ * and probably can be accessed just fine). */
+ fprintf(stderr,"%s :",_ports[i]->target);
+ wassertl (0, "Port definition structure is incomplete");
+ }
}
}
while (argc--)
{
if (!strncmp (*argv, "-m", 2))
- {
- _setPort (*argv + 2);
- return;
- }
+ {
+ _setPort (*argv + 2);
+ return;
+ }
argv++;
}
/* Use the first in the list */
- port = _ports[0];
+ port = _ports[0];
}
/* search through the command line options for the processor */
while (argc--)
{
if (!strncmp (*argv, "-p", 2))
- {
- _setProcessor (*argv + 2);
- return;
- }
+ {
+ _setProcessor (*argv + 2);
+ return;
+ }
argv++;
}
/* no error if processor was not specified. */
}
-
/*-----------------------------------------------------------------*/
/* printVersionInfo - prints the version info */
/*-----------------------------------------------------------------*/
int i;
fprintf (stderr,
- "SDCC : ");
+ "SDCC : ");
for (i = 0; i < NUM_PORTS; i++)
fprintf (stderr, "%s%s", i == 0 ? "" : "/", _ports[i]->target);
-
+
fprintf (stderr, " " SDCC_VERSION_STR
#ifdef SDCC_SUB_VERSION_STR
- "/" SDCC_SUB_VERSION_STR
+ "/" SDCC_SUB_VERSION_STR
#endif
" #%s (" __DATE__ ")"
#ifdef __CYGWIN__
- " (CYGWIN)\n"
+ " (CYGWIN)\n"
#elif defined __MINGW32__
- " (MINGW32)\n"
+ " (MINGW32)\n"
#elif defined __DJGPP__
- " (DJGPP)\n"
+ " (DJGPP)\n"
#elif defined(_MSC_VER)
- " (MSVC)\n"
+ " (MSVC)\n"
#elif defined(__BORLANDC__)
- " (BORLANDC)\n"
+ " (BORLANDC)\n"
#else
- " (UNIX) \n"
+ " (UNIX) \n"
#endif
, getBuildNumber() );
}
printOptions(const OPTION *optionsTable)
{
int i;
- for (i = 0; optionsTable[i].shortOpt != 0 || optionsTable[i].longOpt != NULL; i++)
+ for (i = 0; optionsTable[i].shortOpt != 0 || optionsTable[i].longOpt != NULL; i++)
{
- fprintf(stdout, " %c%c %-20s %s\n",
- optionsTable[i].shortOpt !=0 ? '-' : ' ',
- optionsTable[i].shortOpt !=0 ? optionsTable[i].shortOpt : ' ',
- optionsTable[i].longOpt != NULL ? optionsTable[i].longOpt : "",
- optionsTable[i].help != NULL ? optionsTable[i].help : ""
- );
+ fprintf(stdout, " %c%c %-20s %s\n",
+ optionsTable[i].shortOpt !=0 ? '-' : ' ',
+ optionsTable[i].shortOpt !=0 ? optionsTable[i].shortOpt : ' ',
+ optionsTable[i].longOpt != NULL ? optionsTable[i].longOpt : "",
+ optionsTable[i].help != NULL ? optionsTable[i].help : ""
+ );
}
}
for (i = 0; i < NUM_PORTS; i++)
{
- if (_ports[i]->poptions != NULL)
- {
- fprintf (stdout, "\nSpecial options for the %s port:\n", _ports[i]->target);
- printOptions (_ports[i]->poptions);
- }
+ if (_ports[i]->poptions != NULL)
+ {
+ fprintf (stdout, "\nSpecial options for the %s port:\n", _ports[i]->target);
+ printOptions (_ports[i]->poptions);
+ }
}
exit (0);
/* skip the initial white spaces */
while (isspace(*src))
src++;
-
+
/* skip the trailing white spaces */
length = strlen(src);
while (length && isspace(src[length-1]))
setDefaultOptions (void)
{
/* first the options part */
- options.stack_loc = 0; /* stack pointer initialised to 0 */
- options.xstack_loc = 0; /* xternal stack starts at 0 */
- options.code_loc = 0; /* code starts at 0 */
- options.data_loc = 0; /* JCF: By default let the linker locate data */
+ options.stack_loc = 0; /* stack pointer initialised to 0 */
+ options.xstack_loc = 0; /* xternal stack starts at 0 */
+ options.code_loc = 0; /* code starts at 0 */
+ options.data_loc = 0; /* JCF: By default let the linker locate data */
options.xdata_loc = 0;
options.idata_loc = 0x80;
options.nopeep = 0;
/* source file name : not if we already have a
source file */
if (fullSrcFileName)
- {
- werror (W_TOO_MANY_SRC, s);
- return;
- }
+ {
+ werror (W_TOO_MANY_SRC, s);
+ return;
+ }
/* the only source file */
fullSrcFileName = s;
if (!(srcFile = fopen (fullSrcFileName, "r")))
- {
- werror (E_FILE_OPEN_ERR, s);
- exit (1);
- }
+ {
+ werror (E_FILE_OPEN_ERR, s);
+ exit (1);
+ }
/* copy the file name into the buffer */
strncpyz (buffer, s, sizeof(buffer));
/* do this by going backwards till we
get '\' or ':' or start of buffer */
while (fext != buffer &&
- *(fext - 1) != DIR_SEPARATOR_CHAR &&
- *(fext - 1) != ':')
+ *(fext - 1) != DIR_SEPARATOR_CHAR &&
+ *(fext - 1) != ':')
{
- fext--;
+ fext--;
}
#else
/* do this by going backwards till we
get '/' or start of buffer */
while (fext != buffer &&
- *(fext - 1) != DIR_SEPARATOR_CHAR)
+ *(fext - 1) != DIR_SEPARATOR_CHAR)
{
fext--;
}
#endif
moduleNameBase = Safe_strdup ( fext );
moduleName = Safe_strdup ( fext );
-
+
for (fext = moduleName; *fext; fext++)
if (!isalnum (*fext))
- *fext = '_';
+ *fext = '_';
return;
}
int
getIntArg(const char *szStart, char **argv, int *pi, int argc)
{
- return (int)floatFromVal(constVal(getStringArg(szStart, argv, pi, argc)));
+ return (int)floatFromVal(constVal(getStringArg(szStart, argv, pi, argc)));
}
static void
static bool
tryHandleUnsupportedOpt(char **argv, int *pi)
{
- if (argv[*pi][0] == '-')
+ if (argv[*pi][0] == '-')
{
const char *longOpt = "";
char shortOpt = -1;
int i;
- if (argv[*pi][1] == '-')
+ if (argv[*pi][1] == '-')
{
/* Long option. */
longOpt = argv[*pi];
}
- else
+ else
{
shortOpt = argv[*pi][1];
}
- for (i = 0; i < LENGTH(unsupportedOptTable); i++)
+ for (i = 0; i < LENGTH(unsupportedOptTable); i++)
{
- if (unsupportedOptTable[i].shortOpt == shortOpt ||
+ if (unsupportedOptTable[i].shortOpt == shortOpt ||
(longOpt && unsupportedOptTable[i].longOpt && !strcmp(unsupportedOptTable[i].longOpt, longOpt))) {
/* Found an unsupported opt. */
char buffer[100];
- SNPRINTF(buffer, sizeof(buffer),
- "%s%c%c",
- longOpt ? longOpt : "",
- shortOpt ? '-' : ' ', shortOpt ? shortOpt : ' ');
+ SNPRINTF(buffer, sizeof(buffer),
+ "%s%c%c",
+ longOpt ? longOpt : "",
+ shortOpt ? '-' : ' ', shortOpt ? shortOpt : ' ');
werror (W_UNSUPP_OPTION, buffer, unsupportedOptTable[i].message);
return 1;
}
/* Didn't find in the table */
return 0;
}
- else
+ else
{
/* Not an option, so can't be unsupported :) */
return 0;
for (i = 0; optionsTable[i].shortOpt != 0 || optionsTable[i].longOpt != NULL; i++)
{
if (optionsTable[i].shortOpt == shortOpt ||
- (longOpt && optionsTable[i].longOpt &&
- strcmp(optionsTable[i].longOpt, longOpt) == 0))
- {
-
- /* If it is a flag then we can handle it here */
- if (optionsTable[i].pparameter != NULL)
- {
- if (optionsTable[i].shortOpt == shortOpt)
- {
- verifyShortOption(argv[*pi]);
- }
-
- (*optionsTable[i].pparameter)++;
- return 1;
- }
- else {
- /* Not a flag. Handled manually later. */
- return 0;
- }
- }
+ (longOpt && optionsTable[i].longOpt &&
+ strcmp(optionsTable[i].longOpt, longOpt) == 0))
+ {
+
+ /* If it is a flag then we can handle it here */
+ if (optionsTable[i].pparameter != NULL)
+ {
+ if (optionsTable[i].shortOpt == shortOpt)
+ {
+ verifyShortOption(argv[*pi]);
+ }
+
+ (*optionsTable[i].pparameter)++;
+ return 1;
+ }
+ else {
+ /* Not a flag. Handled manually later. */
+ return 0;
+ }
+ }
}
/* Didn't find in the table */
return 0;
static bool
tryHandleSimpleOpt(char **argv, int *pi)
{
- if (argv[*pi][0] == '-')
+ if (argv[*pi][0] == '-')
{
const char *longOpt = "";
char shortOpt = -1;
- if (argv[*pi][1] == '-')
+ if (argv[*pi][1] == '-')
{
/* Long option. */
longOpt = argv[*pi];
}
- else
+ else
{
shortOpt = argv[*pi][1];
}
- if (scanOptionsTable(optionsTable, shortOpt, longOpt, argv, pi))
- {
- return 1;
- }
- else if (port && port->poptions &&
- scanOptionsTable(port->poptions, shortOpt, longOpt, argv, pi))
- {
- return 1;
- }
- else
- {
- return 0;
- }
+ if (scanOptionsTable(optionsTable, shortOpt, longOpt, argv, pi))
+ {
+ return 1;
+ }
+ else if (port && port->poptions &&
+ scanOptionsTable(port->poptions, shortOpt, longOpt, argv, pi))
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
}
- else
+ else
{
/* Not an option, so can't be handled. */
return 0;
for (i = 1; i < argc; i++)
{
if (i >= argc)
- break;
+ break;
- if (tryHandleUnsupportedOpt(argv, &i) == TRUE)
- {
- continue;
- }
+ if (tryHandleUnsupportedOpt(argv, &i) == TRUE)
+ {
+ continue;
+ }
if (tryHandleSimpleOpt(argv, &i) == TRUE)
- {
- continue;
- }
+ {
+ continue;
+ }
/* options */
if (argv[i][0] == '-' && argv[i][1] == '-')
- {
- if (strcmp (argv[i], OPTION_HELP) == 0)
- {
- printUsage ();
- exit (0);
- }
-
- if (strcmp (argv[i], OPTION_STACK_8BIT) == 0)
- {
- options.stack10bit = 0;
- continue;
- }
-
- if (strcmp (argv[i], OPTION_OUT_FMT_IHX) == 0)
- {
- options.out_fmt = 0;
- continue;
- }
-
- if (strcmp (argv[i], OPTION_LARGE_MODEL) == 0)
- {
- _setModel (MODEL_LARGE, argv[i]);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_MEDIUM_MODEL) == 0)
- {
- _setModel (MODEL_MEDIUM, argv[i]);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_SMALL_MODEL) == 0)
- {
- _setModel (MODEL_SMALL, argv[i]);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_FLAT24_MODEL) == 0)
- {
- _setModel (MODEL_FLAT24, argv[i]);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_DUMP_ALL) == 0)
- {
- options.dump_rassgn =
- options.dump_pack =
- options.dump_range =
- options.dump_kill =
- options.dump_loop =
- options.dump_gcse =
- options.dump_raw = 1;
- continue;
- }
-
- if (strcmp (argv[i], OPTION_PEEP_FILE) == 0)
- {
- options.peep_file = getStringArg(OPTION_PEEP_FILE, argv, &i, argc);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_LIB_PATH) == 0)
+ {
+ if (strcmp (argv[i], OPTION_HELP) == 0)
+ {
+ printUsage ();
+ exit (0);
+ }
+
+ if (strcmp (argv[i], OPTION_STACK_8BIT) == 0)
+ {
+ options.stack10bit = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_OUT_FMT_IHX) == 0)
+ {
+ options.out_fmt = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_LARGE_MODEL) == 0)
+ {
+ _setModel (MODEL_LARGE, argv[i]);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_MEDIUM_MODEL) == 0)
{
- addSet(&libPathsSet, Safe_strdup(getStringArg(OPTION_LIB_PATH, argv, &i, argc)));
- continue;
- }
+ _setModel (MODEL_MEDIUM, argv[i]);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_SMALL_MODEL) == 0)
+ {
+ _setModel (MODEL_SMALL, argv[i]);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_FLAT24_MODEL) == 0)
+ {
+ _setModel (MODEL_FLAT24, argv[i]);
+ continue;
+ }
- if (strcmp (argv[i], OPTION_VERSION) == 0)
- {
- printVersionInfo ();
+ if (strcmp (argv[i], OPTION_DUMP_ALL) == 0)
+ {
+ options.dump_rassgn =
+ options.dump_pack =
+ options.dump_range =
+ options.dump_kill =
+ options.dump_loop =
+ options.dump_gcse =
+ options.dump_raw = 1;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_PEEP_FILE) == 0)
+ {
+ options.peep_file = getStringArg(OPTION_PEEP_FILE, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_LIB_PATH) == 0)
+ {
+ addSet(&libPathsSet, Safe_strdup(getStringArg(OPTION_LIB_PATH, argv, &i, argc)));
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_VERSION) == 0)
+ {
+ printVersionInfo ();
exit (0);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_CALLEE_SAVES) == 0)
- {
- setParseWithComma(&options.calleeSavesSet, getStringArg(OPTION_CALLEE_SAVES, argv, &i, argc));
- continue;
- }
-
- if (strcmp (argv[i], OPTION_XSTACK_LOC) == 0)
- {
- options.xstack_loc = getIntArg(OPTION_XSTACK_LOC, argv, &i, argc);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_STACK_LOC) == 0)
- {
- options.stack_loc = getIntArg(OPTION_STACK_LOC, argv, &i, argc);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_STACK_SIZE) == 0)
- {
- options.stack_size = getIntArg(OPTION_STACK_SIZE, argv, &i, argc);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_XRAM_LOC) == 0)
- {
- options.xdata_loc = getIntArg(OPTION_XRAM_LOC, argv, &i, argc);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_IRAM_SIZE) == 0)
- {
- options.iram_size = getIntArg(OPTION_IRAM_SIZE, argv, &i, argc);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_XRAM_SIZE) == 0)
- {
- options.xram_size = getIntArg(OPTION_IRAM_SIZE, argv, &i, argc);
- options.xram_size_set = TRUE;
- continue;
- }
-
- if (strcmp (argv[i], OPTION_CODE_SIZE) == 0)
- {
- options.code_size = getIntArg(OPTION_IRAM_SIZE, argv, &i, argc);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_DATA_LOC) == 0)
- {
- options.data_loc = getIntArg(OPTION_DATA_LOC, argv, &i, argc);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_IDATA_LOC) == 0)
- {
- options.idata_loc = getIntArg(OPTION_IDATA_LOC, argv, &i, argc);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_CODE_LOC) == 0)
- {
- options.code_loc = getIntArg(OPTION_CODE_LOC, argv, &i, argc);
- continue;
- }
-
- if (strcmp (argv[i], OPTION_NO_GCSE) == 0)
- {
- optimize.global_cse = 0;
- continue;
- }
-
- if (strcmp (argv[i], OPTION_NO_LOOP_INV) == 0)
- {
- optimize.loopInvariant = 0;
- continue;
- }
-
- if (strcmp (argv[i], OPTION_NO_LABEL_OPT) == 0)
- {
- optimize.label4 = 0;
- continue;
- }
-
- if (strcmp (argv[i], OPTION_NO_LOOP_IND) == 0)
- {
- optimize.loopInduction = 0;
- continue;
- }
-
- if (strcmp (argv[i], OPTION_LESS_PEDANTIC) == 0)
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_CALLEE_SAVES) == 0)
+ {
+ setParseWithComma(&options.calleeSavesSet, getStringArg(OPTION_CALLEE_SAVES, argv, &i, argc));
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_XSTACK_LOC) == 0)
{
- options.lessPedantic = 1;
+ options.xstack_loc = getIntArg(OPTION_XSTACK_LOC, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_STACK_LOC) == 0)
+ {
+ options.stack_loc = getIntArg(OPTION_STACK_LOC, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_STACK_SIZE) == 0)
+ {
+ options.stack_size = getIntArg(OPTION_STACK_SIZE, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_XRAM_LOC) == 0)
+ {
+ options.xdata_loc = getIntArg(OPTION_XRAM_LOC, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_IRAM_SIZE) == 0)
+ {
+ options.iram_size = getIntArg(OPTION_IRAM_SIZE, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_XRAM_SIZE) == 0)
+ {
+ options.xram_size = getIntArg(OPTION_IRAM_SIZE, argv, &i, argc);
+ options.xram_size_set = TRUE;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_CODE_SIZE) == 0)
+ {
+ options.code_size = getIntArg(OPTION_IRAM_SIZE, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_DATA_LOC) == 0)
+ {
+ options.data_loc = getIntArg(OPTION_DATA_LOC, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_IDATA_LOC) == 0)
+ {
+ options.idata_loc = getIntArg(OPTION_IDATA_LOC, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_CODE_LOC) == 0)
+ {
+ options.code_loc = getIntArg(OPTION_CODE_LOC, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_NO_GCSE) == 0)
+ {
+ optimize.global_cse = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_NO_LOOP_INV) == 0)
+ {
+ optimize.loopInvariant = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_NO_LABEL_OPT) == 0)
+ {
+ optimize.label4 = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_NO_LOOP_IND) == 0)
+ {
+ optimize.loopInduction = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_LESS_PEDANTIC) == 0)
+ {
+ options.lessPedantic = 1;
setErrorLogLevel(ERROR_LEVEL_WARNING);
continue;
}
- if (strcmp (&argv[i][1], OPTION_SHORT_IS_8BITS) == 0)
+ if (strcmp (argv[i], OPTION_DISABLE_WARNING) == 0)
+ {
+ int w = getIntArg(OPTION_DISABLE_WARNING, argv, &i, argc);
+ if (w < MAX_ERROR_WARNING)
+ {
+ setWarningDisabled(w);
+ }
+ continue;
+ }
+
+ if (strcmp (&argv[i][1], OPTION_SHORT_IS_8BITS) == 0)
{
options.shortis8bits=1;
continue;
}
- if (strcmp (argv[i], OPTION_TINI_LIBID) == 0)
- {
- options.tini_libid = getIntArg(OPTION_TINI_LIBID, argv, &i, argc);
- continue;
- }
-
- if (!port->parseOption (&argc, argv, &i))
- {
- werror (W_UNKNOWN_OPTION, argv[i]);
- continue;
- }
- else
- {
- continue;
- }
- }
+ if (strcmp (argv[i], OPTION_TINI_LIBID) == 0)
+ {
+ options.tini_libid = getIntArg(OPTION_TINI_LIBID, argv, &i, argc);
+ continue;
+ }
+
+ if (!port->parseOption (&argc, argv, &i))
+ {
+ werror (W_UNKNOWN_OPTION, argv[i]);
+ continue;
+ }
+ else
+ {
+ continue;
+ }
+ }
/* if preceded by '-' then option */
if (*argv[i] == '-')
- {
- switch (argv[i][1])
- {
- case 'h':
+ {
+ switch (argv[i][1])
+ {
+ case 'h':
verifyShortOption(argv[i]);
- printUsage ();
- exit (0);
- break;
+ printUsage ();
+ exit (0);
+ break;
- case 'm':
- /* Used to select the port. But this has already been done. */
- break;
+ case 'm':
+ /* Used to select the port. But this has already been done. */
+ break;
- case 'p':
- /* Used to select the processor in port. But this has
- * already been done. */
- break;
+ case 'p':
+ /* Used to select the processor in port. But this has
+ * already been done. */
+ break;
- case 'c':
+ case 'c':
verifyShortOption(argv[i]);
- options.cc_only = 1;
- break;
+ options.cc_only = 1;
+ break;
- case 'L':
+ case 'L':
addSet(&libPathsSet, Safe_strdup(getStringArg("-L", argv, &i, argc)));
break;
case 'l':
addSet(&libFilesSet, Safe_strdup(getStringArg("-l", argv, &i, argc)));
break;
-
+
case 'o':
{
char *p;
/* copy the file name into the buffer */
- strncpyz(buffer, getStringArg("-o", argv, &i, argc),
- sizeof(buffer));
+ strncpyz(buffer, getStringArg("-o", argv, &i, argc),
+ sizeof(buffer));
/* point to last character */
p = buffer + strlen (buffer) - 1;
if (*p == DIR_SEPARATOR_CHAR)
break;
}
- case 'W':
+ case 'W':
/* pre-processer options */
if (argv[i][2] == 'p')
{
setParseWithComma(&preArgvSet, getStringArg("-Wp", argv, &i, argc));
}
- /* linker options */
- else if (argv[i][2] == 'l')
- {
+ /* linker options */
+ else if (argv[i][2] == 'l')
+ {
setParseWithComma(&linkOptionsSet, getStringArg("-Wl", argv, &i, argc));
- }
+ }
/* assembler options */
- else if (argv[i][2] == 'a')
+ else if (argv[i][2] == 'a')
{
setParseWithComma(&asmOptionsSet, getStringArg("-Wa", argv, &i, argc));
}
{
werror (W_UNKNOWN_OPTION, argv[i]);
}
- break;
+ break;
- case 'v':
+ case 'v':
verifyShortOption(argv[i]);
- printVersionInfo ();
- exit (0);
- break;
+ printVersionInfo ();
+ exit (0);
+ break;
- /* preprocessor options */
- case 'M':
- {
- preProcOnly = 1;
+ /* preprocessor options */
+ case 'M':
+ {
+ preProcOnly = 1;
if (argv[i][2] == 'M')
- addSet(&preArgvSet, Safe_strdup("-MM"));
+ addSet(&preArgvSet, Safe_strdup("-MM"));
else
- addSet(&preArgvSet, Safe_strdup("-M"));
- break;
- }
- case 'C':
- {
- addSet(&preArgvSet, Safe_strdup("-C"));
- break;
- }
-
- case 'd':
- case 'D':
- case 'I':
- case 'A':
- case 'U':
- {
- char sOpt = argv[i][1];
- char *rest;
-
- if (argv[i][2] == ' ' || argv[i][2] == '\0')
- {
- i++;
+ addSet(&preArgvSet, Safe_strdup("-M"));
+ break;
+ }
+ case 'C':
+ {
+ addSet(&preArgvSet, Safe_strdup("-C"));
+ break;
+ }
+
+ case 'd':
+ case 'D':
+ case 'I':
+ case 'A':
+ case 'U':
+ {
+ char sOpt = argv[i][1];
+ char *rest;
+
+ if (argv[i][2] == ' ' || argv[i][2] == '\0')
+ {
+ i++;
if (i >= argc)
{
- /* No argument. */
- werror(E_ARGUMENT_MISSING, argv[i-1]);
- break;
+ /* No argument. */
+ werror(E_ARGUMENT_MISSING, argv[i-1]);
+ break;
}
else
{
- rest = argv[i];
+ rest = argv[i];
}
- }
- else
- rest = &argv[i][2];
+ }
+ else
+ rest = &argv[i][2];
- if (sOpt == 'Y')
- sOpt = 'I';
+ if (sOpt == 'Y')
+ sOpt = 'I';
SNPRINTF (buffer, sizeof(buffer),
((sOpt == 'I') ? "-%c\"%s\"": "-%c%s"), sOpt, rest);
- addSet(&preArgvSet, Safe_strdup(buffer));
- if(sOpt == 'I')addSet(&includeDirsSet, Safe_strdup(rest));
- }
- break;
-
- default:
- if (!port->parseOption (&argc, argv, &i))
- werror (W_UNKNOWN_OPTION, argv[i]);
- }
- continue;
- }
+ addSet(&preArgvSet, Safe_strdup(buffer));
+ if(sOpt == 'I')addSet(&includeDirsSet, Safe_strdup(rest));
+ }
+ break;
+
+ default:
+ if (!port->parseOption (&argc, argv, &i))
+ werror (W_UNKNOWN_OPTION, argv[i]);
+ }
+ continue;
+ }
if (!port->parseOption (&argc, argv, &i))
- {
- /* no option must be a filename */
- if (options.c1mode)
- {
- werror (W_NO_FILE_ARG_IN_C1, argv[i]);
- }
- else
- {
- processFile (argv[i]);
- }
- }
+ {
+ /* no option must be a filename */
+ if (options.c1mode)
+ {
+ werror (W_NO_FILE_ARG_IN_C1, argv[i]);
+ }
+ else
+ {
+ processFile (argv[i]);
+ }
+ }
}
/* some sanity checks in c1 mode */
const char *s;
if (fullSrcFileName)
- {
- fclose (srcFile);
- werror (W_NO_FILE_ARG_IN_C1, fullSrcFileName);
- }
+ {
+ fclose (srcFile);
+ werror (W_NO_FILE_ARG_IN_C1, fullSrcFileName);
+ }
fullSrcFileName = NULL;
for (s = setFirstItem(relFilesSet); s != NULL; s = setNextItem(relFilesSet))
- {
- werror (W_NO_FILE_ARG_IN_C1, s);
- }
+ {
+ werror (W_NO_FILE_ARG_IN_C1, s);
+ }
for (s = setFirstItem(libFilesSet); s != NULL; s = setNextItem(libFilesSet))
- {
- werror (W_NO_FILE_ARG_IN_C1, s);
- }
+ {
+ werror (W_NO_FILE_ARG_IN_C1, s);
+ }
deleteSet(&relFilesSet);
deleteSet(&libFilesSet);
- if (options.cc_only || noAssemble || preProcOnly)
- {
- werror (W_ILLEGAL_OPT_COMBINATION);
- }
+ if (options.cc_only || noAssemble || preProcOnly)
+ {
+ werror (W_ILLEGAL_OPT_COMBINATION);
+ }
options.cc_only = noAssemble = preProcOnly = 0;
if (!dstFileName)
- {
- werror (E_NEED_OPT_O_IN_C1);
- exit (1);
- }
+ {
+ werror (E_NEED_OPT_O_IN_C1);
+ exit (1);
+ }
}
/* if no dstFileName given with -o, we've to find one: */
if (!dstFileName)
/* use the modulename from the C-source */
if (fullSrcFileName)
{
- size_t bufSize = strlen (dstPath) + strlen (moduleNameBase) + 1;
+ size_t bufSize = strlen (dstPath) + strlen (moduleNameBase) + 1;
- dstFileName = Safe_alloc (bufSize);
+ dstFileName = Safe_alloc (bufSize);
strncpyz (dstFileName, dstPath, bufSize);
strncatz (dstFileName, moduleNameBase, bufSize);
}
else if ((s = peekSet(relFilesSet)) != NULL)
{
char *objectName;
- size_t bufSize;
+ size_t bufSize;
strncpyz (buffer, s, sizeof(buffer));
/* remove extension (it must be .rel) */
{
objectName = buffer;
}
- bufSize = strlen (dstPath) + strlen (objectName) + 1;
+ bufSize = strlen (dstPath) + strlen (objectName) + 1;
dstFileName = Safe_alloc (bufSize);
strncpyz (dstFileName, dstPath, bufSize);
strncatz (dstFileName, objectName, bufSize);
if (options.debug && fullSrcFileName)
{
SNPRINTF (scratchFileName, sizeof(scratchFileName),
- "%s.adb", dstFileName); /*JCF: Nov 30, 2002*/
+ "%s.adb", dstFileName); /*JCF: Nov 30, 2002*/
if(debugFile->openFile(scratchFileName))
- debugFile->writeModule(moduleName);
+ debugFile->writeModule(moduleName);
else
- werror (E_FILE_OPEN_ERR, scratchFileName);
+ werror (E_FILE_OPEN_ERR, scratchFileName);
}
MSVC_style(options.vc_err_style);
if(options.use_stdout) dup2(STDOUT_FILENO, STDERR_FILENO);
if(port->linker.needLinkerScript)
{
char out_fmt;
-
+
switch (options.out_fmt)
{
- case 0:
- out_fmt = 'i'; /* Intel hex */
- break;
- case 1:
- out_fmt = 's'; /* Motorola S19 */
- break;
- case 2:
- out_fmt = 't'; /* Elf */
- break;
- default:
- out_fmt = 'i';
- }
-
+ case 0:
+ out_fmt = 'i'; /* Intel hex */
+ break;
+ case 1:
+ out_fmt = 's'; /* Motorola S19 */
+ break;
+ case 2:
+ out_fmt = 't'; /* Elf */
+ break;
+ default:
+ out_fmt = 'i';
+ }
+
/* first we need to create the <filename>.lnk file */
SNPRINTF (scratchFileName, sizeof(scratchFileName),
"%s.lnk", dstFileName);
WRITE_SEG_LOC ("_CODE", options.code_loc);
WRITE_SEG_LOC ("_DATA", options.data_loc);
}
-
+
/* If the port has any special linker area declarations, get 'em */
if (port->extraAreas.genExtraAreaLinkOptions)
{
}
else
{
- fprintf(stderr,
+ fprintf(stderr,
"Add support for your FLAT24 target in %s @ line %d\n",
__FILE__, __LINE__);
exit(-1);
}
else
{
- fprintf(stderr,
+ fprintf(stderr,
"Add support for your FLAT24 target in %s @ line %d\n",
__FILE__, __LINE__);
exit(-1);
}
#endif
-#if !OPT_DISABLE_XA51
+#if !OPT_DISABLE_XA51
#ifdef STD_XA51_LIB
if (options.model == MODEL_PAGE0)
{
#endif
#endif
if (TARGET_IS_MCS51)
- {
+ {
fprintf (lnkfile, "-l mcs51\n");
- }
- if (!(TARGET_IS_Z80 || TARGET_IS_GBZ80
+ }
+ if (!(TARGET_IS_Z80 || TARGET_IS_GBZ80
|| TARGET_IS_HC08)) /*Not for the z80, gbz80*/
{ /*Why the z80 port is not using the standard libraries?*/
fprintf (lnkfile, "-l %s\n", STD_LIB);
/* strip ".rel" extension */
*strrchr (scratchFileName, '.') = '\0';
}
- strncatz (scratchFileName,
+ strncatz (scratchFileName,
options.out_fmt ? ".S19" : ".ihx",
sizeof(scratchFileName));
}
strcpy(buffer3, dstFileName);
if(TARGET_IS_PIC16) {
-
+
/* use $l to set the linker include directories */
tempSet = appendStrSet(libDirsSet, "-I\"", "\"");
mergeSets(&linkOptionsSet, tempSet);
-
+
tempSet = appendStrSet(libPathsSet, "-I\"", "\"");
mergeSets(&linkOptionsSet, tempSet);
mergeSets(&libSet, tempSet);
// libSet = reverseSet(libSet);
- if(fullSrcFileName) {
-// strcpy(buffer3, strrchr(fullSrcFileName, DIR_SEPARATOR_CHAR)+1);
- /* if it didn't work, revert to old behaviour */
- if(!strlen(buffer3))strcpy(buffer3, dstFileName);
- strcat(buffer3, port->linker.rel_ext);
-
- } else strcpy(buffer3, "");
+ if(fullSrcFileName) {
+// strcpy(buffer3, strrchr(fullSrcFileName, DIR_SEPARATOR_CHAR)+1);
+ /* if it didn't work, revert to old behaviour */
+ if(!strlen(buffer3))strcpy(buffer3, dstFileName);
+ strcat(buffer3, port->linker.rel_ext);
+
+ } else strcpy(buffer3, "");
}
-
+
buildCmdLine (buffer2, port->linker.cmd, buffer3, scratchFileName, (libSet?joinStrSet(libSet):NULL), linkOptionsSet);
buildCmdLine2 (buffer, sizeof(buffer), buffer2);
} else {
/* the assembled file gets the name of the first modul */
strncpyz (scratchFileName, dstFileName, sizeof(scratchFileName));
- strncatz (scratchFileName, port->linker.rel_ext,
- sizeof(scratchFileName));
+ strncatz (scratchFileName, port->linker.rel_ext,
+ sizeof(scratchFileName));
}
if (port->assembler.do_assemble) {
- port->assembler.do_assemble(asmOptionsSet);
- return ;
+ port->assembler.do_assemble(asmOptionsSet);
+ return ;
} else if (port->assembler.cmd) {
buildCmdLine (buffer, port->assembler.cmd, dstFileName, scratchFileName,
- options.debug ? port->assembler.debug_opts : port->assembler.plain_opts,
- asmOptionsSet);
+ options.debug ? port->assembler.debug_opts : port->assembler.plain_opts,
+ asmOptionsSet);
} else {
- buildCmdLine2 (buffer, sizeof(buffer), port->assembler.mcmd);
+ buildCmdLine2 (buffer, sizeof(buffer), port->assembler.mcmd);
}
if (my_system (buffer)) {
- /* either system() or the assembler itself has reported an error
- perror ("Cannot exec assembler");
- */
- exit (1);
+ /* either system() or the assembler itself has reported an error
+ perror ("Cannot exec assembler");
+ */
+ exit (1);
}
/* TODO: most assembler don't have a -o parameter */
/* -o option overrides default name? */
if (options.cc_only && fullDstFileName) {
strncpyz (scratchFileName, dstFileName, sizeof(scratchFileName));
- strncatz (scratchFileName,
- port->linker.rel_ext,
- sizeof(scratchFileName));
+ strncatz (scratchFileName,
+ port->linker.rel_ext,
+ sizeof(scratchFileName));
if (strcmp (scratchFileName, fullDstFileName))
unlink (fullDstFileName);
rename (scratchFileName, fullDstFileName);
/* if using external stack define the macro */
if (options.useXstack)
- addSet(&preArgvSet, Safe_strdup("-DSDCC_USE_XSTACK"));
+ addSet(&preArgvSet, Safe_strdup("-DSDCC_USE_XSTACK"));
/* set the macro for stack autos */
if (options.stackAuto)
- addSet(&preArgvSet, Safe_strdup("-DSDCC_STACK_AUTO"));
+ addSet(&preArgvSet, Safe_strdup("-DSDCC_STACK_AUTO"));
/* set the macro for stack autos */
if (options.stack10bit)
- addSet(&preArgvSet, Safe_strdup("-DSDCC_STACK_TENBIT"));
+ addSet(&preArgvSet, Safe_strdup("-DSDCC_STACK_TENBIT"));
/* set the macro for no overlay */
if (options.noOverlay)
/* set the macro for large model */
switch (options.model)
- {
- case MODEL_LARGE:
- addSet(&preArgvSet, Safe_strdup("-DSDCC_MODEL_LARGE"));
- break;
- case MODEL_SMALL:
- addSet(&preArgvSet, Safe_strdup("-DSDCC_MODEL_SMALL"));
- break;
- case MODEL_COMPACT:
- addSet(&preArgvSet, Safe_strdup("-DSDCC_MODEL_COMPACT"));
- break;
- case MODEL_MEDIUM:
- addSet(&preArgvSet, Safe_strdup("-DSDCC_MODEL_MEDIUM"));
- break;
- case MODEL_FLAT24:
- addSet(&preArgvSet, Safe_strdup("-DSDCC_MODEL_FLAT24"));
- break;
- case MODEL_PAGE0:
- addSet(&preArgvSet, Safe_strdup("-DSDCC_MODEL_PAGE0"));
- break;
- default:
- werror (W_UNKNOWN_MODEL, __FILE__, __LINE__);
- break;
- }
+ {
+ case MODEL_LARGE:
+ addSet(&preArgvSet, Safe_strdup("-DSDCC_MODEL_LARGE"));
+ break;
+ case MODEL_SMALL:
+ addSet(&preArgvSet, Safe_strdup("-DSDCC_MODEL_SMALL"));
+ break;
+ case MODEL_COMPACT:
+ addSet(&preArgvSet, Safe_strdup("-DSDCC_MODEL_COMPACT"));
+ break;
+ case MODEL_MEDIUM:
+ addSet(&preArgvSet, Safe_strdup("-DSDCC_MODEL_MEDIUM"));
+ break;
+ case MODEL_FLAT24:
+ addSet(&preArgvSet, Safe_strdup("-DSDCC_MODEL_FLAT24"));
+ break;
+ case MODEL_PAGE0:
+ addSet(&preArgvSet, Safe_strdup("-DSDCC_MODEL_PAGE0"));
+ break;
+ default:
+ werror (W_UNKNOWN_MODEL, __FILE__, __LINE__);
+ break;
+ }
/* add port (processor information to processor */
addSet(&preArgvSet, Safe_strdup("-DSDCC_{port}"));
deleteSet(&inclList);
if (preProcOnly && fullDstFileName)
- {
- /* -E and -o given */
- setMainValue ("cppoutfilename", fullDstFileName);
- }
+ {
+ /* -E and -o given */
+ setMainValue ("cppoutfilename", fullDstFileName);
+ }
else
- {
- /* Piping: set cppoutfilename to NULL, to avoid empty quotes */
- setMainValue ("cppoutfilename", NULL);
- }
+ {
+ /* Piping: set cppoutfilename to NULL, to avoid empty quotes */
+ setMainValue ("cppoutfilename", NULL);
+ }
if (options.verbose)
- printf ("sdcc: Calling preprocessor...\n");
+ printf ("sdcc: Calling preprocessor...\n");
buildCmdLine2 (buffer, sizeof(buffer), _preCmd);
if (preProcOnly) {
if (my_system (buffer)) {
- exit (1);
- }
+ exit (1);
+ }
exit (0);
}
#ifdef JAMIN_DS390
if (strcmp(port->target, "mcs51") == 0) {
printf("DS390 jammed in A\n");
- _setPort ("ds390");
+ _setPort ("ds390");
ds390_jammed = 1;
}
#endif
setDataPaths(argv[0]);
if(port->initPaths)
- port->initPaths();
-
+ port->initPaths();
+
if(options.printSearchDirs)
- doPrintSearchDirs();
+ doPrintSearchDirs();
/* if no input then printUsage & exit */
if (!options.c1mode && !fullSrcFileName && peekSet(relFilesSet) == NULL) {
initPeepHole ();
if (options.verbose)
- printf ("sdcc: Generating code...\n");
+ printf ("sdcc: Generating code...\n");
yyparse ();
(fullSrcFileName || peekSet(relFilesSet) != NULL))
{
if (port->linker.do_link)
- port->linker.do_link ();
+ port->linker.do_link ();
else
- linkEdit (envp);
+ linkEdit (envp);
}
return 0;
/* emitcode - writes the code into a file : for now it is simple */
/*-----------------------------------------------------------------*/
static void
-emitcode (char *inst, char *fmt,...)
+emitcode (char *inst, const char *fmt,...)
{
- va_list ap;
- char lb[INITIAL_INLINEASM];
- char *lbp = lb;
+ va_list ap;
+ char lb[INITIAL_INLINEASM];
+ char *lbp = lb;
- va_start (ap, fmt);
+ va_start (ap, fmt);
- if (inst && *inst)
+ if (inst && *inst)
{
- if (fmt && *fmt)
+ if (fmt && *fmt)
{
- SNPRINTF (lb, sizeof(lb), "%s\t", inst);
+ SNPRINTF (lb, sizeof(lb), "%s\t", inst);
}
- else
+ else
{
- SNPRINTF (lb, sizeof(lb), "%s", inst);
+ SNPRINTF (lb, sizeof(lb), "%s", inst);
}
- tvsprintf (lb + strlen(lb), sizeof(lb) - strlen(lb),
- fmt, ap);
+ tvsprintf (lb + strlen(lb), sizeof(lb) - strlen(lb), fmt, ap);
}
- else
+ else
{
- tvsprintf (lb, sizeof(lb), fmt, ap);
+ tvsprintf (lb, sizeof(lb), fmt, ap);
}
-
- while (isspace (*lbp))
+ while (isspace (*lbp))
{
- lbp++;
+ lbp++;
}
- if (lbp && *lbp)
+ if (lbp && *lbp)
{
- lineCurr = (lineCurr ?
- connectLine (lineCurr, newLineNode (lb)) :
- (lineHead = newLineNode (lb)));
+ lineCurr = (lineCurr ?
+ connectLine (lineCurr, newLineNode (lb)) :
+ (lineHead = newLineNode (lb)));
}
- lineCurr->isInline = _G.inLine;
- lineCurr->isDebug = _G.debugLine;
- lineCurr->ic = _G.current_iCode;
- lineCurr->aln = ds390newAsmLineNode(_currentDPS);
- va_end (ap);
+ lineCurr->isInline = _G.inLine;
+ lineCurr->isDebug = _G.debugLine;
+ lineCurr->ic = _G.current_iCode;
+ lineCurr->aln = ds390newAsmLineNode(_currentDPS);
+ va_end (ap);
}
/*-----------------------------------------------------------------*/
{
iCode *ic = sym->rematiCode;
asmop *aop = newAsmop (AOP_IMMD);
- int ptr_type =0;
+ int ptr_type = 0;
int val = 0;
for (;;)
&& strcmp (sym1->rname, sym2->rname) == 0)
return TRUE;
-
/* if left is a tmp & right is not */
if (IS_ITEMP (op1) &&
!IS_ITEMP (op2) &&
sym = OP_SYMBOL (op);
-
/* if the type is a conditional */
if (sym->regType == REG_CND)
{
if (aop)
{
- freeAsmop (NULL, aop, ic, TRUE);
+ freeAsmop (NULL, aop, ic, TRUE);
}
if (ic)
{
- ic->bankSaved = 1;
+ ic->bankSaved = 1;
}
}
if (AOP_TYPE (IC_RESULT (ic)) == AOP_REG ||
IS_AOP_PREG (IC_RESULT (ic)))
- {
- emitcode ("cjne", "%s,#0,!tlabel", l, tlbl->key + 100);
- }
+ {
+ emitcode ("cjne", "%s,#0,!tlabel", l, tlbl->key + 100);
+ }
else
- {
+ {
emitcode ("clr", "a");
emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
- }
+ }
l = aopGet (AOP (IC_RESULT (ic)), MSB16, FALSE, FALSE, NULL);
emitcode ("inc", "%s", l);
if (size > 2)
{
- if (!strcmp(l, "acc"))
+ if (!strcmp(l, "acc"))
{
emitcode("jnz", "!tlabel", tlbl->key + 100);
}
- else if (AOP_TYPE (IC_RESULT (ic)) == AOP_REG ||
- IS_AOP_PREG (IC_RESULT (ic)))
+ else if (AOP_TYPE (IC_RESULT (ic)) == AOP_REG ||
+ IS_AOP_PREG (IC_RESULT (ic)))
{
emitcode ("cjne", "%s,#0,!tlabel", l, tlbl->key + 100);
}
- else
+ else
{
emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
}
- l = aopGet (AOP (IC_RESULT (ic)), MSB24, FALSE, FALSE, NULL);
- emitcode ("inc", "%s", l);
+ l = aopGet (AOP (IC_RESULT (ic)), MSB24, FALSE, FALSE, NULL);
+ emitcode ("inc", "%s", l);
}
if (size > 3)
{
- if (!strcmp(l, "acc"))
+ if (!strcmp(l, "acc"))
{
emitcode("jnz", "!tlabel", tlbl->key + 100);
}
- else if (AOP_TYPE (IC_RESULT (ic)) == AOP_REG ||
- IS_AOP_PREG (IC_RESULT (ic)))
+ else if (AOP_TYPE (IC_RESULT (ic)) == AOP_REG ||
+ IS_AOP_PREG (IC_RESULT (ic)))
{
emitcode ("cjne", "%s,#0,!tlabel", l, tlbl->key + 100);
}
- else
+ else
{
emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
}
- l = aopGet (AOP (IC_RESULT (ic)), MSB32, FALSE, FALSE, NULL);
- emitcode ("inc", "%s", l); }
+ l = aopGet (AOP (IC_RESULT (ic)), MSB32, FALSE, FALSE, NULL);
+ emitcode ("inc", "%s", l);
+ }
if (emitTlbl)
{
if (AOP_TYPE(IC_RESULT(ic))==AOP_STR && IS_ITEMP(IC_RESULT(ic)) &&
!AOP_USESDPTR(IC_LEFT(ic)) && icount <= 5 && size <= 3 &&
- options.model == MODEL_FLAT24 ) {
-
+ options.model == MODEL_FLAT24 )
+ {
+ if (IC_RESULT(ic)->isGptr)
+ {
+ emitcode ("mov","b,%s",aopGet(AOP (IC_LEFT (ic)), 3, FALSE, FALSE, NULL));
+ }
switch (size) {
case 3:
emitcode ("mov","dpx,%s",aopGet(AOP (IC_LEFT (ic)), 2, FALSE, FALSE, NULL));
then we do nothing else we move the value to dptr */
if (AOP_TYPE (left) != AOP_STR)
{
- /* if this is remateriazable */
+ /* if this is rematerializable */
if (AOP_TYPE (left) == AOP_IMMD)
{
emitcode ("mov", "dptr,%s", aopGet (AOP (left), 0, TRUE, FALSE, NULL));
if (AOP(left)->aopu.aop_immd.from_cast_remat)
{
- MOVB(aopGet(AOP (left), AOP_SIZE(left)-1, FALSE, FALSE, NULL));
+ MOVB(aopGet(AOP (left), AOP_SIZE(left)-1, FALSE, FALSE, NULL));
}
- else
+ else
{
- emitcode ("mov", "b,#%d", pointerCode (retype));
+ emitcode ("mov", "b,#%d", pointerCode (retype));
}
}
else
{ /* we need to get it byte by byte */
- _startLazyDPSEvaluation ();
- emitcode ("mov", "dpl,%s", aopGet (AOP(left),0,FALSE,FALSE,NULL));
- emitcode ("mov", "dph,%s", aopGet (AOP(left),1,FALSE,FALSE,NULL));
- if (options.model == MODEL_FLAT24) {
- emitcode ("mov", "dpx,%s", aopGet (AOP(left),2,FALSE,FALSE,NULL));
- emitcode ("mov", "b,%s", aopGet (AOP(left),3,FALSE,FALSE,NULL));
- } else {
- emitcode ("mov", "b,%s", aopGet (AOP(left),2,FALSE,FALSE,NULL));
- }
- _endLazyDPSEvaluation ();
+ _startLazyDPSEvaluation ();
+ emitcode ("mov", "dpl,%s", aopGet (AOP(left),0,FALSE,FALSE,NULL));
+ emitcode ("mov", "dph,%s", aopGet (AOP(left),1,FALSE,FALSE,NULL));
+ if (options.model == MODEL_FLAT24) {
+ emitcode ("mov", "dpx,%s", aopGet (AOP(left),2,FALSE,FALSE,NULL));
+ emitcode ("mov", "b,%s", aopGet (AOP(left),3,FALSE,FALSE,NULL));
+ } else {
+ emitcode ("mov", "b,%s", aopGet (AOP(left),2,FALSE,FALSE,NULL));
+ }
+ _endLazyDPSEvaluation ();
}
}
}
/* special case when cast remat */
if (p_type == GPOINTER && OP_SYMBOL(left)->remat &&
- IS_CAST_ICODE(OP_SYMBOL(left)->rematiCode)) {
- left = IC_RIGHT(OP_SYMBOL(left)->rematiCode);
- type = operandType (left);
- p_type = DCL_TYPE (type);
- }
+ IS_CAST_ICODE(OP_SYMBOL(left)->rematiCode))
+ {
+ left = IC_RIGHT(OP_SYMBOL(left)->rematiCode);
+ type = operandType (left);
+ p_type = DCL_TYPE (type);
+ }
/* now that we have the pointer type we assign
the pointer values */
switch (p_type)
for (ic = lic; ic; ic = ic->next)
{
-
_G.current_iCode = ic;
if (ic->lineno && cln != ic->lineno)
{ "__builtin_memcmp_x2x","c",3,{"cx*","cx*","i"}}, /* void __builtin_memcmp_x2x (xdata char *,xdata char *,int) */
{ "__builtin_memcmp_c2x","c",3,{"cx*","cp*","i"}}, /* void __builtin_memcmp_c2x (xdata char *,code char *,int) */
{ NULL , NULL,0, {NULL}} /* mark end of table */
-};
+};
void ds390_assignRegisters (eBBlock ** ebbs, int count);
static int regParmFlg = 0; /* determine if we can register a parameter */
static int
_ds390_regparm (sym_link * l)
{
-
if (options.parms_in_bank1 == 0) {
/* simple can pass only the first parameter in a register */
if (regParmFlg)
return 0;
}
regParmFlg += size ;
- return regParmFlg - size + 1;
+ return regParmFlg - size + 1;
}
}
port->stack.isr_overhead += 2; /* Will save dpx on ISR entry. */
- port->stack.call_overhead += 2; /* This acounts for the extra byte
+ port->stack.call_overhead += 2; /* This acounts for the extra byte
* of return addres on the stack.
- * but is ugly. There must be a
+ * but is ugly. There must be a
* better way.
*/
} else {
if (!options.stack_loc) options.stack_loc = 0x400008;
}
-
+
/* generate native code 16*16 mul/div */
- if (options.useAccelerator)
+ if (options.useAccelerator)
port->support.muldiv=2;
- else
+ else
port->support.muldiv=1;
/* Fixup the memory map for the stack; it is now in
sym_link *result_type = operandType(result);
//sym_link *right_type = (right ? operandType(right) : 0);
//sym_link *left_type = (left ? operandType(left) : 0);
-
+
/* if it is a pointer then return ok for now */
if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
-
- /* if bitwise | add & subtract then no since mcs51 is pretty good at it
+
+ /* if bitwise | add & subtract then no since mcs51 is pretty good at it
so we will cse only if they are local (i.e. both ic & pdic belong to
the same basic block */
if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
else return 0;
}
-
+
/* for others it is cheaper to do the cse */
return 1;
}
{
if (IN_FARSPACE(oclass))
return 1;
-
+
return 0;
}
instructionSize(char *inst, char *op1, char *op2)
{
int isflat24 = (options.model == MODEL_FLAT24);
-
+
#define ISINST(s) (strncmp(inst, (s), sizeof(s)-1) == 0)
#define IS_A(s) (*(s) == 'a' && *(s+1) == '\0')
#define IS_C(s) (*(s) == 'c' && *(s+1) == '\0')
/* Based on the current (2003-08-22) code generation for the
small library, the top instruction probability is:
-
+
57% mov/movx/movc
6% push
6% pop
if (IS_A (op2) || IS_Rn (op2) || IS_atRi (op2)) return 2;
return 3;
}
-
+
if (ISINST ("push")) return 2;
if (ISINST ("pop")) return 2;
if (ISINST ("acall")) return 2+isflat24;
if (ISINST ("ajmp")) return 2+isflat24;
-
+
if (ISINST ("add") || ISINST ("addc") || ISINST ("subb") || ISINST ("xch"))
{
if (IS_Rn(op2) || IS_atRi(op2)) return 1;
aln->regsWritten = NULL;
aln->initialized = 0;
aln->currentDPS = currentDPS;
-
+
return aln;
}
return strcmp((const char *)key, ((ds390operanddata *)member)->name);
}
-static void
+static void
updateOpRW (asmLineNode *aln, char *op, char *optype, int currentDPS)
{
ds390operanddata *opdat;
int regIdx1 = -1;
int regIdx2 = -1;
int regIdx3 = -1;
-
+
dot = strchr(op, '.');
if (dot)
*dot = '\0';
opdat = bsearch (op, ds390operandDataTable,
sizeof(ds390operandDataTable)/sizeof(ds390operanddata),
sizeof(ds390operanddata), ds390operandCompare);
-
+
if (opdat)
{
regIdx1 = opdat->regIdx1;
regIdx3 = DPX1_IDX;
}
}
-
+
if (strchr(optype,'r'))
{
if (regIdx1 >= 0)
{"xchd", "", "", "rw", "rw"},
{"xrl", "", "", "rw", "r"},
};
-
+
static int
ds390opcodeCompare (const void *key, const void *member)
{
ds390opcodedata *opdat;
aln->initialized = 1;
-
+
p = ln->line;
-
+
while (*p && isspace(*p)) p++;
for (op = inst, opsize=1; *p; p++)
{
if (*p == ';' || *p == ':' || *p == '=')
return aln;
-
+
while (*p && isspace(*p)) p++;
if (*p == '=')
return aln;
*op++ = tolower(*p), opsize++;
}
*op = '\0';
-
+
if (*p == ',') p++;
for (op = op2, opsize=1; *p && *p != ','; p++)
{
"aslink", "-nf", "\"$1\"", NULL
};
-/* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */ static const char *_asmCmd[] =
+/* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
+static const char *_asmCmd[] =
{
"asx8051", "$l", "$3", "\"$1.asm\"", NULL
};
}
port->s.fptr_size = 3;
port->s.gptr_size = 4;
-
+
port->stack.isr_overhead += 2; /* Will save dpx on ISR entry. */
-
- port->stack.call_overhead += 2; /* This acounts for the extra byte
+
+ port->stack.call_overhead += 2; /* This acounts for the extra byte
* of return addres on the stack.
- * but is ugly. There must be a
+ * but is ugly. There must be a
* better way.
*/
-
+
port->mem.default_local_map = xdata;
port->mem.default_globl_map = xdata;
-
+
if (!options.stack10bit) {
options.stack10bit = 1;
fprintf(stderr,"TININative supports only stack10bit \n");
}
-
+
if (!options.stack_loc) options.stack_loc = 0x400008;
-
+
/* generate native code 16*16 mul/div */
- if (options.useAccelerator)
+ if (options.useAccelerator)
port->support.muldiv=2;
- else
+ else
port->support.muldiv=1;
-
+
/* Fixup the memory map for the stack; it is now in
* far space and requires a FPOINTER to access it.
*/
options.cc_only =1;
}
-static int _tininative_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
+static int _tininative_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
{
return 1;
}
buildCmdLine(buffer,a390Cmd,dstFileName,NULL,NULL,asmOptions);
if (my_system(buffer)) {
exit(1);
- }
+ }
}
/* list of key words used by TININative */
{ "System_GetCurrentProcessId","c",0,{NULL}}, /* char System_GetCurrentProcessId() */
{ "System_GetCurrentThreadId","c",0,{NULL}}, /* char System_GetCurrentThreadId() */
{ NULL , NULL,0, {NULL}} /* mark end of table */
-};
+};
static const char *_a390Cmd[] =
{
{
/* We can't generate a static IVT, since the boot rom creates one
* for us in rom_init.
- *
+ *
* we must patch it as part of the C startup.
*/
fprintf (of, ";\tDS80C400 IVT must be generated at runtime.\n");
return TRUE;
}
-
+
static void
_ds400_finaliseOptions (void)
// hackhack: we're a superset of the 390.
addSet(&preArgvSet, Safe_strdup("-DSDCC_ds390"));
addSet(&preArgvSet, Safe_strdup("-D__ds390"));
-
+
/* Hack-o-matic: if we are using the flat24 model,
* adjust pointer sizes.
*/
port->stack.isr_overhead += 2; /* Will save dpx on ISR entry. */
- port->stack.call_overhead += 2; /* This acounts for the extra byte
+ port->stack.call_overhead += 2; /* This acounts for the extra byte
* of return addres on the stack.
- * but is ugly. There must be a
+ * but is ugly. There must be a
* better way.
*/
if (!options.stack_loc) options.stack_loc = 0xffdc00;
// assumes IDM1:0 = 1:0, CMA = 1.
}
-
+
/* generate native code 16*16 mul/div */
- if (options.useAccelerator)
+ if (options.useAccelerator)
port->support.muldiv=2;
- else
+ else
port->support.muldiv=1;
/* Fixup the memory map for the stack; it is now in
if (options.parms_in_bank1) {
addSet(&preArgvSet, Safe_strdup("-DSDCC_PARMS_IN_BANK1"));
}
-
+
// the DS400 rom calling interface uses register bank 3.
RegBankUsed[3] = 1;
-
+
} /* MODEL_FLAT24 */
}
/*------------------------------------------------------------------------
- SDCCralloc.c - source file for register allocation. (8051) specific
+ SDCCralloc.c - source file for register allocation. (DS80C390) specific
Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998)
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
- what you give them. Help stamp out software-hoarding!
+ what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
#include "common.h"
bitVect *totRegAssigned; /* final set of LRs that got into registers */
short blockSpil;
int slocNum;
- bitVect *funcrUsed; /* registers used in a function */
+ bitVect *funcrUsed; /* registers used in a function */
int stackExtend;
int dataExtend;
}
_G;
/* Shared with gen.c */
-int ds390_ptrRegReq; /* one byte pointer register required */
+int ds390_ptrRegReq; /* one byte pointer register required */
/* 8051 registers */
regs regs390[] =
static void spillThis (symbol *);
static void freeAllRegs ();
static iCode * packRegsDPTRuse (operand *);
-static int packRegsDPTRnuse (operand *,int);
+static int packRegsDPTRnuse (operand *,unsigned);
/*-----------------------------------------------------------------*/
/* allocReg - allocates register of given type */
/* if type is given as 0 then any
free register will do */
if (!type &&
- regs390[i].isFree)
- {
- regs390[i].isFree = 0;
- if (currFunc)
- currFunc->regsUsed =
- bitVectSetBit (currFunc->regsUsed, i);
- return ®s390[i];
- }
+ regs390[i].isFree)
+ {
+ regs390[i].isFree = 0;
+ if (currFunc)
+ currFunc->regsUsed =
+ bitVectSetBit (currFunc->regsUsed, i);
+ return ®s390[i];
+ }
/* other wise look for specific type
of register */
if (regs390[i].isFree &&
- regs390[i].type == type)
- {
- regs390[i].isFree = 0;
- if (currFunc)
- currFunc->regsUsed =
- bitVectSetBit (currFunc->regsUsed, i);
- return ®s390[i];
- }
+ regs390[i].type == type)
+ {
+ regs390[i].isFree = 0;
+ if (currFunc)
+ currFunc->regsUsed =
+ bitVectSetBit (currFunc->regsUsed, i);
+ return ®s390[i];
+ }
}
return NULL;
}
/*-----------------------------------------------------------------*/
-/* ds390_regWithIdx - returns pointer to register wit index number */
+/* ds390_regWithIdx - returns pointer to register with index number*/
/*-----------------------------------------------------------------*/
regs *
ds390_regWithIdx (int idx)
return ®s390[i];
werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
- "regWithIdx not found");
+ "regWithIdx not found");
exit (1);
}
static void
freeReg (regs * reg)
{
+ if (!reg)
+ {
+ werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
+ "freeReg - Freeing NULL register");
+ exit (1);
+ }
+
reg->isFree = 1;
}
if (type == REG_PTR)
{
if ((nfr = nFreeRegs (type)) == 0)
- return nFreeRegs (REG_GPR);
+ return nFreeRegs (REG_GPR);
}
return nFreeRegs (type);
{
bitVect *spillable;
- /* spillable live ranges are those that are live at this
+ /* spillable live ranges are those that are live at this
point . the following categories need to be subtracted
- from this set.
+ from this set.
a) - those that are already spilt
b) - if being used by this one
c) - defined by this one */
spillable = bitVectCopy (ic->rlive);
spillable =
- bitVectCplAnd (spillable, _G.spiltSet); /* those already spilt */
+ bitVectCplAnd (spillable, _G.spiltSet); /* those already spilt */
spillable =
- bitVectCplAnd (spillable, ic->uses); /* used in this one */
+ bitVectCplAnd (spillable, ic->uses); /* used in this one */
bitVectUnSetBit (spillable, ic->defKey);
spillable = bitVectIntersect (spillable, _G.regAssigned);
return spillable;
notUsedInRemaining (symbol * sym, eBBlock * ebp, iCode * ic)
{
return ((usedInRemaining (operandFromSymbol (sym), ic) ? 0 : 1) &&
- allDefsOutOfRange (sym->defs, ebp->fSeq, ebp->lSeq));
+ allDefsOutOfRange (sym->defs, ebp->fSeq, ebp->lSeq));
}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
static set *
liveRangesWith (bitVect * lrs, int (func) (symbol *, eBBlock *, iCode *),
- eBBlock * ebp, iCode * ic)
+ eBBlock * ebp, iCode * ic)
{
set *rset = NULL;
int i;
{
symbol *sym;
if (!bitVectBitValue (lrs, i))
- continue;
+ continue;
- /* if we don't find it in the live range
+ /* if we don't find it in the live range
hash table we are in serious trouble */
if (!(sym = hTabItemWithKey (liveRanges, i)))
- {
- werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
- "liveRangesWith could not find liveRange");
- exit (1);
- }
+ {
+ werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
+ "liveRangesWith could not find liveRange");
+ exit (1);
+ }
if (func (sym, ebp, ic) && bitVectBitValue (_G.regAssigned, sym->key))
- addSetHead (&rset, sym);
+ addSetHead (&rset, sym);
}
return rset;
/* if usage is the same then prefer
the spill the smaller of the two */
if (lsym->used == sym->used)
- if (getSize (lsym->type) < getSize (sym->type))
- sym = lsym;
+ if (getSize (lsym->type) < getSize (sym->type))
+ sym = lsym;
/* if less usage */
if (lsym->used < sym->used)
- sym = lsym;
+ sym = lsym;
}
for (sym = setFirstItem (itmpStack); sym;
sym = setNextItem (itmpStack))
{
- if (bitVectBitValue(sym->clashes,fsym->key)) return 0;
+ if (bitVectBitValue(sym->clashes,fsym->key)) return 0;
}
return 1;
}
{
int j;
- /* if no registers assigned to it or
- spilt */
- /* if it does not overlap with this then
- not need to spill it */
+ /* if no registers assigned to it or spilt */
+ /* if it does not overlap this then
+ no need to spill it */
if (lrsym->isspilt || !lrsym->nRegs ||
- (lrsym->liveTo < forSym->liveFrom))
- continue;
+ (lrsym->liveTo < forSym->liveFrom))
+ continue;
/* go thru the registers : if it is either
- r0 or r1 then spil it */
+ r0 or r1 then spill it */
for (j = 0; j < lrsym->nRegs; j++)
- if (lrsym->regs[j] == r0 ||
- lrsym->regs[j] == r1)
- {
- spillThis (lrsym);
- break;
- }
+ if (lrsym->regs[j] == r0 ||
+ lrsym->regs[j] == r1)
+ {
+ spillThis (lrsym);
+ break;
+ }
}
}
char slocBuffer[30];
- /* first go try and find a free one that is already
+ /* first go try and find a free one that is already
existing on the stack */
if (applyToSet (_G.stackSpil, isFree, &sloc, sym))
{
/* found a free one : just update & return */
- sym->usl.spillLoc = sloc;
+ sym->usl.spillLoc = sloc;
sym->stackSpil = 1;
sloc->isFree = 0;
addSetHead (&sloc->usl.itmpStack, sym);
we need to allocate this on the stack : this is really a
hack!! but cannot think of anything better at this time */
- if (SNPRINTF (slocBuffer, sizeof(slocBuffer),
- "sloc%d", _G.slocNum++) >= sizeof (slocBuffer))
+ if (SNPRINTF (slocBuffer, sizeof(slocBuffer),
+ "sloc%d", _G.slocNum++) >= sizeof (slocBuffer))
{
fprintf (stderr, "***Internal error: slocBuffer overflowed: %s:%d\n",
- __FILE__, __LINE__);
+ __FILE__, __LINE__);
exit (1);
}
temporarily turn it off ; we also
turn off memory model to prevent
the spil from going to the external storage
- and turn off overlaying
+ and turn off overlaying
*/
useXstack = options.useXstack;
options.useXstack = useXstack;
options.model = model;
options.noOverlay = noOverlay;
- sloc->isref = 1; /* to prevent compiler warning */
+ sloc->isref = 1; /* to prevent compiler warning */
/* if it is on the stack then update the stack */
if (IN_STACK (sloc->etype))
sym->usl.spillLoc = sloc;
sym->stackSpil = 1;
- /* add it to the set of itempStack set
+ /* add it to the set of itempStack set
of the spill location */
addSetHead (&sloc->usl.itmpStack, sym);
return sym;
if (!(sym->remat || sym->usl.spillLoc))
createStackSpil (sym);
-
/* mark it has spilt & put it in the spilt set */
sym->isspilt = sym->spillA = 1;
_G.spiltSet = bitVectSetBit (_G.spiltSet, sym->key);
if (sym->regs[i])
{
- freeReg (sym->regs[i]);
- sym->regs[i] = NULL;
+ freeReg (sym->regs[i]);
+ sym->regs[i] = NULL;
}
/* if spilt on stack then free up r0 & r1
{
sym = leastUsedLR (selectS);
strncpyz (sym->rname,
- sym->usl.spillLoc->rname[0] ?
- sym->usl.spillLoc->rname : sym->usl.spillLoc->name,
- sizeof(sym->rname));
+ sym->usl.spillLoc->rname[0] ?
+ sym->usl.spillLoc->rname : sym->usl.spillLoc->name,
+ sizeof(sym->rname));
sym->spildir = 1;
/* mark it as allocation required */
sym->usl.spillLoc->allocreq++;
/* check if there are any live ranges allocated
to registers that are not used in this block */
if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInBlock, ebp, ic)))
- {
- sym = leastUsedLR (selectS);
- /* if this is not rematerializable */
- if (!sym->remat)
- {
- _G.blockSpil++;
- sym->blockSpil = 1;
- }
- return sym;
- }
+ {
+ sym = leastUsedLR (selectS);
+ /* if this is not rematerializable */
+ if (!sym->remat)
+ {
+ _G.blockSpil++;
+ sym->blockSpil = 1;
+ }
+ return sym;
+ }
/* check if there are any live ranges that not
used in the remainder of the block */
if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
- {
- sym = leastUsedLR (selectS);
- if (sym != forSym)
- {
- if (!sym->remat)
- {
- sym->remainSpil = 1;
- _G.blockSpil++;
- }
- return sym;
- }
- }
+ {
+ sym = leastUsedLR (selectS);
+ if (sym != forSym)
+ {
+ if (!sym->remat)
+ {
+ sym->remainSpil = 1;
+ _G.blockSpil++;
+ }
+ return sym;
+ }
+ }
}
/* find live ranges with spillocation && not used as pointers */
if (ssym->regs[i])
freeReg (ssym->regs[i]);
- /* if spilt on stack then free up r0 & r1
+ /* if spilt on stack then free up r0 & r1
if they could have been assigned to as gprs */
if (!ds390_ptrRegReq && isSpiltOnStack (ssym) && !options.stack10bit)
{
- ds390_ptrRegReq++;
+ ds390_ptrRegReq++;
spillLRWithPtrReg (ssym);
}
- /* if this was a block level spil then insert push & pop
+ /* if this was a block level spil then insert push & pop
at the start & end of block respectively */
if (ssym->blockSpil)
{
iCode *nic = newiCode (IPUSH, operandFromSymbol (ssym), NULL);
/* add push to the start of the block */
addiCodeToeBBlock (ebp, nic, (ebp->sch->op == LABEL ?
- ebp->sch->next : ebp->sch));
+ ebp->sch->next : ebp->sch));
nic = newiCode (IPOP, operandFromSymbol (ssym), NULL);
/* add pop to the end of the block */
addiCodeToeBBlock (ebp, nic, NULL);
for (j=0; j<=sym->nRegs; j++)
if (sym->regs[j])
sym->regs[j]->isFree = 0;
-
- /* this looks like an infinite loop but
+
+ /* this looks like an infinite loop but
in really selectSpil will abort */
goto tryAgain;
}
for (j=0; j<=sym->nRegs; j++)
if (sym->regs[j])
sym->regs[j]->isFree = 0;
-
- /* this looks like an infinite loop but
+
+ /* this looks like an infinite loop but
in really selectSpil will abort */
goto tryAgain;
}
symbol *psym = NULL;
/* if it does not end here */
if (sym->liveTo > ic->seq)
- continue;
+ continue;
- /* if it was spilt on stack then we can
+ /* if it was spilt on stack then we can
mark the stack spil location as free */
if (sym->isspilt)
- {
- if (sym->stackSpil)
- {
- sym->usl.spillLoc->isFree = 1;
- sym->stackSpil = 0;
- }
- continue;
- }
+ {
+ if (sym->stackSpil)
+ {
+ sym->usl.spillLoc->isFree = 1;
+ sym->stackSpil = 0;
+ }
+ continue;
+ }
if (!bitVectBitValue (_G.regAssigned, sym->key))
- continue;
+ continue;
/* special case check if this is an IFX &
- the privious one was a pop and the
+ the privious one was a pop and the
previous one was not spilt then keep track
of the symbol */
if (ic->op == IFX && ic->prev &&
- ic->prev->op == IPOP &&
- !ic->prev->parmPush &&
- !OP_SYMBOL (IC_LEFT (ic->prev))->isspilt)
- psym = OP_SYMBOL (IC_LEFT (ic->prev));
+ ic->prev->op == IPOP &&
+ !ic->prev->parmPush &&
+ !OP_SYMBOL (IC_LEFT (ic->prev))->isspilt)
+ psym = OP_SYMBOL (IC_LEFT (ic->prev));
if (sym->nRegs)
- {
- int i = 0;
-
- bitVectUnSetBit (_G.regAssigned, sym->key);
-
- /* if the result of this one needs registers
- and does not have it then assign it right
- away */
- if (IC_RESULT (ic) &&
- !(SKIP_IC2 (ic) || /* not a special icode */
- ic->op == JUMPTABLE ||
- ic->op == IFX ||
- ic->op == IPUSH ||
- ic->op == IPOP ||
- ic->op == RETURN ||
- POINTER_SET (ic)) &&
- (result = OP_SYMBOL (IC_RESULT (ic))) && /* has a result */
- result->liveTo > ic->seq && /* and will live beyond this */
- result->liveTo <= ebp->lSeq && /* does not go beyond this block */
- result->regType == sym->regType && /* same register types */
- result->nRegs && /* which needs registers */
- !result->isspilt && /* and does not already have them */
- !result->remat &&
- !bitVectBitValue (_G.regAssigned, result->key) &&
- /* the number of free regs + number of regs in this LR
- can accomodate the what result Needs */
- ((nfreeRegsType (result->regType) +
- sym->nRegs) >= result->nRegs)
- )
- {
-
- for (i = 0; i < result->nRegs; i++)
- if (i < sym->nRegs)
- result->regs[i] = sym->regs[i];
- else
- result->regs[i] = getRegGpr (ic, ebp, result);
-
- _G.regAssigned = bitVectSetBit (_G.regAssigned, result->key);
- _G.totRegAssigned = bitVectSetBit (_G.totRegAssigned, result->key);
-
- }
-
- /* free the remaining */
- for (; i < sym->nRegs; i++)
- {
- if (psym)
- {
- if (!symHasReg (psym, sym->regs[i]))
- freeReg (sym->regs[i]);
- }
- else
- freeReg (sym->regs[i]);
- }
- }
+ {
+ int i = 0;
+
+ bitVectUnSetBit (_G.regAssigned, sym->key);
+
+ /* if the result of this one needs registers
+ and does not have it then assign it right
+ away */
+ if (IC_RESULT (ic) &&
+ !(SKIP_IC2 (ic) || /* not a special icode */
+ ic->op == JUMPTABLE ||
+ ic->op == IFX ||
+ ic->op == IPUSH ||
+ ic->op == IPOP ||
+ ic->op == RETURN ||
+ POINTER_SET (ic)) &&
+ (result = OP_SYMBOL (IC_RESULT (ic))) && /* has a result */
+ result->liveTo > ic->seq && /* and will live beyond this */
+ result->liveTo <= ebp->lSeq && /* does not go beyond this block */
+ result->regType == sym->regType && /* same register types */
+ result->nRegs && /* which needs registers */
+ !result->isspilt && /* and does not already have them */
+ !result->remat &&
+ !bitVectBitValue (_G.regAssigned, result->key) &&
+ /* the number of free regs + number of regs in this LR
+ can accomodate the what result Needs */
+ ((nfreeRegsType (result->regType) +
+ sym->nRegs) >= result->nRegs)
+ )
+ {
+
+ for (i = 0; i < result->nRegs; i++)
+ if (i < sym->nRegs)
+ result->regs[i] = sym->regs[i];
+ else
+ result->regs[i] = getRegGpr (ic, ebp, result);
+
+ _G.regAssigned = bitVectSetBit (_G.regAssigned, result->key);
+ _G.totRegAssigned = bitVectSetBit (_G.totRegAssigned, result->key);
+
+ }
+
+ /* free the remaining */
+ for (; i < sym->nRegs; i++)
+ {
+ if (psym)
+ {
+ if (!symHasReg (psym, sym->regs[i]))
+ freeReg (sym->regs[i]);
+ }
+ else
+ freeReg (sym->regs[i]);
+ }
+ }
}
}
of te type required */
if (rt == REG_PTR)
{
- /* special case for pointer type
- if pointer type not avlb then
+ /* special case for pointer type
+ if pointer type not avlb then
check for type gpr */
if (nFreeRegs (rt) >= nr)
- return 0;
+ return 0;
if (nFreeRegs (REG_GPR) >= nr)
- return 0;
+ return 0;
}
else
{
if (ds390_ptrRegReq)
- {
- if (nFreeRegs (rt) >= nr)
- return 0;
- }
+ {
+ if (nFreeRegs (rt) >= nr)
+ return 0;
+ }
else
- {
- if (nFreeRegs (REG_PTR) +
- nFreeRegs (REG_GPR) >= nr)
- return 0;
- }
+ {
+ if (nFreeRegs (REG_PTR) +
+ nFreeRegs (REG_GPR) >= nr)
+ return 0;
+ }
}
/* it will cause a spil */
for (i = 0; i < count; i++)
{
for (j = 0; j < count; j++)
- {
- if (result->regs[i] == opsym->regs[j] && i != j)
- {
- shared = 1;
- goto xchgPositions;
- }
- }
+ {
+ if (result->regs[i] == opsym->regs[j] && i != j)
+ {
+ shared = 1;
+ goto xchgPositions;
+ }
+ }
}
xchgPositions:
if (shared)
change ++;
goto again;
}
- return change ;
+ return change;
}
/*-----------------------------------------------------------------*/
/* unusedLRS - returns a bitVector of liveranges not used in 'ebp' */
/*-----------------------------------------------------------------*/
-bitVect *unusedLRs (eBBlock *ebp)
+bitVect *unusedLRs (eBBlock *ebp)
{
bitVect *ret = NULL;
symbol *sym;
int key;
-
+
if (!ebp) return NULL;
- for (sym = hTabFirstItem(liveRanges,&key); sym ;
- sym = hTabNextItem(liveRanges,&key)) {
-
- if (notUsedInBlock(sym,ebp,NULL)) {
- ret = bitVectSetBit(ret,sym->key);
- }
+ for (sym = hTabFirstItem(liveRanges,&key); sym ;
+ sym = hTabNextItem(liveRanges,&key)) {
+
+ if (notUsedInBlock(sym,ebp,NULL)) {
+ ret = bitVectSetBit(ret,sym->key);
+ }
}
return ret;
/*-----------------------------------------------------------------*/
/* deassignUnsedLRs - if this baisc block ends in a return then */
-/* deassign symbols not used in this block */
+/* deassign symbols not used in this block */
/*-----------------------------------------------------------------*/
bitVect *deassignUnsedLRs(eBBlock *ebp)
{
switch (returnAtEnd(ebp)) {
case 2: /* successor block ends in a return */
- unused = unusedLRs((eBBlock *) setFirstItem(ebp->succList));
- /* fall thru */
+ unused = unusedLRs((eBBlock *) setFirstItem(ebp->succList));
+ /* fall thru */
case 1: /* this block ends in a return */
- unused = bitVectIntersect(unused,unusedLRs(ebp));
- break;
+ unused = bitVectIntersect(unused,unusedLRs(ebp));
+ break;
}
-
+
if (unused) {
- for (i = 0 ; i < unused->size ; i++ ) {
-
- /* if unused */
- if (bitVectBitValue(unused,i)) {
-
- /* if assigned to registers */
- if (bitVectBitValue(_G.regAssigned,i)) {
- symbol *sym;
- int j;
-
- sym = hTabItemWithKey(liveRanges,i);
- /* remove it from regassigned & mark the
- register free */
- bitVectUnSetBit(_G.regAssigned,i);
- for (j = 0 ; j < sym->nRegs; j++)
- freeReg(sym->regs[j]);
- } else {
- /* not assigned to registers : remove from set*/
- bitVectUnSetBit(unused,i);
- }
- }
- }
+ for (i = 0 ; i < unused->size ; i++ ) {
+
+ /* if unused */
+ if (bitVectBitValue(unused,i)) {
+
+ /* if assigned to registers */
+ if (bitVectBitValue(_G.regAssigned,i)) {
+ symbol *sym;
+ int j;
+
+ sym = hTabItemWithKey(liveRanges,i);
+ /* remove it from regassigned & mark the
+ register free */
+ bitVectUnSetBit(_G.regAssigned,i);
+ for (j = 0 ; j < sym->nRegs; j++)
+ freeReg(sym->regs[j]);
+ } else {
+ /* not assigned to registers : remove from set*/
+ bitVectUnSetBit(unused,i);
+ }
+ }
+ }
}
return unused;
}
if (!unused) return ;
for (i = 0 ; i < unused->size ; i++ ) {
- /* if unused : means it was assigned to registers before */
- if (bitVectBitValue(unused,i)) {
- symbol *sym;
- int j;
-
- /* put it back into reg set*/
- bitVectSetBit(_G.regAssigned,i) ;
-
- sym = hTabItemWithKey(liveRanges,i);
- /* makr registers busy */
- for (j = 0 ; j < sym->nRegs; j++)
- sym->regs[j]->isFree = 0;
- }
+ /* if unused : means it was assigned to registers before */
+ if (bitVectBitValue(unused,i)) {
+ symbol *sym;
+ int j;
+
+ /* put it back into reg set*/
+ bitVectSetBit(_G.regAssigned,i) ;
+
+ sym = hTabItemWithKey(liveRanges,i);
+ /* makr registers busy */
+ for (j = 0 ; j < sym->nRegs; j++)
+ sym->regs[j]->isFree = 0;
+ }
}
}
verifyRegsAssigned (operand *op, iCode * ic)
{
symbol * sym;
-
+
if (!op) return;
if (!IS_ITEMP (op)) return;
-
+
sym = OP_SYMBOL (op);
if (sym->isspilt) return;
if (!sym->nRegs) return;
if (sym->regs[0]) return;
-
- werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT,
- sym->prereqv ? sym->prereqv->name : sym->name);
+
+ werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT,
+ sym->prereqv ? sym->prereqv->name : sym->name);
spillThis (sym);
}
bitVect *unusedLRs = NULL;
if (ebbs[i]->noPath &&
- (ebbs[i]->entryLabel != entryLabel &&
- ebbs[i]->entryLabel != returnLabel))
- continue;
-
+ (ebbs[i]->entryLabel != entryLabel &&
+ ebbs[i]->entryLabel != returnLabel))
+ continue;
+
unusedLRs = deassignUnsedLRs(ebbs[i]);
-
+
/* of all instructions do */
for (ic = ebbs[i]->sch; ic; ic = ic->next)
- {
-
- /* if this is an ipop that means some live
- range will have to be assigned again */
- if (ic->op == IPOP)
- reassignLR (IC_LEFT (ic));
-
- /* if result is present && is a true symbol */
- if (IC_RESULT (ic) && ic->op != IFX &&
- IS_TRUE_SYMOP (IC_RESULT (ic)))
- OP_SYMBOL (IC_RESULT (ic))->allocreq++;
-
- /* take away registers from live
- ranges that end at this instruction */
- deassignLRs (ic, ebbs[i]);
-
- /* some don't need registers */
- if (SKIP_IC2 (ic) ||
- ic->op == JUMPTABLE ||
- ic->op == IFX ||
- ic->op == IPUSH ||
- ic->op == IPOP ||
- (IC_RESULT (ic) && POINTER_SET (ic)))
- continue;
-
- /* now we need to allocate registers
- only for the result */
- if (IC_RESULT (ic))
- {
- symbol *sym = OP_SYMBOL (IC_RESULT (ic));
- bitVect *spillable;
- int willCS;
- int j;
- int ptrRegSet = 0;
-
- /* if it does not need or is spilt
- or is already assigned to registers
- or will not live beyond this instructions */
- if (!sym->nRegs ||
- sym->isspilt ||
- bitVectBitValue (_G.regAssigned, sym->key) ||
- sym->liveTo <= ic->seq)
- continue;
-
- /* if some liverange has been spilt at the block level
- and this one live beyond this block then spil this
- to be safe */
- if (_G.blockSpil && sym->liveTo > ebbs[i]->lSeq)
- {
- spillThis (sym);
- continue;
- }
- /* if trying to allocate this will cause
- a spill and there is nothing to spill
- or this one is rematerializable then
- spill this one */
- willCS = willCauseSpill (sym->nRegs, sym->regType);
- spillable = computeSpillable (ic);
- if (sym->remat ||
- (willCS && bitVectIsZero (spillable)))
- {
-
- spillThis (sym);
- continue;
-
- }
-
- /* If the live range preceeds the point of definition
- then ideally we must take into account registers that
- have been allocated after sym->liveFrom but freed
- before ic->seq. This is complicated, so spill this
- symbol instead and let fillGaps handle the allocation. */
- if (sym->liveFrom < ic->seq)
- {
- spillThis (sym);
- continue;
- }
-
- /* if it has a spillocation & is used less than
- all other live ranges then spill this */
- if (willCS) {
- if (sym->usl.spillLoc) {
- symbol *leastUsed = leastUsedLR (liveRangesWith (spillable,
- allLRs, ebbs[i], ic));
- if (leastUsed && leastUsed->used > sym->used) {
- spillThis (sym);
- continue;
- }
- } else {
- /* if none of the liveRanges have a spillLocation then better
- to spill this one than anything else already assigned to registers */
- if (liveRangesWith(spillable,noSpilLoc,ebbs[i],ic)) {
- /* if this is local to this block then we might find a block spil */
- if (!(sym->liveFrom >= ebbs[i]->fSeq && sym->liveTo <= ebbs[i]->lSeq)) {
- spillThis (sym);
- continue;
- }
- }
- }
- }
-
- /* if we need ptr regs for the right side
- then mark it */
- if (POINTER_GET (ic) && IS_SYMOP (IC_LEFT (ic))
- && getSize (OP_SYMBOL (IC_LEFT (ic))->type)
- <= (unsigned) PTRSIZE)
- {
- ds390_ptrRegReq++;
- ptrRegSet = 1;
- }
- /* else we assign registers to it */
- _G.regAssigned = bitVectSetBit (_G.regAssigned, sym->key);
- _G.totRegAssigned = bitVectSetBit (_G.totRegAssigned, sym->key);
-
- for (j = 0; j < sym->nRegs; j++)
- {
- if (sym->regType == REG_PTR)
- sym->regs[j] = getRegPtr (ic, ebbs[i], sym);
- else
- sym->regs[j] = getRegGpr (ic, ebbs[i], sym);
-
- /* if the allocation falied which means
- this was spilt then break */
- if (!sym->regs[j])
- break;
- }
-
+ {
+
+ /* if this is an ipop that means some live
+ range will have to be assigned again */
+ if (ic->op == IPOP)
+ reassignLR (IC_LEFT (ic));
+
+ /* if result is present && is a true symbol */
+ if (IC_RESULT (ic) && ic->op != IFX &&
+ IS_TRUE_SYMOP (IC_RESULT (ic)))
+ OP_SYMBOL (IC_RESULT (ic))->allocreq++;
+
+ /* take away registers from live
+ ranges that end at this instruction */
+ deassignLRs (ic, ebbs[i]);
+
+ /* some don't need registers */
+ if (SKIP_IC2 (ic) ||
+ ic->op == JUMPTABLE ||
+ ic->op == IFX ||
+ ic->op == IPUSH ||
+ ic->op == IPOP ||
+ (IC_RESULT (ic) && POINTER_SET (ic)))
+ continue;
+
+ /* now we need to allocate registers
+ only for the result */
+ if (IC_RESULT (ic))
+ {
+ symbol *sym = OP_SYMBOL (IC_RESULT (ic));
+ bitVect *spillable;
+ int willCS;
+ int j;
+ int ptrRegSet = 0;
+
+ /* if it does not need or is spilt
+ or is already assigned to registers
+ or will not live beyond this instructions */
+ if (!sym->nRegs ||
+ sym->isspilt ||
+ bitVectBitValue (_G.regAssigned, sym->key) ||
+ sym->liveTo <= ic->seq)
+ continue;
+
+ /* if some liverange has been spilt at the block level
+ and this one live beyond this block then spil this
+ to be safe */
+ if (_G.blockSpil && sym->liveTo > ebbs[i]->lSeq)
+ {
+ spillThis (sym);
+ continue;
+ }
+ /* if trying to allocate this will cause
+ a spill and there is nothing to spill
+ or this one is rematerializable then
+ spill this one */
+ willCS = willCauseSpill (sym->nRegs, sym->regType);
+ spillable = computeSpillable (ic);
+ if (sym->remat ||
+ (willCS && bitVectIsZero (spillable)))
+ {
+
+ spillThis (sym);
+ continue;
+
+ }
+
+ /* If the live range preceeds the point of definition
+ then ideally we must take into account registers that
+ have been allocated after sym->liveFrom but freed
+ before ic->seq. This is complicated, so spill this
+ symbol instead and let fillGaps handle the allocation. */
+ if (sym->liveFrom < ic->seq)
+ {
+ spillThis (sym);
+ continue;
+ }
+
+ /* if it has a spillocation & is used less than
+ all other live ranges then spill this */
+ if (willCS) {
+ if (sym->usl.spillLoc) {
+ symbol *leastUsed = leastUsedLR (liveRangesWith (spillable,
+ allLRs, ebbs[i], ic));
+ if (leastUsed && leastUsed->used > sym->used) {
+ spillThis (sym);
+ continue;
+ }
+ } else {
+ /* if none of the liveRanges have a spillLocation then better
+ to spill this one than anything else already assigned to registers */
+ if (liveRangesWith(spillable,noSpilLoc,ebbs[i],ic)) {
+ /* if this is local to this block then we might find a block spil */
+ if (!(sym->liveFrom >= ebbs[i]->fSeq && sym->liveTo <= ebbs[i]->lSeq)) {
+ spillThis (sym);
+ continue;
+ }
+ }
+ }
+ }
+
+ /* if we need ptr regs for the right side
+ then mark it */
+ if (POINTER_GET (ic) && IS_SYMOP (IC_LEFT (ic))
+ && getSize (OP_SYMBOL (IC_LEFT (ic))->type)
+ <= (unsigned) PTRSIZE)
+ {
+ ds390_ptrRegReq++;
+ ptrRegSet = 1;
+ }
+ /* else we assign registers to it */
+ _G.regAssigned = bitVectSetBit (_G.regAssigned, sym->key);
+ _G.totRegAssigned = bitVectSetBit (_G.totRegAssigned, sym->key);
+
+ for (j = 0; j < sym->nRegs; j++)
+ {
+ if (sym->regType == REG_PTR)
+ sym->regs[j] = getRegPtr (ic, ebbs[i], sym);
+ else
+ sym->regs[j] = getRegGpr (ic, ebbs[i], sym);
+
+ /* if the allocation falied which means
+ this was spilt then break */
+ if (!sym->regs[j])
+ break;
+ }
+
/* if it shares registers with operands make sure
- that they are in the same position */
- if (!POINTER_SET(ic) && !POINTER_GET(ic))
+ that they are in the same position */
+ if (!POINTER_SET(ic) && !POINTER_GET(ic))
{
- if (IC_LEFT (ic) && IS_SYMOP (IC_LEFT (ic)) &&
- OP_SYMBOL (IC_LEFT (ic))->nRegs)
+ if (IC_LEFT (ic) && IS_SYMOP (IC_LEFT (ic)) &&
+ OP_SYMBOL (IC_LEFT (ic))->nRegs)
{
- positionRegs (OP_SYMBOL (IC_RESULT (ic)),
- OP_SYMBOL (IC_LEFT (ic)));
- }
- /* do the same for the right operand */
- if (IC_RIGHT (ic) && IS_SYMOP (IC_RIGHT (ic)) &&
- OP_SYMBOL (IC_RIGHT (ic))->nRegs)
+ positionRegs (OP_SYMBOL (IC_RESULT (ic)),
+ OP_SYMBOL (IC_LEFT (ic)));
+ }
+ /* do the same for the right operand */
+ if (IC_RIGHT (ic) && IS_SYMOP (IC_RIGHT (ic)) &&
+ OP_SYMBOL (IC_RIGHT (ic))->nRegs)
{
- positionRegs (OP_SYMBOL (IC_RESULT (ic)),
- OP_SYMBOL (IC_RIGHT (ic)));
- }
+ positionRegs (OP_SYMBOL (IC_RESULT (ic)),
+ OP_SYMBOL (IC_RIGHT (ic)));
+ }
}
- if (ptrRegSet)
- {
- ds390_ptrRegReq--;
- ptrRegSet = 0;
- }
+ if (ptrRegSet)
+ {
+ ds390_ptrRegReq--;
+ ptrRegSet = 0;
+ }
- }
- }
+ }
+ }
reassignUnusedLRs(unusedLRs);
}
/* Check for and fix any problems with uninitialized operands */
for (i = 0; i < count; i++)
{
- iCode *ic;
-
- if (ebbs[i]->noPath &&
- (ebbs[i]->entryLabel != entryLabel &&
- ebbs[i]->entryLabel != returnLabel))
- continue;
-
- for (ic = ebbs[i]->sch; ic; ic = ic->next)
- {
- if (SKIP_IC2 (ic))
- continue;
-
- if (ic->op == IFX)
- {
- verifyRegsAssigned (IC_COND (ic), ic);
- continue;
- }
-
- if (ic->op == JUMPTABLE)
- {
- verifyRegsAssigned (IC_JTCOND (ic), ic);
- continue;
- }
-
- verifyRegsAssigned (IC_RESULT (ic), ic);
- verifyRegsAssigned (IC_LEFT (ic), ic);
- verifyRegsAssigned (IC_RIGHT (ic), ic);
+ iCode *ic;
+
+ if (ebbs[i]->noPath &&
+ (ebbs[i]->entryLabel != entryLabel &&
+ ebbs[i]->entryLabel != returnLabel))
+ continue;
+
+ for (ic = ebbs[i]->sch; ic; ic = ic->next)
+ {
+ if (SKIP_IC2 (ic))
+ continue;
+
+ if (ic->op == IFX)
+ {
+ verifyRegsAssigned (IC_COND (ic), ic);
+ continue;
+ }
+
+ if (ic->op == JUMPTABLE)
+ {
+ verifyRegsAssigned (IC_JTCOND (ic), ic);
+ continue;
+ }
+
+ verifyRegsAssigned (IC_RESULT (ic), ic);
+ verifyRegsAssigned (IC_LEFT (ic), ic);
+ verifyRegsAssigned (IC_RIGHT (ic), ic);
}
- }
-
+ }
}
/*-----------------------------------------------------------------*/
static void fillGaps()
{
symbol *sym =NULL;
- int key =0;
+ int key =0;
int loop = 0, change;
int pass;
if (getenv("DISABLE_FILL_GAPS")) return;
-
+
/* First try to do DPTRuse once more since now we know what got into
- registers */
-
+ registers */
+
while (loop++ < 10) {
- change = 0;
-
- for (sym = hTabFirstItem(liveRanges,&key) ; sym ;
- sym = hTabNextItem(liveRanges,&key)) {
- int size = getSize(sym->type);
-
- if (sym->liveFrom == sym->liveTo) continue;
-
- if (sym->uptr && sym->dptr==0 && !sym->ruonly &&
- size < 4 && size > 1) {
-
- if (packRegsDPTRuse(operandFromSymbol(sym))) {
-
- /* if this was ssigned to registers then */
- if (bitVectBitValue(_G.totRegAssigned,sym->key)) {
- /* take it out of the register assigned set */
- bitVectUnSetBit(_G.totRegAssigned,sym->key);
- } else if (sym->usl.spillLoc) {
- sym->usl.spillLoc->allocreq--;
- sym->usl.spillLoc = NULL;
- }
-
- sym->nRegs = 0;
- sym->isspilt = sym->spillA = 0;
- continue ;
- }
-
- /* try assigning other dptrs */
- if (sym->dptr == 0 && packRegsDPTRnuse(operandFromSymbol(sym),1) && !getenv("DPTRnDISABLE")) {
- /* if this was ssigned to registers then */
- if (bitVectBitValue(_G.totRegAssigned,sym->key)) {
- /* take it out of the register assigned set */
- bitVectUnSetBit(_G.totRegAssigned,sym->key);
- } else if (sym->usl.spillLoc) {
- sym->usl.spillLoc->allocreq--;
- sym->usl.spillLoc = NULL;
- }
- sym->nRegs = 0;
- sym->isspilt = sym->spillA = 0;
- }
- }
- }
-
- /* look for livernages that was spilt by the allocator */
- for (sym = hTabFirstItem(liveRanges,&key) ; sym ;
- sym = hTabNextItem(liveRanges,&key)) {
-
- int i;
- int pdone = 0;
-
- if (!sym->spillA || !sym->clashes || sym->remat) continue ;
- if (!sym->uses || !sym->defs) continue ;
- /* find the liveRanges this one clashes with, that are
- still assigned to registers & mark the registers as used*/
- for ( i = 0 ; i < sym->clashes->size ; i ++) {
- int k;
- symbol *clr;
-
- if (bitVectBitValue(sym->clashes,i) == 0 || /* those that clash with this */
- bitVectBitValue(_G.totRegAssigned,i) == 0) /* and are still assigned to registers */
- continue ;
-
- clr = hTabItemWithKey(liveRanges,i);
- assert(clr);
-
- /* mark these registers as used */
- for (k = 0 ; k < clr->nRegs ; k++ )
- useReg(clr->regs[k]);
- }
-
- if (willCauseSpill(sym->nRegs,sym->regType)) {
- /* NOPE :( clear all registers & and continue */
- freeAllRegs();
- continue ;
- }
-
- /* THERE IS HOPE !!!! */
- for (i=0; i < sym->nRegs ; i++ ) {
- if (sym->regType == REG_PTR)
- sym->regs[i] = getRegPtrNoSpil ();
- else
- sym->regs[i] = getRegGprNoSpil ();
- }
-
- /* For all its definitions check if the registers
- allocated needs positioning NOTE: we can position
- only ONCE if more than One positioning required
- then give up.
- We may need to perform the checks twice; once to
- position the registers as needed, the second to
- verify any register repositioning is still
- compatible.
+ change = 0;
+
+ for (sym = hTabFirstItem(liveRanges,&key) ; sym ;
+ sym = hTabNextItem(liveRanges,&key)) {
+ int size = getSize(sym->type);
+
+ if (sym->liveFrom == sym->liveTo) continue;
+
+ if (sym->uptr && sym->dptr==0 && !sym->ruonly &&
+ size < 4 && size > 1) {
+
+ if (packRegsDPTRuse(operandFromSymbol(sym))) {
+
+ /* if this was assigned to registers then */
+ if (bitVectBitValue(_G.totRegAssigned,sym->key)) {
+ /* take it out of the register assigned set */
+ bitVectUnSetBit(_G.totRegAssigned,sym->key);
+ } else if (sym->usl.spillLoc) {
+ sym->usl.spillLoc->allocreq--;
+ sym->usl.spillLoc = NULL;
+ }
+
+ sym->nRegs = 0;
+ sym->isspilt = sym->spillA = 0;
+ continue ;
+ }
+
+ /* try assigning other dptrs */
+ if (sym->dptr == 0 && packRegsDPTRnuse(operandFromSymbol(sym),1) && !getenv("DPTRnDISABLE")) {
+ /* if this was ssigned to registers then */
+ if (bitVectBitValue(_G.totRegAssigned,sym->key)) {
+ /* take it out of the register assigned set */
+ bitVectUnSetBit(_G.totRegAssigned,sym->key);
+ } else if (sym->usl.spillLoc) {
+ sym->usl.spillLoc->allocreq--;
+ sym->usl.spillLoc = NULL;
+ }
+ sym->nRegs = 0;
+ sym->isspilt = sym->spillA = 0;
+ }
+ }
+ }
+
+ /* look for livernages that was spilt by the allocator */
+ for (sym = hTabFirstItem(liveRanges,&key) ; sym ;
+ sym = hTabNextItem(liveRanges,&key)) {
+
+ int i;
+ int pdone = 0;
+
+ if (!sym->spillA || !sym->clashes || sym->remat) continue ;
+ if (!sym->uses || !sym->defs) continue ;
+ /* find the liveRanges this one clashes with, that are
+ still assigned to registers & mark the registers as used*/
+ for ( i = 0 ; i < sym->clashes->size ; i ++) {
+ int k;
+ symbol *clr;
+
+ if (bitVectBitValue(sym->clashes,i) == 0 || /* those that clash with this */
+ bitVectBitValue(_G.totRegAssigned,i) == 0) /* and are still assigned to registers */
+ continue ;
+
+ clr = hTabItemWithKey(liveRanges,i);
+ assert(clr);
+
+ /* mark these registers as used */
+ for (k = 0 ; k < clr->nRegs ; k++ )
+ useReg(clr->regs[k]);
+ }
+
+ if (willCauseSpill(sym->nRegs,sym->regType)) {
+ /* NOPE :( clear all registers & and continue */
+ freeAllRegs();
+ continue ;
+ }
+
+ /* THERE IS HOPE !!!! */
+ for (i=0; i < sym->nRegs ; i++ ) {
+ if (sym->regType == REG_PTR)
+ sym->regs[i] = getRegPtrNoSpil ();
+ else
+ sym->regs[i] = getRegGprNoSpil ();
+ }
+
+ /* For all its definitions check if the registers
+ allocated needs positioning NOTE: we can position
+ only ONCE if more than One positioning required
+ then give up.
+ We may need to perform the checks twice; once to
+ position the registers as needed, the second to
+ verify any register repositioning is still
+ compatible.
*/
- sym->isspilt = 0;
+ sym->isspilt = 0;
for (pass=0; pass<2; pass++) {
- for (i = 0 ; i < sym->defs->size ; i++ ) {
- if (bitVectBitValue(sym->defs,i)) {
- iCode *ic;
- if (!(ic = hTabItemWithKey(iCodehTab,i))) continue ;
- if (SKIP_IC(ic)) continue;
- assert(isSymbolEqual(sym,OP_SYMBOL(IC_RESULT(ic)))); /* just making sure */
+ for (i = 0 ; i < sym->defs->size ; i++ ) {
+ if (bitVectBitValue(sym->defs,i)) {
+ iCode *ic;
+ if (!(ic = hTabItemWithKey(iCodehTab,i))) continue ;
+ if (SKIP_IC(ic)) continue;
+ assert(isSymbolEqual(sym,OP_SYMBOL(IC_RESULT(ic)))); /* just making sure */
/* if left is assigned to registers */
- if (IS_SYMOP(IC_LEFT(ic)) &&
- bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_LEFT(ic))->key)) {
- pdone += (positionRegs(sym,OP_SYMBOL(IC_LEFT(ic)))>0);
- }
- if (IS_SYMOP(IC_RIGHT(ic)) &&
- bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_RIGHT(ic))->key)) {
- pdone += (positionRegs(sym,OP_SYMBOL(IC_RIGHT(ic)))>0);
- }
- if (pdone > 1) break;
- }
- }
- for (i = 0 ; i < sym->uses->size ; i++ ) {
- if (bitVectBitValue(sym->uses,i)) {
- iCode *ic;
- if (!(ic = hTabItemWithKey(iCodehTab,i))) continue ;
- if (SKIP_IC(ic)) continue;
- if (POINTER_SET(ic) || POINTER_GET(ic)) continue ;
-
- /* if result is assigned to registers */
- if (IS_SYMOP(IC_RESULT(ic)) &&
- bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_RESULT(ic))->key)) {
- pdone += (positionRegs(sym,OP_SYMBOL(IC_RESULT(ic)))>0);
- }
- if (pdone > 1) break;
- }
- }
+ if (IS_SYMOP(IC_LEFT(ic)) &&
+ bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_LEFT(ic))->key)) {
+ pdone += (positionRegs(sym,OP_SYMBOL(IC_LEFT(ic)))>0);
+ }
+ if (IS_SYMOP(IC_RIGHT(ic)) &&
+ bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_RIGHT(ic))->key)) {
+ pdone += (positionRegs(sym,OP_SYMBOL(IC_RIGHT(ic)))>0);
+ }
+ if (pdone > 1) break;
+ }
+ }
+ for (i = 0 ; i < sym->uses->size ; i++ ) {
+ if (bitVectBitValue(sym->uses,i)) {
+ iCode *ic;
+ if (!(ic = hTabItemWithKey(iCodehTab,i))) continue ;
+ if (SKIP_IC(ic)) continue;
+ if (POINTER_SET(ic) || POINTER_GET(ic)) continue ;
+
+ /* if result is assigned to registers */
+ if (IS_SYMOP(IC_RESULT(ic)) &&
+ bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_RESULT(ic))->key)) {
+ pdone += (positionRegs(sym,OP_SYMBOL(IC_RESULT(ic)))>0);
+ }
+ if (pdone > 1) break;
+ }
+ }
if (pdone == 0) break; /* second pass only if regs repositioned */
- if (pdone > 1) break;
+ if (pdone > 1) break;
+ }
+ /* had to position more than once GIVE UP */
+ if (pdone > 1) {
+ /* UNDO all the changes we made to try this */
+ sym->isspilt = 1;
+ for (i=0; i < sym->nRegs ; i++ ) {
+ sym->regs[i] = NULL;
+ }
+ freeAllRegs();
+ D (fprintf (stderr, "Fill Gap gave up due to positioning for "
+ "%s in function %s\n",
+ sym->name, currFunc ? currFunc->name : "UNKNOWN"));
+ continue ;
}
- /* had to position more than once GIVE UP */
- if (pdone > 1) {
- /* UNDO all the changes we made to try this */
- sym->isspilt = 1;
- for (i=0; i < sym->nRegs ; i++ ) {
- sym->regs[i] = NULL;
- }
- freeAllRegs();
- D (fprintf (stderr, "Fill Gap gave up due to positioning for "
- "%s in function %s\n",
- sym->name, currFunc ? currFunc->name : "UNKNOWN"));
- continue ;
- }
- D (fprintf (stderr, "FILLED GAP for %s in function %s\n",
- sym->name, currFunc ? currFunc->name : "UNKNOWN"));
- _G.totRegAssigned = bitVectSetBit(_G.totRegAssigned,sym->key);
- sym->isspilt = sym->spillA = 0 ;
- sym->usl.spillLoc->allocreq--;
- sym->usl.spillLoc = NULL;
- freeAllRegs();
- change ++;
- }
- if (!change) break;
+ D (fprintf (stderr, "FILLED GAP for %s in function %s\n",
+ sym->name, currFunc ? currFunc->name : "UNKNOWN"));
+ _G.totRegAssigned = bitVectSetBit(_G.totRegAssigned,sym->key);
+ sym->isspilt = sym->spillA = 0 ;
+ sym->usl.spillLoc->allocreq--;
+ sym->usl.spillLoc = NULL;
+ freeAllRegs();
+ change ++;
+ }
+ if (!change) break;
}
}
for (j = 0; j < sym->nRegs; j++)
{
rumask = bitVectSetBit (rumask,
- sym->regs[j]->rIdx);
+ sym->regs[j]->rIdx);
}
return rumask;
if (ic->op == IFX)
{
rmask = bitVectUnion (rmask,
- ds390_rUmaskForOp (IC_COND (ic)));
+ ds390_rUmaskForOp (IC_COND (ic)));
goto ret;
}
if (ic->op == JUMPTABLE)
{
rmask = bitVectUnion (rmask,
- ds390_rUmaskForOp (IC_JTCOND (ic)));
+ ds390_rUmaskForOp (IC_JTCOND (ic)));
goto ret;
}
/* of all other cases */
if (IC_LEFT (ic))
rmask = bitVectUnion (rmask,
- ds390_rUmaskForOp (IC_LEFT (ic)));
+ ds390_rUmaskForOp (IC_LEFT (ic)));
if (IC_RIGHT (ic))
rmask = bitVectUnion (rmask,
- ds390_rUmaskForOp (IC_RIGHT (ic)));
+ ds390_rUmaskForOp (IC_RIGHT (ic)));
if (IC_RESULT (ic))
rmask = bitVectUnion (rmask,
- ds390_rUmaskForOp (IC_RESULT (ic)));
+ ds390_rUmaskForOp (IC_RESULT (ic)));
ret:
return rmask;
iCode *ic;
if (ebbs[i]->noPath &&
- (ebbs[i]->entryLabel != entryLabel &&
- ebbs[i]->entryLabel != returnLabel))
- continue;
+ (ebbs[i]->entryLabel != entryLabel &&
+ ebbs[i]->entryLabel != returnLabel))
+ continue;
/* for all instructions */
for (ic = ebbs[i]->sch; ic; ic = ic->next)
- {
-
- int j;
-
- if (SKIP_IC2 (ic) || !ic->rlive)
- continue;
-
- /* first mark the registers used in this
- instruction */
- ic->rUsed = regsUsedIniCode (ic);
- _G.funcrUsed = bitVectUnion (_G.funcrUsed, ic->rUsed);
-
- /* now create the register mask for those
- registers that are in use : this is a
- super set of ic->rUsed */
- ic->rMask = newBitVect (ds390_nRegs + 1);
-
- /* for all live Ranges alive at this point */
- for (j = 1; j < ic->rlive->size; j++)
- {
- symbol *sym;
- int k;
-
- /* if not alive then continue */
- if (!bitVectBitValue (ic->rlive, j))
- continue;
-
- /* find the live range we are interested in */
- if (!(sym = hTabItemWithKey (liveRanges, j)))
- {
- werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
- "createRegMask cannot find live range");
- exit (0);
- }
+ {
+
+ int j;
+
+ if (SKIP_IC2 (ic) || !ic->rlive)
+ continue;
+
+ /* first mark the registers used in this
+ instruction */
+ ic->rUsed = regsUsedIniCode (ic);
+ _G.funcrUsed = bitVectUnion (_G.funcrUsed, ic->rUsed);
+
+ /* now create the register mask for those
+ registers that are in use : this is a
+ super set of ic->rUsed */
+ ic->rMask = newBitVect (ds390_nRegs + 1);
+
+ /* for all live Ranges alive at this point */
+ for (j = 1; j < ic->rlive->size; j++)
+ {
+ symbol *sym;
+ int k;
+
+ /* if not alive then continue */
+ if (!bitVectBitValue (ic->rlive, j))
+ continue;
+
+ /* find the live range we are interested in */
+ if (!(sym = hTabItemWithKey (liveRanges, j)))
+ {
+ werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
+ "createRegMask cannot find live range");
+ fprintf(stderr, "\tmissing live range: key=%d\n", j);
+ exit (0);
+ }
#if 0
- /* special case for ruonly */
- if (sym->ruonly && sym->liveFrom != sym->liveTo) {
- int size = getSize(sym->type);
- int j = DPL_IDX;
- for (k = 0 ; k < size; k++ )
- ic->rMask = bitVectSetBit (ic->rMask, j++);
- continue ;
- }
+ /* special case for ruonly */
+ if (sym->ruonly && sym->liveFrom != sym->liveTo) {
+ int size = getSize(sym->type);
+ int j = DPL_IDX;
+ for (k = 0 ; k < size; k++ )
+ ic->rMask = bitVectSetBit (ic->rMask, j++);
+ continue ;
+ }
#endif
- /* if no register assigned to it */
- 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);
- }
- }
+ /* if no register assigned to it */
+ 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);
+ }
+ }
}
}
iCode *ic = sym->rematiCode;
*s = 0;
-
+
while (1)
{
/* if plus or minus print the right hand side */
if (ic->op == '+' || ic->op == '-')
- {
- SNPRINTF (s, sizeof(buffer) - strlen(buffer),
- "0x%04x %c ", (int) operandLitValue (IC_RIGHT (ic)),
- ic->op);
- s += strlen (s);
- ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
- continue;
- }
+ {
+ SNPRINTF (s, sizeof(buffer) - strlen(buffer),
+ "0x%04x %c ", (int) operandLitValue (IC_RIGHT (ic)),
+ ic->op);
+ s += strlen (s);
+ ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
+ continue;
+ }
+
/* cast then continue */
if (IS_CAST_ICODE(ic)) {
- ic = OP_SYMBOL (IC_RIGHT (ic))->rematiCode;
- continue;
+ ic = OP_SYMBOL (IC_RIGHT (ic))->rematiCode;
+ continue;
}
/* we reached the end */
- SNPRINTF (s, sizeof(buffer) - strlen(buffer),
- "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
+ SNPRINTF (s, sizeof(buffer) - strlen(buffer),
+ "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
break;
}
/* if used zero times then no registers needed */
if ((sym->liveTo - sym->liveFrom) == 0)
- continue;
+ continue;
/* if the live range is a temporary */
if (sym->isitmp)
- {
-
- /* if the type is marked as a conditional */
- if (sym->regType == REG_CND)
- continue;
-
- /* if used in return only then we don't
- need registers */
- if (sym->ruonly || sym->accuse)
- {
- if (IS_AGGREGATE (sym->type) || sym->isptr)
- sym->type = aggrToPtr (sym->type, FALSE);
- continue;
- }
-
- /* if the symbol has only one definition &
- that definition is a get_pointer */
- if (bitVectnBitsOn (sym->defs) == 1 &&
- (ic = hTabItemWithKey (iCodehTab,
- bitVectFirstBit (sym->defs))) &&
- POINTER_GET (ic) &&
- !IS_BITVAR (sym->etype) &&
- (aggrToPtrDclType (operandType (IC_LEFT (ic)), FALSE) == POINTER))
- {
-
- if (ptrPseudoSymSafe (sym, ic))
- {
- ptrPseudoSymConvert (sym, ic, rematStr (OP_SYMBOL (IC_LEFT (ic))));
- continue;
- }
-
- /* if in data space or idata space then try to
- allocate pointer register */
-
- }
-
- /* if not then we require registers */
- sym->nRegs = ((IS_AGGREGATE (sym->type) || sym->isptr) ?
- getSize (sym->type = aggrToPtr (sym->type, FALSE)) :
- getSize (sym->type));
-
- if (sym->nRegs > 4)
- {
- fprintf (stderr, "allocated more than 4 or 0 registers for type ");
- printTypeChain (sym->type, stderr);
- fprintf (stderr, "\n");
- }
-
- /* determine the type of register required */
- if (sym->nRegs == 1 &&
- IS_PTR (sym->type) &&
- sym->uptr)
- sym->regType = REG_PTR;
- else
- sym->regType = REG_GPR;
-
- }
+ {
+
+ /* if the type is marked as a conditional */
+ if (sym->regType == REG_CND)
+ continue;
+
+ /* if used in return only then we don't
+ need registers */
+ if (sym->ruonly || sym->accuse)
+ {
+ if (IS_AGGREGATE (sym->type) || sym->isptr)
+ sym->type = aggrToPtr (sym->type, FALSE);
+ continue;
+ }
+
+ /* if the symbol has only one definition &
+ that definition is a get_pointer */
+ if (bitVectnBitsOn (sym->defs) == 1 &&
+ (ic = hTabItemWithKey (iCodehTab,
+ bitVectFirstBit (sym->defs))) &&
+ POINTER_GET (ic) &&
+ !IS_BITVAR (sym->etype) &&
+ (aggrToPtrDclType (operandType (IC_LEFT (ic)), FALSE) == POINTER))
+ {
+
+ if (ptrPseudoSymSafe (sym, ic))
+ {
+ ptrPseudoSymConvert (sym, ic, rematStr (OP_SYMBOL (IC_LEFT (ic))));
+ continue;
+ }
+
+ /* if in data space or idata space then try to
+ allocate pointer register */
+
+ }
+
+ /* if not then we require registers */
+ sym->nRegs = ((IS_AGGREGATE (sym->type) || sym->isptr) ?
+ getSize (sym->type = aggrToPtr (sym->type, FALSE)) :
+ getSize (sym->type));
+
+ if (sym->nRegs > 4)
+ {
+ fprintf (stderr, "allocated more than 4 or 0 registers for type ");
+ printTypeChain (sym->type, stderr);
+ fprintf (stderr, "\n");
+ }
+
+ /* determine the type of register required */
+ if (sym->nRegs == 1 &&
+ IS_PTR (sym->type) &&
+ sym->uptr)
+ sym->regType = REG_PTR;
+ else
+ sym->regType = REG_GPR;
+
+ }
else
- /* for the first run we don't provide */
- /* registers for true symbols we will */
- /* see how things go */
- sym->nRegs = 0;
+ /* for the first run we don't provide */
+ /* registers for true symbols we will */
+ /* see how things go */
+ sym->nRegs = 0;
}
}
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;
- }
+ 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;
+ 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;
+ getSize (aggrToPtr (operandType (IC_LEFT (dic)), FALSE)) > 1)
+ return NULL;
if (POINTER_SET (dic) &&
- getSize (aggrToPtr (operandType (IC_RESULT (dic)), FALSE)) > 1)
- return NULL;
+ getSize (aggrToPtr (operandType (IC_RESULT (dic)), FALSE)) > 1)
+ return NULL;
- /* if any three is a true symbol in far space */
+ /* if any tree is a true symbol in far space */
if (IC_RESULT (dic) &&
- IS_TRUE_SYMOP (IC_RESULT (dic)) &&
- isOperandInFarSpace (IC_RESULT (dic)))
- return NULL;
+ 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;
+ 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;
+ 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;
- }
+ {
+ if ((dic->op == LEFT_OP ||
+ dic->op == RIGHT_OP ||
+ dic->op == '-') &&
+ IS_OP_LITERAL (IC_RIGHT (dic)))
+ return NULL;
+ else
+ return dic;
+ }
}
return NULL;
if (isOperandInFarSpace (IC_RESULT (ic)))
{
if ((dic = farSpacePackable (ic)))
- goto pack;
+ goto pack;
else
- return 0;
+ return 0;
}
#else
if (isOperandInFarSpace(IC_RESULT(ic)) && !farSpacePackable(ic)) {
}
#endif
- /* find the definition of iTempNN scanning backwards if we find a
- a use of the true symbol in before we find the definition then
+ /* find the definition of iTempNN scanning backwards if we find a
+ a use of the true symbol in before we find the definition then
we cannot */
for (dic = ic->prev; dic; dic = dic->prev)
{
/* if there is a function call then don't pack it */
if ((dic->op == CALL || dic->op == PCALL))
- {
- dic = NULL;
- break;
- }
+ {
+ dic = NULL;
+ break;
+ }
if (SKIP_IC2 (dic))
- continue;
+ continue;
if (IS_TRUE_SYMOP (IC_RESULT (dic)) &&
- IS_OP_VOLATILE (IC_RESULT (dic)))
- {
- dic = NULL;
- break;
- }
+ IS_OP_VOLATILE (IC_RESULT (dic)))
+ {
+ dic = NULL;
+ break;
+ }
if (IS_SYMOP (IC_RESULT (dic)) &&
- IC_RESULT (dic)->key == IC_RIGHT (ic)->key)
- {
- if (POINTER_SET (dic))
- dic = NULL;
+ IC_RESULT (dic)->key == IC_RIGHT (ic)->key)
+ {
+ if (POINTER_SET (dic))
+ dic = NULL;
- break;
- }
+ break;
+ }
if (IS_SYMOP (IC_RIGHT (dic)) &&
- (IC_RIGHT (dic)->key == IC_RESULT (ic)->key ||
- IC_RIGHT (dic)->key == IC_RIGHT (ic)->key))
- {
- dic = NULL;
- break;
- }
+ (IC_RIGHT (dic)->key == IC_RESULT (ic)->key ||
+ IC_RIGHT (dic)->key == IC_RIGHT (ic)->key))
+ {
+ dic = NULL;
+ break;
+ }
if (IS_SYMOP (IC_LEFT (dic)) &&
- (IC_LEFT (dic)->key == IC_RESULT (ic)->key ||
- IC_LEFT (dic)->key == IC_RIGHT (ic)->key))
- {
- dic = NULL;
- break;
- }
+ (IC_LEFT (dic)->key == IC_RESULT (ic)->key ||
+ IC_LEFT (dic)->key == IC_RIGHT (ic)->key))
+ {
+ dic = NULL;
+ break;
+ }
if (POINTER_SET (dic) &&
- IC_RESULT (dic)->key == IC_RESULT (ic)->key)
- {
- dic = NULL;
- break;
- }
+ IC_RESULT (dic)->key == IC_RESULT (ic)->key)
+ {
+ dic = NULL;
+ break;
+ }
}
if (!dic)
- return 0; /* did not find */
+ return 0; /* did not find */
/* if the result is on stack or iaccess then it must be
the same atleast one of the operands */
/* the operation has only one symbol
operator then we can pack */
if ((IC_LEFT (dic) && !IS_SYMOP (IC_LEFT (dic))) ||
- (IC_RIGHT (dic) && !IS_SYMOP (IC_RIGHT (dic))))
- goto pack;
+ (IC_RIGHT (dic) && !IS_SYMOP (IC_RIGHT (dic))))
+ goto pack;
if (!((IC_LEFT (dic) &&
- IC_RESULT (ic)->key == IC_LEFT (dic)->key) ||
- (IC_RIGHT (dic) &&
- IC_RESULT (ic)->key == IC_RIGHT (dic)->key)))
- return 0;
+ IC_RESULT (ic)->key == IC_LEFT (dic)->key) ||
+ (IC_RIGHT (dic) &&
+ IC_RESULT (ic)->key == IC_RIGHT (dic)->key)))
+ return 0;
}
pack:
/* found the definition */
{
OP_SYMBOL (IC_RESULT (dic))->liveFrom = dic->seq;
}
- /* delete from liverange table also
+ /* delete from liverange table also
delete from all the points inbetween and the new
one */
for (sic = dic; sic != ic; sic = sic->next)
{
bitVectUnSetBit (sic->rlive, IC_RESULT (ic)->key);
if (IS_ITEMP (IC_RESULT (dic)))
- bitVectSetBit (sic->rlive, IC_RESULT (dic)->key);
+ bitVectSetBit (sic->rlive, IC_RESULT (dic)->key);
}
remiCodeFromeBBlock (ebp, ic);
hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL);
OP_DEFS(IC_RESULT (dic))=bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
return 1;
-
}
-/*-----------------------------------------------------------------*/
+/*------------------------------------------------------------------*/
/* findAssignToSym : scanning backwards looks for first assig found */
-/*-----------------------------------------------------------------*/
+/*------------------------------------------------------------------*/
static iCode *
findAssignToSym (operand * op, iCode * ic)
{
iCode *dic;
+ /* This routine is used to find sequences like
+ iTempAA = FOO;
+ ...; (intervening ops don't use iTempAA or modify FOO)
+ blah = blah + iTempAA;
+
+ and eliminate the use of iTempAA, freeing up its register for
+ other uses.
+ */
+
for (dic = ic->prev; dic; dic = dic->prev)
{
/* if definition by assignment */
if (dic->op == '=' &&
- !POINTER_SET (dic) &&
- IC_RESULT (dic)->key == op->key
+ !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
- FALSE */
- if (!IS_SYMOP (IC_RIGHT (dic)))
- return NULL;
-
- /* 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;
- }
+ )
+ {
+
+ /* we are interested only if defined in far space */
+ /* or in stack space in case of + & - */
+
+ /* if assigned to a non-symbol then return
+ FALSE */
+ if (!IS_SYMOP (IC_RIGHT (dic)))
+ return NULL;
+
+ /* 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;
+ break;
- }
+ }
/* if we find an usage then we cannot delete it */
if (IC_LEFT (dic) && IC_LEFT (dic)->key == op->key)
- return NULL;
+ return NULL;
if (IC_RIGHT (dic) && IC_RIGHT (dic)->key == op->key)
- return NULL;
+ return NULL;
if (POINTER_SET (dic) && IC_RESULT (dic)->key == op->key)
- return NULL;
+ return NULL;
}
/* now make sure that the right side of 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;
+ if (IC_RESULT (sic) &&
+ IC_RESULT (sic)->key == IC_RIGHT (dic)->key)
+ return NULL;
}
return dic;
/*-----------------------------------------------------------------*/
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 */
iCode *sic;
if (!dic)
- goto right;
+ 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);
- sic->rlive = bitVectSetBit (sic->rlive, IC_RIGHT (dic)->key);
+ bitVectUnSetBit (sic->rlive, IC_LEFT (ic)->key);
+ sic->rlive = bitVectSetBit (sic->rlive, IC_RIGHT (dic)->key);
}
wassert(IS_SYMOP(IC_LEFT (ic)));
wassert(IS_SYMOP(IC_RIGHT (dic)));
IC_LEFT (ic)->operand.symOperand =
- IC_RIGHT (dic)->operand.symOperand;
+ IC_RIGHT (dic)->operand.symOperand;
OP_SYMBOL(IC_LEFT(ic))->liveTo = ic->seq;
IC_LEFT (ic)->key = IC_RIGHT (dic)->operand.symOperand->key;
bitVectUnSetBit(OP_SYMBOL(IC_RESULT(dic))->defs,dic->key);
iCode *sic;
if (!dic)
- return change;
+ 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;
- }
+ {
+ 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);
- sic->rlive = bitVectSetBit (sic->rlive, IC_RIGHT (dic)->key);
+ bitVectUnSetBit (sic->rlive, IC_RIGHT (ic)->key);
+ sic->rlive = bitVectSetBit (sic->rlive, IC_RIGHT (dic)->key);
}
wassert(IS_SYMOP(IC_RIGHT (ic)));
- wassert(IS_SYMOP(IC_RIGHT (dic)));
+ wassert(IS_SYMOP(IC_RIGHT (dic)));
IC_RIGHT (ic)->operand.symOperand =
- IC_RIGHT (dic)->operand.symOperand;
+ IC_RIGHT (dic)->operand.symOperand;
IC_RIGHT (ic)->key = IC_RIGHT (dic)->operand.symOperand->key;
OP_SYMBOL(IC_RIGHT(ic))->liveTo = ic->seq;
remiCodeFromeBBlock (ebp, dic);
/*-----------------------------------------------------------------*/
/* packRegsDPTRnuse - color live ranges that can go into extra DPTRS */
/*-----------------------------------------------------------------*/
-static int packRegsDPTRnuse( operand *op , int dptr)
+static int packRegsDPTRnuse( operand *op , unsigned dptr)
{
int i,key;
iCode *ic;
if (!IS_SYMOP(op) || !IS_ITEMP(op)) return 0;
- if (OP_SYMBOL(op)->remat || OP_SYMBOL(op)->ruonly || OP_SYMBOL(op)->dptr)
- return 0;
-
+ if (OP_SYMBOL(op)->remat || OP_SYMBOL(op)->ruonly || OP_SYMBOL(op)->dptr)
+ return 0;
+
/* first check if any overlapping liverange has already been
assigned to this DPTR */
if (OP_SYMBOL(op)->clashes) {
- for (i = 0 ; i < OP_SYMBOL(op)->clashes->size ; i++ ) {
- symbol *sym;
- if (bitVectBitValue(OP_SYMBOL(op)->clashes,i)) {
- sym = hTabItemWithKey(liveRanges,i);
- if (sym->dptr == dptr) return 0;
- }
- }
+ for (i = 0 ; i < OP_SYMBOL(op)->clashes->size ; i++ ) {
+ symbol *sym;
+ if (bitVectBitValue(OP_SYMBOL(op)->clashes,i)) {
+ sym = hTabItemWithKey(liveRanges,i);
+ if (sym->dptr == dptr) return 0;
+ }
+ }
}
-
+
/* future for more dptrs */
if (dptr > 1) {
- OP_SYMBOL(op)->dptr = dptr;
- return 1;
+ OP_SYMBOL(op)->dptr = dptr;
+ return 1;
}
/* DPTR1 is special since it is also used as a scratch by the backend .
so we walk thru the entire live range of this operand and make sure
- DPTR1 will not be used by the backed . The logic here is to find out if
- more than one operand in an icode is in far space then we give up : we
+ DPTR1 will not be used by the backed . The logic here is to find out if
+ more than one operand in an icode is in far space then we give up : we
don't keep it live across functions for now
*/
-
+
ic = hTabFirstItemWK(iCodeSeqhTab,OP_SYMBOL(op)->liveFrom);
for (; ic && ic->seq <= OP_SYMBOL(op)->liveTo;
- ic = hTabNextItem(iCodeSeqhTab,&key)) {
- int nfs =0;
-
- if (ic->op == CALL || ic->op == PCALL) return 0;
-
- /* single operand icode are ok */
- if (ic->op == IFX || ic->op == IPUSH)
- continue ;
-
- if (ic->op == SEND ) {
- if (ic->argreg != 1 ) return 0;
- else continue ;
- }
- /* two special cases first */
- if (POINTER_GET(ic) && !isOperandEqual(IC_LEFT(ic),op) && /* pointer get */
- !OP_SYMBOL(IC_LEFT(ic))->ruonly && /* with result in far space */
- (isOperandInFarSpace(IC_RESULT(ic)) &&
- !isOperandInReg(IC_RESULT(ic)))) {
- return 0;
- }
-
- if (POINTER_SET(ic) && !isOperandEqual(IC_RESULT(ic),op) && /* pointer set */
- !OP_SYMBOL(IC_RESULT(ic))->ruonly && /* with right in far space */
- (isOperandInFarSpace(IC_RIGHT(ic)) &&
- !isOperandInReg(IC_RIGHT(ic)))) {
- return 0;
- }
-
- if (IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) && /* if symbol operand */
- !isOperandEqual(IC_RESULT(ic),op) && /* not the same as this */
- ((isOperandInFarSpace(IC_RESULT(ic)) || /* in farspace or */
- OP_SYMBOL(IC_RESULT(ic))->onStack) && /* on the stack */
- !isOperandInReg(IC_RESULT(ic)))) { /* and not in register */
- nfs++;
- }
- /* same for left */
- if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic)) && /* if symbol operand */
- !isOperandEqual(IC_LEFT(ic),op) && /* not the same as this */
- ((isOperandInFarSpace(IC_LEFT(ic)) || /* in farspace or */
- OP_SYMBOL(IC_LEFT(ic))->onStack) && /* on the stack */
- !isOperandInReg(IC_LEFT(ic)))) { /* and not in register */
- nfs++;
- }
- /* same for right */
- if (IC_RIGHT(ic) && IS_SYMOP(IC_RIGHT(ic)) && /* if symbol operand */
- !isOperandEqual(IC_RIGHT(ic),op) && /* not the same as this */
- ((isOperandInFarSpace(IC_RIGHT(ic)) || /* in farspace or */
- OP_SYMBOL(IC_RIGHT(ic))->onStack) && /* on the stack */
- !isOperandInReg(IC_RIGHT(ic)))) { /* and not in register */
- nfs++;
- }
-
- // Check that no other ops in this range have been assigned to dptr1.
- // I don't understand why this is not caught by the first check, above.
- // But it isn't always, see bug 769624.
- if (IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) &&
- (OP_SYMBOL(IC_RESULT(ic))->dptr == 1))
- {
- //fprintf(stderr, "dptr1 already in use in live range #1\n");
- return 0;
- }
-
- if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic)) &&
- (OP_SYMBOL(IC_LEFT(ic))->dptr == 1))
- {
- //fprintf(stderr, "dptr1 already in use in live range # 2\n");
- return 0;
- }
-
- if (IC_RIGHT(ic) && IS_SYMOP(IC_RIGHT(ic)) &&
- (OP_SYMBOL(IC_RIGHT(ic))->dptr == 1))
- {
- //fprintf(stderr, "dptr1 already in use in live range # 3\n");
- return 0;
- }
-
- if (nfs && IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) &&
- OP_SYMBOL(IC_RESULT(ic))->ruonly) return 0;
-
- if (nfs > 1) return 0;
+ ic = hTabNextItem(iCodeSeqhTab,&key)) {
+ int nfs =0;
+
+ if (ic->op == CALL || ic->op == PCALL) return 0;
+
+ /* single operand icode are ok */
+ if (ic->op == IFX || ic->op == IPUSH)
+ continue ;
+
+ if (ic->op == SEND ) {
+ if (ic->argreg != 1 ) return 0;
+ else continue ;
+ }
+ /* two special cases first */
+ if (POINTER_GET(ic) && !isOperandEqual(IC_LEFT(ic),op) && /* pointer get */
+ !OP_SYMBOL(IC_LEFT(ic))->ruonly && /* with result in far space */
+ (isOperandInFarSpace(IC_RESULT(ic)) &&
+ !isOperandInReg(IC_RESULT(ic)))) {
+ return 0;
+ }
+
+ if (POINTER_SET(ic) && !isOperandEqual(IC_RESULT(ic),op) && /* pointer set */
+ !OP_SYMBOL(IC_RESULT(ic))->ruonly && /* with right in far space */
+ (isOperandInFarSpace(IC_RIGHT(ic)) &&
+ !isOperandInReg(IC_RIGHT(ic)))) {
+ return 0;
+ }
+
+ if (IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) && /* if symbol operand */
+ !isOperandEqual(IC_RESULT(ic),op) && /* not the same as this */
+ ((isOperandInFarSpace(IC_RESULT(ic)) || /* in farspace or */
+ OP_SYMBOL(IC_RESULT(ic))->onStack) && /* on the stack */
+ !isOperandInReg(IC_RESULT(ic)))) { /* and not in register */
+ nfs++;
+ }
+ /* same for left */
+ if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic)) && /* if symbol operand */
+ !isOperandEqual(IC_LEFT(ic),op) && /* not the same as this */
+ ((isOperandInFarSpace(IC_LEFT(ic)) || /* in farspace or */
+ OP_SYMBOL(IC_LEFT(ic))->onStack) && /* on the stack */
+ !isOperandInReg(IC_LEFT(ic)))) { /* and not in register */
+ nfs++;
+ }
+ /* same for right */
+ if (IC_RIGHT(ic) && IS_SYMOP(IC_RIGHT(ic)) && /* if symbol operand */
+ !isOperandEqual(IC_RIGHT(ic),op) && /* not the same as this */
+ ((isOperandInFarSpace(IC_RIGHT(ic)) || /* in farspace or */
+ OP_SYMBOL(IC_RIGHT(ic))->onStack) && /* on the stack */
+ !isOperandInReg(IC_RIGHT(ic)))) { /* and not in register */
+ nfs++;
+ }
+
+ // Check that no other ops in this range have been assigned to dptr1.
+ // I don't understand why this is not caught by the first check, above.
+ // But it isn't always, see bug 769624.
+ if (IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) &&
+ (OP_SYMBOL(IC_RESULT(ic))->dptr == 1))
+ {
+ //fprintf(stderr, "dptr1 already in use in live range #1\n");
+ return 0;
+ }
+
+ if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic)) &&
+ (OP_SYMBOL(IC_LEFT(ic))->dptr == 1))
+ {
+ //fprintf(stderr, "dptr1 already in use in live range # 2\n");
+ return 0;
+ }
+
+ if (IC_RIGHT(ic) && IS_SYMOP(IC_RIGHT(ic)) &&
+ (OP_SYMBOL(IC_RIGHT(ic))->dptr == 1))
+ {
+ //fprintf(stderr, "dptr1 already in use in live range # 3\n");
+ return 0;
+ }
+
+ if (nfs && IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) &&
+ OP_SYMBOL(IC_RESULT(ic))->ruonly) return 0;
+
+ if (nfs > 1) return 0;
}
OP_SYMBOL(op)->dptr = dptr;
return 1;
symbol *sym;
iCode *ic, *dic;
sym_link *type, *etype;
-
+
if (!IS_SYMOP(op) || !IS_ITEMP(op)) return NULL;
- if (OP_SYMBOL(op)->remat || OP_SYMBOL(op)->ruonly) return NULL;
+ if (OP_SYMBOL(op)->remat || OP_SYMBOL(op)->ruonly) return NULL;
/* first check if any overlapping liverange has already been
assigned to DPTR */
if (OP_SYMBOL(op)->clashes) {
- for (i = 0 ; i < OP_SYMBOL(op)->clashes->size ; i++ ) {
- if (bitVectBitValue(OP_SYMBOL(op)->clashes,i)) {
- sym = hTabItemWithKey(liveRanges,i);
- if (sym->ruonly) return NULL ;
- }
- }
+ for (i = 0 ; i < OP_SYMBOL(op)->clashes->size ; i++ ) {
+ if (bitVectBitValue(OP_SYMBOL(op)->clashes,i)) {
+ sym = hTabItemWithKey(liveRanges,i);
+ if (sym->ruonly) return NULL ;
+ }
+ }
}
/* no then go thru this guys live range */
dic = ic = hTabFirstItemWK(iCodeSeqhTab,OP_SYMBOL(op)->liveFrom);
for (; ic && ic->seq <= OP_SYMBOL(op)->liveTo;
- ic = hTabNextItem(iCodeSeqhTab,&key)) {
-
- if (SKIP_IC3(ic)) continue;
-
- /* if PCALL cannot be sure give up */
- if (ic->op == PCALL) return NULL;
-
- /* if SEND & not the first parameter then giveup */
- if (ic->op == SEND && ic->argreg != 1 &&
- ((isOperandInFarSpace(IC_LEFT(ic)) && !isOperandInReg(IC_LEFT(ic))) ||
- isOperandEqual(op,IC_LEFT(ic)))) return NULL;
-
- /* if CALL then make sure it is VOID || return value not used
- or the return value is assigned to this one */
- if (ic->op == CALL) {
- if (OP_SYMBOL(IC_RESULT(ic))->liveTo ==
- OP_SYMBOL(IC_RESULT(ic))->liveFrom) continue ;
- etype = getSpec(type = operandType(IC_RESULT(ic)));
- if (getSize(type) == 0 || isOperandEqual(op,IC_RESULT(ic)))
- continue ;
- return NULL ;
- }
-
- /* special case of add with a [remat] */
- if (ic->op == '+' &&
- OP_SYMBOL(IC_LEFT(ic))->remat &&
- (isOperandInFarSpace(IC_RIGHT(ic)) &&
- !isOperandInReg(IC_RIGHT(ic)))) return NULL ;
-
- /* special cases */
- /* pointerGet */
- if (POINTER_GET(ic) && !isOperandEqual(IC_LEFT(ic),op) &&
- getSize(operandType(IC_LEFT(ic))) > 1 ) return NULL ;
-
- /* pointerSet */
- if (POINTER_SET(ic) && !isOperandEqual(IC_RESULT(ic),op) &&
- getSize(operandType(IC_RESULT(ic))) > 1 ) return NULL;
-
- /* conditionals can destroy 'b' - make sure B wont
- be used in this one*/
- if ((IS_CONDITIONAL(ic) || ic->op == '*' || ic->op == '/' ||
- ic->op == LEFT_OP || ic->op == RIGHT_OP ) &&
- getSize(operandType(op)) > 3) return NULL;
-
- /* if this is a cast to a bigger type */
- if (ic->op==CAST) {
- if (!IS_PTR(OP_SYM_TYPE(IC_RESULT(ic))) &&
- getSize(OP_SYM_TYPE(IC_RESULT(ic))) >
- getSize(OP_SYM_TYPE(IC_RIGHT(ic)))) {
- return 0;
- }
- }
-
- /* general case */
- if (IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) &&
- !isOperandEqual(IC_RESULT(ic),op) &&
- ( ( ( isOperandInFarSpace(IC_RESULT(ic)) || OP_SYMBOL(IC_RESULT(ic))->onStack) &&
- !isOperandInReg(IC_RESULT(ic))) ||
- OP_SYMBOL(IC_RESULT(ic))->ruonly)) return NULL;
-
- if (IC_RIGHT(ic) && IS_SYMOP(IC_RIGHT(ic)) &&
- !isOperandEqual(IC_RIGHT(ic),op) &&
- (OP_SYMBOL(IC_RIGHT(ic))->liveTo >= ic->seq ||
- IS_TRUE_SYMOP(IC_RIGHT(ic)) ||
- OP_SYMBOL(IC_RIGHT(ic))->ruonly) &&
- ( ( isOperandInFarSpace(IC_RIGHT(ic)) || OP_SYMBOL(IC_RIGHT(ic))->onStack) &&
- !isOperandInReg(IC_RIGHT(ic))) ) return NULL;
-
- if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic)) &&
- !isOperandEqual(IC_LEFT(ic),op) &&
- (OP_SYMBOL(IC_LEFT(ic))->liveTo >= ic->seq ||
- IS_TRUE_SYMOP(IC_LEFT(ic)) ||
- OP_SYMBOL(IC_LEFT(ic))->ruonly) &&
- ( ( isOperandInFarSpace(IC_LEFT(ic)) || OP_SYMBOL(IC_LEFT(ic))->onStack) &&
- !isOperandInReg(IC_LEFT(ic))) ) return NULL;
-
- if (IC_LEFT(ic) && IC_RIGHT(ic) &&
- IS_ITEMP(IC_LEFT(ic)) && IS_ITEMP(IC_RIGHT(ic)) &&
- (isOperandInFarSpace(IC_LEFT(ic)) && !isOperandInReg(IC_LEFT(ic))) &&
- (isOperandInFarSpace(IC_RIGHT(ic)) && !isOperandInReg(IC_RIGHT(ic))))
- return NULL;
+ ic = hTabNextItem(iCodeSeqhTab,&key)) {
+
+ if (SKIP_IC3(ic)) continue;
+
+ /* if PCALL cannot be sure give up */
+ if (ic->op == PCALL) return NULL;
+
+ /* if SEND & not the first parameter then giveup */
+ if (ic->op == SEND && ic->argreg != 1 &&
+ ((isOperandInFarSpace(IC_LEFT(ic)) && !isOperandInReg(IC_LEFT(ic))) ||
+ isOperandEqual(op,IC_LEFT(ic)))) return NULL;
+
+ /* if CALL then make sure it is VOID || return value not used
+ or the return value is assigned to this one */
+ if (ic->op == CALL) {
+ if (OP_SYMBOL(IC_RESULT(ic))->liveTo ==
+ OP_SYMBOL(IC_RESULT(ic))->liveFrom) continue ;
+ etype = getSpec(type = operandType(IC_RESULT(ic)));
+ if (getSize(type) == 0 || isOperandEqual(op,IC_RESULT(ic)))
+ continue ;
+ return NULL ;
+ }
+
+ /* special case of add with a [remat] */
+ if (ic->op == '+' &&
+ OP_SYMBOL(IC_LEFT(ic))->remat &&
+ (isOperandInFarSpace(IC_RIGHT(ic)) &&
+ !isOperandInReg(IC_RIGHT(ic)))) return NULL ;
+
+ /* special cases */
+ /* pointerGet */
+ if (POINTER_GET(ic) && !isOperandEqual(IC_LEFT(ic),op) &&
+ getSize(operandType(IC_LEFT(ic))) > 1 ) return NULL ;
+
+ /* pointerSet */
+ if (POINTER_SET(ic) && !isOperandEqual(IC_RESULT(ic),op) &&
+ getSize(operandType(IC_RESULT(ic))) > 1 ) return NULL;
+
+ /* conditionals can destroy 'b' - make sure B wont
+ be used in this one*/
+ if ((IS_CONDITIONAL(ic) || ic->op == '*' || ic->op == '/' ||
+ ic->op == LEFT_OP || ic->op == RIGHT_OP ) &&
+ getSize(operandType(op)) > 3) return NULL;
+
+ /* if this is a cast to a bigger type */
+ if (ic->op==CAST) {
+ if (!IS_PTR(OP_SYM_TYPE(IC_RESULT(ic))) &&
+ getSize(OP_SYM_TYPE(IC_RESULT(ic))) >
+ getSize(OP_SYM_TYPE(IC_RIGHT(ic)))) {
+ return 0;
+ }
+ }
+
+ /* general case */
+ if (IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) &&
+ !isOperandEqual(IC_RESULT(ic),op) &&
+ ( ( ( isOperandInFarSpace(IC_RESULT(ic)) || OP_SYMBOL(IC_RESULT(ic))->onStack) &&
+ !isOperandInReg(IC_RESULT(ic))) ||
+ OP_SYMBOL(IC_RESULT(ic))->ruonly)) return NULL;
+
+ if (IC_RIGHT(ic) && IS_SYMOP(IC_RIGHT(ic)) &&
+ !isOperandEqual(IC_RIGHT(ic),op) &&
+ (OP_SYMBOL(IC_RIGHT(ic))->liveTo >= ic->seq ||
+ IS_TRUE_SYMOP(IC_RIGHT(ic)) ||
+ OP_SYMBOL(IC_RIGHT(ic))->ruonly) &&
+ ( ( isOperandInFarSpace(IC_RIGHT(ic)) || OP_SYMBOL(IC_RIGHT(ic))->onStack) &&
+ !isOperandInReg(IC_RIGHT(ic))) ) return NULL;
+
+ if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic)) &&
+ !isOperandEqual(IC_LEFT(ic),op) &&
+ (OP_SYMBOL(IC_LEFT(ic))->liveTo >= ic->seq ||
+ IS_TRUE_SYMOP(IC_LEFT(ic)) ||
+ OP_SYMBOL(IC_LEFT(ic))->ruonly) &&
+ ( ( isOperandInFarSpace(IC_LEFT(ic)) || OP_SYMBOL(IC_LEFT(ic))->onStack) &&
+ !isOperandInReg(IC_LEFT(ic))) ) return NULL;
+
+ if (IC_LEFT(ic) && IC_RIGHT(ic) &&
+ IS_ITEMP(IC_LEFT(ic)) && IS_ITEMP(IC_RIGHT(ic)) &&
+ (isOperandInFarSpace(IC_LEFT(ic)) && !isOperandInReg(IC_LEFT(ic))) &&
+ (isOperandInFarSpace(IC_RIGHT(ic)) && !isOperandInReg(IC_RIGHT(ic))))
+ return NULL;
}
OP_SYMBOL(op)->ruonly = 1;
if (OP_SYMBOL(op)->usl.spillLoc) {
- if (OP_SYMBOL(op)->spillA)
- OP_SYMBOL(op)->usl.spillLoc->allocreq--;
- OP_SYMBOL(op)->usl.spillLoc = NULL;
+ if (OP_SYMBOL(op)->spillA)
+ OP_SYMBOL(op)->usl.spillLoc->allocreq--;
+ OP_SYMBOL(op)->usl.spillLoc = NULL;
}
return dic;
}
sym_link *rtype = getSpec (operandType (IC_RIGHT (ic)));
/* bitwise operations are considered optimizable
- under the following conditions (Jean-Louis VERN)
+ under the following conditions (Jean-Louis VERN)
x & lit
bit & bit
bit | bit
bit | x
*/
- if ( IS_LITERAL (rtype) ||
+ if (IS_LITERAL (rtype) ||
(IS_BITVAR (ltype) && IN_BITSPACE (SPEC_OCLS (ltype))))
return TRUE;
else
/* and the usage immediately follows this iCode */
if (!(uic = hTabItemWithKey (iCodehTab,
- bitVectFirstBit (OP_USES (IC_RESULT (ic))))))
+ bitVectFirstBit (OP_USES (IC_RESULT (ic))))))
return;
if (ic->next != uic)
uic->op != RIGHT_OP)
return;
- /* if used in ^ operation then make sure right is not a
+ /* if used in ^ operation then make sure right is not a
literl */
if (uic->op == '^' && isOperandLiteral (IC_RIGHT (uic)))
return;
if (IC_LEFT (uic)->key == IC_RESULT (ic)->key &&
(IS_ITEMP (IC_RIGHT (uic)) ||
(IS_TRUE_SYMOP (IC_RIGHT (uic)) &&
- !OP_SYMBOL (IC_RIGHT (uic))->onStack)))
+ !OP_SYMBOL (IC_RIGHT (uic))->onStack)))
goto accuse;
if (IC_RIGHT (uic)->key == IC_RESULT (ic)->key &&
(IS_ITEMP (IC_LEFT (uic)) ||
(IS_TRUE_SYMOP (IC_LEFT (uic)) &&
- !OP_SYMBOL (IC_LEFT (uic))->onStack)))
+ !OP_SYMBOL (IC_LEFT (uic))->onStack)))
goto accuse;
return;
accuse:
OP_SYMBOL (IC_RESULT (ic))->accuse = 1;
-
}
/*-----------------------------------------------------------------*/
/* find the definition */
if (!(dic = hTabItemWithKey (iCodehTab,
- bitVectFirstBit (OP_DEFS (IC_LEFT (ic))))))
+ bitVectFirstBit (OP_DEFS (IC_LEFT (ic))))))
return;
if (dic->op != '=' || POINTER_SET (dic))
return;
-
+
if (dic->eBBlockNum != ic->eBBlockNum) return ;
/* make sure the right side does not have any definitions
inbetween */
dbv = OP_DEFS(IC_RIGHT(dic));
for (lic = ic; lic && lic != dic ; lic = lic->prev) {
- if (bitVectBitValue(dbv,lic->key)) return ;
+ if (bitVectBitValue(dbv,lic->key)) return ;
}
/* make sure they have the same type */
if (IS_SPEC(operandType(IC_LEFT(ic))))
sym_link *ditype=operandType(IC_RIGHT(dic));
if (SPEC_USIGN(itype)!=SPEC_USIGN(ditype) ||
- SPEC_LONG(itype)!=SPEC_LONG(ditype))
+ SPEC_LONG(itype)!=SPEC_LONG(ditype))
return;
}
/* extend the live range of replaced operand if needed */
if (OP_SYMBOL(IC_RIGHT(dic))->liveTo < OP_SYMBOL(IC_LEFT(ic))->liveTo) {
- OP_SYMBOL(IC_RIGHT(dic))->liveTo = OP_SYMBOL(IC_LEFT(ic))->liveTo;
- OP_SYMBOL(IC_RIGHT(dic))->clashes =
- bitVectUnion(OP_SYMBOL(IC_RIGHT(dic))->clashes,
- OP_SYMBOL(IC_LEFT(ic))->clashes);
+ OP_SYMBOL(IC_RIGHT(dic))->liveTo = OP_SYMBOL(IC_LEFT(ic))->liveTo;
+ OP_SYMBOL(IC_RIGHT(dic))->clashes =
+ bitVectUnion(OP_SYMBOL(IC_RIGHT(dic))->clashes,
+ OP_SYMBOL(IC_LEFT(ic))->clashes);
}
for (lic = ic; lic && lic != dic; lic = lic->prev)
{
bitVectUnSetBit (lic->rlive, IC_LEFT (ic)->key);
if (IS_ITEMP (IC_RIGHT (dic)))
- bitVectSetBit (lic->rlive, IC_RIGHT (dic)->key);
+ bitVectSetBit (lic->rlive, IC_RIGHT (dic)->key);
}
/* we now we know that it has one & only one def & use
and the that the definition is an assignment */
/* .... */
/* TrueSym := iTempNN:1 */
for (ic = ebp->sch; ic; ic = ic->next)
- {
-
-
- /* find assignment of the form TrueSym := iTempNN:1 */
- if (ic->op == '=' && !POINTER_SET (ic))
- change += packRegsForAssign (ic, ebp);
- }
+ {
+ /* find assignment of the form TrueSym := iTempNN:1 */
+ if (ic->op == '=' && !POINTER_SET (ic))
+ change += packRegsForAssign (ic, ebp);
+ }
if (!change)
- break;
+ break;
}
for (ic = ebp->sch; ic; ic = ic->next)
{
-
- /* if this is an itemp & result of a address of a true sym
+ /* if this is an itemp & result of an address of a true sym
then mark this as rematerialisable */
if (ic->op == ADDRESS_OF &&
- IS_ITEMP (IC_RESULT (ic)) &&
- IS_TRUE_SYMOP (IC_LEFT (ic)) &&
- bitVectnBitsOn (OP_DEFS (IC_RESULT (ic))) == 1 &&
- !OP_SYMBOL (IC_LEFT (ic))->onStack)
- {
-
- OP_SYMBOL (IC_RESULT (ic))->remat = 1;
- OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
- OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
-
- }
-
- /* if this is an itemp & used as a pointer
- & assigned to a literal then remat */
- if (IS_ASSIGN_ICODE(ic) &&
- IS_ITEMP(IC_RESULT(ic)) &&
- bitVectnBitsOn (OP_DEFS (IC_RESULT (ic))) == 1 &&
- isOperandLiteral(IC_RIGHT(ic)))
- {
- OP_SYMBOL (IC_RESULT (ic))->remat = 1;
- OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
- OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
- }
+ IS_ITEMP (IC_RESULT (ic)) &&
+ IS_TRUE_SYMOP (IC_LEFT (ic)) &&
+ bitVectnBitsOn (OP_DEFS (IC_RESULT (ic))) == 1 &&
+ !OP_SYMBOL (IC_LEFT (ic))->onStack)
+ {
+
+ OP_SYMBOL (IC_RESULT (ic))->remat = 1;
+ OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
+ OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
+
+ }
+
+ /* if this is an itemp & used as a pointer
+ & assigned to a literal then remat */
+ if (IS_ASSIGN_ICODE(ic) &&
+ IS_ITEMP(IC_RESULT(ic)) &&
+ bitVectnBitsOn (OP_DEFS (IC_RESULT (ic))) == 1 &&
+ isOperandLiteral(IC_RIGHT(ic)))
+ {
+ OP_SYMBOL (IC_RESULT (ic))->remat = 1;
+ OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
+ OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
+ }
/* if straight assignment then carry remat flag if
this is the only definition */
if (ic->op == '=' &&
- !POINTER_SET (ic) &&
- IS_SYMOP (IC_RIGHT (ic)) &&
- OP_SYMBOL (IC_RIGHT (ic))->remat &&
- !IS_CAST_ICODE(OP_SYMBOL (IC_RIGHT (ic))->rematiCode) &&
- bitVectnBitsOn (OP_SYMBOL (IC_RESULT (ic))->defs) <= 1)
- {
-
- OP_SYMBOL (IC_RESULT (ic))->remat =
- OP_SYMBOL (IC_RIGHT (ic))->remat;
- OP_SYMBOL (IC_RESULT (ic))->rematiCode =
- OP_SYMBOL (IC_RIGHT (ic))->rematiCode;
- }
-
+ !POINTER_SET (ic) &&
+ IS_SYMOP (IC_RIGHT (ic)) &&
+ OP_SYMBOL (IC_RIGHT (ic))->remat &&
+ !IS_CAST_ICODE(OP_SYMBOL (IC_RIGHT (ic))->rematiCode) &&
+ bitVectnBitsOn (OP_SYMBOL (IC_RESULT (ic))->defs) <= 1)
+ {
+
+ OP_SYMBOL (IC_RESULT (ic))->remat =
+ OP_SYMBOL (IC_RIGHT (ic))->remat;
+ OP_SYMBOL (IC_RESULT (ic))->rematiCode =
+ OP_SYMBOL (IC_RIGHT (ic))->rematiCode;
+ }
+
/* if cast to a generic pointer & the pointer being
- cast is remat, then we can remat this cast as well */
- if (ic->op == CAST &&
- IS_SYMOP(IC_RIGHT(ic)) &&
- !OP_SYMBOL(IC_RESULT(ic))->isreqv &&
- OP_SYMBOL(IC_RIGHT(ic))->remat ) {
- sym_link *to_type = operandType(IC_LEFT(ic));
- sym_link *from_type = operandType(IC_RIGHT(ic));
- if (IS_GENPTR(to_type) && IS_PTR(from_type)) {
- OP_SYMBOL (IC_RESULT (ic))->remat = 1;
- OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
- OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
- }
+ cast is remat, then we can remat this cast as well */
+ if (ic->op == CAST &&
+ IS_SYMOP(IC_RIGHT(ic)) &&
+ !OP_SYMBOL(IC_RESULT(ic))->isreqv &&
+ OP_SYMBOL(IC_RIGHT(ic))->remat ) {
+ sym_link *to_type = operandType(IC_LEFT(ic));
+ sym_link *from_type = operandType(IC_RIGHT(ic));
+ if (IS_GENPTR(to_type) && IS_PTR(from_type)) {
+ OP_SYMBOL (IC_RESULT (ic))->remat = 1;
+ OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
+ OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
+ }
}
- /* if this is a +/- operation with a rematerizable
+ /* if this is a +/- operation with a rematerizable
then mark this as rematerializable as well */
if ((ic->op == '+' || ic->op == '-') &&
- (IS_SYMOP (IC_LEFT (ic)) &&
- IS_ITEMP (IC_RESULT (ic)) &&
- OP_SYMBOL (IC_LEFT (ic))->remat &&
- (!IS_SYMOP (IC_RIGHT (ic)) || !IS_CAST_ICODE(OP_SYMBOL (IC_RIGHT (ic))->rematiCode)) &&
- bitVectnBitsOn (OP_DEFS (IC_RESULT (ic))) == 1 &&
- IS_OP_LITERAL (IC_RIGHT (ic))))
- {
-
- //int i = operandLitValue(IC_RIGHT(ic));
- OP_SYMBOL (IC_RESULT (ic))->remat = 1;
- OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
- OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
- }
+ (IS_SYMOP (IC_LEFT (ic)) &&
+ IS_ITEMP (IC_RESULT (ic)) &&
+ OP_SYMBOL (IC_LEFT (ic))->remat &&
+ (!IS_SYMOP (IC_RIGHT (ic)) || !IS_CAST_ICODE(OP_SYMBOL (IC_RIGHT (ic))->rematiCode)) &&
+ bitVectnBitsOn (OP_DEFS (IC_RESULT (ic))) == 1 &&
+ IS_OP_LITERAL (IC_RIGHT (ic))))
+ {
+
+ //int i = operandLitValue(IC_RIGHT(ic));
+ OP_SYMBOL (IC_RESULT (ic))->remat = 1;
+ OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
+ OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
+ }
/* mark the pointer usages */
if (POINTER_SET (ic) && IS_SYMOP (IC_RESULT (ic)))
- OP_SYMBOL (IC_RESULT (ic))->uptr = 1;
+ OP_SYMBOL (IC_RESULT (ic))->uptr = 1;
if (POINTER_GET (ic) && IS_SYMOP (IC_LEFT (ic)))
- OP_SYMBOL (IC_LEFT (ic))->uptr = 1;
+ OP_SYMBOL (IC_LEFT (ic))->uptr = 1;
if (ic->op == RETURN && IS_SYMOP (IC_LEFT(ic)))
- OP_SYMBOL (IC_LEFT (ic))->uptr = 1;
+ OP_SYMBOL (IC_LEFT (ic))->uptr = 1;
if (ic->op == RECEIVE && ic->argreg == 1 &&
- IS_SYMOP (IC_RESULT (ic)) &&
- getSize (operandType(IC_RESULT(ic))) <= 3)
- OP_SYMBOL (IC_RESULT(ic))->uptr = 1;
+ IS_SYMOP (IC_RESULT (ic)) &&
+ getSize (operandType(IC_RESULT(ic))) <= 3)
+ OP_SYMBOL (IC_RESULT(ic))->uptr = 1;
if (ic->op == SEND && ic->argreg == 1 &&
- IS_SYMOP(IC_LEFT(ic)) &&
- getSize (aggrToPtr(operandType(IC_LEFT(ic)),FALSE)) <= 3)
- OP_SYMBOL (IC_LEFT(ic))->uptr = 1;
+ IS_SYMOP(IC_LEFT(ic)) &&
+ getSize (aggrToPtr(operandType(IC_LEFT(ic)),FALSE)) <= 3)
+ OP_SYMBOL (IC_LEFT(ic))->uptr = 1;
if (!SKIP_IC2 (ic))
- {
- /* if we are using a symbol on the stack
- then we should say ds390_ptrRegReq */
- if (options.useXstack && ic->parmPush
- && (ic->op == IPUSH || ic->op == IPOP))
- ds390_ptrRegReq++;
- if (ic->op == IFX && IS_SYMOP (IC_COND (ic)))
- ds390_ptrRegReq += ((OP_SYMBOL (IC_COND (ic))->onStack ? !options.stack10bit : 0) +
- OP_SYMBOL (IC_COND (ic))->iaccess +
- (SPEC_OCLS(OP_SYMBOL (IC_COND (ic))->etype) == idata));
- else if (ic->op == JUMPTABLE && IS_SYMOP (IC_JTCOND (ic)))
- ds390_ptrRegReq += ((OP_SYMBOL (IC_JTCOND (ic))->onStack ? !options.stack10bit : 0) +
- OP_SYMBOL (IC_JTCOND (ic))->iaccess +
- (SPEC_OCLS(OP_SYMBOL (IC_JTCOND (ic))->etype) == idata));
- else
- {
- if (IS_SYMOP (IC_LEFT (ic)))
- ds390_ptrRegReq += ((OP_SYMBOL (IC_LEFT (ic))->onStack ? !options.stack10bit : 0) +
- OP_SYMBOL (IC_LEFT (ic))->iaccess +
- (SPEC_OCLS(OP_SYMBOL (IC_LEFT (ic))->etype) == idata));
- if (IS_SYMOP (IC_RIGHT (ic)))
- ds390_ptrRegReq += ((OP_SYMBOL (IC_RIGHT (ic))->onStack ? !options.stack10bit : 0) +
- OP_SYMBOL (IC_RIGHT (ic))->iaccess +
- (SPEC_OCLS(OP_SYMBOL (IC_RIGHT (ic))->etype) == idata));
- if (IS_SYMOP (IC_RESULT (ic)))
- ds390_ptrRegReq += ((OP_SYMBOL (IC_RESULT (ic))->onStack ? !options.stack10bit : 0) +
- OP_SYMBOL (IC_RESULT (ic))->iaccess +
- (SPEC_OCLS(OP_SYMBOL (IC_RESULT (ic))->etype) == idata));
- }
- }
+ {
+ /* if we are using a symbol on the stack
+ then we should say ds390_ptrRegReq */
+ if (options.useXstack && ic->parmPush
+ && (ic->op == IPUSH || ic->op == IPOP))
+ ds390_ptrRegReq++;
+ if (ic->op == IFX && IS_SYMOP (IC_COND (ic)))
+ ds390_ptrRegReq += ((OP_SYMBOL (IC_COND (ic))->onStack ? !options.stack10bit : 0) +
+ OP_SYMBOL (IC_COND (ic))->iaccess +
+ (SPEC_OCLS(OP_SYMBOL (IC_COND (ic))->etype) == idata));
+ else if (ic->op == JUMPTABLE && IS_SYMOP (IC_JTCOND (ic)))
+ ds390_ptrRegReq += ((OP_SYMBOL (IC_JTCOND (ic))->onStack ? !options.stack10bit : 0) +
+ OP_SYMBOL (IC_JTCOND (ic))->iaccess +
+ (SPEC_OCLS(OP_SYMBOL (IC_JTCOND (ic))->etype) == idata));
+ else
+ {
+ if (IS_SYMOP (IC_LEFT (ic)))
+ ds390_ptrRegReq += ((OP_SYMBOL (IC_LEFT (ic))->onStack ? !options.stack10bit : 0) +
+ OP_SYMBOL (IC_LEFT (ic))->iaccess +
+ (SPEC_OCLS(OP_SYMBOL (IC_LEFT (ic))->etype) == idata));
+ if (IS_SYMOP (IC_RIGHT (ic)))
+ ds390_ptrRegReq += ((OP_SYMBOL (IC_RIGHT (ic))->onStack ? !options.stack10bit : 0) +
+ OP_SYMBOL (IC_RIGHT (ic))->iaccess +
+ (SPEC_OCLS(OP_SYMBOL (IC_RIGHT (ic))->etype) == idata));
+ if (IS_SYMOP (IC_RESULT (ic)))
+ ds390_ptrRegReq += ((OP_SYMBOL (IC_RESULT (ic))->onStack ? !options.stack10bit : 0) +
+ OP_SYMBOL (IC_RESULT (ic))->iaccess +
+ (SPEC_OCLS(OP_SYMBOL (IC_RESULT (ic))->etype) == idata));
+ }
+ }
/* if the condition of an if instruction
is defined in the previous instruction and
- this is the only usage then
+ this is the only usage then
mark the itemp as a conditional */
if ((IS_CONDITIONAL (ic) ||
- (IS_BITWISE_OP(ic) && isBitwiseOptimizable (ic))) &&
- ic->next && ic->next->op == IFX &&
- bitVectnBitsOn (OP_USES(IC_RESULT(ic)))==1 &&
- isOperandEqual (IC_RESULT (ic), IC_COND (ic->next)) &&
- OP_SYMBOL (IC_RESULT (ic))->liveTo <= ic->next->seq)
- {
- OP_SYMBOL (IC_RESULT (ic))->regType = REG_CND;
- continue;
- }
+ (IS_BITWISE_OP(ic) && isBitwiseOptimizable (ic))) &&
+ ic->next && ic->next->op == IFX &&
+ bitVectnBitsOn (OP_USES(IC_RESULT(ic)))==1 &&
+ isOperandEqual (IC_RESULT (ic), IC_COND (ic->next)) &&
+ OP_SYMBOL (IC_RESULT (ic))->liveTo <= ic->next->seq)
+ {
+ OP_SYMBOL (IC_RESULT (ic))->regType = REG_CND;
+ continue;
+ }
#if 1
/* reduce for support function calls */
if (ic->supportRtn || ic->op == '+' || ic->op == '-')
- packRegsForSupport (ic, ebp);
+ packRegsForSupport (ic, ebp);
#endif
/* some cases the redundant moves can
- can be eliminated for return statements . Can be elminated for the first SEND */
- if ((ic->op == RETURN ||
- ((ic->op == SEND || ic->op == RECEIVE)&& ic->argreg == 1)) &&
- !isOperandInFarSpace (IC_LEFT (ic)) &&
- !options.model) {
-
- packRegsDPTRuse (IC_LEFT (ic));
+ can be eliminated for return statements . Can be elminated for the first SEND */
+ if ((ic->op == RETURN ||
+ ((ic->op == SEND || ic->op == RECEIVE)&& ic->argreg == 1)) &&
+ !isOperandInFarSpace (IC_LEFT (ic)) &&
+ !options.model) {
+
+ packRegsDPTRuse (IC_LEFT (ic));
}
if (ic->op == CALL) {
- sym_link *ftype = operandType(IC_LEFT(ic));
- if (getSize(operandType(IC_RESULT(ic))) <= 4 &&
- !IFFUNC_ISBUILTIN(ftype)) {
- packRegsDPTRuse (IC_RESULT (ic));
- }
+ sym_link *ftype = operandType(IC_LEFT(ic));
+ if (getSize(operandType(IC_RESULT(ic))) <= 4 &&
+ !IFFUNC_ISBUILTIN(ftype)) {
+ packRegsDPTRuse (IC_RESULT (ic));
+ }
}
/* if pointer set & left has a size more than
one and right is not in far space */
if (POINTER_SET (ic) &&
- !isOperandInFarSpace (IC_RIGHT (ic)) &&
- IS_SYMOP (IC_RESULT (ic)) &&
- !OP_SYMBOL (IC_RESULT (ic))->remat &&
- !IS_OP_RUONLY (IC_RIGHT (ic)) &&
- getSize (aggrToPtr (operandType (IC_RESULT (ic)), FALSE)) > 1) {
-
- packRegsDPTRuse (IC_RESULT (ic));
+ !isOperandInFarSpace (IC_RIGHT (ic)) &&
+ IS_SYMOP (IC_RESULT (ic)) &&
+ !OP_SYMBOL (IC_RESULT (ic))->remat &&
+ !IS_OP_RUONLY (IC_RIGHT (ic)) &&
+ getSize (aggrToPtr (operandType (IC_RESULT (ic)), FALSE)) > 1) {
+
+ packRegsDPTRuse (IC_RESULT (ic));
}
/* if pointer get */
if (POINTER_GET (ic) &&
- !isOperandInFarSpace (IC_RESULT (ic)) &&
- IS_SYMOP (IC_LEFT (ic)) &&
- !OP_SYMBOL (IC_LEFT (ic))->remat &&
- !IS_OP_RUONLY (IC_RESULT (ic)) &&
- getSize (aggrToPtr (operandType (IC_LEFT (ic)), FALSE)) > 1) {
+ !isOperandInFarSpace (IC_RESULT (ic)) &&
+ IS_SYMOP (IC_LEFT (ic)) &&
+ !OP_SYMBOL (IC_LEFT (ic))->remat &&
+ !IS_OP_RUONLY (IC_RESULT (ic)) &&
+ getSize (aggrToPtr (operandType (IC_LEFT (ic)), FALSE)) > 1) {
- packRegsDPTRuse (IC_LEFT (ic));
+ packRegsDPTRuse (IC_LEFT (ic));
}
/* if this is cast for intergral promotion then
- check if only use of the definition of the
+ check if only use of the definition of the
operand being casted/ if yes then replace
- the result of that arithmetic operation with
+ the result of that arithmetic operation with
this result and get rid of the cast */
if (ic->op == CAST)
- {
- sym_link *fromType = operandType (IC_RIGHT (ic));
- sym_link *toType = operandType (IC_LEFT (ic));
-
- if (IS_INTEGRAL (fromType) && IS_INTEGRAL (toType) &&
- getSize (fromType) != getSize (toType) &&
- SPEC_USIGN (fromType) == SPEC_USIGN (toType))
- {
-
- iCode *dic = packRegsDPTRuse (IC_RIGHT (ic));
- if (dic)
- {
- if (IS_ARITHMETIC_OP (dic))
- {
- bitVectUnSetBit(OP_SYMBOL(IC_RESULT(dic))->defs,dic->key);
- IC_RESULT (dic) = IC_RESULT (ic);
- remiCodeFromeBBlock (ebp, ic);
- bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
- hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL);
- OP_DEFS(IC_RESULT (dic))=bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
- ic = ic->prev;
- }
- else
- OP_SYMBOL (IC_RIGHT (ic))->ruonly = 0;
- }
- }
- else
- {
-
- /* if the type from and type to are the same
- then if this is the only use then packit */
- if (compareType (operandType (IC_RIGHT (ic)),
- operandType (IC_LEFT (ic))) == 1)
- {
- iCode *dic = packRegsDPTRuse (IC_RIGHT (ic));
- if (dic)
- {
- bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
- IC_RESULT (dic) = IC_RESULT (ic);
- remiCodeFromeBBlock (ebp, ic);
- bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
- hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL);
- OP_DEFS(IC_RESULT (dic))=bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
- ic = ic->prev;
- }
- }
- }
- }
-
- /* pack for PUSH
+ {
+ sym_link *fromType = operandType (IC_RIGHT (ic));
+ sym_link *toType = operandType (IC_LEFT (ic));
+
+ if (IS_INTEGRAL (fromType) && IS_INTEGRAL (toType) &&
+ getSize (fromType) != getSize (toType) &&
+ SPEC_USIGN (fromType) == SPEC_USIGN (toType))
+ {
+
+ iCode *dic = packRegsDPTRuse (IC_RIGHT (ic));
+ if (dic)
+ {
+ if (IS_ARITHMETIC_OP (dic))
+ {
+ bitVectUnSetBit(OP_SYMBOL(IC_RESULT(dic))->defs,dic->key);
+ IC_RESULT (dic) = IC_RESULT (ic);
+ remiCodeFromeBBlock (ebp, ic);
+ bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
+ hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL);
+ OP_DEFS(IC_RESULT (dic))=bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
+ ic = ic->prev;
+ }
+ else
+ OP_SYMBOL (IC_RIGHT (ic))->ruonly = 0;
+ }
+ }
+ else
+ {
+
+ /* if the type from and type to are the same
+ then if this is the only use then packit */
+ if (compareType (operandType (IC_RIGHT (ic)),
+ operandType (IC_LEFT (ic))) == 1)
+ {
+ iCode *dic = packRegsDPTRuse (IC_RIGHT (ic));
+ if (dic)
+ {
+ bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
+ IC_RESULT (dic) = IC_RESULT (ic);
+ remiCodeFromeBBlock (ebp, ic);
+ bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
+ hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL);
+ OP_DEFS(IC_RESULT (dic))=bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
+ ic = ic->prev;
+ }
+ }
+ }
+ }
+
+ /* pack for PUSH
iTempNN := (some variable in farspace) V1
push iTempNN ;
-------------
push V1
*/
if (ic->op == IPUSH || ic->op == SEND)
- {
- packForPush (ic, ebp);
- }
+ {
+ packForPush (ic, ebp);
+ }
/* pack registers for accumulator use, when the
we can leave the result of this operation in acc:b
combination */
if ((IS_ARITHMETIC_OP (ic)
- || IS_CONDITIONAL(ic)
- || IS_BITWISE_OP (ic)
- || ic->op == LEFT_OP || ic->op == RIGHT_OP
- || (ic->op == ADDRESS_OF && isOperandOnStack (IC_LEFT (ic)))
- ) &&
- IS_ITEMP (IC_RESULT (ic)) &&
- getSize (operandType (IC_RESULT (ic))) <= 2)
-
- packRegsForAccUse (ic);
-
+ || IS_CONDITIONAL(ic)
+ || IS_BITWISE_OP (ic)
+ || ic->op == LEFT_OP || ic->op == RIGHT_OP
+ || (ic->op == ADDRESS_OF && isOperandOnStack (IC_LEFT (ic)))
+ ) &&
+ IS_ITEMP (IC_RESULT (ic)) &&
+ getSize (operandType (IC_RESULT (ic))) <= 2)
+
+ packRegsForAccUse (ic);
+
}
}
iCode *ic;
int i;
- setToNull ((void *) &_G.funcrUsed);
- setToNull ((void *) &_G.regAssigned);
- setToNull ((void *) &_G.totRegAssigned);
- setToNull ((void *) &_G.funcrUsed);
+ setToNull ((void *) &_G.funcrUsed);
+ setToNull ((void *) &_G.regAssigned);
+ setToNull ((void *) &_G.totRegAssigned);
+ setToNull ((void *) &_G.funcrUsed);
ds390_ptrRegReq = _G.stackExtend = _G.dataExtend = 0;
ds390_nRegs = 12;
if (options.model != MODEL_FLAT24) options.stack10bit = 0;
if (options.dump_pack)
dumpEbbsToFileExt (DUMP_PACK, ebbs, count);
- /* first determine for each live range the number of
+ /* first determine for each live range the number of
registers & the type of registers required for each */
regTypeNum ();
currFunc->regsUsed = bitVectSetBit (currFunc->regsUsed, R0_IDX);
currFunc->regsUsed = bitVectSetBit (currFunc->regsUsed, R1_IDX);
}
-
+
if (options.dump_rassgn) {
dumpEbbsToFileExt (DUMP_RASSGN, ebbs, count);
dumpLiveRanges (DUMP_LRANGE, liveRanges);
/* now get back the chain */
ic = iCodeLabelOptimize (iCodeFromeBBlock (ebbs, count));
-
gen390Code (ic);
/* free up any _G.stackSpil locations allocated */
%3:
jnz %4
} by {
- ; Peephole 115 jump optimization
+ ; Peephole 115 jump optimization
cjne %1,%2,%3
sjmp %4
%3:
jc %1
}
-replace {
+replace {
mov r%1,@r%2
} by {
; Peephole 130 changed target address mode r%1 to ar%1
mov ar%1,@r%2
}
-replace {
+replace {
mov a,%1
subb a,#0x01
mov %2,a
mov %1,%2
} by {
; Peephole 131 optimized decrement (not caring for c)
- dec %1
- mov %2,%1
+ dec %1
+ mov %2,%1
}
replace {
} if notVolatile %1 %2
// applies to f.e. bug-607243.c
+// also check notVolatile %3, as it will return FALSE if it's @r%1
replace {
mov r%1,%2
mov ar%1,%3
} by {
; peephole 177.e removed redundant move
mov ar%1,%3
-}
+} if notVolatile %2 %3
+
+replace {
+ mov ar%1,%2
+ mov r%1,%3
+} by {
+ ; peephole 177.f removed redundant move
+ mov r%1,%3
+} if notVolatile %2
replace {
mov a,%1
movc a,@a+dptr
mov %2,a
mov acc,b
- inc dptr
+ inc dptr
movc a,@a+dptr
mov %3,a
mov acc,b
inc dptr
}
-// char indexed access to: char code table[] = {4,3,2,1};
+// char indexed access to: char code table[] = {4,3,2,1};
replace {
add a,#%1
mov dpl,a
movc a,@a+dptr
}
-// char indexed access to: int code table[] = {4,3,2,1};
+// char indexed access to: int code table[] = {4,3,2,1};
replace {
mov b,#0x02
mul ab
cjne %5,%6,%3
sjmp %7
%3:
- sjmp %8
+ sjmp %8
} by {
; Peephole 197.a optimized misc jump sequence
jnz %8
mov a,%4
cjne %5,%6,%8
sjmp %7
-;%3:
+;%3:
} if labelRefCount %3 2
replace {
push %1
pop %1
} by {
- ; Peephole 211 removed redundant push %1 pop %1
-}
+ ; Peephole 211 removed redundant push %1 pop %1
+}
replace {
mov a,_bp
replace {
mov %1,#(( %2 + %3 >> 8 ) ^ 0x80)
} by {
- ; Peephole 213.b inserted fix
+ ; Peephole 213.b inserted fix
mov %1,#((%2 + %3) >> 8)
xrl %1,#0x80
}
mov %2,%10
mov %3,%11
mov %4,%12
-
+
mov %5,%13
mov %6,%14
mov %7,%15
mov %2,%10
mov %3,%11
mov %4,%12
-
+
mov %5,%13
mov %6,%14
mov %7,%15
mov %2,%6
mov %3,%7
mov %4,%8
-
+
mov %5,%1
mov %6,%2
mov %7,%3
replace {
mov %1,%5
mov %2,%6
-
+
mov %3,%7
mov %4,%8
} by {
mov %1,%5
mov %2,%6
-
+
mov %3,%7
mov %4,%8
; Peephole 238.c removed 2 redundant moves
mov %2,%5
mov %3,%6
; Peephole 238.d removed 3 redundant moves
-} if operandsNotSame6 %1 %2 %3 %4 %5 %6
+} if operandsNotSame6 %1 %2 %3 %4 %5 %6
// applies to f.e. ser_ir.asm
replace {
cjne r%6,#%7,%3
cjne r%8,#%9,%3
mov a,#0x01
- sjmp %10
-%3:
+ sjmp %10
+%3:
clr a
-%10:
+%10:
} by {
; Peephole 241.a optimized compare
clr a
inc a
%3:
%10:
-}
+}
// applies to f.e. time.c
replace {
cjne r%1,#%2,%3
cjne r%4,#%5,%3
mov a,#0x01
- sjmp %6
-%3:
+ sjmp %6
+%3:
clr a
-%6:
+%6:
} by {
; Peephole 241.b optimized compare
clr a
inc a
%3:
%6:
-}
+}
// applies to f.e. malloc.c
replace {
sjmp %4
%3:
clr a
-%4:
+%4:
} by {
; Peephole 241.c optimized compare
clr a
inc a
%3:
%4:
-}
+}
-// applies to f.e. j = (k!=0x1000);
+// applies to f.e. j = (k!=0x1000);
// with volatile idata long k;
replace {
cjne @r%1,#%2,%3
- inc r%1
+ inc r%1
cjne @r%1,#%4,%3
- inc r%1
+ inc r%1
cjne @r%1,#%5,%3
- inc r%1
+ inc r%1
cjne @r%1,#%6,%3
mov a,#0x01
- sjmp %7
-%3:
+ sjmp %7
+%3:
clr a
%7:
} by {
inc a
%3:
%7:
-}
+}
// applies to f.e. j = (k!=0x1000);
// with volatile idata int k;
replace {
cjne @r%1,#%2,%3
- inc r%1
+ inc r%1
cjne @r%1,#%4,%3
mov a,#0x01
- sjmp %7
-%3:
+ sjmp %7
+%3:
clr a
-%7:
+%7:
} by {
; Peephole 241.e optimized compare
clr a
inc a
%3:
%7:
-}
+}
// applies to f.e. vprintf.asm (--stack-auto)
replace {
sjmp %7
%3:
clr a
-%7:
+%7:
} by {
; Peephole 241.f optimized compare
clr a
inc a
%3:
%7:
-}
+}
// applies to f.e. scott-bool1.c
replace {
cjne %1,%2,%3
inc %4
%3:
- sjmp %5
+ sjmp %5
} by {
; Peephole 243 avoided branch to sjmp
cjne %1,%2,%5
inc %4
%3:
- sjmp %5
+ sjmp %5
} if labelInRange
// applies to f.e. simplefloat.c (saving 1 cycle)
rlc a
mov r%1,a
cjne a,#0x01,%2
-%2:
+%2:
clr a
rlc a
mov r%1,a
cpl c
clr a
rlc a
- mov r%1,a
+ mov r%1,a
} if labelRefCount %2 1
// this one will not be triggered if 245 is present
rlc a
mov r%1,a
cjne a,#0x01,%2
-%2:
+%2:
clr a
rlc a
mov r%1,a
rlc a
mov r%1,a
cjne a,#0x01,%2
-%2:
+%2:
clr a
rlc a
mov r%1,a
anl a,#%3
movx @dptr,a
} by {
- ; Peephole 246.a combined clr/clr
+ ; Peephole 246.a combined clr/clr
mov dptr,#%1
movx a,@dptr
anl a,#%2&%3
orl a,#%3
movx @dptr,a
} by {
- ; Peephole 246.b combined set/set
+ ; Peephole 246.b combined set/set
mov dptr,#%1
movx a,@dptr
orl a,#%2|%3
anl a,#%3
movx @dptr,a
} by {
- ; Peephole 246.c combined set/clr
+ ; Peephole 246.c combined set/clr
mov dptr,#%1
movx a,@dptr
orl a,#%2
orl a,#%3
movx @dptr,a
} by {
- ; Peephole 246.d combined clr/set
+ ; Peephole 246.d combined clr/set
mov dptr,#%1
movx a,@dptr
anl a,#%2
anl a,#%4
movx @dptr,a
} by {
- ; Peephole 246.e combined set/clr/clr
+ ; Peephole 246.e combined set/clr/clr
mov dptr,#%1
movx a,@dptr
orl a,#%2
orl a,#%4
movx @dptr,a
} by {
- ; Peephole 246.f combined set/clr/set
+ ; Peephole 246.f combined set/clr/set
mov dptr,#%1
movx a,@dptr
orl a,#%2
anl a,#%4
movx @dptr,a
} by {
- ; Peephole 246.g combined clr/set/clr
+ ; Peephole 246.g combined clr/set/clr
mov dptr,#%1
movx a,@dptr
anl a,#%2
orl a,#%4
movx @dptr,a
} by {
- ; Peephole 246.h combined clr/set/set
+ ; Peephole 246.h combined clr/set/set
mov dptr,#%1
movx a,@dptr
anl a,#%2
anl a,#%3
mov @r%5,a
} by {
- ; Peephole 247.a combined clr/clr
+ ; Peephole 247.a combined clr/clr
mov r%5,#%1
mov a,@r%5
anl a,#%2&%3
orl a,#%3
mov @r%5,a
} by {
- ; Peephole 247.b combined set/set
+ ; Peephole 247.b combined set/set
mov r%5,#%1
mov a,@r%5
orl a,#%2|%3
anl a,#%3
mov @r%5,a
} by {
- ; Peephole 247.c combined set/clr
+ ; Peephole 247.c combined set/clr
mov r%5,#%1
mov a,@r%5
orl a,#%2
orl a,#%3
mov @r%5,a
} by {
- ; Peephole 247.d combined clr/set
+ ; Peephole 247.d combined clr/set
mov r%5,#%1
mov a,@r%5
anl a,#%2
anl a,#%4
mov @r%5,a
} by {
- ; Peephole 247.e combined set/clr/clr
+ ; Peephole 247.e combined set/clr/clr
mov r%5,#%1
mov a,@r%5
orl a,#%2
orl a,#%4
mov @r%5,a
} by {
- ; Peephole 247.f combined set/clr/set
+ ; Peephole 247.f combined set/clr/set
mov r%5,#%1
mov a,@r%5
orl a,#%2
anl a,#%4
mov @r%5,a
} by {
- ; Peephole 247.g combined clr/set/clr
+ ; Peephole 247.g combined clr/set/clr
mov r%5,#%1
mov a,@r%5
anl a,#%2
orl a,#%4
mov @r%5,a
} by {
- ; Peephole 247.h combined clr/set/set
+ ; Peephole 247.h combined clr/set/set
mov r%5,#%1
mov a,@r%5
anl a,#%2
// Peepholes 248.x have to be compatible with the keyword volatile.
// They optimize typical accesses to memory mapped I/O devices:
-// volatile xdata char t; t|=0x01;
+// volatile xdata char t; t|=0x01;
replace {
mov dptr,%1
movx a,@dptr
movx @dptr,a
}
-// volatile xdata char t; t&=0x01;
+// volatile xdata char t; t&=0x01;
replace {
mov dptr,%1
movx a,@dptr
movx @dptr,a
}
-// volatile xdata char t; t^=0x01;
+// volatile xdata char t; t^=0x01;
replace {
mov dptr,%1
movx a,@dptr
}
// applies to f.e. jump tables and scott-bool1.c.
-// similar peepholes can be constructed for other instructions
+// similar peepholes can be constructed for other instructions
// after which a flag or a register is known (like: djnz, cjne, jnc)
replace {
jc %1
addc a,%1
mov %1,a
%4:
-%3:
+%3:
} if notVolatile %1
// in_byte<<=1; if(in_bit) in_byte|=1;
add a,%1
mov %2,c
mov %1,a
-} if notVolatile %1
+} if notVolatile %1
// out_bit=out_byte&0x01; out_byte>>=1;
replace {
static struct {
ERROR_LOG_LEVEL logLevel;
FILE *out;
- int style; /* 1=MSVC */
+ int style; /* 1=MSVC */
+ char disabled[MAX_ERROR_WARNING]; /* 1=warning disabled*/
} _SDCCERRG;
extern char *filename ;
{ E_TWO_OR_MORE_STORAGE_CLASSES, ERROR_LEVEL_ERROR,
"two or more storage classes in declaration for '%s'" },
{ W_EXCESS_INITIALIZERS, ERROR_LEVEL_WARNING,
- "excess elements in %s initializer after `%s'" },
+ "excess elements in %s initializer after '%s'" },
{ E_ARGUMENT_MISSING, ERROR_LEVEL_ERROR,
"Option %s requires an argument." },
{ W_STRAY_BACKSLASH, ERROR_LEVEL_WARNING,
*/
FILE *SetErrorOut(FILE *NewErrorOut)
-
{
_SDCCERRG.out = NewErrorOut ;
-return NewErrorOut ;
+ return NewErrorOut ;
}
-void
-setErrorLogLevel (ERROR_LOG_LEVEL level)
+void setErrorLogLevel (ERROR_LOG_LEVEL level)
{
_SDCCERRG.logLevel = level;
}
_SDCCERRG.out = DEFAULT_ERROR_OUT;
}
- if (ErrTab[errNum].errIndex != errNum)
- {
+ if (ErrTab[errNum].errIndex != errNum) {
fprintf(_SDCCERRG.out,
- "Internal error: error table entry for %d inconsistent.", errNum);
+ "Internal error: error table entry for %d inconsistent.", errNum);
}
-
- if (ErrTab[errNum].errType >= _SDCCERRG.logLevel) {
+ if ((ErrTab[errNum].errType >= _SDCCERRG.logLevel) && (!_SDCCERRG.disabled[errNum])) {
if ( ErrTab[errNum].errType == ERROR_LEVEL_ERROR )
fatalError++ ;
if ( filename && lineno ) {
- if(_SDCCERRG.style)
- fprintf(_SDCCERRG.out, "%s(%d) : ",filename,lineno);
- else
- fprintf(_SDCCERRG.out, "%s:%d: ",filename,lineno);
- } else if (lineno) {
+ if(_SDCCERRG.style)
+ fprintf(_SDCCERRG.out, "%s(%d) : ",filename,lineno);
+ else
+ fprintf(_SDCCERRG.out, "%s:%d: ",filename,lineno);
+ } else if (lineno) {
fprintf(_SDCCERRG.out, "at %d: ", lineno);
} else {
fprintf(_SDCCERRG.out, "-:0: ");
}
-
+
switch(ErrTab[errNum].errType)
{
case ERROR_LEVEL_ERROR:
- fprintf(_SDCCERRG.out, "error: ");
+ fprintf(_SDCCERRG.out, "error %d: ", errNum);
break;
case ERROR_LEVEL_WARNING:
case ERROR_LEVEL_PEDANTIC:
- fprintf(_SDCCERRG.out, "warning: ");
+ fprintf(_SDCCERRG.out, "warning %d: ", errNum);
break;
case ERROR_LEVEL_INFO:
- fprintf(_SDCCERRG.out, "info: ");
+ fprintf(_SDCCERRG.out, "info %d: ", errNum);
break;
default:
break;
vfprintf(_SDCCERRG.out, ErrTab[errNum].errText,marker);
fprintf(_SDCCERRG.out, "\n");
- }
- else {
+ } else {
/* Below the logging level, drop. */
}
}
-------------------------------------------------------------------------------
*/
-void MSVC_style (int style)
+void MSVC_style (int style)
{
_SDCCERRG.style = style;
}
+
+/*
+-------------------------------------------------------------------------------
+disabled - Disable output of specified warning
+-------------------------------------------------------------------------------
+*/
+
+void setWarningDisabled (int errNum)
+{
+ if ((errNum < MAX_ERROR_WARNING) && (ErrTab[errNum].errType <= ERROR_LEVEL_WARNING))
+ _SDCCERRG.disabled[errNum] = 1;
+}
/* ERROR Message Definition */
-#define E_DUPLICATE 0 /* Duplicate variable */
-#define E_SYNTAX_ERROR 1 /* Syntax Error */
-#define E_CONST_EXPECTED 2 /* constant expected */
-#define E_OUT_OF_MEM 3 /* malloc failed */
-#define E_FILE_OPEN_ERR 4 /* File open failed */
-#define E_INVALID_OCLASS 5 /* output class invalid */
-#define E_CANNOT_ALLOC 6 /* cannot allocate space*/
-#define E_OLD_STYLE 7 /* old style C ! allowed*/
-#define E_STACK_OUT 8 /* v r out of stack */
-#define E_INTERNAL_ERROR 9 /* unable to alloc tvar */
-#define E_LVALUE_REQUIRED 10 /* lvalue required */
-#define E_TMPFILE_FAILED 11 /* tmpfile creation failed */
-#define E_FUNCTION_EXPECTED 12 /* function expected */
-#define E_USING_ERROR 13 /* using in error */
-#define E_SFR_INIT 14 /* init error for sbit */
-#define W_INIT_IGNORED 15 /* initialiser ignored */
-#define E_AUTO_ASSUMED 16 /* sclass auto assumed */
-#define E_AUTO_ABSA 17 /* abs addr for auto var*/
-#define W_INIT_WRONG 18 /* initializer type != */
-#define E_FUNC_REDEF 19 /* func name redefined */
-#define E_ID_UNDEF 20 /* identifer undefined */
-#define W_STACK_OVERFLOW 21 /* stack overflow */
-#define E_NEED_ARRAY_PTR 22 /* array or pointer reqd*/
-#define E_IDX_NOT_INT 23 /* index not an integer */
-#define W_IDX_OUT_OF_BOUNDS 24 /* array index out of bounds */
-#define E_STRUCT_UNION 25 /* struct,union expected*/
-#define E_NOT_MEMBER 26 /* !struct/union member */
-#define E_PTR_REQD 27 /* pointer required */
-#define E_UNARY_OP 28 /* unary operator bad op*/
-#define E_CONV_ERR 29 /* conversion error */
-#define E_INT_REQD 30 /* bit field must be int*/
-#define E_BITFLD_SIZE 31 /* bit field size > 16 */
-#define W_TRUNCATION 32 /* high order trucation */
-#define E_CODE_WRITE 33 /* trying 2 write to code */
-#define E_LVALUE_CONST 34 /* lvalue is a const */
-#define E_ILLEGAL_ADDR 35 /* address of bit */
-#define E_CAST_ILLEGAL 36 /* cast illegal */
-#define E_MULT_INTEGRAL 37 /* mult opernd must b integral */
-#define E_ARG_ERROR 38 /* argument count error*/
-#define E_ARG_COUNT 39 /* func expecting more */
-#define E_FUNC_EXPECTED 40 /* func name expected */
-#define E_PLUS_INVALID 41 /* plus invalid */
-#define E_PTR_PLUS_PTR 42 /* pointer + pointer */
-#define E_SHIFT_OP_INVALID 43 /* shft op op invalid */
-#define E_COMPARE_OP 44 /* compare operand */
-#define E_BITWISE_OP 45 /* bit op invalid op */
-#define E_ANDOR_OP 46 /* && || op invalid */
-#define E_TYPE_MISMATCH 47 /* type mismatch */
-#define E_AGGR_ASSIGN 48 /* aggr assign */
-#define E_ARRAY_DIRECT 49 /* array indexing in */
-#define E_BIT_ARRAY 50 /* bit array not allowed */
-#define E_DUPLICATE_TYPEDEF 51 /* typedef name duplicate */
-#define E_ARG_TYPE 52 /* arg type mismatch */
-#define E_RET_VALUE 53 /* return value mismatch */
-#define E_FUNC_AGGR 54 /* function returing aggr */
-#define E_FUNC_DEF 55 /* ANSI Style def neede */
-#define E_DUPLICATE_LABEL 56 /* duplicate label name */
-#define E_LABEL_UNDEF 57 /* undefined label used */
-#define E_FUNC_VOID 58 /* void func ret value */
-#define W_VOID_FUNC 59 /* func must return value */
-#define W_RETURN_MISMATCH 60 /* return value mismatch */
-#define E_CASE_CONTEXT 61 /* case stmnt without switch */
-#define E_CASE_CONSTANT 62 /* case expression ! const */
-#define E_BREAK_CONTEXT 63 /* break statement invalid */
-#define E_SWITCH_AGGR 64 /* non integral for switch */
-#define E_FUNC_BODY 65 /* func has body already */
-#define E_UNKNOWN_SIZE 66 /* variable has unknown size */
-#define E_AUTO_AGGR_INIT 67 /* auto aggregates no init */
-#define E_INIT_COUNT 68 /* too many initializers */
-#define E_INIT_STRUCT 69 /* struct init wrong */
-#define E_INIT_NON_ADDR 70 /* non address xpr for init */
-#define E_INT_DEFINED 71 /* interrupt already over */
-#define E_INT_ARGS 72 /* interrupt rtn cannot have args */
-#define E_INCLUDE_MISSING 73 /* compiler include missing */
-#define E_NO_MAIN 74 /* main function undefined */
-#define E_EXTERN_INIT 75 /* extern variable initialised */
-#define E_PRE_PROC_FAILED 76 /* preprocessor failed */
-#define E_DUP_FAILED 77 /* file DUP failed */
-#define E_INCOMPAT_TYPES 78 /* incompatible types casting */
-#define W_LOOP_ELIMINATE 79 /* loop eliminated */
-#define W_NO_SIDE_EFFECTS 80 /* expression has no side effects */
-#define W_CONST_TOO_LARGE 81 /* constant out of range */
-#define W_BAD_COMPARE 82 /* bad comparison */
-#define E_TERMINATING 83 /* compiler terminating */
-#define W_LOCAL_NOINIT 84 /* local reference before assignment */
-#define W_NO_REFERENCE 85 /* no reference to local variable */
-#define E_OP_UNKNOWN_SIZE 86 /* unknown size for operand */
-#define W_LONG_UNSUPPORTED 87 /* 'long' not supported yet */
-#define E_LITERAL_GENERIC 88 /* literal being cast to generic pointer */
-#define E_SFR_ADDR_RANGE 89 /* sfr address out of range */
-#define E_BITVAR_STORAGE 90 /* storage given for 'bit' variable */
-#define E_EXTERN_MISMATCH 91 /* extern declaration mismatches */
-#define W_NONRENT_ARGS 92 /* fptr non reentrant has args */
-#define W_DOUBLE_UNSUPPORTED 93 /* 'double' not supported yet */
-#define W_IF_NEVER_TRUE 94 /* if always false */
-#define W_FUNC_NO_RETURN 95 /* no return statement found */
-#define W_PRE_PROC_WARNING 96 /* preprocessor generated warning */
-#define W_STRUCT_AS_ARG 97 /* structure passed as argument */
-#define E_PREV_DEF_CONFLICT 98 /* previous definition conflicts with current */
-#define E_CODE_NO_INIT 99 /* vars in code space must have initializer */
-#define E_OPS_INTEGRAL 100 /* operans must be integral for certian assignments */
-#define E_TOO_MANY_PARMS 101 /* too many parameters */
-#define E_TOO_FEW_PARMS 102 /* to few parameters */
-#define E_FUNC_NO_CODE 103 /* fatalError */
-#define E_TYPE_MISMATCH_PARM 104 /* type mismatch for parameter */
-#define E_INVALID_FLOAT_CONST 105 /* invalid floating point literal string */
-#define E_INVALID_OP 106 /* invalid operand for some operation */
-#define E_SWITCH_NON_INTEGER 107 /* switch value not integer */
-#define E_CASE_NON_INTEGER 108 /* case value not integer */
-#define W_FUNC_TOO_LARGE 109 /* function too large */
-#define W_CONTROL_FLOW 110 /* control flow changed due to optimization */
-#define W_PTR_TYPE_INVALID 111 /* invalid type specifier for pointer */
-#define W_IMPLICIT_FUNC 112 /* function declared implicitly */
-#define W_CONTINUE 113 /* more than one line */
-#define I_EXTENDED_STACK_SPILS 114 /* too many spils occured */
-#define W_UNKNOWN_PRAGMA 115 /* #pragma directive unsupported */
-#define W_SHIFT_CHANGED 116 /* shift changed to zero */
-#define W_UNKNOWN_OPTION 117 /* don't know the option */
-#define W_UNSUPP_OPTION 118 /* processor reset has been redifned */
-#define W_UNKNOWN_FEXT 119 /* unknown file extension */
-#define W_TOO_MANY_SRC 120 /* can only compile one .c file at a time */
-#define I_CYCLOMATIC 121 /* information message */
-#define E_DIVIDE_BY_ZERO 122 /* / 0 */
-#define E_FUNC_BIT 123 /* function cannot return bit */
-#define E_CAST_ZERO 124 /* casting to from size zero */
-#define W_CONST_RANGE 125 /* constant too large */
-#define W_CODE_UNREACH 126 /* unreachable code */
-#define E_NONPTR2_GENPTR 127 /* non pointer cast to generic pointer */
-#define W_POSSBUG 128 /* possible code generation error */
-#define E_INCOMPAT_PTYPES 129 /* incampatible pointer assignment */
-#define W_UNKNOWN_MODEL 130 /* Unknown memory model */
-#define E_UNKNOWN_TARGET 131 /* target not defined */
-#define W_INDIR_BANKED 132 /* Indirect call to a banked fun */
-#define W_UNSUPPORTED_MODEL 133 /* Unsupported model, ignored */
-#define W_BANKED_WITH_NONBANKED 134 /* banked and nonbanked attributes mixed */
-#define W_BANKED_WITH_STATIC 135 /* banked and static mixed */
-#define W_INT_TO_GEN_PTR_CAST 136 /* Converting integer type to generic pointer. */
-#define W_ESC_SEQ_OOR_FOR_CHAR 137 /* Escape sequence of of range for char */
-#define E_INVALID_HEX 138 /* \x used with no following hex digits */
-#define W_FUNCPTR_IN_USING_ISR 139 /* Call via function pointer in ISR with using attribute. */
-#define E_NO_SUCH_BANK 140 /* 'using' attribute specifies non-existant register bank. */
-#define E_TWO_OR_MORE_DATA_TYPES 141
-#define E_LONG_OR_SHORT_INVALID 142 /* long or short invalid for .. */
-#define E_SIGNED_OR_UNSIGNED_INVALID 143 /* signed or unsigned invalid for .. */
-#define E_LONG_AND_SHORT_INVALID 144 /* long and short invalid for .. */
+#define E_DUPLICATE 0 /* Duplicate variable */
+#define E_SYNTAX_ERROR 1 /* Syntax Error */
+#define E_CONST_EXPECTED 2 /* constant expected */
+#define E_OUT_OF_MEM 3 /* malloc failed */
+#define E_FILE_OPEN_ERR 4 /* File open failed */
+#define E_INVALID_OCLASS 5 /* output class invalid */
+#define E_CANNOT_ALLOC 6 /* cannot allocate space*/
+#define E_OLD_STYLE 7 /* old style C ! allowed*/
+#define E_STACK_OUT 8 /* v r out of stack */
+#define E_INTERNAL_ERROR 9 /* unable to alloc tvar */
+#define E_LVALUE_REQUIRED 10 /* lvalue required */
+#define E_TMPFILE_FAILED 11 /* tmpfile creation failed */
+#define E_FUNCTION_EXPECTED 12 /* function expected */
+#define E_USING_ERROR 13 /* using in error */
+#define E_SFR_INIT 14 /* init error for sbit */
+#define W_INIT_IGNORED 15 /* initialiser ignored */
+#define E_AUTO_ASSUMED 16 /* sclass auto assumed */
+#define E_AUTO_ABSA 17 /* abs addr for auto var*/
+#define W_INIT_WRONG 18 /* initializer type != */
+#define E_FUNC_REDEF 19 /* func name redefined */
+#define E_ID_UNDEF 20 /* identifer undefined */
+#define W_STACK_OVERFLOW 21 /* stack overflow */
+#define E_NEED_ARRAY_PTR 22 /* array or pointer reqd*/
+#define E_IDX_NOT_INT 23 /* index not an integer */
+#define W_IDX_OUT_OF_BOUNDS 24 /* array index out of bounds */
+#define E_STRUCT_UNION 25 /* struct,union expected*/
+#define E_NOT_MEMBER 26 /* !struct/union member */
+#define E_PTR_REQD 27 /* pointer required */
+#define E_UNARY_OP 28 /* unary operator bad op*/
+#define E_CONV_ERR 29 /* conversion error */
+#define E_INT_REQD 30 /* bit field must be int*/
+#define E_BITFLD_SIZE 31 /* bit field size > 16 */
+#define W_TRUNCATION 32 /* high order trucation */
+#define E_CODE_WRITE 33 /* trying 2 write to code */
+#define E_LVALUE_CONST 34 /* lvalue is a const */
+#define E_ILLEGAL_ADDR 35 /* address of bit */
+#define E_CAST_ILLEGAL 36 /* cast illegal */
+#define E_MULT_INTEGRAL 37 /* mult opernd must b integral */
+#define E_ARG_ERROR 38 /* argument count error*/
+#define E_ARG_COUNT 39 /* func expecting more */
+#define E_FUNC_EXPECTED 40 /* func name expected */
+#define E_PLUS_INVALID 41 /* plus invalid */
+#define E_PTR_PLUS_PTR 42 /* pointer + pointer */
+#define E_SHIFT_OP_INVALID 43 /* shft op op invalid */
+#define E_COMPARE_OP 44 /* compare operand */
+#define E_BITWISE_OP 45 /* bit op invalid op */
+#define E_ANDOR_OP 46 /* && || op invalid */
+#define E_TYPE_MISMATCH 47 /* type mismatch */
+#define E_AGGR_ASSIGN 48 /* aggr assign */
+#define E_ARRAY_DIRECT 49 /* array indexing in */
+#define E_BIT_ARRAY 50 /* bit array not allowed */
+#define E_DUPLICATE_TYPEDEF 51 /* typedef name duplicate */
+#define E_ARG_TYPE 52 /* arg type mismatch */
+#define E_RET_VALUE 53 /* return value mismatch */
+#define E_FUNC_AGGR 54 /* function returing aggr */
+#define E_FUNC_DEF 55 /* ANSI Style def neede */
+#define E_DUPLICATE_LABEL 56 /* duplicate label name */
+#define E_LABEL_UNDEF 57 /* undefined label used */
+#define E_FUNC_VOID 58 /* void func ret value */
+#define W_VOID_FUNC 59 /* func must return value */
+#define W_RETURN_MISMATCH 60 /* return value mismatch */
+#define E_CASE_CONTEXT 61 /* case stmnt without switch */
+#define E_CASE_CONSTANT 62 /* case expression ! const */
+#define E_BREAK_CONTEXT 63 /* break statement invalid */
+#define E_SWITCH_AGGR 64 /* non integral for switch */
+#define E_FUNC_BODY 65 /* func has body already */
+#define E_UNKNOWN_SIZE 66 /* variable has unknown size */
+#define E_AUTO_AGGR_INIT 67 /* auto aggregates no init */
+#define E_INIT_COUNT 68 /* too many initializers */
+#define E_INIT_STRUCT 69 /* struct init wrong */
+#define E_INIT_NON_ADDR 70 /* non address xpr for init */
+#define E_INT_DEFINED 71 /* interrupt already over */
+#define E_INT_ARGS 72 /* interrupt rtn cannot have args */
+#define E_INCLUDE_MISSING 73 /* compiler include missing */
+#define E_NO_MAIN 74 /* main function undefined */
+#define E_EXTERN_INIT 75 /* extern variable initialised */
+#define E_PRE_PROC_FAILED 76 /* preprocessor failed */
+#define E_DUP_FAILED 77 /* file DUP failed */
+#define E_INCOMPAT_TYPES 78 /* incompatible types casting */
+#define W_LOOP_ELIMINATE 79 /* loop eliminated */
+#define W_NO_SIDE_EFFECTS 80 /* expression has no side effects */
+#define W_CONST_TOO_LARGE 81 /* constant out of range */
+#define W_BAD_COMPARE 82 /* bad comparison */
+#define E_TERMINATING 83 /* compiler terminating */
+#define W_LOCAL_NOINIT 84 /* local reference before assignment */
+#define W_NO_REFERENCE 85 /* no reference to local variable */
+#define E_OP_UNKNOWN_SIZE 86 /* unknown size for operand */
+#define W_LONG_UNSUPPORTED 87 /* 'long' not supported yet */
+#define E_LITERAL_GENERIC 88 /* literal being cast to generic pointer */
+#define E_SFR_ADDR_RANGE 89 /* sfr address out of range */
+#define E_BITVAR_STORAGE 90 /* storage given for 'bit' variable */
+#define E_EXTERN_MISMATCH 91 /* extern declaration mismatches */
+#define W_NONRENT_ARGS 92 /* fptr non reentrant has args */
+#define W_DOUBLE_UNSUPPORTED 93 /* 'double' not supported yet */
+#define W_IF_NEVER_TRUE 94 /* if always false */
+#define W_FUNC_NO_RETURN 95 /* no return statement found */
+#define W_PRE_PROC_WARNING 96 /* preprocessor generated warning */
+#define W_STRUCT_AS_ARG 97 /* structure passed as argument */
+#define E_PREV_DEF_CONFLICT 98 /* previous definition conflicts with current */
+#define E_CODE_NO_INIT 99 /* vars in code space must have initializer */
+#define E_OPS_INTEGRAL 100 /* operans must be integral for certian assignments */
+#define E_TOO_MANY_PARMS 101 /* too many parameters */
+#define E_TOO_FEW_PARMS 102 /* to few parameters */
+#define E_FUNC_NO_CODE 103 /* fatalError */
+#define E_TYPE_MISMATCH_PARM 104 /* type mismatch for parameter */
+#define E_INVALID_FLOAT_CONST 105 /* invalid floating point literal string */
+#define E_INVALID_OP 106 /* invalid operand for some operation */
+#define E_SWITCH_NON_INTEGER 107 /* switch value not integer */
+#define E_CASE_NON_INTEGER 108 /* case value not integer */
+#define W_FUNC_TOO_LARGE 109 /* function too large */
+#define W_CONTROL_FLOW 110 /* control flow changed due to optimization */
+#define W_PTR_TYPE_INVALID 111 /* invalid type specifier for pointer */
+#define W_IMPLICIT_FUNC 112 /* function declared implicitly */
+#define W_CONTINUE 113 /* more than one line */
+#define I_EXTENDED_STACK_SPILS 114 /* too many spils occured */
+#define W_UNKNOWN_PRAGMA 115 /* #pragma directive unsupported */
+#define W_SHIFT_CHANGED 116 /* shift changed to zero */
+#define W_UNKNOWN_OPTION 117 /* don't know the option */
+#define W_UNSUPP_OPTION 118 /* processor reset has been redifned */
+#define W_UNKNOWN_FEXT 119 /* unknown file extension */
+#define W_TOO_MANY_SRC 120 /* can only compile one .c file at a time */
+#define I_CYCLOMATIC 121 /* information message */
+#define E_DIVIDE_BY_ZERO 122 /* / 0 */
+#define E_FUNC_BIT 123 /* function cannot return bit */
+#define E_CAST_ZERO 124 /* casting to from size zero */
+#define W_CONST_RANGE 125 /* constant too large */
+#define W_CODE_UNREACH 126 /* unreachable code */
+#define E_NONPTR2_GENPTR 127 /* non pointer cast to generic pointer */
+#define W_POSSBUG 128 /* possible code generation error */
+#define E_INCOMPAT_PTYPES 129 /* incampatible pointer assignment */
+#define W_UNKNOWN_MODEL 130 /* Unknown memory model */
+#define E_UNKNOWN_TARGET 131 /* target not defined */
+#define W_INDIR_BANKED 132 /* Indirect call to a banked fun */
+#define W_UNSUPPORTED_MODEL 133 /* Unsupported model, ignored */
+#define W_BANKED_WITH_NONBANKED 134 /* banked and nonbanked attributes mixed */
+#define W_BANKED_WITH_STATIC 135 /* banked and static mixed */
+#define W_INT_TO_GEN_PTR_CAST 136 /* Converting integer type to generic pointer. */
+#define W_ESC_SEQ_OOR_FOR_CHAR 137 /* Escape sequence of of range for char */
+#define E_INVALID_HEX 138 /* \x used with no following hex digits */
+#define W_FUNCPTR_IN_USING_ISR 139 /* Call via function pointer in ISR with using attribute. */
+#define E_NO_SUCH_BANK 140 /* 'using' attribute specifies non-existant register bank. */
+#define E_TWO_OR_MORE_DATA_TYPES 141
+#define E_LONG_OR_SHORT_INVALID 142 /* long or short invalid for .. */
+#define E_SIGNED_OR_UNSIGNED_INVALID 143 /* signed or unsigned invalid for .. */
+#define E_LONG_AND_SHORT_INVALID 144 /* long and short invalid for .. */
#define E_SIGNED_AND_UNSIGNED_INVALID 145 /* signed and unsigned invalid for .. */
#define E_TWO_OR_MORE_STORAGE_CLASSES 146
-#define W_EXCESS_INITIALIZERS 147 /* too much initializers for array */
-#define E_ARGUMENT_MISSING 148 /* Option requires an argument. */
-#define W_STRAY_BACKSLASH 149
-#define W_NEWLINE_IN_STRING 150
-#define E_CANNOT_USE_GENERIC_POINTER 151
-#define W_EXCESS_SHORT_OPTIONS 152
-#define E_VOID_VALUE_USED 153
-#define W_INTEGRAL2PTR_NOCAST 154
-#define W_PTR2INTEGRAL_NOCAST 155
-#define W_SYMBOL_NAME_TOO_LONG 156
-#define W_CAST_STRUCT_PTR 157 /* pointer to different structure types */
-#define W_IF_ALWAYS_TRUE 158
-#define E_PARAM_NAME_OMITTED 159
-#define W_NO_FILE_ARG_IN_C1 160
-#define E_NEED_OPT_O_IN_C1 161
-#define W_ILLEGAL_OPT_COMBINATION 162
-#define E_DUPLICATE_MEMBER 163
-#define E_STACK_VIOLATION 164 /* internal stack violation */
-#define W_INT_OVL 165 /* integer overflow in expression */
-#define W_USELESS_DECL 166 /* useless declaration */
-#define E_INT_BAD_INTNO 167 /* invalid interrupt number */
-#define W_BITFLD_NAMED 168 /* declarator used with 0 length bitfield */
-#define E_FUNC_ATTR 169 /* function attribute without function */
-#define W_SAVE_RESTORE 170 /* unmatched #pragma SAVE and #pragma RESTORE */
-#define E_INVALID_CRITICAL 171 /* operation invalid in critical sequence */
-#define E_NOT_ALLOWED 172 /* %s not allowed here */
-#define E_BAD_TAG 173 /* '%s' is not a %s tag */
-#define E_ENUM_NON_INTEGER 174 /* enumeration constant not an integer */
-#define W_DEPRECATED_PRAGMA 175 /* deprecated pragma */
-#define E_SIZEOF_INCOMPLETE_TYPE 176 /* sizeof applied to an incomplete type */
-#define E_PREVIOUS_DEF 177 /* previously defined here */
+#define W_EXCESS_INITIALIZERS 147 /* too much initializers for array */
+#define E_ARGUMENT_MISSING 148 /* Option requires an argument. */
+#define W_STRAY_BACKSLASH 149
+#define W_NEWLINE_IN_STRING 150
+#define E_CANNOT_USE_GENERIC_POINTER 151
+#define W_EXCESS_SHORT_OPTIONS 152
+#define E_VOID_VALUE_USED 153
+#define W_INTEGRAL2PTR_NOCAST 154
+#define W_PTR2INTEGRAL_NOCAST 155
+#define W_SYMBOL_NAME_TOO_LONG 156
+#define W_CAST_STRUCT_PTR 157 /* pointer to different structure types */
+#define W_IF_ALWAYS_TRUE 158
+#define E_PARAM_NAME_OMITTED 159
+#define W_NO_FILE_ARG_IN_C1 160
+#define E_NEED_OPT_O_IN_C1 161
+#define W_ILLEGAL_OPT_COMBINATION 162
+#define E_DUPLICATE_MEMBER 163
+#define E_STACK_VIOLATION 164 /* internal stack violation */
+#define W_INT_OVL 165 /* integer overflow in expression */
+#define W_USELESS_DECL 166 /* useless declaration */
+#define E_INT_BAD_INTNO 167 /* invalid interrupt number */
+#define W_BITFLD_NAMED 168 /* declarator used with 0 length bitfield */
+#define E_FUNC_ATTR 169 /* function attribute without function */
+#define W_SAVE_RESTORE 170 /* unmatched #pragma SAVE and #pragma RESTORE */
+#define E_INVALID_CRITICAL 171 /* operation invalid in critical sequence */
+#define E_NOT_ALLOWED 172 /* %s not allowed here */
+#define E_BAD_TAG 173 /* '%s' is not a %s tag */
+#define E_ENUM_NON_INTEGER 174 /* enumeration constant not an integer */
+#define W_DEPRECATED_PRAGMA 175 /* deprecated pragma */
+#define E_SIZEOF_INCOMPLETE_TYPE 176 /* sizeof applied to an incomplete type */
+#define E_PREVIOUS_DEF 177 /* previously defined here */
+
+#define MAX_ERROR_WARNING 256 /* size of disable warnings array */
/** Describes the maximum error level that will be logged. Any level
* includes all of the levels listed after it.
/** Sets the maximum error level to log.
See MAX_ERROR_LEVEL. The default is ERROR_LEVEL_ALL.
*/
-void
-setErrorLogLevel (ERROR_LOG_LEVEL level);
+void setErrorLogLevel (ERROR_LOG_LEVEL level);
/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
-void vwerror (int errNum, va_list marker) ;
+void vwerror (int errNum, va_list marker) ;
/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
-void werror (int errNum, ... ) ;
+void werror (int errNum, ... ) ;
/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
-void fatal (int exitCode, int errNum, ... ) ;
+void fatal (int exitCode, int errNum, ... ) ;
/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
-void MSVC_style (int style) ;
+void MSVC_style (int style) ;
+
+/*
+-------------------------------------------------------------------------------
+disabled - Disable output of specified warning
+-------------------------------------------------------------------------------
+*/
+
+void setWarningDisabled (int errNum) ;
#endif
_fsneq.c _fssub.c _gptrget.c _gptrput.c \
_sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
_islower.c _isprint.c _ispunct.c _isspace.c \
- _isupper.c _isxdigit.c _slong2fs.c _memcmp.c \
- _memcpy.c _memset.c _modsint.c _modslong.c \
- _moduint.c _modulong.c _mulint.c _mullong.c \
+ _isupper.c _isxdigit.c _slong2fs.c \
+ _memcmp.c _memcpy.c _memmove.c _memset.c \
+ _modsint.c _modslong.c _moduint.c _modulong.c \
+ _mulint.c _mullong.c \
_ser.c _setjmp.c \
_spx.c _startup.c _strchr.c _strcmp.c _strcpy.c \
_strcspn.c _strlen.c _strncat.c _strncmp.c \
_strncpy.c _strpbrk.c _strrchr.c _strspn.c \
- _strstr.c _strtok.c _uchar2fs.c _uint2fs.c \
- _ulong2fs.c malloc.c serial.c ser_ir.c printfl.c \
+ _strstr.c _strtok.c \
+ _uchar2fs.c _uint2fs.c _ulong2fs.c \
+ calloc.c malloc.c realloc.c free.c \
+ serial.c ser_ir.c printfl.c \
printf_large.c vprintf.c puts.c gets.c \
assert.c _strcat.c time.c printf_fast.c bpx.c
testMalloc(void)
{
void XDATA *p1, *p2, *p3;
-
+ char *p;
+ unsigned char i;
+
#if !defined(__gbz80) && !defined(__z80) && !defined(__GNUC__)
- init_dynamic_memory((MEMHEADER xdata *)heap, sizeof(heap));
+ init_dynamic_memory((MEMHEADER XDATA *)heap, sizeof(heap));
+
+ p1 = malloc(200);
+ ASSERT(p1 == NULL);
+ LOG(("p1 == NULL when out of memory\n"));
#endif
p1 = malloc(5);
LOG(("p2: %u\n", (unsigned) p2));
#endif
+ p = (char*)p2;
+ for (i=0; i<20; i++, p++)
+ *p = i;
+
+ p2 = realloc(p2, 25);
+ ASSERT(p2 != NULL);
+#ifdef PORT_HOST
+ LOG(("p2, after expanding realloc: %p\n", p2));
+#else
+ LOG(("p2, after expanding realloc: %u\n", (unsigned) p2));
+#endif
+
+ p = (char*)p2;
+ for (i=0; i<20; i++, p++)
+ ASSERT(*p == i);
+
+ p2 = realloc(p2, 15);
+ ASSERT(p2 != NULL);
+#ifdef PORT_HOST
+ LOG(("p2, after shrinking realloc: %p\n", p2));
+#else
+ LOG(("p2, after shrinking realloc: %u\n", (unsigned) p2));
+#endif
+
+ p = (char*)p2;
+ for (i=0; i<15; i++, p++)
+ ASSERT(*p == i);
+
free(p2);
p3 = malloc(10);
# define code
#endif
+const char *string1 = "\x00\x01";
+const char string2[] = "\x00\x01";
+
+#ifndef PORT_HOST
+#pragma disable_warning 147 //no warning about excess initializers (W_EXCESS_INITIALIZERS)
+//array will be truncated but warning will be suppressed
+//if truncation is incorrect, other ASSERTs will fail with high probability
+char STORAGE trunc[2] = {'a', 'b', 'c'};
+#endif
+
char STORAGE array[5] = {'a', 'b', 'c'};
#if TEST_G
void
testZeropad(void)
{
+ ASSERT(string1[1] == '\x01');
+ ASSERT(string2[1] == '\x01');
+
ASSERT(array[2] == 'c');
ASSERT(array[4] == 0);