commit 732711fe948bca7542f04347fa6261c85f56fe1e
parent d229239629cca5886993eeeca0359d5c5f31ce91
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 3 Nov 2021 08:29:00 +0100
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).
Diffstat:
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/cmd/cc/cc2/cc2.h b/src/cmd/cc/cc2/cc2.h
@@ -59,6 +59,7 @@ enum op {
OTMP = 'N',
OAUTO = 'A',
OREG = 'R',
+ OMREG = 'G',
OCONST = '#',
OSTRING = '"',
OLOAD = 'D',
diff --git a/src/cmd/cc/cc2/code.c b/src/cmd/cc/cc2/code.c
@@ -34,10 +34,7 @@ addr(Node *np, Addr *addr)
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 @@ addr(Node *np, Addr *addr)
/* TODO: Add support for more type of constants */
addr->u.i = np->u.i;
break;
+ case OREG:
case OTMP:
case OLABEL:
case OAUTO: