Ported code to Mantra and general clean up.

This commit is contained in:
bruce 1987-01-27 14:15:23 +00:00
parent bbd5b115dd
commit 6fb688f882
5 changed files with 85 additions and 168 deletions

View file

@ -9,11 +9,11 @@ CSRC = nopt.c aux.c mkcalls.c pseudo.c outputdfa.c outcalls.c\
SRCS = Makefile nopt.h parser.h parser.g syntax.l patterns $(CSRC) SRCS = Makefile nopt.h parser.h parser.g syntax.l patterns $(CSRC)
NOFILES=nopt.o dfa.o trans.o incalls.o pseudo.o aux.o mkcalls.o NOFILES = nopt.o dfa.o trans.o incalls.o pseudo.o aux.o mkcalls.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.save trans.c trans.c.save incalls.c incalls.c.save dfa.c dfa.c.save trans.c trans.c.save incalls.c incalls.c.save
all: $(LIBOPT) all: $(LIBOPT)
@ -34,15 +34,18 @@ clean:
rm -f $(NOFILES) $(POFILES) $(GENFILES) parser core makerror rm -f $(NOFILES) $(POFILES) $(GENFILES) parser core makerror
# set HOWMUCH to head -20 to limit number of patterns used # set HOWMUCH to head -20 to limit number of patterns used
#HOWMUCH=head -20 #HOWMUCH = head -20
HOWMUCH=cat HOWMUCH = cat
LEXLIB=-ll LEXLIB = -ll
INCLDIR=-I$(EMHOME)/h -I$(EMHOME)/modules/h -I$(EMHOME)/modules/pkg INCLDIR = -I$(EMHOME)/h -I$(EMHOME)/modules/h -I$(EMHOME)/modules/pkg
PREFLAGS=$(INCLDIR) -DPRIVATE=static PREFLAGS = $(INCLDIR) -DPRIVATE=static
PROFFLAG=-O # Enable the next line to produce a version that output's the line number
CFLAGS=$(PREFLAGS) $(PROFFLAG) # from the patterns file each time an optimization is performed.
LLOPT= #PREFLAGS = $(PREFLAGS) -DSTATS
PROFFLAG = -O
CFLAGS = $(PREFLAGS) $(PROFFLAG)
LLOPT =
$(LIBOPT): dfadummy $(NOFILES) $(LIBOPT): dfadummy $(NOFILES)
rm -f $(LIBOPT) rm -f $(LIBOPT)
@ -63,7 +66,7 @@ dfadummy: patterns parser
# How to build program to parse patterns table and build c files. # 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/libprint.a\ $(EMHOME)/modules/lib/libprint.a\
$(EMHOME)/modules/lib/liballoc.a\ $(EMHOME)/modules/lib/liballoc.a\
$(EMHOME)/modules/lib/libstring.a\ $(EMHOME)/modules/lib/libstring.a\

View file

