Added lint entry to Makefile and removed some things lint complained about

This commit is contained in:
bruce 1987-07-09 15:04:03 +00:00
parent 65aab404ba
commit e5dd1249b2
9 changed files with 133 additions and 89 deletions

View file

@ -1,50 +1,46 @@
# $Header$
EMHOME = ../../..
INSTALL = $(EMHOME)/modules/install
COMPARE = $(EMHOME)/modules/compare
LIBDIR = $(EMHOME)/modules/lib
BINDIR = $(EMHOME)/lib
LIBOPT = libemopt.a
# libraries required for standalone em_nopt
INK = $(LIBDIR)/libread_emk.a
OUTK = $(LIBDIR)/libemk.a
SYS = $(LIBDIR)/libsystem.a
ALLOC = $(LIBDIR)/liballoc.a $(LIBDIR)/malloc.o
DATA = $(EMHOME)/lib/em_data.a
LIBS = $(INK) $(OUTK) $(ALLOC) $(DATA) $(SYS)
EMHOME = ../../..
INSTALL = $(EMHOME)/modules/install
COMPARE = $(EMHOME)/modules/compare
LINT = lint
BINDIR = $(EMHOME)/lib
LIBOPT = libemopt.a
# set HOWMUCH to head -20 to limit number of patterns used
#HOWMUCH= head -20
HOWMUCH = cat
#HOWMUCH = head -20
HOWMUCH = cat
LEXLIB = -ll
INCLDIR = -I$(EMHOME)/h -I$(EMHOME)/modules/h -I$(EMHOME)/modules/pkg
PREFLAGS= $(INCLDIR) -DPRIVATE=static# -DDEBUG
LEXLIB = -ll
INCLDIR = -I$(EMHOME)/h -I$(EMHOME)/modules/h -I$(EMHOME)/modules/pkg
PREFLAGS = $(INCLDIR) -DPRIVATE=static# -DDEBUG
# Enable the next line to produce a version that output's the line number
# from the patterns file each time an optimization is performed.
#PREFLAGS= $(PREFLAGS) -DSTATS
PROFFLAG= -O
CFLAGS = $(PREFLAGS) $(PROFFLAG)
LLOPT =
CMD = '$(CC) -c $(CFLAGS)'
#PREFLAGS = $(PREFLAGS) -DSTATS
PROFFLAG = -O
CFLAGS = $(PREFLAGS) $(PROFFLAG)
LINTFLAGS = $(PREFLAGS) -DNORCSID
LLOPT =
CMD = '$(CC) -c $(CFLAGS)'
.SUFFIXES: .d .r
.r.d:; CMD=$(CMD); export CMD; awk -f makefuns.awk $*.r | sh
.r.d: ; CMD=$(CMD); export CMD; awk -f makefuns.awk $*.r | sh
touch $@
CSRC = main.c nopt.c mkstrct.c aux.c outputdfa.c outcalls.c\
CSRC = main.c nopt.c mkstrct.c aux.c outputdfa.c outcalls.c\
findworst.c initlex.c
SRCS = Makefile nopt.h parser.h parser.g syntax.l pseudo.r patterns $(CSRC)
SRCS = Makefile nopt.h parser.h parser.g syntax.l pseudo.r\
patterns $(CSRC)
NOFILES = nopt.o dfa.o trans.o aux.o
NOFILES = nopt.o dfa.o trans.o aux.o
POFILES = parser.o syntax.o outputdfa.o outcalls.o findworst.o initlex.o Lpars.o
POFILES = parser.o syntax.o outputdfa.o outcalls.o findworst.o\
initlex.o Lpars.o
GENFILES = Lpars.h Lpars.c parserdummy parser.c syntax.c dfadummy\
GENFILES = Lpars.h Lpars.c parserdummy parser.c syntax.c dfadummy\
dfa.c dfa.c.new trans.h trans.h.new trans.c trans.c.new\
incalls.d incalls.r incalls.r.new pseudo.d
@ -52,10 +48,13 @@ all: em_nopt $(LIBOPT)
install: all
$(INSTALL) lib/$(LIBOPT)
cp em_nopt $(BINDIR)
cp em_nopt $(BINDIR)/em_nopt
lint: lintparser lintnopt
cmp: all
$(COMPARE) lib/$(LIBOPT)
-cmp em_nopt $(BINDIR)/em_nopt
pr:
@pr $(SRCS)
@ -69,10 +68,31 @@ clean:
rm -f $(NOFILES) main.o mkstrct.o $(POFILES)
rm -f $(GENFILES) parser em_nopt $(LIBOPT)
em_nopt: main.o $(NOFILES)
$(CC) -o em_nopt main.o $(NOFILES) $(LIBS)
# How to build stand alone version of the optimizer
$(LIBOPT): $(NOFILES) mkstrct.o pseudo.d incalls.d
NOPTLIB = $(EMHOME)/modules/lib/libread_emk.a\
$(EMHOME)/modules/lib/libemk.a\
$(EMHOME)/modules/lib/liballoc.a\
$(EMHOME)/modules/lib/malloc.o\
$(EMHOME)/modules/lib/libsystem.a\
$(EMHOME)/lib/em_data.a
em_nopt: dfadummy main.o $(NOFILES)
$(CC) -o em_nopt main.o $(NOFILES) $(NOPTLIB)
OLINT = main.c nopt.c aux.c dfa.c trans.c
OLINTLIB = $(EMHOME)/modules/lib/llib-lread_emkV.ln\
$(EMHOME)/modules/lib/llib-lemk.ln\
$(EMHOME)/modules/lib/llib-lsystem.ln\
$(EMHOME)/modules/lib/llib-lalloc.ln
lintnopt: dfadummy $(OLINT)
$(LINT) $(LINTFLAGS) $(OLINT) $(OLINTLIB)
# How to build the library version of the optimizer
$(LIBOPT): dfadummy $(NOFILES) mkstrct.o pseudo.d incalls.d
rm -f $(LIBOPT)
ar rc $(LIBOPT) O_*.o $(NOFILES) mkstrct.o
-sh -c 'ranlib $(LIBOPT)'
@ -85,7 +105,7 @@ dfadummy: patterns parser
# How to build program to parse patterns table and build c files.
PARSERLIB = $(EMHOME)/lib/em_data.a\
PARSERLIB = $(EMHOME)/lib/em_data.a\
$(EMHOME)/modules/lib/liballoc.a\
$(EMHOME)/modules/lib/libstring.a\
$(EMHOME)/modules/lib/libsystem.a
@ -97,15 +117,26 @@ parserdummy: parser.g
LLgen $(LLOPT) parser.g
touch parserdummy
PLINT = parser.c syntax.c outputdfa.c outcalls.c\
findworst.c initlex.c Lpars.c
PLINTLIB = $(EMHOME)/modules/lib/llib-lalloc.ln\
$(EMHOME)/modules/lib/llib-lstring.ln\
$(EMHOME)/modules/lib/llib-lsystem.ln
lintparser: parserdummy $(PLINT)
$(LINT) $(LINTFLAGS) $(PLINT) $(PLINTLIB)
# Dependancies
main.o: nopt.h
nopt.o: nopt.h
mkstrct.o: nopt.h
aux.o: nopt.h
pseudo.d: nopt.h makefuns.awk
dfa.o: nopt.h trans.h dfadummy
trans.o: nopt.h dfadummy
dfa.o: nopt.h trans.h
trans.o: nopt.h
incalls.d: nopt.h makefuns.awk
incalls.r: dfadummy
parser.o: Lpars.h parser.h
Lpars.o: Lpars.h

