simplified a bit to make the resulting optimizer smaller; Added a

constant w2 that can be used in the patterns instead of 2*w
This commit is contained in:
ceriel 1989-02-02 11:41:31 +00:00
parent 9359e081db
commit f3c29355f6
9 changed files with 307 additions and 114 deletions

View file

@ -5,7 +5,7 @@ COMPARE = $(EMHOME)/modules/compare
LINT = lint
BINDIR = $(EMHOME)/lib
LIBOPT = libemopt.a
LIBCEOPT = libemoptCE.a
LIBCEOPT = libCEopt.a
# set HOWMUCH to head -20 to limit number of patterns used
#HOWMUCH = head -20
@ -78,6 +78,8 @@ 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/libprint.a\
$(EMHOME)/modules/lib/libstring.a\
$(EMHOME)/modules/lib/libsystem.a\
$(EMHOME)/lib/em_data.a
@ -89,7 +91,9 @@ OLINT = main.c mkstrct.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
$(EMHOME)/modules/lib/llib-lalloc.ln\
$(EMHOME)/modules/lib/llib-lprint.ln\
$(EMHOME)/modules/lib/llib-lstring.ln
lintnopt: dfadummy $(OLINT)
$(LINT) $(LINTFLAGS) $(OLINT) $(OLINTLIB)
@ -101,14 +105,14 @@ $(LIBOPT): dfadummy $(NOFILES) mkstrct.o pseudo.d incalls.d
ar rc $(LIBOPT) O_*.o $(NOFILES) mkstrct.o
-sh -c 'ranlib $(LIBOPT)'
libCEopt.a:
$(LIBCEOPT):
make clean
make PREFLAGS='$(INCLDIR) -DPRIVATE=static -DCODE_EXPANDER' $(LIBOPT)
mv $(LIBOPT) libCEopt.a
mv $(LIBOPT) $(LIBCEOPT)
make clean
dfadummy: patterns parser
-/lib/cpp patterns | $(HOWMUCH) >/tmp/patts
-$(EMHOME)/lib/cpp patterns | $(HOWMUCH) >/tmp/patts
parser </tmp/patts
-rm /tmp/patts
touch dfadummy

View file

@ -93,3 +93,180 @@ EM_mkdefilb(p,opcode,deflb)
p->em_ilb = deflb;
}
EM_Nop(opcode)
int opcode;
{
register p_instr p = GETNXTPATT();
p->em_type = EM_MNEM;
p->em_opcode = opcode;
p->em_argtype = 0;
}
EM_Nnarg(opcode)
int opcode;
{
register p_instr p = GETNXTPATT();
p->em_type = EM_MNEM;
p->em_opcode = opcode;
p->em_argtype = 0;
p->em_cst = 0;
}
EM_Nilb(opcode,lab)
int opcode;
label lab;
{
register p_instr p = GETNXTPATT();
p->em_type = EM_MNEM;
p->em_argtype = ilb_ptyp;
p->em_opcode = opcode;
p->em_ilb = lab;
}
EM_Nnof(opcode,lab,off)
int opcode;
label lab;
arith off;
{
register p_instr p = GETNXTPATT();
p->em_type = EM_MNEM;
p->em_argtype = nof_ptyp;
p->em_opcode = opcode;
p->em_dlb = lab;
p->em_off = off;
}
EM_Nsof(opcode,name,off)
int opcode;
char *name;
arith off;
{
register p_instr p = GETNXTPATT();
p->em_type = EM_MNEM;
p->em_argtype = sof_ptyp;
p->em_opcode = opcode;
p->em_dnam = OO_freestr(name);
p->em_off = off;
}
EM_Ncst(opcode,cst)
int opcode;
arith cst;
{
register p_instr p = GETNXTPATT();
p->em_type = EM_MNEM;
p->em_argtype = cst_ptyp;
p->em_opcode = opcode;
p->em_cst = cst;
}
EM_Npro(opcode,pnam)
int opcode;
char *pnam;
{
register p_instr p = GETNXTPATT();
p->em_type = EM_MNEM;
p->em_argtype = pro_ptyp;
p->em_opcode = opcode;
p->em_pnam = OO_freestr(pnam);
}
EM_Ndefilb(opcode,deflb)
int opcode;
label deflb;
{
register p_instr p = GETNXTPATT();
p->em_type = EM_DEFILB;
p->em_opcode = opcode;
p->em_argtype = 0;
p->em_ilb = deflb;
}
EM_Rop(opcode)
int opcode;
{
register p_instr p = GETNXTREPL();
p->em_type = EM_MNEM;
p->em_opcode = opcode;
p->em_argtype = 0;
}
EM_Rnarg(opcode)
int opcode;
{
register p_instr p = GETNXTREPL();
p->em_type = EM_MNEM;
p->em_opcode = opcode;
p->em_argtype = 0;
p->em_cst = 0;
}
EM_Rilb(opcode,lab)
int opcode;
label lab;
{
register p_instr p = GETNXTREPL();
p->em_type = EM_MNEM;
p->em_argtype = ilb_ptyp;
p->em_opcode = opcode;
p->em_ilb = lab;
}
EM_Rnof(opcode,lab,off)
int opcode;
label lab;
arith off;
{
register p_instr p = GETNXTREPL();
p->em_type = EM_MNEM;
p->em_argtype = nof_ptyp;
p->em_opcode = opcode;
p->em_dlb = lab;
p->em_off = off;
}
EM_Rsof(opcode,name,off)
int opcode;
char *name;
arith off;
{
register p_instr p = GETNXTREPL();
p->em_type = EM_MNEM;
p->em_argtype = sof_ptyp;
p->em_opcode = opcode;
p->em_dnam = OO_freestr(name);
p->em_off = off;
}
EM_Rcst(opcode,cst)
int opcode;
arith cst;
{
register p_instr p = GETNXTREPL();
p->em_type = EM_MNEM;
p->em_argtype = cst_ptyp;
p->em_opcode = opcode;
p->em_cst = cst;
}
EM_Rpro(opcode,pnam)
int opcode;
char *pnam;
{
register p_instr p = GETNXTREPL();
p->em_type = EM_MNEM;
p->em_argtype = pro_ptyp;
p->em_opcode = opcode;
p->em_pnam = OO_freestr(pnam);
}
EM_Rdefilb(opcode,deflb)
int opcode;
label deflb;
{
register p_instr p = GETNXTREPL();
p->em_type = EM_DEFILB;
p->em_opcode = opcode;
p->em_argtype = 0;
p->em_ilb = deflb;
}

