diff options
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/util.c b/util.c index 1654491..238c996 100644 --- a/util.c +++ b/util.c @@ -187,7 +187,8 @@ newtmp(char *prfx, int k, Fn *fn) t = fn->ntmp++; vgrow(&fn->tmp, fn->ntmp); - sprintf(fn->tmp[t].name, "%s%d", prfx, ++n); + if (prfx) + sprintf(fn->tmp[t].name, "%s%d", prfx, ++n); fn->tmp[t].cls = k; fn->tmp[t].slot = -1; fn->tmp[t].nuse = +1; @@ -195,6 +196,13 @@ newtmp(char *prfx, int k, Fn *fn) return TMP(t); } +void +chuse(Ref r, int du, Fn *fn) +{ + if (rtype(r) == RTmp) + fn->tmp[r.val].nuse += du; +} + Ref getcon(int64_t val, Fn *fn) { @@ -203,8 +211,7 @@ getcon(int64_t val, Fn *fn) for (c=0; c<fn->ncon; c++) if (fn->con[c].type == CBits && fn->con[c].bits.i == val) return CON(c); - fn->ncon++; - vgrow(&fn->con, fn->ncon); + vgrow(&fn->con, ++fn->ncon); fn->con[c] = (Con){.type = CBits, .bits.i = val}; return CON(c); } |