Next batch of warning hunt...
This commit is contained in:
parent
1ed1edf94d
commit
25c717d9b3
@ -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"
|
||||
|
||||
@ -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, ...)
|
||||
{
|
||||
error(s,a1,a2,a3,a4);
|
||||
exit(1);
|
||||
va_list ap;
|
||||
va_start(ap, s);
|
||||
verror(s, ap);
|
||||
va_end(ap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*VARARGS1*/
|
||||
int fatal(char *s, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, s);
|
||||
verror(s, ap);
|
||||
va_end(ap);
|
||||
exit(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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".
|
||||
*/
|
||||
|
||||
@ -35,6 +35,7 @@ void fatal(char *format, ...)
|
||||
va_start(ap, format);
|
||||
nerrors++;
|
||||
diag("fatal", format, ap);
|
||||
va_end(ap);
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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[])
|
||||
{
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 */
|
||||
@ -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)),\
|
||||
|
||||
11
util/opt/backward.h
Normal file
11
util/opt/backward.h
Normal file
@ -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 */
|
||||
@ -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()
|
||||
{
|
||||
|
||||
11
util/opt/cleanup.h
Normal file
11
util/opt/cleanup.h
Normal file
@ -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 */
|
||||
@ -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()
|
||||
{
|
||||
|
||||
14
util/opt/flow.h
Normal file
14
util/opt/flow.h
Normal file
@ -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 */
|
||||
@ -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;
|
||||
|
||||
28
util/opt/getline.h
Normal file
28
util/opt/getline.h
Normal file
@ -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 */
|
||||
@ -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.
|
||||
|
||||
@ -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 */
|
||||
@ -1,22 +1,24 @@
|
||||
#ifndef NORCSID
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "param.h"
|
||||
#include "types.h"
|
||||
#include "tes.h"
|
||||
#include "alloc.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 <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"
|
||||
|
||||
#include <missing_proto.h>
|
||||
|
||||
/*
|
||||
* Main program for EM optimizer
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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 */
|
||||
@ -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[] */
|
||||
|
||||
25
util/opt/peephole.h
Normal file
25
util/opt/peephole.h
Normal file
@ -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 */
|
||||
@ -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()
|
||||
{
|
||||
|
||||
20
util/opt/process.h
Normal file
20
util/opt/process.h
Normal file
@ -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 */
|
||||
@ -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 */
|
||||
@ -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)
|
||||
|
||||
|
||||
27
util/opt/putline.h
Normal file
27
util/opt/putline.h
Normal file
@ -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 */
|
||||
@ -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.
|
||||
*/
|
||||
|
||||
17
util/opt/reg.h
Normal file
17
util/opt/reg.h
Normal file
@ -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 */
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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 */
|
||||
|
||||
@ -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 */
|
||||
@ -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
|
||||
|
||||
|
||||
18
util/opt/util.h
Normal file
18
util/opt/util.h
Normal file
@ -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 */
|
||||
@ -1,7 +1,3 @@
|
||||
#ifndef NORCSID
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "param.h"
|
||||
#include "types.h"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user