View file

@ -29,6 +29,7 @@ static char *nextstr;
static char *laststr;
arith OO_WSIZE; /* wordlength */
arith OO_DWSIZE; /* 2*wordlength */
arith OO_PSIZE; /* pointer length */
#ifdef STATS
@ -51,6 +52,7 @@ O_init(wsize,psize)
allocmem();
C_init(wsize,psize);
OO_WSIZE = wsize;
OO_DWSIZE = 2*wsize;
OO_PSIZE = psize;
}

View file

@ -46,6 +46,7 @@ p_instr OO_halfflush();
extern int OO_state;
extern arith OO_WSIZE; /* wordlength */
extern arith OO_DWSIZE; /* 2*wordlength */
extern arith OO_PSIZE; /* pointer length */
#ifdef STATS
extern int OO_wrstats; /* statistics output */

View file

@ -14,7 +14,7 @@ outputincalls()
case NOARG:
fprintf(ofile,"%s\t|\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_mkop(GETNXTPATT(),op_%s);\n",s);
fprintf(ofile,"\tEM_Nop(op_%s);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
@ -25,7 +25,7 @@ outputincalls()
case CSTOPT:
fprintf(ofile,"%s_narg\t|\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_mknarg(GETNXTPATT(),op_%s);\n",s);
fprintf(ofile,"\tEM_Nnarg(op_%s);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
@ -36,7 +36,7 @@ outputincalls()
case CST:
fprintf(ofile,"%s\t| arith:n\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_mkcst(GETNXTPATT(),op_%s,n);\n",s);
fprintf(ofile,"\tEM_Ncst(op_%s,n);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
@ -47,7 +47,7 @@ outputincalls()
case DEFILB:
fprintf(ofile,"df_ilb\t| label:l\t|\n");
if(op->id_used) {
fprintf(ofile,"\tEM_mkdefilb(GETNXTPATT(),op_%s,l);\n",s);
fprintf(ofile,"\tEM_Ndefilb(op_%s,l);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
@ -58,7 +58,7 @@ outputincalls()
case PNAM:
fprintf(ofile,"%s\t| char *:s\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_mkpro(GETNXTPATT(),op_%s,s);\n",s);
fprintf(ofile,"\tEM_Npro(op_%s,s);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
@ -69,7 +69,7 @@ outputincalls()
case LAB:
fprintf(ofile,"%s\t| label:l\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_mkilb(GETNXTPATT(),op_%s,l);\n",s);
fprintf(ofile,"\tEM_Nilb(op_%s,l);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
@ -80,7 +80,7 @@ outputincalls()
case EXT:
fprintf(ofile,"%s\t| arith:n\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_mkcst(GETNXTPATT(),op_%s,n);\n",s);
fprintf(ofile,"\tEM_Ncst(op_%s,n);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
@ -89,7 +89,7 @@ outputincalls()
}
fprintf(ofile,"%s_dnam\t| char *:s arith:n\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_mksof(GETNXTPATT(),op_%s,s,n);\n",s);
fprintf(ofile,"\tEM_Nsof(op_%s,s,n);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
@ -98,7 +98,7 @@ outputincalls()
}
fprintf(ofile,"%s_dlb\t| label:l arith:n\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_mknof(GETNXTPATT(),op_%s,l,n);\n",s);
fprintf(ofile,"\tEM_Nnof(op_%s,l,n);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {

View file

@ -241,7 +241,7 @@ sametest(s1,s2,e1,e2)
int s1,s2;
struct exp_node *e1,*e2;
{
/* retrun 1 if tests are identical */
/* return 1 if tests are identical */
if(e1) {
if(!e2) return 0;
if(e1->node_type!=e2->node_type) return 0;
@ -287,13 +287,15 @@ sametest(s1,s2,e1,e2)
if (e1->leaf_val != e2->leaf_val) return 0;
return (patterns[s1].m_elems[e1->leaf_val-1]->
op_code->id_argfmt
== patterns[s1].m_elems[e2->leaf_val-1]->
== patterns[s2].m_elems[e2->leaf_val-1]->
op_code->id_argfmt);
case PSIZE:
case WSIZE:
case DWSIZE:
return 1;
}
/*NOTREACHED*/
}
else return (e2==0);
}
@ -431,37 +433,37 @@ outrepl(state,repl)
char *mnem = ri->op_code->id_text;
switch(ri->op_code->id_argfmt) {
case NOARG:
fprintf(ofile,"\t\tEM_mkop(GETNXTREPL(),op_%s);\n",mnem);
fprintf(ofile,"\t\tEM_Rop(op_%s);\n",mnem);
break;
case CST:
fprintf(ofile,"\t\tEM_mkcst(GETNXTREPL(),op_%s,",mnem);
fprintf(ofile,"\t\tEM_Rcst(op_%s,",mnem);
fprintf(ofile,"(arith)");
outexp(ri->arg,state);
fprintf(ofile,");\n");
break;
case CSTOPT:
if(ri->arg) {
fprintf(ofile,"\t\tEM_mkcst(GETNXTREPL(),op_%s,",mnem);
fprintf(ofile,"\t\tEM_Rcst(op_%s,",mnem);
fprintf(ofile,"(arith)");
outexp(ri->arg,state);
}
else {
fprintf(ofile,"\t\tEM_mknarg(GETNXTREPL(),op_%s);\n",mnem);
fprintf(ofile,"\t\tEM_Rnarg(op_%s);\n",mnem);
}
fprintf(ofile,");\n");
break;
case LAB:
fprintf(ofile,"\t\tEM_mkilb(GETNXTREPL(),op_%s,",mnem);
fprintf(ofile,"\t\tEM_Rilb(op_%s,",mnem);
outexp(ri->arg,state);
fprintf(ofile,");\n");
break;
case DEFILB:
fprintf(ofile,"\t\tEM_mkdefilb(GETNXTREPL(),op_%s,",mnem);
fprintf(ofile,"\t\tEM_Rdefilb(op_%s,",mnem);
outexp(ri->arg,state);
fprintf(ofile,");\n");
break;
case PNAM:
fprintf(ofile,"\t\tEM_mkpro(GETNXTREPL(),op_%s,",mnem);
fprintf(ofile,"\t\tEM_Rpro(op_%s,",mnem);
outexp(ri->arg,state);
fprintf(ofile,");\n");
break;
@ -573,6 +575,8 @@ outexp(e,state)
fprintf(ofile,"OO_PSIZE"); break;
case WSIZE:
fprintf(ofile,"OO_WSIZE"); break;
case DWSIZE:
fprintf(ofile,"OO_DWSIZE"); break;
case INT:
fprintf(ofile,"%d",e->leaf_val); break;
}

View file

@ -4,7 +4,7 @@
op1 op2 ... : action
and build a program to recognize then */
%token SFIT, UFIT, ROTATE, PSIZE, WSIZE, DEFINED, UNDEFINED, SAMESIGN;
%token SFIT, UFIT, ROTATE, PSIZE, WSIZE, DWSIZE, DEFINED, UNDEFINED, SAMESIGN;
%token SAMEEXT, SAMENAM, OFFSET, LOGAND, LOGOR, BITAND, BITOR, XOR;
%token MINUS, PLUS, TIMES, DIV, MOD, EQ, NE, LT, LE, GT, GE, NOT, COMP;
%token LSHIFT, RSHIFT, COMMA, OPCODE, INT, UPLUS, UMINUS, PATARG;
@ -266,6 +266,10 @@ exp(int level; struct exp_node **result;)
{
*result = mkleaf(WSIZE,0);
}
| DWSIZE
{
*result = mkleaf(DWSIZE,0);
}
| INT
{
*result = mkleaf(INT,lastintval);

View file

@ -5,9 +5,9 @@ inc loc adi w : loc $2+1 adi w
inc loc sbi w : loc $2-1 sbi w
dec loc adi w : loc $2-1 adi w
dec loc sbi w : loc $2+1 sbi w
ldc adi 2*w ldc sbi 2*w : ldc $1-$3 adi 2*w
ldc adi w2 ldc sbi w2 : ldc $1-$3 adi w2
loc adi w loc adi w : loc $1+$3 adi w
ldc adi 2*w ldc adi 2*w : ldc $1+$3 adi 2*w
ldc adi w2 ldc adi w2 : ldc $1+$3 adi w2
loc adi w loc mli w : loc $3 mli w loc $1*$3 adi w
loc adi w loc 1 sli w : loc $3 sli w loc 2*$1 adi w
adp 0 :
@ -15,11 +15,11 @@ adp adp : adp $1+$2
adp lof : lof $1+$2
adp ldf : ldf $1+$2
adp !=0 loi w : lof $1
adp !=0 loi 2*w : ldf $1
adp !=0 loi w2 : ldf $1
adp stf : stf $1+$2
adp sdf : sdf $1+$2
adp !=0 sti w : stf $1
adp !=0 sti 2*w : sdf $1
adp !=0 sti w2 : sdf $1
asp 0 :
asp asp : asp $1+$2
blm 0 : asp 2*p
@ -34,22 +34,22 @@ cmu w zne : bne $2
dvi ngi $1 : ngi $1 dvi $1
lae adp : lae $1+$2
lae blm w : loi w ste $1
lae blm 2*w : loi 2*w sde $1
lae blm w2 : loi w2 sde $1
lae ldf : lde $1+$2
lae lof : loe $1+$2
lae loi w : loe $1
lae loi 2*w : lde $1
lae loi w2 : lde $1
#ifdef INT
lae loi loe $1-w ? $2%w==0: lae $3 loi $2+w
lae loi lde $1-2*w ? $2%w==0: lae $3 loi $2+2*w
lae loi lde $1-w2 ? $2%w==0: lae $3 loi $2+w2
lae $3+$4 loi lae loi ? $2%w==0 && $4%w==0: lae $3 loi $2+$4
lae sti ste $1+$2 : lae $1 sti $2+w
lae sti sde $1+$2 : lae $1 sti $2+2*w
lae sti sde $1+$2 : lae $1 sti $2+w2
lae sti loc ste $1-w : loc $3 lae $4 sti $2+w
lae sti lol ste $1-w : lol $3 lae $4 sti $2+w
#endif
lae lae blm loe $1+$3 ste $2+$3 : lae $1 lae $2 blm $3+w
lae lae blm lde $1+$3 sde $2+$3 : lae $1 lae $2 blm $3+2*w
lae lae blm lde $1+$3 sde $2+$3 : lae $1 lae $2 blm $3+w2
lae lae blm lae $1+$3 lae $2+$3 blm : lae $1 lae $2 blm $3+$6
lae lal blm lae $1+$3 lal $2+$3 blm ? samesign($2,$5):
lae $1 lal $2 blm $3+$6
@ -61,10 +61,10 @@ lal lal sbs w ? samesign($1,$2): loc $1-$2
lae sdf : sde $1+$2
lae stf : ste $1+$2
lae sti w : ste $1
lae sti 2*w : sde $1
lae sti w2 : sde $1
lal adp ? samesign($1,$1+$2): lal $1+$2
lal blm w : loi w stl $1
lal blm 2*w : loi 2*w sdl $1
lal blm w2 : loi w2 sdl $1
#ifdef INT
/*lal sti loc stl $1-w ? notreg($4) && samesign($1,$4): */
/* loc $3 lal $4 sti $2+w */
@ -74,29 +74,29 @@ lal blm 2*w : loi 2*w sdl $1
lal ldf ? samesign($1,$1+$2): ldl $1+$2
lal lof ? samesign($1,$1+$2): lol $1+$2
lal loi w : lol $1
lal loi 2*w : ldl $1
lal loi w2 : ldl $1
#ifdef INT
/*lal loi lol $1-w ? notreg($3) && samesign($1,$3) && $2%w==0: */
/* lal $3 loi $2+w */
/*lal loi ldl $1-2*w ? notreg($3) && samesign($1,$3) && $2%w==0: */
/* lal $3 loi $2+2*w */
/*lal loi ldl $1-w2 ? notreg($3) && samesign($1,$3) && $2%w==0: */
/* lal $3 loi $2+w2 */
lal loi lal loi $1-$3 ? samesign($1,$3) && $2%w==0 && $4%w==0:
lal $3 loi $2+$4
/*lal sti stl $1+$2 ? notreg($3) && samesign($1,$3): lal $1 sti $2+w */
/*lal sti sdl $1+$2 ? notreg($3) && samesign($1,$3): lal $1 sti $2+2*w*/
/*lal sti sdl $1+$2 ? notreg($3) && samesign($1,$3): lal $1 sti $2+w2*/
#endif
lal sdf ? samesign($1,$1+$2): sdl $1+$2
lal stf ? samesign($1,$1+$2): stl $1+$2
lal sti w : stl $1
lal sti 2*w : sdl $1
lal sti w2 : sdl $1
#ifdef INT
lde lde $1-2*w : lae $2 loi 4*w
lde lde $1-w2 : lae $2 loi 4*w
lde loe $1-w : lae $2 loi 3*w
#endif
lde sde $1 :
lde sde lde $1+2*w sde $2+2*w : lae $1 lae $2 blm 4*w
lde sde lde $1+w2 sde $2+w2 : lae $1 lae $2 blm 4*w
#ifdef INT
/*ldl ldl $1-2*w ? notreg($1) && notreg($2) && samesign($1,$2):*/
/*ldl ldl $1-w2 ? notreg($1) && notreg($2) && samesign($1,$2):*/
/* lal $2 loi 4*w */
/*ldl lol $1-w ? notreg($1) && notreg($2) && samesign($1,$2): */
/* lal $2 loi 3*w */
@ -106,28 +106,28 @@ lxa loi lxa $1 sti $2 :
lxa lof lxa $1 stf $2 :
lxa ldf lxa $1 sdf $2 :
lxa >1 stf lxa $1 lof $2 : dup w lxa $1 stf $2
lxa >1 sdf lxa $1 ldf $2 : dup 2*w lxa $1 sdf $2
lxa >1 sdf lxa $1 ldf $2 : dup w2 lxa $1 sdf $2
lxl lof lxl $1 stf $2 :
lxl ldf lxl $1 sdf $2 :
lxl >1 stf lxl $1 lof $2 : dup w lxl $1 stf $2
lxl >1 sdf lxl $1 ldf $2 : dup 2*w lxl $1 sdf $2
lxl >1 sdf lxl $1 ldf $2 : dup w2 lxl $1 sdf $2
lxa >1 sti lxa $1 loi $2 ? $2%w==0: dup $2 lxa $1 sti $2
loc -1 adi w : dec
loc dec ? sfit($1-1,8*w) : loc $1-1
loc -1 bgt : zge $2
loc -1 ble : zlt $2
loc -1 dvi w : ngi w
ldc -1 dvi 2*w : ngi 2*w
ldc -1 dvi w2 : ngi w2
loc -1 loe adi w : loe $2 dec
loc -1 lol adi w : lol $2 dec
loc -1 mli w : ngi w
ldc -1 mli 2*w : ngi 2*w
ldc -1 mli w2 : ngi w2
loc -1 sbi w : inc
loc inc ? sfit($1+1,8*w) : loc $1+1
loc 0 adi w :
ldc 0 adi 2*w :
ldc 0 adi w2 :
loc 0 ads w :
ldc 0 ads 2*w :
ldc 0 ads w2 :
zer adi $1 :
loc 0 beq : zeq $2
loc 0 bge : zge $2
@ -146,33 +146,33 @@ loc 0 cmu w tne : tne
loc 0 cmu w zeq : zeq $3
loc 0 cmu w zne : zne $3
loc 0 ior w :
ldc 0 ior 2*w :
ldc 0 ior w2 :
zer ior $1 :
loc 0 ste : zre $2
loc 0 stl : zrl $2
loc 0 sbi w :
ldc 0 sbi 2*w :
ldc 0 sbi w2 :
zer sbi $1 :
loc 0 xor w :
ldc 0 xor 2*w :
ldc 0 xor w2 :
zer xor $1 :
loc 1 adi w : inc
loc 1 bge : zgt $2
loc 1 blt : zle $2
loc 1 dvi w :
ldc 1 dvi 2*w :
ldc 1 dvi w2 :
loc 1 dvu w :
loc 1 dvu 2*w :
loc 1 dvu w2 :
loc 1 loe adi w : loe $2 inc
loc 1 lol adi w : lol $2 inc
loc 0 mli w : asp w loc 0
ldc 0 mli 2*w : asp 2*w ldc 0
ldc 0 mli w2 : asp w2 ldc 0
loc 0 mlu w : asp w loc 0
ldc 0 mlu 2*w : asp 2*w ldc 0
ldc 0 mlu w2 : asp w2 ldc 0
loc 1 mli w :
ldc 1 mli 2*w :
ldc 1 mli w2 :
loc 1 mlu w :
ldc 1 mlu 2*w :
ldc 1 mlu w2 :
loc 1 sbi w : dec
loc loe mli w : loe $2 loc $1 mli w
loc loe mlu w : loe $2 loc $1 mlu w
@ -184,12 +184,12 @@ loc lol mlu w : lol $2 loc $1 mlu w
loc lol adi w loc : lol $2 loc $1 adi w loc $4
loc lol adi w inc : lol $2 loc $1 adi w dec
loc lol adi w dec : lol $2 loc $1 adi w dec
ldc lde mli 2*w : lde $2 ldc $1 mli 2*w
ldc lde mlu 2*w : lde $2 ldc $1 mlu 2*w
ldc lde adi 2*w : lde $2 ldc $1 adi 2*w
ldc ldl mli 2*w : ldl $2 ldc $1 mli 2*w
ldc ldl mlu 2*w : ldl $2 ldc $1 mlu 2*w
ldc ldl adi 2*w : ldl $2 ldc $1 adi 2*w
ldc lde mli w2 : lde $2 ldc $1 mli w2
ldc lde mlu w2 : lde $2 ldc $1 mlu w2
ldc lde adi w2 : lde $2 ldc $1 adi w2
ldc ldl mli w2 : ldl $2 ldc $1 mli w2
ldc ldl mlu w2 : ldl $2 ldc $1 mlu w2
ldc ldl adi w2 : ldl $2 ldc $1 adi w2
loc 2 mli w : loc 1 sli w
loc 4 mli w : loc 2 sli w
loc 8 mli w : loc 3 sli w
@ -249,7 +249,7 @@ loc zrf undefined : zrf $1
loc los w : loi $1
loc sts w : sti $1
loc ads w : adp $1
ldc ads 2*w ? sfit($1,8*w): adp $1
ldc ads w2 ? sfit($1,8*w): adp $1
loc ass w : asp $1
loc bls w : blm $1
loc dus w : dup $1
@ -295,12 +295,12 @@ loe loe $1 : loe $1 dup w
#endif
loe ste $1 :
lol blm w ? p==w : loi w sil $1
ldl blm w ? p==2*w : loi w sil $1
ldl blm w ? p==w2 : loi w sil $1
lol dec stl $1 : del $1
lol inc stl $1 : inl $1
lol loc 0 mli w : loc 0
lol loi w ? w==p : lil $1
ldl loi w ? p==2*w : lil $1
ldl loi w ? p==w2 : lil $1
#ifdef INT
/*lol lol $1-w ? notreg($1) && notreg($2) && samesign($1,$2): */
/* ldl $2 */
@ -326,7 +326,7 @@ lol lol $1 : lol $1 dup w
#endif
lol stl $1:
lol sti w ? p==w : sil $1
ldl sti w ? p==2*w : sil $1
ldl sti w ? p==w2 : sil $1
mli ngi $1: ngi $1 mli $1
ngi adi $1: sbi $1
ngf adf $1: sbf $1
@ -335,23 +335,23 @@ ngf sbf $1: adf $1
ngi ngi $1:
ngf ngf $1:
#ifdef INT
sde sde $1+2*w : lae $1 sti 4*w
sde ste $1+2*w : lae $1 sti 3*w
sde sde $1+w2 : lae $1 sti 4*w
sde ste $1+w2 : lae $1 sti 3*w
sde loc ste $1-w : loc $2 lae $3 sti 3*w
sde lol ste $1-w : lol $2 lae $3 sti 3*w
sde lde $1 : dup 2*w sde $1
sde lde $1 : dup w2 sde $1
#endif
sdf 0 : sti 2*w
sdf 0 : sti w2
#ifdef INT
/*sdl sdl $1+2*w ? notreg($1) && notreg($2) && samesign($1,$2): */
/*sdl sdl $1+w2 ? notreg($1) && notreg($2) && samesign($1,$2): */
/* lal $1 sti 4*w */
/*sdl stl $1+2*w ? notreg($1) && notreg($2) && samesign($1,$2): */
/*sdl stl $1+w2 ? notreg($1) && notreg($2) && samesign($1,$2): */
/* lal $1 sti 3*w */
/*sdl loc stl $1-w ? notreg($1) && notreg($3) && samesign($1,$3): */
/* loc $2 lal $3 sti 3*w */
/*sdl loe stl $1-w ? notreg($1) && notreg($3) && samesign($1,$3): */
/* loe $2 lal $3 sti 3*w */
sdl ldl $1 : dup 2*w sdl $1
sdl ldl $1 : dup w2 sdl $1
ste loe $1 : dup w ste $1
ste ste $1-w : sde $2
ste loc ste $1-w : loc $2 sde $3
@ -359,7 +359,7 @@ ste lol ste $1-w : lol $2 sde $3
stl lol $1 : dup w stl $1
#endif
stf 0 : sti w
sdl ldl $1 ret 2*w : ret 2*w
sdl ldl $1 ret w2 : ret w2
#ifdef INT
/*stl stl $1+w ? notreg($1) && notreg($2) && samesign($1,$2): sdl $1 */
/*stl loc stl $1-w ? notreg($1) && notreg($3) && samesign($1,$3): */
@ -370,9 +370,9 @@ sdl ldl $1 ret 2*w : ret 2*w
stl lol $1 ret w : ret w
lal sti lal $1 loi $2 ret $2 : ret $2
loc sbi w loc sbi w : loc $1+$3 sbi w
ldc sbi 2*w ldc sbi 2*w : ldc $1+$3 sbi 2*w
ldc sbi w2 ldc sbi w2 : ldc $1+$3 sbi w2
loc sbi w loc adi w : loc $1-$3 sbi w
ldc sbi 2*w ldc adi 2*w : ldc $1-$3 sbi 2*w
ldc sbi w2 ldc adi w2 : ldc $1-$3 sbi w2
loc sbi w loc mli w : loc $3 mli w loc $1*$3 sbi w
loc sbi w loc 1 sli w : loc $3 sli w loc 2*$1 sbi w
teq teq : tne
@ -427,9 +427,9 @@ loe $4 dec dup w ste : dee $1 loe $1
lol $4 inc dup w stl : inl $1 lol $1
lol $4 dec dup w stl : del $1 lol $1
adp dup p ste adp -$1 ? p==w : dup p adp $1 ste $3
adp dup p sde adp -$1 ? p==2*w : dup p adp $1 sde $3
adp dup p sde adp -$1 ? p==w2 : dup p adp $1 sde $3
adp dup p stl adp -$1 ? p==w : dup p adp $1 stl $3
adp dup p sdl adp -$1 ? p==2*w : dup p adp $1 sdl $3
adp dup p sdl adp -$1 ? p==w2 : dup p adp $1 sdl $3
inc dup w ste dec : dup w inc ste $3
inc dup w stl dec : dup w inc stl $3
#endif
@ -452,9 +452,9 @@ lin ret : ret $2
lin bra : bra $2
#ifdef INT
dup p stl loi w ? p==w : stl $2 lil $2
dup p sdl loi w ? p==2*w : sdl $2 lil $2
dup p sdl loi w ? p==w2 : sdl $2 lil $2
dup p stl sti w ? p==w : stl $2 sil $2
dup p sdl sti w ? p==2*w : sdl $2 sil $2
dup p sdl sti w ? p==w2 : sdl $2 sil $2
#endif
loc 0 cms w : tne
zer w : loc 0
@ -464,14 +464,14 @@ loc loc mli w ? sfit($1*$2,8*w) : loc $1*$2
loc loc !=0 dvi w : loc $1/$2
loc loc and w : loc $1&$2
loc loc ior w : loc $1|$2
loc 0 loc 0 ior 2*w :
loc 0 loc 0 ior w2 :
loc loc xor w : loc $1^$2
loc 0 loc 0 xor 2*w :
loc 0 loc 0 xor w2 :
loc loc rol w : loc rotate($1,$2)
loc loc ror w : loc rotate($1,8*w-$2)
loc ngi w ? sfit(-$1,8*w) : loc -$1
loc com w : loc ~$1
ldc ngi 2*w : ldc -$1
ldc ngi w2 : ldc -$1
/*loc lae aar w ? $1>=rom(2,0) && $1 <= rom(2,0)+rom(2,1) : */
/* adp ($1-rom(2,0))*rom(2,2) */
/*loc lae lar w ? $1>=rom(2,0) && $1 <= rom(2,0)+rom(2,1) : */
@ -515,15 +515,15 @@ lal loi >4*w lal sti $2 ? ( $3<=$1-$2 || $3>=$1+$2 ) :
lae loi >4*w lae sti $2 ? ($3<=$1-$2 || $3>=$1+$2) :
lae $1 lae $3 blm $2
loc 0 loc w loc cif : zrf $3
loc >=0 loc w loc 2*w ciu : ldc $1
loc loc w loc 2*w cii : ldc $1
loc >=0 loc w loc w2 ciu : ldc $1
loc loc w loc w2 cii : ldc $1
loi loc >=0 inn $1 ? $2<$1*8 :
lof ($2/(8*w))*w loc $2&(8*w-1) inn w
ldl loc >=0 inn 2*w ? $2<16*w :
ldl loc >=0 inn w2 ? $2<16*w :
lol $1+($2/(8*w))*w loc $2&(8*w-1) inn w
lde loc >=0 inn 2*w ? $2<16*w :
lde loc >=0 inn w2 ? $2<16*w :
loe $1+($2/(8*w))*w loc $2&(8*w-1) inn w
ldf loc >=0 inn 2*w ? $2<16*w :
ldf loc >=0 inn w2 ? $2<16*w :
lof $1+($2/(8*w))*w loc $2&(8*w-1) inn w
loc inn ? $1<0 || $1>=8*$2 : asp $2 loc 0
lol loc adi w stl $1 : loc $2 lol $1 adi w stl $4
@ -546,50 +546,50 @@ loe loe !=$1 and w ste $1 : loe $2 loe $1 and w ste $4
loe lol and w ste $1 : lol $2 loe $1 and w ste $4
loi asp $1 : asp p
lal loi 4*w loc loc loc loc ior 4*w ? ($3==0)+($4==0)+($5==0)+($6==0)>2 :
lol $1+3*w loc $3 ior w lol $1+2*w loc $4 ior w lol $1+w loc $5 ior w lol $1 loc $6 ior w
lol $1+3*w loc $3 ior w lol $1+w2 loc $4 ior w lol $1+w loc $5 ior w lol $1 loc $6 ior w
loc dup 2 stl loc dup 2 stl :
loc $1 stl $3 loc $4 stl $6 loc $1 loc $4
lol lol adp stl $2 sti != p ? p==w : lol $1 sti $5 lol $2 adp $3 stl $4
ldl ldl adp sdl $2 sti != p ? p==2*w : ldl $1 sti $5 ldl $2 adp $3 sdl $4
ldl ldl adp sdl $2 sti != p ? p==w2 : ldl $1 sti $5 ldl $2 adp $3 sdl $4
loe loe adp ste $2 sti !=p ? p==w : loe $1 sti $5 loe $2 adp $3 ste $4
lde lde adp sde $2 sti !=p ? p==2*w : lde $1 sti $5 lde $2 adp $3 sde $4
lde lde adp sde $2 sti !=p ? p==w2 : lde $1 sti $5 lde $2 adp $3 sde $4
#ifndef INT
dup w stl : stl $2 lol $2
dup w ste : ste $2 loe $2
dup w sil : sil $2 lil $2
dup w loe sti w ? p==w : loe $2 sti w loe $2 loi w
dup w lde sti w ? p==2*w : lde $2 sti w lde $2 loi w
dup w lde sti w ? p==w2 : lde $2 sti w lde $2 loi w
dup w lol stf ? p==w : lol $2 stf $3 lol $2 lof $3
dup w ldl stf ? p==2*w : ldl $2 stf $3 ldl $2 lof $3
dup w ldl stf ? p==w2 : ldl $2 stf $3 ldl $2 lof $3
dup w loe stf ? p==w : loe $2 stf $3 loe $2 lof $3
dup w lde stf ? p==2*w : lde $2 stf $3 lde $2 lof $3
dup 2*w sdl : sdl $2 ldl $2
dup 2*w sde : sde $2 lde $2
dup 2*w lol sti 2*w ? p==w : lol $2 sti 2*w lol $2 loi 2*w
dup 2*w ldl sti 2*w ? p==2*w : ldl $2 sti 2*w ldl $2 loi 2*w
dup 2*w loe sti 2*w ? p==w : loe $2 sti 2*w loe $2 loi 2*w
dup 2*w lde sti 2*w ? p==2*w : lde $2 sti 2*w lde $2 loi 2*w
dup 2*w lol sdf ? p==w : lol $2 sdf $3 lol $2 ldf $3
dup 2*w ldl sdf ? p==2*w : ldl $2 sdf $3 ldl $2 ldf $3
dup 2*w loe sdf ? p==w : loe $2 sdf $3 loe $2 ldf $3
dup 2*w lde sdf ? p==2*w : lde $2 sdf $3 lde $2 ldf $3
dup w lde stf ? p==w2 : lde $2 stf $3 lde $2 lof $3
dup w2 sdl : sdl $2 ldl $2
dup w2 sde : sde $2 lde $2
dup w2 lol sti w2 ? p==w : lol $2 sti w2 lol $2 loi w2
dup w2 ldl sti w2 ? p==w2 : ldl $2 sti w2 ldl $2 loi w2
dup w2 loe sti w2 ? p==w : loe $2 sti w2 loe $2 loi w2
dup w2 lde sti w2 ? p==w2 : lde $2 sti w2 lde $2 loi w2
dup w2 lol sdf ? p==w : lol $2 sdf $3 lol $2 ldf $3
dup w2 ldl sdf ? p==w2 : ldl $2 sdf $3 ldl $2 ldf $3
dup w2 loe sdf ? p==w : loe $2 sdf $3 loe $2 ldf $3
dup w2 lde sdf ? p==w2 : lde $2 sdf $3 lde $2 ldf $3
lol dup w : lol $1 lol $1
loe dup w : loe $1 loe $1
lil dup w : lil $1 lil $1
loe loi w dup 2 ? p==w : loe $1 loi w loe $1 loi w
lde loi w dup 2 ? p==2*w : lde $1 loi w lde $1 loi w
ldl dup 2*w : ldl $1 ldl $1
lde dup 2*w : lde $1 lde $1
lde loi w dup 2 ? p==w2 : lde $1 loi w lde $1 loi w
ldl dup w2 : ldl $1 ldl $1
lde dup w2 : lde $1 lde $1
#endif
adp stl lol $2 adp -$1 ? p==w : dup p adp $1 stl $2
adp sdl ldl $2 adp -$1 ? p==2*w : dup p adp $1 sdl $2
adp sdl ldl $2 adp -$1 ? p==w2 : dup p adp $1 sdl $2
adp ste loe $2 adp -$1 ? p==w : dup p adp $1 ste $2
adp sde lde $2 adp -$1 ? p==2*w : dup p adp $1 sde $2
adp sde lde $2 adp -$1 ? p==w2 : dup p adp $1 sde $2
adp sil lil $2 adp -$1 ? p==w : dup p adp $1 sil $2
adp lol sti p lol $2 loi p adp -$1 ? p==w : dup p adp $1 lol $2 sti p
adp ldl sti p ldl $2 loi p adp -$1 ? p==2*w : dup p adp $1 ldl $2 sti p
adp ldl sti p ldl $2 loi p adp -$1 ? p==w2 : dup p adp $1 ldl $2 sti p
adp loe sti p loe $2 loi p adp -$1 ? p==w : dup p adp $1 loe $2 sti p
adp lde sti p lde $2 loi p adp -$1 ? p==2*w : dup p adp $1 lde $2 sti p
adp lde sti p lde $2 loi p adp -$1 ? p==w2 : dup p adp $1 lde $2 sti p
/* dead code patterns */
bra aar : bra $1
bra adf : bra $1

View file

@ -12,6 +12,7 @@ sfit return(SFIT);
ufit return(UFIT);
rotate return(ROTATE);
p return(PSIZE);
w2 return(DWSIZE);
w return(WSIZE);
defined return(DEFINED);
undefined return(UNDEFINED);