Pristine Ack-5.5
[Ack-5.5.git] / mach / ns / ncg / table
1 rcsid = "$Id: table,v 1.15 1994/06/24 13:10:20 ceriel Exp $"
2
3 /*****************************************************************
4  *                                                               *
5  *       N S  1 6 0 3 2    B A C K - E N D  T A B L E            *
6  *                                                               *
7  *                                                               *
8  *      Author: Annita Wilschut.                                 *
9  *                                                               *
10  *      Corrections: Nigel Hall                                  *
11  *                                                               *
12  *****************************************************************/
13
14 /* The handling of arrays was not complete.  Tables extended
15  * in order to handle access to other lexical levels between
16  * local and global.  Corrections to ordering of tokens made.
17  *
18  * The token length was added to cope with the length field
19  * of MOVMi instructions.  The lengths adjusted by division by 4.
20  *
21  * The compare procedures did not return a result.  Caused
22  * an extra word to be popped off the stack. The "cmi txx ior" &
23  * "txx and" sequences needed their branch criterion inverting.
24  *
25  */
26
27 /*
28  * Deze tabel implementeert, naast gewone, ook floating point
29  * instructies. Bij gebrek aan een floating point processor
30  * is het betreffende onderdeel van de tabel echter niet
31  * getest. Wanneer NOFLOAT "aan" is worden er zeker geen
32  * floating point instructies gegenereerd. Na verwijdering van
33  * alle ifdef's worden er bij de vertaling van een programma dat
34  * geen floating point gebruikt, hoogst waarschijnlijk ook
35  * geen floating point instructies gegenereerd. Dit is echter niet
36  * uitgebreid getest.
37  */
38
39 EM_WSIZE=4
40 EM_PSIZE=4
41 EM_BSIZE=8
42
43 #define NOFLOAT
44
45 PROPERTIES
46
47 REG                     /* Normal registers */
48 FREG                    /* Floating point registers */
49 DFREG(8)                /* double floating reg for double precision */
50 MEMREG                  /* sp, fp en sb */
51 REGPAIR(8)              /* register pair for extended integer instr */
52 PROGRAMCOUNTER
53 STACKPOINTER
54 STATICBASE
55 LOCALBASE
56 PROCREG                 /* processor register - used by LPRi & SPRi */
57
58
59 REGISTERS
60
61 r0,r1,r2,r3             : REG.
62 r7,r4,r5,r6             : REG regvar .
63 f0,f1,f2,f3,f4,f5,f6,f7         : FREG.
64 f01("f0")=f0+f1,
65 f23("f2")=f2+f3,
66 f45("f4")=f4+f5,
67 f67("f6")=f6+f7                 : DFREG.
68 r01("r0")=r0+r1,r23("r2")=r2+r3 : REGPAIR.
69 sp                              : STACKPOINTER, MEMREG, PROCREG.
70 pc                              : PROGRAMCOUNTER.
71 fp                              : LOCALBASE, MEMREG, PROCREG.
72 sb                              : STATICBASE, MEMREG, PROCREG.
73
74
75 TOKENS
76
77 const4          = { INT num; } 4 num .
78 LOCAL           = { INT ind;}  4 ind "(fp)" .
79 DLOCAL          = { INT ind;} 8 ind "(fp)".
80
81
82 addr_local      = { INT ind; } 4 .
83 addr_external   = { ADDR disp; } 4 disp .
84
85 regrel1         = { REG reg; ADDR disp; } 4 disp "(" reg ")" .
86 regrel2         = { REG reg; ADDR disp; } 4 disp "(" reg ")" .
87 regrel4         = { REG reg; ADDR disp; } 4 disp "(" reg ")" .
88 regrel8         = { REG reg; ADDR disp; } 8 disp "(" reg ")" .
89 memregrel1      = { MEMREG reg; ADDR disp; } 4 disp "(" reg ")" .
90 memregrel2      = { MEMREG reg; ADDR disp; } 4 disp "(" reg ")" .
91 memregrel4      = { MEMREG reg; ADDR disp; } 4 disp "(" reg ")" .
92 memregrel8      = { MEMREG reg; ADDR disp; } 8 disp "(" reg ")" .
93 memrel1         = { MEMREG reg; ADDR disp1; ADDR disp2; } 4 disp2 "("
94                         disp1 "(" reg "))" .
95 memrel2         = { MEMREG reg; ADDR disp1; ADDR disp2; } 4 disp2 "("
96                         disp1 "(" reg "))" .
97 memrel4         = { MEMREG reg; ADDR disp1; ADDR disp2; } 4 disp2 "("
98                         disp1 "(" reg "))" .
99 memrel8         = { MEMREG reg; ADDR disp1; ADDR disp2; } 8 disp2 "("
100                         disp1 "(" reg "))" .
101 absolute1       = { ADDR disp; } 4 "@" disp .
102 absolute2       = { ADDR disp; } 4 "@" disp .
103 absolute4       = { ADDR disp; } 4 "@" disp .
104 absolute8       = { ADDR disp; } 8 "@" disp .
105 TOS             = {} 4 "tos" .
106
107 regcon4         = { REG reg; ADDR disp; } 4 .
108 memregcon4      = { MEMREG reg; ADDR disp; } 4 .
109 memregrelcon4   = { MEMREG reg; ADDR disp1; ADDR disp2;} 4 .
110
111 label           = {ADDR disp; } 4 disp .
112
113 regrelsid       = {INT ind; REG reg1; REG reg2; } 4 ind "(" reg1
114                         ")[" reg2 ":d]" .
115 memregrelsid    = {INT ind; MEMREG reg1; REG reg2; } 4 ind "(" reg1
116                         ")[" reg2 ":d]" .
117 abssid          = {ADDR disp; REG reg; } 4 "@" disp "[" reg ":d]" .
118 fprelsid        = {ADDR disp1; ADDR disp2; REG reg; } 4
119                         disp2 "(" disp1 "(fp))[" reg ":d]" .
120 sprelsid        = {ADDR disp1; ADDR disp2; REG reg; } 4
121                         disp2 "(" disp1 "(sp))[" reg ":d]" .
122
123 SETS
124
125 src1            = regrel1 + memregrel1 + memrel1 + absolute1 .
126 src2            = regrel2 + memregrel2 + memrel2 + absolute2 .
127 src4            = REG + const4 + LOCAL + regrel4 + memrel4 +
128                   memregrel4 + regrelsid + memregrelsid + abssid + absolute4 +
129                   addr_external.
130 con4            = regcon4 + memregcon4 + memregrelcon4 .
131 tossrc4         = TOS + src4 .
132 consrc4         = con4 + src4 .
133 fsrc4           = FREG + LOCAL + regrel4 + memrel4 +
134                   memregrel4 + memregrelsid + abssid + absolute4 .
135 tosfsrc4        = TOS + fsrc4 .
136 fsrc8           = DFREG + DLOCAL + regrel8 + memrel8 +
137                   memregrel8 + absolute8 .
138 tosfsrc8        = TOS + fsrc8 .
139 dst1            = src1 .
140 tosdst1         = TOS + dst1 .
141 dst2            = src2 .
142 tosdst2         = TOS + dst2 .
143 dst4            = REG + LOCAL + regrel4 + memregrel4 + memrel4 +
144                   absolute4 + regrelsid + memregrelsid + abssid .
145 tosdst4         = TOS + dst4 .
146 fdst4           = FREG + LOCAL + regrel4 + memregrel4 + memrel4 +
147                   absolute4 + regrelsid + memregrelsid + abssid .
148 tosfdst4        = TOS + fdst4 .
149 fdst8           = fsrc8 .
150 tosfdst8        = tosfsrc8 .
151 regrel          = regrel1 + regrel2 + regrel4 +regrel8 .
152 memregrel       = memregrel1 + memregrel2 + memregrel4 +memregrel8 .
153 memrel          = memrel1 + memrel2 + memrel4 +memrel8 .
154 rel             = regrel + memregrel + memrel + regrelsid + memregrelsid
155                    + fprelsid + sprelsid .
156 absolute        = absolute1 + absolute2 + absolute4 + absolute8 + abssid .
157 regs            = REG + FREG + DFREG + MEMREG + REGPAIR .
158 allmincon       = ALL - (regs + const4 + addr_local + addr_external
159                   + regcon4 + memregcon4) .
160 src24           = src2 + src4 .
161 src124          = src1 + src2 + src4 .
162 tossrc24        = TOS + src24 .
163 tossrc124       = TOS + src124 .
164
165
166 INSTRUCTIONS
167
168
169 movb tossrc124:ro, tosdst1:wo .
170 movw tossrc24:ro, tosdst2:wo .
171 movd tossrc4:ro, tosdst4:wo .
172 movf tosfsrc4:ro, tosfdst4:wo .
173 movl tosfsrc8:ro, tosfdst8:wo .
174 movdf tossrc4:ro, tosfdst4:wo .
175 movdl tossrc4:ro, tosfdst8:wo .
176 movfl tosfsrc4:ro, tosfdst8:wo .
177 movlf tosfsrc8:ro, tosfdst4:wo .
178 truncfd tosfsrc4:ro, tosdst4:wo .
179 truncld tosfsrc8:ro, tosdst4:wo .
180 cmpb tossrc124:ro, src1:ro .
181 cmpw tossrc24:ro, src2:ro .
182 cmpd tossrc4:ro, tossrc4:ro .
183 cmpf tosfsrc4:ro, tosfsrc4:ro .
184 cmpl tosfsrc8:ro, tosfsrc8:ro .
185 addd tossrc4:ro, tosdst4:rw .
186 addcd tossrc4:ro, tosdst4:rw .
187 addf tosfsrc4:ro, tosfdst4:rw .
188 addl tosfsrc8:ro, tosfdst8:rw .
189 subd tossrc4:ro, tosdst4:rw .
190 subcd tossrc4:ro, tosdst4:rw .
191 subf tosfsrc4:ro, tosfdst4:rw .
192 subl tosfsrc8:ro, tosfdst8:rw .
193 muld tossrc4:ro, tosdst4:rw .
194 mulf tosfsrc4:ro, tosfdst4:rw .
195 mull tosfsrc8:ro, tosfdst8:rw .
196 quod tossrc4:ro, tosdst4:rw .
197 divd tossrc4:ro, tosdst4:rw .
198 divf tosfsrc4:ro, tosfdst4:rw .
199 divl tosfsrc8:ro, tosfdst8:rw .
200 remd tossrc4:ro, tosdst4:rw .
201 modd tossrc4:ro, tosdst4:rw .
202 negd tossrc4:ro, tosdst4:wo .
203 negf tosfsrc4:ro, tosfdst4:wo .
204 negl tosfsrc8:ro, tosfdst8:wo .
205 roundfd tosfsrc4:ro, tosdst4:wo .
206 roundld tosfsrc8:ro, tosdst4:wo .
207 andd tossrc4:ro, tosdst4:wo .
208 ord tossrc4:ro, tosdst4:wo .
209 xord tossrc4:ro, tosdst4:rw .
210 comd tossrc4:ro, tosdst4:rw .
211 ashd tossrc124:ro, tosdst4:rw .
212 lshd tossrc124:ro, tosdst4:rw .
213 rotd tossrc124:ro, tosdst4:rw .
214 movzbd tossrc124:ro, tosdst4:wo .
215 movzwd tossrc24:ro, tosdst4:wo .
216 movxbd tossrc124:ro, tosdst4:wo .
217 movxwd tossrc124:ro, tosdst4:wo .
218 addr tosdst4:ro, tosdst4:wo .
219 movqd const4:ro, tosdst4:wo .
220 cmpqd const4:ro, tossrc4:ro .
221 meid tossrc4:ro, REGPAIR:rw .
222 sxx tosdst4:wo .
223 seqd tosdst4:wo .
224 sned tosdst4:wo .
225 sltd tosdst4:wo .
226 sled tosdst4:wo .
227 sgtd tosdst4:wo .
228 sged tosdst4:wo .
229 shid tosdst4:wo .
230 sfsd tosdst4:wo .
231 tbitd tossrc4:ro, tosdst4:ro .
232 cbitd tossrc4:ro, tosdst4:rw .
233 sbitd tossrc4:ro, tosdst4:rw .
234 movmd tossrc4:ro, tosdst4:rw, const4 .
235 indexd REG, tossrc4:ro, tossrc4:ro .
236 brxx label .
237 beq label .
238 bne label .
239 ble label .
240 blt label .
241 bge label .
242 bgt label .
243 bfc label .
244 bfs label .
245 blo label .
246 bls label .
247 bhs label .
248 bhi label .
249 br label .
250 acbd const4:ro, tosdst4:rw, label .
251 jsr tosdst4+label .
252 ret const4:ro .
253 adjspd tossrc4:ro .
254 exit label .
255 lprd PROCREG:rw, tossrc4:ro .
256 sprd PROCREG:ro, tossrc4:rw .
257
258
259
260 MOVES
261
262
263 from memregrelcon4 to tosdst4
264 gen addr {memrel4, %1.reg, %1.disp1, %1.disp2}, %2
265
266 from regcon4 to tosdst4
267 gen addr {regrel4, %1.reg, %1.disp}, %2
268
269 from memregcon4 to tosdst4
270 gen addr {memregrel4, %1.reg, %1.disp}, %2
271
272 from tossrc4 to tosdst4
273 gen movd %1, %2
274
275 from tossrc124 to tosdst1
276 gen movb %1, %2
277
278 from tossrc24 to tosdst2
279 gen movw %1, %2
280
281 #ifndef NOFLOAT
282 from tosfsrc4 to FREG
283 gen movf %1, %2
284
285 from FREG to tosfdst4
286 gen movf %1, %2
287
288 from tosfsrc8 to DFREG
289 gen movl %1, %2
290
291 from DFREG to tosfdst8
292 gen movl %1, %2
293 #endif
294
295
296 STACKINGRULES
297
298
299 from src1 to STACK
300 gen movzbd %1, {TOS}
301
302 from src2 to STACK
303 gen movzwd %1, {TOS}
304
305 from src4 to STACK
306 gen movd %1, {TOS}
307
308 #ifndef NOFLOAT
309 from FREG to STACK
310 gen movf %1, {TOS}
311
312 from DFREG to STACK
313 gen movl %1, {TOS}
314 #endif
315
316 from MEMREG to STACK
317 gen addr {memregrel4, %1, 0}, {TOS}
318
319 from addr_local to STACK
320 gen addr {memregrel4, fp, %1.ind}, {TOS}
321
322 from regcon4 to STACK
323 gen addr {regrel4, %1.reg, %1.disp}, {TOS}
324
325 from memregcon4 to STACK
326 gen addr {memregrel4, %1.reg, %1.disp}, {TOS}
327
328 from memregrelcon4 to STACK
329 gen addr {memrel4, %1.reg, %1.disp1, %1.disp2}, {TOS}
330
331 from DLOCAL to STACK
332 gen movd {LOCAL,  %1.ind+4}, {TOS}
333     movd {LOCAL, %1.ind}, {TOS}
334
335 from absolute8 to STACK
336 gen movd {absolute4, %1.disp+4}, {TOS}
337     movd {absolute4, %1.disp}, {TOS}
338
339 from memrel8 to STACK
340 gen movd {memrel4, %1.reg, %1.disp1, %1.disp2+4}, {TOS}
341     movd {memrel4, %1.reg, %1.disp1, %1.disp2}, {TOS}
342
343 from regrel8 to STACK
344 gen movd {regrel4, %1.reg, %1.disp+4}, {TOS}
345     movd {regrel4, %1.reg, %1.disp}, {TOS}
346
347 from memregrel8 to STACK
348 gen movd {memregrel4, %1.reg, %1.disp+4}, {TOS}
349     movd {memregrel4, %1.reg, %1.disp}, {TOS}
350
351 COERCIONS
352
353
354 from STACK
355 uses REG
356 gen move {TOS}, %a                      yields %a
357
358 #ifndef NOFLOAT
359 from STACK
360 uses FREG
361 gen move {TOS}, %a                      yields %a
362
363 from STACK
364 uses DFREG
365 gen move {TOS}, %a                      yields %a
366 #endif
367
368 from STACK
369 uses REG
370 gen move {TOS}, %a                      yields {regcon4, %a, 0}
371
372 from MEMREG                             yields {memregcon4, %1, 0}
373
374 from MEMREG
375 uses REG
376 gen addr {memregrel4, %1, 0}, %a        yields %a
377
378 from REG                                yields {regcon4, %1, 0}
379
380 from regcon4
381 gen addr {regrel4, %1.reg, %1.disp}, %1.reg
382                                         yields %1.reg
383
384 from memregcon4
385 uses REG
386 gen addr {memregrel4, %1.reg, %1.disp}, %a
387                                         yields %a
388
389 from LOCAL                              yields {memregrel4, fp, %1.ind}
390
391 from addr_local
392 uses REG
393 gen addr {LOCAL, %1.ind}, %a            yields %a
394
395 from src4
396 uses reusing %1, REG=%1                 yields %a
397
398 from src4
399 uses reusing %1, REG=%1                 yields {regcon4, %a, 0}
400
401 from memregrelcon4
402 uses REG
403 gen addr {memrel4, %1.reg, %1.disp1, %1.disp2}, %a
404                                         yields %a
405
406 from memregrel4                         yields {memregrelcon4, %1.reg,
407                                                     %1.disp, 0}
408
409 from src1
410 uses REG
411     gen movzbd %1, %a                   yields %a
412
413 from src2
414 uses REG
415     gen movzwd %1, %a                   yields %a
416
417 from DLOCAL                             yields {LOCAL, %1.ind+4}
418                                                {LOCAL, %1.ind}
419
420 from absolute8                          yields {absolute4, %1.disp+4}
421                                                {absolute4, %1.disp}
422
423 from memrel8                            yields {memrel4, %1.reg,
424                                         %1.disp1, %1.disp1+4}
425                                                {memrel4, %1.reg,
426                                         %1.disp1, %1.disp1}
427
428 from regrel8                            yields {regrel4, %1.reg, %1.disp+4}
429                                                {regrel4, %1.reg, %1.disp}
430
431 from memregrel8                         yields {memregrel4, %1.reg, %1.disp+4}
432                                                {memregrel4, %1.reg, %1.disp}
433
434 PATTERNS
435
436 /**********************************************************************
437  * Group1 : load instructions                                         *
438  **********************************************************************/
439
440 pat loc                                 yields {const4, $1}
441
442 pat ldc                                 leaving loc 18
443                                                 trp
444
445 pat lol                                 yields {LOCAL, $1}
446
447 pat loe                                 yields {absolute4, $1}
448
449 pat lil                                 yields {memrel4, fp, $1, 0}
450
451 pat lol lof                             yields {memrel4, fp, $1, $2}
452
453 pat lal lof                             yields {LOCAL, $1+$2}
454
455 pat lae lof                             yields {absolute4, $1+$2}
456
457 pat lof
458 with exact MEMREG                       yields {memregrel4, %1, $1}
459 with REG                                yields {regrel4, %1, $1}
460 with exact addr_external                yields {absolute4, %1.disp+$1}
461 with exact addr_local                   yields {LOCAL, %1.ind+$1}
462 with exact memregrel4                   yields {memrel4, %1.reg,
463                                           %1.disp, $1}
464 with exact memregrelcon4                yields {memrel4, %1.reg,
465                                           %1.disp1, $1+%1.disp2}
466 with exact memregcon4                   yields {memregrel4, %1.reg, %1.disp+$1}
467 with exact regcon4                      yields {regrel4, %1.reg, %1.disp+$1}
468 with exact LOCAL                        yields {memrel4, fp, %1.ind, $1}
469
470 pat lxl $1==0                           yields fp
471
472 pat lxl $1==1                           yields {LOCAL, 8}
473
474 pat lxl $1==2                           yields {memrel4, fp, 8, 8}
475
476 pat lxl $1>2
477     uses REG={memrel4, fp, 8, 8},
478          REG={const4, $1-2}
479     gen 1:
480         move {regrel4, %a, 8}, %a
481         acbd {const4, 0-1}, %b, {label, "1b"}
482                                         yields %a
483
484 pat lxa $1==0                           yields {addr_local, 8}
485
486 pat lxa $1==1                           yields {memregrelcon4, fp, 8, 8}
487
488 pat lxa $1==2
489     uses REG={memrel4, fp, 8, 8}        yields {regcon4, %a, 8}
490
491 pat lxa $1>2
492     uses REG={memrel4, fp, 8, 8},
493          REG={const4, $1-2}
494     gen 1:
495         move {regrel4, %a, 8}, %a
496         acbd {const4, 0-1}, %b, {label, "1b"}
497                                         yields {regcon4, %a, 8}
498
499 pat lol loi $2==1                       yields {memrel1, fp, $1, 0}
500
501 pat lal loi $2==1                       yields {memregrel1, fp, $1}
502
503 pat lae loi $2==1                       yields {absolute1, $1}
504
505 pat lol loi $2==4                       yields {memrel4, fp, $1, 0}
506
507 pat lal loi $2==4                       yields {LOCAL, $1}
508
509 pat lae loi $2==4                       yields {absolute4, $1}
510
511 pat lal                                 yields {addr_local, $1}
512
513 pat lae                                 yields {addr_external, $1}
514
515 pat loi $1==1
516 with exact MEMREG                       yields {memregrel1, %1, 0}
517 with REG                                yields {regrel1, %1, 0}
518 with exact memregcon4                   yields {memregrel1, %1.reg, %1.disp}
519 with exact regcon4                      yields {regrel1, %1.reg, %1.disp}
520 with exact memregrel4                   yields {memrel1, %1.reg, %1.disp, 0}
521 with exact memregrelcon4                yields {memrel1, %1.reg,
522                                           %1.disp1, %1.disp2}
523 with exact addr_local                   yields {memregrel1, fp, %1.ind}
524 with exact addr_external                yields {absolute1, %1.disp}
525 with exact LOCAL                        yields {memrel1, fp, %1.ind, 0}
526
527 pat loi $1==2
528 with exact MEMREG                       yields {memregrel2, %1, 0}
529 with REG                                yields {regrel2, %1, 0}
530 with exact memregcon4                   yields {memregrel2, %1.reg, %1.disp}
531 with exact regcon4                      yields {regrel2, %1.reg, %1.disp}
532 with exact memregrel4                   yields {memrel2, %1.reg, %1.disp, 0}
533 with exact memregrelcon4                yields {memrel2, %1.reg,
534                                           %1.disp1, %1.disp2}
535 with exact addr_local                   yields {memregrel2, fp, %1.ind}
536 with exact addr_external                yields {absolute2, %1.disp}
537 with exact LOCAL                        yields {memrel2, fp, %1.ind, 0}
538
539 pat loi $1==4
540 with exact MEMREG                       yields {memregrel4, %1, 0}
541 with REG                                yields {regrel4, %1, 0}
542 with exact memregcon4                   yields {memregrel4, %1.reg, %1.disp}
543 with exact regcon4                      yields {regrel4, %1.reg, %1.disp}
544 with exact memregrel4                   yields {memrel4,%1.reg,%1.disp,0}
545 with exact memregrelcon4                yields {memrel4, %1.reg,
546                                           %1.disp1,%1.disp2}
547 with exact addr_local                   yields {LOCAL, %1.ind}
548 with exact addr_external                yields {absolute4, %1.disp}
549 with exact LOCAL                        yields {memrel4, fp, %1.ind, 0}
550
551 pat loi $1==8
552 with REG                                yields {regrel8, %1, 0}
553 with exact addr_local                   yields {DLOCAL, %1.ind}
554 with exact addr_external                yields {absolute8, %1.disp}
555 with exact LOCAL                        yields {memrel8, fp, %1.ind, 0}
556
557 pat loi defined($1)
558 with REG STACK
559     uses REG = {const4, $1}
560     gen addd %a, %1
561         1:
562         subd {const4, 4}, %1
563         movd {regrel4, %1, 0}, {TOS}
564         acbd {const4, 0-4}, %a, {label, "1b"}
565
566 pat los $1==4
567 kills ALL
568     gen jsr {absolute4, ".los"}
569
570 pat ldl                                 yields {DLOCAL, $1}
571
572 pat lde                                 yields {absolute8, $1}
573
574 pat ldf
575 with exact addr_local                   yields {DLOCAL, %1.ind+$1}
576 with exact addr_external                yields {absolute8, %1.disp+$1}
577 with regcon4                            yields {regrel8, %1.reg,
578                                                 %1.disp+$1}
579
580 pat lpi                                 yields {addr_external, $1}
581
582
583 /*****************************************************************
584  * Group2 : store instructions                                   *
585  *****************************************************************/
586
587 pat stl
588 with src4 + con4
589 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
590 gen move %1, {LOCAL, $1}
591 with exact STACK
592 gen move {TOS}, {LOCAL, $1}
593 with exact src1
594 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
595 gen movzbd %1, {LOCAL, $1}
596 #ifndef NOFLOAT
597 with FREG
598 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
599 gen move %1, {LOCAL, $1}
600 #endif
601
602 pat ste
603 with src4 + con4
604 kills absolute + rel + memregrelcon4
605 gen move %1, {absolute4, $1}
606 with exact src1
607 kills absolute + rel + memregrelcon4
608 gen movzbd %1, {absolute4, $1}
609 #ifndef NOFLOAT
610 with FREG
611 kills absolute + rel + memregrelcon4
612 gen move %1, {absolute4, $1}
613 #endif
614
615 pat sil
616 with src4 + con4
617 kills allmincon
618 gen move %1, {memrel4, fp, $1, 0}
619 with exact src1
620 kills allmincon
621 gen movzbd %1, {memrel4, fp, $1, 0}
622 #ifndef NOFLOAT
623 with FREG
624 kills allmincon
625 gen move %1, {memrel4, fp, $1, 0}
626 #endif
627
628 pat stf
629 with exact MEMREG src4 + con4
630     kills allmincon
631     gen move %2, {memregrel4, %1, $1}
632 with REG src4 + con4
633     kills allmincon
634     gen move %2, {regrel4, %1, $1}
635 with exact memregcon4 src4 + con4
636     kills allmincon
637     gen move %2, {memregrel4, %1.reg, $1 + %1.disp}
638 with exact regcon4 consrc4
639     kills allmincon
640     gen move %2, {regrel4, %1.reg, $1 + %1.disp}
641 with exact memregrel4 consrc4
642     kills allmincon
643     gen move %2, {memrel4, %1.reg, %1.disp, $1}
644 with exact memregrelcon4 consrc4
645     kills allmincon
646     gen move %2, {memrel4, %1.reg, %1.disp1, %1.disp2 + $1}
647 with exact addr_external consrc4
648     kills allmincon
649     gen move %2, {absolute4, %1.disp + $1}
650 with exact addr_local consrc4
651     kills allmincon
652     gen move %2, {LOCAL,%1.ind + $1}
653 #ifndef NOFLOAT
654 with REG FREG
655     kills allmincon
656     gen move %2, {regrel4, %1, $1}
657 #endif
658
659 pat lal sti $2==4
660 with consrc4
661     kills allmincon
662     gen move %1, {LOCAL, $1}
663
664 pat lae sti $2==4
665 with consrc4
666     kills allmincon
667     gen move %1, {absolute4, $1}
668
669 pat lol sti $2==4
670 with consrc4
671     kills allmincon
672     gen move %1, {memrel4, fp, $1, 0}
673
674 pat lol sti $2==1
675 with src124
676     kills allmincon
677     gen move %1, {memrel1, fp, $1, 0}
678
679 pat sti $1 == 4
680 with exact MEMREG consrc4
681     kills allmincon
682     gen move %2, {memregrel4, %1, 0}
683 with REG consrc4
684     kills allmincon
685     gen move %2, {regrel4, %1, 0}
686 #ifndef NOFLOAT
687 with REG FREG
688     kills allmincon
689     gen movf %2, {regrel4, %1, 0}
690 #endif
691 with exact memregcon4 consrc4
692     kills allmincon
693     gen move %2, {memregrel4, %1.reg, %1.disp}
694 with exact regcon4 consrc4
695     kills allmincon
696     gen move %2, {regrel4, %1.reg, %1.disp}
697 with exact memregrel4 consrc4
698     kills allmincon
699     gen move %2, {memrel4, %1.reg, %1.disp, 0}
700 with exact memregrelcon4 consrc4
701     kills allmincon
702     gen move %2, {memrel4, %1.reg, %1.disp1, %1.disp2}
703 with exact addr_external consrc4
704     kills allmincon
705     gen move %2, {absolute4, %1.disp}
706 with exact addr_local consrc4
707     kills allmincon
708     gen move %2, {LOCAL, %1.ind}
709 with exact LOCAL consrc4
710     kills allmincon
711     gen move %2, {memrel4, fp, %1.ind, 0}
712
713 pat sti $1 == 2
714 with regcon4 src24
715     kills allmincon
716     gen move %2, {regrel2, %1.reg, %1.disp}
717 with exact addr_external src24
718     kills allmincon
719     gen move %2, {absolute2, %1.disp}
720 with exact addr_local src24
721     kills allmincon
722     gen move %2, {memregrel2, fp, %1.ind}
723
724 pat sti $1 == 1
725 with exact MEMREG src124
726     kills allmincon
727     gen move %2, {memregrel1, %1, 0}
728 with REG src124
729     kills allmincon
730     gen move %2, {regrel1, %1, 0}
731 with exact memregcon4 src124
732     kills allmincon
733     gen move %2, {memregrel1, %1.reg, %1.disp}
734 with exact regcon4 src124
735     kills allmincon
736     gen move %2, {regrel1, %1.reg, %1.disp}
737 with exact memregrel4 src124
738     kills allmincon
739     gen move %2, {memrel1, %1.reg, %1.disp, 0}
740 with exact memregrelcon4 src124
741     kills allmincon
742     gen move %2, {memrel1, %1.reg, %1.disp1, %1.disp2}
743 with exact addr_external src124
744     kills allmincon
745     gen move %2, {absolute1, %1.disp}
746 with exact addr_local src124
747     kills allmincon
748     gen move %2, {memregrel1, fp, %1.ind}
749 with exact LOCAL src124
750     kills allmincon
751     gen move %2, {memrel1, fp, %1.ind, 0}
752
753 pat sti $1==8
754 #ifndef NOFLOAT
755 with regcon4 DFREG
756     kills allmincon
757     gen move %2, {regrel8, %1.reg, %1.disp}
758 with exact addr_external DFREG
759     kills allmincon
760     gen move %2, {absolute8, %1.disp}
761 with exact addr_local DFREG
762     kills allmincon
763     gen move %2, {memregrel8, fp, %1.ind}
764 #endif
765 with regcon4 consrc4 consrc4
766     kills allmincon
767     gen move %1, {regrel4, %1.reg, %1.disp}
768         move %2, {regrel4, %1.reg, %1.disp+4}
769
770 pat sti defined($1)
771 with REG
772 kills ALL
773     uses REG={const4, $1}
774     gen 1:
775         movd {TOS}, {regrel4, %1, 0}
776         addr {regrel4, %1, 4}, %1
777         acbd {const4, 0-4}, %a, {label, "1b"}
778
779 pat sts
780 kills ALL
781     gen jsr {absolute4, ".sts"}
782
783 pat sdl
784 with consrc4 consrc4
785 kills rel, LOCAL %ind-8 < $1 && %ind+8 > $1
786 gen move %1, {LOCAL, $1}
787     move %2, {LOCAL, $1+4}
788 #ifndef NOFLOAT
789 with DFREG
790 kills rel, LOCAL %ind-8 < $1 && %ind+8 > $1
791 gen move %1, {DLOCAL, $1}
792 #endif
793
794 pat sde
795 with consrc4 consrc4
796 kills absolute + rel + memregrelcon4
797 gen move %1, {absolute4, $1}
798     move %2, {absolute4, $1+4}
799 #ifndef NOFLOAT
800 with DFREG
801 kills absolute + rel + memregrelcon4
802 gen move %1, {absolute8, $1}
803 #endif
804
805 pat sdf
806 with exact addr_local consrc4 consrc4
807     kills allmincon
808     gen move %2, {LOCAL, %1.ind+$1}
809         move %3, {LOCAL, %1.ind+4+$1}
810 with exact addr_external consrc4 consrc4
811     kills allmincon
812     gen move %2, {absolute4, %1.disp+$1}
813         move %3, {absolute4, %1.disp+4+$1}
814 with  regcon4 consrc4 consrc4
815     kills allmincon
816     gen move %2, {regrel4, %1.reg, %1.disp+$1}
817         move %3, {regrel4, %1.reg, %1.disp+$1+4}
818 #ifndef NOFLOAT
819 with exact addr_local DFREG
820     kills allmincon
821     gen move %2, {DLOCAL, %1.ind+$1}
822 with exact addr_external DFREG
823     kills allmincon
824     gen move %2, {absolute8, %1.disp+$1}
825 with exact regcon4 DFREG
826     kills allmincon
827     gen move %2, {regrel8, %1.reg, %1.disp+$1}
828 #endif
829
830 /*****************************************************************
831  * Group3 : integer arithmetic                                   *
832  *****************************************************************/
833 pat loe loc adi ste $3==4 && $1==$4
834 kills absolute + rel + memregrelcon4
835 gen addd {const4, $2}, {absolute4, $1}
836
837 pat lol loc adi stl $3==4 && $1==$4
838 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
839 gen addd {const4, $2}, {LOCAL, $1}
840
841 pat lil loc adi sil $3==4 && $1==$4
842 kills allmincon
843 gen addd {const4, $2}, {memrel4, fp, $1, 0}
844
845 pat lol adi stl $1==$3 && $2==4
846 with src4
847 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
848 gen addd %1, {LOCAL, $1}
849
850 pat lil adi sil $1==$3 && $2==4
851 with src4
852 kills allmincon
853 gen addd %1, {memrel4, fp, $1, 0}
854
855 pat loe adi ste $1==$3 && $2==4
856 with src4
857 kills absolute + rel + memregrelcon4
858 gen addd %1, {absolute4, $1}
859
860 pat adi $1 == 4
861 with exact MEMREG const4                yields {memregcon4, %1, %2.num}
862 with exact REG const4           yields {regcon4, %1, %2.num}
863 with exact const4 REG           yields {regcon4, %2, %1.num}
864 with exact memregrel4 const4            yields {memregrelcon4, %1.reg,
865                                         %1.disp, %2.num}
866 with exact memregcon4 const4            yields {memregcon4, %1.reg,
867                                         %1.disp + %2.num}
868 with exact regcon4 const4               yields {regcon4, %1.reg,
869                                         %1.disp + %2.num}
870 with exact memregrelcon4 const4         yields {memregrelcon4, %1.reg,
871                                         %1.disp1, %1.disp2+%2.num}
872 with exact addr_local const4            yields {addr_local, %1.ind+%2.num}
873 with exact LOCAL const4                 yields {memregrelcon4, fp,
874                                         %1.ind, %2.num}
875 with exact const4 LOCAL                 yields {memregrelcon4, fp,
876                                         %2.ind, %1.num}
877 with exact const4 addr_local            yields {addr_local, %2.ind+%1.num}
878 with exact MEMREG addr_external         yields {memregcon4, %1, %2.disp}
879 with exact REG addr_external            yields {regcon4, %1, %2.disp}
880 with exact memregrel4 addr_external     yields {memregrelcon4, %1.reg,
881                                         %1.disp, %2.disp}
882 with exact memregcon4 addr_external     yields {memregcon4, %1.reg,
883                                         %1.disp + %2.disp}
884 with exact regcon4 addr_external        yields {regcon4, %1.reg,
885                                         %1.disp + %2.disp}
886 with exact memregrelcon4 addr_external  yields {memregrelcon4, %1.reg,
887                                         %1.disp1, %1.disp2+%2.disp}
888 with src4 REG
889     gen addd %1, %2                     yields %2
890 with REG src4
891     gen addd %2, %1                     yields %1
892
893 pat loe loc sbi ste $3==4 && $1==$4
894 kills absolute + rel + memregrelcon4
895 gen addd {const4, 0-$2}, {absolute4, $1}
896
897 pat lol loc sbi stl $3==4 && $1==$4
898 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
899 gen addd {const4, 0-$2}, {LOCAL, $1}
900
901 pat lil loc sbi sil $3==4 && $1==$4
902 kills allmincon
903 gen addd {const4, 0-$2}, {memrel4, fp, $1, 0}
904
905 pat sbi $1 == 4
906 with src4 REG
907     gen subd %1, %2                     yields %2
908 with const4 REG
909     gen addd {const4, 0-%1.num}, %2     yields %2
910 with exact addr_local addr_local
911     uses REG={const4, %2.ind}
912     gen subd {const4, %1.ind}, %a       yields %a
913
914 pat mli $1 == 4
915 with src4 REG
916     gen muld %1, %2                     yields %2
917 with REG src4
918     gen muld %2, %1                     yields %1
919
920 pat dvi $1 == 4
921 with src4 REG
922     gen quod %1,%2                      yields %2
923
924 pat rmi $1 == 4
925 with src4 REG
926     gen remd %1, %2                     yields %2
927
928 pat ngi $1 == 4
929 with src4
930     uses reusing %1, REG
931     gen negd %1, %a                     yields %a
932
933 pat lol ngi stl $1==$3 && $2==4
934 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
935     gen negd {LOCAL, $1}, {LOCAL, $1}
936
937 pat loe ngi ste $1==$3 && $2==4
938 kills absolute + rel + memregrelcon4
939     gen negd {absolute4, $1}, {absolute4, $1}
940
941 pat lil ngi sil $1==$3 && $2==4
942 kills allmincon
943     gen negd {memrel4, fp, $1, 0}, {memrel4, fp, $1, 0}
944
945 pat sli $1 == 4
946 with src124 REG
947     gen ashd %1, %2                     yields %2
948
949 pat lol loc sli stl $1==$4 && $3==4
950 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
951     gen ashd {const4, $2}, {LOCAL, $1}
952
953 pat loe loc sli ste $1==$4 && $3==4
954 kills absolute + rel + memregrelcon4
955     gen ashd {const4, $2}, {absolute4, $1}
956
957 pat loc sri $2 == 4
958 with REG
959     gen ashd {const4,0-$1}, %1          yields %1
960
961 pat sri $1 == 4
962 with REG REG
963 gen negd %1, %1
964     ashd %1, %2                         yields %2
965
966 pat lol loc sri stl $1==$4 && $3==4
967 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
968     gen ashd {const4, 0-$2}, {LOCAL, $1}
969
970 pat loe loc sri ste $1==$4 && $3==4
971 kills absolute + rel + memregrelcon4
972     gen ashd {const4, 0-$2}, {absolute4, $1}
973
974
975 /*****************************************************************
976  * Group4 : unsigned arithmetic                                  *
977  *****************************************************************/
978
979 pat loe loc adu ste $3==4 && $1==$4
980 kills absolute + rel + memregrelcon4
981 gen addd {const4, $2}, {absolute4, $1}
982
983 pat lol loc adu stl $3==4 && $1==$4
984 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
985 gen addd {const4, $2}, {LOCAL, $1}
986
987 pat lil loc adu sil $3==4 && $1==$4
988 kills allmincon
989 gen addd {const4, $2}, {memrel4, fp, $1, 0}
990
991 pat lol adu stl $1==$3 && $2==4
992 with src4
993 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
994 gen addd %1, {LOCAL, $1}
995
996 pat lil adu sil $1==$3 && $2==4
997 with src4
998 kills allmincon
999 gen addd %1, {memrel4, fp, $1, 0}
1000
1001 pat loe adu ste $1==$3 && $2==4
1002 with src4
1003 kills absolute + rel + memregrelcon4
1004 gen addd %1, {absolute4, $1}
1005
1006 pat adu                                         leaving adi $1
1007
1008 pat loe loc sbu ste $3==4 && $1==$4
1009 kills absolute + rel + memregrelcon4
1010 gen addd {const4, 0-$2}, {absolute4, $1}
1011
1012 pat lol loc sbu stl $3==4 && $1==$4
1013 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
1014 gen addd {const4, 0-$2}, {LOCAL, $1}
1015
1016 pat lil loc sbu sil $3==4 && $1==$4
1017 kills allmincon
1018 gen addd {const4, 0-$2}, {memrel4, fp, $1, 0}
1019
1020 pat sbu                                         leaving sbi $1
1021
1022 pat mlu $1 == 4
1023 with src4 src4
1024     uses reusing %1, REGPAIR
1025     gen move %1, %a.1
1026         meid %2, %a                     yields %a.1
1027
1028 pat dvu $1 == 4
1029 kills ALL
1030     gen jsr {absolute4, ".dvu"}         yields r0
1031
1032 pat rmu $1 == 4
1033 kills ALL
1034     gen jsr {absolute4, ".rmu"}         yields r0
1035
1036 pat slu                                         leaving sli $1
1037
1038 pat loc sru $2 == 4
1039 with REG
1040     gen lshd {const4, 0-$1}, %1         yields %1
1041
1042 pat sru $1 == 4
1043 with REG REG
1044     gen negd %1, %1
1045         lshd %1, %2                     yields %2
1046
1047
1048 /*****************************************************************
1049  * Group5 : floating point arithmetic                            *
1050  *****************************************************************/
1051
1052 #ifndef NOFLOAT
1053 pat adf $1==4
1054 with fsrc4 FREG
1055     gen addf %1, %2                     yields %2
1056
1057 pat adf $1==8
1058 with fsrc8 DFREG
1059     gen addl %1, %2                     yields %2
1060
1061 pat sbf $1==4
1062 with fsrc4 FREG
1063     gen subf %1, %2                     yields %2
1064
1065 pat sbf $1==8
1066 with fsrc8 DFREG
1067     gen subl %1, %2                     yields %2
1068
1069 pat mlf $1==4
1070 with fsrc4 FREG
1071     gen mulf %1, %2                     yields %2
1072
1073 pat mlf $1==8
1074 with fsrc8 DFREG
1075     gen mull %1, %2                     yields %2
1076
1077 pat dvf $1==4
1078 with fsrc4 FREG
1079     gen divf %1, %2                     yields %2
1080
1081 pat dvf $1==8
1082 with fsrc8 DFREG
1083     gen divl %1, %2                     yields %2
1084
1085 pat ngf $1==4
1086 with FREG
1087     gen negf %1, %1                     yields %1
1088
1089 pat ngf $1==8
1090 with DFREG
1091     gen negl %1, %1                     yields %1
1092
1093 pat fif $1==4
1094 with fsrc4 FREG
1095 uses FREG, REG
1096     gen mulf %1, %2
1097         truncfd %2, %b
1098         movdf %b, %a
1099         subf %a, %2                     yields %a %2
1100
1101 pat fif $1==8
1102 with fsrc8 DFREG
1103 uses DFREG, REG
1104     gen mull %1, %2
1105         truncld %2, %b
1106         movdl %b, %a
1107         subl %a, %2                     yields %a %2
1108
1109 pat fef $1==4
1110 with FREG
1111 uses REG
1112     gen movf %1, {TOS}
1113         movf %1, {TOS}
1114         lshd {const4, 1}, {TOS}
1115         lshd {const4, 0-24}, {TOS}
1116         movd {TOS}, %a
1117         subd {const4, 127}, %a
1118         ord {const4, 0x3F000000}, {TOS}
1119         lshd {const4,2},{TOS}
1120         lshd {const4,0-2},{TOS}
1121         cbitd {const4, 23},{TOS}
1122         movf {TOS}, %1                  yields %1 %a
1123
1124 pat fef $1==8
1125 with DFREG
1126 uses REG
1127     gen movl %1, {TOS}
1128         movl %1, {TOS}
1129         adjspd {const4, 0-4}
1130         lshd {const4, 1}, {TOS}
1131         lshd {const4, 0-21}, {TOS}
1132         movd {TOS}, %a
1133         subd {const4, 1023}, %a
1134         ord {const4, 0x3FE00000}, {memregrel4, sp, 4}
1135         lshd {const4,2},{memregrel4, sp, 4}
1136         lshd {const4,0-2},{memregrel4, sp, 4}
1137         cbitd {const4, 52},{TOS}
1138         movl {TOS}, %1                  yields %1 %a
1139
1140 #else
1141
1142 pat adf                                 leaving loc 18 trp
1143 pat sbf                                 leaving loc 18 trp
1144 pat mlf                                 leaving loc 18 trp
1145 pat dvf                                 leaving loc 18 trp
1146 pat ngf                                 leaving loc 18 trp
1147 pat fif                                 leaving loc 18 trp
1148 pat fef                                 leaving loc 18 trp
1149
1150 #endif
1151
1152 /*****************************************************************
1153  * Group6 : pointer arithmetic                                   *
1154  *****************************************************************/
1155
1156 pat lol dup adp stl $1==$4 && $2==4
1157 kills allmincon
1158 uses REG={LOCAL, $1}
1159 gen addr {memrel4, fp, $1, $3}, {LOCAL, $1}     yields %a
1160
1161 pat loe dup adp ste $1==$4 && $2==4
1162 kills allmincon
1163 uses REG={absolute4, $1}
1164 gen addd {const4, $3}, {absolute4, $1}
1165
1166 pat lol adp stl $1==$3
1167 kills allmincon
1168 gen addr {memrel4, fp, $1, $2}, {LOCAL, $1}
1169
1170 pat loe adp ste $1==$3
1171 kills allmincon
1172 gen addd {const4, $2}, {absolute4, $1}
1173
1174 pat adp
1175 with exact MEMREG                       yields {memregcon4, %1, $1}
1176 with REG                                yields {regcon4, %1, $1}
1177 with exact memregcon4                   yields {memregcon4, %1.reg,
1178                                         %1.disp + $1}
1179 with exact regcon4                      yields {regcon4, %1.reg,
1180                                         %1.disp + $1}
1181 with exact memregrel4                   yields {memregrelcon4, %1.reg,
1182                                         %1.disp, $1}
1183 with exact memregrelcon4                yields {memregrelcon4, %1.reg,
1184                                         %1.disp1, %1.disp2 + $1}
1185 with exact addr_external                yields {addr_external, $1+%1.disp}
1186 with exact addr_local                   yields {addr_local, %1.ind + $1}
1187 with exact LOCAL                        yields {memregrelcon4, fp,
1188                                         %1.ind, $1}
1189
1190 pat loe loc ads ste $3==4 && $1==$4
1191 kills absolute + rel + memregrelcon4
1192 gen addd {const4, $2}, {absolute4, $1}
1193
1194 pat lol loc ads stl $3==4 && $1==$4
1195 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
1196 gen addd {const4, $2}, {LOCAL, $1}
1197
1198 pat lol ads stl $1==$3 && $2==4
1199 with src4
1200 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
1201 gen addd %1, {LOCAL, $1}
1202
1203 pat loe ads ste $1==$3 && $2==4
1204 with src4
1205 kills absolute + rel + memregrelcon4
1206 gen addd %1, {absolute4, $1}
1207
1208 pat ads $1==4                                   leaving adi 4
1209
1210 pat sbs $1==4                                   leaving sbi 4
1211
1212 /*****************************************************************
1213  * Group7 : increment/decrement/zero                             *
1214  *****************************************************************/
1215
1216 pat inc
1217 with REG
1218     gen addd {const4,1}, %1             yields %1
1219 with exact STACK
1220     gen addd {const4, 1},{TOS}
1221
1222 pat loc inc                             yields {const4, $1+1}
1223
1224 pat lol inc stl $1==$3
1225 kills allmincon
1226 gen addd {const4, 1}, {LOCAL, $1}
1227
1228 pat lol dec stl $1==$3
1229 kills allmincon
1230 gen addd {const4, 0-1}, {LOCAL, $1}
1231
1232 pat lil inc sil $1==$3
1233 kills allmincon
1234 gen addd {const4, 1}, {memrel4, fp, $1, 0}
1235
1236 pat lil dec sil $1==$3
1237 kills allmincon
1238 gen addd {const4, 0-1}, {memrel4, fp, $1, 0}
1239
1240 pat inl
1241 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
1242     gen addd {const4,1},{LOCAL, $1}
1243
1244 pat ine
1245 kills absolute, rel, memregrelcon4
1246     gen addd {const4,1},{absolute4, $1}
1247
1248 pat dec
1249 with  REG
1250     gen addd {const4,0-1}, %1           yields %1
1251 with exact STACK
1252     gen addd {const4,0-1}, {TOS}
1253
1254 pat loc dec                             yields {const4, $1-1}
1255
1256 pat del
1257 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
1258     gen addd {const4,0-1},{LOCAL, $1}
1259
1260 pat dee
1261 kills absolute, rel, memregrelcon4
1262     gen addd {const4,0-1},{absolute4, $1}
1263
1264 pat zrl
1265 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
1266     gen move {const4, 0}, {LOCAL, $1}
1267
1268 pat zre
1269 kills absolute, rel, memregrelcon4
1270     gen move {const4, 0}, {absolute4, $1}
1271
1272 #ifndef NOFLOAT
1273 pat zrf $1==4
1274 with STACK
1275 gen movd {const4, 0}, {TOS}
1276
1277 pat zrf $1==8
1278 with STACK
1279 gen movd {const4, 0}, {TOS}
1280     movd {const4, 0}, {TOS}
1281 #else
1282 pat zrf                                 leaving loc 18 trp
1283 #endif
1284
1285 pat zer $1==4                           yields {const4, 0}
1286
1287 pat zer $1==8                           yields {const4, 0}
1288                                                {const4, 0}
1289
1290 pat zer $1==12                          yields {const4, 0}
1291                                                {const4, 0}
1292                                                {const4, 0}
1293
1294 pat zer $1>12
1295 with STACK
1296     uses REG={const4, $1/4}
1297     gen 1:
1298         movqd {const4, 0}, {TOS}
1299         acbd {const4, 0-1}, %a, {label, "1b"}
1300
1301 /*****************************************************************
1302  * Group8 : convert                                              *
1303  *****************************************************************/
1304
1305 pat loc loc cii $1==4 && $2==4
1306
1307 pat loc loc cii $1==1 && $2==4
1308 with src124
1309 uses reusing %1, REG
1310     gen movxbd %1, %a                           yields %a
1311
1312 pat loc loc cii $1==2 && $2==4
1313 with src24
1314 uses reusing %1, REG
1315     gen movxwd %1, %a                           yields %a
1316
1317 pat cii
1318 kills ALL
1319     gen jsr {absolute4, ".cii"}
1320
1321 pat cui
1322 with src4 src4
1323
1324 #ifndef NOFLOAT
1325 pat loc loc cfi $1==8 && $2==4
1326 with fsrc8
1327 uses REG
1328     gen roundld %1, %a                          yields %a
1329
1330 pat loc loc cfi $1==4 && $2==4
1331 with fsrc4
1332 uses REG
1333     gen roundfd %1, %a                          yields %a
1334
1335 pat cfi
1336 kills ALL
1337     gen jsr {absolute4, ".cfi"}
1338
1339 pat loc loc cif $1==4 && $2==8
1340 with src4
1341 uses DFREG
1342     gen movdl %1, %a                            yields %a
1343
1344 pat loc loc cif $1==4 && $2==4
1345 with src4
1346 uses FREG
1347     gen movdf %1, %a                            yields %a
1348
1349 pat cif
1350 kills ALL
1351     gen jsr {absolute4, ".cif"}
1352
1353 pat cuf
1354                                         leaving loc 18 trp
1355
1356 pat loc loc cff $1==4 && $2==4
1357
1358 pat loc loc cff $1==8 && $2==8
1359
1360 pat loc loc cff $1==4 && $2==8
1361 with fsrc4
1362 uses DFREG
1363     gen movfl %1, %a                            yields %a
1364
1365 pat loc loc cff $1==8 && $2==4
1366 with fsrc8
1367 uses FREG
1368     gen movlf %1, %a                            yields %a
1369
1370 pat cff
1371 kills ALL
1372     gen jsr {absolute4, ".cff"}
1373
1374 #else
1375
1376 pat cif                                 leaving loc 18 trp
1377 pat cfi                                 leaving loc 18 trp
1378 pat cuf                                 leaving loc 18 trp
1379 pat cfu                                 leaving loc 18 trp
1380 pat cff                                 leaving loc 18 trp
1381
1382 #endif
1383 pat ciu
1384 with src4 src4
1385
1386 pat cuu
1387 with src4 src4
1388
1389 pat cfu
1390                                         leaving loc 18 trp
1391
1392 /*****************************************************************
1393  * Group9 : logical                                              *
1394  *****************************************************************/
1395
1396 pat loe loc and ste $3==4 && $1==$4
1397 kills absolute + rel + memregrelcon4
1398 gen andd {const4, $2}, {absolute4, $1}
1399
1400 pat lol loc and stl $3==4 && $1==$4
1401 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
1402 gen andd {const4, $2}, {LOCAL, $1}
1403
1404 pat lil loc and sil $3==4 && $1==$4
1405 kills allmincon
1406 gen andd {const4, $2}, {memrel4, fp, $1, 0}
1407
1408 pat lol and stl $1==$3 && $2==4
1409 with src4
1410 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
1411 gen andd %1, {LOCAL, $1}
1412
1413 pat lil and sil $1==$3 && $2==4
1414 with src4
1415 kills allmincon
1416 gen andd %1, {memrel4, fp, $1, 0}
1417
1418 pat loe and ste $1==$3 && $2==4
1419 with src4
1420 kills absolute + rel + memregrelcon4
1421 gen andd %1, {absolute4, $1}
1422
1423 pat and $1==4
1424 with src4 REG
1425     gen andd %1, %2                             yields %2
1426 with REG src4
1427     gen andd %2, %1                             yields %1
1428
1429 pat and $1>4
1430 with STACK
1431     gen move {const4, $1}, r0
1432         addr {memregrel4, sp, $1}, r1
1433         1:
1434         andd {TOS}, {regrel4, r1, 0}
1435         addr {regrel4, r1, 4}, r1
1436         acbd {const4, 0-4}, r0, {label, "1b"}
1437
1438 pat and !defined($1)
1439 with REG STACK
1440 uses REG
1441     gen addr {memregrel4, sp, 0}, %a
1442         addd %1, %a
1443         1:
1444         andd {TOS}, {regrel4, %a, 0}
1445         addr {regrel4, %a, 4}, %a
1446         acbd {const4, 0-4}, %1, {label, "1b"}
1447
1448 pat lol ior stl $1==$3 && $2==4
1449 with src4
1450 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
1451 gen ord %1, {LOCAL, $1}
1452
1453 pat lol loc ior stl $3==4 && $1==$4
1454 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
1455 gen ord {const4, $2}, {LOCAL, $1}
1456
1457 pat lil loc ior sil $3==4 && $1==$4
1458 kills allmincon
1459 gen ord {const4, $2}, {memrel4, fp, $1, 0}
1460
1461 pat lil ior sil $1==$3 && $2==4
1462 with src4
1463 kills allmincon
1464 gen ord %1, {memrel4, fp, $1, 0}
1465
1466 pat loe ior ste $1==$3 && $2==4
1467 with src4
1468 kills absolute + rel + memregrelcon4
1469 gen ord %1, {absolute4, $1}
1470
1471 pat lol loc xor stl $3==4 && $1==$4
1472 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
1473 gen xord {const4, $2}, {LOCAL, $1}
1474
1475 pat lil loc xor sil $3==4 && $1==$4
1476 kills allmincon
1477 gen xord {const4, $2}, {memrel4, fp, $1, 0}
1478
1479 pat lol xor stl $1==$3 && $2==4
1480 with src4
1481 kills rel, LOCAL %ind-4 < $1 && %ind+4 > $1
1482 gen xord %1, {LOCAL, $1}
1483
1484 pat lil xor sil $1==$3 && $2==4
1485 with src4
1486 kills allmincon
1487 gen xord %1, {memrel4, fp, $1, 0}
1488
1489 pat loe xor ste $1==$3 && $2==4
1490 with src4
1491 kills absolute + rel + memregrelcon4
1492 gen xord %1, {absolute4, $1}
1493
1494 pat ior $1==4
1495 with src4 REG
1496     gen ord %1, %2                              yields %2
1497 with REG src4
1498     gen ord %2, %1                              yields %1
1499
1500 pat ior $1>4
1501 with STACK
1502     gen move {const4, $1}, r0
1503         addr {memregrel4, sp, $1}, r1
1504         1:
1505         ord {TOS}, {regrel4, r1, 0}
1506         addr {regrel4, r1, 4}, r1
1507         acbd {const4, 0-4}, r0, {label, "1b"}
1508
1509 pat ior !defined($1)
1510 with REG STACK
1511 uses REG
1512     gen addr {memregrel4, sp, 0}, %a
1513         addd %1, %a
1514         1:
1515         ord {TOS}, {regrel4, %a, 0}
1516         addr {regrel4, %a, 4}, %a
1517         acbd {const4, 0-4}, %1, {label, "1b"}
1518
1519 pat xor $1==4
1520 with src4 REG
1521     gen xord %1, %2                             yields %2
1522 with REG src4
1523     gen xord %2, %1                             yields %1
1524
1525 pat xor $1>4
1526 with STACK
1527     gen move {const4, $1}, r0
1528         addr {memregrel4, sp, $1}, r1
1529         1:
1530         xord {TOS}, {regrel4, r1, 0}
1531         addr {regrel4, r1, 4}, r1
1532         acbd {const4, 0-4}, r0, {label, "1b"}
1533
1534 pat xor !defined($1)
1535 with REG STACK
1536 uses REG
1537     gen addr {memregrel4, sp, 0}, %a
1538         addd %1, %a
1539         1:
1540         xord {TOS}, {regrel4, %a, 0}
1541         addr {regrel4, %a, 4}, %a
1542         acbd {const4, 0-4}, %1, {label, "1b"}
1543
1544 pat com $1==4
1545 with REG
1546     gen comd %1, %1                             yields %1
1547
1548 pat com $1>4
1549 with STACK
1550     gen move {const4, $1}, r0
1551         addr {memregrel4, sp, 0}, r1
1552         1:
1553         comd {regrel4, r1, 0}, {regrel4, r1, 0}
1554         addr {regrel4, r1, 4}, r1
1555         acbd {const4, 0-4}, r0, {label, "1b"}
1556
1557 pat com !defined($1)
1558 with REG STACK
1559 uses REG
1560     gen addr {memregrel4, sp, 0}, %a
1561         1:
1562         comd {regrel4, %a, 0}, {regrel4, %a, 0}
1563         addr {regrel4, %a, 4}, %a
1564         acbd {const4, 0-4}, %1, {label, "1b"}
1565
1566 pat rol $1 == 4
1567 with src124 REG
1568     gen rotd %1, %2                     yields %2
1569
1570 pat loc ror $2 == 4
1571 with REG
1572     gen rotd {const4, 0-$1}, %1         yields %1
1573
1574 pat ror $1 == 4
1575 with REG REG
1576     gen negd %1, %1
1577         rotd %1, %2                     yields %2
1578
1579 /*****************************************************************
1580  * Group10 : sets                                                *
1581  *****************************************************************/
1582
1583 pat inn zeq $1==4
1584 with src4 REG
1585     gen cmpd {const4, 0}, %1
1586         bgt {label, $2}
1587         tbitd %1, %2
1588         bfc {label, $2}
1589
1590 pat inn zne $1==4
1591 with src4 REG
1592     gen cmpd {const4, 0}, %1
1593         bgt {label, "1f"}
1594         tbitd %1, %2
1595         bfs {label, $2}
1596         1:
1597
1598 pat inn $1==4
1599 with src4 REG
1600     uses REG
1601     gen tbitd %1, %2
1602         sfsd %a
1603         cmpd {const4,0}, %1
1604         ble {label, "1f"}
1605         xord %a, %a
1606         1:                                      yields %a
1607
1608 pat inn $1>4
1609 with src4 STACK
1610     uses REG
1611     gen tbitd %1, {TOS}
1612         adjspd {const4, 0-4}
1613         sfsd %a
1614         cmpd {const4,0}, %1
1615         ble {label, "1f"}
1616         xord %a, %a
1617         1:                                      yields %a
1618
1619 pat inn !defined($1)
1620 with src4 src4 STACK
1621     uses REG
1622     gen tbitd %2, {TOS}
1623         adjspd {const4, 0-4}
1624         sfsd %a
1625         cmpd {const4,0}, %2
1626         ble {label, "1f"}
1627         xord %a, %a
1628         1:                              yields %a
1629
1630 pat set $1==4
1631 with src4
1632     uses REG={const4, 0}
1633     gen sbitd %1, %a                    yields %a
1634
1635 pat set $1>4
1636 with src4 STACK
1637     uses REG={const4, $1/4}
1638     gen 1:
1639         movqd {const4, 0}, {TOS}
1640         acbd {const4, 0-1}, %a, {label, "1b"}
1641         sbitd %1, {TOS}
1642
1643 pat set !defined($1)
1644 with src4 src4 STACK
1645     uses reusing %1, REG=%1
1646     gen quod {const4, 4}, %a
1647         1:
1648         movqd {const4, 0}, {TOS}
1649         acbd {const4, 0-1}, %a, {label, "1b"}
1650         sbitd %2, {TOS}
1651
1652 /*****************************************************************
1653  * Group11 : array                                               *
1654  *****************************************************************/
1655
1656 pat lae aar $2==4 && rom($1,3)==1 && rom($1,1)==0
1657                                         leaving adi 4
1658
1659 pat lae aar $2==4 && rom($1,3)==1 && rom($1,1)!=0
1660                                         leaving adi 4
1661                                                 adp 0-rom($1,1)
1662
1663 pat lae aar $2==4 && rom($1,3)==2 && rom($1,1)==0
1664 with REG
1665     gen ashd {const4, 1}, %1            yields %1
1666                                         leaving adi 4
1667
1668 pat lae aar $2==4 && rom($1,3)==2 && rom($1,1)!=0
1669 with REG
1670     gen ashd {const4, 1}, %1            yields {regcon4, %1,(0-2)*rom($1,1)}
1671                                         leaving adi 4
1672
1673 pat lae aar $2==4 && rom($1,3)==4 && rom($1,1)==0
1674 with REG REG
1675 uses REG
1676     gen addr {regrelsid, 0, %2, %1}, %a
1677                                         yields %a
1678 with REG addr_local
1679 uses REG
1680     gen addr {memregrelsid, %2.ind, fp, %1}, %a
1681                                         yields %a
1682 with REG addr_external
1683 uses REG
1684     gen addr {abssid, %2.disp, %1}, %a
1685                                         yields %a
1686 with                                    leaving lae $1 aar $2
1687
1688 pat lae aar $2==4 && rom($1,3)==4 && rom($1,1)!=0
1689 with REG REG
1690 uses REG
1691     gen subd {const4, rom($1,1)}, %1
1692         addr {regrelsid, 0, %2, %1}, %a
1693                                         yields %a
1694 with REG addr_local
1695 uses REG
1696     gen subd {const4, rom($1,1)}, %1
1697         addr {memregrelsid, %2.ind, fp, %1}, %a
1698                                         yields %a
1699 with REG addr_external
1700 uses REG
1701     gen subd {const4, rom($1,1)}, %1
1702         addr {abssid, %2.disp, %1}, %a
1703                                         yields %a
1704 with                                    leaving lae $1 aar $2
1705
1706 pat lae lar $2==4 && rom($1,3)==4 && rom($1,1)==0
1707 with REG REG                            yields {regrelsid, 0, %2, %1}
1708 with REG addr_local                     yields {memregrelsid, %2.ind, fp, %1}
1709 with REG addr_external                  yields {abssid, %2.disp, %1}
1710 with                                    leaving lae $1 lar $2
1711
1712 pat lae lar $2==4 && rom($1,3)==4 && rom($1,1)!=0
1713 with REG REG
1714     gen subd {const4, rom($1,1)}, %1    yields {regrelsid, 0, %2, %1}
1715 with REG addr_local
1716     gen subd {const4, rom($1,1)}, %1    yields {memregrelsid, %2.ind, fp, %1}
1717 with REG addr_external
1718     gen subd {const4, rom($1,1)}, %1    yields {abssid, %2.disp, %1}
1719 with                                    leaving lae $1 lar $2
1720
1721 pat lae sar $2==4 && rom($1,3)==4 && rom($1,1)==0
1722 with REG REG src4
1723 kills allmincon
1724     gen movd %3, {regrelsid, 0, %2, %1}
1725 with REG addr_local src4
1726 kills allmincon
1727     gen move %3, {memregrelsid, %2.ind, fp, %1}
1728 with REG addr_external src4
1729 kills allmincon
1730     gen move %3, {abssid, %2.disp, %1}
1731 with                                    leaving lae $1 sar $2
1732
1733 pat lae sar $2==4 && rom($1,3)==4 && rom($1,1)!=0
1734 with REG REG src4
1735 kills allmincon
1736     gen subd {const4, rom($1,1)}, %1
1737         movd %3, {regrelsid, 0, %2, %1}
1738 with REG addr_local src4
1739 kills allmincon
1740     gen subd {const4, rom($1,1)}, %1
1741         move %3, {memregrelsid, %2.ind, fp, %1}
1742 with REG addr_external src4
1743 kills allmincon
1744     gen subd {const4, rom($1,1)}, %1
1745         move %3, {abssid, %2.disp, %1}
1746 with                                    leaving lae $1 sar $2
1747
1748 pat lae aar $2==4 && rom($1,1)==0
1749 with REG src4
1750     gen indexd %1, {const4, rom($1,3)-1}, %2
1751                                         yields %1
1752
1753 pat lae aar $2==4 && rom($1,1)!=0
1754 with REG src4
1755     gen subd {const4, rom($1,1)}, %1
1756         indexd %1, {const4, rom($1,3)-1}, %2
1757                                         yields %1
1758
1759 pat lae sar defined(rom($1,3))
1760                                         leaving lae $1
1761                                                 aar $2
1762                                                 sti rom($1,3)
1763
1764 pat lae lar defined(rom($1,3))
1765                                         leaving lae $1
1766                                                 aar $2
1767                                                 loi rom($1,3)
1768
1769 pat aar defined($1)
1770 kills ALL
1771 gen jsr {absolute4, ".aar"}
1772
1773 pat lar defined($1)
1774 kills ALL
1775 gen jsr {absolute4, ".lar"}
1776
1777 pat sar defined($1)
1778 kills ALL
1779 gen jsr {absolute4, ".sar"}
1780
1781 pat aar !defined($1)
1782 with src4
1783 kills ALL
1784 gen jsr {absolute4, ".aar"}
1785
1786 pat lar !defined($1)
1787 with src4
1788 kills ALL
1789 gen jsr {absolute4, ".lar"}
1790
1791 pat sar !defined($1)
1792 with src4
1793 kills ALL
1794 gen jsr {absolute4, ".sar"}
1795
1796 /*****************************************************************
1797  * Group12 : compare                                             *
1798  *****************************************************************/
1799
1800 proc cmitxxand
1801 with src4 src4 REG
1802 gen cmpd %1, %2
1803     brxx* {label, "1f"}
1804     movqd {const4, 0}, %3
1805     1:                                  yields %3
1806
1807 proc cmitxxior
1808 with src4 src4 REG
1809 gen cmpd %1, %2
1810     brxx* {label, "1f"}
1811     sbitd {const4, 0}, %3
1812     1:                                  yields %3
1813
1814 proc txxand
1815 with src4 REG
1816 gen cmpqd {const4, 0}, %1
1817     brxx* {label, "1f"}
1818     movqd {const4, 0}, %2
1819     1:                                  yields %2
1820
1821 proc txxior
1822 with src4 REG
1823 gen cmpqd {const4, 0}, %1
1824     brxx* {label, "1f"}
1825     sbitd {const4, 0}, %2
1826     1:                                  yields %2
1827
1828 pat cmi tlt and $1==4 && $3==4  call cmitxxand("bgt")
1829 pat cmi tle and $1==4 && $3==4  call cmitxxand("bge")
1830 pat cmi teq and $1==4 && $3==4  call cmitxxand("beq")
1831 pat cmi tne and $1==4 && $3==4  call cmitxxand("bne")
1832 pat cmi tge and $1==4 && $3==4  call cmitxxand("ble")
1833 pat cmi tgt and $1==4 && $3==4  call cmitxxand("blt")
1834
1835 pat cmi tlt ior $1==4 && $3==4  call cmitxxior("ble")
1836 pat cmi tle ior $1==4 && $3==4  call cmitxxior("blt")
1837 pat cmi teq ior $1==4 && $3==4  call cmitxxior("bne")
1838 pat cmi tne ior $1==4 && $3==4  call cmitxxior("beq")
1839 pat cmi tge ior $1==4 && $3==4  call cmitxxior("bgt")
1840 pat cmi tgt ior $1==4 && $3==4  call cmitxxior("bge")
1841
1842 pat tlt and $2==4               call txxand("bgt")
1843 pat tle and $2==4               call txxand("bge")
1844 pat teq and $2==4               call txxand("beq")
1845 pat tne and $2==4               call txxand("bne")
1846 pat tge and $2==4               call txxand("ble")
1847 pat tgt and $2==4               call txxand("blt")
1848
1849 pat tlt ior $2==4               call txxior("ble")
1850 pat tle ior $2==4               call txxior("blt")
1851 pat teq ior $2==4               call txxior("bne")
1852 pat tne ior $2==4               call txxior("beq")
1853 pat tge ior $2==4               call txxior("bgt")
1854 pat tgt ior $2==4               call txxior("bge")
1855
1856 pat cmi $1==4
1857 with src4 src4
1858     uses REG={const4, 0}
1859     gen cmpd %2, %1
1860         blt {label, "1f"}
1861         shid %a
1862         br {label, "2f"}
1863         1:
1864         addd {const4, 0-1}, %a
1865         2:                              yields %a
1866
1867 #ifndef NOFLOAT
1868 pat cmf $1==4
1869 with fsrc4 fsrc4
1870 uses REG = {const4, 0}
1871     gen cmpf %1, %2
1872         beq {label, "1f"}
1873         bgt {label, "2f"}
1874         movqd {const4, 1}, %a
1875         br {label, "1f"}
1876         2:
1877         movqd {const4, 0-1}, %a
1878         1:                              yields %a
1879
1880 pat cmf $1==8
1881 with fsrc8 fsrc8
1882 uses REG = {const4, 0}
1883     gen cmpl %1, %2
1884         beq {label, "1f"}
1885         bgt {label, "2f"}
1886         movqd {const4, 1}, %a
1887         br {label, "1f"}
1888         2:
1889         movqd {const4, 0-1}, %a
1890         1:                              yields %a
1891
1892 #else
1893
1894 pat cmf                                 leaving loc 18 trp
1895
1896 #endif
1897 pat cmu $1==4
1898 with src4 src4
1899     uses REG={const4, 0}
1900     gen cmpd %2, %1
1901         blo {label, "1f"}
1902         shid %a
1903         br {label, "2f"}
1904         1:
1905         addd {const4, 0-1}, %a
1906         2:                              yields %a
1907
1908 pat cmu defined($1)
1909 kills ALL
1910     gen move {const4, $1}, {TOS}
1911         jsr {absolute4, ".cmu"}         yields r1
1912
1913 pat cms $1==4                           leaving cmi $1
1914
1915 pat cms $1!=4
1916 kills ALL
1917 gen move {const4, $1}, {TOS}
1918     jsr {absolute4, ".cms"}             yields r1
1919
1920 pat cms !defined($1)
1921 kills ALL
1922 gen jsr {absolute4, ".cms"}             yields r1
1923
1924 pat cmp
1925 with exact addr_local addr_local        yields {const4, %2.ind}
1926                                                {const4, %1.ind}
1927                                         leaving sbi 4
1928 with                                    leaving cmu 4
1929
1930 proc txx
1931 with src4
1932     uses REG
1933     gen cmpqd {const4, 0}, %1
1934         sxx* %a                                 yields %a
1935
1936 pat tlt                         call txx("sgtd")
1937 pat tle                         call txx("sged")
1938 pat teq                         call txx("seqd")
1939 pat tne                         call txx("sned")
1940 pat tge                         call txx("sled")
1941 pat tgt                         call txx("sltd")
1942
1943 /*****************************************************************
1944  * Group13 : branch                                              *
1945  *****************************************************************/
1946
1947 proc bxx example beq
1948 with src4 src4 STACK
1949         gen cmpd %2, %1
1950             brxx* {label, $1}
1951 with exact src4 STACK
1952     gen cmpd {TOS}, %1
1953         brxx* {label, $1}
1954
1955 pat blt                         call bxx("blt")
1956 pat ble                         call bxx("ble")
1957 pat beq                         call bxx("beq")
1958 pat bne                         call bxx("bne")
1959 pat bge                         call bxx("bge")
1960 pat bgt                         call bxx("bgt")
1961
1962 pat bra
1963 with STACK
1964     gen br {label, $1}
1965
1966 pat loc beq $1>=0 && $1<=127
1967 with exact src1
1968 kills ALL
1969 gen cmpb {const4, $1}, %1
1970     beq {label, $2}
1971 with                                    yields {const4, $1}
1972                                         leaving beq $2
1973
1974 pat loc bne $1>=0 && $1<=127
1975 with exact src1
1976 kills ALL
1977 gen cmpb {const4, $1}, %1
1978     bne {label, $2}
1979 with                                    yields {const4, $1}
1980                                         leaving bne $2
1981
1982 proc cmpzxx example cmp zeq
1983 with src4 src4 STACK
1984     gen cmpd %2,%1
1985         brxx* {label, $2}
1986 with exact src4 STACK
1987     gen cmpd {TOS}, %1
1988         brxx* {label, $2}
1989 with exact addr_local addr_local
1990     kills ALL
1991     gen cmpd {const4, %2.ind}, {const4, %1.ind}
1992         brxx* {label, $2}
1993
1994 pat cmp zlt                     call cmpzxx("blo")
1995 pat cmp zle                     call cmpzxx("bls")
1996 pat cmp zeq                     call cmpzxx("beq")
1997 pat cmp zne                     call cmpzxx("bne")
1998 pat cmp zge                     call cmpzxx("bhs")
1999 pat cmp zgt                     call cmpzxx("bhi")
2000
2001 #ifndef NOFLOAT
2002 proc cmf4zxx example cmf zeq
2003 with fsrc4 fsrc4 STACK
2004     gen cmpf %2,%1
2005         brxx* {label, $2}
2006 with exact fsrc4 STACK
2007     gen cmpf {TOS}, %1
2008         brxx* {label, $2}
2009
2010 pat cmf zlt $1==4                       call cmf4zxx("blo")
2011 pat cmf zle $1==4                       call cmf4zxx("bls")
2012 pat cmf zeq $1==4                       call cmf4zxx("beq")
2013 pat cmf zne $1==4                       call cmf4zxx("bne")
2014 pat cmf zge $1==4                       call cmf4zxx("bhs")
2015 pat cmf zgt $1==4                       call cmf4zxx("bhi")
2016
2017 proc cmf8zxx example cmf zeq
2018 with fsrc8 fsrc8 STACK
2019     gen cmpl %2,%1
2020         brxx* {label, $2}
2021 with exact fsrc8 STACK
2022     gen cmpl {TOS}, %1
2023         brxx* {label, $2}
2024
2025 pat cmf zlt $1==8                       call cmf8zxx("blo")
2026 pat cmf zle $1==8                       call cmf8zxx("bls")
2027 pat cmf zeq $1==8                       call cmf8zxx("beq")
2028 pat cmf zne $1==8                       call cmf8zxx("bne")
2029 pat cmf zge $1==8                       call cmf8zxx("bhs")
2030 pat cmf zgt $1==8                       call cmf8zxx("bhi")
2031 #endif
2032
2033 proc zxx example zeq
2034 with src4 STACK
2035     gen cmpqd {const4,0}, %1
2036         brxx* {label, $1}
2037 with exact STACK
2038     gen cmpqd {const4,0}, {TOS}
2039         brxx* {label, $1}
2040
2041 pat zlt                         call zxx("bgt")
2042 pat zle                         call zxx("bge")
2043 pat zeq                         call zxx("beq")
2044 pat zne                         call zxx("bne")
2045 pat zge                         call zxx("ble")
2046 pat zgt                         call zxx("blt")
2047
2048 /*****************************************************************
2049  * Group14 : procedure call                                      *
2050  *****************************************************************/
2051
2052 pat cal
2053 kills ALL
2054     gen jsr {absolute4, $1}
2055
2056 pat cai
2057 with REG
2058 kills ALL
2059     gen jsr %1
2060
2061 pat ret $1==0
2062 with STACK
2063     gen exit {label, "[]"}
2064         ret {const4, 0}
2065
2066 pat ret $1==4
2067 with src4 STACK
2068     gen move %1, r0
2069         exit {label, "[]"}
2070         ret {const4, 0}
2071
2072 pat ret $1==8
2073 with STACK
2074     gen move {TOS}, r0
2075         move {TOS}, r1
2076         exit {label, "[]"}
2077         ret {const4, 0}
2078
2079 pat lfr $1==4                           yields r0
2080
2081 pat lfr $1==8                           yields r1 r0
2082
2083 /*****************************************************************
2084  * Group15 : miscellaneous                                       *
2085  *****************************************************************/
2086
2087 pat asp
2088 with STACK
2089     gen adjspd {const4,0-$1}
2090
2091 pat ass $1==4
2092 with REG STACK
2093     gen negd %1, %1
2094         adjspd %1
2095 with const4 STACK
2096     gen adjspd {const4,0-%1.num}
2097
2098 pat blm $1==0
2099
2100 pat blm $1==4
2101 with tosdst4 tossrc4
2102 kills allmincon
2103     gen movd %2, %1
2104
2105 pat blm $1>4 && $1<=16
2106 with REG REG
2107 kills allmincon
2108     gen movmd {regrel4, %2, 0}, {regrel4, %1, 0}, {const4, $1/4}
2109 with exact addr_external addr_external
2110 kills allmincon
2111     gen movmd {absolute4, %2.disp}, {absolute4, %1.disp}, {const4, $1/4}
2112 with exact addr_external addr_local
2113 kills allmincon
2114     gen movmd {LOCAL, %2.ind}, {absolute4, %1.disp}, {const4, $1/4}
2115 with exact addr_local addr_external
2116 kills allmincon
2117     gen movmd {absolute4, %2.disp}, {LOCAL, %1.ind}, {const4, $1/4}
2118 with exact addr_local addr_local
2119 kills allmincon
2120     gen movmd {LOCAL, %2.ind}, {LOCAL, %1.ind}, {const4, $1/4}
2121
2122 pat blm $1>16
2123 with REG REG
2124 kills allmincon
2125     uses REG={const4,$1}
2126     gen 1:
2127         movd {regrel4, %2, 0}, {regrel4, %1, 0}
2128         addr {regrel4, %1, 4}, %1
2129         addr {regrel4, %2, 4}, %2
2130         acbd {const4, 0-4}, %a, {label, "1b"}
2131
2132 pat bls $1==4
2133 with REG REG REG
2134 kills ALL
2135     gen 1:
2136         movd {regrel4, %3, 0}, {regrel4, %2, 0}
2137         addr {regrel4, %2, 4}, %2
2138         addr {regrel4, %3, 4}, %3
2139         acbd {const4, 0-4}, %1, {label, "1b"}
2140
2141 pat lae csa $2==4
2142 with src4
2143 kills ALL
2144     gen move %1, r0
2145         move {addr_external, $1}, r1
2146         jsr {absolute4, ".csa"}
2147
2148 pat csa
2149 kills ALL
2150     gen movd {TOS}, r1
2151         movd {TOS}, r0
2152         jsr {absolute4, ".csa"}
2153
2154 pat lae csb $2==4
2155 with src4
2156 kills ALL
2157     gen move %1, r0
2158         move {addr_external, $1}, r1
2159         jsr {absolute4, ".csb"}
2160
2161 pat csb
2162 kills ALL
2163     gen movd {TOS}, r1
2164         movd {TOS}, r0
2165         jsr {absolute4, ".csb"}
2166
2167 pat dch                                 leaving loi 4
2168
2169 pat dup $1==4
2170 with src4                               yields %1 %1
2171
2172 pat dup $1==8
2173 with src4 src4                          yields %2 %1 %2 %1
2174 with exact DLOCAL                       yields %1 %1
2175 with exact absolute8                    yields %1 %1
2176
2177 pat dup $1>8
2178 kills ALL
2179     gen move {const4, $1}, r0
2180         jsr {absolute4, ".dup"}
2181
2182 pat dus $1==4
2183 with src4
2184 kills ALL
2185     gen move %1, r0
2186         jsr {absolute4, ".dup"}
2187
2188 pat exg $1==4
2189 with src4 src4                          yields %1 %2
2190
2191 pat exg $1==8
2192 with src4 src4 src4 src4                yields %2 %1 %4 %3
2193
2194 pat exg
2195 kills ALL
2196     gen move {const4, $1}, r0
2197         jsr {absolute4, ".exg"}
2198
2199 pat fil
2200 gen move {addr_external, $1}, {absolute4, "hol0"+4}
2201
2202 pat gto
2203 with STACK
2204     gen move {addr_external, $1}, r0
2205         br {label, ".gto"}
2206
2207 pat lim                                 yields {absolute2, ".ignmask"}
2208
2209 pat lin
2210 gen move {const4, $1}, {absolute4, "hol0"}
2211
2212 pat lni
2213 gen addd {const4, 1}, {absolute4, "hol0"}
2214
2215 pat lor $1==0                           yields fp
2216
2217 pat lor $1==1
2218 with STACK                              yields sp
2219
2220 pat lor $1==2                           yields {absolute4, ".reghp"}
2221
2222 pat lpb                                 leaving adp 8
2223
2224 pat mon
2225 kills ALL
2226 gen jsr {absolute4, ".mon"}
2227
2228 pat nop
2229 kills ALL
2230 #ifdef DEBUG
2231     gen move {absolute4, "hol0"}, {TOS}
2232         jsr {absolute4, ".print"}
2233         jsr {absolute4, ".prnl"}
2234 #endif
2235
2236 pat rck $1==4
2237 kills ALL
2238     gen jsr {absolute4, ".rck"}
2239
2240 pat rtt                                 leaving ret 0
2241
2242 pat sig
2243 with src4
2244 uses REG
2245     gen move {absolute4, ".trpreg"}, %a
2246         move %1, {absolute4, ".trpreg"}         yields %a
2247
2248 pat sim
2249 with src24
2250 kills ALL
2251     gen movw %1, {absolute2, ".ignmask"}
2252
2253 pat str $1==0
2254 with  src4 STACK
2255     gen lprd fp, %1
2256
2257 pat str $1==1
2258 with src4 STACK
2259     gen lprd sp, %1
2260
2261 pat str $1==2
2262 with src4
2263 kills ALL
2264     gen movd %1, {TOS}
2265         jsr  {absolute4, ".strhp"}
2266         adjspd {const4, 0-4}
2267
2268 pat trp
2269 kills ALL
2270     gen jsr {absolute4, ".trp"}