shithub: scc

Download patch

ref: 61a52a5ce37ea3f7e1342284d3abc6309df30b1e
parent: 37382404ddb754527377141d0e17fd9df287f643
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Mar 20 13:20:52 EDT 2015

Allow assignment of not register things

assign() was limited to register nodes, but this change
make possible to use another kind of nodes.

--- a/cc2/cgen.c
+++ b/cc2/cgen.c
@@ -81,6 +81,7 @@
 	}
 };
 
+/* TODO: Remove reg8 and reg16 arrays */
 static uint8_t
 allocreg(uint8_t size)
 {
@@ -245,6 +246,9 @@
 {
 	assert(np->type.size == 1);
 	switch (parent->op) {
+	case OASSIG:
+		moveto(np, allocreg(1));
+		break;
 	case OADD:
 	case OSUB:
 		switch (np->op) {
@@ -317,7 +321,6 @@
 	Node *lp = np->left, *rp = np->right;
 	Symbol *sym = lp->sym;
 
-	assert(rp->op == REG);
 	switch (np->type.size) {
 	case 1:
 		switch (lp->op) {
@@ -324,8 +327,11 @@
 		case MEM:
 			if (sym && sym->index)
 				lp->op = INDEX;
+			/* PASSTROUGH */
 		case INDEX:
 		case AUTO:
+			if (rp->op != REG)
+				move(rp, np);
 			code(LDL, lp, rp);
 			break;
 		case REG: