Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
341 changes: 266 additions & 75 deletions src/SDCC.lex

Large diffs are not rendered by default.

2,186 changes: 1,403 additions & 783 deletions src/SDCC.y

Large diffs are not rendered by default.

62 changes: 41 additions & 21 deletions src/SDCCBBlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,15 @@
int eBBNum = 0;
set *graphEdges = NULL; /* list of edges in this flow graph */

struct _dumpFiles dumpFiles[] = {{DUMP_RAW0, ".dumpraw0", NULL},
{DUMP_RAW1, ".dumpraw1", NULL},
{DUMP_CSE, ".dumpcse", NULL},
{DUMP_DFLOW, ".dumpdflow", NULL},
{DUMP_GCSE, ".dumpgcse", NULL},
{DUMP_DEADCODE, ".dumpdeadcode", NULL},
{DUMP_LOOP, ".dumploop", NULL},
{DUMP_LOOPG, ".dumploopg", NULL},
{DUMP_LOOPD, ".dumploopd", NULL},
{DUMP_RANGE, ".dumprange", NULL},
{DUMP_PACK, ".dumppack", NULL},
{DUMP_RASSGN, ".dumprassgn", NULL},
{DUMP_LRANGE, ".dumplrange", NULL},
{DUMP_LOSPRE, ".dumplospre", NULL},
{0, NULL, NULL}};
struct _dumpFiles dumpFiles[] = {
{DUMP_RAW0, ".dumpraw0", NULL}, {DUMP_RAW1, ".dumpraw1", NULL},
{DUMP_CSE, ".dumpcse", NULL}, {DUMP_DFLOW, ".dumpdflow", NULL},
{DUMP_GCSE, ".dumpgcse", NULL}, {DUMP_DEADCODE, ".dumpdeadcode", NULL},
{DUMP_LOOP, ".dumploop", NULL}, {DUMP_LOOPG, ".dumploopg", NULL},
{DUMP_LOOPD, ".dumploopd", NULL}, {DUMP_RANGE, ".dumprange", NULL},
{DUMP_PACK, ".dumppack", NULL}, {DUMP_RASSGN, ".dumprassgn", NULL},
{DUMP_LRANGE, ".dumplrange", NULL}, {DUMP_LOSPRE, ".dumplospre", NULL},
{DUMP_CUSTOM, ".dumpcustom", NULL}, {0, NULL, NULL}};

/*-----------------------------------------------------------------*/
/* printEntryLabel - prints entry label of a ebblock */
Expand Down Expand Up @@ -111,7 +105,8 @@ FILE *createDumpFile(int id) {
#endif
dbuf_append_str(&dumpFileName, dumpFilesPtr->ext);
if (!(dumpFilesPtr->filePtr = fopen(dbuf_c_str(&dumpFileName), "w"))) {
werror(E_FILE_OPEN_ERR, dbuf_c_str(&dumpFileName));
werror(E_OUTPUT_FILE_OPEN_ERR, dbuf_c_str(&dumpFileName),
strerror(errno));
dbuf_destroy(&dumpFileName);
exit(1);
}
Expand Down Expand Up @@ -195,9 +190,11 @@ void dumpEbbsToFileExt(int id, ebbIndex *ebbi) {
fprintf(
of,
"\n----------------------------------------------------------------\n");
fprintf(of, "Basic Block %s (df:%d bb:%d lvl:%d): loopDepth=%d%s%s%s\n",
fprintf(of,
"Basic Block %s (df:%d bb:%d lvl:%ld:%ld): loopDepth=%d%s%s%s\n",
ebbs[i]->entryLabel->name, ebbs[i]->dfnum, ebbs[i]->bbnum,
ebbs[i]->entryLabel->level, ebbs[i]->depth,
ebbs[i]->entryLabel->level / LEVEL_UNIT,
ebbs[i]->entryLabel->level % LEVEL_UNIT, ebbs[i]->depth,
ebbs[i]->noPath ? " noPath" : "",
ebbs[i]->partOfLoop ? " partOfLoop" : "",
ebbs[i]->isLastInLoop ? " isLastInLoop" : "");
Expand Down Expand Up @@ -356,7 +353,7 @@ eBBlock *iCode2eBBlock(iCode *ic) {
/*-----------------------------------------------------------------*/
/* eBBWithEntryLabel - finds the basic block with the entry label */
/*-----------------------------------------------------------------*/
eBBlock *eBBWithEntryLabel(ebbIndex *ebbi, symbol *eLabel) {
eBBlock *eBBWithEntryLabel(ebbIndex *ebbi, const symbol *eLabel) {
eBBlock **ebbs = ebbi->bbOrder;
int count = ebbi->count;
int i;
Expand Down Expand Up @@ -682,6 +679,9 @@ void replaceLabel(eBBlock *ebp, symbol *fromLbl, symbol *toLbl) {
else if (isSymbolEqual(IC_FALSE(ic), fromLbl))
IC_FALSE(ic) = toLbl;
break;

case JUMPTABLE:
replaceSetItem(IC_JTLABELS(ic), fromLbl, toLbl);
}
}

Expand All @@ -700,8 +700,9 @@ iCode *iCodeFromeBBlock(eBBlock **ebbs, int count) {
if (ebbs[i]->sch == NULL)
continue;

if (ebbs[i]->noPath && (ebbs[i]->entryLabel != entryLabel &&
ebbs[i]->entryLabel != returnLabel)) {
if (ebbs[i]->noPath && optimize.label4 &&
(ebbs[i]->entryLabel != entryLabel &&
ebbs[i]->entryLabel != returnLabel)) {
iCode *ic = NULL;
bool foundNonlabel = 0;
ic = ebbs[i]->sch;
Expand Down Expand Up @@ -768,3 +769,22 @@ int otherPathsPresent(eBBlock **ebbs, eBBlock *this) {
else
return 1;
}

/*-----------------------------------------------------------------*/
/* freeBBlockData - Deallocate data structures associated with */
/* the current blocks. They will all be recomputed if the */
/* iCode chain is divided into blocks again later. */
/*-----------------------------------------------------------------*/
void freeeBBlockData(ebbIndex *ebbi) {
int i;
eBBlock **ebbs = ebbi->bbOrder;

for (i = 0; i < ebbi->count; i++) {
deleteSet(&ebbs[i]->succList);
deleteSet(&ebbs[i]->predList);
freeBitVect(ebbs[i]->succVect);
freeBitVect(ebbs[i]->domVect);

freeCSEdata(ebbs[i]);
}
}
3 changes: 2 additions & 1 deletion src/SDCCBBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ extern set *graphEdges;
DEFSETFUNC(printEntryLabel);
eBBlock *neweBBlock();
edge *newEdge(eBBlock *, eBBlock *);
eBBlock *eBBWithEntryLabel(ebbIndex *, symbol *);
eBBlock *eBBWithEntryLabel(ebbIndex *, const symbol *);
DEFSETFUNC(ifFromIs);
set *edgesTo(eBBlock *);
void remiCodeFromeBBlock(eBBlock *, iCode *);
Expand All @@ -105,5 +105,6 @@ void replaceLabel(eBBlock *, symbol *, symbol *);
void dumpEbbsToFileExt(int, ebbIndex *);
void dumpLiveRanges(int, hTab *liveRanges);
void closeDumpFiles();
void freeeBBlockData(ebbIndex *);

#endif
2 changes: 1 addition & 1 deletion src/SDCCargs.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ typedef struct {
} OPTION;

char *getStringArg(const char *szStart, char **argv, int *pi, int argc);
int getIntArg(const char *szStart, char **argv, int *pi, int argc);
long getIntArg(const char *szStart, char **argv, int *pi, int argc);

#endif
5 changes: 4 additions & 1 deletion src/SDCCasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ assemblers.

#include <errno.h>

#include "SDCCsymt.h"
#include "common.h"
#include "dbuf_string.h"

Expand All @@ -53,7 +54,7 @@ const char *FileBaseName(const char *fileFullName) {
void dbuf_tvprintf(struct dbuf_s *dbuf, const char *format, va_list ap) {
/*
Under Linux PPC va_list is a structure instead of a primitive type,
and doesnt like being passed around. This version turns everything
and doesn't like being passed around. This version turns everything
into one function.

Supports:
Expand Down Expand Up @@ -224,6 +225,8 @@ const char *printILine(iCode *ic) {
struct dbuf_s tmpBuf;
iCodeTable *icTab = getTableEntry(ic->op);

wassert(icTab);

dbuf_init(&tmpBuf, 1024);

if (INLINEASM == ic->op)
Expand Down
Loading