shithub: scc

Download patch

ref: 64ae09c9fd264a51ac2e8ccf18d37ba5e80be09b
parent: 54e5f131aa340b2ad1ff8bf2cc23024029fa8b50
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Mar 17 11:05:02 EDT 2015

Move reguse update to moveto()

This function is going to be used for all the register transfer,
so it is the best place where update the registers.

--- a/cc2/cgen.c
+++ b/cc2/cgen.c
@@ -102,10 +102,8 @@
 		for (bp = reg8; (c = *bp); ++bp) {
 			if (reguse[c])
 				continue;
-			reguse[c] = np;
 			return c;
 		}
-		/* TODO: Move variable to stack using PUSH/POP */
 		break;
 	case 2:
 		for (bp = reg16; (c = *bp); ++bp) {
@@ -113,10 +111,8 @@
 
 			if (reguse[u] || reguse[l])
 				continue;
-			reguse[u] = reguse[l] = np;
 			return c;
 		}
-		/* TODO: Move variable to stack using PUSH/POP */
 		break;
 	}
 	abort();
@@ -140,6 +136,7 @@
 		default:
 			abort();
 		}
+		reguse[reg] = np;
 		break;
 	case 2:
 		switch (op) {
@@ -153,6 +150,7 @@
 		default:
 			abort();
 		}
+		reguse[upper[reg]] = reguse[lower[reg]] = np;
 		break;
 	default:
 		abort();