summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-07-09 10:18:26 -0700
committerOri Bernstein <ori@eigenstate.org>2017-07-09 10:18:26 -0700
commit95f4d0b36eb2d25889eed6ab48fb025d5b346b67 (patch)
treed5e206f2a9c6713c193911370958826928c91294 /6
parent25d91f98a97df36e1da381b273219ceedf256a4d (diff)
downloadmc-95f4d0b36eb2d25889eed6ab48fb025d5b346b67.tar.gz
Style(9)-ify.
Diffstat (limited to '6')
-rw-r--r--6/blob.c50
-rw-r--r--6/gen.c29
-rw-r--r--6/gengas.c69
-rw-r--r--6/genp9.c61
-rw-r--r--6/isel.c108
-rw-r--r--6/locs.c51
-rw-r--r--6/main.c26
-rw-r--r--6/peep.c15
-rw-r--r--6/ra.c201
-rw-r--r--6/simp.c208
-rw-r--r--6/typeinfo.c39
11 files changed, 557 insertions, 300 deletions
diff --git a/6/blob.c b/6/blob.c
index 2872df1..46072a1 100644
--- a/6/blob.c
+++ b/6/blob.c
@@ -18,7 +18,8 @@
static size_t blobrec(Blob *b, Htab *globls, Htab *strtab, Node *n);
-Blob *mkblobi(Blobtype type, uint64_t ival)
+Blob *
+mkblobi(Blobtype type, uint64_t ival)
{
Blob *b;
@@ -28,7 +29,8 @@ Blob *mkblobi(Blobtype type, uint64_t ival)
return b;
}
-Blob *mkblobpad(size_t sz)
+Blob *
+mkblobpad(size_t sz)
{
Blob *b;
@@ -38,7 +40,8 @@ Blob *mkblobpad(size_t sz)
return b;
}
-Blob *mkblobbytes(char *buf, size_t len)
+Blob *
+mkblobbytes(char *buf, size_t len)
{
Blob *b;
@@ -49,7 +52,8 @@ Blob *mkblobbytes(char *buf, size_t len)
return b;
}
-Blob *mkblobseq(Blob **sub, size_t nsub)
+Blob *
+mkblobseq(Blob **sub, size_t nsub)
{
Blob *b;
@@ -60,7 +64,8 @@ Blob *mkblobseq(Blob **sub, size_t nsub)
return b;
}
-Blob *mkblobref(char *lbl, size_t off, int isextern)
+Blob *
+mkblobref(char *lbl, size_t off, int isextern)
{
Blob *b;
@@ -72,7 +77,8 @@ Blob *mkblobref(char *lbl, size_t off, int isextern)
return b;
}
-void blobfree(Blob *b)
+void
+blobfree(Blob *b)
{
size_t i;
@@ -93,7 +99,8 @@ void blobfree(Blob *b)
free(b);
}
-static size_t getintlit(Node *n, char *failmsg)
+static size_t
+getintlit(Node *n, char *failmsg)
{
if (exprop(n) != Olit)
fatal(n, "%s", failmsg);
@@ -103,19 +110,22 @@ static size_t getintlit(Node *n, char *failmsg)
return n->lit.intval;
}
-void b(Blob *b, Blob *n)
+void
+b(Blob *b, Blob *n)
{
lappend(&b->seq.sub, &b->seq.nsub, n);
}
-static size_t blobpad(Blob *seq, size_t sz)
+static size_t
+blobpad(Blob *seq, size_t sz)
{
if (sz)
b(seq, mkblobpad(sz));
return sz;
}
-static size_t bloblit(Blob *seq, Htab *strtab, Node *v, Type *ty)
+static size_t
+bloblit(Blob *seq, Htab *strtab, Node *v, Type *ty)
{
char buf[128];
char *lbl;
@@ -172,7 +182,8 @@ static size_t bloblit(Blob *seq, Htab *strtab, Node *v, Type *ty)
return sz;
}
-static size_t blobslice(Blob *seq, Htab *globls, Htab *strtab, Node *n)
+static size_t
+blobslice(Blob *seq, Htab *globls, Htab *strtab, Node *n)
{
Node *base, *lo, *hi;
ssize_t loval, hival, sz;
@@ -183,7 +194,7 @@ static size_t blobslice(Blob *seq, Htab *globls, Htab *strtab, Node *n)
lo = n->expr.args[1];
hi = n->expr.args[2];
- /* by this point, all slicing operations should have had their bases
+ /* by this point, all slicing operations should have had their base
* pulled out, and we should have vars with their pseudo-decls in their
* place */
loval = getintlit(lo, "lower bound in slice is not constant literal");
@@ -203,7 +214,8 @@ static size_t blobslice(Blob *seq, Htab *globls, Htab *strtab, Node *n)
return 16;
}
-static Node *structmemb(Node *n, char *dcl)
+static Node *
+structmemb(Node *n, char *dcl)
{
size_t i;
@@ -213,7 +225,8 @@ static Node *structmemb(Node *n, char *dcl)
return NULL;
}
-static size_t blobstruct(Blob *seq, Htab *globls, Htab *strtab, Node *n)
+static size_t
+blobstruct(Blob *seq, Htab *globls, Htab *strtab, Node *n)
{
size_t i, sz, pad, end, ndcl;
Node **dcl, *m;
@@ -239,7 +252,8 @@ static size_t blobstruct(Blob *seq, Htab *globls, Htab *strtab, Node *n)
return sz;
}
-static size_t blobucon(Blob *seq, Htab *globls, Htab *strtab, Node *n)
+static size_t
+blobucon(Blob *seq, Htab *globls, Htab *strtab, Node *n)
{
size_t sz, pad;
Ucon *uc;
@@ -257,7 +271,8 @@ static size_t blobucon(Blob *seq, Htab *globls, Htab *strtab, Node *n)
}
-static size_t blobrec(Blob *b, Htab *globls, Htab *strtab, Node *n)
+static size_t
+blobrec(Blob *b, Htab *globls, Htab *strtab, Node *n)
{
size_t i, sz, end;
@@ -289,7 +304,8 @@ static size_t blobrec(Blob *b, Htab *globls, Htab *strtab, Node *n)
return sz;
}
-Blob *litblob(Htab *globls, Htab *strtab, Node *n)
+Blob *
+litblob(Htab *globls, Htab *strtab, Node *n)
{
Blob *b;
diff --git a/6/gen.c b/6/gen.c
index 2699b62..abde13a 100644
--- a/6/gen.c
+++ b/6/gen.c
@@ -16,7 +16,8 @@
#include "asm.h"
#include "../config.h"
-void fillglobls(Stab *st, Htab *globls)
+void
+fillglobls(Stab *st, Htab *globls)
{
size_t i, j, nk, nns;
void **k, **ns;
@@ -46,7 +47,8 @@ void fillglobls(Stab *st, Htab *globls)
}
-void initconsts(Htab *globls)
+void
+initconsts(Htab *globls)
{
Type *ty;
Node *name;
@@ -70,7 +72,8 @@ void initconsts(Htab *globls)
abortoob->expr.isconst = 1;
}
-Type *codetype(Type *ft)
+Type *
+codetype(Type *ft)
{
ft = tybase(ft);
if (ft->type == Tycode)
@@ -81,7 +84,8 @@ Type *codetype(Type *ft)
return ft;
}
-Type *closuretype(Type *ft)
+Type *
+closuretype(Type *ft)
{
ft = tybase(ft);
if (ft->type == Tyfunc)
@@ -92,7 +96,8 @@ Type *closuretype(Type *ft)
return ft;
}
-static int islocal(Node *dcl)
+static int
+islocal(Node *dcl)
{
if (dcl->decl.vis != Visintern)
return 0;
@@ -101,7 +106,8 @@ static int islocal(Node *dcl)
return 1;
}
-char *genlocallblstr(char *buf, size_t sz)
+char *
+genlocallblstr(char *buf, size_t sz)
{
if (asmsyntax == Plan9)
return genlblstr(buf, 128, "<>");
@@ -109,14 +115,15 @@ char *genlocallblstr(char *buf, size_t sz)
return genlblstr(buf, 128, "");
}
-/*
+/*
* For x86, the assembly names are generated as follows:
* local symbols: .name
* un-namespaced symbols: <symprefix>name
* namespaced symbols: <symprefix>namespace$name
* local symbols on plan9 have the file-unique suffix '<>' appended
*/
-char *asmname(Node *dcl)
+char *
+asmname(Node *dcl)
{
char buf[1024];
char *vis, *pf, *ns, *name, *sep;
@@ -142,7 +149,8 @@ char *asmname(Node *dcl)
return strdup(buf);
}
-char *tydescid(char *buf, size_t bufsz, Type *ty)
+char *
+tydescid(char *buf, size_t bufsz, Type *ty)
{
char *sep, *ns;
char *p, *end;
@@ -174,7 +182,8 @@ char *tydescid(char *buf, size_t bufsz, Type *ty)
return buf;
}
-void gen(Node *file, char *out)
+void
+gen(Node *file, char *out)
{
FILE *fd;
diff --git a/6/gengas.c b/6/gengas.c
index 82e0bd2..d37f37e 100644
--- a/6/gengas.c
+++ b/6/gengas.c
@@ -18,19 +18,19 @@
#define Tdindirect 0x80
-static char *insnfmt[] = {
+static char * insnfmt[] = {
#define Insn(val, gasfmt, p9fmt, use, def) gasfmt,
#include "insns.def"
#undef Insn
};
-static char *regnames[] = {
+static char * regnames[] = {
#define Reg(r, gasname, p9name, mode) gasname,
#include "regs.def"
#undef Reg
};
-static char* modenames[] = {
+static char *modenames[] = {
[ModeB] = "b",
[ModeW] = "w",
[ModeL] = "l",
@@ -41,7 +41,8 @@ static char* modenames[] = {
static void locprint(FILE *fd, Loc *l, char spec);
-void printmem(FILE *fd, Loc *l, char spec)
+void
+printmem(FILE *fd, Loc *l, char spec)
{
if (l->type == Locmem) {
if (l->mem.constdisp)
@@ -66,7 +67,8 @@ void printmem(FILE *fd, Loc *l, char spec)
}
}
-static void locprint(FILE *fd, Loc *l, char spec)
+static void
+locprint(FILE *fd, Loc *l, char spec)
{
assert(l->mode);
switch (l->type) {
@@ -79,7 +81,7 @@ static void locprint(FILE *fd, Loc *l, char spec)
fprintf(fd, "%s", l->lbl);
break;
case Locreg:
- assert((spec == 'r' && isintmode(l->mode)) ||
+ assert((spec == 'r' && isintmode(l->mode)) ||
(spec == 'f' && isfloatmode(l->mode)) ||
spec == 'v' ||
spec == 'x' ||
@@ -104,18 +106,20 @@ static void locprint(FILE *fd, Loc *l, char spec)
}
}
-static int issubreg(Loc *a, Loc *b)
+static int
+issubreg(Loc *a, Loc *b)
{
return rclass(a) == rclass(b) && a->mode != b->mode;
}
-void iprintf(FILE *fd, Insn *insn)
+void
+iprintf(FILE *fd, Insn *insn)
{
char *p;
int i;
int idx;
- /* x64 has a quirk; it has no movzlq because mov zero extends. This
+ /* x64 has a quirk; it has no movzlq because mov zero extends. Thi
* means that we need to do a movl when we really want a movzlq. Since
* we don't know the name of the reg to use, we need to sub it in when
* writing... */
@@ -166,7 +170,8 @@ void iprintf(FILE *fd, Insn *insn)
/* %-formating */
p++;
idx = i;
-again:
+again
+:
switch (*p) {
case '\0':
goto done; /* skip the final p++ */
@@ -193,12 +198,14 @@ again:
break;
}
}
-done:
+done
+:
return;
}
-static void writebytes(FILE *fd, char *p, size_t sz)
+static void
+writebytes(FILE *fd, char *p, size_t sz)
{
size_t i;
@@ -217,7 +224,8 @@ static void writebytes(FILE *fd, char *p, size_t sz)
}
}
-void genstrings(FILE *fd, Htab *strtab)
+void
+genstrings(FILE *fd, Htab *strtab)
{
void **k;
Str *s;
@@ -231,7 +239,8 @@ void genstrings(FILE *fd, Htab *strtab)
}
}
-static void writeasm(FILE *fd, Isel *s, Func *fn)
+static void
+writeasm(FILE *fd, Isel *s, Func *fn)
{
size_t i, j;
@@ -248,7 +257,8 @@ static void writeasm(FILE *fd, Isel *s, Func *fn)
}
}
-static void encodemin(FILE *fd, uvlong val)
+static void
+encodemin(FILE *fd, uvlong val)
{
size_t i, shift;
uint8_t b;
@@ -272,7 +282,8 @@ static void encodemin(FILE *fd, uvlong val)
}
}
-static void emitonce(FILE *fd, Blob *b)
+static void
+emitonce(FILE *fd, Blob *b)
{
if (asmsyntax == Gnugaself) {
fprintf(fd, ".section .text.%s%s,\"aG\",%s%s,comdat\n",
@@ -285,7 +296,8 @@ static void emitonce(FILE *fd, Blob *b)
}
}
-static void writeblob(FILE *fd, Blob *b)
+static void
+writeblob(FILE *fd, Blob *b)
{
size_t i;
@@ -319,7 +331,8 @@ static void writeblob(FILE *fd, Blob *b)
/* genfunc requires all nodes in 'nl' to map cleanly to operations that are
* natively supported, as promised in the output of reduce(). No 64-bit
* operations on x32, no structures, and so on. */
-static void genfunc(FILE *fd, Func *fn, Htab *globls, Htab *strtab)
+static void
+genfunc(FILE *fd, Func *fn, Htab *globls, Htab *strtab)
{
Isel is = {0,};
char cwd[1024];
@@ -344,7 +357,8 @@ static void genfunc(FILE *fd, Func *fn, Htab *globls, Htab *strtab)
writeasm(fd, &is, fn);
}
-static void gentype(FILE *fd, Type *ty)
+static void
+gentype(FILE *fd, Type *ty)
{
Blob *b;
@@ -360,7 +374,8 @@ static void gentype(FILE *fd, Type *ty)
blobfree(b);
}
-static void gentypes(FILE *fd)
+static void
+gentypes(FILE *fd)
{
Type *ty;
size_t i;
@@ -377,7 +392,8 @@ static void gentypes(FILE *fd)
}
-void genblob(FILE *fd, Node *blob, Htab *globls, Htab *strtab)
+void
+genblob(FILE *fd, Node *blob, Htab *globls, Htab *strtab)
{
char *lbl;
Blob *b;
@@ -400,7 +416,8 @@ void genblob(FILE *fd, Node *blob, Htab *globls, Htab *strtab)
}
}
-void gengas(Node *file, FILE *fd)
+void
+gengas(Node *file, FILE *fd)
{
Htab *globls, *strtab;
Node *n, **blob;
@@ -429,7 +446,7 @@ void gengas(Node *file, FILE *fd)
for (i = 0; i < file->file.nstmts; i++) {
n = file->file.stmts[i];
switch (n->type) {
- case Nuse: /* nothing to do */
+ case Nuse: /* nothing to do */
case Nimpl:
break;
case Ndecl:
@@ -467,12 +484,14 @@ void gengas(Node *file, FILE *fd)
fclose(fd);
}
-void dbglocprint(FILE *fd, Loc *l, char spec)
+void
+dbglocprint(FILE *fd, Loc *l, char spec)
{
locprint(fd, l, spec);
}
-void dbgiprintf(FILE *fd, Insn *i)
+void
+dbgiprintf(FILE *fd, Insn *i)
{
iprintf(fd, i);
}
diff --git a/6/genp9.c b/6/genp9.c
index 84f7f3c..7934199 100644
--- a/6/genp9.c
+++ b/6/genp9.c
@@ -29,7 +29,7 @@ static char *regnames[] = {
#undef Reg
};
-static char* modenames[] = {
+static char *modenames[] = {
[ModeB] = "B",
[ModeW] = "W",
[ModeL] = "L",
@@ -38,9 +38,11 @@ static char* modenames[] = {
[ModeD] = "D"
};
-static void locprint(FILE *fd, Loc *l, char spec);
+static void
+locprint(FILE *fd, Loc *l, char spec);
-static void printmem(FILE *fd, Loc *l, char spec)
+static void
+printmem(FILE *fd, Loc *l, char spec)
{
if (l->type == Locmem) {
if (l->mem.constdisp)
@@ -63,7 +65,8 @@ static void printmem(FILE *fd, Loc *l, char spec)
}
}
-static void locprint(FILE *fd, Loc *l, char spec)
+static void
+locprint(FILE *fd, Loc *l, char spec)
{
spec = tolower(spec);
assert(l->mode);
@@ -77,7 +80,7 @@ static void locprint(FILE *fd, Loc *l, char spec)
fprintf(fd, "%s", l->lbl);
break;
case Locreg:
- assert((spec == 'r' && isintmode(l->mode)) ||
+ assert((spec == 'r' && isintmode(l->mode)) ||
(spec == 'f' && isfloatmode(l->mode)) ||
spec == 'v' ||
spec == 'x' ||
@@ -102,18 +105,20 @@ static void locprint(FILE *fd, Loc *l, char spec)
}
}
-static int issubreg(Loc *a, Loc *b)
+static int
+issubreg(Loc *a, Loc *b)
{
return rclass(a) == rclass(b) && a->mode != b->mode;
}
-static void iprintf(FILE *fd, Insn *insn)
+static void
+iprintf(FILE *fd, Insn *insn)
{
char *p;
int i;
int idx;
- /* x64 has a quirk; it has no movzlq because mov zero extends. This
+ /* x64 has a quirk; it has no movzlq because mov zero extends. Thi
* means that we need to do a movl when we really want a movzlq. Since
* we don't know the name of the reg to use, we need to sub it in when
* writing... */
@@ -161,7 +166,8 @@ static void iprintf(FILE *fd, Insn *insn)
/* %-formating */
p++;
idx = i;
-again:
+again
+:
switch (*p) {
case '\0':
goto done; /* skip the final p++ */
@@ -189,12 +195,14 @@ again:
break;
}
}
-done:
+done
+:
return;
}
-static size_t writebytes(FILE *fd, char *name, size_t off, char *p, size_t sz)
+static size_t
+writebytes(FILE *fd, char *name, size_t off, char *p, size_t sz)
{
size_t i, len;
@@ -217,7 +225,8 @@ static size_t writebytes(FILE *fd, char *name, size_t off, char *p, size_t sz)
return sz;
}
-static void genstrings(FILE *fd, Htab *strtab)
+static void
+genstrings(FILE *fd, Htab *strtab)
{
void **k;
char *lbl;
@@ -235,7 +244,8 @@ static void genstrings(FILE *fd, Htab *strtab)
}
}
-static void writeasm(FILE *fd, Isel *s, Func *fn)
+static void
+writeasm(FILE *fd, Isel *s, Func *fn)
{
size_t i, j;
char *hidden;
@@ -243,7 +253,7 @@ static void writeasm(FILE *fd, Isel *s, Func *fn)
hidden = "";
if (fn->isexport)
hidden = "";
- /* we don't use the stack size directive: myrddin handles
+ /* we don't use the stack size directive: myrddin handle
* the stack frobbing on its own */
fprintf(fd, "TEXT %s%s+0(SB),2,$0\n", fn->name, hidden);
for (j = 0; j < s->cfg->nbb; j++) {
@@ -256,7 +266,8 @@ static void writeasm(FILE *fd, Isel *s, Func *fn)
}
}
-static size_t encodemin(FILE *fd, uvlong val, size_t off, char *lbl)
+static size_t
+encodemin(FILE *fd, uvlong val, size_t off, char *lbl)
{
size_t i, shift, n;
uint8_t b;
@@ -284,7 +295,8 @@ static size_t encodemin(FILE *fd, uvlong val, size_t off, char *lbl)
return i;
}
-static size_t writeblob(FILE *fd, Blob *b, size_t off, char *lbl)
+static size_t
+writeblob(FILE *fd, Blob *b, size_t off, char *lbl)
{
size_t i, n;
@@ -339,7 +351,8 @@ static size_t writeblob(FILE *fd, Blob *b, size_t off, char *lbl)
/* genfunc requires all nodes in 'nl' to map cleanly to operations that are
* natively supported, as promised in the output of reduce(). No 64-bit
* operations on x32, no structures, and so on. */
-static void genfunc(FILE *fd, Func *fn, Htab *globls, Htab *strtab)
+static void
+genfunc(FILE *fd, Func *fn, Htab *globls, Htab *strtab)
{
Isel is = {0,};
@@ -359,7 +372,8 @@ static void genfunc(FILE *fd, Func *fn, Htab *globls, Htab *strtab)
writeasm(fd, &is, fn);
}
-static void gentype(FILE *fd, Type *ty)
+static void
+gentype(FILE *fd, Type *ty)
{
Blob *b;
char lbl[1024];
@@ -382,7 +396,8 @@ static void gentype(FILE *fd, Type *ty)
writeblob(fd, b, 0, lbl);
}
-static void gentypes(FILE *fd)
+static void
+gentypes(FILE *fd)
{
Type *ty;
size_t i;
@@ -399,7 +414,8 @@ static void gentypes(FILE *fd)
}
-static void genblob(FILE *fd, Node *blob, Htab *globls, Htab *strtab)
+static void
+genblob(FILE *fd, Node *blob, Htab *globls, Htab *strtab)
{
char *lbl;
Blob *b;
@@ -416,7 +432,8 @@ static void genblob(FILE *fd, Node *blob, Htab *globls, Htab *strtab)
writeblob(fd, b, 0, lbl);
}
-void genp9(Node *file, FILE *fd)
+void
+genp9(Node *file, FILE *fd)
{
Htab *globls, *strtab;
Node *n, **blob;
@@ -444,7 +461,7 @@ void genp9(Node *file, FILE *fd)
for (i = 0; i < file->file.nstmts; i++) {
n = file->file.stmts[i];
switch (n->type) {
- case Nuse: /* nothing to do */
+ case Nuse: /* nothing to do */
case Nimpl:
break;
case Ndecl:
diff --git a/6/isel.c b/6/isel.c
index a250886..c7d637d 100644
--- a/6/isel.c
+++ b/6/isel.c
@@ -59,10 +59,11 @@ struct {
[Ofle] = {Icomis, Ijbe, Isetbe},
};
-static Mode tymode(Type *t)
+static Mode
+tymode(Type *t)
{
/* FIXME: What should the mode for, say, structs be when we have no
- * intention of loading /through/ the pointer? For now, we'll just say it's
+ * intention of loading /through/ the pointer? For now, we'll just say it'
* the pointer mode, since we expect to address through the pointer */
t = tybase(t);
switch (t->type) {
@@ -82,7 +83,8 @@ static Mode tymode(Type *t)
return ModeNone;
}
-static Mode mode(Node *n)
+static Mode
+mode(Node *n)
{
if (n->type == Nexpr)
return tymode(exprtype(n));
@@ -93,7 +95,8 @@ static Mode mode(Node *n)
return ModeNone;
}
-static Loc *varloc(Isel *s, Node *n)
+static Loc *
+varloc(Isel *s, Node *n)
{
ssize_t off;
Loc *l, *rip;
@@ -121,7 +124,8 @@ static Loc *varloc(Isel *s, Node *n)
return l;
}
-static Loc *loc(Isel *s, Node *n)
+static Loc *
+loc(Isel *s, Node *n)
{
Node *v;
Loc *l;
@@ -131,7 +135,7 @@ static Loc *loc(Isel *s, Node *n)
} else {
switch (exprop(n)) {
case Ovar:
- l = varloc(s, n);
+ l = varloc(s, n);
break;
case Olit:
v = n->expr.args[0];
@@ -152,7 +156,8 @@ static Loc *loc(Isel *s, Node *n)
return l;
}
-static Insn *mkinsnv(AsmOp op, va_list ap)
+static Insn *
+mkinsnv(AsmOp op, va_list ap)
{
Loc *l;
Insn *i;
@@ -169,7 +174,8 @@ static Insn *mkinsnv(AsmOp op, va_list ap)
return i;
}
-Insn *mkinsn(int op, ...)
+Insn *
+mkinsn(int op, ...)
{
va_list ap;
Insn *i;
@@ -180,7 +186,8 @@ Insn *mkinsn(int op, ...)
return i;
}
-static void g(Isel *s, int op, ...)
+static void
+g(Isel *s, int op, ...)
{
va_list ap;
Insn *i;
@@ -195,7 +202,8 @@ static void g(Isel *s, int op, ...)
lappend(&s->curbb->il, &s->curbb->ni, i);
}
-static void movz(Isel *s, Loc *src, Loc *dst)
+static void
+movz(Isel *s, Loc *src, Loc *dst)
{
if (src->mode == dst->mode)
g(s, Imov, src, dst, NULL);
@@ -203,7 +211,8 @@ static void movz(Isel *s, Loc *src, Loc *dst)
g(s, Imovzx, src, dst, NULL);
}
-static void load(Isel *s, Loc *a, Loc *b)
+static void
+load(Isel *s, Loc *a, Loc *b)
{
Loc *l;
@@ -218,7 +227,8 @@ static void load(Isel *s, Loc *a, Loc *b)
g(s, Imov, l, b, NULL);
}
-static void stor(Isel *s, Loc *a, Loc *b)
+static void
+stor(Isel *s, Loc *a, Loc *b)
{
Loc *l;
@@ -234,7 +244,8 @@ static void stor(Isel *s, Loc *a, Loc *b)
}
/* ensures that a location is within a reg */
-static Loc *newr(Isel *s, Loc *a)
+static Loc *
+newr(Isel *s, Loc *a)
{
Loc *r;
@@ -250,7 +261,8 @@ static Loc *newr(Isel *s, Loc *a)
return r;
}
-static Loc *inr(Isel *s, Loc *a)
+static Loc *
+inr(Isel *s, Loc *a)
{
if (a->type == Locreg)
return a;
@@ -258,7 +270,8 @@ static Loc *inr(Isel *s, Loc *a)
}
/* ensures that a location is within a reg or an imm */
-static Loc *inri(Isel *s, Loc *a)
+static Loc *
+inri(Isel *s, Loc *a)
{
if (a->type == Locreg || a->type == Loclit)
return a;
@@ -275,7 +288,8 @@ static Loc *inri(Isel *s, Loc *a)
* multiple tests, we want to eval the children
* of the first arg, instead of the first arg
* directly */
-static void selcjmp(Isel *s, Node *n, Node **args)
+static void
+selcjmp(Isel *s, Node *n, Node **args)
{
Loc *a, *b;
Loc *l1, *l2;
@@ -308,7 +322,7 @@ static void selcjmp(Isel *s, Node *n, Node **args)
g(s, Ijmp, l2, NULL);
}
-/* Generate variable length jump. There are 3 cases
+/* Generate variable length jump. There are 3 case
* for this:
*
* 1) Short list: Simple comparison sequence.
@@ -318,11 +332,13 @@ static void selcjmp(Isel *s, Node *n, Node **args)
* If a value is not in the jump table, then the 0th
* value is used.
*/
-static void selvjmp(Isel *s, Node *n, Node **args)
+static void
+selvjmp(Isel *s, Node *n, Node **args)
{
}
-static Loc *binop(Isel *s, AsmOp op, Node *x, Node *y)
+static Loc *
+binop(Isel *s, AsmOp op, Node *x, Node *y)
{
Loc *a, *b;
@@ -346,7 +362,8 @@ static Loc *binop(Isel *s, AsmOp op, Node *x, Node *y)
* Omul(reg,
* 2 || 4 || 8)))
*/
-static int ismergablemul(Node *n, int *r)
+static int
+ismergablemul(Node *n, int *r)
{
int v;
@@ -365,7 +382,8 @@ static int ismergablemul(Node *n, int *r)
return 1;
}
-static Loc *memloc(Isel *s, Node *e, Mode m)
+static Loc *
+memloc(Isel *s, Node *e, Mode m)
{
Node **args;
Loc *l, *b, *o; /* location, base, offset */
@@ -399,13 +417,15 @@ static Loc *memloc(Isel *s, Node *e, Mode m)
return l;
}
-static const Mode szmodes[] = {
+static const
+Mode szmodes[] = {
[8] = ModeQ,
[4] = ModeL,
[2] = ModeW,
[1] = ModeB
};
-static void blit(Isel *s, Loc *to, Loc *from, size_t dstoff, size_t srcoff, size_t sz, size_t align)
+static void
+blit(Isel *s, Loc *to, Loc *from, size_t dstoff, size_t srcoff, size_t sz, size_t align)
{
size_t i, modesz;
Loc *sp, *dp; /* pointers to src, dst */
@@ -433,7 +453,8 @@ static void blit(Isel *s, Loc *to, Loc *from, size_t dstoff, size_t srcoff, size
}
-static void clear(Isel *s, Loc *val, size_t sz, size_t align)
+static void
+clear(Isel *s, Loc *val, size_t sz, size_t align)
{
Loc *dp, *zero, *dst; /* source memory, dst memory */
size_t modesz, i;
@@ -453,7 +474,8 @@ static void clear(Isel *s, Loc *val, size_t sz, size_t align)
}
}
-static void call(Isel *s, Node *n)
+static void
+call(Isel *s, Node *n)
{
AsmOp op;
Node *fn;
@@ -473,7 +495,8 @@ static void call(Isel *s, Node *n)
g(s, op, f, NULL);
}
-static size_t countargs(Type *t)
+static size_t
+countargs(Type *t)
{
size_t nargs;
@@ -488,7 +511,8 @@ static size_t countargs(Type *t)
return nargs;
}
-static Loc *gencall(Isel *s, Node *n)
+static Loc *
+gencall(Isel *s, Node *n)
{
Loc *src, *dst, *arg; /* values we reduced */
size_t argsz, argoff, nargs, vasplit;
@@ -584,7 +608,8 @@ static Loc *gencall(Isel *s, Node *n)
return ret;
}
-Loc *selexpr(Isel *s, Node *n)
+Loc *
+selexpr(Isel *s, Node *n)
{
Loc *a, *b, *c, *d, *r;
Loc *edx, *cl; /* x86 wants some hard-coded regs */
@@ -768,7 +793,7 @@ Loc *selexpr(Isel *s, Node *n)
case Ocallind:
r = gencall(s, n);
break;
- case Oret:
+ case Oret:
a = locstrlbl(s->cfg->end->lbls[0]);
g(s, Ijmp, a, NULL);
break;
@@ -858,7 +883,7 @@ Loc *selexpr(Isel *s, Node *n)
case Opostdec: case Olor: case Oland: case Oaddeq:
case Osubeq: case Omuleq: case Odiveq: case Omodeq: case Oboreq:
case Obandeq: case Obxoreq: case Obsleq: case Obsreq: case Omemb:
- case Oslbase: case Osllen: case Ocast: case Outag: case Oudata:
+ case Oslbase: case Osllen: case Ocast: case Outag: case Oudata:
case Oucon: case Otup: case Oarr: case Ostruct:
case Oslice: case Oidx: case Osize: case Otupget:
case Obreak: case Ocontinue:
@@ -870,7 +895,8 @@ Loc *selexpr(Isel *s, Node *n)
return r;
}
-static void isel(Isel *s, Node *n)
+static void
+isel(Isel *s, Node *n)
{
switch (n->type) {
case Nexpr:
@@ -885,12 +911,14 @@ static void isel(Isel *s, Node *n)
}
/* %rax is for int returns, %xmm0d is for floating returns */
-Reg savedregs[] = {
+Reg
+savedregs[] = {
Rr12, Rr13, Rr14, Rr15,
Rnone
};
-void addarglocs(Isel *s, Func *fn)
+void
+addarglocs(Isel *s, Func *fn)
{
size_t i, nints, nfloats, nargs;
size_t argoff;
@@ -904,7 +932,7 @@ void addarglocs(Isel *s, Func *fn)
vararg = 0;
nargs = countargs(fn->type);
for (i = 0; i < fn->nargs; i++) {
- arg = fn->args[i];
+ arg = fn->args[i];
argoff = alignto(argoff, decltype(arg));
if (i >= nargs)
vararg = 1;
@@ -931,7 +959,8 @@ void addarglocs(Isel *s, Func *fn)
}
}
-static void prologue(Isel *s, Func *fn, size_t sz)
+static void
+prologue(Isel *s, Func *fn, size_t sz)
{
Loc *rsp;
Loc *rbp;
@@ -963,7 +992,8 @@ static void prologue(Isel *s, Func *fn, size_t sz)
s->stksz = stksz; /* need to update if we spill */
}
-static void epilogue(Isel *s)
+static void
+epilogue(Isel *s)
{
Loc *rsp, *rbp;
Loc *ret;
@@ -992,7 +1022,8 @@ static void epilogue(Isel *s)
g(s, Iret, NULL);
}
-static Asmbb *mkasmbb(Bb *bb)
+static Asmbb *
+mkasmbb(Bb *bb)
{
Asmbb *as;
@@ -1007,7 +1038,8 @@ static Asmbb *mkasmbb(Bb *bb)
return as;
}
-void selfunc(Isel *is, Func *fn, Htab *globls, Htab *strtab)
+void
+selfunc(Isel *is, Func *fn, Htab *globls, Htab *strtab)
{
int fileid, lastline;
Node *n;
diff --git a/6/locs.c b/6/locs.c
index a569e1e..aa26f01 100644
--- a/6/locs.c
+++ b/6/locs.c
@@ -22,17 +22,23 @@ Mode regmodes[] = {
#undef Reg
};
-int isintmode(Mode m)
+Loc **locmap = NULL;
+size_t maxregid = 0;
+
+int
+isintmode(Mode m)
{
return m == ModeB || m == ModeW || m == ModeL || m == ModeQ;
}
-int isfloatmode(Mode m)
+int
+isfloatmode(Mode m)
{
return m == ModeF || m == ModeD;
}
-Loc *locstrlbl(char *lbl)
+Loc *
+locstrlbl(char *lbl)
{
Loc *l;
@@ -43,7 +49,8 @@ Loc *locstrlbl(char *lbl)
return l;
}
-Loc *loclitl(char *lbl)
+Loc *
+loclitl(char *lbl)
{
Loc *l;
@@ -54,7 +61,8 @@ Loc *loclitl(char *lbl)
return l;
}
-Loc *loclbl(Node *e)
+Loc *
+loclbl(Node *e)
{
Node *lbl;
assert(e->type == Nexpr);
@@ -64,15 +72,14 @@ Loc *loclbl(Node *e)
return locstrlbl(lbl->lit.lblval);
}
-Loc **locmap = NULL;
-size_t maxregid = 0;
-
-void resetregs()
+void
+resetregs()
{
maxregid = Nreg;
}
-static Loc *locregid(regid id, Mode m)
+static Loc *
+locregid(regid id, Mode m)
{
Loc *l;
@@ -85,12 +92,14 @@ static Loc *locregid(regid id, Mode m)
return l;
}
-Loc *locreg(Mode m)
+Loc *
+locreg(Mode m)
{
return locregid(maxregid++, m);
}
-Loc *locphysreg(Reg r)
+Loc *
+locphysreg(Reg r)
{
static Loc *physregs[Nreg] = {0,};
@@ -101,7 +110,8 @@ Loc *locphysreg(Reg r)
return physregs[r];
}
-Loc *locmem(long disp, Loc *base, Loc *idx, Mode mode)
+Loc *
+locmem(long disp, Loc *base, Loc *idx, Mode mode)
{
Loc *l;
@@ -115,7 +125,8 @@ Loc *locmem(long disp, Loc *base, Loc *idx, Mode mode)
return l;
}
-Loc *locmems(long disp, Loc *base, Loc *idx, int scale, Mode mode)
+Loc *
+locmems(long disp, Loc *base, Loc *idx, int scale, Mode mode)
{
Loc *l;
@@ -124,7 +135,8 @@ Loc *locmems(long disp, Loc *base, Loc *idx, int scale, Mode mode)
return l;
}
-Loc *locmeml(char *disp, Loc *base, Loc *idx, Mode mode)
+Loc *
+locmeml(char *disp, Loc *base, Loc *idx, Mode mode)
{
Loc *l;
@@ -138,7 +150,8 @@ Loc *locmeml(char *disp, Loc *base, Loc *idx, Mode mode)
return l;
}
-Loc *locmemls(char *disp, Loc *base, Loc *idx, int scale, Mode mode)
+Loc *
+locmemls(char *disp, Loc *base, Loc *idx, int scale, Mode mode)
{
Loc *l;
@@ -148,7 +161,8 @@ Loc *locmemls(char *disp, Loc *base, Loc *idx, int scale, Mode mode)
}
-Loc *loclit(long val, Mode m)
+Loc *
+loclit(long val, Mode m)
{
Loc *l;
@@ -159,7 +173,8 @@ Loc *loclit(long val, Mode m)
return l;
}
-Loc *coreg(Reg r, Mode m)
+Loc *
+coreg(Reg r, Mode m)
{
Reg crtab[][Nmode + 1] = {
[Ral] = {Rnone, Ral, Rax, Reax, Rrax},
diff --git a/6/main.c b/6/main.c
index ce298e6..fb3ba9f 100644
--- a/6/main.c
+++ b/6/main.c
@@ -32,7 +32,8 @@ char *localincpath;
size_t nincpaths;
Asmsyntax asmsyntax;
-static void usage(char *prog)
+static void
+usage(char *prog)
{
printf("%s [-?|-h] [-o outfile] [-d[dbgopts]] inputs\n", prog);
printf("\t-?|-h\tPrint this help\n");
@@ -52,7 +53,8 @@ static void usage(char *prog)
printf("\t\tu: log type unifications\n");
}
-static void swapout(char* buf, size_t sz, char* suf) {
+static void
+swapout(char* buf, size_t sz, char* suf) {
char* psuffix;
psuffix = strrchr(outfile, '.');
if (psuffix != NULL)
@@ -61,7 +63,8 @@ static void swapout(char* buf, size_t sz, char* suf) {
bprintf(buf, sz, "%s%s", outfile, suf);
}
-static void assemble(char *asmsrc, char *path)
+static void
+assemble(char *asmsrc, char *path)
{
char *asmcmd[] = Asmcmd;
char objfile[1024];
@@ -98,7 +101,7 @@ static void assemble(char *asmsrc, char *path)
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
die("Couldn't run assembler");
}
- /*
+ /*
We don't want to keep the asm source around, but it's useful
for deubgging without mapping to line numbers.
*/
@@ -106,7 +109,8 @@ static void assemble(char *asmsrc, char *path)
unlink(asmsrc);
}
-static char *dirname(char *path)
+static char *
+dirname(char *path)
{
char *p;
@@ -117,7 +121,8 @@ static char *dirname(char *path)
return xstrdup(".");
}
-static char *gentempfile(char *buf, size_t bufsz, char *path, char *suffix)
+static char *
+gentempfile(char *buf, size_t bufsz, char *path, char *suffix)
{
char *tmpdir;
char *base;
@@ -136,7 +141,8 @@ static char *gentempfile(char *buf, size_t bufsz, char *path, char *suffix)
return buf;
}
-static int hasmain(Node *file)
+static int
+hasmain(Node *file)
{
Node *n, *name;
@@ -150,7 +156,8 @@ static int hasmain(Node *file)
return 1;
}
-static void genuse(char *path)
+static void
+genuse(char *path)
{
FILE *f;
char buf[1024];
@@ -174,7 +181,8 @@ static void genuse(char *path)
fclose(f);
}
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
char buf[1024];
Stab *globls;
diff --git a/6/peep.c b/6/peep.c
index e4aeb9c..8cb5734 100644
--- a/6/peep.c
+++ b/6/peep.c
@@ -16,11 +16,12 @@
#include "asm.h"
-/* we sometimes leave dead code generated after
+/* we sometimes leave dead code generated after
* a non-conditional jump. This code scans for
- * the non-conditional exit from the BB, and truncates
+ * the non-conditional exit from the BB, and truncate
* at that point */
-static void deadcode(Isel *s, Asmbb *bb)
+static void
+deadcode(Isel *s, Asmbb *bb)
{
size_t i;
@@ -40,8 +41,9 @@ static void deadcode(Isel *s, Asmbb *bb)
* jmp .l1
* .l1:
* TODO: check for jumps over jumps.
- */
-static void nopjmp(Isel *s, Asmbb *bb, size_t idx)
+ */
+static void
+nopjmp(Isel *s, Asmbb *bb, size_t idx)
{
Insn *jmp;
Loc *targ;
@@ -79,7 +81,8 @@ static void nopjmp(Isel *s, Asmbb *bb, size_t idx)
}
}
-void peep(Isel *s)
+void
+peep(Isel *s)
{
size_t i;
diff --git a/6/ra.c b/6/ra.c
index cc663dd..1f2f037 100644
--- a/6/ra.c
+++ b/6/ra.c
@@ -136,7 +136,8 @@ static int _K[Nclass] = {
[Classflt] = 16,
};
-Rclass rclass(Loc *l)
+Rclass
+rclass(Loc *l)
{
switch (l->mode) {
case ModeNone: return Classbad;
@@ -153,7 +154,8 @@ Rclass rclass(Loc *l)
}
/* %esp, %ebp are not in the allocatable pool */
-static int isfixreg(Loc *l)
+static int
+isfixreg(Loc *l)
{
if (l->reg.colour == Resp)
return 1;
@@ -162,14 +164,15 @@ static int isfixreg(Loc *l)
return 0;
}
-static size_t uses(Insn *insn, regid *u)
+static size_t
+uses(Insn *insn, regid *u)
{
size_t i, j;
int k;
Loc *m;
j = 0;
- /* Add all the registers used and defined. Duplicates
+ /* Add all the registers used and defined. Duplicate
* in this list are fine, since they're being added to
* a set anyways */
for (i = 0; i < Maxarg; i++) {
@@ -205,13 +208,14 @@ static size_t uses(Insn *insn, regid *u)
return j;
}
-static size_t defs(Insn *insn, regid *d)
+static size_t
+defs(Insn *insn, regid *d)
{
size_t i, j;
int k;
j = 0;
- /* Add all the registers dsed and defined. Duplicates
+ /* Add all the registers dsed and defined. Duplicate
* in this list are fine, since they're being added to
* a set anyways */
for (i = 0; i < Maxarg; i++) {
@@ -234,7 +238,8 @@ static size_t defs(Insn *insn, regid *d)
}
/* The uses and defs for an entire BB. */
-static void udcalc(Asmbb *bb)
+static void
+udcalc(Asmbb *bb)
{
regid u[Nreg], d[Nreg];
size_t nu, nd;
@@ -253,12 +258,14 @@ static void udcalc(Asmbb *bb)
}
}
-static int istrivial(Isel *s, regid r)
+static int
+istrivial(Isel *s, regid r)
{
return s->degree[r] < _K[rclass(locmap[r])];
}
-static void liveness(Isel *s)
+static void
+liveness(Isel *s)
{
Bitset *old;
Asmbb **bb;
@@ -301,21 +308,24 @@ static void liveness(Isel *s)
}
/* we're only interested in register->register moves */
-static int ismove(Insn *i)
+static int
+ismove(Insn *i)
{
if (i->op != Imov && i->op != Imovs)
return 0;
return i->args[0]->type == Locreg && i->args[1]->type == Locreg;
}
-static int gbhasedge(Isel *s, size_t u, size_t v)
+static int
+gbhasedge(Isel *s, size_t u, size_t v)
{
size_t i;
i = (s->nreg * v) + u;
return (s->gbits[i/Sizetbits] & (1ULL <<(i % Sizetbits))) != 0;
}
-static void gbputedge(Isel *s, size_t u, size_t v)
+static void
+gbputedge(Isel *s, size_t u, size_t v)
{
size_t i, j;
@@ -326,12 +336,13 @@ static void gbputedge(Isel *s, size_t u, size_t v)
assert(gbhasedge(s, u, v) && gbhasedge(s, v, u));
}
-static int wlfind(Loc **wl, size_t nwl, regid v, size_t *idx)
+static int
+wlfind(Loc **wl, size_t nwl, regid v, size_t *idx)
{
size_t i;
for (i = 0; i < nwl; i++) {
- if (wl[i]->reg.id == v) {
+ if (wl[i]->reg.id == v) {
*idx = i;
return 1;
}
@@ -345,7 +356,8 @@ static int wlfind(Loc **wl, size_t nwl, regid v, size_t *idx)
* we should not increment the degree, since that would
* be double counting.
*/
-static int degreechange(Isel *s, regid u, regid v)
+static int
+degreechange(Isel *s, regid u, regid v)
{
regid phys, virt, r;
size_t i;
@@ -369,7 +381,8 @@ static int degreechange(Isel *s, regid u, regid v)
return 1;
}
-static void alputedge(Isel *s, regid u, regid v)
+static void
+alputedge(Isel *s, regid u, regid v)
{
if (s->ngadj[u] == s->gadjsz[u]) {
s->gadjsz[u] = s->gadjsz[u]*2 + 1;
@@ -379,26 +392,30 @@ static void alputedge(Isel *s, regid u, regid v)
s->ngadj[u]++;
}
-static void wlput(Loc ***wl, size_t *nwl, Loc *l)
+static void
+wlput(Loc ***wl, size_t *nwl, Loc *l)
{
lappend(wl, nwl, l);
l->list = wl;
}
-static void wldel(Isel *s, Loc ***wl, size_t *nwl, size_t idx)
+static void
+wldel(Isel *s, Loc ***wl, size_t *nwl, size_t idx)
{
(*wl)[idx]->list = NULL;
ldel(wl, nwl, idx);
}
-static void wlputset(Bitset *bs, regid r)
+static void
+wlputset(Bitset *bs, regid r)
{
bsput(bs, r);
locmap[r]->list = bs;
}
-static void addedge(Isel *s, regid u, regid v)
+static void
+addedge(Isel *s, regid u, regid v)
{
if (u == v || gbhasedge(s, u, v))
return;
@@ -423,7 +440,8 @@ static void addedge(Isel *s, regid u, regid v)
}
}
-static void gfree(Isel *s)
+static void
+gfree(Isel *s)
{
size_t i;
@@ -434,7 +452,8 @@ static void gfree(Isel *s)
free(s->ngadj);
}
-static void setup(Isel *s)
+static void
+setup(Isel *s)
{
size_t gchunks;
size_t i;
@@ -471,7 +490,8 @@ static void setup(Isel *s)
s->degree[i] = 1<<16;
}
-static void build(Isel *s)
+static void
+build(Isel *s)
{
regid u[Nreg], d[Nreg];
size_t nu, nd;
@@ -536,7 +556,7 @@ static void build(Isel *s)
wlputset(s->initial, d[k]);
}
- /* moves get special treatment, since we don't want spurious
+ /* moves get special treatment, since we don't want spuriou
* edges between the src and dest */
if (ismove(insn)) {
/* live \= uses(i) */
@@ -585,7 +605,8 @@ static void build(Isel *s)
#undef DEL
}
-static int adjavail(Isel *s, regid r)
+static int
+adjavail(Isel *s, regid r)
{
if (locmap[r]->list == &s->selstk)
return 0;
@@ -594,7 +615,8 @@ static int adjavail(Isel *s, regid r)
return 1;
}
-static size_t nodemoves(Isel *s, regid n, Insn ***pil)
+static size_t
+nodemoves(Isel *s, regid n, Insn ***pil)
{
size_t i, count;
regid rid;
@@ -612,7 +634,8 @@ static size_t nodemoves(Isel *s, regid n, Insn ***pil)
}
-static int moverelated(Isel *s, regid n)
+static int
+moverelated(Isel *s, regid n)
{
size_t i;
@@ -625,7 +648,8 @@ static int moverelated(Isel *s, regid n)
return 0;
}
-static void mkworklist(Isel *s)
+static void
+mkworklist(Isel *s)
{
size_t i;
@@ -643,7 +667,8 @@ static void mkworklist(Isel *s)
}
}
-static void enablemove(Isel *s, regid n)
+static void
+enablemove(Isel *s, regid n)
{
size_t i, j;
Insn **il;
@@ -665,7 +690,8 @@ static void enablemove(Isel *s, regid n)
free(il);
}
-static void decdegree(Isel *s, regid m)
+static void
+decdegree(Isel *s, regid m)
{
int before, after;
int found;
@@ -715,7 +741,8 @@ static void decdegree(Isel *s, regid m)
}
}
-static void simp(Isel *s)
+static void
+simp(Isel *s)
{
Loc *l;
regid m;
@@ -730,11 +757,12 @@ static void simp(Isel *s)
}
}
-static regid getmappedalias(Loc **aliasmap, size_t nreg, regid id)
+static regid
+getmappedalias(Loc **aliasmap, size_t nreg, regid id)
{
- /*
+ /*
* if we get called from rewrite(), we can get a register that
- * we just created, with an id bigger than the number of entries
+ * we just created, with an id bigger than the number of entrie
* in the alias map. We should just return its id in that case.
*/
while (id < nreg) {
@@ -745,12 +773,14 @@ static regid getmappedalias(Loc **aliasmap, size_t nreg, regid id)
return id;
}
-static regid getalias(Isel *s, regid id)
+static regid
+getalias(Isel *s, regid id)
{
return getmappedalias(s->aliasmap, s->nreg, id);
}
-static void wladd(Isel *s, regid u)
+static void
+wladd(Isel *s, regid u)
{
size_t i;
@@ -767,7 +797,8 @@ static void wladd(Isel *s, regid u)
wlput(&s->wlsimp, &s->nwlsimp, locmap[u]);
}
-static int conservative(Isel *s, regid u, regid v)
+static int
+conservative(Isel *s, regid u, regid v)
{
int k;
size_t i;
@@ -788,12 +819,14 @@ static int conservative(Isel *s, regid u, regid v)
}
/* FIXME: is this actually correct? */
-static int ok(Isel *s, regid t, regid r)
+static int
+ok(Isel *s, regid t, regid r)
{
return istrivial(s, t) || bshas(s->prepainted, t) || gbhasedge(s, t, r);
}
-static int combinable(Isel *s, regid u, regid v)
+static int
+combinable(Isel *s, regid u, regid v)
{
regid t;
size_t i;
@@ -816,7 +849,8 @@ static int combinable(Isel *s, regid u, regid v)
return 1;
}
-static void combine(Isel *s, regid u, regid v)
+static void
+combine(Isel *s, regid u, regid v)
{
regid t;
size_t idx;
@@ -862,7 +896,8 @@ static void combine(Isel *s, regid u, regid v)
}
}
-static int constrained(Isel *s, regid u, regid v)
+static int
+constrained(Isel *s, regid u, regid v)
{
size_t i;
@@ -875,7 +910,8 @@ static int constrained(Isel *s, regid u, regid v)
return gbhasedge(s, u, v);
}
-static void coalesce(Isel *s)
+static void
+coalesce(Isel *s)
{
Insn *m;
regid u, v, tmp;
@@ -909,7 +945,8 @@ static void coalesce(Isel *s)
}
}
-static int mldel(Insn ***ml, size_t *nml, Bitset *bs, Insn *m)
+static int
+mldel(Insn ***ml, size_t *nml, Bitset *bs, Insn *m)
{
size_t i;
if (bshas(bs, m->uid)) {
@@ -924,7 +961,8 @@ static int mldel(Insn ***ml, size_t *nml, Bitset *bs, Insn *m)
return 0;
}
-static void freezemoves(Isel *s, Loc *u)
+static void
+freezemoves(Isel *s, Loc *u)
{
size_t i;
Insn **ml;
@@ -956,7 +994,8 @@ static void freezemoves(Isel *s, Loc *u)
lfree(&ml, &nml);
}
-static void freeze(Isel *s)
+static void
+freeze(Isel *s)
{
Loc *l;
@@ -966,7 +1005,8 @@ static void freeze(Isel *s)
}
/* Select the spill candidates */
-static void selspill(Isel *s)
+static void
+selspill(Isel *s)
{
size_t i;
Loc *m;
@@ -999,7 +1039,8 @@ static void selspill(Isel *s)
* Selects the colours for registers, spilling to the
* stack if no free registers can be found.
*/
-static int paint(Isel *s)
+static int
+paint(Isel *s)
{
int taken[Nreg];
Loc *n, *w;
@@ -1042,7 +1083,8 @@ static int paint(Isel *s)
return spilled;
}
-static Loc *mapfind(Isel *s, Htab *map, Loc *old)
+static Loc *
+mapfind(Isel *s, Htab *map, Loc *old)
{
Loc *new;
Loc *base;
@@ -1077,7 +1119,8 @@ static Loc *mapfind(Isel *s, Htab *map, Loc *old)
return old;
}
-static Loc *spillslot(Isel *s, regid reg)
+static Loc *
+spillslot(Isel *s, regid reg)
{
size_t stkoff;
@@ -1085,7 +1128,8 @@ static Loc *spillslot(Isel *s, regid reg)
return locmem(-stkoff, locphysreg(Rrbp), NULL, locmap[reg]->mode);
}
-static void updatelocs(Isel *s, Htab *map, Insn *insn)
+static void
+updatelocs(Isel *s, Htab *map, Insn *insn)
{
size_t i;
@@ -1097,10 +1141,11 @@ static void updatelocs(Isel *s, Htab *map, Insn *insn)
/*
* Takes two tables for remappings, of size Nreg/Nreg,
- * and fills them, storign the number of uses or defs. Returns
+ * and fills them, storign the number of uses or defs. Return
* whether there are any remappings at all.
*/
-static int remap(Isel *s, Htab *map, Insn *insn, regid *use, size_t nuse, regid *def, size_t ndef)
+static int
+remap(Isel *s, Htab *map, Insn *insn, regid *use, size_t nuse, regid *def, size_t ndef)
{
regid ruse, rdef;
int remapped;
@@ -1133,7 +1178,8 @@ static int remap(Isel *s, Htab *map, Insn *insn, regid *use, size_t nuse, regid
return remapped;
}
-static int nopmov(Isel *s, Insn *insn)
+static int
+nopmov(Isel *s, Insn *insn)
{
if (insn->op != Imov)
return 0;
@@ -1143,12 +1189,13 @@ static int nopmov(Isel *s, Insn *insn)
return insn->args[0]->reg.id == insn->args[1]->reg.id && !bshas(s->prepainted, insn->args[0]->reg.id);
}
-void replacealias(Isel *s, Loc **map, size_t nreg, Insn *insn)
+void
+replacealias(Isel *s, Loc **map, size_t nreg, Insn *insn)
{
size_t i;
Loc *l;
- if (!map)
+ if (!map)
return;
for (i = 0; i < insn->nargs; i++) {
l = insn->args[i];
@@ -1163,7 +1210,8 @@ void replacealias(Isel *s, Loc **map, size_t nreg, Insn *insn)
}
}
-static ulong reglochash(void *p)
+static ulong
+reglochash(void *p)
{
Loc *l;
@@ -1172,7 +1220,8 @@ static ulong reglochash(void *p)
}
-static int regloceq(void *pa, void *pb)
+static int
+regloceq(void *pa, void *pb)
{
Loc *a, *b;
@@ -1184,7 +1233,8 @@ static int regloceq(void *pa, void *pb)
* Rewrite instructions using spilled registers, inserting
* appropriate loads and stores into the BB
*/
-static void rewritebb(Isel *s, Asmbb *bb, Loc **aliasmap)
+static void
+rewritebb(Isel *s, Asmbb *bb, Loc **aliasmap)
{
regid use[Nreg], def[Nreg];
size_t nuse, ndef;
@@ -1249,7 +1299,8 @@ static void rewritebb(Isel *s, Asmbb *bb, Loc **aliasmap)
bb->ni = nnew;
}
-static void addspill(Isel *s, Loc *l)
+static void
+addspill(Isel *s, Loc *l)
{
s->stksz->lit += modesize[l->mode];
s->stksz->lit = align(s->stksz->lit, modesize[l->mode]);
@@ -1261,9 +1312,9 @@ static void addspill(Isel *s, Loc *l)
htput(s->spillslots, itop(l->reg.id), itop(s->stksz->lit));
}
-/*
- * Rewrites the function code so that it no longer contains
- * references to spilled registers. Every use of spilled regs
+/*
+ * Rewrites the function code so that it no longer contain
+ * references to spilled registers. Every use of spilled reg
*
* insn %rX,%rY
*
@@ -1273,7 +1324,8 @@ static void addspill(Isel *s, Loc *l)
* insn %rZ,%rW
* mov %rW,234(%rsp)
*/
-static void rewrite(Isel *s, Loc **aliasmap)
+static void
+rewrite(Isel *s, Loc **aliasmap)
{
size_t i;
@@ -1289,7 +1341,7 @@ static void rewrite(Isel *s, Loc **aliasmap)
bsclear(s->spilled);
}
-/*
+/*
* Coalescing registers leaves a lot
* of moves that look like
*
@@ -1297,7 +1349,8 @@ static void rewrite(Isel *s, Loc **aliasmap)
*
* This is useless. This deletes them.
*/
-static void delnops(Isel *s)
+static void
+delnops(Isel *s)
{
Insn *insn;
Asmbb *bb;
@@ -1325,7 +1378,8 @@ static void delnops(Isel *s)
dumpasm(s, stdout);
}
-void regalloc(Isel *s)
+void
+regalloc(Isel *s)
{
int spilled;
size_t i;
@@ -1374,7 +1428,8 @@ void regalloc(Isel *s)
gfree(s);
}
-void wlprint(FILE *fd, char *name, Loc **wl, size_t nwl)
+void
+wlprint(FILE *fd, char *name, Loc **wl, size_t nwl)
{
size_t i;
char *sep;
@@ -1390,7 +1445,8 @@ void wlprint(FILE *fd, char *name, Loc **wl, size_t nwl)
fprintf(fd, "]\n");
}
-static void setprint(FILE *fd, Bitset *s)
+static void
+setprint(FILE *fd, Bitset *s)
{
char *sep;
size_t i;
@@ -1405,7 +1461,8 @@ static void setprint(FILE *fd, Bitset *s)
fprintf(fd, "\n");
}
-static void locsetprint(FILE *fd, Bitset *s)
+static void
+locsetprint(FILE *fd, Bitset *s)
{
char *sep;
size_t i;
@@ -1421,7 +1478,8 @@ static void locsetprint(FILE *fd, Bitset *s)
fprintf(fd, "\n");
}
-static void printedge(FILE *fd, char *msg, size_t a, size_t b)
+static void
+printedge(FILE *fd, char *msg, size_t a, size_t b)
{
fprintf(fd, "\t%s ", msg);
dbglocprint(fd, locmap[a], 'x');
@@ -1430,7 +1488,8 @@ static void printedge(FILE *fd, char *msg, size_t a, size_t b)
fprintf(fd, "\n");
}
-void dumpasm(Isel *s, FILE *fd)
+void
+dumpasm(Isel *s, FILE *fd)
{
size_t i, j;
char *sep;
diff --git a/6/simp.c b/6/simp.c
index 400b6bc..691974a 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -19,12 +19,14 @@
/* takes a list of nodes, and reduces it (and it's subnodes) to a list
* following these constraints:
- * - All nodes are expression nodes
- * - Nodes with side effects are root nodes
- * - All nodes operate on machine-primitive types and tuples
+ * - All nodes are expression node
+ * - Nodes with side effects are root node
+ * - All nodes operate on machine-primitive types and tuple
*/
-typedef struct Simp Simp;
-struct Simp {
+typedef
+struct Simp Simp;
+struct
+Simp {
int isglobl;
Node **stmts;
@@ -67,7 +69,8 @@ Type *tyword;
Type *tyvoid;
Node *abortoob;
-static void append(Simp *s, Node *n)
+static void
+append(Simp *s, Node *n)
{
if (debugopt['S'])
dump(n, stdout);
@@ -75,23 +78,27 @@ static void append(Simp *s, Node *n)
lappend(&s->stmts, &s->nstmts, n);
}
-static int ispure(Node *n)
+static int
+ispure(Node *n)
{
return opispure[exprop(n)];
}
-size_t alignto(size_t sz, Type *t)
+size_t
+alignto(size_t sz, Type *t)
{
return align(sz, tyalign(t));
}
-static Type *base(Type *t)
+static Type *
+base(Type *t)
{
assert(t->nsub == 1);
return t->sub[0];
}
-static Node *add(Node *a, Node *b)
+static Node *
+add(Node *a, Node *b)
{
Node *n;
@@ -101,7 +108,8 @@ static Node *add(Node *a, Node *b)
return n;
}
-static Node *addk(Node *n, uvlong v)
+static Node *
+addk(Node *n, uvlong v)
{
Node *k;
@@ -110,7 +118,8 @@ static Node *addk(Node *n, uvlong v)
return add(n, k);
}
-static Node *sub(Node *a, Node *b)
+static Node *
+sub(Node *a, Node *b)
{
Node *n;
@@ -119,7 +128,8 @@ static Node *sub(Node *a, Node *b)
return n;
}
-static Node *mul(Node *a, Node *b)
+static Node *
+mul(Node *a, Node *b)
{
Node *n;
@@ -128,7 +138,8 @@ static Node *mul(Node *a, Node *b)
return n;
}
-static int addressable(Simp *s, Node *a)
+static int
+addressable(Simp *s, Node *a)
{
if (a->type == Ndecl || (a->type == Nexpr && exprop(a) == Ovar))
return hthas(s->envoff, a) || hthas(s->stkoff, a) || hthas(s->globls, a);
@@ -136,7 +147,8 @@ static int addressable(Simp *s, Node *a)
return stacknode(a);
}
-int stacknode(Node *n)
+int
+stacknode(Node *n)
{
if (n->type == Nexpr)
return isstacktype(n->expr.type);
@@ -144,7 +156,8 @@ int stacknode(Node *n)
return isstacktype(n->decl.type);
}
-int floatnode(Node *n)
+int
+floatnode(Node *n)
{
if (n->type == Nexpr)
return istyfloat(n->expr.type);
@@ -152,7 +165,8 @@ int floatnode(Node *n)
return istyfloat(n->decl.type);
}
-static void forcelocal(Simp *s, Node *n)
+static void
+forcelocal(Simp *s, Node *n)
{
assert(n->type == Ndecl || (n->type == Nexpr && exprop(n) == Ovar));
s->stksz += size(n);
@@ -164,7 +178,8 @@ static void forcelocal(Simp *s, Node *n)
htput(s->stkoff, n, itop(s->stksz));
}
-static void declarelocal(Simp *s, Node *n)
+static void
+declarelocal(Simp *s, Node *n)
{
if (stacknode(n))
forcelocal(s, n);
@@ -172,7 +187,8 @@ static void declarelocal(Simp *s, Node *n)
/* takes the address of a node, possibly converting it to
* a pointer to the base type 'bt' */
-static Node *addr(Simp *s, Node *a, Type *bt)
+static Node *
+addr(Simp *s, Node *a, Type *bt)
{
Node *n;
@@ -186,7 +202,8 @@ static Node *addr(Simp *s, Node *a, Type *bt)
return n;
}
-static Node *load(Node *a)
+static Node *
+load(Node *a)
{
Node *n;
@@ -196,7 +213,8 @@ static Node *load(Node *a)
return n;
}
-static Node *deref(Node *a, Type *t)
+static Node *
+deref(Node *a, Type *t)
{
Node *n;
@@ -209,7 +227,8 @@ static Node *deref(Node *a, Type *t)
return n;
}
-static Node *set(Node *a, Node *b)
+static Node *
+set(Node *a, Node *b)
{
Node *n;
@@ -223,7 +242,8 @@ static Node *set(Node *a, Node *b)
return n;
}
-static void def(Simp *s, Node *var)
+static void
+def(Simp *s, Node *var)
{
Node *d;
@@ -232,7 +252,8 @@ static void def(Simp *s, Node *var)
append(s, d);
}
-static Node *disp(Srcloc loc, uint v)
+static Node *
+disp(Srcloc loc, uint v)
{
Node *n;
@@ -241,7 +262,8 @@ static Node *disp(Srcloc loc, uint v)
return n;
}
-static Node *word(Srcloc loc, uint v)
+static Node *
+word(Srcloc loc, uint v)
{
Node *n;
@@ -250,7 +272,8 @@ static Node *word(Srcloc loc, uint v)
return n;
}
-static Node *temp(Simp *simp, Node *e)
+static Node *
+temp(Simp *simp, Node *e)
{
Node *t, *dcl;
@@ -261,7 +284,8 @@ static Node *temp(Simp *simp, Node *e)
return t;
}
-static void cjmp(Simp *s, Node *cond, Node *iftrue, Node *iffalse)
+static void
+cjmp(Simp *s, Node *cond, Node *iftrue, Node *iffalse)
{
Node *jmp;
@@ -269,13 +293,15 @@ static void cjmp(Simp *s, Node *cond, Node *iftrue, Node *iffalse)
append(s, jmp);
}
-static Node *slicelen(Simp *s, Node *sl)
+static Node *
+slicelen(Simp *s, Node *sl)
{
/* *(&sl + sizeof(size_t)) */
return load(addk(addr(s, rval(s, sl, NULL), tyintptr), Ptrsz));
}
-Node *loadvar(Simp *s, Node *n, Node *dst)
+Node *
+loadvar(Simp *s, Node *n, Node *dst)
{
Node *p, *f, *r;
@@ -293,7 +319,8 @@ Node *loadvar(Simp *s, Node *n, Node *dst)
return r;
}
-static Node *seqlen(Simp *s, Node *n, Type *ty)
+static Node *
+seqlen(Simp *s, Node *n, Type *ty)
{
Node *t, *r;
@@ -310,7 +337,8 @@ static Node *seqlen(Simp *s, Node *n, Type *ty)
}
-static Node *uconid(Simp *s, Node *n)
+static Node *
+uconid(Simp *s, Node *n)
{
Ucon *uc;
@@ -322,7 +350,8 @@ static Node *uconid(Simp *s, Node *n)
return word(uc->loc, uc->id);
}
-static void simpblk(Simp *s, Node *n)
+static void
+simpblk(Simp *s, Node *n)
{
size_t i;
@@ -332,7 +361,8 @@ static void simpblk(Simp *s, Node *n)
}
}
-static Node *geninitdecl(Node *init, Type *ty, Node **dcl)
+static Node *
+geninitdecl(Node *init, Type *ty, Node **dcl)
{
Node *n, *d, *r;
char lbl[128];
@@ -354,7 +384,8 @@ static Node *geninitdecl(Node *init, Type *ty, Node **dcl)
return r;
}
-static Node *simpcode(Simp *s, Node *fn)
+static Node *
+simpcode(Simp *s, Node *fn)
{
Node *r, *d;
@@ -364,7 +395,8 @@ static Node *simpcode(Simp *s, Node *fn)
return r;
}
-static Node *simpblob(Simp *s, Node *blob)
+static Node *
+simpblob(Simp *s, Node *blob)
{
Node *r, *d;
@@ -374,7 +406,8 @@ static Node *simpblob(Simp *s, Node *blob)
return r;
}
-static Node *ptrsized(Simp *s, Node *v)
+static Node *
+ptrsized(Simp *s, Node *v)
{
if (size(v) == Ptrsz)
return v;
@@ -386,7 +419,8 @@ static Node *ptrsized(Simp *s, Node *v)
return v;
}
-static Node *membaddr(Simp *s, Node *n)
+static Node *
+membaddr(Simp *s, Node *n)
{
Node *t, *u, *r;
Node **args;
@@ -405,7 +439,8 @@ static Node *membaddr(Simp *s, Node *n)
return r;
}
-static void checkidx(Simp *s, Op op, Node *len, Node *idx)
+static void
+checkidx(Simp *s, Op op, Node *len, Node *idx)
{
Node *cmp, *die;
Node *ok, *fail;
@@ -427,7 +462,8 @@ static void checkidx(Simp *s, Op op, Node *len, Node *idx)
append(s, ok);
}
-static Node *idxaddr(Simp *s, Node *seq, Node *idx)
+static Node *
+idxaddr(Simp *s, Node *seq, Node *idx)
{
Node *a, *t, *u, *v, *w; /* temps */
Node *r; /* result */
@@ -456,7 +492,8 @@ static Node *idxaddr(Simp *s, Node *seq, Node *idx)
return r;
}
-static Node *slicebase(Simp *s, Node *n, Node *off)
+static Node *
+slicebase(Simp *s, Node *n, Node *off)
{
Node *u, *v;
Type *ty;
@@ -481,7 +518,8 @@ static Node *slicebase(Simp *s, Node *n, Node *off)
}
}
-static Node *loadidx(Simp *s, Node *arr, Node *idx)
+static Node *
+loadidx(Simp *s, Node *arr, Node *idx)
{
Node *v, *a;
@@ -490,7 +528,8 @@ static Node *loadidx(Simp *s, Node *arr, Node *idx)
return v;
}
-static Node *lval(Simp *s, Node *n)
+static Node *
+lval(Simp *s, Node *n)
{
Node *r;
Node **args;
@@ -517,7 +556,8 @@ static Node *lval(Simp *s, Node *n)
return r;
}
-static Node *intconvert(Simp *s, Node *from, Type *to, int issigned)
+static Node *
+intconvert(Simp *s, Node *from, Type *to, int issigned)
{
Node *r;
size_t fromsz, tosz;
@@ -537,7 +577,8 @@ static Node *intconvert(Simp *s, Node *from, Type *to, int issigned)
return r;
}
-static Node *simpcast(Simp *s, Node *val, Type *to)
+static Node *
+simpcast(Simp *s, Node *val, Type *to)
{
Node *r;
Type *t;
@@ -622,7 +663,8 @@ static Node *simpcast(Simp *s, Node *val, Type *to)
/* Simplifies taking a slice of an array, pointer,
* or other slice down to primitive pointer operations */
-static Node *simpslice(Simp *s, Node *n, Node *dst)
+static Node *
+simpslice(Simp *s, Node *n, Node *dst)
{
Node *t;
Node *start, *end, *arg;
@@ -665,7 +707,8 @@ static Node *simpslice(Simp *s, Node *n, Node *dst)
return t;
}
-static Node *visit(Simp *s, Node *n)
+static Node *
+visit(Simp *s, Node *n)
{
size_t i;
Node *r;
@@ -686,7 +729,8 @@ static Node *visit(Simp *s, Node *n)
return r;
}
-static Node *tupget(Simp *s, Node *tup, size_t idx, Node *dst)
+static Node *
+tupget(Simp *s, Node *tup, size_t idx, Node *dst)
{
Node *plv, *prv, *sz, *stor, *dcl;
size_t off, i;
@@ -718,7 +762,8 @@ static Node *tupget(Simp *s, Node *tup, size_t idx, Node *dst)
return dst;
}
-static Node *assign(Simp *s, Node *lhs, Node *rhs)
+static Node *
+assign(Simp *s, Node *lhs, Node *rhs)
{
Node *t, *u, *v, *r;
@@ -747,7 +792,8 @@ static Node *assign(Simp *s, Node *lhs, Node *rhs)
return r;
}
-static Node *assignat(Simp *s, Node *r, size_t off, Node *val)
+static Node *
+assignat(Simp *s, Node *r, size_t off, Node *val)
{
Node *pval, *pdst;
Node *sz;
@@ -770,7 +816,8 @@ static Node *assignat(Simp *s, Node *r, size_t off, Node *val)
* value by evaluating the rvalue of each node on the
* rhs and assigning it to the correct offset from the
* head of the tuple. */
-static Node *simptup(Simp *s, Node *n, Node *dst)
+static Node *
+simptup(Simp *s, Node *n, Node *dst)
{
Node **args;
Node *r;
@@ -790,7 +837,8 @@ static Node *simptup(Simp *s, Node *n, Node *dst)
return dst;
}
-static Node *simpucon(Simp *s, Node *n, Node *dst)
+static Node *
+simpucon(Simp *s, Node *n, Node *dst)
{
Node *tmp, *u, *tag, *elt, *sz;
Node *r;
@@ -839,7 +887,8 @@ static Node *simpucon(Simp *s, Node *n, Node *dst)
return tmp;
}
-static Node *simpuget(Simp *s, Node *n, Node *dst)
+static Node *
+simpuget(Simp *s, Node *n, Node *dst)
{
Node *u, *p, *l;
size_t o;
@@ -856,7 +905,8 @@ static Node *simpuget(Simp *s, Node *n, Node *dst)
-static Node *vatypeinfo(Simp *s, Node *n)
+static Node *
+vatypeinfo(Simp *s, Node *n)
{
Node *ti, *tp, *td, *tn;
Type *ft, *vt, **st;
@@ -901,7 +951,8 @@ static Node *vatypeinfo(Simp *s, Node *n)
return tp;
}
-static Node *capture(Simp *s, Node *n, Node *dst)
+static Node *
+capture(Simp *s, Node *n, Node *dst)
{
Node *fn, *t, *f, *e, *val, *dcl, *fp, *envsz;
size_t nenv, nenvt, off, i;
@@ -955,13 +1006,15 @@ static Node *capture(Simp *s, Node *n, Node *dst)
return dst;
}
-static Node *getenvptr(Simp *s, Node *n)
+static Node *
+getenvptr(Simp *s, Node *n)
{
assert(tybase(exprtype(n))->type == Tyfunc);
return load(addr(s, n, tyintptr));
}
-static Node *getcode(Simp *s, Node *n)
+static Node *
+getcode(Simp *s, Node *n)
{
Node *r, *p, *d;
Type *ty;
@@ -980,7 +1033,8 @@ static Node *getcode(Simp *s, Node *n)
return r;
}
-static Node *simpcall(Simp *s, Node *n, Node *dst)
+static Node *
+simpcall(Simp *s, Node *n, Node *dst)
{
Node *r, *call, *fn;
size_t i, nargs;
@@ -1039,7 +1093,8 @@ static Node *simpcall(Simp *s, Node *n, Node *dst)
return r;
}
-static Node *rval(Simp *s, Node *n, Node *dst)
+static Node *
+rval(Simp *s, Node *n, Node *dst)
{
Node *t, *u, *v; /* temporary nodes */
Node *r; /* expression result */
@@ -1121,7 +1176,7 @@ static Node *rval(Simp *s, Node *n, Node *dst)
case Llbl:
r = n;
break;
- case Lint:
+ case Lint:
/* we can only have up to 4 byte immediates, but they
* can be moved into 64 bit regs */
if ((uint64_t)args[0]->lit.intval < 0x7fffffffULL)
@@ -1176,7 +1231,7 @@ static Node *rval(Simp *s, Node *n, Node *dst)
break;
case Oneg:
if (istyfloat(exprtype(n))) {
- t = mkfloat(n->loc, -1.0);
+ t = mkfloat(n->loc, -1.0);
u = mkexpr(n->loc, Olit, t, NULL);
t->lit.type = n->expr.type;
u->expr.type = n->expr.type;
@@ -1218,13 +1273,15 @@ static Node *rval(Simp *s, Node *n, Node *dst)
return r;
}
-static void declarearg(Simp *s, Node *n)
+static void
+declarearg(Simp *s, Node *n)
{
assert(n->type == Ndecl || (n->type == Nexpr && exprop(n) == Ovar));
lappend(&s->args, &s->nargs, n);
}
-static int islbl(Node *n)
+static int
+islbl(Node *n)
{
Node *l;
if (exprop(n) != Olit)
@@ -1233,7 +1290,8 @@ static int islbl(Node *n)
return l->type == Nlit && l->lit.littype == Llbl;
}
-static Node *simp(Simp *s, Node *n)
+static Node *
+simp(Simp *s, Node *n)
{
Node *r;
@@ -1264,7 +1322,8 @@ static Node *simp(Simp *s, Node *n)
* and simpler representation, which maps easily and
* directly to assembly instructions.
*/
-static void simpinit(Simp *s, Node *f)
+static void
+simpinit(Simp *s, Node *f)
{
Node *dcl;
Type *ty;
@@ -1295,7 +1354,8 @@ static void simpinit(Simp *s, Node *f)
append(s, s->endlbl);
}
-static int isexport(Node *dcl)
+static int
+isexport(Node *dcl)
{
Node *n;
@@ -1310,7 +1370,8 @@ static int isexport(Node *dcl)
return 0;
}
-static int envcmp(const void *pa, const void *pb)
+static int
+envcmp(const void *pa, const void *pb)
{
const Node *a, *b;
@@ -1319,7 +1380,8 @@ static int envcmp(const void *pa, const void *pb)
return b->decl.did - a->decl.did;
}
-static void collectenv(Simp *s, Node *fn)
+static void
+collectenv(Simp *s, Node *fn)
{
size_t nenv, i;
Node **env;
@@ -1344,7 +1406,8 @@ static void collectenv(Simp *s, Node *fn)
free(env);
}
-static Func *simpfn(Simp *s, char *name, Node *dcl)
+static Func *
+simpfn(Simp *s, char *name, Node *dcl)
{
Node *n;
size_t i;
@@ -1401,7 +1464,8 @@ static Func *simpfn(Simp *s, char *name, Node *dcl)
return fn;
}
-static void extractsub(Simp *s, Node *e)
+static void
+extractsub(Simp *s, Node *e)
{
size_t i;
Node *sub;
@@ -1433,7 +1497,8 @@ static void extractsub(Simp *s, Node *e)
}
}
-static void simpconstinit(Simp *s, Node *dcl)
+static void
+simpconstinit(Simp *s, Node *dcl)
{
Node *e;
@@ -1464,7 +1529,8 @@ static void simpconstinit(Simp *s, Node *dcl)
}
}
-void simpglobl(Node *dcl, Htab *globls, Func ***fn, size_t *nfn, Node ***blob, size_t *nblob)
+void
+simpglobl(Node *dcl, Htab *globls, Func ***fn, size_t *nfn, Node ***blob, size_t *nblob)
{
Simp s = {0,};
char *name;
diff --git a/6/typeinfo.c b/6/typeinfo.c
index 1457caa..312aefb 100644
--- a/6/typeinfo.c
+++ b/6/typeinfo.c
@@ -20,7 +20,8 @@
Blob *tydescsub(Type *ty);
-size_t blobsz(Blob *b)
+size_t
+blobsz(Blob *b)
{
size_t n;
size_t i;
@@ -53,7 +54,8 @@ size_t blobsz(Blob *b)
return 0;
}
-void namevec(Blob ***sub, size_t *nsub, Node *n)
+void
+namevec(Blob ***sub, size_t *nsub, Node *n)
{
char *buf;
size_t len;
@@ -71,7 +73,8 @@ void namevec(Blob ***sub, size_t *nsub, Node *n)
lappend(sub, nsub, mkblobbytes(buf, len));
}
-static void structmemb(Blob ***sub, size_t *nsub, Node *sdecl)
+static void
+structmemb(Blob ***sub, size_t *nsub, Node *sdecl)
{
Blob *b;
@@ -80,7 +83,8 @@ static void structmemb(Blob ***sub, size_t *nsub, Node *sdecl)
lappend(sub, nsub, b);
}
-static void unionmemb(Blob ***sub, size_t *nsub, Ucon *ucon)
+static void
+unionmemb(Blob ***sub, size_t *nsub, Ucon *ucon)
{
namevec(sub, nsub, ucon->name);
if (ucon->etype) {
@@ -91,13 +95,15 @@ static void unionmemb(Blob ***sub, size_t *nsub, Ucon *ucon)
}
}
-static void encodetypeinfo(Blob ***sub, size_t *nsub, Type *t)
+static void
+encodetypeinfo(Blob ***sub, size_t *nsub, Type *t)
{
lappend(sub, nsub, mkblobi(Btimin, tysize(t)));
lappend(sub, nsub, mkblobi(Btimin, tyalign(t)));
}
-Blob *tydescsub(Type *ty)
+Blob *
+tydescsub(Type *ty)
{
Blob **sub, *sz, *bt, *b;
size_t i, nsub;
@@ -191,7 +197,8 @@ Blob *tydescsub(Type *ty)
return b;
}
-Blob *namedesc(Type *ty)
+Blob *
+namedesc(Type *ty)
{
Blob **sub;
size_t nsub;
@@ -204,7 +211,8 @@ Blob *namedesc(Type *ty)
return mkblobseq(sub, nsub);
}
-Blob *tydescblob(Type *ty)
+Blob *
+tydescblob(Type *ty)
{
char buf[512];
Blob *b, *sz, *sub;
@@ -229,7 +237,8 @@ Blob *tydescblob(Type *ty)
return b;
}
-size_t tysize(Type *t)
+size_t
+tysize(Type *t)
{
size_t sz;
size_t i;
@@ -309,7 +318,8 @@ size_t tysize(Type *t)
return -1;
}
-size_t tyalign(Type *ty)
+size_t
+tyalign(Type *ty)
{
size_t align, i;
@@ -340,7 +350,8 @@ size_t tyalign(Type *ty)
}
/* gets the byte offset of 'memb' within the aggregate type 'aggr' */
-ssize_t tyoffset(Type *ty, Node *memb)
+ssize_t
+tyoffset(Type *ty, Node *memb)
{
size_t i;
size_t off;
@@ -361,7 +372,8 @@ ssize_t tyoffset(Type *ty, Node *memb)
return 0;
}
-size_t size(Node *n)
+size_t
+size(Node *n)
{
Type *t;
@@ -372,7 +384,8 @@ size_t size(Node *n)
return tysize(t);
}
-ssize_t offset(Node *aggr, Node *memb)
+ssize_t
+offset(Node *aggr, Node *memb)
{
return tyoffset(exprtype(aggr), memb);
}