Update FSF address.
[official-gcc.git] / gcc / config / iq2000 / iq2000.md
bloba5395cc54fe1bb1acf9f3778d9d72ad1b7cc6d8d
1 ;;  iq2000.md        Machine Description for Vitesse IQ2000 processors
2 ;;  Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
4 ;; This file is part of GCC.
6 ;; GCC is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 2, or (at your option)
9 ;; any later version.
11 ;; GCC is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ;; GNU General Public License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING.  If not, write to
18 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19 ;; Boston, MA 02110-1301, USA.
21 (define_constants
22   [(UNSPEC_ADO16 0)
23    (UNSPEC_RAM  1)
24    (UNSPEC_CHKHDR 2)
25    (UNSPEC_PKRL 3)
26    (UNSPEC_CFC0 4)
27    (UNSPEC_CFC1 5)
28    (UNSPEC_CFC2 6)
29    (UNSPEC_CFC3 7)
30    (UNSPEC_CTC0 8)
31    (UNSPEC_CTC1 9)
32    (UNSPEC_CTC2 10)
33    (UNSPEC_CTC3 11)
34    (UNSPEC_MFC0 12)
35    (UNSPEC_MFC1 13)
36    (UNSPEC_MFC2 14)
37    (UNSPEC_MFC3 15)
38    (UNSPEC_MTC0 16)
39    (UNSPEC_MTC1 17)
40    (UNSPEC_MTC2 18)
41    (UNSPEC_MTC3 19)
42    (UNSPEC_LUR  20)
43    (UNSPEC_RB   21)
44    (UNSPEC_RX   22)
45    (UNSPEC_SRRD 23)
46    (UNSPEC_SRWR 24)
47    (UNSPEC_WB   25)
48    (UNSPEC_WX   26)
49    (UNSPEC_LUC32 49)
50    (UNSPEC_LUC32L 27)
51    (UNSPEC_LUC64 28)
52    (UNSPEC_LUC64L 29)
53    (UNSPEC_LUK 30)
54    (UNSPEC_LULCK 31)
55    (UNSPEC_LUM32 32)
56    (UNSPEC_LUM32L 33)
57    (UNSPEC_LUM64 34)
58    (UNSPEC_LUM64L 35)
59    (UNSPEC_LURL 36)
60    (UNSPEC_MRGB 37)
61    (UNSPEC_SRRDL 38)
62    (UNSPEC_SRULCK 39)
63    (UNSPEC_SRWRU 40)
64    (UNSPEC_TRAPQFL 41)
65    (UNSPEC_TRAPQNE 42)
66    (UNSPEC_TRAPREL 43)
67    (UNSPEC_WBU 44)
68    (UNSPEC_SYSCALL 45)]
70 ;; UNSPEC values used in iq2000.md
71 ;; Number       USE
72 ;; 0            movsi_ul
73 ;; 1            movsi_us, get_fnaddr
74 ;; 3            eh_set_return
75 ;; 20           builtin_setjmp_setup
77 ;; UNSPEC_VOLATILE values
78 ;; 0            blockage
79 ;; 2            loadgp
80 ;; 3            builtin_longjmp
81 ;; 4            exception_receiver
82 ;; 10           consttable_qi
83 ;; 11           consttable_hi
84 ;; 12           consttable_si
85 ;; 13           consttable_di
86 ;; 14           consttable_sf
87 ;; 15           consttable_df
88 ;; 16           align_2
89 ;; 17           align_4
90 ;; 18           align_8
93 ;; ....................
95 ;;      Attributes
97 ;; ....................
99 ;; Classification of each insn.
100 ;; branch       conditional branch
101 ;; jump         unconditional jump
102 ;; call         unconditional call
103 ;; load         load instruction(s)
104 ;; store        store instruction(s)
105 ;; move         data movement within same register set
106 ;; xfer         transfer to/from coprocessor
107 ;; arith        integer arithmetic instruction
108 ;; darith       double precision integer arithmetic instructions
109 ;; imul         integer multiply
110 ;; idiv         integer divide
111 ;; icmp         integer compare
112 ;; fadd         floating point add/subtract
113 ;; fmul         floating point multiply
114 ;; fmadd        floating point multiply-add
115 ;; fdiv         floating point divide
116 ;; fabs         floating point absolute value
117 ;; fneg         floating point negation
118 ;; fcmp         floating point compare
119 ;; fcvt         floating point convert
120 ;; fsqrt        floating point square root
121 ;; multi        multiword sequence (or user asm statements)
122 ;; nop          no operation
124 (define_attr "type"
125   "unknown,branch,jump,call,load,store,move,xfer,arith,darith,imul,idiv,icmp,fadd,fmul,fmadd,fdiv,fabs,fneg,fcmp,fcvt,fsqrt,multi,nop"
126   (const_string "unknown"))
128 ;; Main data type used by the insn
129 (define_attr "mode" "unknown,none,QI,HI,SI,DI,SF,DF,FPSW" (const_string "unknown"))
131 ;; Length (in # of bytes).  A conditional branch is allowed only to a
132 ;; location within a signed 18-bit offset of the delay slot.  If that
133 ;; provides too small a range, we use the `j' instruction.  This
134 ;; instruction takes a 28-bit value, but that value is not an offset.
135 ;; Instead, it's bitwise-ored with the high-order four bits of the
136 ;; instruction in the delay slot, which means it cannot be used to
137 ;; cross a 256MB boundary.  We could fall back back on the jr,
138 ;; instruction which allows full access to the entire address space,
139 ;; but we do not do so at present.
141 (define_attr "length" ""
142    (cond [(eq_attr "type" "branch")
143           (cond [(lt (abs (minus (match_dup 1) (plus (pc) (const_int 4))))
144                      (const_int 131072))
145                  (const_int 4)]
146                  (const_int 12))]
147           (const_int 4)))
149 (define_attr "cpu"
150   "default,iq2000"
151   (const (symbol_ref "iq2000_cpu_attr")))
153 ;; Does the instruction have a mandatory delay slot? has_dslot
154 ;; Can the instruction be in a delay slot? ok_in_dslot
155 ;; Can the instruction not be in a delay slot? not_in_dslot
156 (define_attr "dslot" "has_dslot,ok_in_dslot,not_in_dslot"
157   (if_then_else (eq_attr "type" "branch,jump,call,xfer,fcmp")
158                 (const_string "has_dslot")
159                 (const_string "ok_in_dslot")))
161 ;; Attribute defining whether or not we can use the branch-likely instructions
163 (define_attr "branch_likely" "no,yes"
164   (const
165    (if_then_else (ne (symbol_ref "GENERATE_BRANCHLIKELY") (const_int 0))
166                  (const_string "yes")
167                  (const_string "no"))))
170 ;; Describe a user's asm statement.
171 (define_asm_attributes
172   [(set_attr "type" "multi")])
176 ;; .........................
178 ;;      Delay slots, can't describe load/fcmp/xfer delay slots here
180 ;; .........................
182 (define_delay (eq_attr "type" "jump")
183   [(and (eq_attr "dslot" "ok_in_dslot") (eq_attr "length" "4"))
184    (nil)
185    (nil)])
187 (define_delay (eq_attr "type" "branch")
188   [(and (eq_attr "dslot" "ok_in_dslot") (eq_attr "length" "4"))
189    (nil)
190    (and (eq_attr "branch_likely" "yes") (and (eq_attr "dslot" "ok_in_dslot") (eq_attr "length" "4")))])
192 (define_delay (eq_attr "type" "call")
193   [(and (eq_attr "dslot" "ok_in_dslot") (eq_attr "length" "4"))
194    (nil)
195    (nil)])
197 (include "predicates.md")
200 ;; .........................
202 ;;      Pipeline model
204 ;; .........................
206 (define_automaton "iq2000")
207 (define_cpu_unit "core,memory" "iq2000")
209 (define_insn_reservation "nonmemory" 1
210   (eq_attr "type" "!load,move,store,xfer")
211   "core")
213 (define_insn_reservation "iq2000_load_move" 3
214   (and (eq_attr "type" "load,move")
215        (eq_attr "cpu" "iq2000"))
216   "memory")
218 (define_insn_reservation "other_load_move" 1
219   (and (eq_attr "type" "load,move")
220        (eq_attr "cpu" "!iq2000"))
221   "memory")
223 (define_insn_reservation "store" 1
224   (eq_attr "type" "store")
225   "memory")
227 (define_insn_reservation "xfer" 2
228   (eq_attr "type" "xfer")
229   "memory")
232 ;;  ....................
234 ;;      CONDITIONAL TRAPS
236 ;;  ....................
239 (define_insn "trap"
240   [(trap_if (const_int 1) (const_int 0))]
241   ""
242   "*
244   return \"break\";
248 ;;  ....................
250 ;;      ADDITION
252 ;;  ....................
255 (define_expand "addsi3"
256   [(set (match_operand:SI 0 "register_operand" "=d")
257         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
258                  (match_operand:SI 2 "arith_operand" "dI")))]
259   ""
260   "")
262 (define_insn "addsi3_internal"
263   [(set (match_operand:SI 0 "register_operand" "=d,=d")
264         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ,dJ")
265                  (match_operand:SI 2 "arith_operand" "d,I")))]
266   ""
267   "@
268    addu\\t%0,%z1,%2
269    addiu\\t%0,%z1,%2"
270   [(set_attr "type"     "arith")
271    (set_attr "mode"     "SI")])
274 ;;  ....................
276 ;;      SUBTRACTION
278 ;;  ....................
281 (define_expand "subsi3"
282   [(set (match_operand:SI 0 "register_operand" "=d")
283         (minus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
284                   (match_operand:SI 2 "arith_operand" "dI")))]
285   ""
286   "")
288 (define_insn "subsi3_internal"
289   [(set (match_operand:SI 0 "register_operand" "=d,=d")
290         (minus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ,dJ")
291                   (match_operand:SI 2 "arith_operand" "d,I")))]
292   ""
293   "@
294    subu\\t%0,%z1,%2
295    addiu\\t%0,%z1,%n2"
296   [(set_attr "type"     "arith")
297    (set_attr "mode"     "SI")])
300 ;;  ....................
302 ;;      NEGATION and ONE'S COMPLEMENT
304 ;;  ....................
306 (define_insn "negsi2"
307   [(set (match_operand:SI 0 "register_operand" "=d")
308         (neg:SI (match_operand:SI 1 "register_operand" "d")))]
309   ""
310   "*
312   operands[2] = const0_rtx;
313   return \"subu\\t%0,%z2,%1\";
315   [(set_attr "type"     "arith")
316    (set_attr "mode"     "SI")])
318 (define_insn "one_cmplsi2"
319   [(set (match_operand:SI 0 "register_operand" "=d")
320         (not:SI (match_operand:SI 1 "register_operand" "d")))]
321   ""
322   "*
324   operands[2] = const0_rtx;
325   return \"nor\\t%0,%z2,%1\";
327   [(set_attr "type"     "arith")
328    (set_attr "mode"     "SI")])
331 ;;  ....................
333 ;;      LOGICAL
335 ;;  ....................
338 (define_expand "andsi3"
339   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
340         (and:SI (match_operand:SI 1 "uns_arith_operand" "%d,d,d")
341                 (match_operand:SI 2 "nonmemory_operand" "d,K,N")))]
342   ""
343   "")
345 (define_insn ""
346   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
347         (and:SI (match_operand:SI 1 "uns_arith_operand" "%d,d,d")
348                 (match_operand:SI 2 "nonmemory_operand" "d,K,N")))]
349   ""
350   "*
352   if (which_alternative == 0)
353     return \"and\\t%0,%1,%2\";
354   else if (which_alternative == 1)
355     return \"andi\\t%0,%1,%x2\";
356   else if (which_alternative == 2)
357     {
358       if ((INTVAL (operands[2]) & 0xffff) == 0xffff)
359         {
360           operands[2] = GEN_INT (INTVAL (operands[2]) >> 16);
361           return \"andoui\\t%0,%1,%x2\";
362         }
363       else
364         {
365           operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffff);
366           return \"andoi\\t%0,%1,%x2\";
367         }
368     }
370   [(set_attr "type"     "arith")
371    (set_attr "mode"     "SI")])
373 (define_expand "iorsi3"
374   [(set (match_operand:SI 0 "register_operand" "=d,d")
375         (ior:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
376                 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
377   ""
378   "")
380 (define_insn ""
381   [(set (match_operand:SI 0 "register_operand" "=d,d")
382         (ior:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
383                 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
384   ""
385   "@
386    or\\t%0,%1,%2
387    ori\\t%0,%1,%x2"
388   [(set_attr "type"     "arith")
389    (set_attr "mode"     "SI")])
391 (define_expand "xorsi3"
392   [(set (match_operand:SI 0 "register_operand" "=d,d")
393         (xor:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
394                 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
395   ""
396   "")
398 (define_insn ""
399   [(set (match_operand:SI 0 "register_operand" "=d,d")
400         (xor:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
401                 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
402   ""
403   "@
404    xor\\t%0,%1,%2
405    xori\\t%0,%1,%x2"
406   [(set_attr "type"     "arith")
407    (set_attr "mode"     "SI")])
409 (define_insn "*norsi3"
410   [(set (match_operand:SI 0 "register_operand" "=d")
411         (and:SI (not:SI (match_operand:SI 1 "register_operand" "d"))
412                 (not:SI (match_operand:SI 2 "register_operand" "d"))))]
413   ""
414   "nor\\t%0,%z1,%z2"
415   [(set_attr "type"     "arith")
416    (set_attr "mode"     "SI")])
419 ;;  ....................
421 ;;      ZERO EXTENSION
423 ;;  ....................
425 ;; Extension insns.
426 ;; Those for integer source operand are ordered widest source type first.
428 (define_expand "zero_extendhisi2"
429   [(set (match_operand:SI 0 "register_operand" "")
430         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
431   ""
432   "")
434 (define_insn ""
435   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
436         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "d,R,m")))]
437   ""
438   "*
440   if (which_alternative == 0)
441     return \"andi\\t%0,%1,0xffff\";
442   else
443     return iq2000_move_1word (operands, insn, TRUE);
445   [(set_attr "type"     "arith,load,load")
446    (set_attr "mode"     "SI")
447    (set_attr "length"   "4,4,8")])
449 (define_expand "zero_extendqihi2"
450   [(set (match_operand:HI 0 "register_operand" "")
451         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
452   ""
453   "")
455 (define_insn ""
456   [(set (match_operand:HI 0 "register_operand" "=d,d,d")
457         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,R,m")))]
458   ""
459   "*
461   if (which_alternative == 0)
462     return \"andi\\t%0,%1,0x00ff\";
463   else
464     return iq2000_move_1word (operands, insn, TRUE);
466   [(set_attr "type"     "arith,load,load")
467    (set_attr "mode"     "HI")
468    (set_attr "length"   "4,4,8")])
470 (define_expand "zero_extendqisi2"
471   [(set (match_operand:SI 0 "register_operand" "")
472         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
473   ""
474   "")
476 (define_insn ""
477   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
478         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "d,R,m")))]
479   ""
480   "*
482   if (which_alternative == 0)
483     return \"andi\\t%0,%1,0x00ff\";
484   else
485     return iq2000_move_1word (operands, insn, TRUE);
487   [(set_attr "type"     "arith,load,load")
488    (set_attr "mode"     "SI")
489    (set_attr "length"   "4,4,8")])
492 ;;  ....................
494 ;;      SIGN EXTENSION
496 ;;  ....................
498 ;; Extension insns.
499 ;; Those for integer source operand are ordered widest source type first.
501 ;; These patterns originally accepted general_operands, however, slightly
502 ;; better code is generated by only accepting register_operands, and then
503 ;; letting combine generate the lh and lb insns.
505 (define_expand "extendhisi2"
506   [(set (match_operand:SI 0 "register_operand" "")
507         (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
508   ""
509   "
511   if (optimize && GET_CODE (operands[1]) == MEM)
512     operands[1] = force_not_mem (operands[1]);
514   if (GET_CODE (operands[1]) != MEM)
515     {
516       rtx op1   = gen_lowpart (SImode, operands[1]);
517       rtx temp  = gen_reg_rtx (SImode);
518       rtx shift = GEN_INT (16);
520       emit_insn (gen_ashlsi3 (temp, op1, shift));
521       emit_insn (gen_ashrsi3 (operands[0], temp, shift));
522       DONE;
523     }
526 (define_insn "extendhisi2_internal"
527   [(set (match_operand:SI 0 "register_operand" "=d,d")
528         (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,m")))]
529   ""
530   "* return iq2000_move_1word (operands, insn, FALSE);"
531   [(set_attr "type"     "load")
532    (set_attr "mode"     "SI")
533    (set_attr "length"   "4,8")])
535 (define_expand "extendqihi2"
536   [(set (match_operand:HI 0 "register_operand" "")
537         (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
538   ""
539   "
541   if (optimize && GET_CODE (operands[1]) == MEM)
542     operands[1] = force_not_mem (operands[1]);
544   if (GET_CODE (operands[1]) != MEM)
545     {
546       rtx op0   = gen_lowpart (SImode, operands[0]);
547       rtx op1   = gen_lowpart (SImode, operands[1]);
548       rtx temp  = gen_reg_rtx (SImode);
549       rtx shift = GEN_INT (24);
551       emit_insn (gen_ashlsi3 (temp, op1, shift));
552       emit_insn (gen_ashrsi3 (op0, temp, shift));
553       DONE;
554     }
557 (define_insn "extendqihi2_internal"
558   [(set (match_operand:HI 0 "register_operand" "=d,d")
559         (sign_extend:HI (match_operand:QI 1 "memory_operand" "R,m")))]
560   ""
561   "* return iq2000_move_1word (operands, insn, FALSE);"
562   [(set_attr "type"     "load")
563    (set_attr "mode"     "SI")
564    (set_attr "length"   "4,8")])
567 (define_expand "extendqisi2"
568   [(set (match_operand:SI 0 "register_operand" "")
569         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
570   ""
571   "
573   if (optimize && GET_CODE (operands[1]) == MEM)
574     operands[1] = force_not_mem (operands[1]);
576   if (GET_CODE (operands[1]) != MEM)
577     {
578       rtx op1   = gen_lowpart (SImode, operands[1]);
579       rtx temp  = gen_reg_rtx (SImode);
580       rtx shift = GEN_INT (24);
582       emit_insn (gen_ashlsi3 (temp, op1, shift));
583       emit_insn (gen_ashrsi3 (operands[0], temp, shift));
584       DONE;
585     }
588 (define_insn "extendqisi2_insn"
589   [(set (match_operand:SI 0 "register_operand" "=d,d")
590         (sign_extend:SI (match_operand:QI 1 "memory_operand" "R,m")))]
591   ""
592   "* return iq2000_move_1word (operands, insn, FALSE);"
593   [(set_attr "type"     "load")
594    (set_attr "mode"     "SI")
595    (set_attr "length"   "4,8")])
598 ;;  ........................
600 ;;      BIT FIELD EXTRACTION
602 ;;  ........................
604 (define_insn "extzv"
605   [(set (match_operand:SI 0 "register_operand" "=r")
606         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
607                          (match_operand:SI 2 "const_int_operand" "O")
608                          (match_operand:SI 3 "const_int_operand" "O")))]
609   ""
610   "*
612   int value[4];
613   value[2] = INTVAL (operands[2]);
614   value[3] = INTVAL (operands[3]);
615   operands[2] = GEN_INT ((value[3]));
616   operands[3] = GEN_INT ((32 - value[2]));
617   return \"ram\\t%0,%1,%2,%3,0x0\";  
619   [(set_attr "type" "arith")])
622 ;;  ....................
624 ;;      DATA MOVEMENT
626 ;;  ....................
628 /* Take care of constants that don't fit in single instruction */
629 (define_split
630   [(set (match_operand:SI 0 "register_operand" "")
631         (match_operand:SI 1 "general_operand" ""))]
632   "(reload_in_progress || reload_completed)
633    && large_int (operands[1], SImode)"
635   [(set (match_dup 0 )
636         (high:SI (match_dup 1)))
637    (set (match_dup 0 )
638         (lo_sum:SI (match_dup 0)
639                    (match_dup 1)))]
642 ;; ??? iq2000_move_1word has support for HIGH, so this pattern may be
643 ;; unnecessary.
645 (define_insn "high"
646   [(set (match_operand:SI 0 "register_operand" "=r")
647         (high:SI (match_operand:SI 1 "immediate_operand" "")))]
648   ""
649   "lui\\t%0,%%hi(%1) # high"
650   [(set_attr "type"     "move")])
652 (define_insn "low"
653   [(set (match_operand:SI 0 "register_operand" "=r")
654         (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
655                    (match_operand:SI 2 "immediate_operand" "")))]
656   ""
657   "addiu\\t%0,%1,%%lo(%2) # low"
658   [(set_attr "type"     "arith")
659    (set_attr "mode"     "SI")])
661 ;; 32-bit Integer moves
663 (define_split
664   [(set (match_operand:SI 0 "register_operand" "")
665         (match_operand:SI 1 "large_int" ""))]
666   "reload_in_progress | reload_completed"
667   [(set (match_dup 0)
668         (match_dup 2))
669    (set (match_dup 0)
670         (ior:SI (match_dup 0)
671                 (match_dup 3)))]
672   "
674   operands[2] = GEN_INT (trunc_int_for_mode (INTVAL (operands[1])
675                                              & BITMASK_UPPER16,
676                                              SImode));
677   operands[3] = GEN_INT (INTVAL (operands[1]) & BITMASK_LOWER16);
680 ;; Unlike most other insns, the move insns can't be split with
681 ;; different predicates, because register spilling and other parts of
682 ;; the compiler, have memoized the insn number already.
684 (define_expand "movsi"
685   [(set (match_operand:SI 0 "nonimmediate_operand" "")
686         (match_operand:SI 1 "general_operand" ""))]
687   ""
688   "
690   if (iq2000_check_split (operands[1], SImode))
691     {
692       enum machine_mode mode = GET_MODE (operands[0]);
693       rtx tem = ((reload_in_progress | reload_completed)
694                  ? operands[0] : gen_reg_rtx (mode));
696       emit_insn (gen_rtx_SET (VOIDmode, tem,
697                               gen_rtx_HIGH (mode, operands[1])));
699       operands[1] = gen_rtx_LO_SUM (mode, tem, operands[1]);
700     }
702   if ((reload_in_progress | reload_completed) == 0
703       && !register_operand (operands[0], SImode)
704       && !register_operand (operands[1], SImode)
705       && (GET_CODE (operands[1]) != CONST_INT
706           || INTVAL (operands[1]) != 0))
707     {
708       rtx temp = force_reg (SImode, operands[1]);
709       emit_move_insn (operands[0], temp);
710       DONE;
711     }
713   /* Take care of constants that don't fit in single instruction */
714   if ((reload_in_progress || reload_completed)
715       && CONSTANT_P (operands[1])
716       && GET_CODE (operands[1]) != HIGH
717       && GET_CODE (operands[1]) != LO_SUM
718       && ! SMALL_INT_UNSIGNED (operands[1]))
719     {
720       rtx tem = ((reload_in_progress | reload_completed)
721                  ? operands[0] : gen_reg_rtx (SImode));
723       emit_insn (gen_rtx_SET (VOIDmode, tem,
724                               gen_rtx_HIGH (SImode, operands[1])));
725       operands[1] = gen_rtx_LO_SUM (SImode, tem, operands[1]);
726     }
729 ;; The difference between these two is whether or not ints are allowed
730 ;; in FP registers (off by default, use -mdebugh to enable).
732 (define_insn "movsi_internal2"
733   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,R,m,*d,*z,*x,*d,*x,*d")
734         (match_operand:SI 1 "move_operand" "d,S,IKL,Mnis,R,m,dJ,dJ,*z,*d,J,*x,*d,*a"))]
735   "(register_operand (operands[0], SImode)
736        || register_operand (operands[1], SImode)
737        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
738   "* return iq2000_move_1word (operands, insn, FALSE);"
739   [(set_attr "type"     "move,load,arith,arith,load,load,store,store,xfer,xfer,move,move,move,move")
740    (set_attr "mode"     "SI")
741    (set_attr "length"   "4,8,4,8,4,8,4,8,4,4,4,4,4,4")])
743 ;; 16-bit Integer moves
745 ;; Unlike most other insns, the move insns can't be split with
746 ;; different predicates, because register spilling and other parts of
747 ;; the compiler, have memoized the insn number already.
748 ;; Unsigned loads are used because BYTE_LOADS_ZERO_EXTEND is defined
750 (define_expand "movhi"
751   [(set (match_operand:HI 0 "nonimmediate_operand" "")
752         (match_operand:HI 1 "general_operand" ""))]
753   ""
754   "
756   if ((reload_in_progress | reload_completed) == 0
757       && !register_operand (operands[0], HImode)
758       && !register_operand (operands[1], HImode)
759       && ((GET_CODE (operands[1]) != CONST_INT
760           || INTVAL (operands[1]) != 0)))
761     {
762       rtx temp = force_reg (HImode, operands[1]);
763       emit_move_insn (operands[0], temp);
764       DONE;
765     }
768 ;; The difference between these two is whether or not ints are allowed
769 ;; in FP registers (off by default, use -mdebugh to enable).
771 (define_insn "movhi_internal2"
772   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,R,m,*d,*z,*x,*d")
773         (match_operand:HI 1 "general_operand"       "d,IK,R,m,dJ,dJ,*z,*d,*d,*x"))]
774   "(register_operand (operands[0], HImode)
775        || register_operand (operands[1], HImode)
776        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
777   "* return iq2000_move_1word (operands, insn, TRUE);"
778   [(set_attr "type"     "move,arith,load,load,store,store,xfer,xfer,move,move")
779    (set_attr "mode"     "HI")
780    (set_attr "length"   "4,4,4,8,4,8,4,4,4,4")])
782 ;; 8-bit Integer moves
784 ;; Unlike most other insns, the move insns can't be split with
785 ;; different predicates, because register spilling and other parts of
786 ;; the compiler, have memoized the insn number already.
787 ;; Unsigned loads are used because BYTE_LOADS_ZERO_EXTEND is defined
789 (define_expand "movqi"
790   [(set (match_operand:QI 0 "nonimmediate_operand" "")
791         (match_operand:QI 1 "general_operand" ""))]
792   ""
793   "
795   if ((reload_in_progress | reload_completed) == 0
796       && !register_operand (operands[0], QImode)
797       && !register_operand (operands[1], QImode)
798       && (GET_CODE (operands[1]) != CONST_INT
799           || INTVAL (operands[1]) != 0))
800     {
801       rtx temp = force_reg (QImode, operands[1]);
802       emit_move_insn (operands[0], temp);
803       DONE;
804     }
807 ;; The difference between these two is whether or not ints are allowed
808 ;; in FP registers (off by default, use -mdebugh to enable).
810 (define_insn "movqi_internal2"
811   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,m,*d,*z,*x,*d")
812         (match_operand:QI 1 "general_operand"       "d,IK,R,m,dJ,dJ,*z,*d,*d,*x"))]
813   "(register_operand (operands[0], QImode)
814        || register_operand (operands[1], QImode)
815        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
816   "* return iq2000_move_1word (operands, insn, TRUE);"
817   [(set_attr "type"     "move,arith,load,load,store,store,xfer,xfer,move,move")
818    (set_attr "mode"     "QI")
819    (set_attr "length"   "4,4,4,8,4,8,4,4,4,4")])
821 ;; 32-bit floating point moves
823 (define_expand "movsf"
824   [(set (match_operand:SF 0 "general_operand" "")
825         (match_operand:SF 1 "general_operand" ""))]
826   ""
827   "
829   if (!reload_in_progress
830       && !reload_completed
831       && GET_CODE (operands[0]) == MEM
832       && (GET_CODE (operands[1]) == MEM
833          || GET_CODE (operands[1]) == CONST_DOUBLE))
834     operands[1] = copy_to_mode_reg (SFmode, operands[1]);
836   /* Take care of reg <- SF constant */
837   if ( const_double_operand (operands[1], GET_MODE (operands[1]) ) )
838     {
839       emit_insn (gen_movsf_high (operands[0], operands[1]));
840       emit_insn (gen_movsf_lo_sum (operands[0], operands[0], operands[1]));
841       DONE;
842     }
845 (define_insn "movsf_lo_sum"
846   [(set (match_operand:SF 0 "register_operand" "=r")
847         (lo_sum:SF (match_operand:SF 1 "register_operand" "r")
848                    (match_operand:SF 2 "const_double_operand" "")))]
849   ""
850   "*
852   REAL_VALUE_TYPE r;
853   long i;
855   REAL_VALUE_FROM_CONST_DOUBLE (r, operands[2]);
856   REAL_VALUE_TO_TARGET_SINGLE (r, i);
857   operands[2] = GEN_INT (i);
858   return \"addiu\\t%0,%1,%%lo(%2) # low\";
860   [(set_attr "length" "4")
861    (set_attr "type" "arith")])
863 (define_insn "movsf_high"
864   [(set (match_operand:SF 0 "register_operand" "=r")
865         (high:SF (match_operand:SF 1 "const_double_operand" "")))]
866   ""
867   "*
869   REAL_VALUE_TYPE r;
870   long i;
872   REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
873   REAL_VALUE_TO_TARGET_SINGLE (r, i);
874   operands[1] = GEN_INT (i);
875   return \"lui\\t%0,%%hi(%1) # high\";
877   [(set_attr "length" "4")
878    (set_attr "type" "arith")])
880 (define_insn "*movsf_internal"
881   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m")
882         (match_operand:SF 1 "nonimmediate_operand" "r,m,r"))]
883   "!memory_operand (operands[0], SFmode) || !memory_operand (operands[1], SFmode)"
884   "*
886   iq2000_fill_delay_slot (\"\", DELAY_LOAD, operands, insn);  
887   if (which_alternative == 0)
888     return \"or\\t%0,%1,%1\";
889   else if (which_alternative == 1)
890     return \"lw\\t%0,%1\";
891   else if (which_alternative == 2)
892     return \"sw\\t%1,%0\";
894   [(set_attr "length" "4,4,4")
895    (set_attr "type" "arith,load,store")]
899 ;;  ....................
901 ;;      SHIFTS
903 ;;  ....................
905 (define_expand "ashlsi3"
906   [(set (match_operand:SI 0 "register_operand" "=d")
907         (ashift:SI (match_operand:SI 1 "register_operand" "d")
908                    (match_operand:SI 2 "arith_operand" "dI")))]
909   ""
910   "")
912 (define_insn "ashlsi3_internal1"
913   [(set (match_operand:SI 0 "register_operand" "=d")
914         (ashift:SI (match_operand:SI 1 "register_operand" "d")
915                    (match_operand:SI 2 "arith_operand" "dI")))]
916   ""
917   "*
919   if (GET_CODE (operands[2]) == CONST_INT)
920     {
921       operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
922       return \"sll\\t%0,%1,%2\";
923     }
924   else
925     return \"sllv\\t%0,%1,%2\";
927   [(set_attr "type"     "arith")
928    (set_attr "mode"     "SI")])
930 (define_expand "ashrsi3"
931   [(set (match_operand:SI 0 "register_operand" "=d")
932         (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
933                      (match_operand:SI 2 "arith_operand" "dI")))]
934   ""
935   "")
937 (define_insn "ashrsi3_internal1"
938   [(set (match_operand:SI 0 "register_operand" "=d")
939         (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
940                      (match_operand:SI 2 "arith_operand" "dI")))]
941   ""
942   "*
944   if (GET_CODE (operands[2]) == CONST_INT)
945     {
946       operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
947       return \"sra\\t%0,%1,%2\";
948     }
949   else
950     return \"srav\\t%0,%1,%2\";
952   [(set_attr "type"     "arith")
953    (set_attr "mode"     "SI")])
955 (define_expand "lshrsi3"
956   [(set (match_operand:SI 0 "register_operand" "=d")
957         (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
958                      (match_operand:SI 2 "arith_operand" "dI")))]
959   ""
960   "")
962 (define_insn "lshrsi3_internal1"
963   [(set (match_operand:SI 0 "register_operand" "=d")
964         (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
965                      (match_operand:SI 2 "arith_operand" "dI")))]
966   ""
967   "*
969   if (GET_CODE (operands[2]) == CONST_INT)
970     {
971       operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
972       return \"srl\\t%0,%1,%2\";
973     }
974   else
975     return \"srlv\\t%0,%1,%2\";
977   [(set_attr "type"     "arith")
978    (set_attr "mode"     "SI")])
980 ;; Rotate Right
981 (define_insn "rotrsi3"
982   [(set (match_operand:SI 0 "register_operand" "=r")
983         (rotatert:SI (match_operand:SI 1 "register_operand" "r")
984                      (match_operand:SI 2 "uns_arith_operand" "O")))]
985   ""
986   "ram %0,%1,%2,0x0,0x0"
987   [(set_attr "type" "arith")])
991 ;;  ....................
993 ;;      COMPARISONS
995 ;;  ....................
997 ;; Flow here is rather complex:
999 ;;  1)  The cmp{si,di,sf,df} routine is called.  It deposits the
1000 ;;      arguments into the branch_cmp array, and the type into
1001 ;;      branch_type.  No RTL is generated.
1003 ;;  2)  The appropriate branch define_expand is called, which then
1004 ;;      creates the appropriate RTL for the comparison and branch.
1005 ;;      Different CC modes are used, based on what type of branch is
1006 ;;      done, so that we can constrain things appropriately.  There
1007 ;;      are assumptions in the rest of GCC that break if we fold the
1008 ;;      operands into the branches for integer operations, and use cc0
1009 ;;      for floating point, so we use the fp status register instead.
1010 ;;      If needed, an appropriate temporary is created to hold the
1011 ;;      of the integer compare.
1013 (define_expand "cmpsi"
1014   [(set (cc0)
1015         (compare:CC (match_operand:SI 0 "register_operand" "")
1016                     (match_operand:SI 1 "arith_operand" "")))]
1017   ""
1018   "
1020   if (operands[0])              /* avoid unused code message */
1021     {
1022       branch_cmp[0] = operands[0];
1023       branch_cmp[1] = operands[1];
1024       branch_type = CMP_SI;
1025       DONE;
1026     }
1029 (define_expand "tstsi"
1030   [(set (cc0)
1031         (match_operand:SI 0 "register_operand" ""))]
1032   ""
1033   "
1035   if (operands[0])              /* avoid unused code message */
1036     {
1037       branch_cmp[0] = operands[0];
1038       branch_cmp[1] = const0_rtx;
1039       branch_type = CMP_SI;
1040       DONE;
1041     }
1045 ;;  ....................
1047 ;;      CONDITIONAL BRANCHES
1049 ;;  ....................
1051 ;; Conditional branches on comparisons with zero.
1053 (define_insn "branch_zero"
1054   [(set (pc)
1055         (if_then_else
1056          (match_operator:SI 0 "cmp_op"
1057                             [(match_operand:SI 2 "register_operand" "d")
1058                              (const_int 0)])
1059         (label_ref (match_operand 1 "" ""))
1060         (pc)))]
1061   ""
1062   "*
1064   return iq2000_output_conditional_branch (insn,
1065                                          operands,
1066                                          /*two_operands_p=*/0,
1067                                          /*float_p=*/0,
1068                                          /*inverted_p=*/0,
1069                                          get_attr_length (insn));
1071   [(set_attr "type"     "branch")
1072    (set_attr "mode"     "none")])
1074 (define_insn "branch_zero_inverted"
1075   [(set (pc)
1076         (if_then_else
1077          (match_operator:SI 0 "cmp_op"
1078                             [(match_operand:SI 2 "register_operand" "d")
1079                              (const_int 0)])
1080         (pc)
1081         (label_ref (match_operand 1 "" ""))))]
1082   ""
1083   "*
1085   return iq2000_output_conditional_branch (insn,
1086                                          operands,
1087                                          /*two_operands_p=*/0,
1088                                          /*float_p=*/0,
1089                                          /*inverted_p=*/1,
1090                                          get_attr_length (insn));
1092   [(set_attr "type"     "branch")
1093    (set_attr "mode"     "none")])
1095 ;; Conditional branch on equality comparison.
1097 (define_insn "branch_equality"
1098   [(set (pc)
1099         (if_then_else
1100          (match_operator:SI 0 "equality_op"
1101                             [(match_operand:SI 2 "register_operand" "d")
1102                              (match_operand:SI 3 "register_operand" "d")])
1103          (label_ref (match_operand 1 "" ""))
1104          (pc)))]
1105   ""
1106   "*
1108   return iq2000_output_conditional_branch (insn,
1109                                          operands,
1110                                          /*two_operands_p=*/1,
1111                                          /*float_p=*/0,
1112                                          /*inverted_p=*/0,
1113                                          get_attr_length (insn));
1115   [(set_attr "type"     "branch")
1116    (set_attr "mode"     "none")])
1118 (define_insn "branch_equality_inverted"
1119   [(set (pc)
1120         (if_then_else
1121          (match_operator:SI 0 "equality_op"
1122                             [(match_operand:SI 2 "register_operand" "d")
1123                              (match_operand:SI 3 "register_operand" "d")])
1124          (pc)
1125          (label_ref (match_operand 1 "" ""))))]
1126   ""
1127   "*
1129   return iq2000_output_conditional_branch (insn,
1130                                          operands,
1131                                          /*two_operands_p=*/1,
1132                                          /*float_p=*/0,
1133                                          /*inverted_p=*/1,
1134                                          get_attr_length (insn));
1136   [(set_attr "type"     "branch")
1137    (set_attr "mode"     "none")])
1139 (define_expand "beq"
1140   [(set (pc)
1141         (if_then_else (eq:CC (cc0)
1142                              (const_int 0))
1143                       (label_ref (match_operand 0 "" ""))
1144                       (pc)))]
1145   ""
1146   "
1148   if (operands[0])              /* avoid unused code warning */
1149     {
1150       gen_conditional_branch (operands, EQ);
1151       DONE;
1152     }
1155 (define_expand "bne"
1156   [(set (pc)
1157         (if_then_else (ne:CC (cc0)
1158                              (const_int 0))
1159                       (label_ref (match_operand 0 "" ""))
1160                       (pc)))]
1161   ""
1162   "
1164   if (operands[0])              /* avoid unused code warning */
1165     {
1166       gen_conditional_branch (operands, NE);
1167       DONE;
1168     }
1171 (define_expand "bgt"
1172   [(set (pc)
1173         (if_then_else (gt:CC (cc0)
1174                              (const_int 0))
1175                       (label_ref (match_operand 0 "" ""))
1176                       (pc)))]
1177   ""
1178   "
1180   if (operands[0])              /* avoid unused code warning */
1181     {
1182       gen_conditional_branch (operands, GT);
1183       DONE;
1184     }
1187 (define_expand "bge"
1188   [(set (pc)
1189         (if_then_else (ge:CC (cc0)
1190                              (const_int 0))
1191                       (label_ref (match_operand 0 "" ""))
1192                       (pc)))]
1193   ""
1194   "
1196   if (operands[0])              /* avoid unused code warning */
1197     {
1198       gen_conditional_branch (operands, GE);
1199       DONE;
1200     }
1203 (define_expand "blt"
1204   [(set (pc)
1205         (if_then_else (lt:CC (cc0)
1206                              (const_int 0))
1207                       (label_ref (match_operand 0 "" ""))
1208                       (pc)))]
1209   ""
1210   "
1212   if (operands[0])              /* avoid unused code warning */
1213     {
1214       gen_conditional_branch (operands, LT);
1215       DONE;
1216     }
1219 (define_expand "ble"
1220   [(set (pc)
1221         (if_then_else (le:CC (cc0)
1222                              (const_int 0))
1223                       (label_ref (match_operand 0 "" ""))
1224                       (pc)))]
1225   ""
1226   "
1228   if (operands[0])              /* avoid unused code warning */
1229     {
1230       gen_conditional_branch (operands, LE);
1231       DONE;
1232     }
1235 (define_expand "bgtu"
1236   [(set (pc)
1237         (if_then_else (gtu:CC (cc0)
1238                               (const_int 0))
1239                       (label_ref (match_operand 0 "" ""))
1240                       (pc)))]
1241   ""
1242   "
1244   if (operands[0])              /* avoid unused code warning */
1245     {
1246       gen_conditional_branch (operands, GTU);
1247       DONE;
1248     }
1251 (define_expand "bgeu"
1252   [(set (pc)
1253         (if_then_else (geu:CC (cc0)
1254                               (const_int 0))
1255                       (label_ref (match_operand 0 "" ""))
1256                       (pc)))]
1257   ""
1258   "
1260   if (operands[0])              /* avoid unused code warning */
1261     {
1262       gen_conditional_branch (operands, GEU);
1263       DONE;
1264     }
1268 (define_expand "bltu"
1269   [(set (pc)
1270         (if_then_else (ltu:CC (cc0)
1271                               (const_int 0))
1272                       (label_ref (match_operand 0 "" ""))
1273                       (pc)))]
1274   ""
1275   "
1277   if (operands[0])              /* avoid unused code warning */
1278     {
1279       gen_conditional_branch (operands, LTU);
1280       DONE;
1281     }
1284 (define_expand "bleu"
1285   [(set (pc)
1286         (if_then_else (leu:CC (cc0)
1287                               (const_int 0))
1288                       (label_ref (match_operand 0 "" ""))
1289                       (pc)))]
1290   ""
1291   "
1293   if (operands[0])              /* avoid unused code warning */
1294     {
1295       gen_conditional_branch (operands, LEU);
1296       DONE;
1297     }
1300 ;; Recognize bbi and bbin instructions.  These use two unusual template
1301 ;; patterns, %Ax and %Px.  %Ax outputs an 'i' if operand `x' is a LABEL_REF
1302 ;; otherwise it outputs an 'in'.  %Px does nothing if `x' is PC 
1303 ;; and outputs the operand if `x' is a LABEL_REF.
1305 (define_insn ""
1306   [(set (pc)
1307         (if_then_else
1308          (ne (sign_extract:SI (match_operand:SI 0 "register_operand" "r")
1309                               (const_int 1)
1310                               (match_operand:SI 1 "arith_operand" "I"))
1311              (const_int 0))
1312          (match_operand 2 "pc_or_label_operand" "")
1313          (match_operand 3 "pc_or_label_operand" "")))]
1314   ""
1315   "bb%A2\\t%0(31-%1),%P2%P3"
1316   [(set_attr "length" "4")
1317    (set_attr "type" "branch")])
1319 (define_insn ""
1320   [(set (pc)
1321         (if_then_else
1322          (eq (sign_extract:SI (match_operand:SI 0 "register_operand" "r")
1323                               (const_int 1)
1324                               (match_operand:SI 1 "arith_operand" "I"))
1325              (const_int 0))
1326          (match_operand 2 "pc_or_label_operand" "")
1327          (match_operand 3 "pc_or_label_operand" "")))]
1328   ""
1329   "bb%A3\\t%0(31-%1),%P2%P3"
1330   [(set_attr "length" "4")
1331    (set_attr "type" "branch")])
1333 (define_insn ""
1334   [(set (pc)
1335         (if_then_else
1336          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1337                               (const_int 1)
1338                               (match_operand:SI 1 "arith_operand" "I"))
1339              (const_int 0))
1340          (match_operand 2 "pc_or_label_operand" "")
1341          (match_operand 3 "pc_or_label_operand" "")))]
1342   ""
1343   "bb%A2\\t%0(31-%1),%P2%P3"
1344   [(set_attr "length" "4")
1345    (set_attr "type" "branch")])
1347 (define_insn ""
1348   [(set (pc)
1349         (if_then_else
1350          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1351                               (const_int 1)
1352                               (match_operand:SI 1 "arith_operand" "I"))
1353              (const_int 0))
1354          (match_operand 2 "pc_or_label_operand" "")
1355          (match_operand 3 "pc_or_label_operand" "")))]
1356   ""
1357   "bb%A3\\t%0(31-%1),%P2%P3"
1358   [(set_attr "length" "4")
1359    (set_attr "type" "branch")])
1361 (define_insn ""
1362   [(set (pc)
1363         (if_then_else
1364          (eq (and:SI (match_operand:SI 0 "register_operand" "r")
1365                      (match_operand:SI 1 "power_of_2_operand" "I"))
1366               (const_int 0))
1367          (match_operand 2 "pc_or_label_operand" "")
1368          (match_operand 3 "pc_or_label_operand" "")))]
1369   ""
1370   "bb%A3\\t%0(%p1),%P2%P3"
1371   [(set_attr "length" "4")
1372    (set_attr "type" "branch")])
1374 (define_insn ""
1375   [(set (pc)
1376         (if_then_else
1377          (ne (and:SI (match_operand:SI 0 "register_operand" "r")
1378                      (match_operand:SI 1 "power_of_2_operand" "I"))
1379              (const_int 0))
1380          (match_operand 2 "pc_or_label_operand" "")
1381          (match_operand 3 "pc_or_label_operand" "")))]
1382   ""
1383   "bb%A2\\t%0(%p1),%P2%P3"
1384   [(set_attr "length" "4")
1385    (set_attr "type" "branch")])
1388 ;;  ....................
1390 ;;      SETTING A REGISTER FROM A COMPARISON
1392 ;;  ....................
1394 (define_expand "seq"
1395   [(set (match_operand:SI 0 "register_operand" "=d")
1396         (eq:SI (match_dup 1)
1397                (match_dup 2)))]
1398   ""
1399   "
1401   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1402     FAIL;
1404   /* Set up operands from compare.  */
1405   operands[1] = branch_cmp[0];
1406   operands[2] = branch_cmp[1];
1408   gen_int_relational (EQ, operands[0], operands[1], operands[2], (int *)0);
1409   DONE;
1413 (define_insn "seq_si_zero"
1414   [(set (match_operand:SI 0 "register_operand" "=d")
1415         (eq:SI (match_operand:SI 1 "register_operand" "d")
1416                (const_int 0)))]
1417   ""
1418   "sltiu\\t%0,%1,1"
1419   [(set_attr "type"     "arith")
1420    (set_attr "mode"     "SI")])
1422 (define_expand "sne"
1423   [(set (match_operand:SI 0 "register_operand" "=d")
1424         (ne:SI (match_dup 1)
1425                (match_dup 2)))]
1426   ""
1427   "
1429   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1430     FAIL;
1432   /* Set up operands from compare.  */
1433   operands[1] = branch_cmp[0];
1434   operands[2] = branch_cmp[1];
1436   gen_int_relational (NE, operands[0], operands[1], operands[2], (int *)0);
1437   DONE;
1440 (define_insn "sne_si_zero"
1441   [(set (match_operand:SI 0 "register_operand" "=d")
1442         (ne:SI (match_operand:SI 1 "register_operand" "d")
1443                (const_int 0)))]
1444   ""
1445   "sltu\\t%0,%.,%1"
1446   [(set_attr "type"     "arith")
1447    (set_attr "mode"     "SI")])
1449 (define_expand "sgt"
1450   [(set (match_operand:SI 0 "register_operand" "=d")
1451         (gt:SI (match_dup 1)
1452                (match_dup 2)))]
1453   ""
1454   "
1456   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1457     FAIL;
1459   /* Set up operands from compare.  */
1460   operands[1] = branch_cmp[0];
1461   operands[2] = branch_cmp[1];
1463   gen_int_relational (GT, operands[0], operands[1], operands[2], (int *)0);
1464   DONE;
1467 (define_insn "sgt_si"
1468   [(set (match_operand:SI 0 "register_operand" "=d,=d")
1469         (gt:SI (match_operand:SI 1 "register_operand" "d,d")
1470                (match_operand:SI 2 "reg_or_0_operand" "d,J")))]
1471   ""
1472   "@
1473    slt\\t%0,%z2,%1
1474    slt\\t%0,%z2,%1"
1475   [(set_attr "type"     "arith,arith")
1476    (set_attr "mode"     "SI,SI")])
1478 (define_expand "sge"
1479   [(set (match_operand:SI 0 "register_operand" "=d")
1480         (ge:SI (match_dup 1)
1481                (match_dup 2)))]
1482   ""
1483   "
1485   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1486     FAIL;
1488   /* Set up operands from compare.  */
1489   operands[1] = branch_cmp[0];
1490   operands[2] = branch_cmp[1];
1492   gen_int_relational (GE, operands[0], operands[1], operands[2], (int *)0);
1493   DONE;
1496 (define_expand "slt"
1497   [(set (match_operand:SI 0 "register_operand" "=d")
1498         (lt:SI (match_dup 1)
1499                (match_dup 2)))]
1500   ""
1501   "
1503   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1504     FAIL;
1506   /* Set up operands from compare.  */
1507   operands[1] = branch_cmp[0];
1508   operands[2] = branch_cmp[1];
1510   gen_int_relational (LT, operands[0], operands[1], operands[2], (int *)0);
1511   DONE;
1514 (define_insn "slt_si"
1515   [(set (match_operand:SI 0 "register_operand" "=d,=d")
1516         (lt:SI (match_operand:SI 1 "register_operand" "d,d")
1517                (match_operand:SI 2 "arith_operand" "d,I")))]
1518   ""
1519   "@
1520    slt\\t%0,%1,%2
1521    slti\\t%0,%1,%2"
1522   [(set_attr "type"     "arith,arith")
1523    (set_attr "mode"     "SI,SI")])
1525 (define_expand "sle"
1526   [(set (match_operand:SI 0 "register_operand" "=d")
1527         (le:SI (match_dup 1)
1528                (match_dup 2)))]
1529   ""
1530   "
1532   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1533     FAIL;
1535   /* Set up operands from compare.  */
1536   operands[1] = branch_cmp[0];
1537   operands[2] = branch_cmp[1];
1539   gen_int_relational (LE, operands[0], operands[1], operands[2], (int *)0);
1540   DONE;
1543 (define_insn "sle_si_const"
1544   [(set (match_operand:SI 0 "register_operand" "=d")
1545         (le:SI (match_operand:SI 1 "register_operand" "d")
1546                (match_operand:SI 2 "small_int" "I")))]
1547   "INTVAL (operands[2]) < 32767"
1548   "*
1550   operands[2] = GEN_INT (INTVAL (operands[2])+1);
1551   return \"slti\\t%0,%1,%2\";
1553   [(set_attr "type"     "arith")
1554    (set_attr "mode"     "SI")])
1556 (define_expand "sgtu"
1557   [(set (match_operand:SI 0 "register_operand" "=d")
1558         (gtu:SI (match_dup 1)
1559                 (match_dup 2)))]
1560   ""
1561   "
1563   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1564     FAIL;
1566   /* Set up operands from compare.  */
1567   operands[1] = branch_cmp[0];
1568   operands[2] = branch_cmp[1];
1570   gen_int_relational (GTU, operands[0], operands[1], operands[2], (int *)0);
1571   DONE;
1574 (define_insn "sgtu_si"
1575   [(set (match_operand:SI 0 "register_operand" "=d")
1576         (gtu:SI (match_operand:SI 1 "register_operand" "d")
1577                 (match_operand:SI 2 "reg_or_0_operand" "dJ")))]
1578   ""
1579   "sltu\\t%0,%z2,%1"
1580   [(set_attr "type"     "arith")
1581    (set_attr "mode"     "SI")])
1583 (define_insn ""
1584   [(set (match_operand:SI 0 "register_operand" "=t")
1585         (gtu:SI (match_operand:SI 1 "register_operand" "d")
1586                 (match_operand:SI 2 "register_operand" "d")))]
1587   ""
1588   "sltu\\t%2,%1"
1589   [(set_attr "type"     "arith")
1590    (set_attr "mode"     "SI")])
1592 (define_expand "sgeu"
1593   [(set (match_operand:SI 0 "register_operand" "=d")
1594         (geu:SI (match_dup 1)
1595                 (match_dup 2)))]
1596   ""
1597   "
1599   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1600     FAIL;
1602   /* Set up operands from compare.  */
1603   operands[1] = branch_cmp[0];
1604   operands[2] = branch_cmp[1];
1606   gen_int_relational (GEU, operands[0], operands[1], operands[2], (int *)0);
1607   DONE;
1610 (define_expand "sltu"
1611   [(set (match_operand:SI 0 "register_operand" "=d")
1612         (ltu:SI (match_dup 1)
1613                 (match_dup 2)))]
1614   ""
1615   "
1617   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1618     FAIL;
1620   /* Set up operands from compare.  */
1621   operands[1] = branch_cmp[0];
1622   operands[2] = branch_cmp[1];
1624   gen_int_relational (LTU, operands[0], operands[1], operands[2], (int *)0);
1625   DONE;
1628 (define_insn "sltu_si"
1629   [(set (match_operand:SI 0 "register_operand" "=d,=d")
1630         (ltu:SI (match_operand:SI 1 "register_operand" "d,d")
1631                 (match_operand:SI 2 "arith_operand" "d,I")))]
1632   ""
1633   "@
1634    sltu\\t%0,%1,%2
1635    sltiu\\t%0,%1,%2"
1636   [(set_attr "type"     "arith,arith")
1637    (set_attr "mode"     "SI,SI")])
1639 (define_expand "sleu"
1640   [(set (match_operand:SI 0 "register_operand" "=d")
1641         (leu:SI (match_dup 1)
1642                 (match_dup 2)))]
1643   ""
1644   "
1646   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1647     FAIL;
1649   /* Set up operands from compare.  */
1650   operands[1] = branch_cmp[0];
1651   operands[2] = branch_cmp[1];
1653   gen_int_relational (LEU, operands[0], operands[1], operands[2], (int *)0);
1654   DONE;
1657 (define_insn "sleu_si_const"
1658   [(set (match_operand:SI 0 "register_operand" "=d")
1659         (leu:SI (match_operand:SI 1 "register_operand" "d")
1660                 (match_operand:SI 2 "small_int" "I")))]
1661   "INTVAL (operands[2]) < 32767"
1662   "*
1664   operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
1665   return \"sltiu\\t%0,%1,%2\";
1667   [(set_attr "type"     "arith")
1668    (set_attr "mode"     "SI")])
1672 ;;  ....................
1674 ;;      UNCONDITIONAL BRANCHES
1676 ;;  ....................
1678 ;; Unconditional branches.
1680 (define_insn "jump"
1681   [(set (pc)
1682         (label_ref (match_operand 0 "" "")))]
1683   ""
1684   "*
1686   if (GET_CODE (operands[0]) == REG)
1687     return \"j\\t%0\";
1688   return \"j\\t%l0\";
1689   /* return \"b\\t%l0\";*/
1691   [(set_attr "type"     "jump")
1692    (set_attr "mode"     "none")])
1694 (define_expand "indirect_jump"
1695   [(set (pc) (match_operand 0 "register_operand" "d"))]
1696   ""
1697   "
1699   rtx dest;
1701   if (operands[0])              /* eliminate unused code warnings */
1702     {
1703       dest = operands[0];
1704       if (GET_CODE (dest) != REG || GET_MODE (dest) != Pmode)
1705         operands[0] = copy_to_mode_reg (Pmode, dest);
1707       if (!(Pmode == DImode))
1708         emit_jump_insn (gen_indirect_jump_internal1 (operands[0]));
1709       else
1710         emit_jump_insn (gen_indirect_jump_internal2 (operands[0]));
1712       DONE;
1713     }
1716 (define_insn "indirect_jump_internal1"
1717   [(set (pc) (match_operand:SI 0 "register_operand" "d"))]
1718   "!(Pmode == DImode)"
1719   "j\\t%0"
1720   [(set_attr "type"     "jump")
1721    (set_attr "mode"     "none")])
1723 (define_expand "tablejump"
1724   [(set (pc)
1725         (match_operand 0 "register_operand" "d"))
1726    (use (label_ref (match_operand 1 "" "")))]
1727   ""
1728   "
1730   if (operands[0])              /* eliminate unused code warnings */
1731     {
1732       gcc_assert (GET_MODE (operands[0]) == Pmode);
1734       if (!(Pmode == DImode))
1735         emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
1736       else
1737         emit_jump_insn (gen_tablejump_internal2 (operands[0], operands[1]));
1739       DONE;
1740     }
1743 (define_insn "tablejump_internal1"
1744   [(set (pc)
1745         (match_operand:SI 0 "register_operand" "d"))
1746    (use (label_ref (match_operand 1 "" "")))]
1747   "!(Pmode == DImode)"
1748   "j\\t%0"
1749   [(set_attr "type"     "jump")
1750    (set_attr "mode"     "none")])
1752 (define_expand "tablejump_internal3"
1753   [(parallel [(set (pc)
1754                    (plus:SI (match_operand:SI 0 "register_operand" "d")
1755                             (label_ref:SI (match_operand 1 "" ""))))
1756               (use (label_ref:SI (match_dup 1)))])]
1757   ""
1758   "")
1760 ;;; Make sure that this only matches the insn before ADDR_DIFF_VEC.  Otherwise
1761 ;;; it is not valid.  ??? With the USE, the condition tests may not be required
1762 ;;; any longer.
1764 ;;; ??? The length depends on the ABI.  It is two for o32, and one for n32.
1765 ;;; We just use the conservative number here.
1767 (define_insn ""
1768   [(set (pc)
1769         (plus:SI (match_operand:SI 0 "register_operand" "d")
1770                  (label_ref:SI (match_operand 1 "" ""))))
1771    (use (label_ref:SI (match_dup 1)))]
1772   "!(Pmode == DImode) && next_active_insn (insn) != 0
1773    && GET_CODE (PATTERN (next_active_insn (insn))) == ADDR_DIFF_VEC
1774    && PREV_INSN (next_active_insn (insn)) == operands[1]"
1775   "*
1777   return \"j\\t%0\";
1779   [(set_attr "type"     "jump")
1780    (set_attr "mode"     "none")
1781    (set_attr "length"   "8")])
1784 ;;  ....................
1786 ;;      Function prologue/epilogue
1788 ;;  ....................
1791 (define_expand "prologue"
1792   [(const_int 1)]
1793   ""
1794   "
1796   if (iq2000_isa >= 0)          /* avoid unused code warnings */
1797     {
1798       iq2000_expand_prologue ();
1799       DONE;
1800     }
1803 ;; Block any insns from being moved before this point, since the
1804 ;; profiling call to mcount can use various registers that aren't
1805 ;; saved or used to pass arguments.
1807 (define_insn "blockage"
1808   [(unspec_volatile [(const_int 0)] 0)]
1809   ""
1810   ""
1811   [(set_attr "type"     "unknown")
1812    (set_attr "mode"     "none")
1813    (set_attr "length"   "0")])
1815 (define_expand "epilogue"
1816   [(const_int 2)]
1817   ""
1818   "
1820   if (iq2000_isa >= 0)            /* avoid unused code warnings */
1821     {
1822       iq2000_expand_epilogue ();
1823       DONE;
1824     }
1827 ;; Trivial return.  Make it look like a normal return insn as that
1828 ;; allows jump optimizations to work better .
1829 (define_insn "return"
1830   [(return)]
1831   "iq2000_can_use_return_insn ()"
1832   "j\\t%%31"
1833   [(set_attr "type"     "jump")
1834    (set_attr "mode"     "none")])
1836 ;; Normal return.
1838 (define_insn "return_internal"
1839   [(use (match_operand 0 "pmode_register_operand" ""))
1840    (return)]
1841   ""
1842   "*
1844   return \"j\\t%0\";
1846   [(set_attr "type"     "jump")
1847    (set_attr "mode"     "none")])
1849 (define_insn "eh_return_internal"
1850   [(const_int 4)
1851    (return)
1852    (use (reg:SI 26))
1853    (use (reg:SI 31))]
1854   ""
1855   "j\\t%%26"
1856   [(set_attr "type"     "jump")
1857    (set_attr "mode"     "none")])
1859 (define_expand "eh_return"
1860   [(use (match_operand:SI 0 "register_operand" "r"))]
1861   ""
1862   "
1864   iq2000_expand_eh_return (operands[0]);
1865   DONE;
1870 ;;  ....................
1872 ;;      FUNCTION CALLS
1874 ;;  ....................
1876 ;; calls.c now passes a third argument, make saber happy
1878 (define_expand "call"
1879   [(parallel [(call (match_operand 0 "memory_operand" "m")
1880                     (match_operand 1 "" "i"))
1881               (clobber (reg:SI 31))
1882               (use (match_operand 2 "" ""))             ;; next_arg_reg
1883               (use (match_operand 3 "" ""))])]          ;; struct_value_size_rtx
1884   ""
1885   "
1887   rtx addr;
1889   if (operands[0])              /* eliminate unused code warnings */
1890     {
1891       addr = XEXP (operands[0], 0);
1892       if ((GET_CODE (addr) != REG && (!CONSTANT_ADDRESS_P (addr)))
1893           || ! call_insn_operand (addr, VOIDmode))
1894         XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, addr);
1896       /* In order to pass small structures by value in registers
1897          compatibly with the IQ2000 compiler, we need to shift the value
1898          into the high part of the register.  Function_arg has encoded
1899          a PARALLEL rtx, holding a vector of adjustments to be made
1900          as the next_arg_reg variable, so we split up the insns,
1901          and emit them separately.  */
1903       if (operands[2] != (rtx)0 && GET_CODE (operands[2]) == PARALLEL)
1904         {
1905           rtvec adjust = XVEC (operands[2], 0);
1906           int num = GET_NUM_ELEM (adjust);
1907           int i;
1909           for (i = 0; i < num; i++)
1910             emit_insn (RTVEC_ELT (adjust, i));
1911         }
1913       emit_call_insn (gen_call_internal0 (operands[0], operands[1],
1914                                           gen_rtx_REG (SImode,
1915                                                        GP_REG_FIRST + 31)));
1916       DONE;
1917     }
1920 (define_expand "call_internal0"
1921   [(parallel [(call (match_operand 0 "" "")
1922                     (match_operand 1 "" ""))
1923               (clobber (match_operand:SI 2 "" ""))])]
1924   ""
1925   "")
1927 (define_insn "call_internal1"
1928   [(call (mem (match_operand 0 "call_insn_operand" "ri"))
1929          (match_operand 1 "" "i"))
1930    (clobber (match_operand:SI 2 "register_operand" "=d"))]
1931   ""
1932   "*
1934   register rtx target = operands[0];
1936   if (GET_CODE (target) == CONST_INT)
1937     return \"li\\t%@,%0\\n\\tjalr\\t%2,%@\";
1938   else if (CONSTANT_ADDRESS_P (target))
1939     return \"jal\\t%0\";
1940   else
1941     return \"jalr\\t%2,%0\";
1943   [(set_attr "type"     "call")
1944    (set_attr "mode"     "none")])
1946 ;; calls.c now passes a fourth argument, make saber happy
1948 (define_expand "call_value"
1949   [(parallel [(set (match_operand 0 "register_operand" "=df")
1950                    (call (match_operand 1 "memory_operand" "m")
1951                          (match_operand 2 "" "i")))
1952               (clobber (reg:SI 31))
1953               (use (match_operand 3 "" ""))])]          ;; next_arg_reg
1954   ""
1955   "
1957   rtx addr;
1959   if (operands[0])              /* eliminate unused code warning */
1960     {
1961       addr = XEXP (operands[1], 0);
1962       if ((GET_CODE (addr) != REG && (!CONSTANT_ADDRESS_P (addr)))
1963           || ! call_insn_operand (addr, VOIDmode))
1964         XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, addr);
1966       /* In order to pass small structures by value in registers
1967          compatibly with the IQ2000 compiler, we need to shift the value
1968          into the high part of the register.  Function_arg has encoded
1969          a PARALLEL rtx, holding a vector of adjustments to be made
1970          as the next_arg_reg variable, so we split up the insns,
1971          and emit them separately.  */
1973       if (operands[3] != (rtx)0 && GET_CODE (operands[3]) == PARALLEL)
1974         {
1975           rtvec adjust = XVEC (operands[3], 0);
1976           int num = GET_NUM_ELEM (adjust);
1977           int i;
1979           for (i = 0; i < num; i++)
1980             emit_insn (RTVEC_ELT (adjust, i));
1981         }
1983       if (GET_CODE (operands[0]) == PARALLEL && XVECLEN (operands[0], 0) > 1)
1984         {
1985           emit_call_insn (gen_call_value_multiple_internal0
1986                           (XEXP (XVECEXP (operands[0], 0, 0), 0),
1987                            operands[1], operands[2],
1988                            XEXP (XVECEXP (operands[0], 0, 1), 0),
1989                            gen_rtx_REG (SImode, GP_REG_FIRST + 31)));
1990           DONE;
1991         }
1993       /* We have a call returning a DImode structure in an FP reg.
1994          Strip off the now unnecessary PARALLEL.  */
1995       if (GET_CODE (operands[0]) == PARALLEL)
1996         operands[0] = XEXP (XVECEXP (operands[0], 0, 0), 0);
1998       emit_call_insn (gen_call_value_internal0 (operands[0], operands[1], operands[2],
1999                                                 gen_rtx_REG (SImode,
2000                                                              GP_REG_FIRST + 31)));
2002       DONE;
2003     }
2006 (define_expand "call_value_internal0"
2007   [(parallel [(set (match_operand 0 "" "")
2008                    (call (match_operand 1 "" "")
2009                          (match_operand 2 "" "")))
2010               (clobber (match_operand:SI 3 "" ""))])]
2011   ""
2012   "")
2014 (define_insn "call_value_internal1"
2015   [(set (match_operand 0 "register_operand" "=df")
2016         (call (mem (match_operand 1 "call_insn_operand" "ri"))
2017               (match_operand 2 "" "i")))
2018    (clobber (match_operand:SI 3 "register_operand" "=d"))]
2019   ""
2020   "*
2022   register rtx target = operands[1];
2024   if (GET_CODE (target) == CONST_INT)
2025     return \"li\\t%@,%1\\n\\tjalr\\t%3,%@\";
2026   else if (CONSTANT_ADDRESS_P (target))
2027     return \"jal\\t%1\";
2028   else
2029     return \"jalr\\t%3,%1\";
2031   [(set_attr "type"     "call")
2032    (set_attr "mode"     "none")])
2034 (define_expand "call_value_multiple_internal0"
2035   [(parallel [(set (match_operand 0 "" "")
2036                    (call (match_operand 1 "" "")
2037                          (match_operand 2 "" "")))
2038               (set (match_operand 3 "" "")
2039                    (call (match_dup 1)
2040                          (match_dup 2)))
2041               (clobber (match_operand:SI 4 "" ""))])]
2042   ""
2043   "")
2045 ;; ??? May eventually need all 6 versions of the call patterns with multiple
2046 ;; return values.
2048 (define_insn "call_value_multiple_internal1"
2049   [(set (match_operand 0 "register_operand" "=df")
2050         (call (mem (match_operand 1 "call_insn_operand" "ri"))
2051               (match_operand 2 "" "i")))
2052    (set (match_operand 3 "register_operand" "=df")
2053         (call (mem (match_dup 1))
2054               (match_dup 2)))
2055   (clobber (match_operand:SI 4 "register_operand" "=d"))]
2056   ""
2057   "*
2059   register rtx target = operands[1];
2061   if (GET_CODE (target) == CONST_INT)
2062     return \"li\\t%@,%1\\n\\tjalr\\t%4,%@\";
2063   else if (CONSTANT_ADDRESS_P (target))
2064     return \"jal\\t%1\";
2065   else
2066     return \"jalr\\t%4,%1\";
2068   [(set_attr "type"     "call")
2069    (set_attr "mode"     "none")])
2071 ;; Call subroutine returning any type.
2073 (define_expand "untyped_call"
2074   [(parallel [(call (match_operand 0 "" "")
2075                     (const_int 0))
2076               (match_operand 1 "" "")
2077               (match_operand 2 "" "")])]
2078   ""
2079   "
2081   if (operands[0])              /* silence statement not reached warnings */
2082     {
2083       int i;
2085       emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
2087       for (i = 0; i < XVECLEN (operands[2], 0); i++)
2088         {
2089           rtx set = XVECEXP (operands[2], 0, i);
2090           emit_move_insn (SET_DEST (set), SET_SRC (set));
2091         }
2093       emit_insn (gen_blockage ());
2094       DONE;
2095     }
2099 ;;  ....................
2101 ;;      MISC.
2103 ;;  ....................
2106 (define_insn "nop"
2107   [(const_int 0)]
2108   ""
2109   "nop"
2110   [(set_attr "type"     "nop")
2111    (set_attr "mode"     "none")])
2114 ;; For the rare case where we need to load an address into a register
2115 ;; that cannot be recognized by the normal movsi/addsi instructions.
2116 ;; I have no idea how many insns this can actually generate.  It should
2117 ;; be rare, so over-estimating as 10 instructions should not have any
2118 ;; real performance impact.
2119 (define_insn "leasi"
2120   [(set (match_operand:SI 0 "register_operand" "=d")
2121         (match_operand:SI 1 "address_operand" "p"))]
2122   "Pmode == SImode"
2123   "*
2125   rtx xoperands [3];
2127   xoperands[0] = operands[0];
2128   xoperands[1] = XEXP (operands[1], 0);
2129   xoperands[2] = XEXP (operands[1], 1);
2130   output_asm_insn (\"addiu\\t%0,%1,%2\", xoperands);
2131   return \"\";
2133   [(set_attr "type"     "arith")
2134    (set_attr "mode"     "SI")
2135    (set_attr "length"   "40")])
2137 (define_insn "ado16"
2138   [(set (match_operand:SI             0 "register_operand" "=r")
2139         (unspec:SI [(match_operand:SI 1 "register_operand" "r")
2140                     (match_operand:SI 2 "register_operand" "r")]
2141                 UNSPEC_ADO16))]
2142   ""
2143   "ado16\\t%0, %1, %2"
2146 (define_insn "ram"
2147   [(set (match_operand:SI             0 "register_operand" "=r")
2148               (unspec:SI [(match_operand:SI 1 "register_operand" "r")
2149                                 (match_operand:SI 2 "const_int_operand" "I")
2150                                 (match_operand:SI 3 "const_int_operand" "I")
2151                                 (match_operand:SI 4 "const_int_operand" "I")]
2152                      UNSPEC_RAM))]
2153   ""
2154   "ram\\t%0, %1, %2, %3, %4"
2157 (define_insn "chkhdr"
2158   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "=r")
2159                 (match_operand:SI 1 "register_operand" "r")]
2160                 UNSPEC_CHKHDR)]
2161   ""
2162   "* return iq2000_fill_delay_slot (\"chkhdr\\t%0, %1\", DELAY_LOAD, operands, insn);"
2163   [(set_attr "dslot"    "not_in_dslot")]
2166 (define_insn "pkrl"
2167   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2168                 (match_operand:SI 1 "register_operand" "r")]
2169                 UNSPEC_PKRL)]
2170   ""
2171   "* return iq2000_fill_delay_slot (\"pkrl\\t%0, %1\", DELAY_NONE, operands, insn);"
2172   [(set_attr "dslot"    "not_in_dslot")]
2175 (define_insn "cfc0"
2176    [(set (match_operand:SI                0 "register_operand" "=r")
2177     (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2178                 UNSPEC_CFC0))]
2179   ""
2180   "* return iq2000_fill_delay_slot (\"cfc0\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2181   [(set_attr "dslot"    "ok_in_dslot")]
2184 (define_insn "cfc1"
2185    [(set (match_operand:SI                0 "register_operand" "=r")
2186    (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2187                 UNSPEC_CFC1))]
2188   ""
2189   "* return iq2000_fill_delay_slot (\"cfc1\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2190   [(set_attr "dslot"    "ok_in_dslot")]
2193 (define_insn "cfc2"
2194    [(set (match_operand:SI                0 "register_operand" "=r")
2195    (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2196                 UNSPEC_CFC2))]
2197   ""
2198   "* return iq2000_fill_delay_slot (\"cfc2\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2199   [(set_attr "dslot"    "not_in_dslot")]
2202 (define_insn "cfc3"
2203    [(set (match_operand:SI                0 "register_operand" "=r")
2204    (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2205                 UNSPEC_CFC3))]
2206   ""
2207   "* return iq2000_fill_delay_slot (\"cfc3\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2208   [(set_attr "dslot"    "not_in_dslot")]
2211 (define_insn "ctc0"
2212   [(unspec_volatile:SI [(match_operand:SI 0 "reg_or_0_operand" "rJ")
2213                 (match_operand:SI 1 "const_int_operand" "I")]
2214                 UNSPEC_CTC0)]
2215   ""
2216   "* return iq2000_fill_delay_slot (\"ctc0\\t%z0, %%%1\", DELAY_NONE, operands, insn);"
2217   [(set_attr "dslot"    "ok_in_dslot")]
2220 (define_insn "ctc1"
2221   [(unspec_volatile:SI [(match_operand:SI 0 "reg_or_0_operand" "rJ")
2222                 (match_operand:SI 1 "const_int_operand" "I")]
2223                 UNSPEC_CTC1)]
2224   ""
2225   "* return iq2000_fill_delay_slot (\"ctc1\\t%z0, %%%1\", DELAY_NONE, operands, insn);"
2226   [(set_attr "dslot"    "ok_in_dslot")]
2229 (define_insn "ctc2"
2230   [(unspec_volatile:SI [(match_operand:SI 0 "reg_or_0_operand" "rJ")
2231                 (match_operand:SI 1 "const_int_operand" "I")]
2232                 UNSPEC_CTC2)]
2233   ""
2234   "* return iq2000_fill_delay_slot (\"ctc2\\t%z0, %%%1\", DELAY_NONE, operands, insn);"
2235   [(set_attr "dslot"    "ok_in_dslot")]
2238 (define_insn "ctc3"
2239   [(unspec_volatile:SI [(match_operand:SI 0 "reg_or_0_operand" "rJ")
2240                 (match_operand:SI 1 "const_int_operand" "I")]
2241                 UNSPEC_CTC3)]
2242   ""
2243   "* return iq2000_fill_delay_slot (\"ctc3\\t%z0, %%%1\", DELAY_NONE, operands, insn);"
2244   [(set_attr "dslot"    "ok_in_dslot")]
2247 (define_insn "mfc0"
2248    [(set (match_operand:SI                0 "register_operand" "=r")
2249    (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2250                 UNSPEC_MFC0))]
2251   ""
2252   "* return iq2000_fill_delay_slot (\"mfc0\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2253   [(set_attr "dslot"    "ok_in_dslot")]
2256 (define_insn "mfc1"
2257    [(set (match_operand:SI                0 "register_operand" "=r")
2258    (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2259                 UNSPEC_MFC1))]
2260   ""
2261   "* return iq2000_fill_delay_slot (\"mfc1\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2262   [(set_attr "dslot"    "ok_in_dslot")]
2265 (define_insn "mfc2"
2266    [(set (match_operand:SI                0 "register_operand" "=r")
2267    (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2268                 UNSPEC_MFC2))]
2269   ""
2270   "* return iq2000_fill_delay_slot (\"mfc2\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2271   [(set_attr "dslot"    "not_in_dslot")]
2274 (define_insn "mfc3"
2275    [(set (match_operand:SI                0 "register_operand" "=r")
2276    (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2277                 UNSPEC_MFC3))]
2278   ""
2279   "* return iq2000_fill_delay_slot (\"mfc3\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2280   [(set_attr "dslot"    "not_in_dslot")]
2283 (define_insn "mtc0"
2284   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2285                 (match_operand:SI 1 "const_int_operand" "I")]
2286                 UNSPEC_MTC0)]
2287   ""
2288   "* return iq2000_fill_delay_slot (\"mtc0\\t%0, %%%1\", DELAY_NONE, operands, insn);"
2289   [(set_attr "dslot"    "ok_in_dslot")]
2292 (define_insn "mtc1"
2293   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2294                 (match_operand:SI 1 "const_int_operand" "I")]
2295                 UNSPEC_MTC1)]
2296   ""
2297   "* return iq2000_fill_delay_slot (\"mtc1\\t%0, %%%1\", DELAY_NONE, operands, insn);"
2298   [(set_attr "dslot"    "ok_in_dslot")]
2301 (define_insn "mtc2"
2302   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2303                 (match_operand:SI 1 "const_int_operand" "I")]
2304                 UNSPEC_MTC2)]
2305   ""
2306   "* return iq2000_fill_delay_slot (\"mtc2\\t%0, %%%1\", DELAY_NONE, operands, insn);"
2307   [(set_attr "dslot"    "ok_in_dslot")]
2310 (define_insn "mtc3"
2311   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2312                 (match_operand:SI 1 "const_int_operand" "I")]
2313                 UNSPEC_MTC3)]
2314   ""
2315   "* return iq2000_fill_delay_slot (\"mtc3\\t%0, %%%1\", DELAY_NONE, operands, insn);"
2316   [(set_attr "dslot"    "ok_in_dslot")]
2319 (define_insn "lur"
2320   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2321                 (match_operand:SI 1 "register_operand" "r")]
2322                 UNSPEC_LUR)]
2323   ""
2324   "* return iq2000_fill_delay_slot (\"lur\\t%0, %1\", DELAY_NONE, operands, insn);"
2325   [(set_attr "dslot"    "not_in_dslot")]
2328 (define_insn "rb"
2329   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2330                 (match_operand:SI 1 "register_operand" "r")]
2331                 UNSPEC_RB)]
2332   ""
2333   "* return iq2000_fill_delay_slot (\"rb\\t%0, %1\", DELAY_NONE, operands, insn);"
2334   [(set_attr "dslot"    "not_in_dslot")]
2337 (define_insn "rx"
2338   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2339                 (match_operand:SI 1 "register_operand" "r")]
2340                 UNSPEC_RX)]
2341   ""
2342   "* return iq2000_fill_delay_slot (\"rx\\t%0, %1\", DELAY_NONE, operands, insn);"
2343   [(set_attr "dslot"    "not_in_dslot")]
2346 (define_insn "srrd"
2347   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")]
2348                 UNSPEC_SRRD)]
2349   ""
2350   "* return iq2000_fill_delay_slot (\"srrd\\t%0\", DELAY_NONE, operands, insn);"
2351   [(set_attr "dslot"    "not_in_dslot")]
2354 (define_insn "srwr"
2355   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2356                 (match_operand:SI 1 "register_operand" "r")]
2357                 UNSPEC_SRWR)]
2358   ""
2359   "* return iq2000_fill_delay_slot (\"srwr\\t%0, %1\", DELAY_NONE, operands, insn);"
2360   [(set_attr "dslot"    "not_in_dslot")]
2363 (define_insn "wb"
2364   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2365                 (match_operand:SI 1 "register_operand" "r")]
2366                 UNSPEC_WB)]
2367   ""
2368   "* return iq2000_fill_delay_slot (\"wb\\t%0, %1\", DELAY_NONE, operands, insn);"
2369   [(set_attr "dslot"    "not_in_dslot")]
2372 (define_insn "wx"
2373   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2374                 (match_operand:SI 1 "register_operand" "r")]
2375                 UNSPEC_WX)]
2376   ""
2377   "* return iq2000_fill_delay_slot (\"wx\\t%0, %1\", DELAY_NONE, operands, insn);"
2378   [(set_attr "dslot"    "not_in_dslot")]
2381 (define_insn "luc32"
2382   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2383                 (match_operand:SI 1 "register_operand" "r")]
2384                 UNSPEC_LUC32)]
2385   ""
2386   "* return iq2000_fill_delay_slot (\"luc32\\t%0, %1\", DELAY_NONE, operands, insn);"
2387   [(set_attr "dslot"    "not_in_dslot")]
2390 (define_insn "luc32l"
2391   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2392                 (match_operand:SI 1 "register_operand" "r")]
2393                 UNSPEC_LUC32L)]
2394   ""
2395   "* return iq2000_fill_delay_slot (\"luc32l\\t%0, %1\", DELAY_NONE, operands, insn);"
2396   [(set_attr "dslot"    "not_in_dslot")]
2399 (define_insn "luc64"
2400   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2401                 (match_operand:SI 1 "register_operand" "r")]
2402                 UNSPEC_LUC64)]
2403   ""
2404   "* return iq2000_fill_delay_slot (\"luc64\\t%0, %1\", DELAY_NONE, operands, insn);"
2405   [(set_attr "dslot"    "not_in_dslot")]
2408 (define_insn "luc64l"
2409   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2410                 (match_operand:SI 1 "register_operand" "r")]
2411                 UNSPEC_LUC64L)]
2412   ""
2413   "* return iq2000_fill_delay_slot (\"luc64l\\t%0, %1\", DELAY_NONE, operands, insn);"
2414   [(set_attr "dslot"    "not_in_dslot")]
2417 (define_insn "luk"
2418   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2419                 (match_operand:SI 1 "register_operand" "r")]
2420                 UNSPEC_LUK)]
2421   ""
2422   "* return iq2000_fill_delay_slot (\"luk\\t%0, %1\", DELAY_NONE, operands, insn);"
2423   [(set_attr "dslot"    "ok_in_dslot")]
2426 (define_insn "lulck"
2427   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")]
2428                 UNSPEC_LULCK)]
2429   ""
2430   "* return iq2000_fill_delay_slot (\"lulck\\t%0\", DELAY_NONE, operands, insn);"
2431   [(set_attr "dslot"    "not_in_dslot")]
2434 (define_insn "lum32"
2435   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2436                 (match_operand:SI 1 "register_operand" "r")]
2437                 UNSPEC_LUM32)]
2438   ""
2439   "* return iq2000_fill_delay_slot (\"lum32\\t%0, %1\", DELAY_NONE, operands, insn);"
2440   [(set_attr "dslot"    "not_in_dslot")]
2443 (define_insn "lum32l"
2444   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2445                 (match_operand:SI 1 "register_operand" "r")]
2446                 UNSPEC_LUM32L)]
2447   ""
2448   "* return iq2000_fill_delay_slot (\"lum32l\\t%0, %1\", DELAY_NONE, operands, insn);" 
2449   [(set_attr "dslot"    "not_in_dslot")]
2452 (define_insn "lum64"
2453   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2454                 (match_operand:SI 1 "register_operand" "r")]
2455                 UNSPEC_LUM64)]
2456   ""
2457   "* return iq2000_fill_delay_slot (\"lum64\\t%0, %1\", DELAY_NONE, operands, insn);"
2458   [(set_attr "dslot"    "not_in_dslot")]
2461 (define_insn "lum64l"
2462   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2463                 (match_operand:SI 1 "register_operand" "r")]
2464                 UNSPEC_LUM64L)]
2465   ""
2466   "* return iq2000_fill_delay_slot (\"lum64l\\t%0, %1\", DELAY_NONE, operands, insn);"
2467   [(set_attr "dslot"    "not_in_dslot")]
2470 (define_insn "lurl"
2471   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2472                 (match_operand:SI 1 "register_operand" "r")]
2473                 UNSPEC_LURL)]
2474   ""
2475   "* return iq2000_fill_delay_slot (\"lurl\\t%0, %1\", DELAY_NONE, operands, insn);"
2476   [(set_attr "dslot"    "not_in_dslot")]
2479 (define_insn "mrgb"
2480   [(set (match_operand:SI                 0 "register_operand" "=r")
2481         (unspec_volatile:SI [(match_operand:SI 1 "register_operand" "r")
2482                 (match_operand:SI 2 "register_operand" "r")
2483                 (match_operand:SI 3 "const_int_operand" "I")]
2484                 UNSPEC_MRGB))]
2485   ""
2486   "* return iq2000_fill_delay_slot (\"mrgb\\t%0, %1, %2, %3\", DELAY_LOAD, operands, insn);"
2487   [(set_attr "dslot"    "ok_in_dslot")]
2490 (define_insn "srrdl"
2491   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")]
2492                 UNSPEC_SRRDL)]
2493   ""
2494   "* return iq2000_fill_delay_slot (\"srrdl\\t%0\", DELAY_NONE, operands, insn);"
2495   [(set_attr "dslot"    "not_in_dslot")]
2498 (define_insn "srulck"
2499   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")]
2500                 UNSPEC_SRULCK)]
2501   ""
2502   "* return iq2000_fill_delay_slot (\"srulck\\t%0\", DELAY_NONE, operands, insn);"
2503   [(set_attr "dslot"    "not_in_dslot")]
2506 (define_insn "srwru"
2507   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2508                 (match_operand:SI 1 "register_operand" "r")]
2509                 UNSPEC_SRWRU)]
2510   ""
2511   "* return iq2000_fill_delay_slot (\"srwru\\t%0, %1\", DELAY_NONE, operands, insn);"
2512   [(set_attr "dslot"    "not_in_dslot")]
2515 (define_insn "trapqfl"
2516   [(unspec_volatile:SI [(const_int 1)] UNSPEC_TRAPQFL)]
2517   ""
2518   "* return iq2000_fill_delay_slot (\"trapqfl\", DELAY_NONE, operands, insn);"
2519   [(set_attr "dslot"    "not_in_dslot")]
2522 (define_insn "trapqne"
2523   [(unspec_volatile:SI [(const_int 2)] UNSPEC_TRAPQNE)]
2524   ""
2525   "* return iq2000_fill_delay_slot (\"trapqne\", DELAY_NONE, operands, insn);"
2526   [(set_attr "dslot"    "not_in_dslot")]
2529 (define_insn "traprel"
2530   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")]
2531                 UNSPEC_TRAPREL)]
2532   ""
2533   "* return iq2000_fill_delay_slot (\"traprel %0\", DELAY_NONE, operands, insn);"
2534   [(set_attr "dslot"    "not_in_dslot")]
2537 (define_insn "wbu"
2538   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2539                 (match_operand:SI 1 "register_operand" "r")]
2540                 UNSPEC_WBU)]
2541   ""
2542   "* return iq2000_fill_delay_slot (\"wbu\\t%0, %1\", DELAY_NONE, operands, insn);"
2543   [(set_attr "dslot"    "not_in_dslot")]
2546 (define_insn "syscall"
2547   [(unspec_volatile:SI [(const_int 2)] UNSPEC_SYSCALL)]
2548   ""
2549   "syscall"
2550   [(set_attr "dslot"    "not_in_dslot")]