2016-09-21 22:15:48 +00:00
|
|
|
#include "mcg.h"
|
|
|
|
|
|
|
|
static void print_blocks(char k, struct procedure* proc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
tracef(k, "%c: procedure %s\n", k, proc->name);
|
|
|
|
for (int i=0; i<proc->blocks_count; i++)
|
|
|
|
{
|
|
|
|
struct basicblock* bb = proc->blocks[i];
|
|
|
|
int j;
|
|
|
|
|
2016-09-22 21:19:29 +00:00
|
|
|
tracef(k, "%c:\n", k);
|
|
|
|
tracef(k, "%c: BLOCK: %s\n", k, bb->name);
|
2016-09-21 22:15:48 +00:00
|
|
|
|
2016-09-22 21:19:29 +00:00
|
|
|
tracef(k, "%c: from:", k);
|
2016-09-21 22:15:48 +00:00
|
|
|
for (int j=0; j<bb->inblocks_count; j++)
|
|
|
|
{
|
|
|
|
struct basicblock* obb = bb->inblocks[j];
|
2016-09-22 21:19:29 +00:00
|
|
|
tracef(k, " %s", obb->name);
|
2016-09-21 22:15:48 +00:00
|
|
|
}
|
2016-09-22 21:19:29 +00:00
|
|
|
tracef(k, "\n");
|
|
|
|
tracef(k, "%c: to:", k);
|
2016-09-21 22:15:48 +00:00
|
|
|
for (int j=0; j<bb->outblocks_count; j++)
|
|
|
|
{
|
|
|
|
struct basicblock* obb = bb->outblocks[j];
|
2016-09-22 21:19:29 +00:00
|
|
|
tracef(k, " %s", obb->name);
|
2016-09-21 22:15:48 +00:00
|
|
|
}
|
2016-09-22 21:19:29 +00:00
|
|
|
tracef(k, "\n");
|
|
|
|
|
|
|
|
for (int j=0; j<bb->irs_count; j++)
|
|
|
|
ir_print(k, bb->irs[j]);
|
2016-09-21 22:15:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void compile(struct procedure* proc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
print_blocks('1', proc);
|
2016-09-22 21:19:29 +00:00
|
|
|
|
2016-09-23 19:07:16 +00:00
|
|
|
pass_remove_dead_blocks(proc);
|
|
|
|
pass_convert_stack_ops(proc);
|
|
|
|
pass_splice_adjacent_blocks(proc);
|
2016-09-22 21:19:29 +00:00
|
|
|
|
|
|
|
print_blocks('2', proc);
|
2016-09-21 22:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* vim: set sw=4 ts=4 expandtab : */
|
|
|
|
|