Next batch of warning hunt...
authorManoel Trapier <godzil@godzil.net>
Tue, 19 Mar 2013 16:37:24 +0000 (17:37 +0100)
committerManoël Trapier <godzil@MacBook-Pro.home>
Wed, 24 Jun 2015 22:41:47 +0000 (23:41 +0100)
38 files changed:
modules/h/em_code.h
modules/src/em_code/convert.c
modules/src/em_opt/main.c
modules/src/flt_arith/flt_ar2flt.c
util/led/error.c
util/misc/convert.c
util/misc/esize.c
util/opt/alloc.c
util/opt/alloc.h
util/opt/backward.c
util/opt/backward.h [new file with mode: 0644]
util/opt/cleanup.c
util/opt/cleanup.h [new file with mode: 0644]
util/opt/flow.c
util/opt/flow.h [new file with mode: 0644]
util/opt/getline.c
util/opt/getline.h [new file with mode: 0644]
util/opt/lookup.c
util/opt/lookup.h
util/opt/main.c
util/opt/mktab.y
util/opt/pattern.h
util/opt/peephole.c
util/opt/peephole.h [new file with mode: 0644]
util/opt/process.c
util/opt/process.h [new file with mode: 0644]
util/opt/proinf.h
util/opt/putline.c
util/opt/putline.h [new file with mode: 0644]
util/opt/reg.c
util/opt/reg.h [new file with mode: 0644]
util/opt/scan.l
util/opt/tes.c
util/opt/tes.h
util/opt/types.h
util/opt/util.c
util/opt/util.h [new file with mode: 0644]
util/opt/var.c

index 04a5150..a4861fa 100644 (file)
@@ -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"
index 0e24c82..65bdcc9 100644 (file)
@@ -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;
 }
index 0ac5a16..954a11b 100644 (file)
@@ -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       <stdarg.h>
 #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;
 }
index f1d159a..381b819 100644 (file)
@@ -8,10 +8,7 @@
 #include "flt_misc.h"
 #include <em_arith.h>
 
-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".
        */
index f8df0d1..d89cc89 100644 (file)
@@ -35,6 +35,7 @@ void fatal(char *format, ...)
        va_start(ap, format);
        nerrors++;
        diag("fatal", format, ap);
+       va_end(ap);
        stop();
 }
 
index 16b661c..84d5e3b 100644 (file)
@@ -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       <stdarg.h>
 #endif
@@ -23,18 +19,22 @@ static char rcsid[] = "$Id$";
 #include <stdio.h>
 #include <stdlib.h>
 #include "system.h"
+#include <em_arith.h>
+#include <em_label.h>
 #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 <em_code.h>
 
 #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);
index 1644663..3fe1096 100644 (file)
@@ -4,6 +4,8 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#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[])
 {
index d4a31b1..2090bfb 100644 (file)
@@ -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 <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -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
index d193cd3..c421d15 100644 (file)
@@ -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
index 86f21f3..08e3682 100644 (file)
@@ -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 <em_mnem.h>
 #include <em_mes.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 "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 (file)
index 0000000..8bfdb5c
--- /dev/null
@@ -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
index 80f9a09..f5159d9 100644 (file)
@@ -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 <stdio.h>
+#include <unistd.h>
 #include "param.h"
 #include "types.h"
 #include "assert.h"
@@ -11,14 +14,8 @@ static char rcsid[] = "$Id$";
 #include <em_mes.h>
 #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 (file)
index 0000000..35f736a
--- /dev/null
@@ -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
index 69a47bc..fc9b179 100644 (file)
@@ -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 (file)
index 0000000..1ca8e13
--- /dev/null
@@ -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
index 036f0e7..76b52dc 100644 (file)
@@ -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 <stdlib.h>
 #include <stdio.h>
 #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 <em_spec.h>
 #include <em_pseu.h>
 #include <em_flag.h>
 #include <em_mes.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
- */
-
-
 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 (file)
index 0000000..64b3cb0
--- /dev/null
@@ -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
index 8cda8e5..59bfe89 100644 (file)
@@ -1,7 +1,3 @@
-#ifndef NORCSID
-static char rcsid[] = "$Id$";
-#endif
-
 #include <stdlib.h>
 #include <string.h>
 #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.
index f243dc4..fdaef3e 100644 (file)
@@ -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
index 94335f9..226f72e 100644 (file)
@@ -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 <stdlib.h>
 #include <stdio.h>
 #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 <em_spec.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 <missing_proto.h>
 
 /*
  * Main program for EM optimizer
index e8fff04..717ad77 100644 (file)
@@ -1,8 +1,4 @@
 %{
-#ifndef NORCSID
-static char rcsid[] = "$Id$";
-#endif
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -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;p<lastnode;p++)
-               printf("/* %3ld */\t%3d,%6u,%6u,\n",
+               printf("/* %3ld */\t { %3d,%6u,%6u },\n",
                        (long)(p-nodes),p->ex_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()
index 2cf7d87..cc04718 100644 (file)
@@ -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
index 96972b8..ac580cc 100644 (file)
@@ -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 <stdio.h>
 #include "param.h"
 #include "types.h"
 #include "tes.h"
@@ -15,20 +18,9 @@ static char rcsid[] = "$Id$";
 #include <em_mnem.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
- */
-
-#undef CHK_HASH        /* print numbers patterns are hashed to */
-#ifdef CHK_HASH
-#include <stdio.h>
-#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 (file)
index 0000000..c4e80ec
--- /dev/null
@@ -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
index 9757259..6ed148d 100644 (file)
@@ -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 (file)
index 0000000..eb56006
--- /dev/null
@@ -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
index 940257d..ea14d26 100644 (file)
@@ -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
index a7aa175..b2b9915 100644 (file)
@@ -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 <stdlib.h>
 
 #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 (file)
index 0000000..942b10a
--- /dev/null
@@ -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
index dbbeee3..b418c29 100644 (file)
@@ -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 <em_pseu.h>
 #include <em_mes.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 "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 (file)
index 0000000..7446be4
--- /dev/null
@@ -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
index 85d4aee..799d92f 100644 (file)
@@ -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);
index 04db39c..70b2b59 100644 (file)
@@ -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 <stdio.h>
 #include <em_spec.h>
 #include <em_mnem.h>
@@ -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)
index 7705121..829401c 100644 (file)
@@ -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 */
index c9ff182..75ccd44 100644 (file)
@@ -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
index 66b7c70..41f790b 100644 (file)
@@ -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 <stdlib.h>
 #include <stdio.h>
+#include <stdarg.h>
 #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 (file)
index 0000000..6cf63d1
--- /dev/null
@@ -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
index 58c803f..3e9e71a 100644 (file)
@@ -1,7 +1,3 @@
-#ifndef NORCSID
-static char rcsid[] = "$Id$";
-#endif
-
 #include <stdio.h>
 #include "param.h"
 #include "types.h"