View file

@ -4,8 +4,9 @@ static char rcsid4[] = "$Header$";
#include "nopt.h"
arith
OO_rotate(w,amount)
int w, amount;
arith w, amount;
{
long highmask, lowmask;
highmask = (long)(-1) << amount;
@ -16,13 +17,13 @@ OO_rotate(w,amount)
}
OO_signsame(a,b)
int a, b;
arith a, b;
{
return( (a ^ b) >= 0);
}
OO_sfit(val,nbits)
int val, nbits;
arith val, nbits;
{
register long mask = 0;
register int i;
@ -32,7 +33,7 @@ OO_sfit(val,nbits)
}
OO_ufit(val, nbits)
int val, nbits;
arith val, nbits;
{
register long mask = 0;
register int i;
@ -59,6 +60,7 @@ OO_extsame(a1,a2)
return (a1->em_dlb == a2->em_dlb);
default:
fatal("illegal type (%d) to sameext!",a1->em_argtype);
/*NOTREACHED*/
}
}
@ -76,9 +78,11 @@ OO_namsame(a1,a2)
return (a1->em_dlb == a2->em_dlb);
default:
fatal("illegal type (%d) to samenam!",a1->em_argtype);
/*NOTREACHED*/
}
}
arith
OO_offset(a)
register p_instr a;
{
@ -91,5 +95,6 @@ OO_offset(a)
return a->em_off;
default:
fatal("illegal type (%d) to offset!",a->em_argtype);
/*NOTREACHED*/
}
}

View file

