shithub: scc

Download patch

ref: 9b361f53cda590cb1dc5645301f600dac17d1c5d
parent: 96e6976155ca954ce9abeb308640e28901211479
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Mar 20 09:01:04 EDT 2015

Merge MEM and AUTO cases of assign()

They are exactly the same, only a movement between an address
and a register. If the address is indexed, then is better for us,
in other case is the same.

--- a/cc2/cgen.c
+++ b/cc2/cgen.c
@@ -333,6 +333,7 @@
 	switch (np->type.size) {
 	case 1:
 		switch (lp->op) {
+		case MEM:
 		case AUTO:
 			code(LDL, lp, rp);
 			break;
@@ -339,11 +340,6 @@
 		case REG:
 			/* TODO: what happens with the previous register? */
 			code(MOV, lp, rp);
-			break;
-		case MEM:
-			/* TODO: check if the variable is indexed */
-			index(lp);
-			code(LDL, lp, rp);
 			break;
 		default:
 			abort();