New patterns, man page changes, other little fixes
This commit is contained in:
parent
a8e086dbc3
commit
c8aaa59e1c
|
@ -5,7 +5,7 @@ em_nopt \- EM peephole optimizer
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
~em/lib/em_nopt [ inputfile [ outputfile ] ]
|
~em/lib/em_nopt [ inputfile [ outputfile ] ]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Em_nopt reads a compact EM-program, inputfile or standard input,
|
Em_nopt reads a compact EM-program inputfile or standard input,
|
||||||
and produces another compact EM program on outputfile or standard output
|
and produces another compact EM program on outputfile or standard output
|
||||||
that is functionally equivalent,
|
that is functionally equivalent,
|
||||||
but smaller.
|
but smaller.
|
||||||
|
|
|
@ -70,20 +70,24 @@ used in compilers and other EM code producing programs. The interface
|
||||||
routines are identical to the EM_CODE(3) procedure interface except that all
|
routines are identical to the EM_CODE(3) procedure interface except that all
|
||||||
names have been replaced by
|
names have been replaced by
|
||||||
.I O_xxx
|
.I O_xxx
|
||||||
. It is possible to convert
|
It is possible to convert
|
||||||
a program that is currently using the EM_CODE interface by defining PEEPHOLE
|
a program that is currently using the EM_CODE interface
|
||||||
before including em.h which enables a series of macros to map all the
|
to use this module instead by defining
|
||||||
|
.I PEEPHOLE
|
||||||
|
before including
|
||||||
|
.I em.h.
|
||||||
|
This defines a series of macros to map all the
|
||||||
.I C_xxx
|
.I C_xxx
|
||||||
names to the corresponding
|
names to the corresponding
|
||||||
.I O_xxx
|
.I O_xxx
|
||||||
names. The module in turn calls
|
names. The module in turn calls
|
||||||
.I C_xxx
|
.I C_xxx
|
||||||
routines to output the optimized code. Hence it is possible to add peephole
|
routines to output the optimized code. Hence it is possible to add peephole
|
||||||
optimization to any program that outputs EM code usng the EM_CODE module.
|
optimization to any program that outputs EM code using the EM_CODE module.
|
||||||
.PP
|
.PP
|
||||||
Details of the
|
Details of the
|
||||||
.I O_xxx
|
.I O_xxx
|
||||||
routines may be obtained by refering to the description
|
routines may be obtained by referring to the description
|
||||||
of the corresponding
|
of the corresponding
|
||||||
.I C_xxx
|
.I C_xxx
|
||||||
routine in EM_CODE(3).
|
routine in EM_CODE(3).
|
||||||
|
@ -94,7 +98,7 @@ routine in EM_CODE(3).
|
||||||
.fi
|
.fi
|
||||||
.SH MODULES
|
.SH MODULES
|
||||||
.nf
|
.nf
|
||||||
alloc(3), system(3), string(3)
|
alloc(3), system(3), string(3), em_code(3)
|
||||||
.fi
|
.fi
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
em_nopt(1) em_code(3), read_em(3), em_mes(3)
|
em_nopt(1) em_code(3), read_em(3), em_mes(3)
|
||||||
|
|
|
@ -10,21 +10,19 @@
|
||||||
#include <em.h>
|
#include <em.h>
|
||||||
#include <em_comp.h>
|
#include <em_comp.h>
|
||||||
#include <system.h>
|
#include <system.h>
|
||||||
#include <idf_pkg.spec>
|
|
||||||
#include <emO_code.h>
|
#include <emO_code.h>
|
||||||
|
|
||||||
#define OTHER 255
|
#define OTHER 0
|
||||||
|
#define op_lab sp_fpseu
|
||||||
|
|
||||||
|
typedef struct e_instr *p_instr;
|
||||||
|
|
||||||
#define FLUSHDFA() if(OO_state) {\
|
#define FLUSHDFA() if(OO_state) {\
|
||||||
*OO_nxtpatt++ = OO_OTHER; OO_dfa(OTHER);\
|
*OO_nxtpatt++ = OO_OTHER; OO_dfa(OTHER);\
|
||||||
} else if(OO_noutput) OO_flush();
|
} else if(OO_noutput) OO_flush();
|
||||||
|
|
||||||
#define GETINSTR() (OO_nxtifree>OO_freeiqueue)?*(--OO_nxtifree):\
|
#define GETINSTR() (OO_nxtifree>OO_freeiqueue)?*(--OO_nxtifree):\
|
||||||
((p_instr)Malloc(sizeof(struct e_instr)))
|
((p_instr)Malloc(sizeof(struct e_instr)))
|
||||||
|
|
||||||
#define op_lab sp_ilb1
|
|
||||||
|
|
||||||
typedef struct e_instr *p_instr;
|
|
||||||
|
|
||||||
extern p_instr *OO_freeiqueue;
|
extern p_instr *OO_freeiqueue;
|
||||||
extern p_instr *OO_nxtifree;
|
extern p_instr *OO_nxtifree;
|
||||||
|
|
|
@ -175,16 +175,20 @@ loc 1 mlu w :
|
||||||
ldc 1 mlu 2*w :
|
ldc 1 mlu 2*w :
|
||||||
loc 1 sbi w : dec
|
loc 1 sbi w : dec
|
||||||
loc loe mli w : loe $2 loc $1 mli w
|
loc loe mli w : loe $2 loc $1 mli w
|
||||||
|
loc loe mlu w : loe $2 loc $1 mlu w
|
||||||
loc loe adi w loc : loe $2 loc $1 adi w loc $4
|
loc loe adi w loc : loe $2 loc $1 adi w loc $4
|
||||||
loc loe adi w inc : loe $2 loc $1 adi w inc
|
loc loe adi w inc : loe $2 loc $1 adi w inc
|
||||||
loc loe adi w dec : loe $2 loc $1 adi w dec
|
loc loe adi w dec : loe $2 loc $1 adi w dec
|
||||||
loc lol mli w : lol $2 loc $1 mli w
|
loc lol mli w : lol $2 loc $1 mli w
|
||||||
|
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 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 inc : lol $2 loc $1 adi w dec
|
||||||
loc lol adi w dec : 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 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 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 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 ldl adi 2*w : ldl $2 ldc $1 adi 2*w
|
||||||
loc 2 mli w : loc 1 sli w
|
loc 2 mli w : loc 1 sli w
|
||||||
loc 4 mli w : loc 2 sli w
|
loc 4 mli w : loc 2 sli w
|
||||||
|
@ -407,6 +411,8 @@ loi 1 loc 1 loc w cii loc cmi w zne ? $5>=0&&$5<128 : loi 1 loc $5 cmi w zne
|
||||||
loi 1 loc 1 loc w cii loc w loc w ciu loc 255 and w: loi 1
|
loi 1 loc 1 loc w cii loc w loc w ciu loc 255 and w: loi 1
|
||||||
cmp teq : cms p teq
|
cmp teq : cms p teq
|
||||||
cmp tne : cms p tne
|
cmp tne : cms p tne
|
||||||
|
cmp zeq : cms p zeq $2
|
||||||
|
cmp zne : cms p zne $2
|
||||||
cmu defined teq : cms $1 teq
|
cmu defined teq : cms $1 teq
|
||||||
cmu defined tne : cms $1 tne
|
cmu defined tne : cms $1 tne
|
||||||
cms w zeq : beq $2
|
cms w zeq : beq $2
|
||||||
|
@ -427,6 +433,7 @@ adp dup p sdl adp -$1 ? p==2*w : dup p adp $1 sdl $3
|
||||||
inc dup w ste dec : dup w inc ste $3
|
inc dup w ste dec : dup w inc ste $3
|
||||||
inc dup w stl dec : dup w inc stl $3
|
inc dup w stl dec : dup w inc stl $3
|
||||||
#endif
|
#endif
|
||||||
|
bra lab $1 : lab $2
|
||||||
zeq bra lab $1 : zne $2 lab $1
|
zeq bra lab $1 : zne $2 lab $1
|
||||||
zge bra lab $1: zlt $2 lab $1
|
zge bra lab $1: zlt $2 lab $1
|
||||||
zgt bra lab $1 : zle $2 lab $1
|
zgt bra lab $1 : zle $2 lab $1
|
||||||
|
@ -542,8 +549,8 @@ 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+2*w 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 dup 2 stl loc dup 2 stl :
|
||||||
loc $1 stl $3 loc $4 stl $6 loc $1 loc $4
|
loc $1 stl $3 loc $4 stl $6 loc $1 loc $4
|
||||||
/*LLP LLP adp SLP $2 sti ? (!notreg($2) || $5!=p): */
|
lol lol adp stl $2 sti != p ? p==w : lol $1 sti $5 lol $2 adp $3 stl $4
|
||||||
/* LLP $1 sti $5 LLP $2 adp $3 SLP $4 */
|
ldl ldl adp sdl $2 sti != p ? p==2*w : 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
|
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==2*w : lde $1 sti $5 lde $2 adp $3 sde $4
|
||||||
#ifndef INT
|
#ifndef INT
|
||||||
|
|
Loading…
Reference in a new issue