shithub: scc

Download patch

ref: 1bd29f0df1d13a8ef774b3954f7719bc5a690a4b
parent: 7ffcfc0452eba4d6d04674e0b145c3656c761df0
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Apr 15 09:42:42 EDT 2016

[cc2] Improve addr()

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

--- a/cc2/code.c
+++ b/cc2/code.c
@@ -27,7 +27,7 @@
 }
 
 static void
-addr(int op, Node *np, Addr *addr)
+addr(Node *np, Addr *addr)
 {
 	switch (addr->kind = np->op) {
 	case REG:
@@ -34,14 +34,14 @@
 		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,13 +54,13 @@
 {
 	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)