@ -12,7 +12,7 @@ OO_rotate(w,amount)
return(((w<<amount)&highmask) | ((w >> (8*OO_WSIZE-amount))&lowmask)); return(((w<<amount)&highmask) | ((w >> (8*OO_WSIZE-amount))&lowmask));
} }
OO_samesign(a,b) OO_signsame(a,b)
int a, b; int a, b;
{ {
return( (a ^ b) >= 0); return( (a ^ b) >= 0);
@ -38,7 +38,7 @@ OO_ufit(val, nbits)
return((val&mask) == 0); return((val&mask) == 0);
} }
OO_sameext(a1,a2) OO_extsame(a1,a2)
struct instr *a1, *a2; struct instr *a1, *a2;
{ {
if(a1->argtype != a2->argtype) return(0); if(a1->argtype != a2->argtype) return(0);
@ -56,7 +56,7 @@ OO_sameext(a1,a2)
} }
} }
OO_samenam(a1,a2) OO_namsame(a1,a2)
struct instr *a1, *a2; struct instr *a1, *a2;
{ {
if(a1->argtype != a2->argtype) return(0); if(a1->argtype != a2->argtype) return(0);

View file

@ -3,7 +3,7 @@ static char rcsid[] = "$Header$";
#endif #endif
#include "nopt.h" #include "nopt.h"
#define MAXPATTERN 15 extern int maxpattern; /* Initialized from patterns in dfa.c */
#define MAXBACKUP 50 #define MAXBACKUP 50
#define MAXOUTPUT 200 #define MAXOUTPUT 200
#define MAXFREEI 200 #define MAXFREEI 200
@ -36,21 +36,7 @@ int OO_WSIZE; /* wordlength */
int OO_PSIZE; /* pointer length */ int OO_PSIZE; /* pointer length */
#ifdef STATS #ifdef STATS
int sflag = 1; /* pattern statistics output */ int OO_wrstats = 1; /* pattern statistics output */
#endif
#ifdef COLLECT
int cflag = 0; /* internal statistics output */
#define UPDATEMAX(oldmax,n) if(cflag&&n>oldmax) oldmax=n
static int numwrites = 0;
static int numpushs = 0;
static int numbackups = 0;
static int numflushes = 0;
static int numfrees = 0;
static int numdefaults = 0;
static int highestbackup = 0, totalbackup = 0;
static int highestoutput = 0, totaloutput = 0;
static int highestfreei = 0, totalfreei = 0;
static int higheststr = 0, totalstr = 0;
#endif #endif
C_init(wsize,psize) C_init(wsize,psize)
@ -76,10 +62,6 @@ C_magic()
C_close() C_close()
{ {
#ifdef COLLECT
if(cflag)
outputstats();
#endif
O_close(); O_close();
} }
@ -99,7 +81,7 @@ allocmem()
{ {
/* Allocate memory for queues on heap */ /* Allocate memory for queues on heap */
OO_nxtpatt = OO_patternqueue = OO_nxtpatt = OO_patternqueue =
(struct instr **)Malloc(MAXPATTERN*sizeof(struct instr *)); (struct instr **)Malloc(maxpattern*sizeof(struct instr *));
OO_nxtbackup = OO_bkupqueue = OO_nxtbackup = OO_bkupqueue =
(struct instr **)Malloc(MAXBACKUP*sizeof(struct instr *)); (struct instr **)Malloc(MAXBACKUP*sizeof(struct instr *));
lastbackup = OO_bkupqueue + MAXBACKUP - 1; lastbackup = OO_bkupqueue + MAXBACKUP - 1;
@ -115,58 +97,20 @@ allocmem()
laststr = strqueue + MAXSTRING - 1; laststr = strqueue + MAXSTRING - 1;
} }
#ifdef COLLECT
PRIVATE
outputstats()
{
int i;
fprint(STDERR,"Total of %d instructions read, %d written\n",numreads,numwrites);
fprint(STDERR,"Total of %d calls to flush\n",numflushes);
fprint(STDERR,"Total of %d calls to myfree\n",numfrees);
fprint(STDERR,"Total of %d instructions pushed back\n",numpushs-numbackups);
fprint(STDERR,"Total of %d instructions backed up\n",numbackups);
fprint(STDERR,"Total of %d calls to dodefault\n",numdefaults);
fprint(STDERR,"Max of highestbackup\t%d\t(%d)\t",highestbackup,MAXBACKUP);
printav(totalbackup);
fprint(STDERR,"Max of highestoutput\t%d\t(%d)\t",highestoutput,MAXOUTPUT);
printav(totaloutput);
fprint(STDERR,"Max of highestfreei\t%d\t(%d)\t",highestfreei,MAXFREEI);
printav(totalfreei);
fprint(STDERR,"Max of higheststr\t%d\t(%d)\t",higheststr,MAXSTRING);
printav(totalstr);
}
PRIVATE
printav(n)
int n;
{
fprint(STDERR,"Av.\t%d.%d\n",n/numflushes,(n*10)%numflushes);
}
#endif
OO_free(p) OO_free(p)
struct instr *p; struct instr *p;
{ {
#ifdef DEBUG
fprint(STDERR,"about to free ");
prtinst(p);
fprint(STDERR,"\n");
#endif
#ifdef COLLECT
if(cflag)
numfrees++;
#endif
if(nextifree > lastifree) { if(nextifree > lastifree) {
#ifdef DEBUG #ifdef DEBUG
fprint(STDERR,"Warning: Overflow of freeiqueue-free arg ignored\n"); fprint(STDERR,"Warning: Overflow of free intr. queue.\n");
fprint(STDERR,"Ignored free of ");
prtinst(p);
fprint(STDERR,"\n");
printstate("Freea overflow"); printstate("Freea overflow");
#endif #endif
return; return;
} }
*nextifree++ = p; *nextifree++ = p;
#ifdef COLLECT
UPDATEMAX(highestfreei,nextifree-freeiqueue);
#endif
} }
PRIVATE char * PRIVATE char *
@ -179,9 +123,6 @@ freestr(s)
fprint(STDERR,"string space overflowed!\n"); fprint(STDERR,"string space overflowed!\n");
sys_stop(S_EXIT); sys_stop(S_EXIT);
} }
#ifdef COLLECT
UPDATEMAX(higheststr,nextstr-strqueue);
#endif
return(res); return(res);
} }
@ -194,22 +135,9 @@ OO_flush()
struct instr **p; struct instr **p;
#ifdef DEBUG #ifdef DEBUG
printstate("Flush"); printstate("Flush");
#endif
#ifdef COLLECT
if(cflag) {
numflushes++;
totaloutput += nextoutput-outputqueue;
totalbackup += OO_nxtbackup-OO_bkupqueue;
totalfreei += nextifree-freeiqueue;
totalstr += nextstr-strqueue;
}
#endif #endif
if(OO_noutput) { if(OO_noutput) {
for(p=outputqueue;p<nextoutput;p++) { for(p=outputqueue;p<nextoutput;p++) {
#ifdef COLLECT
if(cflag)
numwrites++;
#endif
OO_mkcalls(*p); OO_mkcalls(*p);
OO_free(*p); OO_free(*p);
} }
@ -226,7 +154,7 @@ OO_outop(opcode)
register struct instr *p = GETINSTR(); register struct instr *p = GETINSTR();
p->opcode = opcode; p->opcode = opcode;
p->argtype = none_ptyp; p->argtype = none_ptyp;
OO_output(p); OO_out(p);
} }
OO_inop(opcode) OO_inop(opcode)
@ -245,7 +173,7 @@ OO_outcst(opcode,cst)
p->opcode = opcode; p->opcode = opcode;
p->argtype = cst_ptyp; p->argtype = cst_ptyp;
p->acst = cst; p->acst = cst;
OO_output(p); OO_out(p);
} }
OO_incst(opcode,cst) OO_incst(opcode,cst)
@ -265,7 +193,7 @@ OO_outlab(opcode,lab)
p->opcode = opcode; p->opcode = opcode;
p->argtype = cst_ptyp; p->argtype = cst_ptyp;
p->acst = lab; p->acst = lab;
OO_output(p); OO_out(p);
} }
OO_inlab(opcode,lab) OO_inlab(opcode,lab)
@ -286,7 +214,7 @@ OO_outpnam(opcode,pnam)
p->opcode = opcode; p->opcode = opcode;
p->argtype = pro_ptyp; p->argtype = pro_ptyp;
p->apnam = pnam; p->apnam = pnam;
OO_output(p); OO_out(p);
} }
OO_inpnam(opcode,pnam) OO_inpnam(opcode,pnam)
@ -308,7 +236,7 @@ OO_outdefilb(opcode,deflb)
p->opcode = opcode; p->opcode = opcode;
p->argtype = lab_ptyp; p->argtype = lab_ptyp;
p->alab = deflb; p->alab = deflb;
OO_output(p); OO_out(p);
} }
OO_indefilb(opcode,deflb) OO_indefilb(opcode,deflb)
@ -344,7 +272,7 @@ OO_outext(opcode,arg,soff)
default: default:
fatal("Unexpected type %d in outext",arg->argtype); fatal("Unexpected type %d in outext",arg->argtype);
} }
OO_output(p); OO_out(p);
} }
OO_indnam(opcode,name,off) OO_indnam(opcode,name,off)
@ -373,22 +301,18 @@ OO_indlb(opcode,lab,off)
*OO_nxtpatt++ = p; *OO_nxtpatt++ = p;
} }
OO_output(p) OO_out(p)
struct instr *p; struct instr *p;
{ {
/* Put the instruction p on the output queue */ /* Put the instruction p on the output queue */
if(nextoutput > lastoutput) { if(nextoutput > lastoutput) {
#ifdef DEBUG #ifdef DEBUG
fprint(STDERR,"Overflow of outputqueue - output flushed\n"); fprint(STDERR,"Warning: Overflow of outputqueue - output flushed\n");
printstate("Output overflow");
#endif #endif
OO_flush(); OO_flush();
} }
OO_noutput++; OO_noutput++;
*nextoutput++ = p; *nextoutput++ = p;
#ifdef COLLECT
UPDATEMAX(highestoutput,nextoutput-outputqueue);
#endif
} }
OO_pushback(p) OO_pushback(p)
@ -403,10 +327,6 @@ OO_pushback(p)
return; return;
} }
*OO_nxtbackup++ = p; *OO_nxtbackup++ = p;
#ifdef COLLECT
UPDATEMAX(highestbackup,OO_nxtbackup-OO_bkupqueue);
numpushs++;
#endif
} }
OO_backup(n) OO_backup(n)
@ -414,10 +334,6 @@ OO_backup(n)
{ {
/* copy (up to) n instructions from output to backup queues */ /* copy (up to) n instructions from output to backup queues */
while(n-- && nextoutput>outputqueue) { while(n-- && nextoutput>outputqueue) {
#ifdef COLLECT
if(cflag)
numbackups++;
#endif
OO_pushback(*(--nextoutput)); OO_pushback(*(--nextoutput));
OO_noutput--; OO_noutput--;
} }
@ -431,16 +347,12 @@ OO_dodefault(numout, numcopy)
while(numcopy--) { while(numcopy--) {
if(numout) { if(numout) {
numout--; numout--;
OO_output(*p); OO_out(*p);
} }
*p++ = *q++; *p++ = *q++;
} }
OO_nxtpatt = p; OO_nxtpatt = p;
while(numout--) OO_output(*p++); while(numout--) OO_out(*p++);
#ifdef COLLECT
if(cflag)
numdefaults++;
#endif
} }
#ifdef DEBUG #ifdef DEBUG

