ref: 8865ed9510427f9af64eeeaa18f8209c91aeb456
parent: 9d00fe8f782d9c86ae4b787acef760ab8dc82af0
author: Ori Bernstein <[email protected]>
date: Mon Jun 11 15:00:52 EDT 2012
Make unexported functions static. Just cleaner that way.
--- a/8/isel.c
+++ b/8/isel.c
@@ -48,7 +48,7 @@
};
-Loc loc(Isel *s, Node *n)
+static Loc loc(Isel *s, Node *n)
{
Loc l;
Node *v;
@@ -82,12 +82,12 @@
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 @@
return l;
}
-Insn *mkinsnv(AsmOp op, va_list ap)
+static Insn *mkinsnv(AsmOp op, va_list ap)
{
Loc *l;
Insn *i;
@@ -126,8 +126,6 @@
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;
@@ -134,7 +132,7 @@
return i;
}
-Insn *mkinsn(AsmOp op, ...)
+static void g(Isel *s, AsmOp op, ...)
{
va_list ap;
Insn *i;
@@ -142,21 +140,10 @@
va_start(ap, op);
i = mkinsnv(op, ap);
va_end(ap);
- return i;
-}
-
-void g(Isel *s, AsmOp op, ...)
-{
- va_list ap;
- Insn *i;
-
- va_start(ap, op);
- i = mkinsnv(op, ap);
- va_end(ap);
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 @@
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 @@
}
/* 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 @@
}
/* 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 @@
}
/* 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 @@
* 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 @@
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 @@
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 @@
return;
}
-void isel(Isel *s, Node *n)
+static void isel(Isel *s, Node *n)
{
Loc lbl;
@@ -674,7 +661,7 @@
}
}
-void prologue(Isel *s, size_t sz)
+static void prologue(Isel *s, size_t sz)
{
Loc esp;
Loc ebp;
@@ -688,7 +675,7 @@
g(s, Isub, &stksz, &esp, NULL);
}
-void epilogue(Isel *s)
+static void epilogue(Isel *s)
{
Loc esp, ebp, eax;
Loc ret;
--- 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 @@
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 @@
return s;
}
-size_t tysize(Type *t)
+static size_t tysize(Type *t)
{
size_t sz;
size_t i;
@@ -156,7 +149,7 @@
return tysize(t);
}
-Node *genlbl(void)
+static Node *genlbl(void)
{
char buf[128];
static int nextlbl;
@@ -165,7 +158,7 @@
return mklbl(-1, buf);
}
-Node *temp(Simp *simp, Node *e)
+static Node *temp(Simp *simp, Node *e)
{
char buf[128];
static int nexttmp;
@@ -183,11 +176,18 @@
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));
+}
-void cjmp(Simp *s, Node *cond, Node *iftrue, Node *iffalse)
+static Node *store(Node *dst, Node *src)
{
+ return mkexpr(-1, Ostor, dst, src, NULL);
+}
+
+static void cjmp(Simp *s, Node *cond, Node *iftrue, Node *iffalse)
+{
Node *jmp;
jmp = mkexpr(-1, Ocjmp, cond, iftrue, iffalse, NULL);
@@ -196,7 +196,7 @@
/* 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 @@
* 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 @@
simp(s, lend); /* exit */
}
-void simpblk(Simp *s, Node *n)
+static void simpblk(Simp *s, Node *n)
{
size_t i;
@@ -351,7 +351,7 @@
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 @@
return r;
}
-Node *lowerslice(Simp *s, Node *n)
+static Node *lowerslice(Simp *s, Node *n)
{
Node *t;
Node *base;
@@ -391,7 +391,7 @@
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 @@
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 @@
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 @@
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 @@
return r;
}
-void reduce(Simp *s, Node *f)
+static void reduce(Simp *s, Node *f)
{
size_t i;
--- 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 @@
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:
--- a/parse/dump.c
+++ b/parse/dump.c
@@ -197,8 +197,3 @@
{
outnode(n, fd, 0);
}
-
-void o(Node *n)
-{
- dump(n, stdout);
-}
--- a/parse/htab.c
+++ b/parse/htab.c
@@ -87,9 +87,9 @@
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;
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -164,7 +164,7 @@
}
}
-int idxhacked(Type **pa, Type **pb)
+static int idxhacked(Type **pa, Type **pb)
{
Type *a, *b;
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -331,6 +331,7 @@
/* 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 @@
/* usefiles */
void readuse(Node *use, Stab *into);
+void writeuse(Node *file, FILE *out);
/* typechecking/inference */
void infer(Node *file);
--- a/parse/pickle.c
+++ b/parse/pickle.c
@@ -115,7 +115,7 @@
}
}
-/*static */char *rdstr(FILE *fd)
+static char *rdstr(FILE *fd)
{
ssize_t len;
char *s;
@@ -147,7 +147,7 @@
die("Unexpected EOF");
}
-/*static */double rdflt(FILE *fd)
+static double rdflt(FILE *fd)
{
char buf[8];
union {
--- a/parse/type.c
+++ b/parse/type.c
@@ -198,13 +198,6 @@
}
}
-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;