From 0a81036fa2dfeb44befad86f0bf3e48b2f4ffed9 Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Thu, 31 Mar 2016 17:17:09 -0400 Subject: move abi code in a new file --- util.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'util.c') 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; cncon; 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); } -- cgit 1.4.1