diff options
author | Ori Bernstein <ori@eigenstate.org> | 2017-01-08 21:39:08 -0800 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2017-01-08 21:39:08 -0800 |
commit | 4ff322bbbc9b8c181b6f48b55c72f5482cec3c88 (patch) | |
tree | 3eed9e6c0d33a3ec0dc28119b9a3115c9a007944 /6 | |
parent | 186c4e4026e1d9db729153e185bd717377060926 (diff) | |
download | mc-4ff322bbbc9b8c181b6f48b55c72f5482cec3c88.tar.gz |
Dedup const initialization.
Diffstat (limited to '6')
-rw-r--r-- | 6/asm.h | 1 | ||||
-rw-r--r-- | 6/gen.c | 25 | ||||
-rw-r--r-- | 6/gengas.c | 25 | ||||
-rw-r--r-- | 6/genp9.c | 24 |
4 files changed, 26 insertions, 49 deletions
@@ -250,6 +250,7 @@ extern Node *abortoob; extern int extracheck; extern Asmsyntax asmsyntax; +void initconsts(Htab *globls); void fillglobls(Stab *st, Htab *globls); void simpglobl(Node *dcl, Htab *globls, Func ***fn, size_t *nfn, Node ***blob, size_t *nblob); void selfunc(Isel *is, Func *fn, Htab *globls, Htab *strtab); @@ -45,6 +45,31 @@ void fillglobls(Stab *st, Htab *globls) free(ns); } + +void initconsts(Htab *globls) +{ + Type *ty; + Node *name; + Node *dcl; + + tyintptr = mktype(Zloc, Tyuint64); + tyword = mktype(Zloc, Tyuint); + tyvoid = mktype(Zloc, Tyvoid); + + ty = mktyfunc(Zloc, NULL, 0, mktype(Zloc, Tyvoid)); + ty->type = Tycode; + name = mknsname(Zloc, "_rt", "abort_oob"); + dcl = mkdecl(Zloc, name, ty); + dcl->decl.isconst = 1; + dcl->decl.isextern = 1; + htput(globls, dcl, asmname(dcl)); + + abortoob = mkexpr(Zloc, Ovar, name, NULL); + abortoob->expr.type = ty; + abortoob->expr.did = dcl->decl.did; + abortoob->expr.isconst = 1; +} + Type *codetype(Type *ft) { ft = tybase(ft); @@ -41,31 +41,6 @@ static char* modenames[] = { static void locprint(FILE *fd, Loc *l, char spec); -static void initconsts(Htab *globls) -{ - Type *ty; - Node *name; - Node *dcl; - - tyintptr = mktype(Zloc, Tyuint64); - tyword = mktype(Zloc, Tyuint); - tyvoid = mktype(Zloc, Tyvoid); - - ty = mktyfunc(Zloc, NULL, 0, mktype(Zloc, Tyvoid)); - ty->type = Tycode; - name = mknsname(Zloc, "_rt", "abort_oob"); - dcl = mkdecl(Zloc, name, ty); - dcl->decl.isconst = 1; - dcl->decl.isextern = 1; - dcl->decl.isglobl = 1; - htput(globls, dcl, asmname(dcl)); - - abortoob = mkexpr(Zloc, Ovar, name, NULL); - abortoob->expr.type = ty; - abortoob->expr.did = dcl->decl.did; - abortoob->expr.isconst = 1; -} - void printmem(FILE *fd, Loc *l, char spec) { if (l->type == Locmem) { @@ -40,30 +40,6 @@ static char* modenames[] = { static void locprint(FILE *fd, Loc *l, char spec); -static void initconsts(Htab *globls) -{ - Type *ty; - Node *name; - Node *dcl; - - tyintptr = mktype(Zloc, Tyuint64); - tyword = mktype(Zloc, Tyuint); - tyvoid = mktype(Zloc, Tyvoid); - - ty = mktyfunc(Zloc, NULL, 0, mktype(Zloc, Tyvoid)); - ty->type = Tycode; - name = mknsname(Zloc, "_rt", "abort_oob"); - dcl = mkdecl(Zloc, name, ty); - dcl->decl.isconst = 1; - dcl->decl.isextern = 1; - htput(globls, dcl, asmname(dcl)); - - abortoob = mkexpr(Zloc, Ovar, name, NULL); - abortoob->expr.type = ty; - abortoob->expr.did = dcl->decl.did; - abortoob->expr.isconst = 1; -} - static void printmem(FILE *fd, Loc *l, char spec) { if (l->type == Locmem) { |