summaryrefslogtreecommitdiff
path: root/parse/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'parse/node.c')
-rw-r--r--parse/node.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/parse/node.c b/parse/node.c
index c3522cb..eb613ff 100644
--- a/parse/node.c
+++ b/parse/node.c
@@ -245,6 +245,22 @@ Node *mklbl(Srcloc loc, char *lbl)
return mkexpr(loc, Olit, n, NULL);
}
+char *genlblstr(char *buf, size_t sz, char *suffix)
+{
+ static int nextlbl;
+ bprintf(buf, 128, ".L%d%s", nextlbl++, suffix);
+ return buf;
+}
+
+Node *genlbl(Srcloc loc)
+{
+ char buf[128];
+
+ genlblstr(buf, 128, "");
+ return mklbl(loc, buf);
+}
+
+
Node *mkstr(Srcloc loc, Str val)
{
Node *n;
@@ -330,6 +346,23 @@ Node *mkdecl(Srcloc loc, Node *name, Type *ty)
return n;
}
+Node *gentemp(Srcloc loc, Type *ty, Node **dcl)
+{
+ char buf[128];
+ static int nexttmp;
+ Node *t, *r, *n;
+
+ bprintf(buf, 128, ".t%d", nexttmp++);
+ n = mkname(loc, buf);
+ t = mkdecl(loc, n, ty);
+ r = mkexpr(loc, Ovar, n, NULL);
+ r->expr.type = t->decl.type;
+ r->expr.did = t->decl.did;
+ if (dcl)
+ *dcl = t;
+ return r;
+}
+
Ucon *mkucon(Srcloc loc, Node *name, Type *ut, Type *et)
{
Ucon *uc;