scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit a0d19a4ca73c1c2c54f9e053f6ac9983098dfbfb
parent 0e08446b45ed4de0faa2573ca1c523e83bed08e5
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat,  4 Jan 2025 14:29:54 +0100

cc2: Improve debug output

Diffstat:
Msrc/cmd/scc-cc/cc2/cfg.c | 2--
Msrc/cmd/scc-cc/cc2/node.c | 32+++++++++++++++++++++++++++++++-
2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/cmd/scc-cc/cc2/cfg.c b/src/cmd/scc-cc/cc2/cfg.c @@ -323,8 +323,6 @@ optjmps(Node *np) void gencfg(void) { - PRTREE("before_gencfg"); - apply(optjmps); apply(optlabels); DBG("new cfg"); diff --git a/src/cmd/scc-cc/cc2/node.c b/src/cmd/scc-cc/cc2/node.c @@ -36,7 +36,34 @@ prnode(Node *np) prnode(np->left); prnode(np->right); - fprintf(stderr, "\t%c%lu", np->op, np->type.size); + switch (np->op) { + case OBRANCH: + case OJMP: + fprintf(stderr, + "\t%c -> L%u", + np->op, np->u.sym->numid); + break; + case OCONST: + fprintf(stderr, + "\t%c%lu{%llu}", + np->op, np->type.size, np->u.i); + break; + case OAUTO: + case OREG: + case OMEM: + case OLABEL: + case OTMP: + fprintf(stderr, + "\t%c%lu[%u]", + np->op, np->type.size, np->u.sym->numid); + break; + default: + fprintf(stderr, + "\t%c%lu", + np->op, np->type.size); + break; + } + fprintf(stderr,"(%d,%d)", np->complex, np->address); } void @@ -51,6 +78,9 @@ prtree(Node *np) fprintf(stderr, "(%d)", bb ? bb->id : 0); if (np->flags & BBEXIT) putc('>', stderr); + putc('\t', stderr); + if (np->label) + fprintf(stderr, "L%u:", np->label->numid); prnode(np); putc('\n', stderr);