ack/mach/proto/mcg/main.c
David Given 9077baa850 Add a bodged in algorithm for converting basic block communication from stacked
variables to SSA. Also add dead block removal and block splicing. IR code is
much better now.
2016-09-22 23:19:29 +02:00

73 lines
1 KiB
C

#include "mcg.h"
void fatal(const char* msg, ...)
{
va_list ap;
va_start(ap, msg);
vfprintf(stderr, msg, ap);
fprintf(stderr, "\n");
va_end(ap);
abort();
}
const char* aprintf(const char* fmt, ...)
{
int n;
char* p;
va_list ap;
va_start(ap, fmt);
n = vsnprintf(NULL, 0, fmt, ap) + 1;
va_end(ap);
p = malloc(n);
if (!p)
return NULL;
va_start(ap, fmt);
vsnprintf(p, n, fmt, ap);
va_end(ap);
return p;
}
bool tracing(char k)
{
switch (k)
{
case 'E': return false;
case '0': return false;
case '1': return true;
case '2': return true;
default: return true;
}
}
void tracef(char k, const char* fmt, ...)
{
va_list ap;
if (tracing(k))
{
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
}
}
int main(int argc, char* argv[])
{
symbol_init();
if (!EM_open(argv[1]))
fatal("Couldn't open input file: %s", EM_error);
parse_em();
EM_close();
return 0;
}
/* vim: set sw=4 ts=4 expandtab : */