Initial revision
[official-gcc.git] / gcc / config / ns32k / ns32k.md
blob28e65e6df9149eebc2609278a031405658ed8263
1 ;;- Machine description for GNU compiler, ns32000 Version
2 ;;  Copyright (C) 1988, 1994, 1996 Free Software Foundation, Inc.
3 ;;  Contributed by Michael Tiemann (tiemann@cygnus.com)
5 ;; This file is part of GNU CC.
7 ;; GNU CC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; any later version.
12 ;; GNU CC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU CC; see the file COPYING.  If not, write to
19 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
23 ; BUGS:
24 ;; Insert no-op between an insn with memory read-write operands
25 ;;   following by a scale-indexing operation.
26 ;; The Sequent assembler does not allow addresses to be used
27 ;;   except in insns which explicitly compute an effective address.
28 ;;   I.e., one cannot say "cmpd _p,@_x"
29 ;; Implement unsigned multiplication??
31 ;;- Instruction patterns.  When multiple patterns apply,
32 ;;- the first one in the file is chosen.
33 ;;-
34 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
35 ;;-
36 ;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code
37 ;;- updates for most instructions.
39 ;; We don't want to allow a constant operand for test insns because
40 ;; (set (cc0) (const_int foo)) has no mode information.  Such insns will
41 ;; be folded while optimizing anyway.
43 (define_insn "tstsi"
44   [(set (cc0)
45         (match_operand:SI 0 "nonimmediate_operand" "rm"))]
46   ""
47   "*
48 { cc_status.flags |= CC_REVERSED;
49   operands[1] = const0_rtx;
50   return \"cmpqd %1,%0\"; }")
52 (define_insn "tsthi"
53   [(set (cc0)
54         (match_operand:HI 0 "nonimmediate_operand" "g"))]
55   ""
56   "*
57 { cc_status.flags |= CC_REVERSED;
58   operands[1] = const0_rtx;
59   return \"cmpqw %1,%0\"; }")
61 (define_insn "tstqi"
62   [(set (cc0)
63         (match_operand:QI 0 "nonimmediate_operand" "g"))]
64   ""
65   "*
66 { cc_status.flags |= CC_REVERSED;
67   operands[1] = const0_rtx;
68   return \"cmpqb %1,%0\"; }")
70 (define_insn "tstdf"
71   [(set (cc0)
72         (match_operand:DF 0 "general_operand" "fmF"))]
73   "TARGET_32081"
74   "*
75 { cc_status.flags |= CC_REVERSED;
76   operands[1] = CONST0_RTX (DFmode);
77   return \"cmpl %1,%0\"; }")
79 (define_insn "tstsf"
80   [(set (cc0)
81         (match_operand:SF 0 "general_operand" "fmF"))]
82   "TARGET_32081"
83   "*
84 { cc_status.flags |= CC_REVERSED;
85   operands[1] = CONST0_RTX (SFmode);
86   return \"cmpf %1,%0\"; }")
88 (define_insn "cmpsi"
89   [(set (cc0)
90         (compare (match_operand:SI 0 "nonimmediate_operand" "rmn")
91                  (match_operand:SI 1 "general_operand" "rmn")))]
92   ""
93   "*
95   if (GET_CODE (operands[1]) == CONST_INT)
96     {
97       int i = INTVAL (operands[1]);
98       if (i <= 7 && i >= -8)
99         {
100           cc_status.flags |= CC_REVERSED;
101           return \"cmpqd %1,%0\";
102         }
103     }
104   cc_status.flags &= ~CC_REVERSED;
105   if (GET_CODE (operands[0]) == CONST_INT)
106     {
107       int i = INTVAL (operands[0]);
108       if (i <= 7 && i >= -8)
109         return \"cmpqd %0,%1\";
110     }
111   return \"cmpd %0,%1\";
114 (define_insn "cmphi"
115   [(set (cc0)
116         (compare (match_operand:HI 0 "nonimmediate_operand" "g")
117                  (match_operand:HI 1 "general_operand" "g")))]
118   ""
119   "*
121   if (GET_CODE (operands[1]) == CONST_INT)
122     {
123       short i = INTVAL (operands[1]);
124     if (i <= 7 && i >= -8)
125       {
126         cc_status.flags |= CC_REVERSED;
127         if (INTVAL (operands[1]) > 7)
128           operands[1] = gen_rtx(CONST_INT, VOIDmode, i);
129         return \"cmpqw %1,%0\";
130       }
131     }
132   cc_status.flags &= ~CC_REVERSED;
133   if (GET_CODE (operands[0]) == CONST_INT)
134     {
135       short i = INTVAL (operands[0]);
136       if (i <= 7 && i >= -8)
137         {
138           if (INTVAL (operands[0]) > 7)
139             operands[0] = gen_rtx(CONST_INT, VOIDmode, i);
140           return \"cmpqw %0,%1\";
141         }
142     }
143   return \"cmpw %0,%1\";
146 (define_insn "cmpqi"
147   [(set (cc0)
148         (compare (match_operand:QI 0 "nonimmediate_operand" "g")
149                  (match_operand:QI 1 "general_operand" "g")))]
150   ""
151   "*
153   if (GET_CODE (operands[1]) == CONST_INT)
154     {
155       char i = INTVAL (operands[1]);
156       if (i <= 7 && i >= -8)
157         {
158           cc_status.flags |= CC_REVERSED;
159           if (INTVAL (operands[1]) > 7)
160             operands[1] = gen_rtx(CONST_INT, VOIDmode, i);
161           return \"cmpqb %1,%0\";
162         }
163     }
164   cc_status.flags &= ~CC_REVERSED;
165   if (GET_CODE (operands[0]) == CONST_INT)
166     {
167       char i = INTVAL (operands[0]);
168       if (i <= 7 && i >= -8)
169         {
170           if (INTVAL (operands[0]) > 7)
171             operands[0] = gen_rtx(CONST_INT, VOIDmode, i);
172           return \"cmpqb %0,%1\";
173         }
174     }
175   return \"cmpb %0,%1\";
178 (define_insn "cmpdf"
179   [(set (cc0)
180         (compare (match_operand:DF 0 "general_operand" "fmF")
181                  (match_operand:DF 1 "general_operand" "fmF")))]
182   "TARGET_32081"
183   "cmpl %0,%1")
185 (define_insn "cmpsf"
186   [(set (cc0)
187         (compare (match_operand:SF 0 "general_operand" "fmF")
188                  (match_operand:SF 1 "general_operand" "fmF")))]
189   "TARGET_32081"
190   "cmpf %0,%1")
192 (define_insn "movdf"
193   [(set (match_operand:DF 0 "general_operand" "=fg<")
194         (match_operand:DF 1 "general_operand" "fFg"))]
195   ""
196   "*
198   if (FP_REG_P (operands[0]))
199     {
200       if (FP_REG_P (operands[1]) || GET_CODE (operands[1]) == CONST_DOUBLE)
201         return \"movl %1,%0\";
202       if (REG_P (operands[1]))
203         {
204           rtx xoperands[2];
205           xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
206           output_asm_insn (\"movd %1,tos\", xoperands);
207           output_asm_insn (\"movd %1,tos\", operands);
208           return \"movl tos,%0\";
209         }
210       return \"movl %1,%0\";
211     }
212   else if (FP_REG_P (operands[1]))
213     {
214       if (REG_P (operands[0]))
215         {
216           output_asm_insn (\"movl %1,tos\;movd tos,%0\", operands);
217           operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
218           return \"movd tos,%0\";
219         }
220       else
221         return \"movl %1,%0\";
222     }
223   return output_move_double (operands);
226 (define_insn "movsf"
227   [(set (match_operand:SF 0 "general_operand" "=fg<")
228         (match_operand:SF 1 "general_operand" "fFg"))]
229   ""
230   "*
232   if (FP_REG_P (operands[0]))
233     {
234       if (GET_CODE (operands[1]) == REG && REGNO (operands[1]) < 8)
235         return \"movd %1,tos\;movf tos,%0\";
236       else
237         return \"movf %1,%0\";
238     }
239   else if (FP_REG_P (operands[1]))
240     {
241       if (REG_P (operands[0]))
242         return \"movf %1,tos\;movd tos,%0\";
243       return \"movf %1,%0\";
244     }
245 #if 0 /* Someone suggested this for the Sequent.  Is it needed?  */
246   else if (GET_CODE (operands[1]) == CONST_DOUBLE)
247     return \"movf %1,%0\";
248 #endif
249 /* There was a #if 0 around this, but that was erroneous
250    for many machines -- rms.  */
251 #ifndef MOVD_FLOAT_OK
252   /* GAS understands floating constants in ordinary movd instructions
253      but other assemblers might object.  */
254   else if (GET_CODE (operands[1]) == CONST_DOUBLE)
255     {
256       union {int i[2]; float f; double d;} convrt;
257       convrt.i[0] = CONST_DOUBLE_LOW (operands[1]);
258       convrt.i[1] = CONST_DOUBLE_HIGH (operands[1]);
259       convrt.f = convrt.d;
261       /* Is there a better machine-independent way to to this?  */
262       operands[1] = gen_rtx (CONST_INT, VOIDmode, convrt.i[0]);
263       return \"movd %1,%0\";
264     }
265 #endif
266   else return \"movd %1,%0\";
269 (define_insn ""
270   [(set (match_operand:TI 0 "memory_operand" "=m")
271         (match_operand:TI 1 "memory_operand" "m"))]
272   ""
273   "movmd %1,%0,4")
275 (define_insn "movdi"
276   [(set (match_operand:DI 0 "general_operand" "=g<,*f,g")
277         (match_operand:DI 1 "general_operand" "gF,g,*f"))]
278   ""
279   "*
281   if (FP_REG_P (operands[0]))
282     {
283       if (FP_REG_P (operands[1]) || GET_CODE (operands[1]) == CONST_DOUBLE)
284         return \"movl %1,%0\";
285       if (REG_P (operands[1]))
286         {
287           rtx xoperands[2];
288           xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
289           output_asm_insn (\"movd %1,tos\", xoperands);
290           output_asm_insn (\"movd %1,tos\", operands);
291           return \"movl tos,%0\";
292         }
293       return \"movl %1,%0\";
294     }
295   else if (FP_REG_P (operands[1]))
296     {
297       if (REG_P (operands[0]))
298         {
299           output_asm_insn (\"movl %1,tos\;movd tos,%0\", operands);
300           operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
301           return \"movd tos,%0\";
302         }
303       else
304         return \"movl %1,%0\";
305     }
306   return output_move_double (operands);
309 ;; This special case must precede movsi.
310 (define_insn ""
311   [(set (reg:SI 17)
312         (match_operand:SI 0 "general_operand" "rmn"))]
313   ""
314   "lprd sp,%0")
316 (define_insn "movsi"
317   [(set (match_operand:SI 0 "general_operand" "=g<,g<,*f,g,x")
318         (match_operand:SI 1 "general_operand" "g,?xy,g,*f,rmn"))]
319   ""
320   "*
322   extern int flag_pic;                                          \
324   if (FP_REG_P (operands[0]))
325     {
326       if (GET_CODE (operands[1]) == REG && REGNO (operands[1]) < 8)
327         return \"movd %1,tos\;movf tos,%0\";
328       else
329         return \"movf %1,%0\";
330     }
331   else if (FP_REG_P (operands[1]))
332     {
333       if (REG_P (operands[0]))
334         return \"movf %1,tos\;movd tos,%0\";
335       return \"movf %1,%0\";
336     }
337   if (GET_CODE (operands[0]) == REG
338       && REGNO (operands[0]) == FRAME_POINTER_REGNUM)
339     return \"lprd fp,%1\";
340   if (GET_CODE (operands[1]) == CONST_DOUBLE)
341     operands[1]
342       = gen_rtx (CONST_INT, VOIDmode, CONST_DOUBLE_LOW (operands[1]));
343   if (GET_CODE (operands[1]) == CONST_INT)
344     {
345       int i = INTVAL (operands[1]);
346       if (! TARGET_32532)
347         {
348           if (i <= 7 && i >= -8)
349             return \"movqd %1,%0\";
350           if (i <= 0x1fffffff && i >= -0x20000000)
351 #if defined (GNX_V3) || defined (UTEK_ASM)
352             return \"addr %c1,%0\";
353 #else
354             return \"addr @%c1,%0\";
355 #endif
356           return \"movd %$%1,%0\";
357         }
358       else
359         return output_move_dconst(i, \"%$%1,%0\");
360     }
361   else if (GET_CODE (operands[1]) == CONST && ! flag_pic)
362     {
363         /* Must contain symbols so we don`t know how big it is. In
364          * that case addr might lead to overflow. For PIC symbolic
365          * address loads always have to be done with addr.
366          */
367         return \"movd %$%1,%0\";
368     }
369   else if (GET_CODE (operands[1]) == REG)
370     {
371       if (REGNO (operands[1]) < 16)
372         return \"movd %1,%0\";
373       else if (REGNO (operands[1]) == FRAME_POINTER_REGNUM)
374         {
375           if (GET_CODE(operands[0]) == REG)
376             return \"sprd fp,%0\";
377           else
378             return \"addr 0(fp),%0\" ;
379         }
380       else if (REGNO (operands[1]) == STACK_POINTER_REGNUM)
381         {
382           if (GET_CODE(operands[0]) == REG)
383             return \"sprd sp,%0\";
384           else
385             return \"addr 0(sp),%0\" ;
386         }
387       else abort ();
388     }
389   else if (GET_CODE (operands[1]) == MEM)
390     return \"movd %1,%0\";
392   /* Check if this effective address can be
393      calculated faster by pulling it apart.  */
394   if (REG_P (operands[0])
395       && GET_CODE (operands[1]) == MULT
396       && GET_CODE (XEXP (operands[1], 1)) == CONST_INT
397       && (INTVAL (XEXP (operands[1], 1)) == 2
398           || INTVAL (XEXP (operands[1], 1)) == 4))
399     {
400       rtx xoperands[3];
401       xoperands[0] = operands[0];
402       xoperands[1] = XEXP (operands[1], 0);
403       xoperands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (XEXP (operands[1], 1)) >> 1);
404       return output_shift_insn (xoperands);
405     }
406   return \"addr %a1,%0\";
409 (define_insn "movhi"
410   [(set (match_operand:HI 0 "general_operand" "=g<,*f,g")
411         (match_operand:HI 1 "general_operand" "g,g,*f"))]
412   ""
413   "*
415   if (GET_CODE (operands[1]) == CONST_INT)
416     {
417       short i = INTVAL (operands[1]);
418       if (i <= 7 && i >= -8)
419         {
420           if (INTVAL (operands[1]) > 7)
421             operands[1] =
422               gen_rtx (CONST_INT, VOIDmode, i);
423           return \"movqw %1,%0\";
424         }
425         return \"movw %1,%0\";
426     }
427   else if (FP_REG_P (operands[0]))
428     {
429       if (GET_CODE (operands[1]) == REG && REGNO (operands[1]) < 8)
430         return \"movwf %1,tos\;movf tos,%0\";
431       else
432         return \"movwf %1,%0\";
433     }
434   else if (FP_REG_P (operands[1]))
435     {
436       if (REG_P (operands[0]))
437         return \"movf %1,tos\;movd tos,%0\";
438       return \"movf %1,%0\";
439     }
440   else
441      return \"movw %1,%0\";
444 (define_insn "movstricthi"
445   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+r"))
446         (match_operand:HI 1 "general_operand" "g"))]
447   ""
448   "*
450   if (GET_CODE (operands[1]) == CONST_INT
451       && INTVAL(operands[1]) <= 7 && INTVAL(operands[1]) >= -8)
452     return \"movqw %1,%0\";
453   return \"movw %1,%0\";
456 (define_insn "movqi"
457   [(set (match_operand:QI 0 "general_operand" "=g<,*f,g")
458         (match_operand:QI 1 "general_operand" "g,g,*f"))]
459   ""
460   "*
461 { if (GET_CODE (operands[1]) == CONST_INT)
462     {
463       char char_val = (char)INTVAL (operands[1]);
464       if (char_val <= 7 && char_val >= -8)
465         {
466           if (INTVAL (operands[1]) > 7)
467             operands[1] =
468               gen_rtx (CONST_INT, VOIDmode, char_val);
469           return \"movqb %1,%0\";
470         }
471         return \"movb %1,%0\";
472     }
473   else if (FP_REG_P (operands[0]))
474     {
475       if (GET_CODE (operands[1]) == REG && REGNO (operands[1]) < 8)
476         return \"movbf %1,tos\;movf tos,%0\";
477       else
478         return \"movbf %1,%0\";
479     }
480   else if (FP_REG_P (operands[1]))
481     {
482       if (REG_P (operands[0]))
483         return \"movf %1,tos\;movd tos,%0\";
484       return \"movf %1,%0\";
485     }
486   else
487      return \"movb %1,%0\";
490 (define_insn "movstrictqi"
491   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+r"))
492         (match_operand:QI 1 "general_operand" "g"))]
493   ""
494   "*
496   if (GET_CODE (operands[1]) == CONST_INT
497       && INTVAL(operands[1]) < 8 && INTVAL(operands[1]) > -9)
498     return \"movqb %1,%0\";
499   return \"movb %1,%0\";
502 ;; This is here to accept 4 arguments and pass the first 3 along
503 ;; to the movstrsi1 pattern that really does the work.
504 (define_expand "movstrsi"
505   [(set (match_operand:BLK 0 "general_operand" "=g")
506         (match_operand:BLK 1 "general_operand" "g"))
507    (use (match_operand:SI 2 "general_operand" "rmn"))
508    (match_operand 3 "" "")]
509   ""
510   "
511   emit_insn (gen_movstrsi1 (operands[0], operands[1], operands[2]));
512   DONE;
515 ;; The definition of this insn does not really explain what it does,
516 ;; but it should suffice
517 ;; that anything generated as this insn will be recognized as one
518 ;; and that it won't successfully combine with anything.
519 (define_insn "movstrsi1"
520   [(set (match_operand:BLK 0 "general_operand" "=g")
521         (match_operand:BLK 1 "general_operand" "g"))
522    (use (match_operand:SI 2 "general_operand" "rmn"))
523    (clobber (reg:SI 0))
524    (clobber (reg:SI 1))
525    (clobber (reg:SI 2))]
526   ""
527   "*
529   if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
530     abort ();
531   operands[0] = XEXP (operands[0], 0);
532   operands[1] = XEXP (operands[1], 0);
533   if (GET_CODE (operands[0]) == MEM)
534     if (GET_CODE (operands[1]) == MEM)
535       output_asm_insn (\"movd %0,r2\;movd %1,r1\", operands);
536     else
537       output_asm_insn (\"movd %0,r2\;addr %a1,r1\", operands);
538   else if (GET_CODE (operands[1]) == MEM)
539     output_asm_insn (\"addr %a0,r2\;movd %1,r1\", operands);
540   else
541     output_asm_insn (\"addr %a0,r2\;addr %a1,r1\", operands);
543 #ifdef UTEK_ASM
544   if (GET_CODE (operands[2]) == CONST_INT && (INTVAL (operands[2]) & 0x3) == 0)
545     {
546       operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) >> 2);
547       if ((unsigned) INTVAL (operands[2]) <= 7)
548         return \"movqd %2,r0\;movsd $0\";
549       else 
550         return \"movd %2,r0\;movsd $0\";
551     }
552   else
553     {
554       return \"movd %2,r0\;movsb $0\";
555     }
556 #else
557   if (GET_CODE (operands[2]) == CONST_INT && (INTVAL (operands[2]) & 0x3) == 0)
558     {
559       operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) >> 2);
560       if ((unsigned) INTVAL (operands[2]) <= 7)
561         return \"movqd %2,r0\;movsd\";
562       else 
563         return \"movd %2,r0\;movsd\";
564     }
565   else
566     {
567       return \"movd %2,r0\;movsb\";
568     }
569 #endif
572 ;; Extension and truncation insns.
573 ;; Those for integer source operand
574 ;; are ordered widest source type first.
576 (define_insn "truncsiqi2"
577   [(set (match_operand:QI 0 "general_operand" "=g<")
578         (truncate:QI (match_operand:SI 1 "nonimmediate_operand" "rmn")))]
579   ""
580   "movb %1,%0")
582 (define_insn "truncsihi2"
583   [(set (match_operand:HI 0 "general_operand" "=g<")
584         (truncate:HI (match_operand:SI 1 "nonimmediate_operand" "rmn")))]
585   ""
586   "movw %1,%0")
588 (define_insn "trunchiqi2"
589   [(set (match_operand:QI 0 "general_operand" "=g<")
590         (truncate:QI (match_operand:HI 1 "nonimmediate_operand" "g")))]
591   ""
592   "movb %1,%0")
594 (define_insn "extendhisi2"
595   [(set (match_operand:SI 0 "general_operand" "=g<")
596         (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "g")))]
597   ""
598   "movxwd %1,%0")
600 (define_insn "extendqihi2"
601   [(set (match_operand:HI 0 "general_operand" "=g<")
602         (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "g")))]
603   ""
604   "movxbw %1,%0")
606 (define_insn "extendqisi2"
607   [(set (match_operand:SI 0 "general_operand" "=g<")
608         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "g")))]
609   ""
610   "movxbd %1,%0")
612 (define_insn "extendsfdf2"
613   [(set (match_operand:DF 0 "general_operand" "=fm<")
614         (float_extend:DF (match_operand:SF 1 "general_operand" "fmF")))]
615   "TARGET_32081"
616   "movfl %1,%0")
618 (define_insn "truncdfsf2"
619   [(set (match_operand:SF 0 "general_operand" "=fm<")
620         (float_truncate:SF (match_operand:DF 1 "general_operand" "fmF")))]
621   "TARGET_32081"
622   "movlf %1,%0")
624 (define_insn "zero_extendhisi2"
625   [(set (match_operand:SI 0 "general_operand" "=g<")
626         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "g")))]
627   ""
628   "movzwd %1,%0")
630 (define_insn "zero_extendqihi2"
631   [(set (match_operand:HI 0 "general_operand" "=g<")
632         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "g")))]
633   ""
634   "movzbw %1,%0")
636 (define_insn "zero_extendqisi2"
637   [(set (match_operand:SI 0 "general_operand" "=g<")
638         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "g")))]
639   ""
640   "movzbd %1,%0")
642 ;; Fix-to-float conversion insns.
643 ;; Note that the ones that start with SImode come first.
644 ;; That is so that an operand that is a CONST_INT
645 ;; (and therefore lacks a specific machine mode).
646 ;; will be recognized as SImode (which is always valid)
647 ;; rather than as QImode or HImode.
649 ;; Rumor has it that the National part does not correctly convert
650 ;; constant ints to floats.  This conversion is therefore disabled.
651 ;; A register must be used to perform the conversion.
653 (define_insn "floatsisf2"
654   [(set (match_operand:SF 0 "general_operand" "=fm<")
655         (float:SF (match_operand:SI 1 "general_operand" "rm")))]
656   "TARGET_32081"
657   "movdf %1,%0")
659 (define_insn "floatsidf2"
660   [(set (match_operand:DF 0 "general_operand" "=fm<")
661         (float:DF (match_operand:SI 1 "general_operand" "rm")))]
662   "TARGET_32081"
663   "movdl %1,%0")
665 (define_insn "floathisf2"
666   [(set (match_operand:SF 0 "general_operand" "=fm<")
667         (float:SF (match_operand:HI 1 "general_operand" "rm")))]
668   "TARGET_32081"
669   "movwf %1,%0")
671 (define_insn "floathidf2"
672   [(set (match_operand:DF 0 "general_operand" "=fm<")
673         (float:DF (match_operand:HI 1 "general_operand" "rm")))]
674   "TARGET_32081"
675   "movwl %1,%0")
677 (define_insn "floatqisf2"
678   [(set (match_operand:SF 0 "general_operand" "=fm<")
679         (float:SF (match_operand:QI 1 "general_operand" "rm")))]
680   "TARGET_32081"
681   "movbf %1,%0")
683 ; Some assemblers warn that this insn doesn't work.
684 ; Maybe they know something we don't.
685 ;(define_insn "floatqidf2"
686 ;  [(set (match_operand:DF 0 "general_operand" "=fm<")
687 ;       (float:DF (match_operand:QI 1 "general_operand" "rm")))]
688 ;  "TARGET_32081"
689 ;  "movbl %1,%0")
691 ;; Float-to-fix conversion insns.
692 ;; The sequent compiler always generates "trunc" insns.
694 (define_insn "fixsfqi2"
695   [(set (match_operand:QI 0 "general_operand" "=g<")
696         (fix:QI (fix:SF (match_operand:SF 1 "general_operand" "fm"))))]
697   "TARGET_32081"
698   "truncfb %1,%0")
700 (define_insn "fixsfhi2"
701   [(set (match_operand:HI 0 "general_operand" "=g<")
702         (fix:HI (fix:SF (match_operand:SF 1 "general_operand" "fm"))))]
703   "TARGET_32081"
704   "truncfw %1,%0")
706 (define_insn "fixsfsi2"
707   [(set (match_operand:SI 0 "general_operand" "=g<")
708         (fix:SI (fix:SF (match_operand:SF 1 "general_operand" "fm"))))]
709   "TARGET_32081"
710   "truncfd %1,%0")
712 (define_insn "fixdfqi2"
713   [(set (match_operand:QI 0 "general_operand" "=g<")
714         (fix:QI (fix:DF (match_operand:DF 1 "general_operand" "fm"))))]
715   "TARGET_32081"
716   "trunclb %1,%0")
718 (define_insn "fixdfhi2"
719   [(set (match_operand:HI 0 "general_operand" "=g<")
720         (fix:HI (fix:DF (match_operand:DF 1 "general_operand" "fm"))))]
721   "TARGET_32081"
722   "trunclw %1,%0")
724 (define_insn "fixdfsi2"
725   [(set (match_operand:SI 0 "general_operand" "=g<")
726         (fix:SI (fix:DF (match_operand:DF 1 "general_operand" "fm"))))]
727   "TARGET_32081"
728   "truncld %1,%0")
730 ;; Unsigned
732 (define_insn "fixunssfqi2"
733   [(set (match_operand:QI 0 "general_operand" "=g<")
734         (unsigned_fix:QI (fix:SF (match_operand:SF 1 "general_operand" "fm"))))]
735   "TARGET_32081"
736   "truncfb %1,%0")
738 (define_insn "fixunssfhi2"
739   [(set (match_operand:HI 0 "general_operand" "=g<")
740         (unsigned_fix:HI (fix:SF (match_operand:SF 1 "general_operand" "fm"))))]
741   "TARGET_32081"
742   "truncfw %1,%0")
744 (define_insn "fixunssfsi2"
745   [(set (match_operand:SI 0 "general_operand" "=g<")
746         (unsigned_fix:SI (fix:SF (match_operand:SF 1 "general_operand" "fm"))))]
747   "TARGET_32081"
748   "truncfd %1,%0")
750 (define_insn "fixunsdfqi2"
751   [(set (match_operand:QI 0 "general_operand" "=g<")
752         (unsigned_fix:QI (fix:DF (match_operand:DF 1 "general_operand" "fm"))))]
753   "TARGET_32081"
754   "trunclb %1,%0")
756 (define_insn "fixunsdfhi2"
757   [(set (match_operand:HI 0 "general_operand" "=g<")
758         (unsigned_fix:HI (fix:DF (match_operand:DF 1 "general_operand" "fm"))))]
759   "TARGET_32081"
760   "trunclw %1,%0")
762 (define_insn "fixunsdfsi2"
763   [(set (match_operand:SI 0 "general_operand" "=g<")
764         (unsigned_fix:SI (fix:DF (match_operand:DF 1 "general_operand" "fm"))))]
765   "TARGET_32081"
766   "truncld %1,%0")
768 ;;; These are not yet used by GCC
769 (define_insn "fix_truncsfqi2"
770   [(set (match_operand:QI 0 "general_operand" "=g<")
771         (fix:QI (match_operand:SF 1 "general_operand" "fm")))]
772   "TARGET_32081"
773   "truncfb %1,%0")
775 (define_insn "fix_truncsfhi2"
776   [(set (match_operand:HI 0 "general_operand" "=g<")
777         (fix:HI (match_operand:SF 1 "general_operand" "fm")))]
778   "TARGET_32081"
779   "truncfw %1,%0")
781 (define_insn "fix_truncsfsi2"
782   [(set (match_operand:SI 0 "general_operand" "=g<")
783         (fix:SI (match_operand:SF 1 "general_operand" "fm")))]
784   "TARGET_32081"
785   "truncfd %1,%0")
787 (define_insn "fix_truncdfqi2"
788   [(set (match_operand:QI 0 "general_operand" "=g<")
789         (fix:QI (match_operand:DF 1 "general_operand" "fm")))]
790   "TARGET_32081"
791   "trunclb %1,%0")
793 (define_insn "fix_truncdfhi2"
794   [(set (match_operand:HI 0 "general_operand" "=g<")
795         (fix:HI (match_operand:DF 1 "general_operand" "fm")))]
796   "TARGET_32081"
797   "trunclw %1,%0")
799 (define_insn "fix_truncdfsi2"
800   [(set (match_operand:SI 0 "general_operand" "=g<")
801         (fix:SI (match_operand:DF 1 "general_operand" "fm")))]
802   "TARGET_32081"
803   "truncld %1,%0")
805 ;;- All kinds of add instructions.
807 (define_insn "adddf3"
808   [(set (match_operand:DF 0 "general_operand" "=fm")
809         (plus:DF (match_operand:DF 1 "general_operand" "%0")
810                  (match_operand:DF 2 "general_operand" "fmF")))]
811   "TARGET_32081"
812   "addl %2,%0")
815 (define_insn "addsf3"
816   [(set (match_operand:SF 0 "general_operand" "=fm")
817         (plus:SF (match_operand:SF 1 "general_operand" "%0")
818                  (match_operand:SF 2 "general_operand" "fmF")))]
819   "TARGET_32081"
820   "addf %2,%0")
822 (define_insn ""
823   [(set (reg:SI 17)
824         (plus:SI (reg:SI 17)
825                  (match_operand:SI 0 "immediate_operand" "i")))]
826   "GET_CODE (operands[0]) == CONST_INT"
827   "*
829 #ifndef SEQUENT_ADJUST_STACK
830   if (TARGET_32532)
831     if (INTVAL (operands[0]) == 8)
832       return \"cmpd tos,tos\";
833   if (TARGET_32532 || TARGET_32332)
834     if (INTVAL (operands[0]) == 4)
835       return \"cmpqd %$0,tos\";
836 #endif
837   if (! TARGET_32532)
838     {
839       if (INTVAL (operands[0]) < 64 && INTVAL (operands[0]) > -64)
840         return \"adjspb %$%n0\";
841       else if (INTVAL (operands[0]) < 8192 && INTVAL (operands[0]) >= -8192)
842         return \"adjspw %$%n0\";
843     }
844   return \"adjspd %$%n0\";
847 (define_insn ""
848   [(set (match_operand:SI 0 "general_operand" "=g<")
849         (plus:SI (reg:SI 16)
850                  (match_operand:SI 1 "immediate_operand" "i")))]
851   "GET_CODE (operands[1]) == CONST_INT"
852   "addr %c1(fp),%0")
854 (define_insn ""
855   [(set (match_operand:SI 0 "general_operand" "=g<")
856         (plus:SI (reg:SI 17)
857                  (match_operand:SI 1 "immediate_operand" "i")))]
858   "GET_CODE (operands[1]) == CONST_INT"
859   "addr %c1(sp),%0")
861 (define_insn "adddi3"
862   [(set (match_operand:DI 0 "general_operand" "=ro")
863         (plus:DI (match_operand:DI 1 "general_operand" "%0")
864                  (match_operand:DI 2 "general_operand" "ron")))]
865   ""
866   "*
868   rtx low[3], high[3], xops[4];
869   split_di (operands, 3, low, high);
870   xops[0] = low[0];
871   xops[1] = high[0];
872   xops[2] = low[2];
873   xops[3] = high[2];
875   if (GET_CODE (xops[2]) == CONST_INT)
876     {
877       int i = INTVAL (xops[2]);
879       if (i <= 7 && i >= -8) 
880         {
881           if (i == 0)
882             {
883               i = INTVAL (xops[3]);
884               if (i <= 7 && i >= -8)
885                 output_asm_insn (\"addqd %$%3,%1\", xops);
886               else
887                 output_asm_insn (\"addd %$%3,%1\", xops);
888             }
889           else
890             {
891               output_asm_insn (\"addqd %$%2,%0\", xops);
892               output_asm_insn (\"addcd %$%3,%1\", xops);
893             }
894           return \"\";
895         }
896     }
897   output_asm_insn (\"addd %2,%0\", xops);
898   output_asm_insn (\"addcd %3,%1\", xops);
899   return \"\";
902 (define_insn "addsi3"
903   [(set (match_operand:SI 0 "general_operand" "=g,=g&<")
904         (plus:SI (match_operand:SI 1 "general_operand" "%0,r")
905                  (match_operand:SI 2 "general_operand" "rmn,n")))]
906   ""
907   "*
909   if (which_alternative == 1)
910     {
911       int i = INTVAL (operands[2]);
912       if (NS32K_DISPLACEMENT_P (i))
913         return \"addr %c2(%1),%0\";
914       else
915         return \"movd %1,%0\;addd %2,%0\";
916     }
917   if (GET_CODE (operands[2]) == CONST_INT)
918     {
919       int i = INTVAL (operands[2]);
921       if (i <= 7 && i >= -8)
922         return \"addqd %2,%0\";
923       else if (! TARGET_32532 && GET_CODE (operands[0]) == REG
924                && i <= 0x1fffffff && i >= -0x20000000)
925         return \"addr %c2(%0),%0\";
926     }
927   return \"addd %2,%0\";
930 (define_insn "addhi3"
931   [(set (match_operand:HI 0 "general_operand" "=g")
932         (plus:HI (match_operand:HI 1 "general_operand" "%0")
933                  (match_operand:HI 2 "general_operand" "g")))]
934   ""
935   "*
936 { if (GET_CODE (operands[2]) == CONST_INT)
937     {
938       int i = INTVAL (operands[2]);
939       if (i <= 7 && i >= -8)
940         return \"addqw %2,%0\";
941     }
942   return \"addw %2,%0\";
945 (define_insn ""
946   [(set (strict_low_part (match_operand:HI 0 "general_operand" "=r"))
947         (plus:HI (match_operand:HI 1 "general_operand" "0")
948                  (match_operand:HI 2 "general_operand" "g")))]
949   ""
950   "*
952   if (GET_CODE (operands[1]) == CONST_INT
953       && INTVAL (operands[1]) >-9 && INTVAL(operands[1]) < 8)
954     return \"addqw %2,%0\";
955   return \"addw %2,%0\";
958 (define_insn "addqi3"
959   [(set (match_operand:QI 0 "general_operand" "=g")
960         (plus:QI (match_operand:QI 1 "general_operand" "%0")
961                  (match_operand:QI 2 "general_operand" "g")))]
962   ""
963   "*
964 { if (GET_CODE (operands[2]) == CONST_INT)
965     {
966       int i = INTVAL (operands[2]);
967       if (i <= 7 && i >= -8)
968         return \"addqb %2,%0\";
969     }
970   return \"addb %2,%0\";
973 (define_insn ""
974   [(set (strict_low_part (match_operand:QI 0 "general_operand" "=r"))
975         (plus:QI (match_operand:QI 1 "general_operand" "0")
976                  (match_operand:QI 2 "general_operand" "g")))]
977   ""
978   "*
980   if (GET_CODE (operands[1]) == CONST_INT
981       && INTVAL (operands[1]) >-9 && INTVAL(operands[1]) < 8)
982     return \"addqb %2,%0\";
983   return \"addb %2,%0\";
986 ;;- All kinds of subtract instructions.
988 (define_insn "subdf3"
989   [(set (match_operand:DF 0 "general_operand" "=fm")
990         (minus:DF (match_operand:DF 1 "general_operand" "0")
991                   (match_operand:DF 2 "general_operand" "fmF")))]
992   "TARGET_32081"
993   "subl %2,%0")
995 (define_insn "subsf3"
996   [(set (match_operand:SF 0 "general_operand" "=fm")
997         (minus:SF (match_operand:SF 1 "general_operand" "0")
998                   (match_operand:SF 2 "general_operand" "fmF")))]
999   "TARGET_32081"
1000   "subf %2,%0")
1002 (define_insn ""
1003   [(set (reg:SI 17)
1004         (minus:SI (reg:SI 17)
1005                   (match_operand:SI 0 "immediate_operand" "i")))]
1006   "GET_CODE (operands[0]) == CONST_INT"
1007   "*
1009   if (! TARGET_32532 && GET_CODE(operands[0]) == CONST_INT 
1010       && INTVAL(operands[0]) < 64 && INTVAL(operands[0]) > -64)
1011     return \"adjspb %$%0\";
1012   return \"adjspd %$%0\";
1015 (define_insn "subdi3"
1016   [(set (match_operand:DI 0 "general_operand" "=ro")
1017         (minus:DI (match_operand:DI 1 "general_operand" "0")
1018                   (match_operand:DI 2 "general_operand" "ron")))]
1019   ""
1020   "*
1022   rtx low[3], high[3], xops[4];
1023   split_di (operands, 3, low, high);
1024   xops[0] = low[0];
1025   xops[1] = high[0];
1026   xops[2] = low[2];
1027   xops[3] = high[2];
1029   if (GET_CODE (xops[2]) == CONST_INT)
1030     {
1031       int i = INTVAL (xops[2]);
1033       if (i <= 8 && i >= -7)
1034         {
1035           if (i == 0)
1036             {
1037               i = INTVAL (xops[3]);
1038               if (i <= 8 && i >= -7)
1039                 output_asm_insn (\"addqd %$%n3,%1\", xops);
1040               else
1041                 output_asm_insn (\"subd %$%3,%1\", xops);
1042             }
1043           else
1044             {
1045               output_asm_insn (\"addqd %$%n2,%0\", xops);
1046               output_asm_insn (\"subcd %$%3,%1\", xops);
1047             }
1048           return \"\";
1049         }
1050     }
1051   output_asm_insn (\"subd %2,%0\", xops);
1052   output_asm_insn (\"subcd %3,%1\", xops);
1053   return \"\";
1056 (define_insn "subsi3"
1057   [(set (match_operand:SI 0 "general_operand" "=g")
1058         (minus:SI (match_operand:SI 1 "general_operand" "0")
1059                   (match_operand:SI 2 "general_operand" "rmn")))]
1060   ""
1061   "*
1062 { if (GET_CODE (operands[2]) == CONST_INT)
1063     {
1064       int i = INTVAL (operands[2]);
1066       if (i <= 8 && i >= -7)
1067         return \"addqd %$%n2,%0\";
1068     }
1069   return \"subd %2,%0\";
1072 (define_insn "subhi3"
1073   [(set (match_operand:HI 0 "general_operand" "=g")
1074         (minus:HI (match_operand:HI 1 "general_operand" "0")
1075                   (match_operand:HI 2 "general_operand" "g")))]
1076   ""
1077   "*
1078 { if (GET_CODE (operands[2]) == CONST_INT)
1079     {
1080       int i = INTVAL (operands[2]);
1082       if (i <= 8 && i >= -7)
1083         return \"addqw %$%n2,%0\";
1084     }
1085   return \"subw %2,%0\";
1088 (define_insn ""
1089   [(set (strict_low_part (match_operand:HI 0 "general_operand" "=r"))
1090         (minus:HI (match_operand:HI 1 "general_operand" "0")
1091                   (match_operand:HI 2 "general_operand" "g")))]
1092   ""
1093   "*
1095   if (GET_CODE (operands[1]) == CONST_INT
1096       && INTVAL (operands[1]) >-8 && INTVAL(operands[1]) < 9)
1097     return \"addqw %$%n2,%0\";
1098   return \"subw %2,%0\";
1101 (define_insn "subqi3"
1102   [(set (match_operand:QI 0 "general_operand" "=g")
1103         (minus:QI (match_operand:QI 1 "general_operand" "0")
1104                   (match_operand:QI 2 "general_operand" "g")))]
1105   ""
1106   "*
1107 { if (GET_CODE (operands[2]) == CONST_INT)
1108     {
1109       int i = INTVAL (operands[2]);
1111       if (i <= 8 && i >= -7)
1112         return \"addqb %$%n2,%0\";
1113     }
1114   return \"subb %2,%0\";
1117 (define_insn ""
1118   [(set (strict_low_part (match_operand:QI 0 "general_operand" "=r"))
1119         (minus:QI (match_operand:QI 1 "general_operand" "0")
1120                   (match_operand:QI 2 "general_operand" "g")))]
1121   ""
1122   "*
1124   if (GET_CODE (operands[1]) == CONST_INT
1125       && INTVAL (operands[1]) >-8 && INTVAL(operands[1]) < 9)
1126     return \"addqb %$%n2,%0\";
1127   return \"subb %2,%0\";
1130 ;;- Multiply instructions.
1132 (define_insn "muldf3"
1133   [(set (match_operand:DF 0 "general_operand" "=fm")
1134         (mult:DF (match_operand:DF 1 "general_operand" "%0")
1135                  (match_operand:DF 2 "general_operand" "fmF")))]
1136   "TARGET_32081"
1137   "mull %2,%0")
1139 (define_insn "mulsf3"
1140   [(set (match_operand:SF 0 "general_operand" "=fm")
1141         (mult:SF (match_operand:SF 1 "general_operand" "%0")
1142                  (match_operand:SF 2 "general_operand" "fmF")))]
1143   "TARGET_32081"
1144   "mulf %2,%0")
1146 (define_insn "mulsi3"
1147   [(set (match_operand:SI 0 "general_operand" "=g")
1148         (mult:SI (match_operand:SI 1 "general_operand" "%0")
1149                  (match_operand:SI 2 "general_operand" "rmn")))]
1150   ""
1151   "muld %2,%0")
1153 (define_insn "mulhi3"
1154   [(set (match_operand:HI 0 "general_operand" "=g")
1155         (mult:HI (match_operand:HI 1 "general_operand" "%0")
1156                  (match_operand:HI 2 "general_operand" "g")))]
1157   ""
1158   "mulw %2,%0")
1160 (define_insn "mulqi3"
1161   [(set (match_operand:QI 0 "general_operand" "=g")
1162         (mult:QI (match_operand:QI 1 "general_operand" "%0")
1163                  (match_operand:QI 2 "general_operand" "g")))]
1164   ""
1165   "mulb %2,%0")
1167 (define_insn "umulsidi3"
1168   [(set (match_operand:DI 0 "general_operand" "=g")
1169         (mult:DI (zero_extend:DI
1170                   (match_operand:SI 1 "nonimmediate_operand" "0"))
1171                  (zero_extend:DI
1172                   (match_operand:SI 2 "nonimmediate_operand" "rmn"))))]
1173   ""
1174   "meid %2,%0")
1176 ;;- Divide instructions.
1178 (define_insn "divdf3"
1179   [(set (match_operand:DF 0 "general_operand" "=fm")
1180         (div:DF (match_operand:DF 1 "general_operand" "0")
1181                 (match_operand:DF 2 "general_operand" "fmF")))]
1182   "TARGET_32081"
1183   "divl %2,%0")
1185 (define_insn "divsf3"
1186   [(set (match_operand:SF 0 "general_operand" "=fm")
1187         (div:SF (match_operand:SF 1 "general_operand" "0")
1188                 (match_operand:SF 2 "general_operand" "fmF")))]
1189   "TARGET_32081"
1190   "divf %2,%0")
1192 (define_insn "divsi3"
1193   [(set (match_operand:SI 0 "general_operand" "=g")
1194         (div:SI (match_operand:SI 1 "general_operand" "0")
1195                 (match_operand:SI 2 "general_operand" "rmn")))]
1196   ""
1197   "quod %2,%0")
1199 (define_insn "divhi3"
1200   [(set (match_operand:HI 0 "general_operand" "=g")
1201         (div:HI (match_operand:HI 1 "general_operand" "0")
1202                 (match_operand:HI 2 "general_operand" "g")))]
1203   ""
1204   "quow %2,%0")
1206 (define_insn "divqi3"
1207   [(set (match_operand:QI 0 "general_operand" "=g")
1208         (div:QI (match_operand:QI 1 "general_operand" "0")
1209                 (match_operand:QI 2 "general_operand" "g")))]
1210   ""
1211   "quob %2,%0")
1213 (define_insn "udivsi3"
1214   [(set (match_operand:SI 0 "register_operand" "=r")
1215         (udiv:SI (subreg:SI (match_operand:DI 1 "reg_or_mem_operand" "0") 0)
1216                  (match_operand:SI 2 "general_operand" "rmn")))]
1217   ""
1218   "*
1220   operands[1] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
1221   return \"deid %2,%0\;movd %1,%0\";
1224 (define_insn "udivhi3"
1225   [(set (match_operand:HI 0 "register_operand" "=r")
1226         (udiv:HI (subreg:HI (match_operand:DI 1 "reg_or_mem_operand" "0") 0)
1227                  (match_operand:HI 2 "general_operand" "g")))]
1228   ""
1229   "*
1231   operands[1] = gen_rtx (REG, HImode, REGNO (operands[0]) + 1);
1232   return \"deiw %2,%0\;movw %1,%0\";
1235 (define_insn "udivqi3"
1236   [(set (match_operand:QI 0 "register_operand" "=r")
1237         (udiv:QI (subreg:QI (match_operand:DI 1 "reg_or_mem_operand" "0") 0)
1238                  (match_operand:QI 2 "general_operand" "g")))]
1239   ""
1240   "*
1242   operands[1] = gen_rtx (REG, QImode, REGNO (operands[0]) + 1);
1243   return \"deib %2,%0\;movb %1,%0\";
1246 ;; Remainder instructions.
1248 (define_insn "modsi3"
1249   [(set (match_operand:SI 0 "general_operand" "=g")
1250         (mod:SI (match_operand:SI 1 "general_operand" "0")
1251                 (match_operand:SI 2 "general_operand" "rmn")))]
1252   ""
1253   "remd %2,%0")
1255 (define_insn "modhi3"
1256   [(set (match_operand:HI 0 "general_operand" "=g")
1257         (mod:HI (match_operand:HI 1 "general_operand" "0")
1258                 (match_operand:HI 2 "general_operand" "g")))]
1259   ""
1260   "remw %2,%0")
1262 (define_insn "modqi3"
1263   [(set (match_operand:QI 0 "general_operand" "=g")
1264         (mod:QI (match_operand:QI 1 "general_operand" "0")
1265                 (match_operand:QI 2 "general_operand" "g")))]
1266   ""
1267   "remb %2,%0")
1269 (define_insn "umodsi3"
1270   [(set (match_operand:SI 0 "register_operand" "=r")
1271         (umod:SI (subreg:SI (match_operand:DI 1 "reg_or_mem_operand" "0") 0)
1272                  (match_operand:SI 2 "general_operand" "rmn")))]
1273   ""
1274   "deid %2,%0")
1276 (define_insn "umodhi3"
1277   [(set (match_operand:HI 0 "register_operand" "=r")
1278         (umod:HI (subreg:HI (match_operand:DI 1 "reg_or_mem_operand" "0") 0)
1279                  (match_operand:HI 2 "general_operand" "g")))]
1280   ""
1281   "deiw %2,%0")
1283 (define_insn "umodqi3"
1284   [(set (match_operand:QI 0 "register_operand" "=r")
1285         (umod:QI (subreg:QI (match_operand:DI 1 "reg_or_mem_operand" "0") 0)
1286                  (match_operand:QI 2 "general_operand" "g")))]
1287   ""
1288   "deib %2,%0")
1290 ; This isn't be usable in its current form.
1291 ;(define_insn "udivmoddisi4"
1292 ;  [(set (subreg:SI (match_operand:DI 0 "general_operand" "=r") 1)
1293 ;       (udiv:SI (match_operand:DI 1 "general_operand" "0")
1294 ;                (match_operand:SI 2 "general_operand" "rmn")))
1295 ;   (set (subreg:SI (match_dup 0) 0)
1296 ;       (umod:SI (match_dup 1) (match_dup 2)))]
1297 ;  ""
1298 ;  "deid %2,%0")
1300 ;;- Logical Instructions: AND
1302 (define_insn "andsi3"
1303   [(set (match_operand:SI 0 "general_operand" "=g")
1304         (and:SI (match_operand:SI 1 "general_operand" "%0")
1305                 (match_operand:SI 2 "general_operand" "rmn")))]
1306   ""
1307   "*
1309   if (GET_CODE (operands[2]) == CONST_INT)
1310     {
1311       if ((INTVAL (operands[2]) | 0xff) == 0xffffffff)
1312         {
1313           if (INTVAL (operands[2]) == 0xffffff00)
1314             return \"movqb %$0,%0\";
1315           else
1316             {
1317               operands[2] = gen_rtx (CONST_INT, VOIDmode,
1318                                      INTVAL (operands[2]) & 0xff);
1319               return \"andb %2,%0\";
1320             }
1321         }
1322       if ((INTVAL (operands[2]) | 0xffff) == 0xffffffff)
1323         {
1324           if (INTVAL (operands[2]) == 0xffff0000)
1325             return \"movqw %$0,%0\";
1326           else
1327             {
1328               operands[2] = gen_rtx (CONST_INT, VOIDmode,
1329                                      INTVAL (operands[2]) & 0xffff);
1330               return \"andw %2,%0\";
1331             }
1332         }
1333     }
1334   return \"andd %2,%0\";
1337 (define_insn "andhi3"
1338   [(set (match_operand:HI 0 "general_operand" "=g")
1339         (and:HI (match_operand:HI 1 "general_operand" "%0")
1340                 (match_operand:HI 2 "general_operand" "g")))]
1341   ""
1342   "*
1344   if (GET_CODE (operands[2]) == CONST_INT
1345       && (INTVAL (operands[2]) | 0xff) == 0xffffffff)
1346     {
1347       if (INTVAL (operands[2]) == 0xffffff00)
1348         return \"movqb %$0,%0\";
1349       else
1350         {
1351           operands[2] = gen_rtx (CONST_INT, VOIDmode,
1352                                  INTVAL (operands[2]) & 0xff);
1353           return \"andb %2,%0\";
1354         }
1355     }
1356   return \"andw %2,%0\";
1359 (define_insn "andqi3"
1360   [(set (match_operand:QI 0 "general_operand" "=g")
1361         (and:QI (match_operand:QI 1 "general_operand" "%0")
1362                 (match_operand:QI 2 "general_operand" "g")))]
1363   ""
1364   "andb %2,%0")
1366 (define_insn ""
1367   [(set (match_operand:SI 0 "general_operand" "=g")
1368         (and:SI (not:SI (match_operand:SI 1 "general_operand" "rmn"))
1369                 (match_operand:SI 2 "general_operand" "0")))]
1370   ""
1371   "bicd %1,%0")
1373 (define_insn ""
1374   [(set (match_operand:HI 0 "general_operand" "=g")
1375         (and:HI (not:HI (match_operand:HI 1 "general_operand" "g"))
1376                 (match_operand:HI 2 "general_operand" "0")))]
1377   ""
1378   "bicw %1,%0")
1380 (define_insn ""
1381   [(set (match_operand:QI 0 "general_operand" "=g")
1382         (and:QI (not:QI (match_operand:QI 1 "general_operand" "g"))
1383                 (match_operand:QI 2 "general_operand" "0")))]
1384   ""
1385   "bicb %1,%0")
1387 ;;- Bit set instructions.
1389 (define_insn "iorsi3"
1390   [(set (match_operand:SI 0 "general_operand" "=g")
1391         (ior:SI (match_operand:SI 1 "general_operand" "%0")
1392                 (match_operand:SI 2 "general_operand" "rmn")))]
1393   ""
1394   "*
1396   if (GET_CODE (operands[2]) == CONST_INT) {
1397     if ((INTVAL (operands[2]) & 0xffffff00) == 0)
1398       return \"orb %2,%0\";
1399     if ((INTVAL (operands[2]) & 0xffff0000) == 0)
1400       return \"orw %2,%0\";
1401   }
1402   return \"ord %2,%0\";
1405 (define_insn "iorhi3"
1406   [(set (match_operand:HI 0 "general_operand" "=g")
1407         (ior:HI (match_operand:HI 1 "general_operand" "%0")
1408                 (match_operand:HI 2 "general_operand" "g")))]
1409   ""
1410   "*
1412   if (GET_CODE(operands[2]) == CONST_INT &&
1413       (INTVAL(operands[2]) & 0xffffff00) == 0)
1414     return \"orb %2,%0\";
1415   return \"orw %2,%0\";
1418 (define_insn "iorqi3"
1419   [(set (match_operand:QI 0 "general_operand" "=g")
1420         (ior:QI (match_operand:QI 1 "general_operand" "%0")
1421                 (match_operand:QI 2 "general_operand" "g")))]
1422   ""
1423   "orb %2,%0")
1425 ;;- xor instructions.
1427 (define_insn "xorsi3"
1428   [(set (match_operand:SI 0 "general_operand" "=g")
1429         (xor:SI (match_operand:SI 1 "general_operand" "%0")
1430                 (match_operand:SI 2 "general_operand" "rmn")))]
1431   ""
1432   "*
1434   if (GET_CODE (operands[2]) == CONST_INT) {
1435     if ((INTVAL (operands[2]) & 0xffffff00) == 0)
1436       return \"xorb %2,%0\";
1437     if ((INTVAL (operands[2]) & 0xffff0000) == 0)
1438       return \"xorw %2,%0\";
1439   }
1440   return \"xord %2,%0\";
1443 (define_insn "xorhi3"
1444   [(set (match_operand:HI 0 "general_operand" "=g")
1445         (xor:HI (match_operand:HI 1 "general_operand" "%0")
1446                 (match_operand:HI 2 "general_operand" "g")))]
1447   ""
1448   "*
1450   if (GET_CODE(operands[2]) == CONST_INT &&
1451       (INTVAL(operands[2]) & 0xffffff00) == 0)
1452     return \"xorb %2,%0\";
1453   return \"xorw %2,%0\";
1456 (define_insn "xorqi3"
1457   [(set (match_operand:QI 0 "general_operand" "=g")
1458         (xor:QI (match_operand:QI 1 "general_operand" "%0")
1459                 (match_operand:QI 2 "general_operand" "g")))]
1460   ""
1461   "xorb %2,%0")
1463 (define_insn "negdf2"
1464   [(set (match_operand:DF 0 "general_operand" "=fm<")
1465         (neg:DF (match_operand:DF 1 "general_operand" "fmF")))]
1466   "TARGET_32081"
1467   "negl %1,%0")
1469 (define_insn "negsf2"
1470   [(set (match_operand:SF 0 "general_operand" "=fm<")
1471         (neg:SF (match_operand:SF 1 "general_operand" "fmF")))]
1472   "TARGET_32081"
1473   "negf %1,%0")
1475 (define_insn "negdi2"
1476   [(set (match_operand:DI 0 "general_operand" "=ro")
1477         (neg:DI (match_operand:DI 1 "general_operand" "ro")))]
1478   ""
1479   "*
1481   rtx low[2], high[2], xops[4];
1482   split_di (operands, 2, low, high);
1483   xops[0] = low[0];
1484   xops[1] = high[0];
1485   xops[2] = low[1];
1486   xops[3] = high[1];
1488   if (rtx_equal_p (operands[0], operands[1]))
1489     {
1490       output_asm_insn (\"negd %3,%1\", xops);
1491       output_asm_insn (\"negd %2,%0\", xops);
1492       output_asm_insn (\"subcd %$0,%1\", xops);
1493     }
1494   else
1495     {
1496       output_asm_insn (\"negd %2,%0\", xops);
1497       output_asm_insn (\"movqd %$0,%1\", xops);
1498       output_asm_insn (\"subcd %3,%1\", xops);
1499     }
1500   return \"\"; 
1503 (define_insn "negsi2"
1504   [(set (match_operand:SI 0 "general_operand" "=g<")
1505         (neg:SI (match_operand:SI 1 "general_operand" "rmn")))]
1506   ""
1507   "negd %1,%0")
1509 (define_insn "neghi2"
1510   [(set (match_operand:HI 0 "general_operand" "=g<")
1511         (neg:HI (match_operand:HI 1 "general_operand" "g")))]
1512   ""
1513   "negw %1,%0")
1515 (define_insn "negqi2"
1516   [(set (match_operand:QI 0 "general_operand" "=g<")
1517         (neg:QI (match_operand:QI 1 "general_operand" "g")))]
1518   ""
1519   "negb %1,%0")
1521 (define_insn "one_cmplsi2"
1522   [(set (match_operand:SI 0 "general_operand" "=g<")
1523         (not:SI (match_operand:SI 1 "general_operand" "rmn")))]
1524   ""
1525   "comd %1,%0")
1527 (define_insn "one_cmplhi2"
1528   [(set (match_operand:HI 0 "general_operand" "=g<")
1529         (not:HI (match_operand:HI 1 "general_operand" "g")))]
1530   ""
1531   "comw %1,%0")
1533 (define_insn "one_cmplqi2"
1534   [(set (match_operand:QI 0 "general_operand" "=g<")
1535         (not:QI (match_operand:QI 1 "general_operand" "g")))]
1536   ""
1537   "comb %1,%0")
1539 ;; arithmetic left and right shift operations
1540 ;; on the 32532 we will always use lshd for arithmetic left shifts,
1541 ;; because it is three times faster.  Broken programs which
1542 ;; use negative shift counts are probably broken differently
1543 ;; than elsewhere.
1545 ;; alternative 0 never matches on the 32532
1546 (define_insn "ashlsi3"
1547   [(set (match_operand:SI 0 "general_operand" "=g,g")
1548         (ashift:SI (match_operand:SI 1 "general_operand" "r,0")
1549                    (match_operand:SI 2 "general_operand" "I,rmn")))]
1550   ""
1551   "*
1552 { if (TARGET_32532)
1553     return \"lshd %2,%0\";
1554   else
1555     return output_shift_insn (operands);
1558 (define_insn "ashlhi3"
1559   [(set (match_operand:HI 0 "general_operand" "=g")
1560         (ashift:HI (match_operand:HI 1 "general_operand" "0")
1561                    (match_operand:SI 2 "general_operand" "rmn")))]
1562   ""
1563   "*
1564 { if (GET_CODE (operands[2]) == CONST_INT)
1565     {
1566       if (INTVAL (operands[2]) == 1)
1567         return \"addw %0,%0\";
1568       else if (! TARGET_32532 && INTVAL (operands[2]) == 2)
1569         return \"addw %0,%0\;addw %0,%0\";
1570     }
1571   if (TARGET_32532)
1572     return \"lshw %2,%0\";
1573   else
1574     return \"ashw %2,%0\";
1577 (define_insn "ashlqi3"
1578   [(set (match_operand:QI 0 "general_operand" "=g")
1579         (ashift:QI (match_operand:QI 1 "general_operand" "0")
1580                    (match_operand:SI 2 "general_operand" "rmn")))]
1581   ""
1582   "*
1583 { if (GET_CODE (operands[2]) == CONST_INT)
1584     {
1585       if (INTVAL (operands[2]) == 1)
1586         return \"addb %0,%0\";
1587       else if (! TARGET_32532 && INTVAL (operands[2]) == 2)
1588         return \"addb %0,%0\;addb %0,%0\";
1589     }
1590   if (TARGET_32532)
1591     return \"lshb %2,%0\";
1592   else
1593     return \"ashb %2,%0\";
1596 ;; Arithmetic right shift on the 32k works by negating the shift count.
1597 (define_expand "ashrsi3"
1598   [(set (match_operand:SI 0 "general_operand" "=g")
1599         (ashiftrt:SI (match_operand:SI 1 "general_operand" "g")
1600                      (match_operand:SI 2 "general_operand" "g")))]
1601   ""
1602   "
1604   if (GET_CODE (operands[2]) != CONST_INT)
1605     operands[2] = gen_rtx (NEG, SImode, negate_rtx (SImode, operands[2]));
1608 (define_insn ""
1609   [(set (match_operand:SI 0 "general_operand" "=g")
1610         (ashiftrt:SI (match_operand:SI 1 "general_operand" "0")
1611                      (match_operand:SI 2 "immediate_operand" "i")))]
1612   ""
1613   "ashd %$%n2,%0")
1615 (define_insn ""
1616   [(set (match_operand:SI 0 "general_operand" "=g")
1617         (ashiftrt:SI (match_operand:SI 1 "general_operand" "0")
1618                      (neg:SI (match_operand:SI 2 "general_operand" "r"))))]
1619   ""
1620   "ashd %2,%0")
1622 (define_expand "ashrhi3"
1623   [(set (match_operand:HI 0 "general_operand" "=g")
1624         (ashiftrt:HI (match_operand:HI 1 "general_operand" "g")
1625                      (match_operand:SI 2 "general_operand" "g")))]
1626   ""
1627   "
1629   if (GET_CODE (operands[2]) != CONST_INT)
1630     operands[2] = gen_rtx (NEG, SImode, negate_rtx (SImode, operands[2]));
1633 (define_insn ""
1634   [(set (match_operand:HI 0 "general_operand" "=g")
1635         (ashiftrt:HI (match_operand:HI 1 "general_operand" "0")
1636                      (match_operand:SI 2 "immediate_operand" "i")))]
1637   ""
1638   "ashw %$%n2,%0")
1640 (define_insn ""
1641   [(set (match_operand:HI 0 "general_operand" "=g")
1642         (ashiftrt:HI (match_operand:HI 1 "general_operand" "0")
1643                      (neg:SI (match_operand:SI 2 "general_operand" "r"))))]
1644   ""
1645   "ashw %2,%0")
1647 (define_expand "ashrqi3"
1648   [(set (match_operand:QI 0 "general_operand" "=g")
1649         (ashiftrt:QI (match_operand:QI 1 "general_operand" "g")
1650                      (match_operand:SI 2 "general_operand" "g")))]
1651   ""
1652   "
1654   if (GET_CODE (operands[2]) != CONST_INT)
1655     operands[2] = gen_rtx (NEG, SImode, negate_rtx (SImode, operands[2]));
1658 (define_insn ""
1659   [(set (match_operand:QI 0 "general_operand" "=g")
1660         (ashiftrt:QI (match_operand:QI 1 "general_operand" "0")
1661                      (match_operand:SI 2 "immediate_operand" "i")))]
1662   ""
1663   "ashb %$%n2,%0")
1665 (define_insn ""
1666   [(set (match_operand:QI 0 "general_operand" "=g")
1667         (ashiftrt:QI (match_operand:QI 1 "general_operand" "0")
1668                      (neg:SI (match_operand:SI 2 "general_operand" "r"))))]
1669   ""
1670   "ashb %2,%0")
1672 ;; logical shift instructions
1674 ;; Logical right shift on the 32k works by negating the shift count.
1675 (define_expand "lshrsi3"
1676   [(set (match_operand:SI 0 "general_operand" "=g")
1677         (lshiftrt:SI (match_operand:SI 1 "general_operand" "g")
1678                      (match_operand:SI 2 "general_operand" "g")))]
1679   ""
1680   "
1682   if (GET_CODE (operands[2]) != CONST_INT)
1683     operands[2] = gen_rtx (NEG, SImode, negate_rtx (SImode, operands[2]));
1686 (define_insn ""
1687   [(set (match_operand:SI 0 "general_operand" "=g")
1688         (lshiftrt:SI (match_operand:SI 1 "general_operand" "0")
1689                      (match_operand:SI 2 "immediate_operand" "i")))]
1690   ""
1691   "lshd %$%n2,%0")
1693 (define_insn ""
1694   [(set (match_operand:SI 0 "general_operand" "=g")
1695         (lshiftrt:SI (match_operand:SI 1 "general_operand" "0")
1696                      (neg:SI (match_operand:SI 2 "general_operand" "r"))))]
1697   ""
1698   "lshd %2,%0")
1700 (define_expand "lshrhi3"
1701   [(set (match_operand:HI 0 "general_operand" "=g")
1702         (lshiftrt:HI (match_operand:HI 1 "general_operand" "g")
1703                      (match_operand:SI 2 "general_operand" "g")))]
1704   ""
1705   "
1707   if (GET_CODE (operands[2]) != CONST_INT)
1708     operands[2] = gen_rtx (NEG, SImode, negate_rtx (SImode, operands[2]));
1711 (define_insn ""
1712   [(set (match_operand:HI 0 "general_operand" "=g")
1713         (lshiftrt:HI (match_operand:HI 1 "general_operand" "0")
1714                      (match_operand:SI 2 "immediate_operand" "i")))]
1715   ""
1716   "lshw %$%n2,%0")
1718 (define_insn ""
1719   [(set (match_operand:HI 0 "general_operand" "=g")
1720         (lshiftrt:HI (match_operand:HI 1 "general_operand" "0")
1721                      (neg:SI (match_operand:SI 2 "general_operand" "r"))))]
1722   ""
1723   "lshw %2,%0")
1725 (define_expand "lshrqi3"
1726   [(set (match_operand:QI 0 "general_operand" "=g")
1727         (lshiftrt:QI (match_operand:QI 1 "general_operand" "g")
1728                      (match_operand:SI 2 "general_operand" "g")))]
1729   ""
1730   "
1732   if (GET_CODE (operands[2]) != CONST_INT)
1733     operands[2] = gen_rtx (NEG, SImode, negate_rtx (SImode, operands[2]));
1736 (define_insn ""
1737   [(set (match_operand:QI 0 "general_operand" "=g")
1738         (lshiftrt:QI (match_operand:QI 1 "general_operand" "0")
1739                      (match_operand:SI 2 "immediate_operand" "i")))]
1740   ""
1741   "lshb %$%n2,%0")
1743 (define_insn ""
1744   [(set (match_operand:QI 0 "general_operand" "=g")
1745         (lshiftrt:QI (match_operand:QI 1 "general_operand" "0")
1746                      (neg:SI (match_operand:SI 2 "general_operand" "r"))))]
1747   ""
1748   "lshb %2,%0")
1750 ;; Rotate instructions
1752 (define_insn "rotlsi3"
1753   [(set (match_operand:SI 0 "general_operand" "=g")
1754         (rotate:SI (match_operand:SI 1 "general_operand" "0")
1755                    (match_operand:SI 2 "general_operand" "rmn")))]
1756   ""
1757   "rotd %2,%0")
1759 (define_insn "rotlhi3"
1760   [(set (match_operand:HI 0 "general_operand" "=g")
1761         (rotate:HI (match_operand:HI 1 "general_operand" "0")
1762                    (match_operand:SI 2 "general_operand" "rmn")))]
1763   ""
1764   "rotw %2,%0")
1766 (define_insn "rotlqi3"
1767   [(set (match_operand:QI 0 "general_operand" "=g")
1768         (rotate:QI (match_operand:QI 1 "general_operand" "0")
1769                    (match_operand:SI 2 "general_operand" "rmn")))]
1770   ""
1771   "rotb %2,%0")
1773 ;; Right rotate on the 32k works by negating the shift count.
1774 (define_expand "rotrsi3"
1775   [(set (match_operand:SI 0 "general_operand" "=g")
1776         (rotatert:SI (match_operand:SI 1 "general_operand" "g")
1777                      (match_operand:SI 2 "general_operand" "g")))]
1778   ""
1779   "
1781   if (GET_CODE (operands[2]) != CONST_INT)
1782     operands[2] = gen_rtx (NEG, SImode, negate_rtx (SImode, operands[2]));
1785 (define_insn ""
1786   [(set (match_operand:SI 0 "general_operand" "=g")
1787         (rotatert:SI (match_operand:SI 1 "general_operand" "0")
1788                      (match_operand:SI 2 "immediate_operand" "i")))]
1789   ""
1790   "rotd %$%n2,%0")
1792 (define_insn ""
1793   [(set (match_operand:SI 0 "general_operand" "=g")
1794         (rotatert:SI (match_operand:SI 1 "general_operand" "0")
1795                      (neg:SI (match_operand:SI 2 "general_operand" "r"))))]
1796   ""
1797   "rotd %2,%0")
1799 (define_expand "rotrhi3"
1800   [(set (match_operand:HI 0 "general_operand" "=g")
1801         (rotatert:HI (match_operand:HI 1 "general_operand" "g")
1802                      (match_operand:SI 2 "general_operand" "g")))]
1803   ""
1804   "
1806   if (GET_CODE (operands[2]) != CONST_INT)
1807     operands[2] = gen_rtx (NEG, SImode, negate_rtx (SImode, operands[2]));
1810 (define_insn ""
1811   [(set (match_operand:HI 0 "general_operand" "=g")
1812         (rotatert:HI (match_operand:HI 1 "general_operand" "0")
1813                      (match_operand:SI 2 "immediate_operand" "i")))]
1814   ""
1815   "rotw %$%n2,%0")
1817 (define_insn ""
1818   [(set (match_operand:HI 0 "general_operand" "=g")
1819         (rotatert:HI (match_operand:HI 1 "general_operand" "0")
1820                      (neg:SI (match_operand:SI 2 "general_operand" "r"))))]
1821   ""
1822   "rotw %2,%0")
1824 (define_expand "rotrqi3"
1825   [(set (match_operand:QI 0 "general_operand" "=g")
1826         (rotatert:QI (match_operand:QI 1 "general_operand" "g")
1827                      (match_operand:SI 2 "general_operand" "g")))]
1828   ""
1829   "
1831   if (GET_CODE (operands[2]) != CONST_INT)
1832     operands[2] = gen_rtx (NEG, SImode, negate_rtx (SImode, operands[2]));
1835 (define_insn ""
1836   [(set (match_operand:QI 0 "general_operand" "=g")
1837         (rotatert:QI (match_operand:QI 1 "general_operand" "0")
1838                      (match_operand:SI 2 "immediate_operand" "i")))]
1839   ""
1840   "rotb %$%n2,%0")
1842 (define_insn ""
1843   [(set (match_operand:QI 0 "general_operand" "=g")
1844         (rotatert:QI (match_operand:QI 1 "general_operand" "0")
1845                      (neg:SI (match_operand:SI 2 "general_operand" "r"))))]
1846   ""
1847   "rotb %2,%0")
1849 ;;- load or push effective address 
1850 ;; These come after the move, add, and multiply patterns
1851 ;; because we don't want pushl $1 turned into pushad 1.
1853 (define_insn ""
1854   [(set (match_operand:SI 0 "general_operand" "=g<")
1855         (match_operand:QI 1 "address_operand" "p"))]
1856   ""
1857   "*
1859   if (REG_P (operands[0])
1860       && GET_CODE (operands[1]) == MULT
1861       && GET_CODE (XEXP (operands[1], 1)) == CONST_INT
1862       && (INTVAL (XEXP (operands[1], 1)) == 2
1863           || INTVAL (XEXP (operands[1], 1)) == 4))
1864     {
1865       rtx xoperands[3];
1866       xoperands[0] = operands[0];
1867       xoperands[1] = XEXP (operands[1], 0);
1868       xoperands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (XEXP (operands[1], 1)) >> 1);
1869       return output_shift_insn (xoperands);
1870     }
1871   return \"addr %a1,%0\";
1874 ;;; Index insns.  These are about the same speed as multiply-add counterparts.
1875 ;;; but slower then using power-of-2 shifts if we can use them
1877 ;(define_insn ""
1878 ;  [(set (match_operand:SI 0 "register_operand" "=r")
1879 ;       (plus:SI (match_operand:SI 1 "general_operand" "rmn")
1880 ;                (mult:SI (match_operand:SI 2 "register_operand" "0")
1881 ;                         (plus:SI (match_operand:SI 3 "general_operand" "rmn") (const_int 1)))))]
1882 ;  "GET_CODE (operands[3]) != CONST_INT || INTVAL (operands[3]) > 8"
1883 ;  "indexd %0,%3,%1")
1885 ;(define_insn ""
1886 ;  [(set (match_operand:SI 0 "register_operand" "=r")
1887 ;       (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "0")
1888 ;                         (plus:SI (match_operand:SI 2 "general_operand" "rmn") (const_int 1)))
1889 ;                (match_operand:SI 3 "general_operand" "rmn")))]
1890 ;  "GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) > 8"
1891 ;  "indexd %0,%2,%3")
1893 ;; Set, Clear, and Invert bit
1895 (define_insn ""
1896   [(set (zero_extract:SI (match_operand:SI 0 "general_operand" "+g")
1897                          (const_int 1)
1898                          (match_operand:SI 1 "general_operand" "rmn"))
1899         (const_int 1))]
1900   ""
1901   "sbitd %1,%0")
1903 (define_insn ""
1904   [(set (zero_extract:SI (match_operand:SI 0 "general_operand" "+g")
1905                          (const_int 1)
1906                          (match_operand:SI 1 "general_operand" "rmn"))
1907         (const_int 0))]
1908   ""
1909   "cbitd %1,%0")
1911 (define_insn ""
1912   [(set (match_operand:SI 0 "general_operand" "+g")
1913         (xor:SI (ashift:SI (const_int 1)
1914                            (match_operand:SI 1 "general_operand" "rmn"))
1915                 (match_dup 0)))]
1916   ""
1917   "ibitd %1,%0")
1919 (define_insn ""
1920   [(set (match_operand:QI 0 "general_operand" "=g")
1921         (xor:QI (subreg:QI
1922                  (ashift:SI (const_int 1)
1923                             (match_operand:QI 1 "general_operand" "rmn")) 0)
1924                 (match_dup 0)))]
1925   ""
1926   "ibitb %1,%0")
1928 ;; Recognize jbs and jbc instructions.
1930 (define_insn ""
1931   [(set (cc0)
1932         (zero_extract (match_operand:SI 0 "general_operand" "rm")
1933                       (const_int 1)
1934                       (match_operand:SI 1 "general_operand" "g")))]
1935   ""
1936   "*
1937 { cc_status.flags = CC_Z_IN_F;
1938   return \"tbitd %1,%0\";
1941 ;; extract(base, width, offset)
1942 ;; Signed bitfield extraction is not supported in hardware on the
1943 ;; NS 32032.  It is therefore better to let GCC figure out a
1944 ;; good strategy for generating the proper instruction sequence
1945 ;; and represent it as rtl.
1947 ;; Optimize the case of extracting a byte or word from a register.
1948 ;; Otherwise we must load a register with the offset of the
1949 ;; chunk we want, and perform an extract insn (each of which
1950 ;; is very expensive).  Since we use the stack to do our bit-twiddling
1951 ;; we cannot use it for a destination.  Perhaps things are fast
1952 ;; enough on the 32532 that such hacks are not needed.
1954 (define_insn ""
1955   [(set (match_operand:SI 0 "general_operand" "=ro")
1956         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
1957                          (match_operand:SI 2 "const_int_operand" "i")
1958                          (match_operand:SI 3 "const_int_operand" "i")))]
1959   "(INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
1960    && (INTVAL (operands[3]) == 8 || INTVAL (operands[3]) == 16 || INTVAL (operands[3]) == 24)"
1961   "*
1963   output_asm_insn (\"movd %1,tos\", operands);
1964   if (INTVAL (operands[2]) == 16)
1965     {
1966       if (INTVAL (operands[3]) == 8)
1967         output_asm_insn (\"movzwd 1(sp),%0\", operands);
1968       else
1969         output_asm_insn (\"movzwd 2(sp),%0\", operands);
1970     }
1971   else
1972     {
1973       if (INTVAL (operands[3]) == 8)
1974         output_asm_insn (\"movzbd 1(sp),%0\", operands);
1975       else if (INTVAL (operands[3]) == 16)
1976         output_asm_insn (\"movzbd 2(sp),%0\", operands);
1977       else
1978         output_asm_insn (\"movzbd 3(sp),%0\", operands);
1979     }
1980   if (TARGET_32532 || TARGET_32332)
1981     return \"cmpqd %$0,tos\";
1982   else
1983     return \"adjspb %$-4\";
1986 ;; The exts/ext instructions have the problem that they always access
1987 ;; 32 bits even if the bitfield is smaller. For example the instruction
1988 ;;      extsd 7(r1),r0,2,5
1989 ;; would read not only at address 7(r1) but also at 8(r1) to 10(r1).
1990 ;; If these addresses are in a different (unmapped) page a memory fault
1991 ;; is the result.
1993 ;; Timing considerations:
1994 ;;      movd    0(r1),r0        3 bytes
1995 ;;      lshd    -26,r0          4
1996 ;;      andd    0x1f,r0         5
1997 ;; takes about 13 cycles on the 532 while
1998 ;;      extsd   7(r1),r0,2,5    5 bytes
1999 ;; takes about 21 cycles.
2001 ;; The inss/ins instructions suffer from the same problem.
2003 ;; A machine specific option (-mbitfield/-mnobitfield) is used
2004 ;; to allow/disallow the use of these instructions.
2006 (define_insn ""
2007   [(set (match_operand:SI 0 "general_operand" "=g<")
2008         (zero_extract:SI (match_operand:SI 1 "register_operand" "g")
2009                          (match_operand:SI 2 "const_int_operand" "i")
2010                          (match_operand:SI 3 "general_operand" "rK")))]
2011   "TARGET_BITFIELD"
2012   "*
2013 { if (GET_CODE (operands[3]) == CONST_INT)
2014     return \"extsd %1,%0,%3,%2\";
2015   else return \"extd %3,%1,%0,%2\";
2018 (define_insn "extzv"
2019   [(set (match_operand:SI 0 "general_operand" "=g<")
2020         (zero_extract:SI (match_operand:QI 1 "general_operand" "g")
2021                          (match_operand:SI 2 "const_int_operand" "i")
2022                          (match_operand:SI 3 "general_operand" "rK")))]
2023   "TARGET_BITFIELD"
2024   "*
2025 { if (GET_CODE (operands[3]) == CONST_INT)
2026     return \"extsd %1,%0,%3,%2\";
2027   else return \"extd %3,%1,%0,%2\";
2030 (define_insn ""
2031   [(set (zero_extract:SI (match_operand:SI 0 "memory_operand" "+o")
2032                          (match_operand:SI 1 "const_int_operand" "i")
2033                          (match_operand:SI 2 "general_operand" "rn"))
2034         (match_operand:SI 3 "general_operand" "rm"))]
2035   "TARGET_BITFIELD"
2036   "*
2037 { if (GET_CODE (operands[2]) == CONST_INT)
2038     {
2039       if (INTVAL (operands[2]) >= 8)
2040         {
2041           operands[0] = adj_offsettable_operand (operands[0],
2042                                                 INTVAL (operands[2]) / 8);
2043           operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) % 8);
2044         }
2045       if (INTVAL (operands[1]) <= 8)
2046         return \"inssb %3,%0,%2,%1\";
2047       else if (INTVAL (operands[1]) <= 16)
2048         return \"inssw %3,%0,%2,%1\";
2049       else
2050         return \"inssd %3,%0,%2,%1\";
2051     }
2052   return \"insd %2,%3,%0,%1\";
2055 (define_insn ""
2056   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
2057                          (match_operand:SI 1 "const_int_operand" "i")
2058                          (match_operand:SI 2 "general_operand" "rK"))
2059         (match_operand:SI 3 "general_operand" "rm"))]
2060   "TARGET_BITFIELD"
2061   "*
2062 { if (GET_CODE (operands[2]) == CONST_INT)
2063     if (INTVAL (operands[1]) <= 8)
2064       return \"inssb %3,%0,%2,%1\";
2065     else if (INTVAL (operands[1]) <= 16)
2066       return \"inssw %3,%0,%2,%1\";
2067     else
2068       return \"inssd %3,%0,%2,%1\";
2069   return \"insd %2,%3,%0,%1\";
2072 (define_insn "insv"
2073   [(set (zero_extract:SI (match_operand:QI 0 "general_operand" "+g")
2074                          (match_operand:SI 1 "const_int_operand" "i")
2075                          (match_operand:SI 2 "general_operand" "rK"))
2076         (match_operand:SI 3 "general_operand" "rm"))]
2077   "TARGET_BITFIELD"
2078   "*
2079 { if (GET_CODE (operands[2]) == CONST_INT)
2080     if (INTVAL (operands[1]) <= 8)
2081       return \"inssb %3,%0,%2,%1\";
2082     else if (INTVAL (operands[1]) <= 16)
2083       return \"inssw %3,%0,%2,%1\";
2084     else
2085       return \"inssd %3,%0,%2,%1\";
2086   return \"insd %2,%3,%0,%1\";
2090 (define_insn "jump"
2091   [(set (pc)
2092         (label_ref (match_operand 0 "" "")))]
2093   ""
2094   "br %l0")
2096 (define_insn "beq"
2097   [(set (pc)
2098         (if_then_else (eq (cc0)
2099                           (const_int 0))
2100                       (label_ref (match_operand 0 "" ""))
2101                       (pc)))]
2102   ""
2103   "*
2104 { if (cc_prev_status.flags & CC_Z_IN_F)
2105     return \"bfc %l0\";
2106   else if (cc_prev_status.flags & CC_Z_IN_NOT_F)
2107     return \"bfs %l0\";
2108   else return \"beq %l0\";
2111 (define_insn "bne"
2112   [(set (pc)
2113         (if_then_else (ne (cc0)
2114                           (const_int 0))
2115                       (label_ref (match_operand 0 "" ""))
2116                       (pc)))]
2117   ""
2118   "*
2119 { if (cc_prev_status.flags & CC_Z_IN_F)
2120     return \"bfs %l0\";
2121   else if (cc_prev_status.flags & CC_Z_IN_NOT_F)
2122     return \"bfc %l0\";
2123   else return \"bne %l0\";
2126 (define_insn "bgt"
2127   [(set (pc)
2128         (if_then_else (gt (cc0)
2129                           (const_int 0))
2130                       (label_ref (match_operand 0 "" ""))
2131                       (pc)))]
2132   ""
2133   "bgt %l0")
2135 (define_insn "bgtu"
2136   [(set (pc)
2137         (if_then_else (gtu (cc0)
2138                            (const_int 0))
2139                       (label_ref (match_operand 0 "" ""))
2140                       (pc)))]
2141   ""
2142   "bhi %l0")
2144 (define_insn "blt"
2145   [(set (pc)
2146         (if_then_else (lt (cc0)
2147                           (const_int 0))
2148                       (label_ref (match_operand 0 "" ""))
2149                       (pc)))]
2150   ""
2151   "blt %l0")
2153 (define_insn "bltu"
2154   [(set (pc)
2155         (if_then_else (ltu (cc0)
2156                            (const_int 0))
2157                       (label_ref (match_operand 0 "" ""))
2158                       (pc)))]
2159   ""
2160   "blo %l0")
2162 (define_insn "bge"
2163   [(set (pc)
2164         (if_then_else (ge (cc0)
2165                           (const_int 0))
2166                       (label_ref (match_operand 0 "" ""))
2167                       (pc)))]
2168   ""
2169   "bge %l0")
2171 (define_insn "bgeu"
2172   [(set (pc)
2173         (if_then_else (geu (cc0)
2174                            (const_int 0))
2175                       (label_ref (match_operand 0 "" ""))
2176                       (pc)))]
2177   ""
2178   "bhs %l0")
2180 (define_insn "ble"
2181   [(set (pc)
2182         (if_then_else (le (cc0)
2183                           (const_int 0))
2184                       (label_ref (match_operand 0 "" ""))
2185                       (pc)))]
2186   ""
2187   "ble %l0")
2189 (define_insn "bleu"
2190   [(set (pc)
2191         (if_then_else (leu (cc0)
2192                            (const_int 0))
2193                       (label_ref (match_operand 0 "" ""))
2194                       (pc)))]
2195   ""
2196   "bls %l0")
2198 (define_insn ""
2199   [(set (pc)
2200         (if_then_else (eq (cc0)
2201                           (const_int 0))
2202                       (pc)
2203                       (label_ref (match_operand 0 "" ""))))]
2204   ""
2205   "*
2206 { if (cc_prev_status.flags & CC_Z_IN_F)
2207     return \"bfs %l0\";
2208   else if (cc_prev_status.flags & CC_Z_IN_NOT_F)
2209     return \"bfc %l0\";
2210   else return \"bne %l0\";
2213 (define_insn ""
2214   [(set (pc)
2215         (if_then_else (ne (cc0)
2216                           (const_int 0))
2217                       (pc)
2218                       (label_ref (match_operand 0 "" ""))))]
2219   ""
2220   "*
2221 { if (cc_prev_status.flags & CC_Z_IN_F)
2222     return \"bfc %l0\";
2223   else if (cc_prev_status.flags & CC_Z_IN_NOT_F)
2224     return \"bfs %l0\";
2225   else return \"beq %l0\";
2228 (define_insn ""
2229   [(set (pc)
2230         (if_then_else (gt (cc0)
2231                           (const_int 0))
2232                       (pc)
2233                       (label_ref (match_operand 0 "" ""))))]
2234   ""
2235   "ble %l0")
2237 (define_insn ""
2238   [(set (pc)
2239         (if_then_else (gtu (cc0)
2240                            (const_int 0))
2241                       (pc)
2242                       (label_ref (match_operand 0 "" ""))))]
2243   ""
2244   "bls %l0")
2246 (define_insn ""
2247   [(set (pc)
2248         (if_then_else (lt (cc0)
2249                           (const_int 0))
2250                       (pc)
2251                       (label_ref (match_operand 0 "" ""))))]
2252   ""
2253   "bge %l0")
2255 (define_insn ""
2256   [(set (pc)
2257         (if_then_else (ltu (cc0)
2258                            (const_int 0))
2259                       (pc)
2260                       (label_ref (match_operand 0 "" ""))))]
2261   ""
2262   "bhs %l0")
2264 (define_insn ""
2265   [(set (pc)
2266         (if_then_else (ge (cc0)
2267                           (const_int 0))
2268                       (pc)
2269                       (label_ref (match_operand 0 "" ""))))]
2270   ""
2271   "blt %l0")
2273 (define_insn ""
2274   [(set (pc)
2275         (if_then_else (geu (cc0)
2276                            (const_int 0))
2277                       (pc)
2278                       (label_ref (match_operand 0 "" ""))))]
2279   ""
2280   "blo %l0")
2282 (define_insn ""
2283   [(set (pc)
2284         (if_then_else (le (cc0)
2285                           (const_int 0))
2286                       (pc)
2287                       (label_ref (match_operand 0 "" ""))))]
2288   ""
2289   "bgt %l0")
2291 (define_insn ""
2292   [(set (pc)
2293         (if_then_else (leu (cc0)
2294                            (const_int 0))
2295                       (pc)
2296                       (label_ref (match_operand 0 "" ""))))]
2297   ""
2298   "bhi %l0")
2300 ;; Subtract-and-jump and Add-and-jump insns.
2301 ;; These can actually be used for adding numbers in the range -8 to 7
2303 (define_insn ""
2304   [(set (pc)
2305         (if_then_else
2306          (ne (match_operand:SI 0 "general_operand" "+g")
2307              (match_operand:SI 1 "const_int_operand" "i"))
2308          (label_ref (match_operand 2 "" ""))
2309          (pc)))
2310   (set (match_dup 0)
2311        (minus:SI (match_dup 0)
2312                  (match_dup 1)))]
2313   "INTVAL (operands[1]) > -8 && INTVAL (operands[1]) <= 8"
2314   "acbd %$%n1,%0,%l2")
2316 (define_insn ""
2317   [(set (pc)
2318         (if_then_else
2319          (ne (match_operand:SI 0 "general_operand" "+g")
2320              (match_operand:SI 1 "const_int_operand" "i"))
2321          (label_ref (match_operand 2 "" ""))
2322          (pc)))
2323   (set (match_dup 0)
2324        (plus:SI (match_dup 0)
2325                 (match_operand:SI 3 "const_int_operand" "i")))]
2326   "INTVAL (operands[1]) == - INTVAL (operands[3])
2327    && INTVAL (operands[3]) >= -8 && INTVAL (operands[3]) < 8"
2328   "acbd %3,%0,%l2")
2330 (define_insn "call"
2331   [(call (match_operand:QI 0 "memory_operand" "m")
2332          (match_operand:QI 1 "general_operand" "g"))]
2333   ""
2334   "*
2336 #ifndef JSR_ALWAYS
2337   if (GET_CODE (operands[0]) == MEM)
2338     {
2339       rtx temp = XEXP (operands[0], 0);
2340       if (CONSTANT_ADDRESS_P (temp))
2341         {
2342 #ifdef ENCORE_ASM
2343           return \"bsr %?%0\";
2344 #else
2345 #ifdef CALL_MEMREF_IMPLICIT
2346           operands[0] = temp;
2347           return \"bsr %0\";
2348 #else
2349 #ifdef GNX_V3
2350           return \"bsr %0\";
2351 #else
2352           return \"bsr %?%a0\";
2353 #endif
2354 #endif
2355 #endif
2356         }
2357       if (GET_CODE (XEXP (operands[0], 0)) == REG)
2358 #if defined (GNX_V3) || defined (CALL_MEMREF_IMPLICIT)
2359         return \"jsr %0\";
2360 #else
2361         return \"jsr %a0\";
2362 #endif
2363     }
2364 #endif /* not JSR_ALWAYS */
2365   return \"jsr %0\";
2368 (define_insn "call_value"
2369   [(set (match_operand 0 "" "=rf")
2370         (call (match_operand:QI 1 "memory_operand" "m")
2371               (match_operand:QI 2 "general_operand" "g")))]
2372   ""
2373   "*
2375 #ifndef JSR_ALWAYS
2376   if (GET_CODE (operands[1]) == MEM)
2377     {
2378       rtx temp = XEXP (operands[1], 0);
2379       if (CONSTANT_ADDRESS_P (temp))
2380         {
2381 #ifdef ENCORE_ASM
2382           return \"bsr %?%1\";
2383 #else
2384 #ifdef CALL_MEMREF_IMPLICIT
2385           operands[1] = temp;
2386           return \"bsr %1\";
2387 #else
2388 #ifdef GNX_V3
2389           return \"bsr %1\";
2390 #else
2391           return \"bsr %?%a1\";
2392 #endif
2393 #endif
2394 #endif
2395         }
2396       if (GET_CODE (XEXP (operands[1], 0)) == REG)
2397 #if defined (GNX_V3) || defined (CALL_MEMREF_IMPLICIT)
2398         return \"jsr %1\";
2399 #else
2400         return \"jsr %a1\";
2401 #endif
2402     }
2403 #endif /* not JSR_ALWAYS */
2404   return \"jsr %1\";
2407 ;; Call subroutine returning any type.
2409 (define_expand "untyped_call"
2410   [(parallel [(call (match_operand 0 "" "")
2411                     (const_int 0))
2412               (match_operand 1 "" "")
2413               (match_operand 2 "" "")])]
2414   ""
2415   "
2417   int i;
2419   emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx));
2421   for (i = 0; i < XVECLEN (operands[2], 0); i++)
2422     {
2423       rtx set = XVECEXP (operands[2], 0, i);
2424       emit_move_insn (SET_DEST (set), SET_SRC (set));
2425     }
2427   /* The optimizer does not know that the call sets the function value
2428      registers we stored in the result block.  We avoid problems by
2429      claiming that all hard registers are used and clobbered at this
2430      point.  */
2431   emit_insn (gen_blockage ());
2433   DONE;
2436 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
2437 ;; all of memory.  This blocks insns from being moved across this point.
2439 (define_insn "blockage"
2440   [(unspec_volatile [(const_int 0)] 0)]
2441   ""
2442   "")
2444 (define_insn "return"
2445   [(return)]
2446   "0"
2447   "ret 0")
2449 (define_insn "abssf2"
2450   [(set (match_operand:SF 0 "general_operand" "=fm<")
2451         (abs:SF (match_operand:SF 1 "general_operand" "fmF")))]
2452   "TARGET_32081"
2453   "absf %1,%0")
2455 (define_insn "absdf2"
2456   [(set (match_operand:DF 0 "general_operand" "=fm<")
2457         (abs:DF (match_operand:DF 1 "general_operand" "fmF")))]
2458   "TARGET_32081"
2459   "absl %1,%0")
2461 (define_insn "abssi2"
2462   [(set (match_operand:SI 0 "general_operand" "=g<")
2463         (abs:SI (match_operand:SI 1 "general_operand" "rmn")))]
2464   ""
2465   "absd %1,%0")
2467 (define_insn "abshi2"
2468   [(set (match_operand:HI 0 "general_operand" "=g<")
2469         (abs:HI (match_operand:HI 1 "general_operand" "g")))]
2470   ""
2471   "absw %1,%0")
2473 (define_insn "absqi2"
2474   [(set (match_operand:QI 0 "general_operand" "=g<")
2475         (abs:QI (match_operand:QI 1 "general_operand" "g")))]
2476   ""
2477   "absb %1,%0")
2479 (define_insn "nop"
2480   [(const_int 0)]
2481   ""
2482   "nop")
2484 (define_insn "indirect_jump"
2485   [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
2486   ""
2487   "jump %0")
2489 (define_insn "tablejump"
2490   [(set (pc)
2491         (plus:SI (pc) (match_operand:SI 0 "general_operand" "g")))
2492    (use (label_ref (match_operand 1 "" "")))]
2493   ""
2494   "*
2496   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"LI\",
2497                              CODE_LABEL_NUMBER (operands[1]));
2498   return \"cased %0\";
2501 ;; Scondi instructions
2502 (define_insn "seq"
2503   [(set (match_operand:SI 0 "general_operand" "=g<")
2504         (eq:SI (cc0) (const_int 0)))]
2505   ""
2506   "*
2507 { if (cc_prev_status.flags & CC_Z_IN_F)
2508     return \"sfcd %0\";
2509   else if (cc_prev_status.flags & CC_Z_IN_NOT_F)
2510     return \"sfsd %0\";
2511   else return \"seqd %0\";
2514 (define_insn ""
2515   [(set (match_operand:HI 0 "general_operand" "=g<")
2516         (eq:HI (cc0) (const_int 0)))]
2517   ""
2518   "*
2519 { if (cc_prev_status.flags & CC_Z_IN_F)
2520     return \"sfcw %0\";
2521   else if (cc_prev_status.flags & CC_Z_IN_NOT_F)
2522     return \"sfsw %0\";
2523   else return \"seqw %0\";
2526 (define_insn ""
2527   [(set (match_operand:QI 0 "general_operand" "=g<")
2528         (eq:QI (cc0) (const_int 0)))]
2529   ""
2530   "*
2531 { if (cc_prev_status.flags & CC_Z_IN_F)
2532     return \"sfcb %0\";
2533   else if (cc_prev_status.flags & CC_Z_IN_NOT_F)
2534     return \"sfsb %0\";
2535   else return \"seqb %0\";
2538 (define_insn "sne"
2539   [(set (match_operand:SI 0 "general_operand" "=g<")
2540         (ne:SI (cc0) (const_int 0)))]
2541   ""
2542   "*
2543 { if (cc_prev_status.flags & CC_Z_IN_F)
2544     return \"sfsd %0\";
2545   else if (cc_prev_status.flags & CC_Z_IN_NOT_F)
2546     return \"sfcd %0\";
2547   else return \"sned %0\";
2550 (define_insn ""
2551   [(set (match_operand:HI 0 "general_operand" "=g<")
2552         (ne:HI (cc0) (const_int 0)))]
2553   ""
2554   "*
2555 { if (cc_prev_status.flags & CC_Z_IN_F)
2556     return \"sfsw %0\";
2557   else if (cc_prev_status.flags & CC_Z_IN_NOT_F)
2558     return \"sfcw %0\";
2559   else return \"snew %0\";
2562 (define_insn ""
2563   [(set (match_operand:QI 0 "general_operand" "=g<")
2564         (ne:QI (cc0) (const_int 0)))]
2565   ""
2566   "*
2567 { if (cc_prev_status.flags & CC_Z_IN_F)
2568     return \"sfsb %0\";
2569   else if (cc_prev_status.flags & CC_Z_IN_NOT_F)
2570     return \"sfcb %0\";
2571   else return \"sneb %0\";
2574 (define_insn "sgt"
2575   [(set (match_operand:SI 0 "general_operand" "=g<")
2576         (gt:SI (cc0) (const_int 0)))]
2577   ""
2578   "sgtd %0")
2580 (define_insn ""
2581   [(set (match_operand:HI 0 "general_operand" "=g<")
2582         (gt:HI (cc0) (const_int 0)))]
2583   ""
2584   "sgtw %0")
2586 (define_insn ""
2587   [(set (match_operand:QI 0 "general_operand" "=g<")
2588         (gt:QI (cc0) (const_int 0)))]
2589   ""
2590   "sgtb %0")
2592 (define_insn "sgtu"
2593   [(set (match_operand:SI 0 "general_operand" "=g<")
2594         (gtu:SI (cc0) (const_int 0)))]
2595   ""
2596   "shid %0")
2598 (define_insn ""
2599   [(set (match_operand:HI 0 "general_operand" "=g<")
2600         (gtu:HI (cc0) (const_int 0)))]
2601   ""
2602   "shiw %0")
2604 (define_insn ""
2605   [(set (match_operand:QI 0 "general_operand" "=g<")
2606         (gtu:QI (cc0) (const_int 0)))]
2607   ""
2608   "shib %0")
2610 (define_insn "slt"
2611   [(set (match_operand:SI 0 "general_operand" "=g<")
2612         (lt:SI (cc0) (const_int 0)))]
2613   ""
2614   "sltd %0")
2616 (define_insn ""
2617   [(set (match_operand:HI 0 "general_operand" "=g<")
2618         (lt:HI (cc0) (const_int 0)))]
2619   ""
2620   "sltw %0")
2622 (define_insn ""
2623   [(set (match_operand:QI 0 "general_operand" "=g<")
2624         (lt:QI (cc0) (const_int 0)))]
2625   ""
2626   "sltb %0")
2628 (define_insn "sltu"
2629   [(set (match_operand:SI 0 "general_operand" "=g<")
2630         (ltu:SI (cc0) (const_int 0)))]
2631   ""
2632   "slod %0")
2634 (define_insn ""
2635   [(set (match_operand:HI 0 "general_operand" "=g<")
2636         (ltu:HI (cc0) (const_int 0)))]
2637   ""
2638   "slow %0")
2640 (define_insn ""
2641   [(set (match_operand:QI 0 "general_operand" "=g<")
2642         (ltu:QI (cc0) (const_int 0)))]
2643   ""
2644   "slob %0")
2646 (define_insn "sge"
2647   [(set (match_operand:SI 0 "general_operand" "=g<")
2648         (ge:SI (cc0) (const_int 0)))]
2649   ""
2650   "sged %0")
2652 (define_insn ""
2653   [(set (match_operand:HI 0 "general_operand" "=g<")
2654         (ge:HI (cc0) (const_int 0)))]
2655   ""
2656   "sgew %0")
2658 (define_insn ""
2659   [(set (match_operand:QI 0 "general_operand" "=g<")
2660         (ge:QI (cc0) (const_int 0)))]
2661   ""
2662   "sgeb %0")
2664 (define_insn "sgeu"
2665   [(set (match_operand:SI 0 "general_operand" "=g<")
2666         (geu:SI (cc0) (const_int 0)))]
2667   ""
2668   "shsd %0")  
2670 (define_insn ""
2671   [(set (match_operand:HI 0 "general_operand" "=g<")
2672         (geu:HI (cc0) (const_int 0)))]
2673   ""
2674   "shsw %0")  
2676 (define_insn ""
2677   [(set (match_operand:QI 0 "general_operand" "=g<")
2678         (geu:QI (cc0) (const_int 0)))]
2679   ""
2680   "shsb %0")  
2682 (define_insn "sle"
2683   [(set (match_operand:SI 0 "general_operand" "=g<")
2684         (le:SI (cc0) (const_int 0)))]
2685   ""
2686   "sled %0")
2688 (define_insn ""
2689   [(set (match_operand:HI 0 "general_operand" "=g<")
2690         (le:HI (cc0) (const_int 0)))]
2691   ""
2692   "slew %0")
2694 (define_insn ""
2695   [(set (match_operand:QI 0 "general_operand" "=g<")
2696         (le:QI (cc0) (const_int 0)))]
2697   ""
2698   "sleb %0")
2700 (define_insn "sleu"
2701   [(set (match_operand:SI 0 "general_operand" "=g<")
2702         (leu:SI (cc0) (const_int 0)))]
2703   ""
2704   "slsd %0")
2706 (define_insn ""
2707   [(set (match_operand:HI 0 "general_operand" "=g<")
2708         (leu:HI (cc0) (const_int 0)))]
2709   ""
2710   "slsw %0")
2712 (define_insn ""
2713   [(set (match_operand:QI 0 "general_operand" "=g<")
2714         (leu:QI (cc0) (const_int 0)))]
2715   ""
2716   "slsb %0")
2718 ;; ffs instructions
2720 (define_insn ""
2721   [(set (match_operand:SI 0 "general_operand" "ro")
2722         (minus:SI 
2723                 (plus:SI (ffs:SI (zero_extract:SI 
2724                                 (match_operand:SI 1 "general_operand" "g") 
2725                                 (minus:SI (const_int 32) (match_dup 0))
2726                                 (match_dup 0)))
2727                         (match_dup 0)) 
2728                 (const_int 1)))]
2729   ""
2730   "ffsd %1,%0; bfc 1f; addqd %$-1,%0; 1:")
2732 (define_expand "ffssi2"
2733   [(set (match_operand:SI 0 "general_operand" "=g") (const_int 0))
2734    (set (match_dup 0)
2735         (minus:SI 
2736                 (plus:SI (ffs:SI (zero_extract:SI 
2737                                 (match_operand:SI 1 "general_operand" "g") 
2738                                 (minus:SI (const_int 32) (match_dup 0))
2739                                 (match_dup 0)))
2740                         (match_dup 0)) 
2741                 (const_int 1)))
2742    (set (match_dup 0)
2743         (plus:SI (match_dup 0)
2744                  (const_int 1)))]
2745   ""
2746   "operands[1] = make_safe_from(operands[1], operands[0]);")
2748 ;; Speed up stack adjust followed by a HI fixedpoint push.
2750 (define_peephole
2751   [(set (reg:SI 17) (plus:SI (reg:SI 17) (const_int -2)))
2752    (set (match_operand:HI 0 "push_operand" "=m")
2753         (match_operand:HI 1 "general_operand" "g"))]
2754   "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
2755   "*
2757   if (GET_CODE (operands[1]) == CONST_INT)
2758         output_asm_insn (output_move_dconst (INTVAL (operands[1]), \"%$%1,tos\"),
2759                          operands);
2760   else
2761         output_asm_insn (\"movzwd %1,tos\", operands);
2762   return \"\";
2765 ;; Speed up stack adjust followed by a zero_extend:HI(QI) fixedpoint push.
2767 (define_peephole
2768   [(set (reg:SI 17) (plus:SI (reg:SI 17) (const_int -2)))
2769    (set (match_operand:HI 0 "push_operand" "=m")
2770         (zero_extend:HI (match_operand:QI 1 "general_operand" "g")))]
2771   "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
2772   "*
2774   if (GET_CODE (operands[1]) == CONST_INT)
2775         output_asm_insn (output_move_dconst (INTVAL (operands[1]), \"%$%1,tos\"),
2776                          operands);
2777   else
2778         output_asm_insn (\"movzbd %1,tos\", operands);
2779   return \"\";
2782 ;; Speed up stack adjust followed by a sign_extend:HI(QI) fixedpoint push.
2784 (define_peephole
2785   [(set (reg:SI 17) (plus:SI (reg:SI 17) (const_int -2)))
2786    (set (match_operand:HI 0 "push_operand" "=m")
2787         (sign_extend:HI (match_operand:QI 1 "general_operand" "g")))]
2788   "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
2789   "*
2791   if (GET_CODE (operands[1]) == CONST_INT)
2792         output_asm_insn (output_move_dconst (INTVAL (operands[1]), \"%$%1,tos\"),
2793                          operands);
2794   else
2795         output_asm_insn (\"movxbd %1,tos\", operands);
2796   return \"\";
2799 ;; Speed up stack adjust followed by a QI fixedpoint push.
2801 (define_peephole
2802   [(set (reg:SI 17) (plus:SI (reg:SI 17) (const_int -3)))
2803    (set (match_operand:QI 0 "push_operand" "=m")
2804         (match_operand:QI 1 "general_operand" "g"))]
2805   "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
2806   "*
2808   if (GET_CODE (operands[1]) == CONST_INT)
2809         output_asm_insn (output_move_dconst (INTVAL (operands[1]), \"%$%1,tos\"),
2810                          operands);
2811   else
2812         output_asm_insn (\"movzbd %1,tos\", operands);
2813   return \"\";
2816 ;; Speed up stack adjust followed by a SI fixedpoint push.
2818 (define_peephole
2819   [(set (reg:SI 17) (plus:SI (reg:SI 17) (const_int 4)))
2820    (set (match_operand:SI 0 "push_operand" "=m")
2821         (match_operand:SI 1 "general_operand" "g"))]
2822   "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
2823   "*
2825   if (GET_CODE (operands[1]) == CONST_INT)
2826         output_asm_insn (output_move_dconst (INTVAL (operands[1]), \"%$%1,0(sp)\"),
2827                          operands);
2828   else if (GET_CODE (operands[1]) != REG
2829            && GET_CODE (operands[1]) != MEM
2830            && address_operand (operands[1], SImode))
2831         output_asm_insn (\"addr %a1,0(sp)\", operands);
2832   else
2833         output_asm_insn (\"movd %1,0(sp)\", operands);
2834   return \"\";
2837 ;; Speed up stack adjust followed by two fullword fixedpoint pushes.
2839 (define_peephole
2840   [(set (reg:SI 17) (plus:SI (reg:SI 17) (const_int 8)))
2841    (set (match_operand:SI 0 "push_operand" "=m")
2842         (match_operand:SI 1 "general_operand" "g"))
2843    (set (match_operand:SI 2 "push_operand" "=m")
2844         (match_operand:SI 3 "general_operand" "g"))]
2845   "! reg_mentioned_p (stack_pointer_rtx, operands[1])
2846    && ! reg_mentioned_p (stack_pointer_rtx, operands[3])"
2847   "*
2849   if (GET_CODE (operands[1]) == CONST_INT)
2850         output_asm_insn (output_move_dconst (INTVAL (operands[1]), \"%$%1,4(sp)\"),
2851                          operands);
2852   else if (GET_CODE (operands[1]) != REG
2853            && GET_CODE (operands[1]) != MEM
2854            && address_operand (operands[1], SImode))
2855         output_asm_insn (\"addr %a1,4(sp)\", operands);
2856   else
2857         output_asm_insn (\"movd %1,4(sp)\", operands);
2859   if (GET_CODE (operands[3]) == CONST_INT)
2860         output_asm_insn (output_move_dconst (INTVAL (operands[3]), \"%$%3,0(sp)\"),
2861                          operands);
2862   else if (GET_CODE (operands[3]) != REG
2863            && GET_CODE (operands[3]) != MEM
2864            && address_operand (operands[3], SImode))
2865         output_asm_insn (\"addr %a3,0(sp)\", operands);
2866   else
2867         output_asm_insn (\"movd %3,0(sp)\", operands);
2868   return \"\";