From 25c717d9b3c907c163ad3bdaef673079a5a7ae04 Mon Sep 17 00:00:00 2001 From: Manoel Trapier Date: Tue, 19 Mar 2013 17:37:24 +0100 Subject: [PATCH] Next batch of warning hunt... --- modules/h/em_code.h | 3 +++ modules/src/em_code/convert.c | 35 ++++++++++++++++++++---------- modules/src/em_opt/main.c | 35 ++++++++++++++++++------------ modules/src/flt_arith/flt_ar2flt.c | 5 +---- util/led/error.c | 1 + util/misc/convert.c | 14 ++++++------ util/misc/esize.c | 3 +++ util/opt/alloc.c | 20 +++++++---------- util/opt/alloc.h | 34 +++++++++++++++++------------ util/opt/backward.c | 20 ++++++++--------- util/opt/backward.h | 11 ++++++++++ util/opt/cleanup.c | 21 ++++++++---------- util/opt/cleanup.h | 11 ++++++++++ util/opt/flow.c | 22 ++++++------------- util/opt/flow.h | 14 ++++++++++++ util/opt/getline.c | 25 +++++++++------------ util/opt/getline.h | 28 ++++++++++++++++++++++++ util/opt/lookup.c | 6 ++--- util/opt/lookup.h | 4 ++++ util/opt/main.c | 22 ++++++++++--------- util/opt/mktab.y | 11 +++++----- util/opt/pattern.h | 4 ++++ util/opt/peephole.c | 28 +++++++++--------------- util/opt/peephole.h | 25 +++++++++++++++++++++ util/opt/process.c | 31 +++++++++++--------------- util/opt/process.h | 20 +++++++++++++++++ util/opt/proinf.h | 4 ++++ util/opt/putline.c | 30 ++++++++----------------- util/opt/putline.h | 27 +++++++++++++++++++++++ util/opt/reg.c | 21 ++++++++---------- util/opt/reg.h | 17 +++++++++++++++ util/opt/scan.l | 9 ++++---- util/opt/tes.c | 8 +------ util/opt/tes.h | 14 ++++++++++++ util/opt/types.h | 4 ++++ util/opt/util.c | 28 +++++++++++------------- util/opt/util.h | 18 +++++++++++++++ util/opt/var.c | 4 ---- 38 files changed, 401 insertions(+), 236 deletions(-) create mode 100644 util/opt/backward.h create mode 100644 util/opt/cleanup.h create mode 100644 util/opt/flow.h create mode 100644 util/opt/getline.h create mode 100644 util/opt/peephole.h create mode 100644 util/opt/process.h create mode 100644 util/opt/putline.h create mode 100644 util/opt/reg.h create mode 100644 util/opt/util.h diff --git a/modules/h/em_code.h b/modules/h/em_code.h index 04a51504f..a4861fae3 100644 --- a/modules/h/em_code.h +++ b/modules/h/em_code.h @@ -35,6 +35,9 @@ _PROTOTYPE(void C_ms_stb_pnam, (char *, int, int, char *)); _PROTOTYPE(void C_ms_std, (char *, int, int)); _PROTOTYPE(int C_out, (struct e_instr *p)); +_PROTOTYPE(void error, (char *, ...)); +_PROTOTYPE(void fatal, (char *, ...)); + #ifdef PEEPHOLE #include "em_codeO.h" #include "emO_code.h" diff --git a/modules/src/em_code/convert.c b/modules/src/em_code/convert.c index 0e24c820b..65bdcc927 100644 --- a/modules/src/em_code/convert.c +++ b/modules/src/em_code/convert.c @@ -28,11 +28,10 @@ static char rcsid[] = "$Id$"; char *filename; /* Name of input file */ int errors; /* Number of errors */ -main(argc,argv) - char **argv; +int main(int argc, char *argv[]) { struct e_instr buf; - register struct e_instr *p = &buf; + struct e_instr *p = &buf; if (argc >= 2) { filename = argv[1]; @@ -68,22 +67,34 @@ main(argc,argv) } /* VARARGS */ -error(s,a1,a2,a3,a4) - char *s; +static int verror(char *s, va_list ap) { - fprint(STDERR, + fprintf(stderr, "%s, line %d: ", filename ? filename : "standard input", EM_lineno); - fprint(STDERR,s,a1,a2,a3,a4); - fprint(STDERR, "\n"); + vfprintf(stderr, s, ap); + fprintf(stderr, "\n"); errors++; + return 0; } -/* VARARGS */ -fatal(s,a1,a2,a3,a4) - char *s; +int error(char *s, ...) +{ + va_list ap; + va_start(ap, s); + verror(s, ap); + va_end(ap); + return 0; +} + +/*VARARGS1*/ +int fatal(char *s, ...) { - error(s,a1,a2,a3,a4); + va_list ap; + va_start(ap, s); + verror(s, ap); + va_end(ap); exit(1); + return 0; } diff --git a/modules/src/em_opt/main.c b/modules/src/em_opt/main.c index 0ac5a1617..954a11b64 100644 --- a/modules/src/em_opt/main.c +++ b/modules/src/em_opt/main.c @@ -2,24 +2,19 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef NORCSID -static char rcsid1[] = "$Id$"; -#endif - /* This is the main program for the stand-alone version of the peephole optimizer. */ - +#include #include "nopt.h" char *filename; /* Name of input file */ int errors; /* Number of errors */ -main(argc,argv) - char **argv; +int main(int argc, char *argv[]) { static struct e_instr buff; - register p_instr p = &buff; + p_instr p = &buff; if (argc >= 2) { filename = argv[1]; @@ -93,22 +88,34 @@ main(argc,argv) } /*VARARGS1*/ -error(s,a1,a2,a3,a4) - char *s; +static int verror(char *s, va_list ap) { fprintf(stderr, "%s, line %d: ", filename ? filename : "standard input", EM_lineno); - fprintf(stderr,s,a1,a2,a3,a4); + vfprintf(stderr, s, ap); fprintf(stderr, "\n"); errors++; + return 0; +} + +int error(char *s, ...) +{ + va_list ap; + va_start(ap, s); + verror(s, ap); + va_end(ap); + return 0; } /*VARARGS1*/ -fatal(s,a1,a2,a3,a4) - char *s; +int fatal(char *s, ...) { - error(s,a1,a2,a3,a4); + va_list ap; + va_start(ap, s); + verror(s, ap); + va_end(ap); exit(1); + return 0; } diff --git a/modules/src/flt_arith/flt_ar2flt.c b/modules/src/flt_arith/flt_ar2flt.c index f1d159a67..381b81948 100644 --- a/modules/src/flt_arith/flt_ar2flt.c +++ b/modules/src/flt_arith/flt_ar2flt.c @@ -8,10 +8,7 @@ #include "flt_misc.h" #include -void -flt_arith2flt(n, e, uns) - register arith n; - register flt_arith *e; +void flt_arith2flt(arith n, flt_arith *e, int uns) { /* Convert the arith "n" to a flt_arith "e". */ diff --git a/util/led/error.c b/util/led/error.c index f8df0d11c..d89cc89fe 100644 --- a/util/led/error.c +++ b/util/led/error.c @@ -35,6 +35,7 @@ void fatal(char *format, ...) va_start(ap, format); nerrors++; diag("fatal", format, ap); + va_end(ap); stop(); } diff --git a/util/misc/convert.c b/util/misc/convert.c index 16b661c64..84d5e3b69 100644 --- a/util/misc/convert.c +++ b/util/misc/convert.c @@ -2,10 +2,6 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif - #if __STDC__ #include #endif @@ -23,18 +19,22 @@ static char rcsid[] = "$Id$"; #include #include #include "system.h" +#include +#include #include "em_pseu.h" #include "em_mnem.h" #include "em_spec.h" #include "em_flag.h" #include "em_ptyp.h" -#include "em.h" #include "em_comp.h" +#include "em.h" +#include #if __STDC__ void error(char *fmt, ...); void fatal(char *fmt, ...); #else +#include "print.h" void error(); void fatal(); #endif @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) void error(char *fmt, ...) { va_list ap; - fprint(stderr, + fprintf(stderr, "%s, line %d: ", filename ? filename : "standard input", EM_lineno); @@ -104,7 +104,7 @@ void fatal(char *fmt, ...) if (C_busy()) C_close(); - fprint(stderr, + fprintf(stderr, "%s, line %d: ", filename ? filename : "standard input", EM_lineno); diff --git a/util/misc/esize.c b/util/misc/esize.c index 1644663b3..3fe10966b 100644 --- a/util/misc/esize.c +++ b/util/misc/esize.c @@ -4,6 +4,8 @@ #include #include +#include "object.h" + #ifndef MAGIC #define MAGIC 07255 #endif /* MAGIC */ @@ -35,6 +37,7 @@ long ptr8; void esize(char *fname); void rd_close(); +int rd_header(); int main(int argc, char *argv[]) { diff --git a/util/opt/alloc.c b/util/opt/alloc.c index d4a31b185..2090bfb9c 100644 --- a/util/opt/alloc.c +++ b/util/opt/alloc.c @@ -1,7 +1,9 @@ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif - +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Hans van Staveren + */ #include #include #include @@ -13,13 +15,7 @@ static char rcsid[] = "$Id$"; #include "line.h" #include "lookup.h" #include "proinf.h" - -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Hans van Staveren - */ +#include "util.h" #ifdef USEMALLOC @@ -438,7 +434,7 @@ short *freshcore(int size) #else /* USEMALLOC */ -void coreinit() { +void coreinit(short *p1, short *p2) { /* * Empty function, no initialization needed diff --git a/util/opt/alloc.h b/util/opt/alloc.h index d193cd39d..c421d15d0 100644 --- a/util/opt/alloc.h +++ b/util/opt/alloc.h @@ -3,20 +3,8 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* $Id$ */ - -extern line_p newline(); -extern offset *newrom(); -extern sym_p newsym(); -extern num_p newnum(); -extern arg_p newarg(); -extern argb_p newargb(); -extern reg_p newreg(); - - - -void oldline(line_p lnp); -void oldargb(argb_p abp); -void oldreg(reg_p rp); +#ifndef UTIL_OPT_ALLOC_H +#define UTIL_OPT_ALLOC_H #define USEMALLOC /* if defined malloc() and free() are used */ @@ -49,3 +37,21 @@ void oldreg(reg_p rp); #define STACKROOM 1 /* 0 gives problems */ #endif /* USEMALLOC */ + +/* util/opt/alloc.c */ +line_p newline(int optyp); +void oldline(line_p lnp); +arg_p newarg(int kind); +void oldargs(arg_p ap); +void oldargb(argb_p abp); +reg_p newreg(void); +void oldreg(reg_p rp); +num_p newnum(void); +void oldnum(num_p lp); +offset *newrom(void); +sym_p newsym(int len); +argb_p newargb(void); +void coreinit(short *p1, short *p2); +short *myalloc(int size); + +#endif /* UTIL_OPT_ALLOC_H */ \ No newline at end of file diff --git a/util/opt/backward.c b/util/opt/backward.c index 86f21f37f..08e368206 100644 --- a/util/opt/backward.c +++ b/util/opt/backward.c @@ -1,7 +1,9 @@ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif - +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Hans van Staveren + */ #include "param.h" #include "types.h" #include "tes.h" @@ -15,13 +17,9 @@ static char rcsid[] = "$Id$"; #include #include #include "ext.h" - -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Hans van Staveren - */ +#include "reg.h" +#include "util.h" +#include "getline.h" #define local(x) ((((x)->s_flags&SYMKNOWN) == 0 && \ ((x)->s_flags &= ~ SYMGLOBAL)),\ diff --git a/util/opt/backward.h b/util/opt/backward.h new file mode 100644 index 000000000..8bfdb5c3f --- /dev/null +++ b/util/opt/backward.h @@ -0,0 +1,11 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef UTIL_OPT_BACKWARD_H +#define UTIL_OPT_BACKWARD_H + +/* util/opt/backward.c */ +void backward(void); + +#endif /* UTIL_OPT_BACKWARD_H */ \ No newline at end of file diff --git a/util/opt/cleanup.c b/util/opt/cleanup.c index 80f9a09c4..f5159d902 100644 --- a/util/opt/cleanup.c +++ b/util/opt/cleanup.c @@ -1,8 +1,11 @@ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif - +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Hans van Staveren + */ #include +#include #include "param.h" #include "types.h" #include "assert.h" @@ -11,14 +14,8 @@ static char rcsid[] = "$Id$"; #include #include "lookup.h" #include "ext.h" - -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Hans van Staveren - */ - +#include "putline.h" +#include "util.h" void cleanup() { diff --git a/util/opt/cleanup.h b/util/opt/cleanup.h new file mode 100644 index 000000000..35f736a07 --- /dev/null +++ b/util/opt/cleanup.h @@ -0,0 +1,11 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef UTIL_OPT_CLEANUP_H +#define UTIL_OPT_CLEANUP_H + +/* util/opt/cleanup.c */ +void cleanup(void); + +#endif /* UTIL_OPT_CLEANUP_H */ \ No newline at end of file diff --git a/util/opt/flow.c b/util/opt/flow.c index 69a47bc24..fc9b1799e 100644 --- a/util/opt/flow.c +++ b/util/opt/flow.c @@ -1,7 +1,9 @@ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif - +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Hans van Staveren + */ #include "param.h" #include "types.h" #include "tes.h" @@ -13,17 +15,7 @@ static char rcsid[] = "$Id$"; #include "proinf.h" #include "optim.h" #include "ext.h" - -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Hans van Staveren - */ - -void findreach(); -void reach(line_p lnp); -void cleaninstrs(); +#include "flow.h" void flow() { diff --git a/util/opt/flow.h b/util/opt/flow.h new file mode 100644 index 000000000..1ca8e13db --- /dev/null +++ b/util/opt/flow.h @@ -0,0 +1,14 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef UTIL_OPT_FLOW_H +#define UTIL_OPT_FLOW_H + +/* util/opt/flow.c */ +void flow(void); +void findreach(void); +void reach(line_p lnp); +void cleaninstrs(void); + +#endif /* UTIL_OPT_FLOW_H */ \ No newline at end of file diff --git a/util/opt/getline.c b/util/opt/getline.c index 036f0e705..76b52dc86 100644 --- a/util/opt/getline.c +++ b/util/opt/getline.c @@ -1,7 +1,9 @@ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif - +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Hans van Staveren + */ #include #include #include "param.h" @@ -11,20 +13,16 @@ static char rcsid[] = "$Id$"; #include "lookup.h" #include "alloc.h" #include "proinf.h" +#include "getline.h" +#include "util.h" +#include "process.h" +#include "reg.h" #include #include #include #include #include "ext.h" -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Hans van Staveren - */ - - static short tabval; /* temp store for shorts */ static offset tabval2; /* temp store for offsets */ static char string[IDL+1]; /* temp store for names */ @@ -44,9 +42,6 @@ static char string[IDL+1]; /* temp store for names */ #define readbyte getchar -int inpseudo(short n); -void tstinpro(); - short readshort() { int l_byte, h_byte; diff --git a/util/opt/getline.h b/util/opt/getline.h new file mode 100644 index 000000000..64b3cb08e --- /dev/null +++ b/util/opt/getline.h @@ -0,0 +1,28 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef UTIL_OPT_GETLINE_H +#define UTIL_OPT_GETLINE_H + +/* util/opt/getline.c */ +short readshort(void); +offset readoffset(void); +void draininput(void); +short getint(void); +sym_p getsym(int status); +offset getoff(void); +void make_string(int n); +void inident(void); +int table3(int n); +int table1(void); +int table2(void); +void getlines(void); +void argstring(offset length, argb_p abp); +line_p arglist(int n); +offset aoff(arg_p ap, int n); +int inpseudo(short n); +void tstinpro(void); + + +#endif /* UTIL_OPT_GETLINE_H */ \ No newline at end of file diff --git a/util/opt/lookup.c b/util/opt/lookup.c index 8cda8e518..59bfe8917 100644 --- a/util/opt/lookup.c +++ b/util/opt/lookup.c @@ -1,7 +1,3 @@ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif - #include #include #include "param.h" @@ -10,6 +6,8 @@ static char rcsid[] = "$Id$"; #include "lookup.h" #include "alloc.h" #include "proinf.h" +#include "util.h" +#include "lookup.h" /* * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. diff --git a/util/opt/lookup.h b/util/opt/lookup.h index f243dc42c..fdaef3e51 100644 --- a/util/opt/lookup.h +++ b/util/opt/lookup.h @@ -3,6 +3,8 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* $Id$ */ +#ifndef UTIL_OPT_LOOKUP_H +#define UTIL_OPT_LOOKUP_H #define IDL 100 @@ -28,3 +30,5 @@ extern sym_p symhash[NSYMHASH],symlookup(); #define OCCURRING 0 #define DEFINING 1 #define NOTHING 2 + +#endif /* UTIL_OPT_LOOKUP_H */ \ No newline at end of file diff --git a/util/opt/main.c b/util/opt/main.c index 94335f998..226f72e78 100644 --- a/util/opt/main.c +++ b/util/opt/main.c @@ -1,22 +1,24 @@ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif - +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Hans van Staveren + */ #include #include #include "param.h" #include "types.h" #include "tes.h" #include "alloc.h" +#include "util.h" +#include "getline.h" +#include "cleanup.h" +#include "util.h" +#include "putline.h" #include #include "ext.h" -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Hans van Staveren - */ +#include /* * Main program for EM optimizer diff --git a/util/opt/mktab.y b/util/opt/mktab.y index e8fff04ed..717ad7771 100644 --- a/util/opt/mktab.y +++ b/util/opt/mktab.y @@ -1,8 +1,4 @@ %{ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif - #include #include #include @@ -37,6 +33,9 @@ bool onlyconst[N_EX_OPS]; int nerrors=0; char patid[128]; +/* fileno is not C89 and can be missing sometimes. */ +int fileno(FILE *stream); + int CBO_instrs[] = { op_adi, op_adu, @@ -341,11 +340,11 @@ void printnodes() printf("};\n\nshort lastind = %d;\n\nexpr_t enodes[] = {\n",prevind); for (p=nodes;pex_operator,p->ex_lnode,p->ex_rnode); printf("};\n\niarg_t iargs[%d];\n", (maxpatlen>0 ? maxpatlen : 1)); if (patid[0]) - printf("static char rcsid[] = %s;\n",patid); + printf("/*rcsid: %s*/\n",patid); } void initio() diff --git a/util/opt/pattern.h b/util/opt/pattern.h index 2cf7d8738..cc047185a 100644 --- a/util/opt/pattern.h +++ b/util/opt/pattern.h @@ -3,6 +3,8 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* $Id$ */ +#ifndef UTIL_OPT_PATTERN_H +#define UTIL_OPT_PATTERN_H /* * pattern contains the optimization patterns in an apparently @@ -128,3 +130,5 @@ extern byte nparam[]; extern bool nonumlab[]; extern bool onlyconst[]; extern expr_t enodes[]; + +#endif /* UTIL_OPT_PATTERN_H */ \ No newline at end of file diff --git a/util/opt/peephole.c b/util/opt/peephole.c index 96972b872..ac580ccbb 100644 --- a/util/opt/peephole.c +++ b/util/opt/peephole.c @@ -1,7 +1,10 @@ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif - +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Hans van Staveren + */ +#include #include "param.h" #include "types.h" #include "tes.h" @@ -15,20 +18,9 @@ static char rcsid[] = "$Id$"; #include #include "optim.h" #include "ext.h" - -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Hans van Staveren - */ - -#undef CHK_HASH /* print numbers patterns are hashed to */ -#ifdef CHK_HASH -#include -#endif - -int optimize(); +#include "util.h" +#include "peephole.h" +#include "reg.h" #define ILLHASH 0177777 short pathash[256]; /* table of indices into pattern[] */ diff --git a/util/opt/peephole.h b/util/opt/peephole.h new file mode 100644 index 000000000..c4e80ec67 --- /dev/null +++ b/util/opt/peephole.h @@ -0,0 +1,25 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef UTIL_OPT_PEEPHOLE_H +#define UTIL_OPT_PEEPHOLE_H + +#include "types.h" +#include "pattern.h" + +/* util/opt/peephole.c */ +void opcheck(byte *bp); +void hashpatterns(void); +int peephole(void); +int optimize(void); +offset oabs(offset off); +line_p repline(eval_t ev, int patlen); +offset rotate(offset w, offset amount); +eval_t compute(expr_p pexp); +bool tryrepl(line_p *lpp, register byte *bp, int patlen); +bool trypat(line_p *lpp, register byte *bp, int len); +int basicblock(line_p *alpp); +int repl_mul(register line_p lp, line_p *b, line_p *e); + +#endif /* UTIL_OPT_PEEPHOLE_H */ \ No newline at end of file diff --git a/util/opt/process.c b/util/opt/process.c index 9757259c9..6ed148d34 100644 --- a/util/opt/process.c +++ b/util/opt/process.c @@ -1,7 +1,9 @@ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif - +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Hans van Staveren + */ #include "param.h" #include "types.h" #include "tes.h" @@ -13,20 +15,13 @@ static char rcsid[] = "$Id$"; #include "lookup.h" #include "proinf.h" #include "ext.h" - -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Hans van Staveren - */ - -void relabel(); -void symknown(); -void cleanlocals(); -void checklocs(); -void symvalue(); -void do_tes(); +#include "util.h" +#include "backward.h" +#include "process.h" +#include "peephole.h" +#include "flow.h" +#include "putline.h" +#include "reg.h" void process() { diff --git a/util/opt/process.h b/util/opt/process.h new file mode 100644 index 000000000..eb5600639 --- /dev/null +++ b/util/opt/process.h @@ -0,0 +1,20 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef UTIL_OPT_PROCESS_H +#define UTIL_OPT_PROCESS_H + +#include "types.h" + +/* util/opt/process.c */ +void process(void); +void relabel(void); +void symknown(void); +void cleanlocals(void); +void checklocs(void); +offset align(offset count, offset alignment); +void symvalue(void); +void do_tes(void); + +#endif /* UTIL_OPT_PROCESS_H */ \ No newline at end of file diff --git a/util/opt/proinf.h b/util/opt/proinf.h index 940257d2e..ea14d26d1 100644 --- a/util/opt/proinf.h +++ b/util/opt/proinf.h @@ -3,6 +3,8 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* $Id$ */ +#ifndef UTIL_OPT_PROINF_H +#define UTIL_OPT_PROINF_H struct num { num_p n_next; @@ -42,3 +44,5 @@ typedef struct proinf { } proinf; extern proinf curpro; + +#endif /* UTIL_OPT_PROINF_H */ \ No newline at end of file diff --git a/util/opt/putline.c b/util/opt/putline.c index a7aa175ec..b2b9915c3 100644 --- a/util/opt/putline.c +++ b/util/opt/putline.c @@ -1,6 +1,10 @@ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Hans van Staveren + */ +#include #include "param.h" #include "types.h" @@ -16,24 +20,8 @@ static char rcsid[] = "$Id$"; #include "proinf.h" #include "optim.h" #include "ext.h" - -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Hans van Staveren - */ -void putargs(arg_p ap); -void putstr(argb_p abp); -void outdef(sym_p sp); -void outocc(sym_p sp); -void outinst(int m); -void outoff(offset off); -void outint(short i); -void outshort(short i); -void numlab(num_p np); -void outnum(num_p np); -void outsym(sym_p sp); +#include "util.h" +#include "putline.h" #define outbyte(b) putc(b,outfile) diff --git a/util/opt/putline.h b/util/opt/putline.h new file mode 100644 index 000000000..942b10aa3 --- /dev/null +++ b/util/opt/putline.h @@ -0,0 +1,27 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef UTIL_OPT_PUTLINE_H +#define UTIL_OPT_PUTLINE_H + +#include "proinf.h" +#include "types.h" + +/* util/opt/putline.c */ +void putlines(line_p lnp); +void putargs(arg_p ap); +void putstr(argb_p abp); +void outdef(sym_p sp); +void outocc(sym_p sp); +void outpro(void); +void outend(void); +void outinst(int m); +void outoff(offset off); +void outint(short i); +void outshort(short i); +void numlab(num_p np); +void outnum(num_p np); +void outsym(sym_p sp); + +#endif /* UTIL_OPT_PUTLINE_H */ \ No newline at end of file diff --git a/util/opt/reg.c b/util/opt/reg.c index dbbeee3cd..b418c29af 100644 --- a/util/opt/reg.c +++ b/util/opt/reg.c @@ -1,7 +1,9 @@ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif - +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Hans van Staveren + */ #include "assert.h" #include "param.h" #include "types.h" @@ -13,13 +15,8 @@ static char rcsid[] = "$Id$"; #include #include #include "ext.h" - -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Hans van Staveren - */ +#include "util.h" +#include "putline.h" void regvar(arg_p ap) { @@ -101,9 +98,9 @@ void outtes() { void incregusage(offset off) { +#ifndef GLOBAL_OPT reg_p rp; -#ifndef GLOBAL_OPT /* If we're optimizing the output of the global optimizer * we must not change the count fields of the register messages. */ diff --git a/util/opt/reg.h b/util/opt/reg.h new file mode 100644 index 000000000..7446be480 --- /dev/null +++ b/util/opt/reg.h @@ -0,0 +1,17 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef UTIL_OPT_REG_H +#define UTIL_OPT_REG_H + +#include "types.h" + +/* util/opt/reg.c */ +void regvar(arg_p ap); +int inreg(offset off); +void outregs(void); +void outtes(void); +void incregusage(offset off); + +#endif /* UTIL_OPT_REG_H */ \ No newline at end of file diff --git a/util/opt/scan.l b/util/opt/scan.l index 85d4aeefe..799d92f5c 100644 --- a/util/opt/scan.l +++ b/util/opt/scan.l @@ -1,8 +1,4 @@ %{ -#ifndef NORCSID -static char rcsid2[] = "$Id$"; -#endif - /* * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". @@ -10,8 +6,11 @@ static char rcsid2[] = "$Id$"; * Author: Hans van Staveren */ -extern long atol(); %} + +%option nounput +%option noinput + %% \"[^"]*\" { strncpy(patid,yytext,sizeof(patid)); return(STRING); } notreg return(NOTREG); diff --git a/util/opt/tes.c b/util/opt/tes.c index 04db39cb7..70b2b590a 100644 --- a/util/opt/tes.c +++ b/util/opt/tes.c @@ -1,12 +1,8 @@ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif /* * This file contains the main part of the top element size computation phase. * * Author: Hans van Eck. */ - #include #include #include @@ -20,13 +16,11 @@ static char rcsid[] = "$Id$"; #include "line.h" #include "ext.h" #include "pop_push.h" +#include "util.h" extern char *pop_push[]; extern char flow_tab[]; -void assign_label(num_p label); -void do_inst_label(line_p lnp); - #define NON_CONTINUABLE(i) (flow_tab[i]&JUMP) #define ISABRANCH(i) (flow_tab[i]&HASLABEL) #define ISCONDBRANCH(i) (flow_tab[i]&CONDBRA) diff --git a/util/opt/tes.h b/util/opt/tes.h index 770512166..829401caa 100644 --- a/util/opt/tes.h +++ b/util/opt/tes.h @@ -1,8 +1,22 @@ /* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * * Author: Hans van Eck. */ /* $Id$ */ +#ifndef UTIL_OPT_TES_H +#define UTIL_OPT_TES_H extern int state; #define KNOWN 1 #define NOTREACHED 2 + +/* util/opt/tes.c */ +void init_state(void); +void tes_pseudos(void); +void tes_instr(line_p lnp, line_p x, line_p y); +void assign_label(num_p label); +void do_inst_label(line_p lnp); + +#endif /* UTIL_OPT_TES_H */ diff --git a/util/opt/types.h b/util/opt/types.h index c9ff1824d..75ccd445b 100644 --- a/util/opt/types.h +++ b/util/opt/types.h @@ -3,6 +3,8 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* $Id$ */ +#ifndef UTIL_OPT_TYPES_H +#define UTIL_OPT_TYPES_H typedef char byte; typedef char bool; @@ -23,3 +25,5 @@ typedef long offset; #else typedef short offset; #endif + +#endif /* UTIL_OPT_TYPES_H */ \ No newline at end of file diff --git a/util/opt/util.c b/util/opt/util.c index 66b7c7015..41f790b72 100644 --- a/util/opt/util.c +++ b/util/opt/util.c @@ -1,9 +1,12 @@ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif - +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + * Author: Hans van Staveren + */ #include #include +#include #include "param.h" #include "types.h" #include "tes.h" @@ -13,22 +16,17 @@ static char rcsid[] = "$Id$"; #include "optim.h" #include "ext.h" -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Hans van Staveren - */ - - /* VARARGS1 */ -void error(char *s, char *a) +void error(char *s, ...) { + va_list ap; fprintf(stderr,"%s: error on line %u",progname,linecount); if (prodepth != 0) fprintf(stderr,"(%.*s)",IDL,curpro.symbol->s_name); fprintf(stderr,": "); - fprintf(stderr,s,a); + va_start(ap, s); + vfprintf(stderr,s, ap); + va_end(ap); fprintf(stderr,"\n"); #ifndef NDEBUG abort(); @@ -40,7 +38,7 @@ void error(char *s, char *a) void badassertion(char *file, unsigned int line) { fprintf(stderr,"assertion failed file %s, line %u\n",file,line); - error("assertion", NULL); + error("assertion"); } #endif diff --git a/util/opt/util.h b/util/opt/util.h new file mode 100644 index 000000000..6cf63d138 --- /dev/null +++ b/util/opt/util.h @@ -0,0 +1,18 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef UTIL_OPT_UTIL_H +#define UTIL_OPT_UTIL_H + +/* util/opt/util.c */ +void error(char *s, ...); + +#ifndef NDEBUG +void badassertion(char *file, unsigned int line); +#endif + +#ifdef DIAGOPT +void optim(int n); +#endif +#endif /* UTIL_OPT_UTIL_H */ \ No newline at end of file diff --git a/util/opt/var.c b/util/opt/var.c index 58c803f03..3e9e71a91 100644 --- a/util/opt/var.c +++ b/util/opt/var.c @@ -1,7 +1,3 @@ -#ifndef NORCSID -static char rcsid[] = "$Id$"; -#endif - #include #include "param.h" #include "types.h" -- 2.34.1