View file

@ -59,11 +59,8 @@ extern int OO_state;
extern int OO_noutput; /* number of instructions in output queue */ extern int OO_noutput; /* number of instructions in output queue */
extern int OO_WSIZE; /* wordlength */ extern int OO_WSIZE; /* wordlength */
extern int OO_PSIZE; /* pointer length */ extern int OO_PSIZE; /* pointer length */
#ifdef DEBUG
extern int dflag; /* debugging output */
#endif
#ifdef STATS #ifdef STATS
extern int sflag; /* statistics output */ extern int OO_wrstats; /* statistics output */
#endif #endif
#define CST(p) (p->acst) #define CST(p) (p->acst)

View file

@ -13,23 +13,25 @@ outputnopt()
fprint(STDERR,"Couldn't open dfa.c for output\n"); fprint(STDERR,"Couldn't open dfa.c for output\n");
sys_stop(S_EXIT); sys_stop(S_EXIT);
} }
outputheaders(); outheaders();
outputtables(); outtables();
outputdfa(); outdfa();
outputdodefault(); outdodefault();
outputdotrans(); outdotrans();
outputincalls(); outputincalls();
} }
PRIVATE PRIVATE
outputheaders() outheaders()
{ {
fprint(ofile,"#include \"nopt.h\"\n"); fprint(ofile,"#include \"nopt.h\"\n");
fprint(ofile,"\n"); fprint(ofile,"\n");
fprint(ofile,"int maxpattern = %d;\n", longestpattern);
fprint(ofile,"\n");
} }
PRIVATE PRIVATE
outputtables() outtables()
{ {
int s; int s;
fprint(ofile,"static struct defact {\n"); fprint(ofile,"static struct defact {\n");
@ -47,7 +49,7 @@ outputtables()
} }
PRIVATE PRIVATE
outputdfa() outdfa()
{ {
int s; int s;
struct idf *op; struct idf *op;
@ -64,7 +66,7 @@ outputdfa()
fprint(ofile,"\t\t\tswitch(OO_state) {\n"); fprint(ofile,"\t\t\tswitch(OO_state) {\n");
if(!op->id_startpatt) { if(!op->id_startpatt) {
fprint(ofile,"\t\t\tcase 0: "); fprint(ofile,"\t\t\tcase 0: ");
fprint(ofile,"OO_output(*--OO_nxtpatt); "); fprint(ofile,"OO_out(*--OO_nxtpatt); ");
fprint(ofile,"break;\n"); fprint(ofile,"break;\n");
} }
for(s=0;s<=higheststate;s++) for(s=0;s<=higheststate;s++)
@ -77,12 +79,12 @@ outputdfa()
fprint(ofile,"break;\n"); fprint(ofile,"break;\n");
} }
} }
fprint(ofile,"\t\t\tdefault: defaultaction(); break;\n"); fprint(ofile,"\t\t\tdefault: dodefaultaction(); break;\n");
fprint(ofile,"\t\t\t}\n"); fprint(ofile,"\t\t\t}\n");
fprint(ofile,"\t\t\tbreak;\n"); fprint(ofile,"\t\t\tbreak;\n");
} }
fprint(ofile,"\t\tdefault:\n"); fprint(ofile,"\t\tdefault:\n");
fprint(ofile,"\t\t\tif(OO_state) defaultaction();\n"); fprint(ofile,"\t\t\tif(OO_state) dodefaultaction();\n");
fprint(ofile,"\t\t\telse {\n"); fprint(ofile,"\t\t\telse {\n");
fprint(ofile,"\t\t\t\tOO_flush();\n"); fprint(ofile,"\t\t\t\tOO_flush();\n");
fprint(ofile,"\t\t\t\tOO_mkcalls(*--OO_nxtpatt);\n"); fprint(ofile,"\t\t\t\tOO_mkcalls(*--OO_nxtpatt);\n");
@ -90,7 +92,7 @@ outputdfa()
fprint(ofile,"\t\t\t}\n"); fprint(ofile,"\t\t\t}\n");
fprint(ofile,"\t\t\tbreak;\n"); fprint(ofile,"\t\t\tbreak;\n");
fprint(ofile,"\t\tcase OTHER:\n"); fprint(ofile,"\t\tcase OTHER:\n");
fprint(ofile,"\t\t\tif(OO_state) defaultaction();\n"); fprint(ofile,"\t\t\tif(OO_state) dodefaultaction();\n");
fprint(ofile,"\t\t\telse {\n"); fprint(ofile,"\t\t\telse {\n");
fprint(ofile,"\t\t\t\tOO_flush();\n"); fprint(ofile,"\t\t\t\tOO_flush();\n");
fprint(ofile,"\t\t\t\tOO_free(*--OO_nxtpatt);\n"); fprint(ofile,"\t\t\t\tOO_free(*--OO_nxtpatt);\n");
@ -103,7 +105,7 @@ outputdfa()
} }
PRIVATE PRIVATE
outputmnems(l) outmnems(l)
struct mnems l; struct mnems l;
{ {
int i; int i;
@ -112,7 +114,7 @@ outputmnems(l)
} }
PRIVATE PRIVATE
outputdotrans() outdotrans()
{ {
int s; int s;
int i; int i;
@ -131,15 +133,15 @@ outputdotrans()
for(s=0;s<=higheststate;s++) for(s=0;s<=higheststate;s++)
if(actions[s]!=(struct action *)NULL) { if(actions[s]!=(struct action *)NULL) {
fprint(ofile,"\tcase %d: /*",s); fprint(ofile,"\tcase %d: /*",s);
outputmnems(patterns[s]); outmnems(patterns[s]);
fprint(ofile," */\n"); fprint(ofile," */\n");
seennontested=0; seennontested=0;
for(a=actions[s];a!=(struct action *)NULL;a=a->next) { for(a=actions[s];a!=(struct action *)NULL;a=a->next) {
if(a->test!=(struct exp_node *)NULL) { if(a->test!=(struct exp_node *)NULL) {
fprint(ofile,"\t\tif("); fprint(ofile,"\t\tif(");
outputexp(a->test,s); outexp(a->test,s);
fprint(ofile,") {\n"); fprint(ofile,") {\n");
outputoneaction(s,a); outoneaction(s,a);
fprint(ofile,"\t\t\tgoto free%d;\n",patterns[s].m_len); fprint(ofile,"\t\t\tgoto free%d;\n",patterns[s].m_len);
fprint(ofile,"\t\t}\n"); fprint(ofile,"\t\t}\n");
} }
@ -149,7 +151,7 @@ outputdotrans()
nerrors++; nerrors++;
} }
seennontested++; seennontested++;
outputoneaction(s,a); outoneaction(s,a);
fprint(ofile,"\t\t\tgoto free%d;\n",patterns[s].m_len); fprint(ofile,"\t\t\tgoto free%d;\n",patterns[s].m_len);
} }
} }
@ -166,9 +168,9 @@ outputdotrans()
} }
PRIVATE PRIVATE
outputdodefault() outdodefault()
{ {
fprint(ofile,"\nstatic defaultaction() {\n"); fprint(ofile,"\nstatic dodefaultaction() {\n");
fprint(ofile,"\tregister struct defact *p = &defaultactions[OO_state];\n"); fprint(ofile,"\tregister struct defact *p = &defaultactions[OO_state];\n");
fprint(ofile,"\tOO_pushback(*--OO_nxtpatt);\n"); fprint(ofile,"\tOO_pushback(*--OO_nxtpatt);\n");
fprint(ofile,"\tOO_dodefault(p->numoutput,p->numcopy);\n"); fprint(ofile,"\tOO_dodefault(p->numoutput,p->numcopy);\n");
@ -177,20 +179,23 @@ outputdodefault()
} }
PRIVATE PRIVATE
outputoneaction(s,a) outoneaction(s,a)
int s; int s;
struct action *a; struct action *a;
{ {
fprint(ofile,"\t\t/* "); fprint(ofile,"\t\t/* ");
fprint(ofile," -> "); fprint(ofile," -> ");
outputmnems(a->replacement); outmnems(a->replacement);
fprint(ofile," */\n"); fprint(ofile," */\n");
outputrepl(s,patterns[s],a->replacement); fprint(ofile,"#ifdef STATS\n");
fprint(ofile,"\t\t\tif(OO_wrstats) fprint(STDERR,\"%d\\n\");\n",a->linenum);
fprint(ofile,"#endif\n");
outrepl(s,patterns[s],a->replacement);
findworst(a->replacement); findworst(a->replacement);
} }
PRIVATE PRIVATE
outputrepl(state,patt,repl) outrepl(state,patt,repl)
int state; int state;
struct mnems patt,repl; struct mnems patt,repl;
{ {
@ -210,27 +215,27 @@ outputrepl(state,patt,repl)
case CST: case CST:
case CSTOPT: case CSTOPT:
fprint(ofile,"\t\t\tOO_outcst(op_%s,",mnem); fprint(ofile,"\t\t\tOO_outcst(op_%s,",mnem);
outputexp(ri->arg,state); outexp(ri->arg,state);
fprint(ofile,");\n"); fprint(ofile,");\n");
break; break;
case LAB: case LAB:
fprint(ofile,"\t\t\tOO_outlab(op_%s,",mnem); fprint(ofile,"\t\t\tOO_outlab(op_%s,",mnem);
outputexp(ri->arg,state); outexp(ri->arg,state);
fprint(ofile,");\n"); fprint(ofile,");\n");
break; break;
case DEFILB: case DEFILB:
fprint(ofile,"\t\t\tOO_outdefilb(op_%s,",mnem); fprint(ofile,"\t\t\tOO_outdefilb(op_%s,",mnem);
outputexp(ri->arg,state); outexp(ri->arg,state);
fprint(ofile,");\n"); fprint(ofile,");\n");
break; break;
case PNAM: case PNAM:
fprint(ofile,"\t\t\tOO_outpnam(op_%s,",mnem); fprint(ofile,"\t\t\tOO_outpnam(op_%s,",mnem);
outputexp(ri->arg,state); outexp(ri->arg,state);
fprint(ofile,");\n"); fprint(ofile,");\n");
break; break;
case EXT: case EXT:
fprint(ofile,"\t\t\tOO_outext(op_%s,",mnem); fprint(ofile,"\t\t\tOO_outext(op_%s,",mnem);
outputexp(ri->arg,state); outexp(ri->arg,state);
fprint(ofile,");\n"); fprint(ofile,");\n");
break; break;
} }
@ -238,7 +243,7 @@ outputrepl(state,patt,repl)
} }
PRIVATE PRIVATE
outputexp(e,state) outexp(e,state)
struct exp_node *e; struct exp_node *e;
int state; int state;
{ {
@ -262,9 +267,9 @@ outputexp(e,state)
case LSHIFT: case LSHIFT:
case RSHIFT: case RSHIFT:
fprint(ofile,"("); fprint(ofile,"(");
outputexp(e->exp_left,state); outexp(e->exp_left,state);
outputop(e->node_type); outop(e->node_type);
outputexp(e->exp_right,state); outexp(e->exp_right,state);
fprint(ofile,")"); fprint(ofile,")");
break; break;
case NOT: case NOT:
@ -272,8 +277,8 @@ outputexp(e,state)
case UPLUS: case UPLUS:
case UMINUS: case UMINUS:
fprint(ofile,"("); fprint(ofile,"(");
outputop(e->node_type); outop(e->node_type);
outputexp(e->exp_left,state); outexp(e->exp_left,state);
fprint(ofile,")"); fprint(ofile,")");
break; break;
case DEFINED: case DEFINED:
@ -284,21 +289,21 @@ outputexp(e,state)
break; break;
case COMMA: case COMMA:
outext(e->exp_left); outext(e->exp_left);
fprint(ofile,","); outputexp(e->exp_right,state); fprint(ofile,","); outexp(e->exp_right,state);
break; break;
case SAMESIGN: case SAMESIGN:
case SFIT: case SFIT:
case UFIT: case UFIT:
case ROTATE: case ROTATE:
outputop(e->node_type); outop(e->node_type);
outputexp(e->exp_left,state); outexp(e->exp_left,state);
fprint(ofile,","); fprint(ofile,",");
outputexp(e->exp_right,state); outexp(e->exp_right,state);
fprint(ofile,")"); fprint(ofile,")");
break; break;
case SAMEEXT: case SAMEEXT:
case SAMENAM: case SAMENAM:
outputop(e->node_type); outop(e->node_type);
outext(e->exp_left); outext(e->exp_left);
fprint(ofile,","); fprint(ofile,",");
outext(e->exp_right,state); outext(e->exp_right,state);
@ -349,7 +354,7 @@ outext(e)
} }
PRIVATE PRIVATE
outputop(op) outop(op)
int op; int op;
{ {
switch(op) { switch(op) {
@ -375,11 +380,11 @@ outputop(op)
case COMP: fprint(ofile,"~"); break; case COMP: fprint(ofile,"~"); break;
case UPLUS: fprint(ofile,"+"); break; case UPLUS: fprint(ofile,"+"); break;
case UMINUS: fprint(ofile,"-"); break; case UMINUS: fprint(ofile,"-"); break;
case SAMESIGN: fprint(ofile,"OO_samesign("); break; case SAMESIGN: fprint(ofile,"OO_signsame("); break;
case SFIT: fprint(ofile,"OO_sfit("); break; case SFIT: fprint(ofile,"OO_sfit("); break;
case UFIT: fprint(ofile,"OO_ufit("); break; case UFIT: fprint(ofile,"OO_ufit("); break;
case ROTATE: fprint(ofile,"OO_rotate("); break; case ROTATE: fprint(ofile,"OO_rotate("); break;
case SAMEEXT: fprint(ofile,"OO_sameext("); break; case SAMEEXT: fprint(ofile,"OO_extsame("); break;
case SAMENAM: fprint(ofile,"OO_samenam("); break; case SAMENAM: fprint(ofile,"OO_namsame("); break;
} }
} }