-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathpeeprules.vmg
418 lines (395 loc) · 13.1 KB
/
peeprules.vmg
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
\ Gforth superinstructions and stack caching replicas
\ Authors: Anton Ertl, Bernd Paysan
\ Copyright (C) 2003,2004,2005,2007,2010,2012,2013,2015,2016,2019,2020,2022,2023,2024 Free Software Foundation, Inc.
\ This file is part of Gforth.
\ Gforth is free software; you can redistribute it and/or
\ modify it under the terms of the GNU General Public License
\ as published by the Free Software Foundation, either version 3
\ of the License, or (at your option) any later version.
\ This program is distributed in the hope that it will be useful,
\ but WITHOUT ANY WARRANTY; without even the implied warranty of
\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\ GNU General Public License for more details.
\ You should have received a copy of the GNU General Public License
\ along with this program. If not, see http://www.gnu.org/licenses/.
\ taken from David Gregg's EuroForth 2001 paper; omitted some sequences
\ eliminated for gforth-native:
\ 1) sequences containing call
\ 2) sequences with immediate arguments not in the first position
\ no new prim-nums for supers and state-replicas
\E ' noop is output-c-prim-num
\ super1 = lit +
\ super2 = lit call
\ super3 = lit @
\ super4 = lit @ call
\ super5 = @ call
\ super6 = lit !
\ super7 = lit lit
\ super8 = dup lit
\ super9 = ! lit
\ super10 = lit ! lit
\ super11 = ! ;s
\ super12 = lit + @
\ super14 = dup call
\ super15 = useraddr @
\ super16 = + @
\ super17 = lit @ ?branch
\ super18 = lit ! ;s
\ super19 = lit@ and
\ super21 = lit lit !
\ super22 = @ ?branch
\ super23 = useraddr !
\ super24 = dup ?branch
\ super25 = @ ;s
\ super26 = lit@ +
\ super27 = dup @
\ super28 = lit execute \ currently not supported
\ super29 = o+ @
\ super30 = o+ ! \ doesn't get selected
\ super31 = lit f@
\ super32 = lit f!
\ super33 = noop flit
\ super34 = lit+ @
super35 = f@ f*
super36 = f@ f+
\ super37 = lit and
\ super38 = lit arshift
\ super39 = dup lit and swap
super40 = >l >l
super40a = >l >l >l
super40b = >l >l >l >l
super40c = f>l f>l
super40d = >l @local0
super40e = f>l lit f@localn
super41 = dup >r
\ compare-and-branch; comment them out if we take up work on gforth-native again
cb1 = 0< ?branch
cb2 = 0<= ?branch
cb3 = 0<> ?branch
cb4 = 0= ?branch
cb5 = 0> ?branch
cb6 = 0>= ?branch
cb7 = < ?branch
cb8 = <= ?branch
cb9 = <> ?branch
cb10 = = ?branch
cb11 = > ?branch
cb12 = >= ?branch
cb13 = d0= ?branch
cb14 = d< ?branch
cb15 = d= ?branch
cb16 = f< ?branch
cb17 = f= ?branch
cb18 = u< ?branch
cb19 = u<= ?branch
cb20 = u> ?branch
cb21 = u>= ?branch
cb22 = within ?branch
\ branch-to-ip variants of compare-and-branch
\E 1 to branch-to-ip
\E cr ." #undef SET_IP"
\E cr ." #define SET_IP(x)" cr
cb1a = 0< ?branch
cb2a = 0<= ?branch
cb3a = 0<> ?branch
cb4a = 0= ?branch
cb5a = 0> ?branch
cb6a = 0>= ?branch
cb7a = < ?branch
cb8a = <= ?branch
cb9a = <> ?branch
cb10a = = ?branch
cb11a = > ?branch
cb12a = >= ?branch
cb13a = d0= ?branch
cb14a = d< ?branch
cb15a = d= ?branch
cb16a = f< ?branch
cb17a = f= ?branch
cb18a = u< ?branch
cb19a = u<= ?branch
cb20a = u> ?branch
cb21a = u>= ?branch
cb22a = within ?branch
\E cr ." #undef SET_IP"
\E cr ." # define SET_IP(p) do {ip=(p); NEXT_P0;} while(0)" cr
\E 0 to branch-to-ip
\ memory access combinations
cscfetch = c@ c>s
cswfetch = w@ w>s
cslfetch = l@ l>s
swapwfetch = w@ w><
swaplfetch = l@ l><
\ cswapxfatch = x@ x>< \ only on 64 bits
csswapwfetch = w@ w>< w>s
csswaplfetch = l@ l>< l>s
torrfrom = >r r>
csswapwstore = >r w>< r> w!
csswaplstore = >r l>< r> l!
\F 0 [if]
\ \E prim-states ;s \ 2950159
\ \E prim-states lit \ 2802835
\E prim-states-offsets lit \ 2802835
\E S1 S1 state-offset-prim call \ 2558373
\E prim-states @ \ 2244351
\E S2 S1 state-offset-prim ?branch \ 1134432
\E S2 state-enabled? 0= [if] S1 S1 state-offset-prim ?branch [then] \ 1134432
\E prim-states-offsets lit@ \ 1051813
\E prim-states swap \ 737988
\E S0 S2 state-prim swap
\E S1 S2 state-prim swap
\E S2 S1 state-prim swap
\E S2 S3 state-prim swap
\E S3 S2 state-prim swap
\E S2 S0 state-prim swap
\E prim-states c@ \ 651406
\E prim-states = \ 590006
\E prim-states 0= \ 584487
\E prim-states dup \ 566855
\E S0 S1 state-prim dup
\E S1 S1 state-prim dup
\E prim-states + \ 566003
\E prim-states under+ \ 154
\E S2 S1 state-prim under+
\E S1 S0 state-prim under+
\E prim-states i \ 502908
\E prim-states +! \ 448925
\E prim-states !@
\E prim-states +!@
\E S1 S1 state-offset-prim branch \ 409561
\E S1 S1 state-offset-prim (loop) \ 379646
\ \E prim-states lp! \ 326743
\E prim-states and \ 309427
\ \E prim-states useraddr \ 303254
\E prim-states over \ 283556
\E S0 S1 state-prim over
\E S1 S2 state-prim over
\E S2 S1 state-prim over
\E S3 S2 state-prim over
\E S0 S1 state-prim third
\E S1 S2 state-prim third
\E S2 S3 state-prim third
\E S3 S1 state-prim third
\E S0 S1 state-prim fourth
\E S1 S2 state-prim fourth
\E S2 S3 state-prim fourth
\E prim-states negate \ 257417
\E prim-states cells \ 254644
\E prim-states rot \ 220273
\E S3 S1 state-prim rot
\E S2 S3 state-prim rot
\E S1 S3 state-prim rot
\E S0 S3 state-prim rot
\E S4 S2 state-prim rot
\E S5 S3 state-prim rot
\E prim-states ! \ 218672
\E prim-states 2dup \ 211315
\E S0 S1 state-prim 2dup
\E S0 S2 state-prim 2dup
\E S1 S3 state-prim 2dup
\E S2 S2 state-prim 2dup
\E S3 S1 state-prim 2dup
\E S4 S4 state-prim 2dup
\E S4 S2 state-prim 2dup
\E S1 S1 state-offset-prim lit-perform \ 188331
\E prim-states <> \ 179502
\E prim-states c! \ 179332
\E S1 S1 state-offset-prim lit+ \ 179156
\E prim-states-offsets lit+ \ 179156
\E prim-states drop \ 173995
\E S0 S0 state-prim drop
\E prim-states lshift \ 164671
\E prim-states rshift
\E prim-states arshift
\ \E prim-states /modf \ 164670
\ \E prim-states /mods
\E prim-states >r \ 145247
\E prim-states r> \ 133792
\ \E S1 S1 state-offset-prim does-xt \ 120944 \ new DOES, reduces executions
\E prim-states cell+ \ 116183
\E prim-states lp+! \ 106697 \ --
\E prim-states - \ 106245
\E prim-states unloop \ 98938 \ --
\E prim-states lp+ \ 87190 \ --
\E prim-states >= \ 80994
\E prim-states tuck \ 78696
\E S2 S2 state-prim tuck
\E S3 S3 state-prim tuck
\E prim-states /string \ 78595
\E prim-states char+ \ 77542
\E prim-states ?dup \ 76850
\E prim-states @localn \ 75322
\E prim-states lp+n \ 75322
forlocal(`7',`\E prim-states @local%i \ 75322')
\E prim-states !localn
forlocal(`7',`\E prim-states !local%i')
\E prim-states +!localn
\E prim-states f@localn
\E prim-states o
\E prim-states o+
forlocal(`31',`\E prim-states o%i')
forlocal(`15',`\E prim-states !o%i')
forlocal(`15',`\E prim-states @o%i')
\E prim-states min \ 75264
\ \E prim-states compare \ 65603
\E branch-states (u+do) \ 63823
\ \E prim-states (read-line) \ 63823
\E prim-states 2>r \ 62646
\E prim-states 2r> \ 62644
\E prim-states 2r@ \ 61338
\E prim-states 2@ \ 61067
\E prim-states nip \ 54961
\E S1 S1 state-prim nip
\E S0 S1 state-prim nip
\E S2 S2 state-prim nip
\E prim-states within \ 51075
\E prim-states 1- \ 47441
\E branch-states execute \ 46674
\ if you add more variants of execute-;s, also add them to ip_dead (main.c)
\E S2 S1 state-prim execute-;s
\E prim-states lp- \ 45385
\E branch-states perform \ 38756
\E prim-states xor \ 35599
\ \E prim-states pick \ 32015
\E prim-states u> \ 29373
\E prim-states -rot \ 26211
\E S3 S2 state-prim -rot
\E S1 S3 state-prim -rot
\E S4 S3 state-prim -rot
\E S2 S4 state-prim -rot
\E S3 S5 state-prim -rot
\E prim-states 2drop \ 25418
\E S0 S0 state-prim 2drop
\E S1 S0 state-prim 2drop
\ \E prim-states (tablelfind) \ 22243
\E prim-states or \ 21587
\E prim-states @local2 \ 20859
\E S2 S1 state-prim (+loop) \ 20006
\E S2 S1 state-prim (/loop) \ 20006
\E prim-states 1+ \ 17944
\E prim-states rdrop \ 17902
\E branch-states (?do) \ 17348
\E prim-states max \ 16948
\E prim-states 2* \ 15606
\ \E prim-states filename-match \ 15003
\ \E prim-states (listlfind) \ 13074
\ \E prim-states sp@ \ 12741
\ \E prim-states fp@ \ 12384
\ \E prim-states um/mod \ 12288
\E prim-states 2! \ 11904
\ \E prim-states fill \ 10781
\ \E prim-states (parse-white) \ 10624
\E branch-states (do) \ 10516
\ \E prim-states (hashkey1) \ 10239
\E prim-states u< \ 9602
\ \E prim-states write-file \ 8973
\E prim-states count \ 8873
\ \E prim-states rp@ \ 8410
\E prim-states 0< \ 8380
\E prim-states < \ 7741
\ \E prim-states move \ 7050
\E prim-states u>= \ 6138
\E branch-states (+do) \ 5863
\ \E prim-states va-return-double \ 5517
\E prim-states um* \ 5342
\ \E prim-states toupper \ 3517
\ \E prim-states rp! \ 2859
\ \E prim-states ?dup-?branch \ 2829
\E prim-states d+ \ 2671
\ \E prim-states ftuck \ 2636
\ \E prim-states read-file \ 2623
\ \E prim-states ms \ 2454
\ \E prim-states (s+loop) \ 2429
\ \E prim-states allocate \ 1869
\E prim-states * \ 1520
\E prim-states 0<> \ 925
\ \E prim-states noop \ 715
\E prim-states aligned \ 714
\E prim-states u<= \ 684
\E prim-states i' \ 684
\E prim-states delta-i
\E prim-states bounds
\E prim-states > \ 411
\ \E prim-states (hashlfind) \ 397
\E prim-states 2swap \ 336
\E S0 S3 state-prim 2swap
\E S1 S3 state-prim 2swap
\E S2 S4 state-prim 2swap
\E S4 S2 state-prim 2swap
\E prim-states lp@ \ 335
\ \E prim-states faxpy \ 286
\ \E prim-states (next) \ 272
\ \E prim-states (-loop)-lp+!# \ 248
\E prim-states <= \ 199
\E prim-states invert \ 170
\E branch-states (-do) \ 169
\E prim-states 2over \ 165
\E S0 S2 state-prim 2over
\E S1 S3 state-prim 2over
\E S2 S4 state-prim 2over
\E S3 S5 state-prim 2over
\E S4 S2 state-prim 2over
\E S5 S3 state-prim 2over
\E S6 S4 state-prim 2over
\E prim-states dnegate \ 128
\E prim-states u<> \ 128
\E prim-states 0> \ 122
\ \E prim-states (loop)-lp+!# \ 118
\E prim-states j \ 117
\E prim-states float+ \ 78
\ \E prim-states (for) \ 68
\E prim-states 2rdrop \ 60 \ --
\E prim-states f@
\E prim-states f+
\E prim-states f*
\E prim-states f! \ 14
\E prim-states >l \ 14
\ \E prim-states close-file \ 5
\ \E prim-states call-c \ 4
\ \E prim-states reposition-file \ 3
\ \E prim-states /f \ 3
\ \E prim-states /s
\ \E prim-states modf
\ \E prim-states mods
\ \E prim-states resize-file \ 2
\ \E prim-states free \ 2
\E prim-states 2/ \ 2
\ \E prim-states up! \ 1
\ \E prim-states stdin \ 1
\ \E prim-states key?-file \ 1
\ \E prim-states flush-icache \ 1
\ \E prim-states cmove \ 1
\ \E prim-states (system) \ 1
\E S0 S0 state-prim abi-call
\E S0 S0 state-prim ;abi-code-exec
\E prim-states w!
\E prim-states l!
\ \E prim-states x!
\E prim-states w><
\E prim-states l><
\ \E prim-states x><
\E prim-states o
\E prim-states up@
\E gen-ip-updates noop
\E ' noop is ip-update
\E ' noop is output-nextp0
\E ' noop is output-nextp1
\E gen-transitions noop
\ now the branch-to-ip conditional branches;
\E 1 to branch-to-ip
\E cr ." #undef SET_IP"
\E cr ." #define SET_IP(x)" cr
\E S1 S1 s" ?branch" lookup-prim state-prim2
\E S2 S1 state-prim ?branch
\E S1 S1 s" (next)" lookup-prim state-prim2
\E S1 S1 s" (loop)" lookup-prim state-prim2 \ 379646
\E S1 S1 s" (+loop)" lookup-prim state-prim2
\E S2 S1 state-prim (+loop) \ 20006
\ \E S2 S1 state-prim (-loop)
\E S1 S1 s" (/loop)" lookup-prim state-prim2
\E S2 S1 state-prim (/loop)
\ \E S2 S1 state-prim (s+loop)
\E cr ." #undef SET_IP"
\E cr ." # define SET_IP(p) do {ip=(p); NEXT_P0;} while(0)" cr
\E 0 to branch-to-ip
\F [ENDIF]