Pristine Ack-5.5
[Ack-5.5.git] / mach / i386 / ncg / table
1 /*
2  * (c) copyright 1989 by the Vrije Universiteit, Amsterdam, The Netherlands.
3  * See the copyright notice in the ACK home directory, in the file "Copyright".
4  */
5
6 rscid = "$Id: table,v 1.18 1995/09/12 12:09:08 ceriel Exp $"
7
8 /*
9  * Back end tables for Intel 80386
10  *
11  * Author : Ceriel J.H. Jacobs
12  *
13  * Partly adapted from Intel 8086 table
14  *
15  * wordsize = 4 bytes, pointersize = 4 bytes.
16  *
17  * Register ebp is used as LB, esp is used for SP.
18  * Some global variables are used:
19  * - .reghp     : the heap pointer
20  * - .ignmask   : trap ignore mask
21  * - .trppc     : address of user defined trap handler
22  *
23  */
24
25 #define WS 4
26 #define PS 4
27
28 SL = 8
29 SSL = "8"
30
31 EM_WSIZE = WS
32 EM_PSIZE = PS
33 EM_BSIZE = 8
34
35 SIZEFACTOR = 5/1
36
37 #define REGVARS
38
39 #define EXACT exact     /* to improve code but slow down code generator,
40                            define it to nothing
41                         */
42
43 /*****************************************************************/
44 PROPERTIES
45 /*****************************************************************/
46
47 REG1                    /* general 1 byte register */
48 REG2                    /* general 2 byte register */
49 ACC1                    /* 1 byte accumulator */
50 ACC2                    /* 2 byte accumulator */
51 REG                     /* allocatable register */
52 GENREG                  /* register with sub-registers */
53 ACC                     /* accumulator */
54 SHIFT_CREG              /* shift count register */
55 BXREG                   /* ebx register */
56 AREG                    /* address register */
57 ADDREG                  /* allocatable address register */
58 CXREG                   /* ecx register */
59 DXREG                   /* edx register */
60 IREG                    /* index register */
61 RREG                    /* register variable, or register without subregs */
62
63 /*****************************************************************/
64 REGISTERS
65 /*****************************************************************/
66
67 al                                  : REG1 , ACC1 .
68 ah,bl, bh, ch,dl,dh                 : REG1 .
69 cl                                  : REG1 , SHIFT_CREG .
70 ax = al + ah                        : REG2 , ACC2 .
71 bx = bl + bh                        : REG2 .
72 cx = cl + ch                        : REG2 .
73 dx = dl + dh                        : REG2 .
74 eax = al + ah                       : REG, GENREG, IREG, ACC, ADDREG, AREG.
75 ebx = bl + bh                       : REG, GENREG, IREG, BXREG, ADDREG, AREG.
76 ecx = cl + ch                       : REG, GENREG, IREG, CXREG, SHIFT_CREG, ADDREG , AREG .
77 edx = dl + dh                       : REG, GENREG, IREG, DXREG, ADDREG, AREG .
78 #ifndef REGVARS
79 esi                                 : REG, RREG, IREG, AREG, ADDREG .
80 edi                                 : REG, RREG, IREG, AREG, ADDREG .
81 #else
82 esi                                 : AREG , IREG , RREG regvar(reg_any) .
83 edi                                 : AREG , IREG , RREG regvar(reg_any) .
84 #endif
85 ebp                                 : AREG , IREG .
86 esp                                 : AREG .
87
88 /*****************************************************************/
89 TOKENS
90 /*****************************************************************/
91
92 ANYCON          = { INT val; }      4 cost(4,0) val .
93 CONSTR          = { ADDR off; }     4 cost(4,0) off .
94 ADDR_EXTERN     = { ADDR off; }     4 cost(4,0) off .
95 EXTERN1         = { ADDR off; }     4 cost(4,5) "(" off ")" .
96 EXTERN2         = { ADDR off; }     4 cost(4,5) "(" off ")" .
97 EXTERN          = { ADDR off; }     4 cost(4,5) "(" off ")" .
98 ADDR_LOCAL      = { INT ind; }      4 cost(1,0) ind "(ebp)" .
99 LOCAL           = { INT ind; INT size; } 4 cost(1,5) ind "(ebp)" .
100 LOCAL1          = { INT ind; INT size; } 4 cost(1,5) ind "(ebp)" .
101 LOCAL2          = { INT ind; INT size; } 4 cost(1,5) ind "(ebp)" .
102
103 Rreg_off        = { AREG reg; ADDR off;} 4 cost(4,0) off "(" reg ")" .
104 Xreg_off        = { AREG reg; ADDR off;} 4 cost(4,0) off "(" reg ")" .
105 indexed_r_off   = { AREG reg; IREG reg2; INT scale; ADDR off;}
106                         4 cost(5,0) off "(" reg ")" "(" reg2 "*" scale ")" .
107 indexed_off     = { IREG reg; INT scale; ADDR off;}
108                         4 cost(5,0) off "(" reg "*" scale ")" .
109
110 indir_r         = { AREG reg;} 4 cost(0,5) "(" reg ")" .
111 indir_r1        = { AREG reg;} 4 cost(0,5) "(" reg ")" .
112 indir_r2        = { AREG reg;} 4 cost(0,5) "(" reg ")" .
113 indir_r_off     = { AREG reg; ADDR off;} 4 cost(4,5) off "(" reg ")" .
114 indir_r_off1    = { AREG reg; ADDR off;} 4 cost(4,5) off "(" reg ")" .
115 indir_r_off2    = { AREG reg; ADDR off;} 4 cost(4,5) off "(" reg ")" .
116
117 indir_indexed_r_off =
118                   { AREG reg; IREG reg2; INT scale; ADDR off;}
119                         4 cost(5,5) off "(" reg ")" "(" reg2 "*" scale ")" .
120 indir_indexed_r_off1 =
121                   { AREG reg; IREG reg2; INT scale; ADDR off;}
122                         4 cost(5,5) off "(" reg ")" "(" reg2 "*" scale ")" .
123 indir_indexed_r_off2 =
124                   { AREG reg; IREG reg2; INT scale; ADDR off;}
125                         4 cost(5,5) off "(" reg ")" "(" reg2 "*" scale ")" .
126 indir_indexed_off =
127                   { IREG reg; INT scale; ADDR off;}
128                         4 cost(5,5) off "(" reg "*" scale ")" .
129 indir_indexed_off1 =
130                   { IREG reg; INT scale; ADDR off;}
131                         4 cost(5,5) off "(" reg "*" scale ")" .
132 indir_indexed_off2 =
133                   { IREG reg; INT scale; ADDR off;}
134                         4 cost(5,5) off "(" reg "*" scale ")" .
135
136 label           = { ADDR off;} 4 off .
137
138 /*****************************************************************/
139 SETS
140 /*****************************************************************/
141
142 /* Mode refering to a word in memory */
143 memory2         = EXTERN2 + indir_r2 + indir_r_off2 + LOCAL2 +
144                   indir_indexed_r_off2 + indir_indexed_off2 .
145 memory1         = EXTERN1 + indir_r1 + indir_r_off1 + LOCAL1 +
146                   indir_indexed_r_off1 + indir_indexed_off1 .
147 memory          = EXTERN + indir_r + indir_r_off + LOCAL +
148                   indir_indexed_r_off + indir_indexed_off .
149 noacc           = EXTERN + LOCAL + BXREG + CXREG + RREG .
150 const           = ANYCON + ADDR_EXTERN + CONSTR .
151 register        = REG + ADDREG + RREG + IREG .
152 addreg          = ADDREG + RREG .
153 anyreg          = register + AREG .
154 rm              = anyreg + memory .
155 rmorconst       = const + rm .
156 regorconst      = const + anyreg .
157 dest            = register + memory .
158
159 rm1             = REG1 + memory1 .
160 rmorconst1      = const + rm1 .
161 rm2             = REG2 + memory2 .
162 rmorconst2      = const + rm2 .
163 regorconst124   = REG1 + REG2 + GENREG + const .
164 regorconst24    = REG2 + GENREG + const .
165 dest1           = REG1 + memory1 .
166 dest2           = REG2 + memory2 .
167
168 /* Modes used to indicate tokens to be removed from the fakestack */
169 reg_indir       = indir_r1 + indir_r2 + indir_r_off1 + indir_r_off2 + indir_r +
170                   indir_r_off .
171 indexed         = indir_indexed_r_off1 + indir_indexed_r_off2 +
172                   indir_indexed_r_off + indir_indexed_off1 +
173                   indir_indexed_off2 + indir_indexed_off .
174 indir           = reg_indir + indexed .
175 externals       = EXTERN2 + EXTERN1 + EXTERN .
176 locals          = LOCAL2 + LOCAL1 + LOCAL .
177 mem_nonlocals   = externals + reg_indir .
178 all_mems        = mem_nonlocals + locals .
179
180 /* Miscellaneous */
181 reg_off         = Xreg_off + Rreg_off .
182 halfindir       = reg_off + ADDR_LOCAL + indexed_r_off + indexed_off .
183 some_off        = halfindir + ADDR_EXTERN + AREG .
184 a_word          = rmorconst + halfindir .
185
186 /*****************************************************************/
187 INSTRUCTIONS
188 /*****************************************************************/
189
190 cost(2,2)
191 adc rm:rw:cc, regorconst:ro.
192 adc anyreg:rw:cc, rmorconst:ro.
193 #ifdef REGVARS
194 add LOCAL:rw:cc, rmorconst:ro.  /* only for register variables; UNSAFE !!! */
195 #endif
196 add anyreg:rw:cc, rmorconst:ro.
197 add rm:rw:cc, regorconst:ro.
198 #ifdef REGVARS
199 axx "syntax error" LOCAL:rw:cc, rmorconst:ro.   /* only for register variables; UNSAFE !!! */
200 #endif
201 axx "syntax error" anyreg:rw:cc, rmorconst:ro.
202 axx "syntax error" rm:rw:cc, regorconst:ro.
203 #ifdef REGVARS
204 and LOCAL:rw:cc, rmorconst:ro.  /* only for register variables; UNSAFE !!! */
205 #endif
206 and rm:rw:cc, regorconst:ro.
207 and anyreg:rw:cc, rmorconst:ro.
208 cdq kills edx cost(1,3).
209 cmp rm:ro, regorconst:ro kills :cc.
210 cmp anyreg:ro, rmorconst:ro kills :cc.
211 cmpb rm1:rw, const:ro kills :cc.
212 cmpw "o16 cmp" rm2:rw, const:ro kills :cc cost(3,2).
213 dec anyreg:rw:cc cost(1,2).
214 dec rm:rw:cc.
215 div rm:ro kills:cc eax edx cost(2,43).
216 idiv rm:ro kills:cc eax edx cost(2,43).
217 imul rm:rw, anyreg:ro kills:cc cost(3,41).
218 imul anyreg:rw, rm:ro kills:cc cost(3,41).
219 imul anyreg:wo, rm:ro, const:ro kills :cc cost(2,38).
220 inc anyreg:rw:cc cost(1,2).
221 inc rm:rw:cc.
222 ja label cost(1,4).
223 jae label cost(1,4).
224 jb label cost(1,4).
225 jbe label cost(1,4).
226 jcxz label cost(1,4).
227 je label cost(1,4).
228 jg label cost(1,4).
229 jge label cost(1,4).
230 jl label cost(1,4).
231 jle label cost(1,4).
232 jne label cost(1,4).
233 jmp label cost(1,4).
234 proccall "call" label+rm cost(1,8).
235 jxx "syntax error" label cost(1,4).
236 setxx "syntax error" REG1:rw cost(2,4).
237 setle REG1:rw cost(2,4).
238 setg REG1:rw cost(2,4).
239 lea anyreg:rw, halfindir:ro.
240 lea LOCAL:rw, halfindir:ro.     /* only for register variables, UNSAFE!!! */
241 leave cost(1,4).
242 loop label kills ecx.
243 #ifdef REGVARS
244 mov LOCAL:wo, rmorconst:ro.     /* only for register variables, UNSAFE!!! */
245 #endif
246 mov a_word:wo, regorconst:ro.
247 mov anyreg:wo, rmorconst:ro.
248 movb rm1:wo, regorconst124:ro.
249 movb REG1:wo, rm1:ro.
250 movw "o16 mov" rm2:wo, regorconst124:ro cost(3,2).
251 movw "o16 mov" REG2:wo, rmorconst2:ro cost(3,2).
252 movsxb anyreg:wo, REG+rm1:ro.
253 movsx anyreg:wo, REG+rm2:ro.
254 movzxb anyreg:wo, REG+rm1:ro.
255 movzx anyreg:wo, REG+rm2:ro.
256 mul rmorconst:ro kills :cc eax edx cost(2,41).
257 neg rmorconst:rw:cc.
258 not rmorconst:rw.
259 #ifdef REGVARS
260 or LOCAL:rw:cc, rmorconst:ro.   /* only for register variables; UNSAFE !!! */
261 #endif
262 or rm:rw:cc, regorconst:ro.
263 or anyreg:rw:cc, rmorconst:ro.
264 pop anyreg:wo cost(1,4).
265 pop rm:wo.
266 push anyreg:ro cost(1,2).
267 push const:ro cost(1,2).
268 push rm:ro cost(2,5).
269 rcl rm:rw, ANYCON+SHIFT_CREG:ro kills :cc cost(2,10).
270 rcr rm:rw, ANYCON+SHIFT_CREG:ro kills :cc cost(2,10).
271 ret cost(1,10).
272 rol rm:rw, ANYCON+SHIFT_CREG:ro kills :cc.
273 ror rm:rw, ANYCON+SHIFT_CREG:ro kills :cc.
274 sal rm:rw, ANYCON+SHIFT_CREG:ro kills :cc.
275 sar rm:rw, ANYCON+SHIFT_CREG:ro kills :cc.
276 sbb rm:rw:cc, regorconst:ro.
277 sbb anyreg:rw:cc, rmorconst:ro.
278 shl rm:rw, ANYCON+SHIFT_CREG:ro kills :cc.
279 shr rm:rw, ANYCON+SHIFT_CREG:ro kills :cc.
280 #ifdef REGVARS
281 sub LOCAL:rw:cc, rmorconst:ro.  /* only for register variables; UNSAFE !!! */
282 #endif
283 sub rm:rw:cc, regorconst:ro.
284 sub anyreg:rw:cc, rmorconst+halfindir:ro.
285 check "test" rm:ro, regorconst:ro kills :cc.
286 check "test" anyreg:ro, rmorconst:ro kills :cc.
287 testb "testb" rm1:ro, regorconst124:ro kills :cc.
288 testb "testb" REG1:ro, rmorconst1:ro kills :cc.
289 testw "o16 test" rm2:ro, regorconst24:ro kills :cc.
290 testw "o16 test" REG2:ro, rmorconst2:ro kills :cc.
291 testl "test" rm:ro, regorconst:ro kills :cc.
292 testl "test" REG:ro, rmorconst:ro kills :cc.
293 uxx "syntax error"  rm:rw:cc.
294 xchg rm:rw, anyreg:rw.
295 xchg anyreg:rw, rm:rw.
296 xor rm:rw:cc, regorconst:ro.
297 xor anyreg:rw:cc, rmorconst:ro.
298 xorb rm1:rw:cc, regorconst124:ro.
299 xorb anyreg:rw:cc, rmorconst1:ro.
300 xorw "o16 xor" rm2:rw:cc, regorconst124:ro.
301 xorw "o16 xor" anyreg:rw:cc, rmorconst2:ro.
302
303 killreg "! kill" anyreg:wo cost(0,0).
304 killcc "! kill cc" kills:cc cost(0,0).
305
306
307 /*****************************************************************/
308 MOVES
309 /*****************************************************************/
310
311 #ifdef REGVARS
312 from rmorconst to LOCAL         /* unsafe !!! */
313 gen mov %2,%1
314 #endif
315
316 from rm to register
317 gen mov %2,%1
318
319 from anyreg to dest
320 gen mov %2,%1
321
322 from halfindir to register+AREG
323 gen lea %2,%1
324
325 from halfindir to LOCAL         /* unsafe !!! */
326 gen lea %2,%1
327
328 from rm1 to REG1
329 gen movb %2,%1
330
331 from rm2 to REG2
332 gen movw %2,%1
333
334 from GENREG to rm1
335 gen movb %2,%1.1
336
337 from GENREG to rm2
338 gen movw %2,%1
339
340 from REG2 to rm1
341 gen movb %2,%1.1
342
343 from ANYCON %val==0 to register
344 gen xor %2,%2
345
346 from ANYCON %val==0 to REG1
347 gen xorb %2,%2
348
349 from ANYCON %val==0 to REG2
350 gen xorw %2,%2
351
352 from const to dest
353 gen mov %2,%1
354
355 from const+REG1 to rm1
356 gen movb %2,%1
357
358 from const+REG2 to rm2
359 gen movw %2,%1
360
361 /*****************************************************************/
362 TESTS
363 /*****************************************************************/
364
365 to test anyreg
366 gen testl %1,%1
367
368 to test memory
369 gen cmp %1, {ANYCON,0}
370
371 to test REG1
372 gen testb %1,%1
373
374 to test memory1
375 gen cmpb %1, {ANYCON,0}
376
377 to test REG2
378 gen testw %1,%1
379
380 to test memory2
381 gen cmpw %1, {ANYCON,0}
382
383
384 /*****************************************************************/
385 STACKINGRULES
386 /*****************************************************************/
387
388 from rm to STACK
389   gen push %1
390
391 from const to STACK
392   gen push %1
393
394 from rm1 to STACK
395   uses REG
396   gen movzxb %a,%1
397       push %a
398
399 from rm1 to STACK
400   gen push eax
401       movzxb eax,%1
402       xchg {indir_r,esp},eax
403
404 from rm2 to STACK
405   uses REG
406   gen movzx %a,%1
407       push %a
408
409 from rm2 to STACK
410   gen push eax
411       movzx eax,%1
412       xchg {indir_r,esp},eax
413
414 from Xreg_off to STACK
415   gen add %1.reg,{CONSTR,%1.off}
416       push %1.reg
417
418 from ADDR_LOCAL %ind==0 to STACK
419   gen push ebp
420
421 from halfindir to STACK
422   uses REG
423   gen move %1,%a
424       push %a
425
426 from halfindir to STACK
427   gen push eax
428       lea eax,%1
429       xchg {indir_r,esp},eax
430
431
432 /*****************************************************************/
433 COERCIONS
434 /*****************************************************************/
435
436 /***************************
437  * From source to register *
438  ***************************/
439
440 from rmorconst
441   uses reusing %1,REG=%1                yields %a
442 from rmorconst
443   uses reusing %1,IREG=%1               yields %a
444
445 from Xreg_off
446   gen add %1.reg,{CONSTR,%1.off}        yields %1.reg
447
448 from halfindir
449   uses reusing %1,ADDREG
450   gen move %1,%a                        yields %a
451
452 from halfindir
453   uses reusing %1,REG
454   gen move %1,%a                        yields %a
455
456 from halfindir
457   uses reusing %1,IREG
458   gen move %1,%a                        yields %a
459
460 /************************
461  * From source to token *
462  ************************/
463
464 from ANYCON                             yields {ADDR_EXTERN,%1.val}
465
466 /****************
467  * From source1 *
468  ****************/
469
470 from rm1
471   uses reusing %1,REG1=%1               yields %a
472
473 from rm1
474   uses GENREG
475   gen
476       movzxb %a,%1                      yields %a
477
478 /****************
479  * From source2 *
480  ****************/
481
482 from rm2
483   uses reusing %1,REG2=%1               yields %a
484
485 from rm2
486   uses GENREG
487   gen
488       movzx %a,%1                       yields %a
489
490 /************************
491  * From STACK coercions *
492  ************************/
493
494 from STACK
495   uses REG
496   gen pop %a                            yields %a
497
498
499 /*****************************************************************/
500 PATTERNS
501 /*****************************************************************/
502
503 /******************************************************************
504  *  Group 1 : Load Instructions                                   *
505  ******************************************************************/
506
507 pat loc                                 yields {ANYCON,$1}
508
509 pat ldc                                 leaving loc 18 trp
510
511 pat lol                                 yields {LOCAL,$1,4}
512
513 pat stl lol $1==$2
514 #ifdef REGVARS
515         && inreg($1) <= 0
516 #endif
517                                                 leaving dup 4 stl $1
518
519 pat sdl ldl $1==$2                              leaving dup 8 sdl $1
520
521 #ifdef REGVARS
522 pat lol dup stl $2==4 && inreg($1) <= 0 && inreg($3) > 0
523 kills regvar($3)
524 gen     move {LOCAL,$1,4}, {LOCAL,$3,4}
525                                         yields {LOCAL,$3,4}
526 #endif
527
528 pat loe                                 yields {EXTERN,$1}
529
530 pat ste loe $1==$2                              leaving dup 4 ste $1
531
532 pat sde lde $1==$2                              leaving dup 8 sde $1
533
534 #ifdef REGVARS
535 pat loe dup stl $2==4 && inreg($3) > 0
536 kills regvar($3)
537 gen     move {EXTERN,$1}, {LOCAL,$3,4}
538                                         yields {LOCAL,$3,4}
539 #endif
540
541 #ifdef REGVARS
542 pat lil inreg($1) > 0                   yields {indir_r, regvar($1)}
543 #endif
544 pat lil
545   uses ADDREG={indir_r_off,ebp,$1}      yields {indir_r,%a}
546
547 pat lil dup stl $2==4                           leaving lil $1 stl $3 lol $3
548
549 pat sil lil $1==$2                              leaving dup 4 sil $1
550
551 pat lof
552   with exact indexed_r_off      yields {indir_indexed_r_off,%1.reg,%1.reg2,
553                                                 %1.scale,%1.off+$1}
554   with exact indexed_off        yields {indir_indexed_off,%1.reg,
555                                                 %1.scale,%1.off+$1}
556   with exact reg_off            yields {indir_r_off,%1.reg,%1.off+$1}
557   with exact ADDR_EXTERN        yields {EXTERN,%1.off+$1}
558   with exact ADDR_LOCAL         yields {LOCAL,%1.ind + $1,4}
559   with addreg                   yields {indir_r_off,%1,$1}
560
561 pat lal                                 yields {ADDR_LOCAL,$1}
562
563 pat lae                                 yields {ADDR_EXTERN,$1}
564
565 pat lpb                                         leaving adp SL
566
567 pat lxl $1==0                           yields {ADDR_LOCAL,0}
568
569 pat lxl $1==1                           yields {LOCAL,SL,4}
570
571 pat lxl $1==2
572   uses ADDREG={indir_r_off,ebp,SSL}     yields {indir_r_off,%a,SSL}
573
574 pat lxl $1>2
575   uses ADDREG={indir_r_off,ebp,SSL},
576        CXREG={ANYCON,$1-1}
577   gen 1:
578       mov %a,{indir_r_off,%a,SSL}
579       loop {label,1b}                   yields %a
580
581 pat lxa $1==0                           yields {ADDR_LOCAL,SL}
582
583 pat lxa $1==1
584   uses ADDREG={indir_r_off,ebp,SSL}     yields {Xreg_off,%a,SSL}
585
586 pat lxa $1==2
587   uses ADDREG={indir_r_off,ebp,SSL}
588   gen move {indir_r_off,%a,SSL},%a      yields {Xreg_off,%a,SSL}
589
590 pat lxa $1>2
591   uses ADDREG={indir_r_off,ebp,SSL},
592        CXREG={ANYCON,$1-1}
593   gen 1:
594       mov %a,{indir_r_off,%a,SSL}
595       loop {label,1b}                   yields {Xreg_off,%a,SSL}
596
597 pat dch                                         leaving loi 4
598
599 pat loi $1==2
600   with addreg                   yields {indir_r2,%1}
601   with exact indexed_r_off      yields {indir_indexed_r_off2, %1.reg, %1.reg2,
602                                                 %1.scale, %1.off}
603   with exact indexed_off        yields {indir_indexed_off2, %1.reg,
604                                                 %1.scale, %1.off}
605   with exact reg_off            yields {indir_r_off2,%1.reg,%1.off}
606   with exact ADDR_EXTERN        yields {EXTERN2,%1.off}
607   with exact ADDR_LOCAL         yields {LOCAL2,%1.ind,2}
608
609 pat loi $1==1
610   with addreg                   yields {indir_r1,%1}
611   with exact indexed_r_off      yields {indir_indexed_r_off1, %1.reg, %1.reg2,
612                                                 %1.scale, %1.off}
613   with exact indexed_off        yields {indir_indexed_off1, %1.reg,
614                                                 %1.scale, %1.off}
615   with exact reg_off            yields {indir_r_off1,%1.reg,%1.off}
616   with exact ADDR_EXTERN        yields {EXTERN1,%1.off}
617   with exact ADDR_LOCAL         yields {LOCAL1,%1.ind,1}
618
619 pat loi $1==4
620   with addreg                   yields {indir_r,%1}
621   with exact indexed_r_off      yields {indir_indexed_r_off, %1.reg, %1.reg2,
622                                                 %1.scale, %1.off}
623   with exact indexed_off        yields {indir_indexed_off, %1.reg,
624                                                 %1.scale, %1.off}
625   with exact reg_off            yields {indir_r_off,%1.reg,%1.off}
626   with exact ADDR_EXTERN        yields {EXTERN,%1.off}
627   with exact ADDR_LOCAL         yields {LOCAL,%1.ind,4}
628
629 pat loi $1==8
630   with addreg                   yields {indir_r_off,%1,4}
631                                        {indir_r,%1}
632   with exact indexed_r_off      yields {indir_indexed_r_off, %1.reg, %1.reg2,
633                                                 %1.scale, %1.off+4}
634                                         {indir_indexed_r_off, %1.reg, %1.reg2,
635                                                 %1.scale, %1.off}
636   with exact indexed_off        yields {indir_indexed_off, %1.reg,
637                                                 %1.scale, %1.off+4}
638                                         {indir_indexed_off, %1.reg,
639                                                 %1.scale, %1.off}
640   with exact reg_off            yields {indir_r_off,%1.reg,%1.off+4}
641                                        {indir_r_off,%1.reg,%1.off}
642   with exact ADDR_LOCAL         yields {LOCAL,%1.ind+4,4}
643                                        {LOCAL,%1.ind,4}
644   with exact ADDR_EXTERN        yields {EXTERN,%1.off + 4}
645                                        {EXTERN,%1.off}
646 pat loi
647   with BXREG
648   kills ALL
649   gen mov ecx,{ANYCON,$1}
650       proccall {label,".loi"}
651
652 pat los $1==4
653   with CXREG BXREG
654   kills ALL
655   gen proccall {label,".los"}
656
657 pat ldl                                 yields {LOCAL,$1+4,4}
658                                                {LOCAL,$1,4}
659
660 pat lde                                 yields {EXTERN,$1+4}
661                                                {EXTERN,$1}
662
663 pat ldf
664   with exact reg_off                    yields {indir_r_off,%1.reg,
665                                                 %1.off + 4 + $1}
666                                                {indir_r_off,%1.reg,
667                                                 %1.off + $1}
668   with exact indexed_r_off      yields {indir_indexed_r_off, %1.reg, %1.reg2,
669                                                 %1.scale, %1.off+$1+4}
670                                         {indir_indexed_r_off, %1.reg, %1.reg2,
671                                                 %1.scale, %1.off+$1}
672   with exact indexed_off        yields {indir_indexed_off, %1.reg,
673                                                 %1.scale, %1.off+$1+4}
674                                         {indir_indexed_off, %1.reg,
675                                                 %1.scale, %1.off+$1}
676   with addreg                           yields {indir_r_off,%1,$1+4}
677                                                {indir_r_off,%1,$1}
678   with exact ADDR_EXTERN        yields {EXTERN,%1.off+4+$1}
679                                        {EXTERN,%1.off+$1}
680   with exact ADDR_LOCAL         yields {LOCAL,%1.ind + $1 + 4,4}
681                                        {LOCAL,%1.ind + $1,4}
682
683 pat lpi                         yields {ADDR_EXTERN,$1}
684
685 /* this code sequence is generated by the C-compiler to tackle
686    char parameters, on the 80386 it reduces to nil */
687
688 pat lol lal sti $1==$2 && $3<=4
689
690 /*******************************************************************
691  *  Group 2 : Store Instructions                                   *
692  *******************************************************************/
693
694 #ifdef REGVARS
695 pat stl inreg($1)==reg_any
696   with rmorconst
697   kills regvar($1)
698   gen move %1, {LOCAL,$1,4}
699   with exact halfindir
700   kills regvar($1)
701   gen move %1, {LOCAL,$1,4}
702   with exact STACK
703   kills regvar($1)
704   gen pop {LOCAL, $1, 4}
705 #endif
706 pat stl
707   with regorconst
708   kills indir,locals %ind+%size > $1 && %ind < $1+4
709   gen move %1,{LOCAL,$1,4}
710   with exact STACK
711   kills ALL
712   gen pop {indir_r_off,ebp,$1}
713
714 pat ste
715   with regorconst
716   kills mem_nonlocals
717   gen move %1,{EXTERN,$1}
718   with exact STACK
719   kills ALL
720   gen pop {EXTERN,$1}
721
722 #ifdef REGVARS
723 pat sil inreg($1)==reg_any
724   with regorconst
725   kills all_mems
726   gen move %1,{indir_r,regvar($1)}
727   with exact STACK
728   kills ALL
729   gen pop {indir_r,regvar($1)}
730 #endif
731 pat sil
732   with regorconst
733   kills all_mems
734   uses ADDREG={indir_r_off,ebp,$1}
735   gen move %1,{indir_r,%a}
736       killreg %a
737   with exact STACK
738   kills ALL
739   uses ADDREG={indir_r_off,ebp,$1}
740   gen pop {indir_r,%a}
741       killreg %a
742
743 pat stf
744   with addreg regorconst
745   kills all_mems
746   gen move %2,{indir_r_off,%1,$1}
747   with exact addreg STACK
748   kills ALL
749   gen pop {indir_r_off, %1,$1}
750   with reg_off regorconst
751   kills all_mems
752   gen move %2,{indir_r_off,%1.reg,%1.off+$1}
753   with exact reg_off STACK
754   gen pop {indir_r_off,%1.reg,$1+%1.off}
755   with indexed_r_off regorconst
756   kills all_mems
757   gen move %2,{indir_indexed_r_off,%1.reg,%1.reg2,%1.scale,%1.off+$1}
758   with exact indexed_r_off STACK
759   kills all_mems
760   gen pop {indir_indexed_r_off,%1.reg,%1.reg2,%1.scale,%1.off+$1}
761   with indexed_off regorconst
762   kills all_mems
763   gen move %2,{indir_indexed_off,%1.reg,%1.scale,%1.off+$1}
764   with exact indexed_off STACK
765   kills all_mems
766   gen pop {indir_indexed_off,%1.reg,%1.scale,%1.off+$1}
767   with ADDR_LOCAL regorconst
768   kills indir,locals %ind+%size > %1.ind+$1 && %ind < %1.ind+$1+4
769   gen move %2,{LOCAL,%1.ind+$1,4}
770   with exact ADDR_LOCAL STACK
771   kills indir,locals %ind+%size > %1.ind+$1 && %ind < %1.ind+$1+4
772   gen pop {LOCAL,%1.ind+$1,4}
773   with ADDR_EXTERN regorconst
774   kills mem_nonlocals
775   gen move %2,{EXTERN,%1.off+$1}
776   with exact ADDR_EXTERN STACK
777   kills mem_nonlocals
778   gen pop {EXTERN,%1.off+$1}
779
780 pat sti $1==4
781   with addreg regorconst
782   kills all_mems
783   gen move %2,{indir_r,%1}
784   with exact addreg STACK
785   kills all_mems
786   gen pop {indir_r,%1}
787   with reg_off regorconst
788   kills all_mems
789   gen move %2,{indir_r_off,%1.reg,%1.off}
790   with exact reg_off STACK
791   kills all_mems
792   gen pop {indir_r_off,%1.reg,%1.off}
793   with indexed_r_off regorconst
794   kills all_mems
795   gen move %2,{indir_indexed_r_off,%1.reg,%1.reg2,%1.scale,%1.off}
796   with exact indexed_r_off STACK
797   kills all_mems
798   gen pop {indir_indexed_r_off,%1.reg,%1.reg2,%1.scale,%1.off}
799   with indexed_off regorconst
800   kills all_mems
801   gen move %2,{indir_indexed_off,%1.reg,%1.scale,%1.off}
802   with exact indexed_off STACK
803   kills all_mems
804   gen pop {indir_indexed_off,%1.reg,%1.scale,%1.off}
805   with ADDR_LOCAL regorconst
806   kills indir,locals %ind+%size > %1.ind && %ind < %1.ind+4
807   gen move %2,{LOCAL,%1.ind,4}
808   with exact ADDR_LOCAL STACK
809   kills indir,locals %ind+%size > %1.ind && %ind < %1.ind+4
810   gen pop {LOCAL,%1.ind,4}
811   with ADDR_EXTERN regorconst
812   kills mem_nonlocals
813   gen move %2,{EXTERN,%1.off}
814   with exact ADDR_EXTERN STACK
815   kills mem_nonlocals
816   gen pop {EXTERN,%1.off}
817
818 pat sti $1==1
819   with addreg regorconst124
820   kills all_mems
821   gen move %2,{indir_r1,%1}
822   with reg_off regorconst124
823   kills all_mems
824   gen move %2,{indir_r_off1,%1.reg,%1.off}
825   with indexed_r_off regorconst124
826   kills all_mems
827   gen move %2,{indir_indexed_r_off1,%1.reg,%1.reg2,%1.scale,%1.off}
828   with indexed_off regorconst124
829   kills all_mems
830   gen move %2,{indir_indexed_off1,%1.reg,%1.scale,%1.off}
831   with ADDR_EXTERN regorconst124
832   kills mem_nonlocals
833   gen move %2,{EXTERN1,%1.off}
834   with ADDR_LOCAL regorconst124
835   kills indir,locals %ind<%1.ind+1 && %ind+%size>%1.ind
836   gen move %2,{indir_r_off1,ebp,%1.ind}
837
838 pat sti $1==2
839   with addreg regorconst24
840   kills all_mems
841   gen move %2,{indir_r2,%1}
842   with reg_off regorconst24
843   kills all_mems
844   gen move %2,{indir_r_off2,%1.reg,%1.off}
845   with indexed_r_off regorconst24
846   kills all_mems
847   gen move %2,{indir_indexed_r_off2,%1.reg,%1.reg2,%1.scale,%1.off}
848   with indexed_off regorconst24
849   kills all_mems
850   gen move %2,{indir_indexed_off2,%1.reg,%1.scale,%1.off}
851   with ADDR_EXTERN regorconst24
852   kills mem_nonlocals
853   gen move %2,{EXTERN2,%1.off}
854   with ADDR_LOCAL regorconst24
855   kills indir,locals %ind<%1.ind+2 && %ind+%size>%1.ind
856   gen move %2,{indir_r_off2,ebp,%1.ind}
857
858 pat sti $1==8                   leaving sdf 0
859
860 pat sti
861   with BXREG
862   kills ALL
863   gen mov ecx,{ANYCON,$1}
864       proccall {label, ".sti"}
865
866 /* this sort of construction gives problems in the codegenerator
867    because of the potential very large lookahead
868
869   with addreg
870   kills ALL
871   gen pop (%1)
872       add %1,{ANYCON,2}                 yields %1       leaving sti $1-4
873
874 */
875
876 pat sts $1==4
877   with CXREG BXREG
878   kills ALL
879   gen proccall {label,".sts"}
880
881 pat sdl
882   with regorconst regorconst    yields %2 %1
883                                         leaving stl $1 stl $1+4
884   with exact STACK                      leaving stl $1 stl $1+4
885
886 pat sde
887   with regorconst regorconst    yields %2 %1
888                                         leaving ste $1 ste $1+4
889   with exact STACK                      leaving ste $1 ste $1+4
890
891 pat sdf
892   with addreg regorconst regorconst
893   kills all_mems
894   gen move %2,{indir_r_off,%1,$1}
895       move %3,{indir_r_off,%1,$1+4}
896   with exact addreg STACK
897   kills all_mems
898   gen pop {indir_r_off,%1,$1}
899       pop {indir_r_off,%1,$1+4}
900   with reg_off regorconst regorconst
901   kills all_mems
902   gen move %2,{indir_r_off,%1.reg,%1.off+$1}
903       move %3,{indir_r_off,%1.reg,%1.off+$1+4}
904   with exact reg_off STACK
905   kills all_mems
906   gen pop {indir_r_off,%1.reg,$1+%1.off}
907       pop {indir_r_off,%1.reg,$1+%1.off+4}
908   with indexed_r_off regorconst regorconst
909   kills all_mems
910   gen move %2,{indir_indexed_r_off,%1.reg,%1.reg2,%1.scale,%1.off+$1}
911       move %3,{indir_indexed_r_off,%1.reg,%1.reg2,%1.scale,%1.off+4+$1}
912   with exact indexed_r_off STACK
913   kills all_mems
914   gen pop {indir_indexed_r_off,%1.reg,%1.reg2,%1.scale,%1.off+$1}
915       pop {indir_indexed_r_off,%1.reg,%1.reg2,%1.scale,%1.off+4+$1}
916   with indexed_off regorconst regorconst
917   kills all_mems
918   gen move %2,{indir_indexed_off,%1.reg,%1.scale,%1.off+$1}
919       move %3,{indir_indexed_off,%1.reg,%1.scale,%1.off+4+$1}
920   with exact indexed_off STACK
921   kills all_mems
922   gen pop {indir_indexed_off,%1.reg,%1.scale,%1.off+$1}
923       pop {indir_indexed_off,%1.reg,%1.scale,%1.off+4+$1}
924   with ADDR_LOCAL regorconst regorconst
925   kills indir,locals %ind+%size > $1 && %ind < $1+8
926   gen   move %2,{LOCAL,%1.ind+$1,4}
927         move %3,{LOCAL,%1.ind+$1+4,4}
928   with exact ADDR_LOCAL STACK
929   kills indir,locals %ind+%size > $1 && %ind < $1+8
930   gen   pop {LOCAL,%1.ind+$1,4}
931         pop {LOCAL,%1.ind+$1+4,4}
932   with ADDR_EXTERN regorconst regorconst
933   kills mem_nonlocals
934   gen   move %2,{EXTERN,%1.off+$1}
935         move %3,{EXTERN,%1.off+$1+4}
936   with exact ADDR_EXTERN STACK
937   kills mem_nonlocals
938   gen   pop {EXTERN,%1.off+$1}
939         pop {EXTERN,%1.off+$1+4}
940
941
942 /****************************************************************
943  *  Group 3 : Integer Arithmetic.                               *
944  *                                                              *
945  *  Implemented (sometimes with the use of subroutines) :       *
946  *  4 byte arithmetic.                                          *
947  ****************************************************************/
948
949 pat adi $1==4
950 #ifdef REGVARS
951 with exact ANYCON RREG
952                                 yields {Rreg_off,%2,%1.val}
953 with exact RREG ANYCON
954                                 yields {Rreg_off,%1,%2.val}
955 #endif
956 with REG rmorconst
957   gen add %1,%2                 yields %1
958 with rmorconst REG
959   gen add %2,%1                 yields %2
960 with EXACT rmorconst const
961   uses reusing %1,REG=%1
962   gen add %a,%2                 yields %a
963
964 /*
965 pat adi !defined($1)
966 with CXREG ACC
967   kills ALL
968   gen proccall {label,".adi"}   yields eax
969 */
970
971 pat sbi $1==4
972
973 with rmorconst REG
974   gen sub %2,%1                 yields %2
975 with EXACT REG rmorconst
976   gen sub %1,%2
977       neg %1                    yields %1
978
979 /*
980 pat sbi !defined($1)
981 with CXREG ACC
982   kills ALL
983   gen proccall {label,".sbi"}   yields eax
984 */
985
986 pat mli $1==4
987 with rm REG
988   gen imul %2,%1                yields %2
989 with REG rm
990   gen imul %1,%2                yields %1
991 with const rm
992   uses reusing %2,REG
993   gen imul %a,%2,%1             yields %a
994 with rm const
995   uses reusing %1,REG
996   gen imul %a,%1,%2             yields %a
997
998 /*
999 pat mli !defined($1)
1000 with ACC
1001   kills ALL
1002   gen proccall {label,".mli"}
1003 */
1004
1005 pat dvi $1==4
1006 with noacc ACC
1007   uses DXREG
1008   gen cdq.
1009       idiv %1                   yields eax
1010
1011 /*
1012 pat dvi !defined($1)
1013 with ACC
1014   kills ALL
1015   gen proccall {label,".dvi"}
1016 */
1017
1018 pat rmi $1==4
1019 with noacc ACC
1020   uses DXREG
1021   gen cdq.
1022       idiv %1                   yields edx
1023
1024 /*
1025 pat rmi !defined($1)
1026 with ACC
1027   kills ALL
1028   gen proccall {label,".rmi"}
1029 */
1030
1031 pat ngi $1==4
1032 with REG
1033   gen neg %1                    yields %1
1034
1035 /*
1036 pat ngi !defined($1)
1037 with ACC
1038   kills ALL
1039   gen proccall {label,".ngi"}
1040 */
1041
1042 pat sli $1==4
1043 with ANYCON REG
1044   gen sal %2,%1                 yields %2
1045 with SHIFT_CREG REG
1046   gen sal %2,cl                 yields %2
1047
1048 /*
1049 pat sli !defined($1)
1050 with ACC
1051   kills ALL
1052   gen proccall {label,".sli"}
1053 */
1054
1055 pat sri $1==4
1056 with SHIFT_CREG REG
1057   gen sar %2,cl                 yields %2
1058 with ANYCON REG
1059   gen sar %2,%1                 yields %2
1060
1061 /*
1062 pat sri !defined($1)
1063 with ACC
1064   kills ALL
1065   gen proccall {label,".sri"}
1066 */
1067
1068 /*******************************************************************
1069  *  Group 4: Unsigned Arithmetic                                   *
1070  *******************************************************************/
1071
1072 pat adu                                 leaving adi $1
1073 pat loc lol adu stl $1==1 && $3==4 && $2==$4    leaving inl $2
1074 pat loc loe adu ste $1==1 && $3==4 && $2==$4    leaving ine $2
1075 pat loc lol adu $1==1 && $3==4          leaving lol $2 inc
1076 pat loc loe adu $1==1 && $3==4          leaving loe $2 inc
1077 pat loc lil adu $1==1 && $3==4          leaving lil $2 inc
1078 pat loc lol adu stl $1==0-1 && $3==4 && $2==$4  leaving del $2
1079 pat loc loe adu ste $1==0-1 && $3==4 && $2==$4  leaving dee $2
1080 pat loc lol adu $1==0-1 && $3==4                leaving lol $2 dec
1081 pat loc loe adu $1==0-1 && $3==4                leaving loe $2 dec
1082 pat loc lil adu $1==0-1 && $3==4                leaving lil $2 dec
1083 pat sbu                                 leaving sbi $1
1084 pat lol loc sbu stl $1==$4 && $2==1 && $3==4    leaving del $1
1085 pat loe loc sbu ste $1==$4 && $2==1 && $3==4    leaving dee $1
1086 pat lol loc sbu $2==1 && $3==4          leaving lol $1 dec
1087 pat loe loc sbu $2==1 && $3==4          leaving loe $1 dec
1088 pat lil loc sbu $2==1 && $3==4          leaving lil $1 dec
1089 pat lol loc sbu stl $1==$4 && $2==0-1 && $3==4  leaving inl $1
1090 pat loe loc sbu ste $1==$4 && $2==0-1 && $3==4  leaving ine $1
1091 pat lol loc sbu $2==0-1 && $3==4                leaving lol $1 inc
1092 pat loe loc sbu $2==0-1 && $3==4                leaving loe $1 inc
1093 pat lil loc sbu $2==0-1 && $3==4                leaving lil $1 inc
1094 pat mlu                                 leaving mli $1
1095
1096 pat loe loc loe adu ste $1==$3 && $1==$5 && $4==4
1097 uses REG = {EXTERN, $1}
1098                                 yields %a leaving loc $2 loe $3 adu 4 ste $3
1099
1100 pat lol loc lol adu stl $1==$3 && $1==$5 && $4==4
1101 uses REG = {LOCAL, $1, 4}
1102                                 yields %a leaving loc $2 lol $3 adu 4 stl $3
1103
1104 pat loe loc loe adi ste $1==$3 && $1==$5 && $4==4
1105 uses REG = {EXTERN, $1}
1106                                 yields %a leaving loc $2 loe $3 adi 4 ste $3
1107
1108 pat lol loc lol adi stl $1==$3 && $1==$5 && $4==4
1109 uses REG = {LOCAL, $1, 4}
1110                                 yields %a leaving loc $2 lol $3 adi 4 stl $3
1111
1112 pat dvu $1==4
1113 with noacc ACC
1114 uses DXREG={ANYCON,0}
1115 gen div %1                      yields eax
1116
1117 /*
1118 pat dvu !defined($1)
1119 with ACC STACK
1120 kills ALL
1121 gen proccall {label,".dvu"}
1122 */
1123
1124 pat rmu $1==4
1125 with noacc ACC
1126 uses DXREG={ANYCON,0}
1127 gen div %1                      yields edx
1128
1129 /*
1130 pat rmu !defined($1)
1131 with ACC STACK
1132 kills ALL
1133 gen proccall {label,".rmu"}
1134 */
1135
1136 pat slu                                 leaving sli $1
1137 pat loc slu                                     leaving loc $1 sli $2
1138
1139 pat sru $1==4
1140 with SHIFT_CREG REG
1141 gen shr %2,cl                   yields %2
1142 with ANYCON REG
1143 gen shr %2,%1                   yields %2
1144
1145 /*
1146 pat sru !defined($1)
1147 with ACC STACK
1148 kills ALL
1149 gen proccall {label,".sru"}
1150 */
1151
1152 /*******************************************************************
1153  *  Group 5: Floating Point Instructions                           *
1154  *******************************************************************/
1155
1156 pat adf $1==4           leaving cal ".adf4" asp 4
1157 pat adf $1==8           leaving cal ".adf8" asp 8
1158 pat sbf $1==4           leaving cal ".sbf4" asp 4
1159 pat sbf $1==8           leaving cal ".sbf8" asp 8
1160 pat mlf $1==4           leaving cal ".mlf4" asp 4
1161 pat mlf $1==8           leaving cal ".mlf8" asp 8
1162 pat dvf $1==4           leaving cal ".dvf4" asp 4
1163 pat dvf $1==8           leaving cal ".dvf8" asp 8
1164 pat ngf $1==4           leaving cal ".ngf4"
1165 pat ngf $1==8           leaving cal ".ngf8"
1166 pat fif $1==4           leaving lor 1 cal ".fif4" asp 4
1167 pat fif $1==8           leaving lor 1 cal ".fif8" asp 4
1168 pat fef $1==4           leaving lor 1 adp 0-4 cal ".fef4"
1169 pat fef $1==8           leaving lor 1 adp 0-4 cal ".fef8"
1170
1171 /******************************************************************
1172  *  Group 6: Pointer Arithmetic                                   *
1173  ******************************************************************/
1174
1175 pat adp $1==1
1176 with exact Xreg_off     yields {Xreg_off,%1.reg,%1.off+$1}
1177 with exact Rreg_off     yields {Rreg_off,%1.reg,%1.off+$1}
1178 with exact indexed_r_off
1179                         yields {indexed_r_off,%1.reg,%1.reg2,%1.scale,%1.off+$1}
1180 with exact indexed_off  yields {indexed_off,%1.reg,%1.scale,%1.off+$1}
1181 with exact ADDR_EXTERN  yields {ADDR_EXTERN,%1.off+$1}
1182 with exact ADDR_LOCAL   yields {ADDR_LOCAL,%1.ind+$1}
1183 with REG
1184   gen inc %1            yields %1
1185 with ADDREG
1186   gen killreg %1
1187                         yields {Xreg_off, %1, $1}
1188 with exact RREG         yields {Rreg_off, %1, $1}
1189
1190 pat adp $1==0-1
1191 with exact Xreg_off     yields {Xreg_off,%1.reg,%1.off+$1}
1192 with exact Rreg_off     yields {Rreg_off,%1.reg,%1.off+$1}
1193 with exact indexed_r_off
1194                         yields {indexed_r_off,%1.reg,%1.reg2,%1.scale,%1.off+$1}
1195 with exact indexed_off  yields {indexed_off,%1.reg,%1.scale,%1.off+$1}
1196 with exact ADDR_EXTERN  yields {ADDR_EXTERN,%1.off+$1}
1197 with exact ADDR_LOCAL   yields {ADDR_LOCAL,%1.ind+$1}
1198 with REG
1199   gen dec %1            yields %1
1200 with ADDREG
1201   gen killreg %1
1202                         yields {Xreg_off, %1, $1}
1203 with exact RREG         yields {Rreg_off, %1, $1}
1204
1205 pat adp
1206 with exact Xreg_off     yields {Xreg_off,%1.reg,%1.off+$1}
1207 with exact Rreg_off     yields {Rreg_off,%1.reg,%1.off+$1}
1208 with exact indexed_r_off
1209                         yields {indexed_r_off,%1.reg,%1.reg2,%1.scale,%1.off+$1}
1210 with exact indexed_off  yields {indexed_off,%1.reg,%1.scale,%1.off+$1}
1211 with exact ADDR_EXTERN  yields {ADDR_EXTERN,%1.off+$1}
1212 with exact ADDR_LOCAL   yields {ADDR_LOCAL,%1.ind+$1}
1213 with ADDREG
1214   gen killreg %1
1215                         yields {Xreg_off,%1,$1}
1216 with exact RREG         yields {Rreg_off, %1, $1}
1217 with REG
1218   gen add %1,{ANYCON,$1}        yields %1
1219
1220 pat ads stl $1==4                       leaving adi 4 stl $2
1221 pat ads ste $1==4                       leaving adi 4 ste $2
1222 pat ads sil $1==4                       leaving adi 4 sil $2
1223 pat ads lol stf $1==4                   leaving adi 4 lol $2 stf $3
1224 pat ads loe stf $1==4                   leaving adi 4 loe $2 stf $3
1225
1226 pat ads $1==4
1227 with exact ANYCON Rreg_off
1228                         yields {Rreg_off,%2.reg,%2.off+%1.val}
1229 with exact ANYCON Xreg_off
1230                         yields {Xreg_off,%2.reg,%2.off+%1.val}
1231 with exact ANYCON indexed_r_off
1232                         yields {indexed_r_off,%2.reg,%2.reg2,
1233                                         %2.scale,%2.off+%1.val}
1234 with exact ANYCON indexed_off
1235                         yields {indexed_off,%2.reg,%2.scale,%2.off+%1.val}
1236 with exact ADDR_EXTERN Rreg_off
1237                         yields {Rreg_off,%2.reg,%2.off+%1.off}
1238 with exact ADDR_EXTERN Xreg_off
1239                         yields {Xreg_off,%2.reg,%2.off+%1.off}
1240 with exact ADDR_EXTERN indexed_r_off
1241                         yields {indexed_r_off,%2.reg,%2.reg2,
1242                                         %2.scale,%2.off+%1.off}
1243 with exact ADDR_EXTERN indexed_off
1244                         yields {indexed_off,%2.reg,%2.scale,%2.off+%1.off}
1245 with exact IREG reg_off
1246                         yields {indexed_r_off,%2.reg,%1,1,%2.off}
1247 with exact reg_off IREG
1248                         yields {indexed_r_off,%1.reg,%2,1,%1.off}
1249 with exact IREG ADDR_LOCAL
1250                         yields {indexed_r_off,ebp,%1,1,%2.ind}
1251 with exact ADDR_LOCAL IREG
1252                         yields {indexed_r_off,ebp,%2,1,%1.ind}
1253 with rmorconst Xreg_off
1254   gen add %2.reg,%1     yields %2
1255 with Xreg_off rmorconst
1256   gen add %1.reg,%2     yields %1
1257 with exact Xreg_off ANYCON
1258                         yields {Xreg_off,%1.reg,%1.off+%2.val}
1259 with exact Rreg_off ANYCON
1260                         yields {Rreg_off,%1.reg,%1.off+%2.val}
1261 with exact indexed_r_off ANYCON
1262                         yields {indexed_r_off,%1.reg,%1.reg2,
1263                                         %1.scale,%1.off+%2.val}
1264 with exact indexed_off ANYCON
1265                         yields {indexed_off,%1.reg,%1.scale,%1.off+%2.val}
1266 with exact Xreg_off ADDR_EXTERN
1267                         yields {Xreg_off,%1.reg,%1.off+%2.off}
1268 with exact Rreg_off ADDR_EXTERN
1269                         yields {Rreg_off,%1.reg,%1.off+%2.off}
1270 with exact indexed_r_off ADDR_EXTERN
1271                         yields {indexed_r_off,%1.reg,%1.reg2,
1272                                         %1.scale,%1.off+%2.off}
1273 with exact indexed_off ADDR_EXTERN
1274                         yields {indexed_off,%1.reg,%1.scale,%1.off+%2.off}
1275 with exact Xreg_off reg_off
1276   gen add %1.reg,%2.reg
1277                         yields {Xreg_off,%1.reg,%1.off+%2.off}
1278 with exact RREG ADDR_EXTERN
1279                         yields {Rreg_off, %1, %2.off}
1280 with exact ADDR_EXTERN RREG
1281                         yields {Rreg_off,%2,%1.off}
1282
1283 with exact rmorconst ADDR_EXTERN
1284   uses reusing %1,ADDREG=%1
1285                         yields {Xreg_off,%a,%2.off}
1286 with exact ADDR_EXTERN rmorconst
1287   uses reusing %2,ADDREG=%2
1288                         yields {Xreg_off,%a,%1.off}
1289 with rmorconst ADDREG
1290   gen add %2,%1         yields %2
1291 with ADDREG rmorconst
1292   gen add %1,%2         yields %1
1293
1294 pat sbs $1==4
1295 with exact ANYCON Xreg_off
1296                         yields {Xreg_off,%2.reg,%2.off+"-"+%1.val}
1297 with exact ANYCON Rreg_off
1298                         yields {Rreg_off,%2.reg,%2.off+"-"+%1.val}
1299 with exact ANYCON indexed_r_off
1300                         yields {indexed_r_off,%2.reg,%2.reg2,%2.scale,
1301                                         %2.off+"-"+%1.val}
1302 with exact ANYCON indexed_off
1303                         yields {indexed_off,%2.reg,%2.scale,%2.off+"-"+%1.val}
1304 with exact ANYCON ADDR_LOCAL
1305                         yields {ADDR_LOCAL,%2.ind-%1.val}
1306 with rm Xreg_off
1307   gen sub %2.reg,%1     yields {Xreg_off,%2.reg,%2.off}
1308
1309 /* Should not occur
1310 with exact reg_off ANYCON
1311                         yields {reg_off,%1.reg,%1.off-%2.val}
1312 with ANYCON ADDR_EXTERN
1313                         yields {ADDR_EXTERN,%2.off+%1.val}
1314 with exact ANYCON ADDR_LOCAL
1315                         yields {ADDR_LOCAL,%1.val+%2.ind}
1316 */
1317
1318 with rm REG
1319   gen sub %2,%1         yields %2
1320 with const ACC
1321   gen sub %2,%1         yields %2
1322
1323 /*******************************************************************
1324  *  Group 7 : Increment/Decrement Zero                             *
1325  *******************************************************************/
1326
1327 pat inc
1328 with REG
1329 gen inc %1                      yields %1
1330
1331 #ifdef REGVARS
1332 pat inl inreg($1)==reg_any
1333   kills regvar($1)
1334   gen inc {LOCAL,$1,4}
1335 #endif
1336
1337 pat inl
1338 kills indir, locals %ind + %size>$1 && %ind<$1+4
1339 gen inc {LOCAL,$1,4}
1340
1341 pat ine
1342 kills mem_nonlocals
1343 gen inc {EXTERN,$1}
1344
1345 pat dec
1346 with REG
1347 gen dec %1                      yields %1
1348
1349 #ifdef REGVARS
1350 pat del inreg($1)==reg_any
1351   kills regvar($1)
1352   gen dec {LOCAL,$1,4}
1353 #endif
1354
1355 pat del
1356 kills indir, locals %ind+%size>$1 && %ind<$1+4
1357 gen dec {LOCAL, $1, 4}
1358
1359 pat dee
1360 kills mem_nonlocals
1361 gen dec {EXTERN, $1}
1362
1363 #ifdef REGVARS
1364 pat zrl inreg($1)==reg_any
1365   kills regvar($1)
1366   gen move {ANYCON, 0}, {LOCAL,$1,4}
1367 #endif
1368
1369 pat zrl
1370 kills indir, locals %ind+%size>$1 && %ind<$1+4
1371 gen move {ANYCON, 0}, {LOCAL,$1,4}
1372
1373 pat zre
1374 kills mem_nonlocals
1375 gen move {ANYCON, 0},  {EXTERN, $1}
1376
1377 pat zrf                 leaving zer $1
1378
1379 pat zer $1==4                   yields {ANYCON, 0}
1380 pat zer $1==8                   yields {ANYCON, 0} {ANYCON, 0}
1381 pat zer $1==12                  yields {ANYCON, 0} {ANYCON, 0}
1382                                        {ANYCON, 0}
1383 pat zer $1==16                  yields {ANYCON, 0} {ANYCON, 0}
1384                                        {ANYCON, 0} {ANYCON, 0}
1385
1386 pat zer defined($1)
1387 with STACK
1388 gen move {ANYCON, $1/4}, ecx
1389     move {ANYCON, 0}, ebx
1390     1:
1391     push ebx
1392     loop {label,1b}
1393
1394 pat zer !defined($1)
1395 with CXREG STACK
1396 gen move {ANYCON, $1/4}, ebx
1397     sar ecx,{ANYCON, 1}
1398     1:
1399     push ebx
1400     loop {label,1b}
1401
1402 #ifdef REGVARS
1403 proc lolrxxxstl example lol adi stl
1404 with rmorconst
1405   kills regvar($1)
1406   gen axx* {LOCAL, $1, 4}, %1
1407
1408 proc lilrxxxsil example lil adi sil
1409 with regorconst
1410 kills all_mems
1411 gen axx* {indir_r, regvar($1)}, %1
1412
1413 proc xxxrstl example adi stl
1414 with rmorconst regorconst-RREG
1415   kills regvar($2)
1416   gen move %1, {LOCAL, $2, 4}
1417       axx* {LOCAL, $2, 4}, %2
1418
1419 pat lol adi stl $1==$3 && $2==4 && inreg($1)==reg_any   call lolrxxxstl("add")
1420 pat lol adu stl $1==$3 && $2==4 && inreg($1)==reg_any   call lolrxxxstl("add")
1421 pat lol ads stl $1==$3 && $2==4 && inreg($1)==reg_any   call lolrxxxstl("add")
1422 pat lol and stl $1==$3 && $2==4 && inreg($1)==reg_any   call lolrxxxstl("and")
1423 pat lol ior stl $1==$3 && $2==4 && inreg($1)==reg_any   call lolrxxxstl("or")
1424 pat lol xor stl $1==$3 && $2==4 && inreg($1)==reg_any   call lolrxxxstl("xor")
1425
1426 pat lil adi sil $1==$3 && $2==4 && inreg($1)==reg_any   call lilrxxxsil("add")
1427 pat lil adu sil $1==$3 && $2==4 && inreg($1)==reg_any   call lilrxxxsil("add")
1428 pat lil ads sil $1==$3 && $2==4 && inreg($1)==reg_any   call lilrxxxsil("add")
1429 pat lil and sil $1==$3 && $2==4 && inreg($1)==reg_any   call lilrxxxsil("and")
1430 pat lil ior sil $1==$3 && $2==4 && inreg($1)==reg_any   call lilrxxxsil("or")
1431 pat lil xor sil $1==$3 && $2==4 && inreg($1)==reg_any   call lilrxxxsil("xor")
1432
1433 pat adi stl $1==4 && inreg($2)==reg_any call xxxrstl("add")
1434 pat adu stl $1==4 && inreg($2)==reg_any call xxxrstl("add")
1435 pat ads stl $1==4 && inreg($2)==reg_any call xxxrstl("add")
1436 pat and stl $1==4 && inreg($2)==reg_any call xxxrstl("and")
1437 pat ior stl $1==4 && inreg($2)==reg_any call xxxrstl("or")
1438 pat xor stl $1==4 && inreg($2)==reg_any call xxxrstl("xor")
1439 #endif
1440
1441 proc lolxxxstl example lol adi stl
1442 with regorconst
1443 kills indir, locals %ind+%size>$1 && %ind<$1+4
1444 gen axx* {LOCAL, $1, 4}, %1
1445
1446 pat lol adi stl $1==$3 && $2==4         call lolxxxstl("add")
1447 pat lol adu stl $1==$3 && $2==4         call lolxxxstl("add")
1448 pat lol ads stl $1==$3 && $2==4         call lolxxxstl("add")
1449 pat lol and stl $1==$3 && $2==4         call lolxxxstl("and")
1450 pat lol ior stl $1==$3 && $2==4         call lolxxxstl("or")
1451 pat lol xor stl $1==$3 && $2==4         call lolxxxstl("xor")
1452
1453 proc lilxxxsil example lil adi sil
1454 with regorconst
1455 kills all_mems
1456 uses ADDREG={LOCAL, $1, 4}
1457 gen axx* {indir_r, %a}, %1
1458     killreg %a
1459
1460 pat lil adi sil $1==$3 && $2==4         call lilxxxsil("add")
1461 pat lil adu sil $1==$3 && $2==4         call lilxxxsil("add")
1462 pat lil ads sil $1==$3 && $2==4         call lilxxxsil("add")
1463 pat lil and sil $1==$3 && $2==4         call lilxxxsil("and")
1464 pat lil ior sil $1==$3 && $2==4         call lilxxxsil("or")
1465 pat lil xor sil $1==$3 && $2==4         call lilxxxsil("xor")
1466
1467 #ifdef REGVARS
1468 proc lilruxxsil example lil ngi sil
1469 kills all_mems
1470 gen uxx* {indir_r, regvar($1)}
1471
1472 pat lil ngi sil $1==$3 && $2==4 && inreg($1)==reg_any   call lilruxxsil("neg")
1473 pat lil com sil $1==$3 && $2==4 && inreg($1)==reg_any   call lilruxxsil("not")
1474 pat lil dec sil $1==$3 && inreg($1)==reg_any            call lilruxxsil("dec")
1475 pat lil inc sil $1==$3 && inreg($1)==reg_any            call lilruxxsil("inc")
1476 pat lil adp sil $1==$3 && inreg($1)==reg_any && $2==1   call lilruxxsil("inc")
1477 pat lil adp sil $1==$3 && inreg($1)==reg_any && $2==(0-1)
1478                                                         call lilruxxsil("dec")
1479 #endif
1480
1481 proc liluxxsil example lil ngi sil
1482 kills all_mems
1483 uses ADDREG={LOCAL, $1, 4}
1484 gen uxx* {indir_r, %a}
1485     killreg %a
1486
1487 pat lil ngi sil $1==$3 && $2==4         call liluxxsil("neg")
1488 pat lil com sil $1==$3 && $2==4         call liluxxsil("not")
1489 pat lil dec sil $1==$3                  call liluxxsil("dec")
1490 pat lil inc sil $1==$3                  call liluxxsil("inc")
1491 pat lil adp sil $1==$3 && $2==1         call liluxxsil("inc")
1492 pat lil adp sil $1==$3 && $2==(0-1)     call liluxxsil("dec")
1493
1494 proc loexxxste example loe adi ste
1495 with regorconst
1496 kills mem_nonlocals
1497 gen axx* {EXTERN, $1}, %1
1498
1499 pat loe adi ste $1==$3 && $2==4         call loexxxste("add")
1500 pat loe adu ste $1==$3 && $2==4         call loexxxste("add")
1501 pat loe ads ste $1==$3 && $2==4         call loexxxste("add")
1502 pat loe and ste $1==$3 && $2==4         call loexxxste("and")
1503 pat loe ior ste $1==$3 && $2==4         call loexxxste("or")
1504 pat loe xor ste $1==$3 && $2==4         call loexxxste("xor")
1505
1506 #ifdef REGVARS
1507 proc lofrxxxsof example lol lof adi lol stf
1508 with regorconst
1509 kills all_mems
1510 gen axx* {indir_r_off, regvar($1), $2}, %1
1511
1512 pat lol lof adi lol stf $1==$4 && $2==$5 && $3==4 && inreg($1)==reg_any
1513                                         call lofrxxxsof("add")
1514 pat lol lof adu lol stf $1==$4 && $2==$5 && $3==4 && inreg($1)==reg_any
1515                                         call lofrxxxsof("add")
1516 pat lol lof ads lol stf $1==$4 && $2==$5 && $3==4 && inreg($1)==reg_any
1517                                         call lofrxxxsof("add")
1518 pat lol lof and lol stf $1==$4 && $2==$5 && $3==4 && inreg($1)==reg_any
1519                                         call lofrxxxsof("and")
1520 pat lol lof ior lol stf $1==$4 && $2==$5 && $3==4 && inreg($1)==reg_any
1521                                         call lofrxxxsof("or")
1522 pat lol lof xor lol stf $1==$4 && $2==$5 && $3==4 && inreg($1)==reg_any
1523                                         call lofrxxxsof("xor")
1524
1525 proc lofruxxsof example lol lof inc lol stf
1526 kills all_mems
1527 gen uxx* {indir_r_off, regvar($1), $2}
1528
1529 pat lol lof inc lol stf $1==$4 && $2==$5 && inreg($1)==reg_any
1530                                         call lofruxxsof("inc")
1531 pat lol lof adp lol stf $1==$4 && $2==$5 && inreg($1)==reg_any && $3==1
1532                                         call lofruxxsof("inc")
1533 pat lol lof dec lol stf $1==$4 && $2==$5 && inreg($1)==reg_any
1534                                         call lofruxxsof("dec")
1535 pat lol lof adp lol stf $1==$4 && $2==$5 && inreg($1)==reg_any && $3==(0-1)
1536                                         call lofruxxsof("dec")
1537 pat lol lof ngi lol stf $1==$4 && $2==$5 && $3==4 && inreg($1)==reg_any
1538                                         call lofruxxsof("neg")
1539 pat lol lof com lol stf $1==$4 && $2==$5 && $3==4 && inreg($1)==reg_any
1540                                         call lofruxxsof("not")
1541
1542 pat lol lof dup adp lol stf $1==$5 && $2==$6 && $3==4 && inreg($1)==reg_any
1543 kills all_mems
1544 uses ADDREG={indir_r_off, regvar($1), $2}
1545 gen add {indir_r_off, regvar($1), $2}, {ANYCON, $4}     yields %a
1546
1547 #endif
1548
1549 proc lofuxxsof example lol lof inc lol stf
1550 kills all_mems
1551 uses ADDREG={LOCAL,$1,4}
1552 gen uxx* {indir_r_off, %a, $2}
1553     killreg %a
1554
1555 pat lol lof ngi lol stf $1==$4 && $2==$5 && $3==4       call lofuxxsof("neg")
1556 pat lol lof com lol stf $1==$4 && $2==$5 && $3==4       call lofuxxsof("not")
1557 pat lol lof dec lol stf $1==$4 && $2==$5                call lofuxxsof("dec")
1558 pat lol lof inc lol stf $1==$4 && $2==$5                call lofuxxsof("inc")
1559 pat lol lof adp lol stf $1==$4 && $2==$5 && $3==1       call lofuxxsof("inc")
1560 pat lol lof adp lol stf $1==$4 && $2==$5 && $3==(0-1)   call lofuxxsof("dec")
1561
1562 proc lofxxxsof example lol lof adi lol stf
1563 with regorconst
1564 kills all_mems
1565 uses ADDREG={LOCAL,$1,4}
1566 gen axx* {indir_r_off, %a, $2}, %1
1567     killreg %a
1568
1569 pat lol lof adi lol stf $1==$4 && $2==$5 && $3==4       call lofxxxsof("add")
1570 pat lol lof adu lol stf $1==$4 && $2==$5 && $3==4       call lofxxxsof("add")
1571 pat lol lof ads lol stf $1==$4 && $2==$5 && $3==4       call lofxxxsof("add")
1572 pat lol lof and lol stf $1==$4 && $2==$5 && $3==4       call lofxxxsof("and")
1573 pat lol lof ior lol stf $1==$4 && $2==$5 && $3==4       call lofxxxsof("or")
1574 pat lol lof xor lol stf $1==$4 && $2==$5 && $3==4       call lofxxxsof("xor")
1575
1576 pat lol lof dup adp lol stf $1==$5 && $2==$6 && $3==4
1577 kills all_mems
1578 uses ADDREG={LOCAL,$1,4},ADDREG
1579 gen mov %b, {indir_r_off, %a, $2}
1580     add {indir_r_off, %a, $2}, {ANYCON, $4}
1581     killreg %a                          yields %b
1582
1583 proc lefuxxsef example loe lof inc loe stf
1584 kills all_mems
1585 uses ADDREG={EXTERN,$1}
1586 gen uxx* {indir_r_off, %a, $2}
1587     killreg %a
1588
1589 pat loe lof ngi loe stf $1==$4 && $2==$5 && $3==4       call lefuxxsef("neg")
1590 pat loe lof com loe stf $1==$4 && $2==$5 && $3==4       call lefuxxsef("not")
1591 pat loe lof dec loe stf $1==$4 && $2==$5                call lefuxxsef("dec")
1592 pat loe lof inc loe stf $1==$4 && $2==$5                call lefuxxsef("inc")
1593 pat loe lof adp loe stf $1==$4 && $2==$5 && $3==1       call lefuxxsef("inc")
1594 pat loe lof adp loe stf $1==$4 && $2==$5 && $3==(0-1)   call lefuxxsef("dec")
1595
1596 proc lefxxxsef example loe lof adi loe stf
1597 with regorconst
1598 kills all_mems
1599 uses ADDREG={EXTERN,$1}
1600 gen axx* {indir_r_off, %a, $2}, %1
1601     killreg %a
1602
1603 pat loe lof adi loe stf $1==$4 && $2==$5 && $3==4       call lefxxxsef("add")
1604 pat loe lof adu loe stf $1==$4 && $2==$5 && $3==4       call lefxxxsef("add")
1605 pat loe lof ads loe stf $1==$4 && $2==$5 && $3==4       call lefxxxsef("add")
1606 pat loe lof and loe stf $1==$4 && $2==$5 && $3==4       call lefxxxsef("and")
1607 pat loe lof ior loe stf $1==$4 && $2==$5 && $3==4       call lefxxxsef("or")
1608 pat loe lof xor loe stf $1==$4 && $2==$5 && $3==4       call lefxxxsef("xor")
1609
1610 pat loe lof dup adp loe stf $1==$5 && $2==$6 && $3==4
1611 kills all_mems
1612 uses ADDREG={EXTERN,$1},ADDREG
1613 gen mov %b, {indir_r_off, %a, $2}
1614     add {indir_r_off, %a, $2}, {ANYCON, $4}
1615     killreg %a                          yields %b
1616
1617 proc leiuxxsei example loe loi inc loe sti
1618 kills all_mems
1619 uses ADDREG={EXTERN,$1}
1620 gen uxx* {indir_r, %a}
1621     killreg %a
1622
1623 pat loe loi ngi loe sti $1==$4 && $2==4 && $5==4 && $3==4
1624         call leiuxxsei("neg")
1625 pat loe loi com loe sti $1==$4 && $2==4 && $5==4 && $3==4
1626         call leiuxxsei("not")
1627 pat loe loi dec loe sti $1==$4 && $2==4 && $5==4
1628         call leiuxxsei("dec")
1629 pat loe loi inc loe sti $1==$4 && $2==4 && $5==4
1630         call leiuxxsei("inc")
1631 pat loe loi adp loe sti $1==$4 && $2==4 && $5==4 && $3==1
1632         call leiuxxsei("inc")
1633 pat loe loi adp loe sti $1==$4 && $2==4 && $5==4 && $3==(0-1)
1634         call leiuxxsei("dec")
1635
1636 proc leixxxsei example loe loi adi loe sti
1637 with regorconst
1638 kills all_mems
1639 uses ADDREG={EXTERN,$1}
1640 gen axx* {indir_r, %a}, %1
1641     killreg %a
1642
1643 pat loe loi adi loe sti $1==$4 && $2==4 && $5==4 && $3==4
1644         call leixxxsei("add")
1645 pat loe loi adu loe sti $1==$4 && $2==4 && $5==4 && $3==4
1646         call leixxxsei("add")
1647 pat loe loi ads loe sti $1==$4 && $2==4 && $5==4 && $3==4
1648         call leixxxsei("add")
1649 pat loe loi and loe sti $1==$4 && $2==4 && $5==4 && $3==4
1650         call leixxxsei("and")
1651 pat loe loi ior loe sti $1==$4 && $2==4 && $5==4 && $3==4
1652         call leixxxsei("or")
1653 pat loe loi xor loe sti $1==$4 && $2==4 && $5==4 && $3==4
1654         call leixxxsei("xor")
1655
1656 #ifdef REGVARS
1657 proc lifuxxsif example lil lof inc lil stf
1658 kills all_mems
1659 uses ADDREG={indir_r,regvar($1)}
1660 gen uxx* {indir_r_off, %a, $2}
1661     killreg %a
1662
1663 pat lil lof ngi lil stf $1==$4 && $2==$5 && $3==4 && inreg($1)>0
1664         call lifuxxsif("neg")
1665 pat lil lof com lil stf $1==$4 && $2==$5 && $3==4 && inreg($1)>0
1666         call lifuxxsif("not")
1667 pat lil lof dec lil stf $1==$4 && $2==$5 && inreg($1)>0
1668         call lifuxxsif("dec")
1669 pat lil lof inc lil stf $1==$4 && $2==$5 && inreg($1)>0
1670         call lifuxxsif("inc")
1671
1672 proc lifxxxsif example lil lof adi lil stf
1673 with regorconst
1674 kills all_mems
1675 uses ADDREG={indir_r,regvar($1)}
1676 gen axx* {indir_r_off, %a, $2}, %1
1677     killreg %a
1678
1679 pat lil lof adi lil stf $1==$4 && $2==$5 && $3==4 && inreg($1)>0
1680         call lifxxxsif("add")
1681 pat lil lof adu lil stf $1==$4 && $2==$5 && $3==4 && inreg($1)>0
1682         call lifxxxsif("add")
1683 pat lil lof ads lil stf $1==$4 && $2==$5 && $3==4 && inreg($1)>0
1684         call lifxxxsif("add")
1685 pat lil lof and lil stf $1==$4 && $2==$5 && $3==4 && inreg($1)>0
1686         call lifxxxsif("and")
1687 pat lil lof ior lil stf $1==$4 && $2==$5 && $3==4 && inreg($1)>0
1688         call lifxxxsif("or")
1689 pat lil lof xor lil stf $1==$4 && $2==$5 && $3==4 && inreg($1)>0
1690         call lifxxxsif("xor")
1691
1692 proc liiuxxsii example lil loi inc lil sti
1693 kills all_mems
1694 uses ADDREG={indir_r,regvar($1)}
1695 gen uxx* {indir_r, %a}
1696     killreg %a
1697
1698 pat lil loi ngi lil sti $1==$4 && $2==4 && $5==4 && $3==4 && inreg($1)>0
1699         call liiuxxsii("neg")
1700 pat lil loi com lil sti $1==$4 && $2==4 && $5==4 && $3==4 && inreg($1)>0
1701         call liiuxxsii("not")
1702 pat lil loi dec lil sti $1==$4 && $2==4 && $5==4 && inreg($1)>0
1703         call liiuxxsii("dec")
1704 pat lil loi inc lil sti $1==$4 && $2==4 && $5==4 && inreg($1)>0
1705         call liiuxxsii("inc")
1706 pat lil loi adp lil sti $1==$4 && $2==4 && $5==4 && inreg($1)>0 && $3==1
1707         call liiuxxsii("inc")
1708 pat lil loi adp lil sti $1==$4 && $2==4 && $5==4 && inreg($1)>0 && $3==(0-1)
1709         call liiuxxsii("dec")
1710
1711 proc liixxxsii example lil loi adi lil sti
1712 with regorconst
1713 kills all_mems
1714 uses ADDREG={indir_r,regvar($1)}
1715 gen axx* {indir_r, %a}, %1
1716     killreg %a
1717
1718 pat lil loi adi lil sti $1==$4 && $2==4 && $5==4 && $3==4 && inreg($1)>0
1719         call liixxxsii("add")
1720 pat lil loi adu lil sti $1==$4 && $2==4 && $5==4 && $3==4 && inreg($1)>0
1721         call liixxxsii("add")
1722 pat lil loi ads lil sti $1==$4 && $2==4 && $5==4 && $3==4 && inreg($1)>0
1723         call liixxxsii("add")
1724 pat lil loi and lil sti $1==$4 && $2==4 && $5==4 && $3==4 && inreg($1)>0
1725         call liixxxsii("and")
1726 pat lil loi ior lil sti $1==$4 && $2==4 && $5==4 && $3==4 && inreg($1)>0
1727         call liixxxsii("or")
1728 pat lil loi xor lil sti $1==$4 && $2==4 && $5==4 && $3==4 && inreg($1)>0
1729         call liixxxsii("xor")
1730
1731 proc lolcrxxstl example lol loc sbi stl
1732   kills regvar($1)
1733   gen axx* {LOCAL,$1,4},{ANYCON,$2}
1734
1735 pat lol loc sbi stl $1==$4 && $3==4 && inreg($1)==reg_any
1736                                                 call lolcrxxstl("sub")
1737 pat lol loc sbu stl $1==$4 && $3==4 && inreg($1)==reg_any
1738                                                 call lolcrxxstl("sub")
1739 pat lol loc sli stl $1==$4 && $3==4 && inreg($1)==reg_any
1740                                                 call lolcrxxstl("sal")
1741 pat lol loc slu stl $1==$4 && $3==4 && inreg($1)==reg_any
1742                                                 call lolcrxxstl("sal")
1743 pat lol loc sri stl $1==$4 && $3==4 && inreg($1)==reg_any
1744                                                 call lolcrxxstl("sar")
1745 pat lol loc sru stl $1==$4 && $3==4 && inreg($1)==reg_any
1746                                                 call lolcrxxstl("shr")
1747 #endif
1748
1749 proc lolcxxstl example lol loc sbi stl
1750   kills indir, locals %ind+%size>$1 && %ind<$1+4
1751   gen axx* {LOCAL,$1,4},{ANYCON,$2}
1752
1753 pat lol loc sbi stl $1==$4 && $3==4             call lolcxxstl("sub")
1754 pat lol loc sbu stl $1==$4 && $3==4             call lolcxxstl("sub")
1755 pat lol loc adi stl $1==$4 && $3==4             call lolcxxstl("add")
1756 pat lol loc adi stl $1==$4 && $3==4             call lolcxxstl("add")
1757 pat lol loc sli stl $1==$4 && $3==4             call lolcxxstl("sal")
1758 pat lol loc slu stl $1==$4 && $3==4             call lolcxxstl("sal")
1759 pat lol loc sri stl $1==$4 && $3==4             call lolcxxstl("sar")
1760 pat lol loc sru stl $1==$4 && $3==4             call lolcxxstl("shr")
1761
1762 proc loecxxste example loe loc sbi ste
1763   kills mem_nonlocals
1764   gen axx* {EXTERN,$1},{ANYCON,$2}
1765
1766 pat loe loc sbi ste $1==$4 && $3==4             call loecxxste("sub")
1767 pat loe loc sbu ste $1==$4 && $3==4             call loecxxste("sub")
1768 pat loe loc adu ste $1==$4 && $3==4             call loecxxste("add")
1769 pat loe loc adi ste $1==$4 && $3==4             call loecxxste("add")
1770 pat loe loc sli ste $1==$4 && $3==4             call loecxxste("sal")
1771 pat loe loc slu ste $1==$4 && $3==4             call loecxxste("sal")
1772 pat loe loc sri ste $1==$4 && $3==4             call loecxxste("sar")
1773 pat loe loc sru ste $1==$4 && $3==4             call loecxxste("shr")
1774
1775 #ifdef REGVARS
1776 proc lilcxxsil example lil loc sbi sil
1777   kills mem_nonlocals
1778   gen axx* {indir_r,regvar($1)},{ANYCON,$2}
1779
1780 pat lil loc sbi sil $1==$4 && $3==4 && inreg($1)>0      call lilcxxsil("sub")
1781 pat lil loc sbu sil $1==$4 && $3==4 && inreg($1)>0      call lilcxxsil("sub")
1782 pat lil loc adu sil $1==$4 && $3==4 && inreg($1)>0      call lilcxxsil("add")
1783 pat lil loc adi sil $1==$4 && $3==4 && inreg($1)>0      call lilcxxsil("add")
1784 pat lil loc sli sil $1==$4 && $3==4 && inreg($1)>0      call lilcxxsil("sal")
1785 pat lil loc slu sil $1==$4 && $3==4 && inreg($1)>0      call lilcxxsil("sal")
1786 pat lil loc sri sil $1==$4 && $3==4 && inreg($1)>0      call lilcxxsil("sar")
1787 pat lil loc sru sil $1==$4 && $3==4 && inreg($1)>0      call lilcxxsil("shr")
1788
1789 pat lol ngi stl $1==$3 && $2==4 && inreg($1)==reg_any
1790 kills regvar($1)
1791 gen neg {LOCAL, $1, 4}
1792 #endif
1793
1794 pat lol ngi stl $1==$3 && $2==4
1795 kills indir, locals %ind+%size>$1 && %ind<$1+4
1796 gen neg {LOCAL, $1, 4}
1797
1798 pat lol dup adp stl loi stl $1==$4 && $2==4 && $5<=4
1799                                         leaving lol $1 loi $5 stl $6 lol $1 adp $3 stl $4
1800
1801 #ifdef REGVARS
1802 pat lol dup adp stl loi loc loc cii $1==$4 && $2==4 && $5==1 && inreg($1) > 0 && $6==1 && $7==4
1803 uses REG
1804 gen movsxb %a,{indir_r1, regvar($1)}
1805                                 yields %a
1806                                         leaving lol $1 adp $3 stl $4
1807
1808 pat lol dup adp stl loi $1==$4 && $2==4 && $5==1 && inreg($1) > 0
1809 uses REG1 = {indir_r1, regvar($1)}
1810                                 yields %a
1811                                         leaving lol $1 adp $3 stl $4
1812
1813 pat lol dup adp stl loi loc loc cii $1==$4 && $2==4 && $5==2 && inreg($1) > 0 && $6==2 && $7==4
1814 uses REG
1815 gen movsx %a,{indir_r2, regvar($1)}
1816                                 yields %a
1817                                         leaving lol $1 adp $3 stl $4
1818
1819 pat lol dup adp stl loi $1==$4 && $2==4 && $5==2 && inreg($1) > 0
1820 uses REG2 = {indir_r2, regvar($1)}
1821                                 yields %a
1822                                         leaving lol $4 adp $3 stl $4
1823
1824 pat lol dup adp stl loi $1==$4 && $2==4 && $5==4 && inreg($1) > 0
1825 uses REG = {indir_r, regvar($1)}
1826                                 yields %a
1827                                         leaving lol $4 adp $3 stl $4
1828 pat adp stl inreg($2) > 0               leaving stl $2 lol $2 adp $1 stl $2
1829 #endif
1830
1831 pat lol dup adp stl $1==$4 && $2==4
1832 uses ADDREG={LOCAL,$1,4}        yields %a
1833                                         leaving lol $4 adp $3 stl $4
1834
1835 pat lol inl $1==$2
1836 uses REG={LOCAL,$1,4}           yields %a
1837                                         leaving inl $1
1838
1839 pat lol del $1==$2
1840 uses REG={LOCAL,$1,4}           yields %a
1841                                         leaving del $1
1842
1843 pat lol adp stl $1==$3 && $2==1         leaving inl $1
1844 pat lol adp stl $1==$3 && $2==0-1       leaving del $1
1845 pat lol adp stl $1==$3                  leaving loc $2 lol $1 adi 4 stl $3
1846
1847 #ifdef REGVARS
1848 pat lol com stl $1==$3 && $2==4 && inreg($1)==reg_any
1849 kills regvar($1)
1850 gen not {LOCAL,$1,4}
1851 #endif
1852
1853 pat lol com stl $1==$3 && $2==4
1854 kills indir, locals %ind+%size>$1 && %ind<$1+4
1855 gen not {LOCAL, $1, 4}
1856
1857 #ifdef REGVARS
1858 pat lil dup adp sil $1==$4 && $2==4 && inreg($1)==reg_any
1859 uses ADDREG={indir_r, regvar($1)}
1860                                 yields %a
1861                                         leaving lil $4 adp $3 sil $4
1862
1863 pat lil dup inc sil $1==$4 && $2==4 && inreg($1)==reg_any
1864 uses REG={indir_r, regvar($1)}
1865                                 yields %a
1866                                         leaving lil $4 inc sil $4
1867
1868 pat lil dup dec sil $1==$4 && $2==4 && inreg($1)==reg_any
1869 uses REG={indir_r, regvar($1)}
1870                                 yields %a
1871                                         leaving lil $4 dec sil $4
1872 #endif
1873
1874 pat lil adp sil $1==$3 && $2==1         leaving lil $1 inc sil $1
1875
1876 pat lil adp sil $1==$3 && $2==0-1       leaving lil $1 dec sil $1
1877
1878 pat lil adp sil $1==$3                  leaving loc $2 lil $1 adi 4 sil $3
1879
1880 #ifdef REGVARS
1881 pat lol lof lol lof adp lol stf
1882         $1==$3 && $1==$6 && $2==$4 && $2==$7 && inreg($1)==reg_any
1883 uses ADDREG={indir_r_off, regvar($1), $2}
1884                                 yields %a
1885                                         leaving lol $1 lof $2 adp $5 lol $6 stf $7
1886
1887 pat lol lof lol lof inc lol stf
1888         $1==$3 && $1==$6 && $2==$4 && $2==$7 && inreg($1)==reg_any
1889 uses REG={indir_r_off, regvar($1), $2}
1890                                 yields %a
1891                                         leaving lol $1 lof $2 inc lol $6 stf $7
1892
1893 pat lol lof lol lof dec lol stf
1894         $1==$3 && $1==$6 && $2==$4 && $2==$7 && inreg($1)==reg_any
1895 uses REG={indir_r_off, regvar($1), $2}
1896                                 yields %a
1897                                         leaving lol $1 lof $2 dec lol $6 stf $7
1898
1899 pat lol lof dup adp lol stf
1900         $1==$5 && $2==$6 && $3==4 && inreg($1)==reg_any
1901 uses REG={indir_r_off, regvar($1), $2}
1902                                 yields %a
1903                                         leaving lol $1 lof $2 adp $4 lol $1 stf
1904 $2
1905
1906 pat lol lof dup inc lol stf
1907         $1==$5 && $2==$6 && $3==4 && inreg($1)==reg_any
1908 uses REG={indir_r_off, regvar($1), $2}
1909                                 yields %a
1910                                         leaving lol $1 lof $2 inc lol $1 stf $2
1911
1912 pat lol lof dup dec lol stf
1913         $1==$5 && $2==$6 && $3==4 && inreg($1)==reg_any
1914 uses REG={indir_r_off, regvar($1), $2}
1915                                 yields %a
1916                                         leaving lol $1 lof $2 dec lol $1 stf $2
1917
1918 #endif
1919
1920 pat lol lof adp lol stf $1==$4 && $2==$5
1921                         leaving loc $3 lol $1 lof $2 adi 4 lol $4 stf $5
1922
1923 pat lol lof dup adp lol stf
1924         $1==$5 && $2==$6 && $3==4 && $4==1
1925 kills all_mems
1926 uses REG={LOCAL,$1,4}, REG
1927 gen move {indir_r_off, %a, $2},%b
1928     inc {indir_r_off, %a, $2}
1929                                 yields %b
1930
1931 pat loe lof dup adp loe stf
1932         $1==$5 && $2==$6 && $3==4 && $4==1
1933 kills all_mems
1934 uses REG={EXTERN,$1}, REG
1935 gen move {indir_r_off, %a, $2},%b
1936     inc {indir_r_off, %a, $2}
1937                                 yields %b
1938
1939 pat loe loi dup adp loe sti
1940         $1==$5 && $2==$6 && $3==4 && $2==4 && $4==1
1941 kills all_mems
1942 uses REG={EXTERN,$1}, REG
1943 gen move {indir_r, %a},%b
1944     inc {indir_r, %a}
1945                                 yields %b
1946
1947 pat lol lof dup adp lol stf
1948         $1==$5 && $2==$6 && $3==4 && $4==(0-1)
1949 kills all_mems
1950 uses REG={LOCAL,$1,4}, REG
1951 gen move {indir_r_off, %a, $2},%b
1952     dec {indir_r_off, %a, $2}
1953                                 yields %b
1954
1955 pat loe lof dup adp loe stf
1956         $1==$5 && $2==$6 && $3==4 && $4==(0-1)
1957 kills all_mems
1958 uses REG={EXTERN,$1}, REG
1959 gen move {indir_r_off, %a, $2},%b
1960     dec {indir_r_off, %a, $2}
1961                                 yields %b
1962 pat loe loi dup adp loe sti
1963         $1==$5 && $2==$6 && $3==4 && $2==4 && $4==(0-1)
1964 kills all_mems
1965 uses REG={EXTERN,$1}, REG
1966 gen move {indir_r, %a},%b
1967     dec {indir_r, %a}
1968                                 yields %b
1969
1970 pat lol lof dup adp lol stf
1971         $1==$5 && $2==$6 && $3==4
1972 kills all_mems
1973 uses REG={LOCAL,$1,4}, REG
1974 gen move {indir_r_off, %a, $2},%b
1975     add {indir_r_off, %a, $2}, {ANYCON, $4}
1976                                 yields %b
1977
1978 pat loe lof dup adp loe stf
1979         $1==$5 && $2==$6 && $3==4
1980 kills all_mems
1981 uses REG={EXTERN,$1}, REG
1982 gen move {indir_r_off, %a, $2},%b
1983     add {indir_r_off, %a, $2}, {ANYCON, $4}
1984                                 yields %b
1985
1986 pat loe loi dup adp loe sti
1987         $1==$5 && $2==$6 && $3==4 && $2==4
1988 kills all_mems
1989 uses REG={EXTERN,$1}, REG
1990 gen move {indir_r, %a},%b
1991     add {indir_r, %a}, {ANYCON, $4}
1992                                 yields %b
1993
1994
1995 pat loe ngi ste $1==$3 && $2==4
1996 kills mem_nonlocals
1997 gen neg {EXTERN, $1}
1998
1999 pat loe dup adp ste $1==$4 && $2==4
2000 uses REG={EXTERN,$1}    yields %a
2001                                         leaving loe $1 adp $3 ste $1
2002
2003 pat loe ine $1==$2
2004 uses REG={EXTERN,$1}    yields %a
2005                                         leaving ine $1
2006
2007 pat loe dee $1==$2
2008 uses REG={EXTERN,$1}    yields %a
2009                                         leaving dee $1
2010
2011 pat loe adp ste $1==$3 && $2==1         leaving ine $1
2012
2013 pat loe adp ste $1==$3 && $2==0-1       leaving dee $1
2014
2015 pat loe adp ste $1==$3                  leaving loc $2 loe $1 adi 4 ste $3
2016
2017 pat loe com ste $1==$3 && $2==4
2018 kills mem_nonlocals
2019 gen not {EXTERN, $1}
2020
2021 pat loe lof adp loe stf $1==$4 && $2==$5
2022                                 leaving loc $3 loe $1 lof $2 adi 4 loe $1 stf $2
2023
2024 pat loe loi adp loe sti $1==$4 && $2==$5 && $2==4
2025                                 leaving loc $3 loe $1 loi $2 adi 4 loe $1 sti $2
2026
2027 pat lil lof adp lil stf $1==$4 && $2==$5 && $3==1
2028                                 leaving lil $1 lof $2 inc lil $1 stf $2
2029 pat lil lof adp lil stf $1==$4 && $2==$5 && $3==0-1
2030                                 leaving lil $1 lof $2 dec lil $1 stf $2
2031 pat lil lof adp lil stf $1==$4 && $2==$5
2032                                 leaving loc $3 lil $1 lof $2 adi 4 lil $1 stf $2
2033 pat lil loi adp lil sti $1==$4 && $2==$5 && $2==4 && $3==1
2034                                 leaving lil $1 loi $2 inc lil $1 sti $2
2035 pat lil loi adp lil sti $1==$4 && $2==$5 && $2==4 && $3==0-1
2036                                 leaving lil $1 loi $2 dec lil $1 sti $2
2037 pat lil loi adp lil sti $1==$4 && $2==$5 && $2==4
2038                                 leaving loc $3 lil $1 loi $2 adi 4 lil $1 sti $2
2039
2040 /*******************************************************************
2041  *  Group 8: Convert Instructions                                  *
2042  *******************************************************************/
2043
2044 pat cii
2045 with CXREG DXREG ACC
2046 kills ALL
2047 gen proccall {label,".cii"}             yields %3
2048
2049 pat ciu                                 leaving cuu
2050 pat cui                                 leaving cuu
2051
2052 pat cuu
2053
2054 pat loc loc cii zeq $1==1
2055 with GENREG STACK
2056 gen test %1.1
2057     je {label, $4}
2058
2059 pat loc loc cii zne $1==1
2060 with GENREG STACK
2061 gen test %1.1
2062     jne {label, $4}
2063
2064 pat loc loc cii loc and zeq $4<256 && $4>=0 && $5==4 && $1==1 && $2==4
2065                 leaving loc $4 and $5 zeq $6
2066 pat loc loc cii loc and zne $4<256 && $4>=0 && $5==4 && $1==1 && $2==4
2067                 leaving loc $4 and $5 zne $6
2068 pat loc loc cii loc and zeq $4<65536 && $4>=0 && $5==4 && $1==2 && $2==4
2069                 leaving loc $4 and $5 zeq $6
2070 pat loc loc cii loc and zne $4<65536 && $4>=0 && $5==4 && $1==2 && $2==4
2071                 leaving loc $4 and $5 zne $6
2072
2073 pat loc loc cii $1==1 && $2==4
2074 with ACC
2075 gen movsxb %1,%1                yields eax
2076 with exact rm1
2077 uses reusing %1, GENREG
2078 gen movsxb %a,%1                yields %a
2079
2080 pat loc loc cii $1==2 && $2==4
2081 with ACC
2082 gen  movsx %1,%1                yields eax
2083 with exact rm2
2084 uses reusing %1,GENREG
2085 gen movsx %a,%1                 yields %a
2086
2087 pat loc loc ciu                         leaving loc $1 loc $2 cuu
2088 pat loc loc cui                         leaving loc $1 loc $2 cuu
2089
2090 pat loc loc cuu $1==$2
2091
2092 pat loc loc cif $1==4 && $2==4          leaving loc 4 cal ".cif4" asp 4
2093 pat loc loc cif $1==4 && $2==8          leaving loc 4 cal ".cif8"
2094 pat loc loc cuf $1==4 && $2==4          leaving loc 4 cal ".cuf4" asp 4
2095 pat loc loc cuf $1==4 && $2==8          leaving loc 4 cal ".cuf8"
2096 pat loc loc cfi         leaving loc $1 loc $2 cal ".cfi" asp 8+($1-4)
2097 pat loc loc cfu         leaving loc $1 loc $2 cal ".cfu" asp 8+($1-4)
2098 pat loc loc cff $1==8 && $2==4  leaving cal ".cff4" asp 4
2099 pat loc loc cff $1==4 && $2==8
2100 with REG
2101 kills ALL
2102   gen push {ANYCON,0}
2103       push %1                   leaving cal ".cff8"
2104
2105 /********************************************************************
2106  *  Group 9 : Logical Instructions                                  *
2107  ********************************************************************/
2108
2109 pat and $1==4
2110 with REG rmorconst
2111   gen and %1,%2                         yields %1
2112 with rmorconst REG
2113   gen and %2,%1                         yields %2
2114
2115 pat loc and $1==255 && $2==4
2116 with GENREG                             yields %1.1
2117
2118 pat and $1==8
2119 with EXACT REG REG rmorconst rmorconst
2120   gen and %1,%3
2121       and %2,%4                         yields %2 %1
2122 with rmorconst rmorconst REG REG
2123   gen and %3,%1
2124       and %4,%2                         yields %4 %3
2125
2126 pat and defined($1)
2127 kills ALL
2128   gen mov ecx,{ANYCON,$1}
2129       proccall {label, ".and"}
2130
2131 pat and !defined($1)
2132 with CXREG
2133 kills ALL
2134   gen proccall {label, ".and"}
2135
2136 pat ior $1==4
2137 with REG rmorconst
2138   gen or %1,%2                          yields %1
2139 with rmorconst REG
2140   gen or %2,%1                          yields %2
2141
2142 pat ior $1==8
2143 with EXACT REG REG rmorconst rmorconst
2144   gen or %1,%3
2145       or %2,%4                          yields %2 %1
2146 with rmorconst rmorconst REG REG
2147   gen or %3,%1
2148       or %4,%2                          yields %4 %3
2149
2150 pat ior defined($1)
2151 kills ALL
2152   gen mov ecx,{ANYCON,$1}
2153       proccall {label, ".ior"}
2154
2155 pat ior !defined($1)
2156 with CXREG
2157 kills ALL
2158   gen proccall {label, ".ior"}
2159
2160 pat xor $1==4
2161 with REG rmorconst
2162   gen xor %1,%2                         yields %1
2163 with rmorconst REG
2164   gen xor %2,%1                         yields %2
2165
2166 pat xor $1==8
2167 with EXACT REG REG rmorconst rmorconst
2168   gen xor %1,%3
2169       xor %2,%4                         yields %2 %1
2170 with rmorconst rmorconst REG REG
2171   gen xor %3,%1
2172       xor %4,%2                         yields %4 %3
2173
2174 pat xor defined($1)
2175 kills ALL
2176   gen mov ecx,{ANYCON,$1}
2177       proccall {label, ".xor"}
2178
2179 pat xor !defined($1)
2180 with CXREG
2181 kills ALL
2182   gen proccall {label, ".xor"}
2183
2184 pat com $1==4
2185 with REG
2186   gen not %1                            yields %1
2187
2188 pat com $1==8
2189 with REG REG
2190   gen not %2
2191       not %1                            yields %2 %1
2192
2193 pat com defined($1)
2194 kills ALL
2195   gen mov ecx,{ANYCON,$1}
2196       proccall {label, ".com"}
2197
2198 pat com !defined($1)
2199 with CXREG
2200 kills ALL
2201   gen proccall {label, ".com"}
2202
2203 pat rol $1==4
2204 with SHIFT_CREG REG
2205   gen rol %2,cl                         yields %2
2206 with ANYCON REG
2207   gen rol %2,%1                         yields %2
2208
2209 pat ror $1==4
2210 with SHIFT_CREG REG
2211   gen ror %2,cl                         yields %2
2212 with ANYCON REG
2213   gen ror %2,%1                         yields %2
2214
2215 /*******************************************************************
2216  *  Group 10 : Set Instructions                                    *
2217  *******************************************************************/
2218
2219 pat inn $1==4
2220 with SHIFT_CREG REG
2221 gen shr %2,cl
2222     and %2,{ANYCON, 1}                  yields %2
2223 with ANYCON REG
2224 gen shr %2,%1
2225     and %2,{ANYCON, 1}                  yields %2
2226
2227 pat loc inn $1==0 && $2==4
2228 with REG
2229 gen and %1,{ANYCON, 1}                  yields %1
2230
2231 pat inn defined($1)
2232 with ACC
2233 kills ALL
2234 gen mov ecx,{ANYCON, $1}
2235     proccall {label,".inn"}             yields eax
2236
2237 pat inn !defined($1)
2238 with CXREG ACC
2239 kills ALL
2240 gen proccall {label,".inn"}             yields eax
2241
2242 pat loc inn zeq $2==4
2243 with rm STACK
2244 gen check %1,{ANYCON,1<<$1}
2245     je {label,$3}
2246
2247 pat loc inn zne $2==4
2248 with rm STACK
2249 gen check %1,{ANYCON,1<<$1}
2250     jne {label,$3}
2251
2252 pat set $1==4
2253 with SHIFT_CREG
2254 uses REG={ANYCON, 1}
2255 gen shl %a,cl                   yields %a
2256
2257 pat set defined($1)
2258 with ACC
2259 kills ALL
2260 gen mov ecx,{ANYCON, $1}
2261     proccall {label,".set"}
2262
2263 pat set !defined($1)
2264 with CXREG ACC
2265 kills ALL
2266 gen proccall {label,".set"}
2267
2268 /********************************************************************
2269  *  Group 11 : Array Instructions                                   *
2270  ********************************************************************/
2271
2272 pat lae aar $2==4 && rom($1,3)==1 && rom($1,1)==0
2273                                 leaving ads 4
2274
2275 pat lae aar $2==4 && rom($1,3)==1 && rom($1,1)!=0
2276                                 leaving adp 0-rom($1,1) ads 4
2277
2278 pat lae aar $2==4 && rom($1,3)==2 && rom($1,1)==0
2279                                 leaving loc 1 sli 4 ads 4
2280
2281 pat lae aar $2==4 && rom($1,3)==2 && rom($1,1)!=0
2282                                 leaving adp 0-rom($1,1) loc 1 sli 4 ads 4
2283
2284 pat lae aar $2==4 && rom($1,3)==4 && rom($1,1)==0
2285                                 leaving loc 2 sli 4 ads 4
2286
2287 pat lae aar $2==4 && rom($1,3)==4 && rom($1,1)!=0
2288                                 leaving adp 0-rom($1,1) loc 2 sli 4 ads 4
2289
2290 pat lae aar $2==4 && rom($1,3)==8 && rom($1,1)==0
2291                                 leaving loc 3 sli 4 ads 4
2292
2293 pat lae aar $2==4 && rom($1,3)==8 && rom($1,1)!=0
2294                                 leaving adp 0-rom($1,1) loc 3 sli 4 ads 4
2295
2296 pat lae aar $2==4 && rom($1,1)==0
2297   with ADDREG
2298   gen imul %1,%1,{ANYCON,rom($1,3)}     yields %1       leaving ads 4
2299
2300 pat lae aar $2==4 && defined(rom($1,1))
2301   with ADDREG
2302   gen imul %1,%1,{ANYCON,rom($1,3)}     yields %1
2303                                 leaving adp 0-rom($1,1)*rom($1,3) ads 4
2304
2305 /* when followed by an LOI or STI instruction, use indexed mode */
2306 pat loc sli ads loi ($1==1 || $1==2 || $1==3) && $2==4 && $3==4
2307 with IREG ADDR_LOCAL            yields {indexed_r_off,ebp,%1,1<<$1,%2.ind}
2308                                         leaving loi $4
2309 with IREG ADDR_EXTERN           yields {indexed_off,%1,1<<$1,%2.off}
2310                                         leaving loi $4
2311 with IREG ADDREG                yields {indexed_r_off,%2,%1,1<<$1,0}
2312                                         leaving loi $4
2313
2314 pat loc sli ads sti ($1==1 || $1==2 || $1==3) && $2==4 && $3==4
2315 with IREG ADDR_LOCAL            yields {indexed_r_off,ebp,%1,1<<$1,%2.ind}
2316                                         leaving sti $4
2317 with IREG ADDR_EXTERN           yields {indexed_off,%1,1<<$1,%2.off}
2318                                         leaving sti $4
2319 with IREG ADDREG                yields {indexed_r_off,%2,%1,1<<$1,0}
2320                                         leaving sti $4
2321
2322 pat loc sli ads ($1==1 || $1==2 || $1==3) && $2==4 && $3==4
2323 with IREG ADDR_LOCAL            yields {indexed_r_off,ebp,%1,1<<$1,%2.ind}
2324 with IREG ADDR_EXTERN           yields {indexed_off,%1,1<<$1,%2.off}
2325 with IREG ADDREG                yields {indexed_r_off,%2,%1,1<<$1,0}
2326 with REG rmorconst
2327 gen sal %1,{ANYCON,$1}          yields %2 %1    leaving ads 4
2328
2329 pat aar $1==4
2330   with AREG REG
2331   gen sub %2,{indir_r,%1}
2332       imul %2,{indir_r_off,%1,8}                yields %2       leaving ads 4
2333   with reg_off REG
2334   gen sub %2,{indir_r_off, %1.reg, %1.off}
2335       imul %2,{indir_r_off, %1.reg, 8+%1.off}
2336                                         yields %2       leaving ads 4
2337   with ADDR_LOCAL REG
2338   gen sub %2,{LOCAL,%1.ind,4}
2339       imul %2,{LOCAL,8+%1.ind,4}        yields %2       leaving ads 4
2340   with ADDR_EXTERN REG
2341   gen sub %2,{EXTERN,%1.off}
2342       imul %2,{EXTERN,8+%1.off}         yields %2       leaving ads 4
2343
2344 pat lae lar defined(rom($1,3))  leaving lae $1 aar $2 loi rom($1,3)
2345
2346 pat lae sar defined(rom($1,3))  leaving lae $1 aar $2 sti rom($1,3)
2347
2348 pat aar !defined($1)
2349   kills ALL
2350   gen proccall {label,".iaar"}          yields ebx
2351
2352 pat sar $1==4
2353   with BXREG ACC
2354   kills ALL
2355   gen proccall {label,".sar4"}
2356
2357 pat sar !defined($1)
2358   kills ALL
2359   gen proccall {label,".isar"}
2360
2361 pat lar $1==4
2362   with BXREG ACC
2363   kills ALL
2364   gen proccall {label,".lar4"}
2365
2366 pat lar !defined($1)
2367   kills ALL
2368   gen proccall {label,".ilar"}
2369
2370 /*******************************************************************
2371  *  Group 12 : Compare Instructions                                *
2372  *******************************************************************/
2373
2374 pat cmi $1==4
2375 with register rmorconst
2376   uses REG={ANYCON,0}
2377   gen cmp %1,%2
2378       je {label,2f}
2379       jl {label,1f}
2380       inc %a
2381       jmp {label,2f}
2382       1:
2383       dec %a
2384       2:                        yields %a
2385 with rmorconst register
2386   uses REG={ANYCON,0}
2387   gen cmp %2,%1
2388       je {label,2f}
2389       jg {label,1f}
2390       inc %a
2391       jmp {label,2f}
2392       1:
2393       dec %a
2394       2:                        yields %a
2395
2396 pat cmu $1==4                            leaving cmp
2397
2398 pat cms $1==4
2399 with REG rmorconst
2400   gen sub %1,%2                 yields %1
2401 with rmorconst REG
2402   gen sub %2,%1                 yields %2
2403
2404 pat cms $1==8
2405 with rmorconst rmorconst REG REG
2406   gen sub %3,%1
2407       sbb %4,%2
2408       or %4,%3                  yields %4
2409 with REG REG rmorconst rmorconst
2410   gen sub %1,%3
2411       sbb %2,%4
2412       or %2,%1                  yields %2
2413
2414 pat cms defined($1)
2415 kills ALL
2416   gen mov ecx,{ANYCON,$1}
2417       proccall {label,".cms"}   yields ecx
2418
2419 pat cms !defined($1)
2420 with CXREG
2421 kills ALL
2422   gen proccall {label,".cms"}   yields ecx
2423
2424 pat cmf $1==4
2425 kills ALL
2426   gen proccall {label,".cmf4"}  leaving asp 8 lfr 4
2427
2428 pat cmf $1==8
2429 kills ALL
2430   gen proccall {label,".cmf8"}  leaving asp 16 lfr 4
2431
2432 pat cmp
2433 with register rmorconst
2434 uses REG = {ANYCON,0}
2435   gen cmp %1,%2
2436       je  {label,2f}
2437       jb  {label,1f}
2438       inc %a
2439       jmp {label,2f}
2440       1: dec %a
2441       2:                            yields %a
2442 with rmorconst register
2443 uses REG = {ANYCON,0}
2444   gen cmp %2,%1
2445       je  {label,2f}
2446       ja  {label,1f}
2447       inc %a
2448       jmp {label,2f}
2449       1: dec %a
2450       2:                            yields %a
2451
2452 proc txx
2453 with rm
2454 uses GENREG = {ANYCON,0}
2455   gen test %1
2456       setxx* %a.1                   yields %a
2457
2458 pat tlt call txx("sets")
2459 pat teq call txx("sete")
2460 pat tne call txx("setne")
2461 pat tge call txx("setns")
2462
2463 /* Explicit test for TLE and TGT. We must make sure that the OC
2464    flag is cleared.
2465 */
2466 pat tle
2467 with rm
2468 uses GENREG = {ANYCON,0}
2469   gen
2470       killcc.
2471       test %1
2472       setle %a.1
2473                                    yields %a
2474
2475 pat tgt
2476 with rm
2477 uses GENREG = {ANYCON,0}
2478   gen
2479       killcc.
2480       test %1
2481       setg %a.1
2482                                    yields %a
2483
2484 proc txxior
2485 with rm REG
2486   gen test %1
2487       jxx* {label,1f}
2488       or  %2,{ANYCON,1}
2489       1:                            yields %2
2490
2491 pat tlt ior $2==4 call txxior("jge")
2492 pat tle ior $2==4 call txxior("jg")
2493 pat teq ior $2==4 call txxior("jne")
2494 pat tne ior $2==4 call txxior("je")
2495 pat tge ior $2==4 call txxior("jl")
2496 pat tgt ior $2==4 call txxior("jle")
2497
2498 proc cmixxior
2499 with regorconst rm REG
2500   gen cmp %2,%1
2501       jxx* {label,1f}
2502       or  %3,{ANYCON,1}
2503       1:                            yields %3
2504
2505 pat cmi tlt ior $1==4 && $3==4 call cmixxior("jge")
2506 pat cmi tle ior $1==4 && $3==4 call cmixxior("jg")
2507 pat cmi teq ior $1==4 && $3==4 call cmixxior("jne")
2508 pat cmi tne ior $1==4 && $3==4 call cmixxior("je")
2509 pat cmi tge ior $1==4 && $3==4 call cmixxior("jl")
2510 pat cmi tgt ior $1==4 && $3==4 call cmixxior("jle")
2511
2512 proc cmxtxx
2513 with regorconst rm
2514 uses REG = {ANYCON,0}
2515   gen cmp %2,%1
2516       jxx[1] {label,1f}
2517       inc %a
2518       1:                            yields %a
2519 with rm regorconst
2520 uses REG = {ANYCON,0}
2521   gen cmp %1,%2
2522       jxx[2] {label,1f}
2523       inc %a
2524       1:                            yields %a
2525
2526 pat cmi tlt $1==4     call cmxtxx("jge","jle")
2527 pat cmi tle $1==4     call cmxtxx("jg","jl")
2528 pat cmi teq $1==4     call cmxtxx("jne","jne")
2529 pat cmi tne $1==4     call cmxtxx("je","je")
2530 pat cmi tge $1==4     call cmxtxx("jl","jg")
2531 pat cmi tgt $1==4     call cmxtxx("jle","jge")
2532 pat cmp tlt           call cmxtxx("jae","jbe")
2533 pat cmp tle           call cmxtxx("ja","jb")
2534 pat cmp teq           call cmxtxx("jne","jne")
2535 pat cmp tne           call cmxtxx("je","je")
2536 pat cmp tge           call cmxtxx("jb","ja")
2537 pat cmp tgt           call cmxtxx("jbe","jae")
2538 pat cms teq $1==4     call cmxtxx("jne","jne")
2539 pat cms tne $1==4     call cmxtxx("je","je")
2540
2541 proc cmxzxx example cmp zlt
2542 with regorconst rm STACK
2543   gen cmp %2,%1
2544       jxx[1] {label,$2}
2545 with rm regorconst STACK
2546   gen cmp %1,%2
2547       jxx[2] {label,$2}
2548
2549 pat cmp zlt         call cmxzxx("jb","ja")
2550 pat cmp zle         call cmxzxx("jbe","jae")
2551 pat cmp zeq         call cmxzxx("je","je")
2552 pat cmp zne         call cmxzxx("jne","jne")
2553 pat cmp zge         call cmxzxx("jae","jbe")
2554 pat cmp zgt         call cmxzxx("ja","jb")
2555 pat cms zeq $1==4   call cmxzxx("je","je")
2556 pat cms zne $1==4   call cmxzxx("jne","jne")
2557
2558 pat cms zne $1==8
2559 with regorconst regorconst rm rm STACK
2560   gen cmp %3,%1
2561       jne {label,$2}
2562       cmp %4,%2
2563       jne {label,$2}
2564 with rm rm regorconst regorconst STACK
2565 kills ALL
2566   gen cmp %1,%3
2567       jne {label,$2}
2568       cmp %2,%4
2569       jne {label,$2}
2570
2571 pat cms zeq $1==8
2572 with regorconst regorconst rm rm STACK
2573   gen cmp %3,%1
2574       jne {label, 1f}
2575       cmp %4,%2
2576       je {label,$2}
2577       1:
2578 with rm rm regorconst regorconst STACK
2579 kills ALL
2580   gen cmp %1,%3
2581       jne {label,1f}
2582       cmp %2,%4
2583       je {label,$2}
2584       1:
2585
2586 proc andzxx example and zeq
2587 with regorconst rm STACK
2588   gen check %2,%1
2589       jxx* {label,$2}
2590 with exact rm regorconst
2591   kills ALL
2592   gen check %1,%2
2593       jxx* {label,$2}
2594
2595 pat and zeq $1==4 call andzxx("je")
2596 pat and zne $1==4 call andzxx("jne")
2597
2598 proc locandzxx example loc and zeq
2599 with rm1 STACK
2600   gen testb %1,{ANYCON,$1}
2601       jxx* {label,$3}
2602 with GENREG STACK
2603   gen testb %1.1,{ANYCON,$1}
2604       jxx* {label,$3}
2605 with exact RREG
2606   kills ALL
2607   gen check %1,{ANYCON,$1}
2608       jxx* {label,$3}
2609
2610 pat loc and zeq $1<256 && $1>=0 && $2==4 call locandzxx("je")
2611 pat loc and zne $1<256 && $1>=0 && $2==4 call locandzxx("jne")
2612
2613 proc locbxx example loc beq
2614 with rm1 STACK
2615   gen cmpb %1,{ANYCON,$1}
2616       jxx* {label,$2}
2617 with rm STACK
2618   gen cmp %1,{ANYCON,$1}
2619       jxx* {label,$2}
2620
2621 pat loc beq $1<256 && $1>=0 call locbxx("je")
2622 pat loc bne $1<256 && $1>=0 call locbxx("jne")
2623
2624 proc loccmuzxx example loc cmu zeq
2625 with rm1 STACK
2626   gen cmpb %1,{ANYCON,$1}
2627       jxx* {label,$3}
2628 with rm STACK
2629   gen cmp %1,{ANYCON,$1}
2630       jxx* {label,$3}
2631
2632 pat loc cmu zeq $1<256 && $1>=0 && $2==4 call loccmuzxx("je")
2633 pat loc cmu zne $1<256 && $1>=0 && $2==4 call loccmuzxx("jne")
2634
2635 /*******************************************************************
2636  *  Group 13 : Branch Instructions                                 *
2637  *******************************************************************/
2638
2639 pat lab topeltsize($1)==4 && !fallthrough($1)
2640   with STACK
2641   kills ALL
2642   gen labeldef $1                 yields eax
2643
2644 pat lab topeltsize($1)==4 && fallthrough($1)
2645   with ACC STACK
2646   kills ALL
2647   gen labeldef $1                 yields eax
2648
2649 pat lab topeltsize($1)!=4
2650   with STACK
2651   kills ALL
2652   gen labeldef $1
2653
2654 pat bra topeltsize($1)==4
2655   with ACC STACK
2656   gen jmp {label,$1}
2657
2658 pat bra topeltsize($1)!=4
2659   with STACK
2660   gen jmp {label,$1}
2661
2662 proc bxx example blt
2663 with regorconst rm STACK
2664   gen cmp %2,%1
2665       jxx[1] {label,$1}
2666 with rm regorconst STACK
2667   gen cmp %1,%2
2668       jxx[2] {label,$1}
2669
2670 pat blt         call bxx("jl","jg")
2671 pat ble         call bxx("jle","jge")
2672 pat beq         call bxx("je","je")
2673 pat bne         call bxx("jne","jne")
2674 pat bge         call bxx("jge","jle")
2675 pat bgt         call bxx("jg","jl")
2676
2677 proc zxx example zlt
2678 with rm STACK
2679   gen test %1
2680       jxx* {label,$1}
2681
2682 pat zlt         call zxx("js")
2683 pat zge         call zxx("jns")
2684
2685 /* Explicit test for ZLE and ZGT. We must make sure that the OC
2686    flag is cleared.
2687 */
2688 pat zle
2689 with rm STACK
2690   gen 
2691       killcc.
2692       test %1
2693       jle {label,$1}
2694
2695 pat zgt
2696 with rm STACK
2697   gen
2698       killcc.
2699       test %1
2700       jg {label, $1}
2701
2702 pat zne
2703 with rm+rm1 STACK
2704   gen test %1
2705       jne {label,$1}
2706
2707 pat zeq
2708 with rm+rm1 STACK
2709   gen test %1
2710       je {label,$1}
2711
2712 /*******************************************************************
2713  *  Group 14 : Procedure-call Instructions                         *
2714  *******************************************************************/
2715
2716 pat cal
2717   kills ALL
2718   gen proccall {label,$1}
2719
2720 pat cai
2721   with rm
2722   kills ALL
2723   gen proccall %1
2724
2725 #ifdef REGVARS
2726 pat lfr adi stl $1==4 && $2==4 && inreg($3) > 0
2727   kills ALL
2728   gen pop {LOCAL,$3,4}
2729       add {LOCAL,$3,4}, eax
2730 #endif
2731
2732 pat lfr $1==4                   yields eax
2733
2734 pat lfr $1==8                   yields edx eax
2735
2736 pat ret $1==0
2737   kills ALL
2738   gen
2739 #ifdef REGVARS
2740         return
2741 #else
2742       leave.
2743       ret.
2744 #endif
2745
2746 pat ret $1==4
2747   with ACC
2748   kills ALL
2749   gen
2750 #ifdef REGVARS
2751         return
2752 #else
2753       leave.
2754       ret.
2755 #endif
2756
2757 pat ret $1==8
2758   with ACC DXREG
2759   kills ALL
2760   gen
2761 #ifdef REGVARS
2762         return
2763 #else
2764       leave.
2765       ret.
2766 #endif
2767
2768 /********************************************************************
2769  *  Group 15 : Miscellaneous Instructions                           *
2770  ********************************************************************/
2771
2772 pat asp $1==4
2773 with exact a_word
2774 with STACK
2775   uses CXREG /* GENREG may contain lfr area */
2776   gen pop %a
2777
2778 pat asp $1==8
2779 with exact a_word a_word
2780 with STACK
2781   uses CXREG /* GENREG may contain lfr area */
2782   gen pop %a
2783       pop %a
2784
2785 pat asp $1==0-4
2786 with STACK                                      yields ebp
2787
2788 pat asp
2789 with STACK
2790   gen add esp,{ANYCON,$1}
2791
2792 pat ass $1==4
2793 with rmorconst STACK
2794   gen add esp,%1
2795
2796 pat ass !defined($1)
2797 with rm rmorconst STACK
2798   gen cmp %1,{ANYCON,4}
2799       jne {label, ".unknown"}
2800       add esp,%2
2801
2802 pat blm $1==0                                   leaving asp 4
2803
2804 pat blm $1>0
2805 kills ALL
2806   gen mov ecx,{ANYCON,$1/4}
2807       proccall {label, ".blm"}
2808
2809 pat bls $1==4
2810 with CXREG
2811 kills ALL
2812   gen sar ecx,{ANYCON,2}
2813       proccall {label, ".blm"}
2814
2815 pat bls !defined($1)
2816 with rm-CXREG CXREG
2817 kills ALL
2818   gen cmp %1,{ANYCON,4}
2819       jne {label, ".unknown"}
2820       sar ecx,{ANYCON,2}
2821       proccall {label, ".blm"}
2822
2823 pat csa $1==4
2824 with BXREG ACC
2825 kills ALL
2826   gen jmp {label, ".csa4"}
2827
2828 pat csa !defined($1)
2829 with rm-BXREG-ACC BXREG ACC
2830 kills ALL
2831   gen cmp %1,{ANYCON,4}
2832       jne {label, ".unknown"}
2833       jmp {label, ".csa4"}
2834
2835 pat csb $1==4
2836 with BXREG ACC
2837 kills ALL
2838   gen jmp {label, ".csb4"}
2839
2840 pat csb !defined($1)
2841 with rm-BXREG-ACC BXREG ACC
2842   gen cmp %1,{ANYCON,4}
2843       jne {label, ".unknown"}
2844       jmp {label, ".csb4"}
2845
2846 pat dup $1==4
2847 with anyreg                             yields %1 %1
2848 with ACC1                               yields %1 %1
2849
2850 pat dup $1==8
2851 with regorconst regorconst              yields %2 %1 %2 %1
2852
2853 pat dup
2854 kills ALL
2855   gen mov ecx,{ANYCON,$1}
2856       proccall {label, ".dup"}
2857
2858 pat dus $1==4
2859 with CXREG
2860 kills ALL
2861   gen proccall {label, ".dup"}
2862
2863 pat dus !defined($1)
2864 with rm-CXREG CXREG
2865 kills ALL
2866   gen cmp %1,{ANYCON,4}
2867       jne {label, ".unknown"}
2868       proccall {label, ".dup"}
2869
2870 pat exg $1==4
2871 with a_word a_word                      yields %1 %2
2872
2873 pat exg $1==8
2874 with a_word a_word a_word a_word        yields %2 %1 %4 %3
2875
2876 pat exg defined($1)
2877 kills ALL
2878   gen mov ecx,{ANYCON,$1}
2879       proccall {label, ".exg"}
2880
2881 pat exg
2882 with CXREG
2883   kills ALL
2884   gen proccall {label, ".exg"}
2885
2886 pat gto
2887 kills ALL
2888   gen mov ebx,{ADDR_EXTERN,$1}
2889       jmp {label, ".gto"}
2890
2891 pat fil
2892   gen mov {EXTERN,"hol0+4"},{ADDR_EXTERN,$1}
2893
2894 pat lim
2895   uses REG
2896   gen mov %a,{EXTERN,".ignmask"}        yields %a
2897
2898 pat lin
2899   gen mov {EXTERN,"hol0"},{ANYCON,$1}
2900
2901 pat lni
2902   gen inc {EXTERN,"hol0"}
2903
2904 pat lor $1==0                           yields ebp
2905
2906 pat lor $1==1
2907 with STACK
2908   uses REG
2909   gen mov %a,esp                        yields %a
2910
2911 pat lor $1==2
2912   uses REG
2913   gen mov %a,{EXTERN,".reghp"}          yields %a
2914
2915 pat mon
2916 with ACC
2917 kills ALL
2918   gen proccall {label, ".mon"}
2919
2920 pat nop
2921 kills ALL
2922 #ifdef DEBUG
2923   gen proccall {label, ".nop"}
2924 #endif
2925
2926 pat rck $1==4
2927 with BXREG ACC
2928 kills ALL
2929   gen proccall {label, ".rck"}          yields eax
2930
2931 pat rck !defined($1)
2932 with rm-BXREG-ACC BXREG ACC
2933 kills ALL
2934   gen cmp %1,{ANYCON,4}
2935       jne {label, ".unknown"}
2936       proccall {label, ".rck"}          yields eax
2937
2938 pat rtt                                         leaving ret 0
2939
2940 pat sig
2941 with REG
2942   gen xchg {EXTERN,".trppc"},%1         yields %1
2943
2944 pat sim
2945 with regorconst
2946   gen mov {EXTERN,".ignmask"},%1
2947
2948 pat str $1==0
2949 with rmorconst
2950   gen mov ebp,%1
2951
2952 pat str $1==1
2953 with rmorconst STACK
2954   gen mov esp,%1
2955
2956 pat str $1==2
2957 kills ALL
2958   gen proccall {label, ".strhp"}
2959
2960 pat trp
2961 with ACC
2962 kills ALL
2963   gen proccall {label, ".Xtrp"}