From e04166b85d1d6a8adbb3c385755ccd90323bf6b5 Mon Sep 17 00:00:00 2001 From: George Koehler Date: Mon, 13 Nov 2017 12:44:17 -0500 Subject: [PATCH] More prototypes, less register in mach/proto/ncg Files that #include "equiv.h" must do so after including "data.h", now that a function prototype in equiv.h uses type rl_p from data.h. Adjust style, changing some `for(...)` to `for (...)`. The style in mach/proto/ncg is less than consistent; the big annoyance now is that some files want tabs at 4 spaces, others want tabs at 8 spaces. --- mach/proto/ncg/codegen.c | 45 ++++++++++++++-------------------------- mach/proto/ncg/compute.c | 7 +++---- mach/proto/ncg/data.h | 12 +++++++++++ mach/proto/ncg/equiv.c | 9 ++++---- mach/proto/ncg/equiv.h | 2 ++ mach/proto/ncg/extern.h | 3 --- mach/proto/ncg/fillem.c | 14 ++++++------- mach/proto/ncg/gencode.c | 28 ++++++++++++------------- mach/proto/ncg/glosym.c | 10 ++++----- mach/proto/ncg/glosym.h | 3 ++- mach/proto/ncg/label.c | 12 +++++------ mach/proto/ncg/label.h | 4 +++- mach/proto/ncg/main.c | 20 +++++++----------- mach/proto/ncg/move.c | 14 ++++++------- mach/proto/ncg/nextem.c | 21 +++++++++---------- mach/proto/ncg/reg.c | 42 ++++++++++++++++++------------------- mach/proto/ncg/regvar.c | 43 ++++++++++++++++---------------------- mach/proto/ncg/result.h | 3 +++ mach/proto/ncg/salloc.c | 8 ++++--- mach/proto/ncg/state.c | 9 ++++---- mach/proto/ncg/state.h | 4 ++++ mach/proto/ncg/subr.c | 11 +++++----- mach/proto/ncg/types.h | 26 +++++++++++++++++++++++ 23 files changed, 184 insertions(+), 166 deletions(-) diff --git a/mach/proto/ncg/codegen.c b/mach/proto/ncg/codegen.c index 7e65590ee..7339265b7 100644 --- a/mach/proto/ncg/codegen.c +++ b/mach/proto/ncg/codegen.c @@ -27,13 +27,6 @@ static char rcsid[] = "$Id$"; byte startupcode[] = { DO_NEXTEM }; -byte* nextem(); -unsigned costcalc(); -unsigned docoerc(); -unsigned stackupto(); -string tostring(); -string ad2str(); - #ifdef NDEBUG #define DEBUG(string) #else @@ -124,7 +117,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for byte* bp; int n; unsigned mindistance, dist; - register i; + int i; int cindex; int npos, pos[MAXRULE]; unsigned mincost, t; @@ -295,8 +288,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for DEBUG("XXMATCH"); case DO_XMATCH: { - register i; - int temp; + int i, temp; DEBUG("XMATCH"); tokpatlen = (codep[-1] >> 5) & 07; @@ -306,8 +298,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for } case DO_MATCH: { - register i; - int j; + int i, j; unsigned mincost, t; token_p tp; int size, lsize; @@ -603,8 +594,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for case DO_KILLREG: case DO_RREMOVE: { /* register remove */ - register i; - int nodeno; + int i, nodeno; token_p tp; tkdef_p tdp; result_t result; @@ -650,7 +640,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for } case DO_DEALLOCATE: { - register i; + int i; tkdef_p tdp; int tinstno; token_t token; @@ -684,8 +674,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for } case DO_ALLOCATE: { - register i; - int j; + int i, j; int tinstno; int npos, npos2, pos[NREGS], pos2[NREGS]; unsigned mincost, t; @@ -844,8 +833,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for } case DO_INSTR: { - register i; - int n; + int i, n; int tinstno; token_t token; int stringno; @@ -933,7 +921,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for } case DO_TOKREPLACE: { - register i; + int i; int tinstno; int repllen; token_t reptoken[MAXREPLLEN]; @@ -969,8 +957,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for } case DO_EMREPLACE: { - register i; - int j; + int i, j; int nodeno; result_t result[MAXEMREPLLEN]; int emrepllen, eminstr; @@ -1093,10 +1080,10 @@ doreturn: return (totalcost); } -readcodebytes() +void readcodebytes(void) { #ifndef CODEINC - register fd; + int fd; extern int ncodebytes; if ((fd = open("code", 0)) < 0) @@ -1108,11 +1095,11 @@ readcodebytes() error("Short read from code"); } close(fd); -#endif +#endif /* CODEINC */ } #ifdef TABLEDEBUG -initlset(f) char* f; +void initlset(char *f) { set_flag = f; @@ -1123,7 +1110,7 @@ initlset(f) char* f; read(set_fd, set_val, set_size); } -termlset() +void termlset(void) { if (set_fd) @@ -1133,7 +1120,7 @@ termlset() close(set_fd); if (set_flag[0] == 'u') { - register i; + int i; fprintf(stderr, "Unused code rules:\n\n"); for (i = 0; i < 8 * set_size; i++) @@ -1142,4 +1129,4 @@ termlset() } } } -#endif +#endif /* TABLEDEBUG */ diff --git a/mach/proto/ncg/compute.c b/mach/proto/ncg/compute.c index 30d129cef..aa97329a4 100644 --- a/mach/proto/ncg/compute.c +++ b/mach/proto/ncg/compute.c @@ -35,7 +35,7 @@ static char rcsid[] = "$Id$"; #define LLDEF LLEAF|LDEF #define RLDEF RLEAF|RDEF -char opdesc[] = { +static const char opdesc[] = { 0, /* EX_TOKFIELD */ 0, /* EX_ARG */ 0, /* EX_CON */ @@ -121,10 +121,9 @@ string tostring(word n) { return(mystrcpy(buf)); } -void -compute(node, presult) register node_p node; register result_t *presult; { +void compute(node_p node, result_t *presult) { result_t leaf1,leaf2; - register token_p tp; + token_p tp; int desc; long mask,tmp; int i,tmpreg; diff --git a/mach/proto/ncg/data.h b/mach/proto/ncg/data.h index dbba9914a..06779d730 100644 --- a/mach/proto/ncg/data.h +++ b/mach/proto/ncg/data.h @@ -72,6 +72,18 @@ typedef struct { int rl_list[NREGS]; } rl_t,*rl_p; +/* gencode.c */ +void genstr(int); +string ad2str(address_t); +void gennl(void); +void prtoken(token_p, int); +#ifdef USE_TES +void printlabel(int); +#endif +/* move.c */ +int move(token_p, token_p, int, int, unsigned); +void setcc(token_p); +int test(token_p, int, int, unsigned); /* subr.c */ int match(token_p, set_p, int); void instance(int, token_p); diff --git a/mach/proto/ncg/equiv.c b/mach/proto/ncg/equiv.c index 9057aa211..01a518bd4 100644 --- a/mach/proto/ncg/equiv.c +++ b/mach/proto/ncg/equiv.c @@ -5,12 +5,12 @@ static char rcsid[] = "$Id$"; #include #include #include -#include "equiv.h" #include "param.h" #include "tables.h" #include "types.h" #include #include "data.h" +#include "equiv.h" #include "result.h" #include "extern.h" @@ -29,11 +29,10 @@ static struct perm *perms; static void permute(int); -struct perm * -tuples(regls,nregneeded) rl_p *regls; { +struct perm *tuples(rl_p *regls, int nregneeded) { int class=0; - register i,j; - register struct reginfo *rp; + int i,j; + struct reginfo *rp; /* * First compute equivalence classes of registers. diff --git a/mach/proto/ncg/equiv.h b/mach/proto/ncg/equiv.h index fcd7971da..85a5ad52c 100644 --- a/mach/proto/ncg/equiv.h +++ b/mach/proto/ncg/equiv.h @@ -10,3 +10,5 @@ struct perm { struct perm *p_next; int p_rar[MAXCREG]; }; + +struct perm *tuples(rl_p *, int); diff --git a/mach/proto/ncg/extern.h b/mach/proto/ncg/extern.h index e289eb8af..330e2c68e 100644 --- a/mach/proto/ncg/extern.h +++ b/mach/proto/ncg/extern.h @@ -54,6 +54,3 @@ extern int *rvnumbers[]; /* lists of numbers */ #endif extern FILE *codefile; - -extern void error(const char *s, ...); -extern void fatal(const char *s, ...); diff --git a/mach/proto/ncg/fillem.c b/mach/proto/ncg/fillem.c index 1306b91fd..c9f3fb5b3 100644 --- a/mach/proto/ncg/fillem.c +++ b/mach/proto/ncg/fillem.c @@ -17,6 +17,7 @@ static char rcsid2[] = "$Id$"; #include "types.h" #include #include "data.h" +#include "glosym.h" #include "result.h" #ifdef REGVARS #include "regvar.h" @@ -103,7 +104,7 @@ static string holstr(word); /* Own version of atol that continues computing on overflow. We don't know that about the ANSI C one. */ -long our_atol(char *s) { +static long our_atol(char *s) { long total = 0; unsigned digit; int minus = 0; @@ -235,18 +236,17 @@ void fillemlines(void) { void dopseudo() { - register b,t; - register full n; - register long save; + int b,t; + full n; + long save; word romcont[MAXROM+1]; int nromwords; int rombit,rommask; - unsigned stackupto(); if (nextispseu==0 || nemlines>0) error("No table entry for %d",emlines[0].em_instr); nextispseu=0; - switch(savetab1) { + switch (savetab1) { #ifndef USE_TES case sp_ilb1: case sp_ilb2: @@ -680,7 +680,7 @@ static long con(int t) { extern char *segname[]; -swtxt() { +void swtxt(void) { switchseg(SEGTXT); } diff --git a/mach/proto/ncg/gencode.c b/mach/proto/ncg/gencode.c index d3018b057..5b092340f 100644 --- a/mach/proto/ncg/gencode.c +++ b/mach/proto/ncg/gencode.c @@ -4,6 +4,7 @@ static char rcsid[] = "$Id$"; #include #include +#include /* isatty */ #include "param.h" #include "tables.h" #include "types.h" @@ -24,7 +25,7 @@ static char rcsid[] = "$Id$"; FILE *codefile; -out_init(filename) char *filename; { +void out_init(char *filename) { #ifndef NDEBUG static char stderrbuff[BUFSIZ]; @@ -45,7 +46,7 @@ out_init(filename) char *filename; { #endif } -out_finish() { +void out_finish(void) { #ifndef NDEBUG if (Debug) @@ -58,18 +59,18 @@ out_finish() { #endif } -tstoutput() { +void tstoutput(void) { if (ferror(codefile)) error("Write error on output"); } -genstr(stringno) { +void genstr(int stringno) { fputs(codestrings[stringno],codefile); } -string ad2str(ad) address_t ad; { +string ad2str(address_t ad) { static char buf[100]; if (ad.ea_str==0) @@ -84,7 +85,7 @@ string ad2str(ad) address_t ad; { return(mystrcpy(buf)); } -praddr(ad) address_t ad; { +static void praddr(address_t ad) { if (ad.ea_str==0 || *(ad.ea_str) == '\0') fprintf(codefile,WRD_FMT,ad.ea_off); @@ -101,15 +102,14 @@ praddr(ad) address_t ad; { } } -gennl() { +void gennl(void) { putc('\n',codefile); } -void -prtoken(tp,leadingchar) token_p tp; { - register c; - register char *code; - register tkdef_p tdp; +void prtoken(token_p tp, int leadingchar) { + int c; + char *code; + tkdef_p tdp; putc(leadingchar,codefile); if (tp->t_token == -1) { @@ -142,9 +142,7 @@ prtoken(tp,leadingchar) token_p tp; { } #ifdef USE_TES -printlabel(labnum) -int labnum; -{ +void printlabel(int labnum) { newilb(dollar[labnum].e_v.e_addr.ea_str); } #endif diff --git a/mach/proto/ncg/glosym.c b/mach/proto/ncg/glosym.c index fa88895af..fe763b13c 100644 --- a/mach/proto/ncg/glosym.c +++ b/mach/proto/ncg/glosym.c @@ -18,9 +18,9 @@ static char rcsid[] = "$Id$"; static glosym_p glolist= (glosym_p) 0; -enterglo(name,romp) string name; word *romp; { - register glosym_p gp; - register i; +void enterglo(string name, word *romp) { + glosym_p gp; + int i; gp = (glosym_p) myalloc(sizeof *gp); gp->gl_next = glolist; @@ -31,8 +31,8 @@ enterglo(name,romp) string name; word *romp; { glolist = gp; } -glosym_p lookglo(name) string name; { - register glosym_p gp; +glosym_p lookglo(string name) { + glosym_p gp; for (gp=glolist;gp != (glosym_p) 0; gp=gp->gl_next) if (strcmp(gp->gl_name,name)==0) diff --git a/mach/proto/ncg/glosym.h b/mach/proto/ncg/glosym.h index 1449b9b1b..89322319b 100644 --- a/mach/proto/ncg/glosym.h +++ b/mach/proto/ncg/glosym.h @@ -10,4 +10,5 @@ typedef struct glosym { word gl_rom[MAXROM+1]; } glosym_t,*glosym_p; -glosym_p lookglo(); +void enterglo(string, word *); +glosym_p lookglo(string); diff --git a/mach/proto/ncg/label.c b/mach/proto/ncg/label.c index ed88a8dc7..bb7fdad20 100644 --- a/mach/proto/ncg/label.c +++ b/mach/proto/ncg/label.c @@ -6,10 +6,9 @@ static label_p label_list = (label_p)0; -void -add_label(num, height, flth) +void add_label(num, height, flth) { - register label_p lbl = (label_p)0; + label_p lbl = (label_p)0; if (height <= 0) return; if (flth != TRUE && flth != FALSE) @@ -23,10 +22,9 @@ add_label(num, height, flth) label_list = lbl; } -label_p get_label(num) -register word num; +label_p get_label(word num) { - register label_p tmp = label_list; + label_p tmp = label_list; while (tmp != (label_p)0) { if (tmp->lb_number == num) return tmp; @@ -35,7 +33,7 @@ register word num; return (label_p)0; } -kill_labels() +void kill_labels(void) { label_p tmp; diff --git a/mach/proto/ncg/label.h b/mach/proto/ncg/label.h index 96c290be6..fc79cb838 100644 --- a/mach/proto/ncg/label.h +++ b/mach/proto/ncg/label.h @@ -14,4 +14,6 @@ struct label { short lb_fallthrough; }; -extern label_p get_label(); +void add_label(int, int, int); +label_p get_label(word); +void kill_labels(void); diff --git a/mach/proto/ncg/main.c b/mach/proto/ncg/main.c index 3336bc49b..0b3a40f86 100644 --- a/mach/proto/ncg/main.c +++ b/mach/proto/ncg/main.c @@ -2,9 +2,10 @@ static char rcsid[] = "$Id$"; #endif +#include /* atoi */ #include "param.h" #include "tables.h" -#include "types.h" /* byte, codegen */ +#include "types.h" #include "mach.h" /* @@ -22,16 +23,11 @@ int Debug=0; char *strtdebug=""; #endif -/* fillem.c */ -void in_init(char *); -void in_start(void); -/* subr.c */ -void itokcost(void); +static unsigned ggd(unsigned, unsigned); -main(argc,argv) char **argv; { - register unsigned n; - extern unsigned cc1,cc2,cc3,cc4; - unsigned ggd(); +int main(int argc, char **argv) { + unsigned n; + extern unsigned cc1,cc2,cc3,cc4; /* tables.c */ progname = argv[0]; while (--argc && **++argv == '-') { @@ -90,8 +86,8 @@ main(argc,argv) char **argv; { error("Bombed out of codegen"); } -unsigned ggd(a,b) register unsigned a,b; { - register unsigned c; +unsigned ggd(unsigned a, unsigned b) { + unsigned c; do { c = a%b; a=b; b=c; diff --git a/mach/proto/ncg/move.c b/mach/proto/ncg/move.c index 7cce99b75..c3b7bea5c 100644 --- a/mach/proto/ncg/move.c +++ b/mach/proto/ncg/move.c @@ -20,11 +20,11 @@ static char rcsid[] = "$Id$"; * Author: Hans van Staveren */ -move(tp1,tp2,ply,toplevel,maxcost) token_p tp1,tp2; unsigned maxcost; { - register move_p mp; +int move(token_p tp1, token_p tp2, int ply, int toplevel, unsigned maxcost) { + move_p mp; unsigned t; - register struct reginfo *rp; - register byte *tdpb; + struct reginfo *rp; + byte *tdpb; int i; if (eqtoken(tp1,tp2)) @@ -96,13 +96,13 @@ move(tp1,tp2,ply,toplevel,maxcost) token_p tp1,tp2; unsigned maxcost; { #define cocoreg machregs[0].r_contents -setcc(tp) token_p tp; { +void setcc(token_p tp) { cocoreg = *tp; } -test(tp,ply,toplevel,maxcost) token_p tp; unsigned maxcost; { - register test_p mp; +int test(token_p tp, int ply, int toplevel, unsigned maxcost) { + test_p mp; unsigned t; if (cocoreg.t_token!=0) { diff --git a/mach/proto/ncg/nextem.c b/mach/proto/ncg/nextem.c index daad8223c..6ff6e8260 100644 --- a/mach/proto/ncg/nextem.c +++ b/mach/proto/ncg/nextem.c @@ -27,11 +27,10 @@ static char rcsid[] = "$Id$"; extern char em_mnem[][4]; #endif -/* fillem.c */ -void fillemlines(void); +static int argtyp(int); -byte *trypat(bp,len) register byte *bp; { - register patlen,i; +static byte *trypat(byte *bp, int len) { + int patlen,i; result_t result; getint(patlen,bp); @@ -42,7 +41,7 @@ byte *trypat(bp,len) register byte *bp; { if (patlen != len) return(0); } - for(i=0;iemlines) { diff --git a/mach/proto/ncg/reg.c b/mach/proto/ncg/reg.c index fd0f115f0..bcbcf19a6 100644 --- a/mach/proto/ncg/reg.c +++ b/mach/proto/ncg/reg.c @@ -20,10 +20,10 @@ static char rcsid[] = "$Id$"; * Author: Hans van Staveren */ -chrefcount(regno,amount,tflag) { - register struct reginfo *rp; +void chrefcount(int regno, int amount, int tflag) { + struct reginfo *rp; #if MAXMEMBERS != 0 - register i, tmp; + int i, tmp; #endif rp= &machregs[regno]; @@ -42,10 +42,10 @@ chrefcount(regno,amount,tflag) { #endif } -getrefcount(regno, tflag) { - register struct reginfo *rp; +int getrefcount(int regno, int tflag) { + struct reginfo *rp; #if MAXMEMBERS != 0 - register i,maxcount, tmp; + int i,maxcount, tmp; #endif rp= &machregs[regno]; @@ -66,10 +66,10 @@ getrefcount(regno, tflag) { #endif } -erasereg(regno) { - register struct reginfo *rp = &machregs[regno]; - register int i; - register byte *tdpb; +void erasereg(int regno) { + struct reginfo *rp = &machregs[regno]; + int i; + byte *tdpb; #if MAXMEMBERS==0 rp->r_contents.t_token = 0; @@ -108,7 +108,7 @@ erasereg(regno) { } #else extern short clashlist[]; - register short *sp = &clashlist[rp->r_iclash]; + short *sp = &clashlist[rp->r_iclash]; rp->r_contents.t_token = 0; while (*sp) { @@ -151,9 +151,9 @@ erasereg(regno) { #endif } -cleanregs() { - register struct reginfo *rp; - register i; +void cleanregs(void) { + struct reginfo *rp; + int i; for (rp=machregs;rpr_contents.t_token = 0; @@ -163,9 +163,9 @@ cleanregs() { } #ifndef NDEBUG -inctcount(regno) { - register struct reginfo *rp; - register i; +static void inctcount(int regno) { + struct reginfo *rp; + int i; rp = &machregs[regno]; #if MAXMEMBERS!=0 @@ -181,10 +181,10 @@ inctcount(regno) { #endif } -chkregs() { - register struct reginfo *rp; - register token_p tp; - register byte *tdpb; +void chkregs(void) { + struct reginfo *rp; + token_p tp; + byte *tdpb; int i; for (rp=machregs+1;rprv_next = rvlist; @@ -41,11 +40,10 @@ linkreg(long of, int sz, int tp, int sc) { return(rvlp); } -void -tryreg(struct regvar *rvlp, int typ) { +void tryreg(struct regvar *rvlp, int typ) { int score; - register i; - register struct regassigned *ra; + int i; + struct regassigned *ra; struct regvar *save; if (typ != reg_any && nregvar[typ]!=0) { @@ -99,8 +97,7 @@ tryreg(struct regvar *rvlp, int typ) { } } -void -fixregvars(int saveall) { +void fixregvars(int saveall) { struct reginfo *rp, *rp2; struct regvar *rv; int i, regno, rvtyp; @@ -145,9 +142,8 @@ fixregvars(int saveall) { f_regsave(); } -int -isregvar(long off) { - register struct regvar *rvlp; +int isregvar(long off) { + struct regvar *rvlp; for(rvlp=rvlist;rvlp!=0;rvlp=rvlp->rv_next) if(rvlp->rv_off == off) @@ -156,8 +152,7 @@ isregvar(long off) { } #ifdef REGLAP -int -isregvar_size(long off, int size) { +int isregvar_size(long off, int size) { int regno = isregvar(off); /* * A reg_float may have two sizes. If this register has the @@ -175,29 +170,27 @@ isregvar_size(long off, int size) { } #endif /* REGLAP */ -int -isregtyp(long off) { - register struct regvar *rvlp; +int isregtyp(long off) { + struct regvar *rvlp; - for(rvlp=rvlist;rvlp!=0;rvlp=rvlp->rv_next) - if(rvlp->rv_off == off) + for (rvlp=rvlist;rvlp!=0;rvlp=rvlp->rv_next) + if (rvlp->rv_off == off) return(rvlp->rv_reg ? rvlp->rv_type+1 : 0); return(-1); } -void -unlinkregs(void) { - register struct regvar *rvlp,*t; - register struct regassigned *ra; +void unlinkregs(void) { + struct regvar *rvlp,*t; + struct regassigned *ra; int rvtyp,i; - for(rvlp=rvlist;rvlp!=0;rvlp=t) { + for (rvlp=rvlist;rvlp!=0;rvlp=t) { t=rvlp->rv_next; myfree((string)rvlp); } rvlist=0; for (rvtyp=reg_any;rvtyp<=reg_float;rvtyp++) { - for(i=0;ira_rv = 0; ra->ra_score = 0; diff --git a/mach/proto/ncg/result.h b/mach/proto/ncg/result.h index fdb9e16e1..82cf970ce 100644 --- a/mach/proto/ncg/result.h +++ b/mach/proto/ncg/result.h @@ -19,3 +19,6 @@ struct result { #define EV_ADDR 3 typedef struct result result_t; + +/* compute.c */ +void compute(node_p, result_t *); diff --git a/mach/proto/ncg/salloc.c b/mach/proto/ncg/salloc.c index 7a7dd189c..71fe20c3d 100644 --- a/mach/proto/ncg/salloc.c +++ b/mach/proto/ncg/salloc.c @@ -35,7 +35,7 @@ int nstab=0; static void chkstr(string, char *); string myalloc(size) { - register string p; + string p; p = (string) calloc((unsigned)size, 1); if (p==0) @@ -66,7 +66,9 @@ char *salloc(int size) { return(p); } -static int compar(char **p1, char **p2) { +static int compar(const void *v1, const void *v2) { + char *const *p1 = v1; + char *const *p2 = v2; assert(*p1 != *p2); if (*p1 < *p2) @@ -88,7 +90,7 @@ void garbage_collect(void) { qsort((char *)stab,nstab,sizeof (char *),compar); for (i=0;iem_soper,used); for (tp= fakestack;tp<&fakestack[stackheight];tp++) { if (tp->t_token== -1) diff --git a/mach/proto/ncg/state.c b/mach/proto/ncg/state.c index b8d53b27f..45288546f 100644 --- a/mach/proto/ncg/state.c +++ b/mach/proto/ncg/state.c @@ -23,9 +23,9 @@ static char rcsid[] = "$Id$"; extern int nstab; /* salloc.c */ -void bmove(); +static void bmove(short *, short *, int); -savestatus(sp) register state_p sp; { +void savestatus(state_p sp) { sp->st_sh = stackheight; bmove((short *)fakestack,(short *)sp->st_fs,stackheight*sizeof(token_t)); @@ -42,7 +42,7 @@ savestatus(sp) register state_p sp; { sp->st_ns = nstab; } -restorestatus(sp) register state_p sp; { +void restorestatus(state_p sp) { stackheight = sp->st_sh; bmove((short *)sp->st_fs,(short *)fakestack,stackheight*sizeof(token_t)); @@ -59,8 +59,7 @@ restorestatus(sp) register state_p sp; { popstr(sp->st_ns); } -void -bmove(from,to,nbytes) register short *from,*to; register nbytes; { +static void bmove(short *from, short *to, int nbytes) { if (nbytes<=0) return; diff --git a/mach/proto/ncg/state.h b/mach/proto/ncg/state.h index 962fd35f8..dafdebe0d 100644 --- a/mach/proto/ncg/state.h +++ b/mach/proto/ncg/state.h @@ -20,3 +20,7 @@ typedef struct state { int st_tl; /* tokpatlen */ int st_ns; /* nstab */ } state_t,*state_p; + +/* state.c */ +void savestatus(state_p); +void restorestatus(state_p); diff --git a/mach/proto/ncg/subr.c b/mach/proto/ncg/subr.c index 81a021be1..0feb54f30 100644 --- a/mach/proto/ncg/subr.c +++ b/mach/proto/ncg/subr.c @@ -6,6 +6,7 @@ static char rcsid[] = "$Id$"; #include #include #include +#include /* strcmp */ #include "param.h" #include "tables.h" #include "types.h" @@ -562,8 +563,8 @@ unsigned stackupto(token_p limit, int ply, int toplevel) { int tpl; /* saved tokpatlen */ int nareg; /* saved nareg */ int areg[MAXALLREG]; - register c1_p cp; - register token_p tp; + c1_p cp; + token_p tp; unsigned totalcost=0; struct reginfo *rp,**rpp; @@ -620,10 +621,10 @@ unsigned stackupto(token_p limit, int ply, int toplevel) { } c3_p findcoerc(token_p tp, set_p tep) { - register c3_p cp; + c3_p cp; token_t rtoken; - register i; - register struct reginfo **rpp; + int i; + struct reginfo **rpp; for (cp=c3coercs;cp->c3_texpno>=0; cp++) { if (tp!=(token_p) 0) { diff --git a/mach/proto/ncg/types.h b/mach/proto/ncg/types.h index 1867853ca..2f88bfbb6 100644 --- a/mach/proto/ncg/types.h +++ b/mach/proto/ncg/types.h @@ -31,12 +31,38 @@ typedef char * string; /* codegen.c */ unsigned codegen(byte *, int, int, unsigned, int); +void readcodebytes(void); +#ifdef TABLEDEBUG +void initlset(char *); +void termlset(void); +#endif /* compute.c */ string mystrcpy(string); string tostring(word); +/* fillem.c */ +void in_init(char *); +void in_start(void); +void fillemlines(void); +void swtxt(void); +/* gencode.c */ +void out_init(char *); +void out_finish(void); +void tstoutput(void); +/* nextem.c */ +byte *nextem(int); +/* reg.c */ +void chrefcount(int, int, int); +int getrefcount(int, int); +void erasereg(int); +void cleanregs(void); +void chkregs(void); /* salloc.c */ string myalloc(int); void myfree(string); void popstr(int); char *salloc(int); void garbage_collect(void); +/* subr.c */ +void itokcost(void); +void error(const char *s, ...); +void fatal(const char *s, ...);