aboutsummaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <[email protected]>2016-03-31 17:17:09 -0400
committerQuentin Carbonneaux <[email protected]>2016-03-31 17:17:09 -0400
commit0a81036fa2dfeb44befad86f0bf3e48b2f4ffed9 (patch)
treeb1078a98f83abe0bfb106b81fcdab7fa2ab75b91 /util.c
parent729aa97b799f72afdec3604f96526760701f36bc (diff)
move abi code in a new file
Diffstat (limited to 'util.c')
-rw-r--r--util.c13
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);
}