major lifting: get rid of RReg

I've been septic since I introduced it, this commit
proves that it costs more than it helps.  I've also fixed
a bad bug in rega() where I alloc'ed the wrong size for
internal arrays.  Enums now have names so I can use them
to cast in gdb to get the name corresponding to a constant.
This commit is contained in:
Quentin Carbonneaux 2015-08-13 16:10:54 -04:00
parent 78bf28f56e
commit 5fc8104e00
8 changed files with 97 additions and 142 deletions

View file

@ -257,7 +257,7 @@ tmpref(char *v, int use)
{
int t;
for (t=0; t<ntmp; t++)
for (t=Tmp0; t<ntmp; t++)
if (strcmp(v, tmp[t].name) == 0)
goto Found;
if (ntmp++ >= NTmp)
@ -496,9 +496,12 @@ parsefn(FILE *f)
for (i=0; i<NBlk; i++)
bmap[i] = 0;
for (i=0; i<NTmp; i++)
tmp[i] = (Tmp){.name = ""};
ntmp = 1; /* first tmp is invalid */
ncon = 1; /* first con in 0 */
if (i < Tmp0)
tmp[i] = (Tmp){.type = TReg};
else
tmp[i] = (Tmp){.name = ""};
ntmp = Tmp0;
ncon = 1; /* first constant must be 0 */
curi = insb;
curb = 0;
lnum = 1;
@ -531,11 +534,15 @@ printref(Ref r, Fn *fn, FILE *f)
[TUndef] = "?",
[TWord] = "w",
[TLong] = "l",
[TReg] = "",
};
switch (r.type) {
case RTmp:
fprintf(f, "%%%s", fn->tmp[r.val].name);
if (r.val < Tmp0)
fprintf(f, "R%d", r.val);
else
fprintf(f, "%%%s", fn->tmp[r.val].name);
return ttoa[fn->tmp[r.val].type];
case RCon:
switch (fn->con[r.val].type) {
@ -554,9 +561,6 @@ printref(Ref r, Fn *fn, FILE *f)
case RSlot:
fprintf(f, "$%d", r.val);
break;
case RReg:
fprintf(f, "R%d", r.val);
break;
}
return "";
}