1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
.\"Text automatically generated by txt2man
.TH copt 1 "01 December 2009" "" "z88 Development Kit"
.SH NAME
\fBcopt \fP- peephole optimizer
.SH SYSNOPIS
copt file \.\.\.
.SH DESCRIPTION
copt is a general-purpose peephole optimizer. It reads
code from its standard input and writes an improved version to its standard output.
copy reads the named files for its optimizations, which are encoded as follows:
.PP
.nf
.fam C
<pattern for input line 1>
<pattern for input line 2>
\.\.\.
<pattern for input line n>
=
<pattern for output line 1>
<pattern for output line 2>
\.\.\.
<pattern for output line m>
<blank line>
.fam T
.fi
Pattern matching uses literal string comparison, with one
exception: ``%%'' matches the ``%'' character, and ``%''
followed by a digit matches everything up to the next
occurrence of the next pattern character, though all
occurrences of %\fIn\fP must denote the same string. For example,
the pattern ``%1=%1.'' matches exactly those strings
that begin with a string X, followed by a ``='' (the
first), followed by a second occurrence of X, followed by
a period. In this way, the input/output pattern
.PP
.nf
.fam C
mov $%1,r%2
mov *r%2,r%2
=
mov %1,r%2
.fam T
.fi
commands copt to replace runs like
.PP
.nf
.fam C
mov $_a,r3
mov *r3,r3
.fam T
.fi
with
.PP
.nf
.fam C
mov _a,r3
.fam T
.fi
Note that a tab or newline can terminate a %\fBn\fP variable.
.PP
copt compares each run of input patterns with the current
input instruction and its predecessors. If no match is
found, it advances to the next input instruction and tries
again. Otherwise, it replaces the input instructions with
the corresponding output patterns, pattern variables
instantiated,and resumes its search with the \fIfirst\fP
instruction of the replacement. copt matches input patterns
in reverse order to cascade optimizations without
backing up.
.SH BUGS
Errors in optimization files are always possible.
.SH SEE ALSO
\fBz88dk\fP(1), \fBz88dk-zcc\fP(1), \fBz88dk-z80asm\fP(1), \fBz88dk-appmake\fP(1), \fBz88dk-copt\fP(1).
.SH AUTHOR
z88dk was written by Dominic Morris <dom@z88dk.org>, and others.
|