summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2012-06-11 19:00:52 -0400
committerOri Bernstein <ori@eigenstate.org>2012-06-11 19:00:52 -0400
commit8865ed9510427f9af64eeeaa18f8209c91aeb456 (patch)
tree8637c3f57547622f07549277683e2c84f3e28b77
parent9d00fe8f782d9c86ae4b787acef760ab8dc82af0 (diff)
downloadmc-8865ed9510427f9af64eeeaa18f8209c91aeb456.tar.gz
Make unexported functions static.
Just cleaner that way.
-rw-r--r--8/isel.c45
-rw-r--r--8/reduce.c60
-rw-r--r--opt/cfg.c6
-rw-r--r--parse/dump.c5
-rw-r--r--parse/htab.c4
-rw-r--r--parse/infer.c2
-rw-r--r--parse/parse.h2
-rw-r--r--parse/pickle.c4
-rw-r--r--parse/type.c7
9 files changed, 56 insertions, 79 deletions
diff --git a/8/isel.c b/8/isel.c
index 0d0e4eb..82be39b 100644
--- a/8/isel.c
+++ b/8/isel.c
@@ -48,7 +48,7 @@ struct {
};
-Loc loc(Isel *s, Node *n)
+static Loc loc(Isel *s, Node *n)
{
Loc l;
Node *v;
@@ -82,12 +82,12 @@ Loc loc(Isel *s, Node *n)
return l;
}
-Mode mode(Node *n)
+static Mode mode(Node *n)
{
return ModeL;
}
-Loc coreg(Loc r, Mode m)
+static Loc coreg(Loc r, Mode m)
{
Loc l;
@@ -117,7 +117,7 @@ Loc coreg(Loc r, Mode m)
return l;
}
-Insn *mkinsnv(AsmOp op, va_list ap)
+static Insn *mkinsnv(AsmOp op, va_list ap)
{
Loc *l;
Insn *i;
@@ -126,26 +126,13 @@ Insn *mkinsnv(AsmOp op, va_list ap)
n = 0;
i = malloc(sizeof(Insn));
i->op = op;
- if (op == Isetnz)
- breakhere();
while ((l = va_arg(ap, Loc*)) != NULL)
i->args[n++] = *l;
i->narg = n;
return i;
}
-Insn *mkinsn(AsmOp op, ...)
-{
- va_list ap;
- Insn *i;
-
- va_start(ap, op);
- i = mkinsnv(op, ap);
- va_end(ap);
- return i;
-}
-
-void g(Isel *s, AsmOp op, ...)
+static void g(Isel *s, AsmOp op, ...)
{
va_list ap;
Insn *i;
@@ -156,7 +143,7 @@ void g(Isel *s, AsmOp op, ...)
lappend(&s->il, &s->ni, i);
}
-void load(Isel *s, Loc *a, Loc *b)
+static void load(Isel *s, Loc *a, Loc *b)
{
Loc l;
assert(b->type == Locreg);
@@ -167,7 +154,7 @@ void load(Isel *s, Loc *a, Loc *b)
g(s, Imov, &l, b, NULL);
}
-void stor(Isel *s, Loc *a, Loc *b)
+static void stor(Isel *s, Loc *a, Loc *b)
{
Loc l;
@@ -180,7 +167,7 @@ void stor(Isel *s, Loc *a, Loc *b)
}
/* ensures that a location is within a reg */
-Loc inr(Isel *s, Loc a)
+static Loc inr(Isel *s, Loc a)
{
Loc r;
@@ -192,7 +179,7 @@ Loc inr(Isel *s, Loc a)
}
/* ensures that a location is within a reg or an imm */
-Loc inri(Isel *s, Loc a)
+static Loc inri(Isel *s, Loc a)
{
if (a.type == Locreg || a.type == Loclit)
return a;
@@ -201,7 +188,7 @@ Loc inri(Isel *s, Loc a)
}
/* ensures that a location is within a reg or an imm */
-Loc inrm(Isel *s, Loc a)
+static Loc inrm(Isel *s, Loc a)
{
if (a.type == Locreg || a.type == Locmem)
return a;
@@ -218,7 +205,7 @@ Loc inrm(Isel *s, Loc a)
* multiple tests, we want to eval the children
* of the first arg, instead of the first arg
* directly */
-void selcjmp(Isel *s, Node *n, Node **args)
+static void selcjmp(Isel *s, Node *n, Node **args)
{
Loc a, b;
Loc l1, l2;
@@ -319,7 +306,7 @@ static Loc memloc(Isel *s, Node *e, Mode m)
return l;
}
-Loc gencall(Isel *s, Node *n)
+static Loc gencall(Isel *s, Node *n)
{
int argsz, argoff;
size_t i;
@@ -359,7 +346,7 @@ Loc gencall(Isel *s, Node *n)
return eax;
}
-void blit(Isel *s, Loc a, Loc b, int sz)
+static void blit(Isel *s, Loc a, Loc b, int sz)
{
int i;
Reg sp, dp; /* pointers to src, dst */
@@ -655,7 +642,7 @@ done:
return;
}
-void isel(Isel *s, Node *n)
+static void isel(Isel *s, Node *n)
{
Loc lbl;
@@ -674,7 +661,7 @@ void isel(Isel *s, Node *n)
}
}
-void prologue(Isel *s, size_t sz)
+static void prologue(Isel *s, size_t sz)
{
Loc esp;
Loc ebp;
@@ -688,7 +675,7 @@ void prologue(Isel *s, size_t sz)
g(s, Isub, &stksz, &esp, NULL);
}
-void epilogue(Isel *s)
+static void epilogue(Isel *s)
{
Loc esp, ebp, eax;
Loc ret;
diff --git a/8/reduce.c b/8/reduce.c
index 3b47597..f915a35 100644
--- a/8/reduce.c
+++ b/8/reduce.c
@@ -15,12 +15,6 @@
#include "platform.h" /* HACK. We need some platform specific code gen behavior. *sigh.* */
-void breakhere()
-{
- volatile int x = 0;
- x++;
-}
-
/* takes a list of nodes, and reduces it (and it's subnodes) to a list
* following these constraints:
* - All nodes are expression nodes
@@ -49,23 +43,22 @@ struct Simp {
Node *ret;
};
-Node *simp(Simp *s, Node *n);
-Node *rval(Simp *s, Node *n);
-Node *lval(Simp *s, Node *n);
-void declarelocal(Simp *s, Node *n);
-size_t size(Node *n);
+static Node *simp(Simp *s, Node *n);
+static Node *rval(Simp *s, Node *n);
+static Node *lval(Simp *s, Node *n);
+static void declarelocal(Simp *s, Node *n);
-void append(Simp *s, Node *n)
+static void append(Simp *s, Node *n)
{
lappend(&s->stmts, &s->nstmts, n);
}
-int ispure(Node *n)
+static int ispure(Node *n)
{
return ispureop[exprop(n)];
}
-int isconstfn(Sym *s)
+static int isconstfn(Sym *s)
{
return s->isconst && s->type->type == Tyfunc;
}
@@ -91,7 +84,7 @@ static char *asmname(Node *n)
return s;
}
-size_t tysize(Type *t)
+static size_t tysize(Type *t)
{
size_t sz;
size_t i;
@@ -156,7 +149,7 @@ size_t size(Node *n)
return tysize(t);
}
-Node *genlbl(void)
+static Node *genlbl(void)
{
char buf[128];
static int nextlbl;
@@ -165,7 +158,7 @@ Node *genlbl(void)
return mklbl(-1, buf);
}
-Node *temp(Simp *simp, Node *e)
+static Node *temp(Simp *simp, Node *e)
{
char buf[128];
static int nexttmp;
@@ -183,10 +176,17 @@ Node *temp(Simp *simp, Node *e)
return r;
}
-void jmp(Simp *s, Node *lbl) { append(s, mkexpr(-1, Ojmp, lbl, NULL)); }
-Node *store(Node *dst, Node *src) { return mkexpr(-1, Ostor, dst, src, NULL); }
+static void jmp(Simp *s, Node *lbl)
+{
+ append(s, mkexpr(-1, Ojmp, lbl, NULL));
+}
+
+static Node *store(Node *dst, Node *src)
+{
+ return mkexpr(-1, Ostor, dst, src, NULL);
+}
-void cjmp(Simp *s, Node *cond, Node *iftrue, Node *iffalse)
+static void cjmp(Simp *s, Node *cond, Node *iftrue, Node *iffalse)
{
Node *jmp;
@@ -196,7 +196,7 @@ void cjmp(Simp *s, Node *cond, Node *iftrue, Node *iffalse)
/* if foo; bar; else baz;;
* => cjmp (foo) :bar :baz */
-void simpif(Simp *s, Node *n)
+static void simpif(Simp *s, Node *n)
{
Node *l1, *l2;
Node *c;
@@ -221,7 +221,7 @@ void simpif(Simp *s, Node *n)
* cjmp (cond) :body :end
* :end
*/
-void simploop(Simp *s, Node *n)
+static void simploop(Simp *s, Node *n)
{
Node *lbody;
Node *lend;
@@ -243,7 +243,7 @@ void simploop(Simp *s, Node *n)
simp(s, lend); /* exit */
}
-void simpblk(Simp *s, Node *n)
+static void simpblk(Simp *s, Node *n)
{
size_t i;
@@ -351,7 +351,7 @@ Node *lval(Simp *s, Node *n)
return r;
}
-Node *simplazy(Simp *s, Node *n, Node *r)
+static Node *simplazy(Simp *s, Node *n, Node *r)
{
Node *a, *b;
Node *next;
@@ -372,7 +372,7 @@ Node *simplazy(Simp *s, Node *n, Node *r)
return r;
}
-Node *lowerslice(Simp *s, Node *n)
+static Node *lowerslice(Simp *s, Node *n)
{
Node *t;
Node *base;
@@ -391,7 +391,7 @@ Node *lowerslice(Simp *s, Node *n)
return t;
}
-Node *rval(Simp *s, Node *n)
+static Node *rval(Simp *s, Node *n)
{
Node *r; /* expression result */
Node *t, *u, *v; /* temporary nodes */
@@ -520,7 +520,7 @@ Node *rval(Simp *s, Node *n)
return r;
}
-void declarelocal(Simp *s, Node *n)
+static void declarelocal(Simp *s, Node *n)
{
assert(n->type == Ndecl);
s->stksz += size(n);
@@ -529,7 +529,7 @@ void declarelocal(Simp *s, Node *n)
htput(s->locs, (void*)n->decl.sym->id, (void*)s->stksz);
}
-void declarearg(Simp *s, Node *n)
+static void declarearg(Simp *s, Node *n)
{
assert(n->type == Ndecl);
if (debug)
@@ -538,7 +538,7 @@ void declarearg(Simp *s, Node *n)
s->argsz += size(n);
}
-Node *simp(Simp *s, Node *n)
+static Node *simp(Simp *s, Node *n)
{
Node *r;
size_t i;
@@ -581,7 +581,7 @@ Node *simp(Simp *s, Node *n)
return r;
}
-void reduce(Simp *s, Node *f)
+static void reduce(Simp *s, Node *f)
{
size_t i;
diff --git a/opt/cfg.c b/opt/cfg.c
index 92e3d50..ec09216 100644
--- a/opt/cfg.c
+++ b/opt/cfg.c
@@ -14,7 +14,7 @@
#include "opt.h"
-Bb *mkbb(Cfg *cfg)
+static Bb *mkbb(Cfg *cfg)
{
static int nextbbid = 0;
Bb *bb;
@@ -27,13 +27,13 @@ Bb *mkbb(Cfg *cfg)
return bb;
}
-void label(Cfg *cfg, Node *lbl, Bb *bb)
+static void label(Cfg *cfg, Node *lbl, Bb *bb)
{
htput(cfg->lblmap, lbl->lbl.name, bb);
lappend(&bb->lbls, &bb->nlbls, lbl->lbl.name);
}
-int addnode(Cfg *cfg, Bb *bb, Node *n)
+static int addnode(Cfg *cfg, Bb *bb, Node *n)
{
switch (exprop(n)) {
case Ojmp:
diff --git a/parse/dump.c b/parse/dump.c
index ebb1378..3792e69 100644
--- a/parse/dump.c
+++ b/parse/dump.c
@@ -197,8 +197,3 @@ void dump(Node *n, FILE *fd)
{
outnode(n, fd, 0);
}
-
-void o(Node *n)
-{
- dump(n, stdout);
-}
diff --git a/parse/htab.c b/parse/htab.c
index 46b8d78..0dcaf80 100644
--- a/parse/htab.c
+++ b/parse/htab.c
@@ -87,9 +87,9 @@ int htput(Htab *ht, void *k, void *v)
return 1;
}
-ssize_t htidx(Htab *ht, void *k)
+static ssize_t htidx(Htab *ht, void *k)
{
- int i;
+ ssize_t i;
ulong h;
int di;
diff --git a/parse/infer.c b/parse/infer.c
index 90f5b6f..dcafc0f 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -164,7 +164,7 @@ static void mergecstrs(Node *ctx, Type *a, Type *b)
}
}
-int idxhacked(Type **pa, Type **pb)
+static int idxhacked(Type **pa, Type **pb)
{
Type *a, *b;
diff --git a/parse/parse.h b/parse/parse.h
index a4e7821..a3e00ec 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -331,6 +331,7 @@ Node *mkslice(int line, Node *base, Node *off);
/* node util functions */
char *declname(Node *n);
Type *decltype(Node *n);
+Type *exprtype(Node *n);
Type *nodetype(Node *n);
void addstmt(Node *file, Node *stmt);
void setns(Node *n, char *name);
@@ -340,6 +341,7 @@ char *namestr(Node *name);
/* usefiles */
void readuse(Node *use, Stab *into);
+void writeuse(Node *file, FILE *out);
/* typechecking/inference */
void infer(Node *file);
diff --git a/parse/pickle.c b/parse/pickle.c
index 0156a09..19d0bcf 100644
--- a/parse/pickle.c
+++ b/parse/pickle.c
@@ -115,7 +115,7 @@ static void wrstr(FILE *fd, char *val)
}
}
-/*static */char *rdstr(FILE *fd)
+static char *rdstr(FILE *fd)
{
ssize_t len;
char *s;
@@ -147,7 +147,7 @@ static void wrflt(FILE *fd, double val)
die("Unexpected EOF");
}
-/*static */double rdflt(FILE *fd)
+static double rdflt(FILE *fd)
{
char buf[8];
union {
diff --git a/parse/type.c b/parse/type.c
index 80fd3c6..fdd4a13 100644
--- a/parse/type.c
+++ b/parse/type.c
@@ -198,13 +198,6 @@ int istysigned(Type *t)
}
}
-void tlappend(Type ***tl, int *len, Type *t)
-{
- *tl = xrealloc(tl, (*len + 1)*sizeof(Type*));
- (*tl)[*len] = t;
- (*len)++;
-}
-
static int namefmt(char *buf, size_t len, Node *name)
{
size_t i;