USE_ALT_LEX = 0
-PORTS = mcs51 z80 avr ds390 pic
+PORTS = mcs51 z80 avr ds390 pic izt
PORT_LIBS = $(PORTS:%=%/port.a)
ifeq ($(DISABLE_GC),1)
if (!htab)
return NULL;
- for (htip = htab->table[key] ; htip ; htip = htip->next ) {
+ for (htip = htab->table[key] ; htip ; htip = htip->next) {
/* if a compare function is given use it */
- if (compare && compare(pkey, htip->pkey))
+ if (compare && compare(pkey, htip->pkey)) {
break;
- else
- if (pkey == htip->pkey)
+ }
+ else {
+ if (pkey == htip->pkey) {
break;
+ }
+ }
}
return htip;
}
} operand ;
/* definition for intermediate code */
-#define IC_RESULT(x) x->ulrrcnd.lrr.result
-#define IC_LEFT(x) x->ulrrcnd.lrr.left
-#define IC_RIGHT(x) x->ulrrcnd.lrr.right
-#define IC_COND(x) x->ulrrcnd.cnd.condition
-#define IC_TRUE(x) x->ulrrcnd.cnd.trueLabel
-#define IC_FALSE(x) x->ulrrcnd.cnd.falseLabel
-#define IC_LABEL(x) x->argLabel.label
-#define IC_ARGS(x) x->argLabel.args
-#define IC_JTCOND(x) x->ulrrcnd.jmpTab.condition
-#define IC_JTLABELS(x) x->ulrrcnd.jmpTab.labels
-#define IC_INLINE(x) x->inlineAsm
+#define IC_RESULT(x) (x)->ulrrcnd.lrr.result
+#define IC_LEFT(x) (x)->ulrrcnd.lrr.left
+#define IC_RIGHT(x) (x)->ulrrcnd.lrr.right
+#define IC_COND(x) (x)->ulrrcnd.cnd.condition
+#define IC_TRUE(x) (x)->ulrrcnd.cnd.trueLabel
+#define IC_FALSE(x) (x)->ulrrcnd.cnd.falseLabel
+#define IC_LABEL(x) (x)->argLabel.label
+#define IC_ARGS(x) (x)->argLabel.args
+#define IC_JTCOND(x) (x)->ulrrcnd.jmpTab.condition
+#define IC_JTLABELS(x) (x)->ulrrcnd.jmpTab.labels
+#define IC_INLINE(x) (x)->inlineAsm
typedef struct iCode
{
// No unistd.h in Borland C++
extern int access(const char *, int);
#define X_OK 1
+
#endif
//REMOVE ME!!!
#if !OPT_DISABLE_PIC
&pic14_port,
#endif
+#if !OPT_DISABLE_I186
+ &i186_port,
+#endif
+#if !OPT_DISABLE_TLCS900H
+ &tlcs900h_port,
+#endif
};
#define NUM_PORTS (sizeof(_ports)/sizeof(_ports[0]))
exit(1);
}
+static void _validatePorts(void)
+{
+ int i;
+ for (i=0; i<NUM_PORTS; i++) {
+ if (_ports[i]->magic != PORT_MAGIC) {
+ printf("Error: port %s is incomplete.\n", _ports[i]->target);
+ wassert(0);
+ }
+ }
+}
+
void buildCmdLine(char *into, char **args, const char **cmds,
const char *p1, const char *p2,
const char *p3, const char **list)
static void _findPort(int argc, char **argv)
{
+ _validatePorts();
+
argc--;
while (argc) {
if (!strncmp(*argv, "-m", 2)) {
/*-----------------------------------------------------------------*/
/* redoStackOffsets :- will reassign the values for stack offsets */
/*-----------------------------------------------------------------*/
-void redoStackOffsets ()
+void redoStackOffsets(void)
{
symbol *sym;
int sPtr = 0;
return shash_find(_h, szKey);
}
-static va_list _iprintf(char *pInto, const char *sz, va_list ap)
+#if 0
+static void _iprintf(char *pInto, const char *sz, va_list *pap)
{
char format[MAX_TOKEN_LEN];
char *pStart = pInto;
*p++ = *sz++;
*p++ = *sz++;
*p = '\0';
- vsprintf(pInto, format, ap);
+ vsprintf(pInto, format, *pap);
/* PENDING: Assume that the arg length was an int */
- (void)va_arg(ap, int);
+ (void)va_arg(*pap, int);
}
}
pInto = pStart + strlen(pStart);
}
}
*pInto = '\0';
-
- return ap;
}
void tvsprintf(char *buffer, const char *sz, va_list ap)
*p = '\0';
/* Now find the token in the token list */
if ((t = _findMapping(token))) {
- ap = _iprintf(pInto, t, ap);
+ printf("tvsprintf: found token \"%s\" to \"%s\"\n", token, t);
+ _iprintf(pInto, t, &ap);
pInto = buffer + strlen(buffer);
}
else {
}
*pInto = '\0';
}
+#else
+// Append a string onto another, and update the pointer to the end of
+// the new string.
+static char *_appendAt(char *at, char *onto, const char *sz)
+{
+ wassert(at && onto && sz);
+ strcpy(at, sz);
+ return at + strlen(sz);
+}
+
+void tvsprintf(char *buffer, 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
+ // into one function.
+
+ // Supports:
+ // !tokens
+ // %[CIF] - special formats with no argument (ie list isnt touched)
+ // All of the system formats
+
+ // This is acheived by expanding the tokens and zero arg formats into
+ // one big format string, which is passed to the native printf.
+ static int count;
+ char newformat[MAX_INLINEASM];
+ char *pInto = newformat;
+ char *p;
+ char token[MAX_TOKEN_LEN];
+ const char *sz = format;
+
+ // NULL terminate it to let strlen work.
+ *pInto = '\0';
+
+ while (*sz) {
+ if (*sz == '!') {
+ /* Start of a token. Search until the first
+ [non alpha, *] and call it a token. */
+ const char *t;
+ p = token;
+ sz++;
+ while (isalpha(*sz) || *sz == '*') {
+ *p++ = *sz++;
+ }
+ *p = '\0';
+ /* Now find the token in the token list */
+ if ((t = _findMapping(token))) {
+ pInto = _appendAt(pInto, newformat, t);
+ }
+ else {
+ fprintf(stderr, "Cant find token \"%s\"\n", token);
+ wassert(0);
+ }
+ }
+ else if (*sz == '%') {
+ // See if its one that we handle.
+ sz++;
+ switch (*sz) {
+ case 'C':
+ // Code segment name.
+ pInto = _appendAt(pInto, newformat, CODE_NAME);
+ break;
+ case 'F':
+ // Source file name.
+ pInto = _appendAt(pInto, newformat, srcFileName);
+ break;
+ case 'I': {
+ // Unique ID.
+ char id[20];
+ sprintf(id, "%u", ++count);
+ pInto = _appendAt(pInto, newformat, id);
+ break;
+ }
+ default:
+ // Not one of ours. Copy until the end.
+ *pInto++ = '%';
+ while (!isalpha(*sz)) {
+ *pInto++ = *sz++;
+ }
+ *pInto++ = *sz++;
+ }
+ }
+ else {
+ *pInto++ = *sz++;
+ }
+ }
+ *pInto = '\0';
+
+ // Now do the actual printing
+ vsprintf(buffer, newformat, ap);
+}
+#endif
void tfprintf(FILE *fp, const char *szFormat, ...)
{
0, /* leave ge */
0, /* leave != */
0, /* leave == */
-
+ PORT_MAGIC
};
OBJ = gen.o ralloc.o main.o
LIB = port.a
-CFLAGS = -g -Wall -O2
CFLAGS += -I.. -I.
all: $(LIB)
1, /* transform <= to ! > */
1, /* transform >= to ! < */
1, /* transform != to !(a == b) */
- 0 /* leave == */
+ 0, /* leave == */
+ PORT_MAGIC
};
va_start(ap, szFormat);
- vsprintf(buffer, szFormat, ap);
+ tvsprintf(buffer, szFormat, ap);
_tidyUp(buffer);
void izt_addEmittersToHTab(hTab **into, EMITTER _base_emitters[])
{
while (_base_emitters->emit != NULL) {
- printf("Added an emitter for %u %p\n", _base_emitters->op, _base_emitters);
hTabAddItemLong(into, _base_emitters->op, _base_emitters, _base_emitters);
_base_emitters++;
}
1, /* transform <= to ! > */
1, /* transform >= to ! < */
1, /* transform != to !(a == b) */
- 0 /* leave == */
+ 0, /* leave == */
+ PORT_MAGIC
};
// And free all registers.
_freeAllRegs();
}
+
+void warningStopper(void)
+{
+ // For now references all unused functions.
+ _dumpRegs();
+ _packRegisters(NULL);
+ _getSubReg(NULL, 0, 0);
+}
{ 0, REG_ID_NONE,"??", 0, { REG_ID_NONE, REG_ID_NONE, REG_ID_NONE } }
};
+static IZT_PORT _tlcs900h_port = {
+ _tlcs900h_regs
+};
+
static char _defaultRules[] =
{
//#include "peeph.rul"
};
-/* list of key words used by msc51 */
static char *_tlcs900h_keywords[] = {
NULL
};
static void _tlcs900h_init(void)
{
asm_addTree(&asm_asxxxx_mapping);
+ izt_init(&_tlcs900h_port);
}
static void _tlcs900h_reset_regparm()
1, /* transform <= to ! > */
1, /* transform >= to ! < */
1, /* transform != to !(a == b) */
- 0 /* leave == */
+ 0, /* leave == */
+ PORT_MAGIC
};
1, /* transform <= to ! > */
1, /* transform >= to ! < */
1, /* transform != to !(a == b) */
- 0 /* leave == */
+ 0, /* leave == */
+ PORT_MAGIC
};
1, /* transform <= to ! > */
1, /* transform >= to ! < */
1, /* transform != to !(a == b) */
- 0 /* leave == */
+ 0, /* leave == */
+ PORT_MAGIC
};
bool ge_nlt ; /* transform (a >= b) to !(a < b) */
bool ne_neq ; /* transform a != b --> ! (a == b) */
bool eq_nne ; /* transform a == b --> ! (a != b) */
+
+#define PORT_MAGIC 0xAC32
+ /** Used at runtime to detect if this structure has been completly filled in. */
+ int magic;
} PORT;
extern PORT *port;
#if !OPT_DISABLE_PIC
extern PORT pic14_port;
#endif
+#if !OPT_DISABLE_I186
+extern PORT i186_port;
+#endif
+#if !OPT_DISABLE_TLCS900H
+extern PORT tlcs900h_port;
+#endif
/* Test to see if we are current compiling in DS390 mode. */
#define IS_MCS51_PORT (port == &mcs51_port)
_reset_regparm,
_reg_parm,
_process_pragma,
- TRUE
+ TRUE,
+ 0, /* leave lt */
+ 0, /* leave gt */
+ 1, /* transform <= to ! > */
+ 1, /* transform >= to ! < */
+ 1, /* transform != to !(a == b) */
+ 0, /* leave == */
+ PORT_MAGIC
};
/* Globals */
1, /* transform <= to ! > */
1, /* transform >= to ! < */
1, /* transform != to !(a == b) */
- 0 /* leave == */
+ 0, /* leave == */
+ PORT_MAGIC
};