@ -26,7 +26,7 @@ findworst(repl)
/* requires a backup of n-i+1 instructions and a goto to state 0.
*/
int n = repl.m_len;
int first,i,j;
int first,i;
int s;
int mostbackups = 0;
if(n==0) {
@ -71,7 +71,7 @@ findfail(state,resout,rescpy,resgto)
/* The first such match of the form pi pi+1 ... pn requires an output
/* of p1 p2 ... pi-1 and a push back of pn pn-1 ... pi.
*/
int s,i,j;
int s,i;
struct state *p;
int istrans;
int n = patterns[state].m_len;

View file

@ -80,7 +80,7 @@ main(argc,argv)
exit(errors);
}
/* VARARGS */
/*VARARGS1*/
error(s,a1,a2,a3,a4)
char *s;
{
@ -93,7 +93,7 @@ error(s,a1,a2,a3,a4)
errors++;
}
/* VARARGS */
/*VARARGS1*/
fatal(s,a1,a2,a3,a4)
char *s;
{

View file

@ -31,8 +31,8 @@ static char *nextstr;
static char *laststr;
int OO_noutput; /* number of instructions in output queue */
int OO_WSIZE; /* wordlength */
int OO_PSIZE; /* pointer length */
arith OO_WSIZE; /* wordlength */
arith OO_PSIZE; /* pointer length */
#ifdef STATS
int OO_wrstats = 1; /* pattern statistics output */
@ -199,7 +199,8 @@ OO_outop(opcode)
}
OO_outcst(opcode,cst)
int opcode,cst;
int opcode;
arith cst;
{
register p_instr p = GETINSTR();
p->em_type = EM_MNEM;
@ -210,7 +211,8 @@ OO_outcst(opcode,cst)
}
OO_outlab(opcode,lab)
int opcode,lab;
int opcode;
label lab;
{
register p_instr p = GETINSTR();
p->em_type = EM_MNEM;
@ -247,7 +249,7 @@ OO_outdefilb(opcode,deflb)
OO_outext(opcode,arg,off)
int opcode;
p_instr arg;
int off;
arith off;
{
register p_instr p = GETINSTR();
p->em_type = EM_MNEM;

View file

@ -35,13 +35,15 @@ extern p_instr *OO_nxtbackup;
extern p_instr OO_OTHER;
extern int OO_state;
extern int OO_noutput; /* number of instructions in output queue */
extern int OO_WSIZE; /* wordlength */
extern int OO_PSIZE; /* pointer length */
extern arith OO_WSIZE; /* wordlength */
extern arith OO_PSIZE; /* pointer length */
#ifdef STATS
extern int OO_wrstats; /* statistics output */
#endif
extern char *OO_freestr();
extern arith OO_rotate();
extern arith OO_offset();
#define CST(p) (p->em_cst)
#define PNAM(p) (p->em_pnam)

View file

@ -7,10 +7,8 @@ static char rcsidp4[] = "$Header$";
outputincalls()
{
struct idf *op;
int opcode;
char *s;
for(op=ops;op!=(struct idf *)NULL;op=op->id_nextidf) {
opcode = op->id_opcode;
s = op->id_text;
switch(op->id_argfmt) {
case NOARG:

View file

@ -33,6 +33,7 @@ PRIVATE
openofile(filename)
char *filename;
{
char *strcpy(), *strcat();
strcpy(ofilename,filename);
strcpy(ofiletemp,filename);
strcat(ofiletemp,".new");
@ -210,23 +211,21 @@ PRIVATE
outdotrans()
{
int s;
int i;
struct state *p;
struct action *a;
int firsttest;
int seennontested;
int seentested;
fprintf(ofile,"#include \"nopt.h\"\n\n");
for(s=0;s<=higheststate;s++) {
if(actions[s]!=(struct action *)NULL) {
fprintf(ofile,"\nOO_%ddotrans() {\n",s);
fprintf(ofile,"\tregister p_instr *patt = OO_patternqueue;\n");
fprintf(ofile,"\t/* ");
outmnems(patterns[s]);
fprintf(ofile," */\n");
fprintf(ofile,"\tregister p_instr *patt = OO_patternqueue;\n");
seennontested=0;
firsttest=1;
seentested = seennontested=0;
for(a=actions[s];a!=(struct action *)NULL;a=a->next) {
if(a->test!=(struct exp_node *)NULL) {
seentested++;
fprintf(ofile,"\tif(");
outexp(a->test,s);
fprintf(ofile,") {\n");
@ -246,7 +245,8 @@ outdotrans()
fprintf(ofile,"\tOO_state=%d;\n",s);
fprintf(ofile,"\treturn;\n");
}
fprintf(ofile,"free:\tOO_nfree(%d);\n",patterns[s].m_len);
if(seentested) fprintf(ofile,"free:");
fprintf(ofile,"\tOO_nfree(%d);\n",patterns[s].m_len);
fprintf(ofile,"}\n");
}
/*
@ -278,21 +278,20 @@ outoneaction(s,a)
fprintf(ofile,"#ifdef STATS\n");
fprintf(ofile,"\t\tif(OO_wrstats) fprintf(stderr,\"%d\\n\");\n",a->linenum);
fprintf(ofile,"#endif\n");
outrepl(s,patterns[s],a->replacement);
outrepl(s,a->replacement);
findworst(a->replacement);
}
PRIVATE
outrepl(state,patt,repl)
outrepl(state,repl)
int state;
struct mnems patt,repl;
struct mnems repl;
{
/*
/* Contruct <repl>=r1 r2 ... rn and put on output queue.
*/
int n = repl.m_len;
int m = patt.m_len;
int i,j,count;
int i;
for(i=1;i<=n;i++) {
struct mnem_elem *ri = repl.m_elems[i-1];
char *mnem = ri->op_code->id_text;
@ -303,6 +302,7 @@ outrepl(state,patt,repl)
case CST:
case CSTOPT:
fprintf(ofile,"\t\tOO_outcst(op_%s,",mnem);
fprintf(ofile,"(arith)");
outexp(ri->arg,state);
fprintf(ofile,");\n");
break;
@ -377,15 +377,19 @@ outexp(e,state)
break;
case COMMA:
outext(e->exp_left);
fprintf(ofile,","); outexp(e->exp_right,state);
fprintf(ofile,",");
fprintf(ofile,"(arith)");
outexp(e->exp_right,state);
break;
case SAMESIGN:
case SFIT:
case UFIT:
case ROTATE:
outop(e->node_type);
fprintf(ofile,"(arith)");
outexp(e->exp_left,state);
fprintf(ofile,",");
fprintf(ofile,"(arith)");
outexp(e->exp_right,state);
fprintf(ofile,")");
break;
@ -394,7 +398,7 @@ outexp(e,state)
outop(e->node_type);
outext(e->exp_left);
fprintf(ofile,",");
outext(e->exp_right,state);
outext(e->exp_right);
fprintf(ofile,")");
break;
case PATARG:

View file

@ -65,25 +65,26 @@ optimization
;
patterns(struct exp_node **tests;)
{ struct mnem_list *list;
struct exp_node *pair1, *pair2;
struct exp_node *onetest; int argtype; }
{
struct mnem_list *list;
struct exp_node *onetest;
}
:
{
list = (struct mnem_list *)NULL;
*tests = (struct exp_node *)NULL;
}
{
list = (struct mnem_list *)NULL;
*tests = (struct exp_node *)NULL;
}
[
OPCODE
{
if(++lencurrpatt>longestpattern)
longestpattern=lencurrpatt;
list = addelem(list,opval, (struct exp_node *)NULL);
opval->id_used=1;
if(lencurrpatt==1)
opval->id_startpatt=1;
currentstate=dotransition(currentstate,opval,list,lencurrpatt);
}
{
if(++lencurrpatt>longestpattern)
longestpattern=lencurrpatt;
list = addelem(list,opval, (struct exp_node *)NULL);
opval->id_used=1;
if(lencurrpatt==1)
opval->id_startpatt=1;
currentstate=dotransition(currentstate,opval,list,lencurrpatt);
}
[
restriction(opval->id_argfmt,&onetest)
{
@ -202,7 +203,7 @@ action(struct mnem_list **list;)
exp(int level; struct exp_node **result;)
{ struct exp_node *res1, *res2;
int operator, intval; }
int operator; }
:
%if(level <= MAXPRIO)
exp(MAXPRIO+1,&res1)
@ -331,8 +332,8 @@ addaction(startline, state, restrictions, finaltest, repllist)
p->replacement.m_len = lenthisrepl;
p->replacement.m_elems = constructlist(repllist,lenthisrepl);
/* chain new action to END of action chain */
if((q = actions[currentstate])==(struct action *)NULL)
actions[currentstate] = p;
if((q = actions[state])==(struct action *)NULL)
actions[state] = p;
else {
while(q->next != (struct action *)NULL)
q = q->next;
@ -346,7 +347,6 @@ constructlist(list,len)
int len;
{
struct mnem_elem **p;
int i;
p = (struct mnem_elem **)Malloc(len*sizeof(struct mnem_elem *));
while(len--) {
p[len] = list->elem;
@ -443,6 +443,8 @@ priority(op) int op; {
case UPLUS:
case UMINUS: return(11);
}
fprintf(stderr,"Internal error: priority: - unrecognized operator\n");
return(0);
}
struct exp_node *