commit 496963e823b09f572271baea68b42376b2c58ad4
parent 6902f4ced599888da040b7abe331a07ddf88c46b
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sun, 15 Mar 2015 10:01:44 +0000
Use a Node array instead of bool in reguse
We want to know whcich is the node which is using some register
so the best option is to keep it in the register array.
Diffstat:
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/cc2/cgen.c b/cc2/cgen.c
@@ -8,7 +8,7 @@
#include "cc2.h"
-static bool reguse[NREGS];
+static Node *reguse[NREGS];
static char upper[] = {[DE] = D, [HL] = H, [BC] = B, [IY] = IYH};
static char lower[] = {[DE] = E, [HL] = L, [BC] = C, [IY] = IYL};
@@ -88,7 +88,7 @@ static char
allocreg(Node *np)
{
static char reg8[] = {A, B, C, D, E, H, L, IYL, IY, 0};
- static char reg16[] = {BC, HL, DE, IY, 0};
+ static char reg16[] = {BC, DE, IY, 0};
char *bp, c;
switch (np->type.size) {
@@ -96,7 +96,7 @@ allocreg(Node *np)
for (bp = reg8; (c = *bp); ++bp) {
if (reguse[c])
continue;
- reguse[c] = 1;
+ reguse[c] = np;
return c;
}
/* TODO: Move variable to stack using PUSH/POP */
@@ -107,8 +107,7 @@ allocreg(Node *np)
if (reguse[u] || reguse[l])
continue;
- reguse[l] = 1;
- reguse[u];
+ reguse[u] = reguse[l] = np;
return c;
}
/* TODO: Move variable to stack using PUSH/POP */