shithub: scc

Download patch

ref: 3b779b98d1cbcf4e2803970c72927306f5e02603
parent: c7aa94922866485be4cd5dee6c0f04c75b2fcd46
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Nov 3 04:29:00 EDT 2021

cc2: Differentiate between variable and machine register

The actions performed for a register variable are different to
the actions for a machine register. For this reason is  needed
a way to differentiate between them, otherwise we can  confuse
integer constants and symbol pointers (the u value of  machine
registers and register variables).

--- a/src/cmd/cc/cc2/cc2.h
+++ b/src/cmd/cc/cc2/cc2.h
@@ -59,6 +59,7 @@
 	OTMP     = 'N',
 	OAUTO    = 'A',
 	OREG     = 'R',
+	OMREG    = 'G',
 	OCONST   = '#',
 	OSTRING  = '"',
 	OLOAD    = 'D',
--- a/src/cmd/cc/cc2/code.c
+++ b/src/cmd/cc/cc2/code.c
@@ -34,10 +34,7 @@
 	Symbol *sym;
 
 	switch (np->op) {
-	case OREG:
-		/* TODO:
-		 * At this moment this op is used also for register variables
-		 */
+	case OMREG:
 		addr->kind = SREG;
 		addr->u.reg = np->u.reg;
 		break;
@@ -46,6 +43,7 @@
 		/* TODO: Add support for more type of constants */
 		addr->u.i = np->u.i;
 		break;
+	case OREG:
 	case OTMP:
 	case OLABEL:
 	case OAUTO: