projects
/
fw
/
sdcc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* sim/ucsim/cmd.src/cmdutil.cc: NUL device is detected as CG_FILE type
[fw/sdcc]
/
src
/
mcs51
/
gen.c
diff --git
a/src/mcs51/gen.c
b/src/mcs51/gen.c
index 576d529e25ab66efa3e117a09f809707e0f561dc..a2841f70701081452a7f27e7ba5da925a466433a 100644
(file)
--- a/
src/mcs51/gen.c
+++ b/
src/mcs51/gen.c
@@
-42,6
+42,7
@@
#include "SDCCpeeph.h"
#include "ralloc.h"
#include "gen.h"
#include "SDCCpeeph.h"
#include "ralloc.h"
#include "gen.h"
+#include "dbuf_string.h"
char *aopLiteral (value * val, int offset);
char *aopLiteralLong (value * val, int offset, int size);
char *aopLiteral (value * val, int offset);
char *aopLiteralLong (value * val, int offset, int size);
@@
-117,7
+118,7
@@
static char *rb1regs[] = {
"b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7"
};
"b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7"
};
-extern
FILE *codeOutFile
;
+extern
struct dbuf_s *codeOutBuf
;
static void saveRBank (int, iCode *, bool);
#define RESULTONSTACK(x) \
static void saveRBank (int, iCode *, bool);
#define RESULTONSTACK(x) \
@@
-149,32
+150,33
@@
static unsigned char SRMask[] =
/* emitcode - writes the code into a file : for now it is simple */
/*-----------------------------------------------------------------*/
static void
/* emitcode - writes the code into a file : for now it is simple */
/*-----------------------------------------------------------------*/
static void
-emitcode (char *inst, const char *fmt,...)
+emitcode (c
onst c
har *inst, const char *fmt,...)
{
va_list ap;
{
va_list ap;
- char lb[INITIAL_INLINEASM];
- char *lbp = lb;
+ struct dbuf_s dbuf;
+ const char *lbp, *lb;
+
+ dbuf_init (&dbuf, INITIAL_INLINEASM);
va_start (ap, fmt);
if (inst && *inst)
{
va_start (ap, fmt);
if (inst && *inst)
{
+ dbuf_append_str (&dbuf, inst);
+
if (fmt && *fmt)
{
if (fmt && *fmt)
{
- SNPRINTF (lb, sizeof(lb), "%s\t", inst);
- }
- else
- {
- SNPRINTF (lb, sizeof(lb), "%s", inst);
+ dbuf_append_char (&dbuf, '\t');
+ dbuf_tvprintf (&dbuf, fmt, ap);
}
}
-
- tvsprintf (lb + strlen(lb), sizeof(lb) - strlen(lb), fmt, ap);
}
else
{
}
else
{
-
tvsprintf (lb, sizeof(lb)
, fmt, ap);
+
dbuf_tvprintf (&dbuf
, fmt, ap);
}
}
+ lbp = lb = dbuf_c_str(&dbuf);
+
while (isspace ((unsigned char)*lbp))
{
lbp++;
while (isspace ((unsigned char)*lbp))
{
lbp++;
@@
-192,12
+194,15
@@
emitcode (char *inst, const char *fmt,...)
lineCurr->ic = _G.current_iCode;
lineCurr->isComment = (*lbp==';');
va_end (ap);
lineCurr->ic = _G.current_iCode;
lineCurr->isComment = (*lbp==';');
va_end (ap);
+
+ dbuf_destroy(&dbuf);
}
static void
emitLabel (symbol *tlbl)
{
emitcode ("", "%05d$:", tlbl->key + 100);
}
static void
emitLabel (symbol *tlbl)
{
emitcode ("", "%05d$:", tlbl->key + 100);
+ lineCurr->isLabel = 1;
}
/*-----------------------------------------------------------------*/
}
/*-----------------------------------------------------------------*/
@@
-3206,12
+3211,6
@@
resultRemat (iCode * ic)
return 0;
}
return 0;
}
-#if defined(__BORLANDC__) || defined(_MSC_VER)
-#define STRCASECMP stricmp
-#else
-#define STRCASECMP strcasecmp
-#endif
-
/*-----------------------------------------------------------------*/
/* inExcludeList - return 1 if the string is in exclude Reg list */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* inExcludeList - return 1 if the string is in exclude Reg list */
/*-----------------------------------------------------------------*/
@@
-3255,6
+3254,7
@@
genFunction (iCode * ic)
emitcode (";", "-----------------------------------------");
emitcode ("", "%s:", sym->rname);
emitcode (";", "-----------------------------------------");
emitcode ("", "%s:", sym->rname);
+ lineCurr->isLabel = 1;
ftype = operandType (IC_LEFT (ic));
_G.currentFunc = sym;
ftype = operandType (IC_LEFT (ic));
_G.currentFunc = sym;
@@
-4020,7
+4020,7
@@
genLabel (iCode * ic)
if (IC_LABEL (ic) == entryLabel)
return;
if (IC_LABEL (ic) == entryLabel)
return;
- emit
code ("", "%05d$:", (IC_LABEL (ic)->key + 100
));
+ emit
Label (IC_LABEL (ic
));
}
/*-----------------------------------------------------------------*/
}
/*-----------------------------------------------------------------*/
@@
-11714,7
+11714,7
@@
gen51Code (iCode * lic)
/* print the allocation information */
if (allocInfo && currFunc)
/* print the allocation information */
if (allocInfo && currFunc)
- printAllocInfo (currFunc, codeOut
File
);
+ printAllocInfo (currFunc, codeOut
Buf
);
/* if debug information required */
if (options.debug && currFunc)
{
/* if debug information required */
if (options.debug && currFunc)
{
@@
-11753,6
+11753,7
@@
gen51Code (iCode * lic)
if (options.iCodeInAsm) {
char regsInUse[80];
int i;
if (options.iCodeInAsm) {
char regsInUse[80];
int i;
+ char *iLine;
#if 0
for (i=0; i<8; i++) {
#if 0
for (i=0; i<8; i++) {
@@
-11769,7
+11770,9
@@
gen51Code (iCode * lic)
}
#endif
}
}
#endif
}
+ iLine = printILine(ic);
emitcode("", "; [%s] ic:%d: %s", regsInUse, ic->seq, printILine(ic));
emitcode("", "; [%s] ic:%d: %s", regsInUse, ic->seq, printILine(ic));
+ dbuf_free(iLine);
}
/* if the result is marked as
spilt and rematerializable or code for
}
/* if the result is marked as
spilt and rematerializable or code for
@@
-12008,6
+12011,6
@@
gen51Code (iCode * lic)
peepHole (&lineHead);
/* now do the actual printing */
peepHole (&lineHead);
/* now do the actual printing */
- printLine (lineHead, codeOut
File
);
+ printLine (lineHead, codeOut
Buf
);
return;
}
return;
}