scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 924e73fca9662a6295f2cb5c19be2eac1c2033c9
parent f60d000d6fbecc3541928fe1112bed3d0dbaeef5
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
Date:   Fri, 15 Apr 2016 13:42:42 +0200

[cc2] Improve addr()

Remove unused op argument and add TMP nodes to
the list of nodes that can be used in it.

Diffstat:
Mcc2/code.c | 16++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/cc2/code.c b/cc2/code.c @@ -27,21 +27,21 @@ nextpc(void) } static void -addr(int op, Node *np, Addr *addr) +addr(Node *np, Addr *addr) { switch (addr->kind = np->op) { case REG: addr->u.reg = np->u.reg; break; case CONST: - /* TODO: different type of constants*/ - np->u.i = np->u.i; + abort(); break; case LABEL: addr->u.sym = np->u.sym; break; case AUTO: - case INDEX: + case TMP: + addr->u.sym = np->u.sym; break; default: abort(); @@ -54,14 +54,14 @@ code(int op, Node *to, Node *from1, Node *from2) { nextpc(); if (from1) - addr(op, from1, &pc->from1); + addr(from1, &pc->from1); if (from2) - addr(op, from2, &pc->from2); + addr(from2, &pc->from2); if (to) - addr(op, to, &pc->to); + addr(to, &pc->to); + pc->op = op; } - void delcode(void) {