summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2013-02-09 19:18:06 -0500
committerOri Bernstein <ori@eigenstate.org>2013-02-09 19:18:06 -0500
commit3eebcf6c31e23b12d11332f3b424bfe91dc66dcc (patch)
tree92b54b283074aee4adf33b96391d23999cd8e2e7
parent25be8b19d826b8faf73275e0294f661f1a4c32fe (diff)
downloadmc-3eebcf6c31e23b12d11332f3b424bfe91dc66dcc.tar.gz
Split out printing basic blocks in writeasm()
It's easier to call the function from the debugger this way.
-rw-r--r--6/isel.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/6/isel.c b/6/isel.c
index 6a82941..95ebbe3 100644
--- a/6/isel.c
+++ b/6/isel.c
@@ -819,19 +819,25 @@ static void epilogue(Isel *s)
g(s, Iret, NULL);
}
+static void writebb(FILE *fd, Asmbb *bb)
+{
+ size_t i;
+
+ for (i = 0; i < bb->nlbls; i++)
+ fprintf(fd, "%s:\n", bb->lbls[i]);
+ for (i = 0; i < bb->ni; i++)
+ iprintf(fd, bb->il[i]);
+}
+
static void writeasm(FILE *fd, Isel *s, Func *fn)
{
- size_t i, j;
+ size_t i;
if (fn->isexport || !strcmp(fn->name, Symprefix "main"))
fprintf(fd, ".globl %s\n", fn->name);
fprintf(fd, "%s:\n", fn->name);
- for (j = 0; j < s->cfg->nbb; j++) {
- for (i = 0; i < s->bb[j]->nlbls; i++)
- fprintf(fd, "%s:\n", s->bb[j]->lbls[i]);
- for (i = 0; i < s->bb[j]->ni; i++)
- iprintf(fd, s->bb[j]->il[i]);
- }
+ for (i = 0; i < s->nbb; i++)
+ writebb(fd, s->bb[i]);
}
static Asmbb *mkasmbb(Bb *bb)
@@ -959,6 +965,7 @@ void genasm(FILE *fd, Func *fn, Htab *globls)
epilogue(&is);
regalloc(&is);
+ peep(&is);
if (debugopt['i'])
writeasm(stdout, &is, fn);
writeasm(fd, &is, fn);