2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / config / iq2000 / iq2000.md
blobe00794402f2c3443a615d76d8d6f585be5e0303c
1 ;;  iq2000.md        Machine Description for Vitesse IQ2000 processors
2 ;;  Copyright (C) 2003 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, 59 Temple Place - Suite 330,
19 ;; Boston, MA 02111-1307, USA.
21 ;; ??? Currently does not have define_function_unit support for the R8000.
22 ;; Must include new entries for fmadd in addition to existing entries.
24 (define_constants
25   [(UNSPEC_ADO16 0)
26    (UNSPEC_RAM  1)
27    (UNSPEC_CHKHDR 2)
28    (UNSPEC_PKRL 3)
29    (UNSPEC_CFC0 4)
30    (UNSPEC_CFC1 5)
31    (UNSPEC_CFC2 6)
32    (UNSPEC_CFC3 7)
33    (UNSPEC_CTC0 8)
34    (UNSPEC_CTC1 9)
35    (UNSPEC_CTC2 10)
36    (UNSPEC_CTC3 11)
37    (UNSPEC_MFC0 12)
38    (UNSPEC_MFC1 13)
39    (UNSPEC_MFC2 14)
40    (UNSPEC_MFC3 15)
41    (UNSPEC_MTC0 16)
42    (UNSPEC_MTC1 17)
43    (UNSPEC_MTC2 18)
44    (UNSPEC_MTC3 19)
45    (UNSPEC_LUR  20)
46    (UNSPEC_RB   21)
47    (UNSPEC_RX   22)
48    (UNSPEC_SRRD 23)
49    (UNSPEC_SRWR 24)
50    (UNSPEC_WB   25)
51    (UNSPEC_WX   26)
52    (UNSPEC_LUC32 49)
53    (UNSPEC_LUC32L 27)
54    (UNSPEC_LUC64 28)
55    (UNSPEC_LUC64L 29)
56    (UNSPEC_LUK 30)
57    (UNSPEC_LULCK 31)
58    (UNSPEC_LUM32 32)
59    (UNSPEC_LUM32L 33)
60    (UNSPEC_LUM64 34)
61    (UNSPEC_LUM64L 35)
62    (UNSPEC_LURL 36)
63    (UNSPEC_MRGB 37)
64    (UNSPEC_SRRDL 38)
65    (UNSPEC_SRULCK 39)
66    (UNSPEC_SRWRU 40)
67    (UNSPEC_TRAPQFL 41)
68    (UNSPEC_TRAPQNE 42)
69    (UNSPEC_TRAPREL 43)
70    (UNSPEC_WBU 44)
71    (UNSPEC_SYSCALL 45)]
73 ;; UNSPEC values used in iq2000.md
74 ;; Number       USE
75 ;; 0            movsi_ul
76 ;; 1            movsi_us, get_fnaddr
77 ;; 3            eh_set_return
78 ;; 20           builtin_setjmp_setup
80 ;; UNSPEC_VOLATILE values
81 ;; 0            blockage
82 ;; 2            loadgp
83 ;; 3            builtin_longjmp
84 ;; 4            exception_receiver
85 ;; 10           consttable_qi
86 ;; 11           consttable_hi
87 ;; 12           consttable_si
88 ;; 13           consttable_di
89 ;; 14           consttable_sf
90 ;; 15           consttable_df
91 ;; 16           align_2
92 ;; 17           align_4
93 ;; 18           align_8
96 ;; ....................
98 ;;      Attributes
100 ;; ....................
102 ;; Classification of each insn.
103 ;; branch       conditional branch
104 ;; jump         unconditional jump
105 ;; call         unconditional call
106 ;; load         load instruction(s)
107 ;; store        store instruction(s)
108 ;; move         data movement within same register set
109 ;; xfer         transfer to/from coprocessor
110 ;; arith        integer arithmetic instruction
111 ;; darith       double precision integer arithmetic instructions
112 ;; imul         integer multiply
113 ;; idiv         integer divide
114 ;; icmp         integer compare
115 ;; fadd         floating point add/subtract
116 ;; fmul         floating point multiply
117 ;; fmadd        floating point multiply-add
118 ;; fdiv         floating point divide
119 ;; fabs         floating point absolute value
120 ;; fneg         floating point negation
121 ;; fcmp         floating point compare
122 ;; fcvt         floating point convert
123 ;; fsqrt        floating point square root
124 ;; multi        multiword sequence (or user asm statements)
125 ;; nop          no operation
127 (define_attr "type"
128   "unknown,branch,jump,call,load,store,move,xfer,arith,darith,imul,idiv,icmp,fadd,fmul,fmadd,fdiv,fabs,fneg,fcmp,fcvt,fsqrt,multi,nop"
129   (const_string "unknown"))
131 ;; Main data type used by the insn
132 (define_attr "mode" "unknown,none,QI,HI,SI,DI,SF,DF,FPSW" (const_string "unknown"))
134 ;; Length (in # of bytes).  A conditional branch is allowed only to a
135 ;; location within a signed 18-bit offset of the delay slot.  If that
136 ;; provides too small a range, we use the `j' instruction.  This
137 ;; instruction takes a 28-bit value, but that value is not an offset.
138 ;; Instead, it's bitwise-ored with the high-order four bits of the
139 ;; instruction in the delay slot, which means it cannot be used to
140 ;; cross a 256MB boundary.  We could fall back back on the jr,
141 ;; instruction which allows full access to the entire address space,
142 ;; but we do not do so at present.
144 (define_attr "length" ""
145    (cond [(eq_attr "type" "branch")
146           (cond [(lt (abs (minus (match_dup 1) (plus (pc) (const_int 4))))
147                      (const_int 131072))
148                  (const_int 4)]
149                  (const_int 12))]
150           (const_int 4)))
152 (define_attr "cpu"
153   "default,iq2000"
154   (const (symbol_ref "iq2000_cpu_attr")))
156 ;; Does the instruction have a mandatory delay slot? has_dslot
157 ;; Can the instruction be in a delay slot? ok_in_dslot
158 ;; Can the instruction not be in a delay slot? not_in_dslot
159 (define_attr "dslot" "has_dslot,ok_in_dslot,not_in_dslot"
160   (if_then_else (eq_attr "type" "branch,jump,call,xfer,fcmp")
161                 (const_string "has_dslot")
162                 (const_string "ok_in_dslot")))
164 ;; Attribute defining whether or not we can use the branch-likely instructions
166 (define_attr "branch_likely" "no,yes"
167   (const
168    (if_then_else (ne (symbol_ref "GENERATE_BRANCHLIKELY") (const_int 0))
169                  (const_string "yes")
170                  (const_string "no"))))
173 ;; Describe a user's asm statement.
174 (define_asm_attributes
175   [(set_attr "type" "multi")])
179 ;; .........................
181 ;;      Delay slots, can't describe load/fcmp/xfer delay slots here
183 ;; .........................
185 (define_delay (eq_attr "type" "jump")
186   [(and (eq_attr "dslot" "ok_in_dslot") (eq_attr "length" "4"))
187    (nil)
188    (nil)])
190 (define_delay (eq_attr "type" "branch")
191   [(and (eq_attr "dslot" "ok_in_dslot") (eq_attr "length" "4"))
192    (nil)
193    (and (eq_attr "branch_likely" "yes") (and (eq_attr "dslot" "ok_in_dslot") (eq_attr "length" "4")))])
195 (define_delay (eq_attr "type" "call")
196   [(and (eq_attr "dslot" "ok_in_dslot") (eq_attr "length" "4"))
197    (nil)
198    (nil)])
202 ;; .........................
204 ;;      Functional units
206 ;; .........................
208 ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
209 ;                       TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
211 ;; Make the default case (PROCESSOR_DEFAULT) handle the worst case
213 (define_function_unit "memory" 1 0
214   (and (eq_attr "type" "load")
215        (eq_attr "cpu" "iq2000"))
216   3 0)
218 (define_function_unit "memory" 1 0
219   (and (eq_attr "type" "move")
220        (eq_attr "cpu" "iq2000"))
221   3 0)
223 (define_function_unit "memory" 1 0
224   (and (eq_attr "type" "arith")
225        (eq_attr "cpu" "iq2000"))
226   3 0)
228 (define_function_unit "memory"   1 0 (eq_attr "type" "store") 1 0)
230 (define_function_unit "memory"   1 0 (eq_attr "type" "xfer") 2 0)
233 ;;  ....................
235 ;;      CONDITIONAL TRAPS
237 ;;  ....................
240 (define_insn "trap"
241   [(trap_if (const_int 1) (const_int 0))]
242   ""
243   "*
245   return \"break\";
249 ;;  ....................
251 ;;      ADDITION
253 ;;  ....................
256 (define_expand "addsi3"
257   [(set (match_operand:SI 0 "register_operand" "=d")
258         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
259                  (match_operand:SI 2 "arith_operand" "dI")))]
260   ""
261   "")
263 (define_insn "addsi3_internal"
264   [(set (match_operand:SI 0 "register_operand" "=d,=d")
265         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ,dJ")
266                  (match_operand:SI 2 "arith_operand" "d,I")))]
267   ""
268   "@
269    addu\\t%0,%z1,%2
270    addiu\\t%0,%z1,%2"
271   [(set_attr "type"     "arith")
272    (set_attr "mode"     "SI")])
275 ;;  ....................
277 ;;      SUBTRACTION
279 ;;  ....................
282 (define_expand "subsi3"
283   [(set (match_operand:SI 0 "register_operand" "=d")
284         (minus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
285                   (match_operand:SI 2 "arith_operand" "dI")))]
286   ""
287   "")
289 (define_insn "subsi3_internal"
290   [(set (match_operand:SI 0 "register_operand" "=d,=d")
291         (minus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ,dJ")
292                   (match_operand:SI 2 "arith_operand" "d,I")))]
293   ""
294   "@
295    subu\\t%0,%z1,%2
296    addiu\\t%0,%z1,%n2"
297   [(set_attr "type"     "arith")
298    (set_attr "mode"     "SI")])
301 ;;  ....................
303 ;;      NEGATION and ONE'S COMPLEMENT
305 ;;  ....................
307 (define_insn "negsi2"
308   [(set (match_operand:SI 0 "register_operand" "=d")
309         (neg:SI (match_operand:SI 1 "register_operand" "d")))]
310   ""
311   "*
313   operands[2] = const0_rtx;
314   return \"subu\\t%0,%z2,%1\";
316   [(set_attr "type"     "arith")
317    (set_attr "mode"     "SI")])
319 (define_insn "one_cmplsi2"
320   [(set (match_operand:SI 0 "register_operand" "=d")
321         (not:SI (match_operand:SI 1 "register_operand" "d")))]
322   ""
323   "*
325   operands[2] = const0_rtx;
326   return \"nor\\t%0,%z2,%1\";
328   [(set_attr "type"     "arith")
329    (set_attr "mode"     "SI")])
332 ;;  ....................
334 ;;      LOGICAL
336 ;;  ....................
339 (define_expand "andsi3"
340   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
341         (and:SI (match_operand:SI 1 "uns_arith_operand" "%d,d,d")
342                 (match_operand:SI 2 "nonmemory_operand" "d,K,N")))]
343   ""
344   "")
346 (define_insn ""
347   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
348         (and:SI (match_operand:SI 1 "uns_arith_operand" "%d,d,d")
349                 (match_operand:SI 2 "nonmemory_operand" "d,K,N")))]
350   ""
351   "*
353   if (which_alternative == 0)
354     return \"and\\t%0,%1,%2\";
355   else if (which_alternative == 1)
356     return \"andi\\t%0,%1,%x2\";
357   else if (which_alternative == 2)
358     {
359       if ((INTVAL (operands[2]) & 0xffff) == 0xffff)
360         {
361           operands[2] = GEN_INT (INTVAL (operands[2]) >> 16);
362           return \"andoui\\t%0,%1,%x2\";
363         }
364       else
365         {
366           operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffff);
367           return \"andoi\\t%0,%1,%x2\";
368         }
369     }
371   [(set_attr "type"     "arith")
372    (set_attr "mode"     "SI")])
374 (define_expand "iorsi3"
375   [(set (match_operand:SI 0 "register_operand" "=d,d")
376         (ior:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
377                 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
378   ""
379   "")
381 (define_insn ""
382   [(set (match_operand:SI 0 "register_operand" "=d,d")
383         (ior:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
384                 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
385   ""
386   "@
387    or\\t%0,%1,%2
388    ori\\t%0,%1,%x2"
389   [(set_attr "type"     "arith")
390    (set_attr "mode"     "SI")])
392 (define_expand "xorsi3"
393   [(set (match_operand:SI 0 "register_operand" "=d,d")
394         (xor:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
395                 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
396   ""
397   "")
399 (define_insn ""
400   [(set (match_operand:SI 0 "register_operand" "=d,d")
401         (xor:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
402                 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
403   ""
404   "@
405    xor\\t%0,%1,%2
406    xori\\t%0,%1,%x2"
407   [(set_attr "type"     "arith")
408    (set_attr "mode"     "SI")])
410 (define_insn "*norsi3"
411   [(set (match_operand:SI 0 "register_operand" "=d")
412         (and:SI (not:SI (match_operand:SI 1 "register_operand" "d"))
413                 (not:SI (match_operand:SI 2 "register_operand" "d"))))]
414   ""
415   "nor\\t%0,%z1,%z2"
416   [(set_attr "type"     "arith")
417    (set_attr "mode"     "SI")])
420 ;;  ....................
422 ;;      ZERO EXTENSION
424 ;;  ....................
426 ;; Extension insns.
427 ;; Those for integer source operand are ordered widest source type first.
429 (define_expand "zero_extendhisi2"
430   [(set (match_operand:SI 0 "register_operand" "")
431         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
432   ""
433   "")
435 (define_insn ""
436   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
437         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "d,R,m")))]
438   ""
439   "*
441   if (which_alternative == 0)
442     return \"andi\\t%0,%1,0xffff\";
443   else
444     return iq2000_move_1word (operands, insn, TRUE);
446   [(set_attr "type"     "arith,load,load")
447    (set_attr "mode"     "SI")
448    (set_attr "length"   "4,4,8")])
450 (define_expand "zero_extendqihi2"
451   [(set (match_operand:HI 0 "register_operand" "")
452         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
453   ""
454   "")
456 (define_insn ""
457   [(set (match_operand:HI 0 "register_operand" "=d,d,d")
458         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,R,m")))]
459   ""
460   "*
462   if (which_alternative == 0)
463     return \"andi\\t%0,%1,0x00ff\";
464   else
465     return iq2000_move_1word (operands, insn, TRUE);
467   [(set_attr "type"     "arith,load,load")
468    (set_attr "mode"     "HI")
469    (set_attr "length"   "4,4,8")])
471 (define_expand "zero_extendqisi2"
472   [(set (match_operand:SI 0 "register_operand" "")
473         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
474   ""
475   "")
477 (define_insn ""
478   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
479         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "d,R,m")))]
480   ""
481   "*
483   if (which_alternative == 0)
484     return \"andi\\t%0,%1,0x00ff\";
485   else
486     return iq2000_move_1word (operands, insn, TRUE);
488   [(set_attr "type"     "arith,load,load")
489    (set_attr "mode"     "SI")
490    (set_attr "length"   "4,4,8")])
493 ;;  ....................
495 ;;      SIGN EXTENSION
497 ;;  ....................
499 ;; Extension insns.
500 ;; Those for integer source operand are ordered widest source type first.
502 ;; These patterns originally accepted general_operands, however, slightly
503 ;; better code is generated by only accepting register_operands, and then
504 ;; letting combine generate the lh and lb insns.
506 (define_expand "extendhisi2"
507   [(set (match_operand:SI 0 "register_operand" "")
508         (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
509   ""
510   "
512   if (optimize && GET_CODE (operands[1]) == MEM)
513     operands[1] = force_not_mem (operands[1]);
515   if (GET_CODE (operands[1]) != MEM)
516     {
517       rtx op1   = gen_lowpart (SImode, operands[1]);
518       rtx temp  = gen_reg_rtx (SImode);
519       rtx shift = GEN_INT (16);
521       emit_insn (gen_ashlsi3 (temp, op1, shift));
522       emit_insn (gen_ashrsi3 (operands[0], temp, shift));
523       DONE;
524     }
527 (define_insn "extendhisi2_internal"
528   [(set (match_operand:SI 0 "register_operand" "=d,d")
529         (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,m")))]
530   ""
531   "* return iq2000_move_1word (operands, insn, FALSE);"
532   [(set_attr "type"     "load")
533    (set_attr "mode"     "SI")
534    (set_attr "length"   "4,8")])
536 (define_expand "extendqihi2"
537   [(set (match_operand:HI 0 "register_operand" "")
538         (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
539   ""
540   "
542   if (optimize && GET_CODE (operands[1]) == MEM)
543     operands[1] = force_not_mem (operands[1]);
545   if (GET_CODE (operands[1]) != MEM)
546     {
547       rtx op0   = gen_lowpart (SImode, operands[0]);
548       rtx op1   = gen_lowpart (SImode, operands[1]);
549       rtx temp  = gen_reg_rtx (SImode);
550       rtx shift = GEN_INT (24);
552       emit_insn (gen_ashlsi3 (temp, op1, shift));
553       emit_insn (gen_ashrsi3 (op0, temp, shift));
554       DONE;
555     }
558 (define_insn "extendqihi2_internal"
559   [(set (match_operand:HI 0 "register_operand" "=d,d")
560         (sign_extend:HI (match_operand:QI 1 "memory_operand" "R,m")))]
561   ""
562   "* return iq2000_move_1word (operands, insn, FALSE);"
563   [(set_attr "type"     "load")
564    (set_attr "mode"     "SI")
565    (set_attr "length"   "4,8")])
568 (define_expand "extendqisi2"
569   [(set (match_operand:SI 0 "register_operand" "")
570         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
571   ""
572   "
574   if (optimize && GET_CODE (operands[1]) == MEM)
575     operands[1] = force_not_mem (operands[1]);
577   if (GET_CODE (operands[1]) != MEM)
578     {
579       rtx op1   = gen_lowpart (SImode, operands[1]);
580       rtx temp  = gen_reg_rtx (SImode);
581       rtx shift = GEN_INT (24);
583       emit_insn (gen_ashlsi3 (temp, op1, shift));
584       emit_insn (gen_ashrsi3 (operands[0], temp, shift));
585       DONE;
586     }
589 (define_insn "extendqisi2_insn"
590   [(set (match_operand:SI 0 "register_operand" "=d,d")
591         (sign_extend:SI (match_operand:QI 1 "memory_operand" "R,m")))]
592   ""
593   "* return iq2000_move_1word (operands, insn, FALSE);"
594   [(set_attr "type"     "load")
595    (set_attr "mode"     "SI")
596    (set_attr "length"   "4,8")])
599 ;;  ........................
601 ;;      BIT FIELD EXTRACTION
603 ;;  ........................
605 (define_insn "extzv"
606   [(set (match_operand:SI 0 "register_operand" "=r")
607         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
608                          (match_operand:SI 2 "const_int_operand" "O")
609                          (match_operand:SI 3 "const_int_operand" "O")))]
610   ""
611   "*
613   int value[4];
614   value[2] = INTVAL (operands[2]);
615   value[3] = INTVAL (operands[3]);
616   operands[2] = GEN_INT ((value[3]));
617   operands[3] = GEN_INT ((32 - value[2]));
618   return \"ram\\t%0,%1,%2,%3,0x0\";  
620   [(set_attr "type" "arith")])
623 ;;  ....................
625 ;;      DATA MOVEMENT
627 ;;  ....................
629 /* Take care of constants that don't fit in single instruction */
630 (define_split
631   [(set (match_operand:SI 0 "register_operand" "")
632         (match_operand:SI 1 "general_operand" ""))]
633   "(reload_in_progress || reload_completed)
634    && large_int (operands[1], SImode)"
636   [(set (match_dup 0 )
637         (high:SI (match_dup 1)))
638    (set (match_dup 0 )
639         (lo_sum:SI (match_dup 0)
640                    (match_dup 1)))]
643 ;; ??? iq2000_move_1word has support for HIGH, so this pattern may be
644 ;; unnecessary.
646 (define_insn "high"
647   [(set (match_operand:SI 0 "register_operand" "=r")
648         (high:SI (match_operand:SI 1 "immediate_operand" "")))]
649   ""
650   "lui\\t%0,%%hi(%1) # high"
651   [(set_attr "type"     "move")])
653 (define_insn "low"
654   [(set (match_operand:SI 0 "register_operand" "=r")
655         (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
656                    (match_operand:SI 2 "immediate_operand" "")))]
657   ""
658   "addiu\\t%0,%1,%%lo(%2) # low"
659   [(set_attr "type"     "arith")
660    (set_attr "mode"     "SI")])
662 ;; 32-bit Integer moves
664 (define_split
665   [(set (match_operand:SI 0 "register_operand" "")
666         (match_operand:SI 1 "large_int" ""))]
667   "reload_in_progress | reload_completed"
668   [(set (match_dup 0)
669         (match_dup 2))
670    (set (match_dup 0)
671         (ior:SI (match_dup 0)
672                 (match_dup 3)))]
673   "
675   operands[2] = GEN_INT (trunc_int_for_mode (INTVAL (operands[1])
676                                              & BITMASK_UPPER16,
677                                              SImode));
678   operands[3] = GEN_INT (INTVAL (operands[1]) & BITMASK_LOWER16);
681 ;; Unlike most other insns, the move insns can't be split with
682 ;; different predicates, because register spilling and other parts of
683 ;; the compiler, have memoized the insn number already.
685 (define_expand "movsi"
686   [(set (match_operand:SI 0 "nonimmediate_operand" "")
687         (match_operand:SI 1 "general_operand" ""))]
688   ""
689   "
691   if (iq2000_check_split (operands[1], SImode))
692     {
693       enum machine_mode mode = GET_MODE (operands[0]);
694       rtx tem = ((reload_in_progress | reload_completed)
695                  ? operands[0] : gen_reg_rtx (mode));
697       emit_insn (gen_rtx_SET (VOIDmode, tem,
698                               gen_rtx_HIGH (mode, operands[1])));
700       operands[1] = gen_rtx_LO_SUM (mode, tem, operands[1]);
701     }
703   if ((reload_in_progress | reload_completed) == 0
704       && !register_operand (operands[0], SImode)
705       && !register_operand (operands[1], SImode)
706       && (GET_CODE (operands[1]) != CONST_INT
707           || INTVAL (operands[1]) != 0))
708     {
709       rtx temp = force_reg (SImode, operands[1]);
710       emit_move_insn (operands[0], temp);
711       DONE;
712     }
714   /* Take care of constants that don't fit in single instruction */
715   if ((reload_in_progress || reload_completed)
716       && CONSTANT_P (operands[1])
717       && GET_CODE (operands[1]) != HIGH
718       && GET_CODE (operands[1]) != LO_SUM
719       && ! SMALL_INT_UNSIGNED (operands[1]))
720     {
721       rtx tem = ((reload_in_progress | reload_completed)
722                  ? operands[0] : gen_reg_rtx (SImode));
724       emit_insn (gen_rtx_SET (VOIDmode, tem,
725                               gen_rtx_HIGH (SImode, operands[1])));
726       operands[1] = gen_rtx_LO_SUM (SImode, tem, operands[1]);
727     }
730 ;; The difference between these two is whether or not ints are allowed
731 ;; in FP registers (off by default, use -mdebugh to enable).
733 (define_insn "movsi_internal2"
734   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,R,m,*d,*z,*x,*d,*x,*d")
735         (match_operand:SI 1 "move_operand" "d,S,IKL,Mnis,R,m,dJ,dJ,*z,*d,J,*x,*d,*a"))]
736   "(register_operand (operands[0], SImode)
737        || register_operand (operands[1], SImode)
738        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
739   "* return iq2000_move_1word (operands, insn, FALSE);"
740   [(set_attr "type"     "move,load,arith,arith,load,load,store,store,xfer,xfer,move,move,move,move")
741    (set_attr "mode"     "SI")
742    (set_attr "length"   "4,8,4,8,4,8,4,8,4,4,4,4,4,4")])
744 ;; 16-bit Integer moves
746 ;; Unlike most other insns, the move insns can't be split with
747 ;; different predicates, because register spilling and other parts of
748 ;; the compiler, have memoized the insn number already.
749 ;; Unsigned loads are used because BYTE_LOADS_ZERO_EXTEND is defined
751 (define_expand "movhi"
752   [(set (match_operand:HI 0 "nonimmediate_operand" "")
753         (match_operand:HI 1 "general_operand" ""))]
754   ""
755   "
757   if ((reload_in_progress | reload_completed) == 0
758       && !register_operand (operands[0], HImode)
759       && !register_operand (operands[1], HImode)
760       && ((GET_CODE (operands[1]) != CONST_INT
761           || INTVAL (operands[1]) != 0)))
762     {
763       rtx temp = force_reg (HImode, operands[1]);
764       emit_move_insn (operands[0], temp);
765       DONE;
766     }
769 ;; The difference between these two is whether or not ints are allowed
770 ;; in FP registers (off by default, use -mdebugh to enable).
772 (define_insn "movhi_internal2"
773   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,R,m,*d,*z,*x,*d")
774         (match_operand:HI 1 "general_operand"       "d,IK,R,m,dJ,dJ,*z,*d,*d,*x"))]
775   "(register_operand (operands[0], HImode)
776        || register_operand (operands[1], HImode)
777        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
778   "* return iq2000_move_1word (operands, insn, TRUE);"
779   [(set_attr "type"     "move,arith,load,load,store,store,xfer,xfer,move,move")
780    (set_attr "mode"     "HI")
781    (set_attr "length"   "4,4,4,8,4,8,4,4,4,4")])
783 ;; 8-bit Integer moves
785 ;; Unlike most other insns, the move insns can't be split with
786 ;; different predicates, because register spilling and other parts of
787 ;; the compiler, have memoized the insn number already.
788 ;; Unsigned loads are used because BYTE_LOADS_ZERO_EXTEND is defined
790 (define_expand "movqi"
791   [(set (match_operand:QI 0 "nonimmediate_operand" "")
792         (match_operand:QI 1 "general_operand" ""))]
793   ""
794   "
796   if ((reload_in_progress | reload_completed) == 0
797       && !register_operand (operands[0], QImode)
798       && !register_operand (operands[1], QImode)
799       && (GET_CODE (operands[1]) != CONST_INT
800           || INTVAL (operands[1]) != 0))
801     {
802       rtx temp = force_reg (QImode, operands[1]);
803       emit_move_insn (operands[0], temp);
804       DONE;
805     }
808 ;; The difference between these two is whether or not ints are allowed
809 ;; in FP registers (off by default, use -mdebugh to enable).
811 (define_insn "movqi_internal2"
812   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,m,*d,*z,*x,*d")
813         (match_operand:QI 1 "general_operand"       "d,IK,R,m,dJ,dJ,*z,*d,*d,*x"))]
814   "(register_operand (operands[0], QImode)
815        || register_operand (operands[1], QImode)
816        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
817   "* return iq2000_move_1word (operands, insn, TRUE);"
818   [(set_attr "type"     "move,arith,load,load,store,store,xfer,xfer,move,move")
819    (set_attr "mode"     "QI")
820    (set_attr "length"   "4,4,4,8,4,8,4,4,4,4")])
822 ;; 32-bit floating point moves
824 (define_expand "movsf"
825   [(set (match_operand:SF 0 "general_operand" "")
826         (match_operand:SF 1 "general_operand" ""))]
827   ""
828   "
830   if (!reload_in_progress
831       && !reload_completed
832       && GET_CODE (operands[0]) == MEM
833       && (GET_CODE (operands[1]) == MEM
834          || GET_CODE (operands[1]) == CONST_DOUBLE))
835     operands[1] = copy_to_mode_reg (SFmode, operands[1]);
837   /* Take care of reg <- SF constant */
838   if ( const_double_operand (operands[1], GET_MODE (operands[1]) ) )
839     {
840       emit_insn (gen_movsf_high (operands[0], operands[1]));
841       emit_insn (gen_movsf_lo_sum (operands[0], operands[0], operands[1]));
842       DONE;
843     }
846 (define_insn "movsf_lo_sum"
847   [(set (match_operand:SF 0 "register_operand" "=r")
848         (lo_sum:SF (match_operand:SF 1 "register_operand" "r")
849                    (match_operand:SF 2 "const_double_operand" "")))]
850   ""
851   "*
853   REAL_VALUE_TYPE r;
854   long i;
856   REAL_VALUE_FROM_CONST_DOUBLE (r, operands[2]);
857   REAL_VALUE_TO_TARGET_SINGLE (r, i);
858   operands[2] = GEN_INT (i);
859   return \"addiu\\t%0,%1,%%lo(%2) # low\";
861   [(set_attr "length" "4")
862    (set_attr "type" "arith")])
864 (define_insn "movsf_high"
865   [(set (match_operand:SF 0 "register_operand" "=r")
866         (high:SF (match_operand:SF 1 "const_double_operand" "")))]
867   ""
868   "*
870   REAL_VALUE_TYPE r;
871   long i;
873   REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
874   REAL_VALUE_TO_TARGET_SINGLE (r, i);
875   operands[1] = GEN_INT (i);
876   return \"lui\\t%0,%%hi(%1) # high\";
878   [(set_attr "length" "4")
879    (set_attr "type" "arith")])
881 (define_insn "*movsf_internal"
882   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m")
883         (match_operand:SF 1 "nonimmediate_operand" "r,m,r"))]
884   "!memory_operand (operands[0], SFmode) || !memory_operand (operands[1], SFmode)"
885   "*
887   iq2000_fill_delay_slot (\"\", DELAY_LOAD, operands, insn);  
888   if (which_alternative == 0)
889     return \"or\\t%0,%1,%1\";
890   else if (which_alternative == 1)
891     return \"lw\\t%0,%1\";
892   else if (which_alternative == 2)
893     return \"sw\\t%1,%0\";
895   [(set_attr "length" "4,4,4")
896    (set_attr "type" "arith,load,store")]
900 ;;  ....................
902 ;;      SHIFTS
904 ;;  ....................
906 (define_expand "ashlsi3"
907   [(set (match_operand:SI 0 "register_operand" "=d")
908         (ashift:SI (match_operand:SI 1 "register_operand" "d")
909                    (match_operand:SI 2 "arith_operand" "dI")))]
910   ""
911   "")
913 (define_insn "ashlsi3_internal1"
914   [(set (match_operand:SI 0 "register_operand" "=d")
915         (ashift:SI (match_operand:SI 1 "register_operand" "d")
916                    (match_operand:SI 2 "arith_operand" "dI")))]
917   ""
918   "*
920   if (GET_CODE (operands[2]) == CONST_INT)
921     {
922       operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
923       return \"sll\\t%0,%1,%2\";
924     }
925   else
926     return \"sllv\\t%0,%1,%2\";
928   [(set_attr "type"     "arith")
929    (set_attr "mode"     "SI")])
931 (define_expand "ashrsi3"
932   [(set (match_operand:SI 0 "register_operand" "=d")
933         (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
934                      (match_operand:SI 2 "arith_operand" "dI")))]
935   ""
936   "")
938 (define_insn "ashrsi3_internal1"
939   [(set (match_operand:SI 0 "register_operand" "=d")
940         (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
941                      (match_operand:SI 2 "arith_operand" "dI")))]
942   ""
943   "*
945   if (GET_CODE (operands[2]) == CONST_INT)
946     {
947       operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
948       return \"sra\\t%0,%1,%2\";
949     }
950   else
951     return \"srav\\t%0,%1,%2\";
953   [(set_attr "type"     "arith")
954    (set_attr "mode"     "SI")])
956 (define_expand "lshrsi3"
957   [(set (match_operand:SI 0 "register_operand" "=d")
958         (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
959                      (match_operand:SI 2 "arith_operand" "dI")))]
960   ""
961   "")
963 (define_insn "lshrsi3_internal1"
964   [(set (match_operand:SI 0 "register_operand" "=d")
965         (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
966                      (match_operand:SI 2 "arith_operand" "dI")))]
967   ""
968   "*
970   if (GET_CODE (operands[2]) == CONST_INT)
971     {
972       operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
973       return \"srl\\t%0,%1,%2\";
974     }
975   else
976     return \"srlv\\t%0,%1,%2\";
978   [(set_attr "type"     "arith")
979    (set_attr "mode"     "SI")])
981 ;; Rotate Right
982 (define_insn "rotrsi3"
983   [(set (match_operand:SI 0 "register_operand" "=r")
984         (rotatert:SI (match_operand:SI 1 "register_operand" "r")
985                      (match_operand:SI 2 "uns_arith_operand" "O")))]
986   ""
987   "ram %0,%1,%2,0x0,0x0"
988   [(set_attr "type" "arith")])
992 ;;  ....................
994 ;;      COMPARISONS
996 ;;  ....................
998 ;; Flow here is rather complex:
1000 ;;  1)  The cmp{si,di,sf,df} routine is called.  It deposits the
1001 ;;      arguments into the branch_cmp array, and the type into
1002 ;;      branch_type.  No RTL is generated.
1004 ;;  2)  The appropriate branch define_expand is called, which then
1005 ;;      creates the appropriate RTL for the comparison and branch.
1006 ;;      Different CC modes are used, based on what type of branch is
1007 ;;      done, so that we can constrain things appropriately.  There
1008 ;;      are assumptions in the rest of GCC that break if we fold the
1009 ;;      operands into the branches for integer operations, and use cc0
1010 ;;      for floating point, so we use the fp status register instead.
1011 ;;      If needed, an appropriate temporary is created to hold the
1012 ;;      of the integer compare.
1014 (define_expand "cmpsi"
1015   [(set (cc0)
1016         (compare:CC (match_operand:SI 0 "register_operand" "")
1017                     (match_operand:SI 1 "arith_operand" "")))]
1018   ""
1019   "
1021   if (operands[0])              /* avoid unused code message */
1022     {
1023       branch_cmp[0] = operands[0];
1024       branch_cmp[1] = operands[1];
1025       branch_type = CMP_SI;
1026       DONE;
1027     }
1030 (define_expand "tstsi"
1031   [(set (cc0)
1032         (match_operand:SI 0 "register_operand" ""))]
1033   ""
1034   "
1036   if (operands[0])              /* avoid unused code message */
1037     {
1038       branch_cmp[0] = operands[0];
1039       branch_cmp[1] = const0_rtx;
1040       branch_type = CMP_SI;
1041       DONE;
1042     }
1046 ;;  ....................
1048 ;;      CONDITIONAL BRANCHES
1050 ;;  ....................
1052 ;; Conditional branches on comparisons with zero.
1054 (define_insn "branch_zero"
1055   [(set (pc)
1056         (if_then_else
1057          (match_operator:SI 0 "cmp_op"
1058                             [(match_operand:SI 2 "register_operand" "d")
1059                              (const_int 0)])
1060         (label_ref (match_operand 1 "" ""))
1061         (pc)))]
1062   ""
1063   "*
1065   return iq2000_output_conditional_branch (insn,
1066                                          operands,
1067                                          /*two_operands_p=*/0,
1068                                          /*float_p=*/0,
1069                                          /*inverted_p=*/0,
1070                                          get_attr_length (insn));
1072   [(set_attr "type"     "branch")
1073    (set_attr "mode"     "none")])
1075 (define_insn "branch_zero_inverted"
1076   [(set (pc)
1077         (if_then_else
1078          (match_operator:SI 0 "cmp_op"
1079                             [(match_operand:SI 2 "register_operand" "d")
1080                              (const_int 0)])
1081         (pc)
1082         (label_ref (match_operand 1 "" ""))))]
1083   ""
1084   "*
1086   return iq2000_output_conditional_branch (insn,
1087                                          operands,
1088                                          /*two_operands_p=*/0,
1089                                          /*float_p=*/0,
1090                                          /*inverted_p=*/1,
1091                                          get_attr_length (insn));
1093   [(set_attr "type"     "branch")
1094    (set_attr "mode"     "none")])
1096 ;; Conditional branch on equality comparison.
1098 (define_insn "branch_equality"
1099   [(set (pc)
1100         (if_then_else
1101          (match_operator:SI 0 "equality_op"
1102                             [(match_operand:SI 2 "register_operand" "d")
1103                              (match_operand:SI 3 "register_operand" "d")])
1104          (label_ref (match_operand 1 "" ""))
1105          (pc)))]
1106   ""
1107   "*
1109   return iq2000_output_conditional_branch (insn,
1110                                          operands,
1111                                          /*two_operands_p=*/1,
1112                                          /*float_p=*/0,
1113                                          /*inverted_p=*/0,
1114                                          get_attr_length (insn));
1116   [(set_attr "type"     "branch")
1117    (set_attr "mode"     "none")])
1119 (define_insn "branch_equality_inverted"
1120   [(set (pc)
1121         (if_then_else
1122          (match_operator:SI 0 "equality_op"
1123                             [(match_operand:SI 2 "register_operand" "d")
1124                              (match_operand:SI 3 "register_operand" "d")])
1125          (pc)
1126          (label_ref (match_operand 1 "" ""))))]
1127   ""
1128   "*
1130   return iq2000_output_conditional_branch (insn,
1131                                          operands,
1132                                          /*two_operands_p=*/1,
1133                                          /*float_p=*/0,
1134                                          /*inverted_p=*/1,
1135                                          get_attr_length (insn));
1137   [(set_attr "type"     "branch")
1138    (set_attr "mode"     "none")])
1140 (define_expand "beq"
1141   [(set (pc)
1142         (if_then_else (eq:CC (cc0)
1143                              (const_int 0))
1144                       (label_ref (match_operand 0 "" ""))
1145                       (pc)))]
1146   ""
1147   "
1149   if (operands[0])              /* avoid unused code warning */
1150     {
1151       gen_conditional_branch (operands, EQ);
1152       DONE;
1153     }
1156 (define_expand "bne"
1157   [(set (pc)
1158         (if_then_else (ne:CC (cc0)
1159                              (const_int 0))
1160                       (label_ref (match_operand 0 "" ""))
1161                       (pc)))]
1162   ""
1163   "
1165   if (operands[0])              /* avoid unused code warning */
1166     {
1167       gen_conditional_branch (operands, NE);
1168       DONE;
1169     }
1172 (define_expand "bgt"
1173   [(set (pc)
1174         (if_then_else (gt:CC (cc0)
1175                              (const_int 0))
1176                       (label_ref (match_operand 0 "" ""))
1177                       (pc)))]
1178   ""
1179   "
1181   if (operands[0])              /* avoid unused code warning */
1182     {
1183       gen_conditional_branch (operands, GT);
1184       DONE;
1185     }
1188 (define_expand "bge"
1189   [(set (pc)
1190         (if_then_else (ge:CC (cc0)
1191                              (const_int 0))
1192                       (label_ref (match_operand 0 "" ""))
1193                       (pc)))]
1194   ""
1195   "
1197   if (operands[0])              /* avoid unused code warning */
1198     {
1199       gen_conditional_branch (operands, GE);
1200       DONE;
1201     }
1204 (define_expand "blt"
1205   [(set (pc)
1206         (if_then_else (lt:CC (cc0)
1207                              (const_int 0))
1208                       (label_ref (match_operand 0 "" ""))
1209                       (pc)))]
1210   ""
1211   "
1213   if (operands[0])              /* avoid unused code warning */
1214     {
1215       gen_conditional_branch (operands, LT);
1216       DONE;
1217     }
1220 (define_expand "ble"
1221   [(set (pc)
1222         (if_then_else (le:CC (cc0)
1223                              (const_int 0))
1224                       (label_ref (match_operand 0 "" ""))
1225                       (pc)))]
1226   ""
1227   "
1229   if (operands[0])              /* avoid unused code warning */
1230     {
1231       gen_conditional_branch (operands, LE);
1232       DONE;
1233     }
1236 (define_expand "bgtu"
1237   [(set (pc)
1238         (if_then_else (gtu:CC (cc0)
1239                               (const_int 0))
1240                       (label_ref (match_operand 0 "" ""))
1241                       (pc)))]
1242   ""
1243   "
1245   if (operands[0])              /* avoid unused code warning */
1246     {
1247       gen_conditional_branch (operands, GTU);
1248       DONE;
1249     }
1252 (define_expand "bgeu"
1253   [(set (pc)
1254         (if_then_else (geu:CC (cc0)
1255                               (const_int 0))
1256                       (label_ref (match_operand 0 "" ""))
1257                       (pc)))]
1258   ""
1259   "
1261   if (operands[0])              /* avoid unused code warning */
1262     {
1263       gen_conditional_branch (operands, GEU);
1264       DONE;
1265     }
1269 (define_expand "bltu"
1270   [(set (pc)
1271         (if_then_else (ltu:CC (cc0)
1272                               (const_int 0))
1273                       (label_ref (match_operand 0 "" ""))
1274                       (pc)))]
1275   ""
1276   "
1278   if (operands[0])              /* avoid unused code warning */
1279     {
1280       gen_conditional_branch (operands, LTU);
1281       DONE;
1282     }
1285 (define_expand "bleu"
1286   [(set (pc)
1287         (if_then_else (leu:CC (cc0)
1288                               (const_int 0))
1289                       (label_ref (match_operand 0 "" ""))
1290                       (pc)))]
1291   ""
1292   "
1294   if (operands[0])              /* avoid unused code warning */
1295     {
1296       gen_conditional_branch (operands, LEU);
1297       DONE;
1298     }
1301 ;; Recognize bbi and bbin instructions.  These use two unusual template
1302 ;; patterns, %Ax and %Px.  %Ax outputs an 'i' if operand `x' is a LABEL_REF
1303 ;; otherwise it outputs an 'in'.  %Px does nothing if `x' is PC 
1304 ;; and outputs the operand if `x' is a LABEL_REF.
1306 (define_insn ""
1307   [(set (pc)
1308         (if_then_else
1309          (ne (sign_extract:SI (match_operand:SI 0 "register_operand" "r")
1310                               (const_int 1)
1311                               (match_operand:SI 1 "arith_operand" "I"))
1312              (const_int 0))
1313          (match_operand 2 "pc_or_label_operand" "")
1314          (match_operand 3 "pc_or_label_operand" "")))]
1315   ""
1316   "bb%A2\\t%0(31-%1),%P2%P3"
1317   [(set_attr "length" "4")
1318    (set_attr "type" "branch")])
1320 (define_insn ""
1321   [(set (pc)
1322         (if_then_else
1323          (eq (sign_extract:SI (match_operand:SI 0 "register_operand" "r")
1324                               (const_int 1)
1325                               (match_operand:SI 1 "arith_operand" "I"))
1326              (const_int 0))
1327          (match_operand 2 "pc_or_label_operand" "")
1328          (match_operand 3 "pc_or_label_operand" "")))]
1329   ""
1330   "bb%A3\\t%0(31-%1),%P2%P3"
1331   [(set_attr "length" "4")
1332    (set_attr "type" "branch")])
1334 (define_insn ""
1335   [(set (pc)
1336         (if_then_else
1337          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1338                               (const_int 1)
1339                               (match_operand:SI 1 "arith_operand" "I"))
1340              (const_int 0))
1341          (match_operand 2 "pc_or_label_operand" "")
1342          (match_operand 3 "pc_or_label_operand" "")))]
1343   ""
1344   "bb%A2\\t%0(31-%1),%P2%P3"
1345   [(set_attr "length" "4")
1346    (set_attr "type" "branch")])
1348 (define_insn ""
1349   [(set (pc)
1350         (if_then_else
1351          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1352                               (const_int 1)
1353                               (match_operand:SI 1 "arith_operand" "I"))
1354              (const_int 0))
1355          (match_operand 2 "pc_or_label_operand" "")
1356          (match_operand 3 "pc_or_label_operand" "")))]
1357   ""
1358   "bb%A3\\t%0(31-%1),%P2%P3"
1359   [(set_attr "length" "4")
1360    (set_attr "type" "branch")])
1362 (define_insn ""
1363   [(set (pc)
1364         (if_then_else
1365          (eq (and:SI (match_operand:SI 0 "register_operand" "r")
1366                      (match_operand:SI 1 "power_of_2_operand" "I"))
1367               (const_int 0))
1368          (match_operand 2 "pc_or_label_operand" "")
1369          (match_operand 3 "pc_or_label_operand" "")))]
1370   ""
1371   "bb%A3\\t%0(%p1),%P2%P3"
1372   [(set_attr "length" "4")
1373    (set_attr "type" "branch")])
1375 (define_insn ""
1376   [(set (pc)
1377         (if_then_else
1378          (ne (and:SI (match_operand:SI 0 "register_operand" "r")
1379                      (match_operand:SI 1 "power_of_2_operand" "I"))
1380              (const_int 0))
1381          (match_operand 2 "pc_or_label_operand" "")
1382          (match_operand 3 "pc_or_label_operand" "")))]
1383   ""
1384   "bb%A2\\t%0(%p1),%P2%P3"
1385   [(set_attr "length" "4")
1386    (set_attr "type" "branch")])
1389 ;;  ....................
1391 ;;      SETTING A REGISTER FROM A COMPARISON
1393 ;;  ....................
1395 (define_expand "seq"
1396   [(set (match_operand:SI 0 "register_operand" "=d")
1397         (eq:SI (match_dup 1)
1398                (match_dup 2)))]
1399   ""
1400   "
1402   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1403     FAIL;
1405   /* set up operands from compare.  */
1406   operands[1] = branch_cmp[0];
1407   operands[2] = branch_cmp[1];
1409   gen_int_relational (EQ, operands[0], operands[1], operands[2], (int *)0);
1410   DONE;
1414 (define_insn "seq_si_zero"
1415   [(set (match_operand:SI 0 "register_operand" "=d")
1416         (eq:SI (match_operand:SI 1 "register_operand" "d")
1417                (const_int 0)))]
1418   ""
1419   "sltiu\\t%0,%1,1"
1420   [(set_attr "type"     "arith")
1421    (set_attr "mode"     "SI")])
1423 (define_expand "sne"
1424   [(set (match_operand:SI 0 "register_operand" "=d")
1425         (ne:SI (match_dup 1)
1426                (match_dup 2)))]
1427   ""
1428   "
1430   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1431     FAIL;
1433   /* set up operands from compare.  */
1434   operands[1] = branch_cmp[0];
1435   operands[2] = branch_cmp[1];
1437   gen_int_relational (NE, operands[0], operands[1], operands[2], (int *)0);
1438   DONE;
1441 (define_insn "sne_si_zero"
1442   [(set (match_operand:SI 0 "register_operand" "=d")
1443         (ne:SI (match_operand:SI 1 "register_operand" "d")
1444                (const_int 0)))]
1445   ""
1446   "sltu\\t%0,%.,%1"
1447   [(set_attr "type"     "arith")
1448    (set_attr "mode"     "SI")])
1450 (define_expand "sgt"
1451   [(set (match_operand:SI 0 "register_operand" "=d")
1452         (gt:SI (match_dup 1)
1453                (match_dup 2)))]
1454   ""
1455   "
1457   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1458     FAIL;
1460   /* set up operands from compare.  */
1461   operands[1] = branch_cmp[0];
1462   operands[2] = branch_cmp[1];
1464   gen_int_relational (GT, operands[0], operands[1], operands[2], (int *)0);
1465   DONE;
1468 (define_insn "sgt_si"
1469   [(set (match_operand:SI 0 "register_operand" "=d,=d")
1470         (gt:SI (match_operand:SI 1 "register_operand" "d,d")
1471                (match_operand:SI 2 "reg_or_0_operand" "d,J")))]
1472   ""
1473   "@
1474    slt\\t%0,%z2,%1
1475    slt\\t%0,%z2,%1"
1476   [(set_attr "type"     "arith,arith")
1477    (set_attr "mode"     "SI,SI")])
1479 (define_expand "sge"
1480   [(set (match_operand:SI 0 "register_operand" "=d")
1481         (ge:SI (match_dup 1)
1482                (match_dup 2)))]
1483   ""
1484   "
1486   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1487     FAIL;
1489   /* set up operands from compare.  */
1490   operands[1] = branch_cmp[0];
1491   operands[2] = branch_cmp[1];
1493   gen_int_relational (GE, operands[0], operands[1], operands[2], (int *)0);
1494   DONE;
1497 (define_expand "slt"
1498   [(set (match_operand:SI 0 "register_operand" "=d")
1499         (lt:SI (match_dup 1)
1500                (match_dup 2)))]
1501   ""
1502   "
1504   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1505     FAIL;
1507   /* set up operands from compare.  */
1508   operands[1] = branch_cmp[0];
1509   operands[2] = branch_cmp[1];
1511   gen_int_relational (LT, operands[0], operands[1], operands[2], (int *)0);
1512   DONE;
1515 (define_insn "slt_si"
1516   [(set (match_operand:SI 0 "register_operand" "=d,=d")
1517         (lt:SI (match_operand:SI 1 "register_operand" "d,d")
1518                (match_operand:SI 2 "arith_operand" "d,I")))]
1519   ""
1520   "@
1521    slt\\t%0,%1,%2
1522    slti\\t%0,%1,%2"
1523   [(set_attr "type"     "arith,arith")
1524    (set_attr "mode"     "SI,SI")])
1526 (define_expand "sle"
1527   [(set (match_operand:SI 0 "register_operand" "=d")
1528         (le:SI (match_dup 1)
1529                (match_dup 2)))]
1530   ""
1531   "
1533   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1534     FAIL;
1536   /* set up operands from compare.  */
1537   operands[1] = branch_cmp[0];
1538   operands[2] = branch_cmp[1];
1540   gen_int_relational (LE, operands[0], operands[1], operands[2], (int *)0);
1541   DONE;
1544 (define_insn "sle_si_const"
1545   [(set (match_operand:SI 0 "register_operand" "=d")
1546         (le:SI (match_operand:SI 1 "register_operand" "d")
1547                (match_operand:SI 2 "small_int" "I")))]
1548   "INTVAL (operands[2]) < 32767"
1549   "*
1551   operands[2] = GEN_INT (INTVAL (operands[2])+1);
1552   return \"slti\\t%0,%1,%2\";
1554   [(set_attr "type"     "arith")
1555    (set_attr "mode"     "SI")])
1557 (define_expand "sgtu"
1558   [(set (match_operand:SI 0 "register_operand" "=d")
1559         (gtu:SI (match_dup 1)
1560                 (match_dup 2)))]
1561   ""
1562   "
1564   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1565     FAIL;
1567   /* set up operands from compare.  */
1568   operands[1] = branch_cmp[0];
1569   operands[2] = branch_cmp[1];
1571   gen_int_relational (GTU, operands[0], operands[1], operands[2], (int *)0);
1572   DONE;
1575 (define_insn "sgtu_si"
1576   [(set (match_operand:SI 0 "register_operand" "=d")
1577         (gtu:SI (match_operand:SI 1 "register_operand" "d")
1578                 (match_operand:SI 2 "reg_or_0_operand" "dJ")))]
1579   ""
1580   "sltu\\t%0,%z2,%1"
1581   [(set_attr "type"     "arith")
1582    (set_attr "mode"     "SI")])
1584 (define_insn ""
1585   [(set (match_operand:SI 0 "register_operand" "=t")
1586         (gtu:SI (match_operand:SI 1 "register_operand" "d")
1587                 (match_operand:SI 2 "register_operand" "d")))]
1588   ""
1589   "sltu\\t%2,%1"
1590   [(set_attr "type"     "arith")
1591    (set_attr "mode"     "SI")])
1593 (define_expand "sgeu"
1594   [(set (match_operand:SI 0 "register_operand" "=d")
1595         (geu:SI (match_dup 1)
1596                 (match_dup 2)))]
1597   ""
1598   "
1600   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1601     FAIL;
1603   /* set up operands from compare.  */
1604   operands[1] = branch_cmp[0];
1605   operands[2] = branch_cmp[1];
1607   gen_int_relational (GEU, operands[0], operands[1], operands[2], (int *)0);
1608   DONE;
1611 (define_expand "sltu"
1612   [(set (match_operand:SI 0 "register_operand" "=d")
1613         (ltu:SI (match_dup 1)
1614                 (match_dup 2)))]
1615   ""
1616   "
1618   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1619     FAIL;
1621   /* set up operands from compare.  */
1622   operands[1] = branch_cmp[0];
1623   operands[2] = branch_cmp[1];
1625   gen_int_relational (LTU, operands[0], operands[1], operands[2], (int *)0);
1626   DONE;
1629 (define_insn "sltu_si"
1630   [(set (match_operand:SI 0 "register_operand" "=d,=d")
1631         (ltu:SI (match_operand:SI 1 "register_operand" "d,d")
1632                 (match_operand:SI 2 "arith_operand" "d,I")))]
1633   ""
1634   "@
1635    sltu\\t%0,%1,%2
1636    sltiu\\t%0,%1,%2"
1637   [(set_attr "type"     "arith,arith")
1638    (set_attr "mode"     "SI,SI")])
1640 (define_expand "sleu"
1641   [(set (match_operand:SI 0 "register_operand" "=d")
1642         (leu:SI (match_dup 1)
1643                 (match_dup 2)))]
1644   ""
1645   "
1647   if (branch_type != CMP_SI && (branch_type != CMP_DI))
1648     FAIL;
1650   /* set up operands from compare.  */
1651   operands[1] = branch_cmp[0];
1652   operands[2] = branch_cmp[1];
1654   gen_int_relational (LEU, operands[0], operands[1], operands[2], (int *)0);
1655   DONE;
1658 (define_insn "sleu_si_const"
1659   [(set (match_operand:SI 0 "register_operand" "=d")
1660         (leu:SI (match_operand:SI 1 "register_operand" "d")
1661                 (match_operand:SI 2 "small_int" "I")))]
1662   "INTVAL (operands[2]) < 32767"
1663   "*
1665   operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
1666   return \"sltiu\\t%0,%1,%2\";
1668   [(set_attr "type"     "arith")
1669    (set_attr "mode"     "SI")])
1673 ;;  ....................
1675 ;;      UNCONDITIONAL BRANCHES
1677 ;;  ....................
1679 ;; Unconditional branches.
1681 (define_insn "jump"
1682   [(set (pc)
1683         (label_ref (match_operand 0 "" "")))]
1684   ""
1685   "*
1687   if (GET_CODE (operands[0]) == REG)
1688     return \"j\\t%0\";
1689   return \"j\\t%l0\";
1690   /* return \"b\\t%l0\";*/
1692   [(set_attr "type"     "jump")
1693    (set_attr "mode"     "none")])
1695 (define_expand "indirect_jump"
1696   [(set (pc) (match_operand 0 "register_operand" "d"))]
1697   ""
1698   "
1700   rtx dest;
1702   if (operands[0])              /* eliminate unused code warnings */
1703     {
1704       dest = operands[0];
1705       if (GET_CODE (dest) != REG || GET_MODE (dest) != Pmode)
1706         operands[0] = copy_to_mode_reg (Pmode, dest);
1708       if (!(Pmode == DImode))
1709         emit_jump_insn (gen_indirect_jump_internal1 (operands[0]));
1710       else
1711         emit_jump_insn (gen_indirect_jump_internal2 (operands[0]));
1713       DONE;
1714     }
1717 (define_insn "indirect_jump_internal1"
1718   [(set (pc) (match_operand:SI 0 "register_operand" "d"))]
1719   "!(Pmode == DImode)"
1720   "j\\t%0"
1721   [(set_attr "type"     "jump")
1722    (set_attr "mode"     "none")])
1724 (define_expand "tablejump"
1725   [(set (pc)
1726         (match_operand 0 "register_operand" "d"))
1727    (use (label_ref (match_operand 1 "" "")))]
1728   ""
1729   "
1731   if (operands[0])              /* eliminate unused code warnings */
1732     {
1733       if (GET_MODE (operands[0]) != Pmode)
1734         abort ();
1736       if (!(Pmode == DImode))
1737         emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
1738       else
1739         emit_jump_insn (gen_tablejump_internal2 (operands[0], operands[1]));
1741       DONE;
1742     }
1745 (define_insn "tablejump_internal1"
1746   [(set (pc)
1747         (match_operand:SI 0 "register_operand" "d"))
1748    (use (label_ref (match_operand 1 "" "")))]
1749   "!(Pmode == DImode)"
1750   "j\\t%0"
1751   [(set_attr "type"     "jump")
1752    (set_attr "mode"     "none")])
1754 (define_expand "tablejump_internal3"
1755   [(parallel [(set (pc)
1756                    (plus:SI (match_operand:SI 0 "register_operand" "d")
1757                             (label_ref:SI (match_operand 1 "" ""))))
1758               (use (label_ref:SI (match_dup 1)))])]
1759   ""
1760   "")
1762 ;;; Make sure that this only matches the insn before ADDR_DIFF_VEC.  Otherwise
1763 ;;; it is not valid.  ??? With the USE, the condition tests may not be required
1764 ;;; any longer.
1766 ;;; ??? The length depends on the ABI.  It is two for o32, and one for n32.
1767 ;;; We just use the conservative number here.
1769 (define_insn ""
1770   [(set (pc)
1771         (plus:SI (match_operand:SI 0 "register_operand" "d")
1772                  (label_ref:SI (match_operand 1 "" ""))))
1773    (use (label_ref:SI (match_dup 1)))]
1774   "!(Pmode == DImode) && next_active_insn (insn) != 0
1775    && GET_CODE (PATTERN (next_active_insn (insn))) == ADDR_DIFF_VEC
1776    && PREV_INSN (next_active_insn (insn)) == operands[1]"
1777   "*
1779   return \"j\\t%0\";
1781   [(set_attr "type"     "jump")
1782    (set_attr "mode"     "none")
1783    (set_attr "length"   "8")])
1786 ;;  ....................
1788 ;;      Function prologue/epilogue
1790 ;;  ....................
1793 (define_expand "prologue"
1794   [(const_int 1)]
1795   ""
1796   "
1798   if (iq2000_isa >= 0)          /* avoid unused code warnings */
1799     {
1800       iq2000_expand_prologue ();
1801       DONE;
1802     }
1805 ;; Block any insns from being moved before this point, since the
1806 ;; profiling call to mcount can use various registers that aren't
1807 ;; saved or used to pass arguments.
1809 (define_insn "blockage"
1810   [(unspec_volatile [(const_int 0)] 0)]
1811   ""
1812   ""
1813   [(set_attr "type"     "unknown")
1814    (set_attr "mode"     "none")
1815    (set_attr "length"   "0")])
1817 (define_expand "epilogue"
1818   [(const_int 2)]
1819   ""
1820   "
1822   if (iq2000_isa >= 0)            /* avoid unused code warnings */
1823     {
1824       iq2000_expand_epilogue ();
1825       DONE;
1826     }
1829 ;; Trivial return.  Make it look like a normal return insn as that
1830 ;; allows jump optimizations to work better .
1831 (define_insn "return"
1832   [(return)]
1833   "iq2000_can_use_return_insn ()"
1834   "j\\t%%31"
1835   [(set_attr "type"     "jump")
1836    (set_attr "mode"     "none")])
1838 ;; Normal return.
1840 (define_insn "return_internal"
1841   [(use (match_operand 0 "pmode_register_operand" ""))
1842    (return)]
1843   ""
1844   "*
1846   return \"j\\t%0\";
1848   [(set_attr "type"     "jump")
1849    (set_attr "mode"     "none")])
1851 (define_insn "eh_return_internal"
1852   [(const_int 4)
1853    (return)
1854    (use (reg:SI 26))
1855    (use (reg:SI 31))]
1856   ""
1857   "j\\t%%26"
1858   [(set_attr "type"     "jump")
1859    (set_attr "mode"     "none")])
1861 (define_expand "eh_return"
1862   [(use (match_operand:SI 0 "register_operand" "r"))]
1863   ""
1864   "
1866   iq2000_expand_eh_return (operands[0]);
1867   DONE;
1872 ;;  ....................
1874 ;;      FUNCTION CALLS
1876 ;;  ....................
1878 ;; calls.c now passes a third argument, make saber happy
1880 (define_expand "call"
1881   [(parallel [(call (match_operand 0 "memory_operand" "m")
1882                     (match_operand 1 "" "i"))
1883               (clobber (reg:SI 31))
1884               (use (match_operand 2 "" ""))             ;; next_arg_reg
1885               (use (match_operand 3 "" ""))])]          ;; struct_value_size_rtx
1886   ""
1887   "
1889   rtx addr;
1891   if (operands[0])              /* eliminate unused code warnings */
1892     {
1893       addr = XEXP (operands[0], 0);
1894       if ((GET_CODE (addr) != REG && (!CONSTANT_ADDRESS_P (addr)))
1895           || ! call_insn_operand (addr, VOIDmode))
1896         XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, addr);
1898       /* In order to pass small structures by value in registers
1899          compatibly with the IQ2000 compiler, we need to shift the value
1900          into the high part of the register.  Function_arg has encoded
1901          a PARALLEL rtx, holding a vector of adjustments to be made
1902          as the next_arg_reg variable, so we split up the insns,
1903          and emit them separately.  */
1905       if (operands[2] != (rtx)0 && GET_CODE (operands[2]) == PARALLEL)
1906         {
1907           rtvec adjust = XVEC (operands[2], 0);
1908           int num = GET_NUM_ELEM (adjust);
1909           int i;
1911           for (i = 0; i < num; i++)
1912             emit_insn (RTVEC_ELT (adjust, i));
1913         }
1915       emit_call_insn (gen_call_internal0 (operands[0], operands[1],
1916                                           gen_rtx_REG (SImode,
1917                                                        GP_REG_FIRST + 31)));
1918       DONE;
1919     }
1922 (define_expand "call_internal0"
1923   [(parallel [(call (match_operand 0 "" "")
1924                     (match_operand 1 "" ""))
1925               (clobber (match_operand:SI 2 "" ""))])]
1926   ""
1927   "")
1929 (define_insn "call_internal1"
1930   [(call (mem (match_operand 0 "call_insn_operand" "ri"))
1931          (match_operand 1 "" "i"))
1932    (clobber (match_operand:SI 2 "register_operand" "=d"))]
1933   ""
1934   "*
1936   register rtx target = operands[0];
1938   if (GET_CODE (target) == CONST_INT)
1939     return \"li\\t%@,%0\\n\\tjalr\\t%2,%@\";
1940   else if (CONSTANT_ADDRESS_P (target))
1941     return \"jal\\t%0\";
1942   else
1943     return \"jalr\\t%2,%0\";
1945   [(set_attr "type"     "call")
1946    (set_attr "mode"     "none")])
1948 ;; calls.c now passes a fourth argument, make saber happy
1950 (define_expand "call_value"
1951   [(parallel [(set (match_operand 0 "register_operand" "=df")
1952                    (call (match_operand 1 "memory_operand" "m")
1953                          (match_operand 2 "" "i")))
1954               (clobber (reg:SI 31))
1955               (use (match_operand 3 "" ""))])]          ;; next_arg_reg
1956   ""
1957   "
1959   rtx addr;
1961   if (operands[0])              /* eliminate unused code warning */
1962     {
1963       addr = XEXP (operands[1], 0);
1964       if ((GET_CODE (addr) != REG && (!CONSTANT_ADDRESS_P (addr)))
1965           || ! call_insn_operand (addr, VOIDmode))
1966         XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, addr);
1968       /* In order to pass small structures by value in registers
1969          compatibly with the IQ2000 compiler, we need to shift the value
1970          into the high part of the register.  Function_arg has encoded
1971          a PARALLEL rtx, holding a vector of adjustments to be made
1972          as the next_arg_reg variable, so we split up the insns,
1973          and emit them separately.  */
1975       if (operands[3] != (rtx)0 && GET_CODE (operands[3]) == PARALLEL)
1976         {
1977           rtvec adjust = XVEC (operands[3], 0);
1978           int num = GET_NUM_ELEM (adjust);
1979           int i;
1981           for (i = 0; i < num; i++)
1982             emit_insn (RTVEC_ELT (adjust, i));
1983         }
1985       if (GET_CODE (operands[0]) == PARALLEL && XVECLEN (operands[0], 0) > 1)
1986         {
1987           emit_call_insn (gen_call_value_multiple_internal0
1988                           (XEXP (XVECEXP (operands[0], 0, 0), 0),
1989                            operands[1], operands[2],
1990                            XEXP (XVECEXP (operands[0], 0, 1), 0),
1991                            gen_rtx_REG (SImode, GP_REG_FIRST + 31)));
1992           DONE;
1993         }
1995       /* We have a call returning a DImode structure in an FP reg.
1996          Strip off the now unnecessary PARALLEL.  */
1997       if (GET_CODE (operands[0]) == PARALLEL)
1998         operands[0] = XEXP (XVECEXP (operands[0], 0, 0), 0);
2000       emit_call_insn (gen_call_value_internal0 (operands[0], operands[1], operands[2],
2001                                                 gen_rtx_REG (SImode,
2002                                                              GP_REG_FIRST + 31)));
2004       DONE;
2005     }
2008 (define_expand "call_value_internal0"
2009   [(parallel [(set (match_operand 0 "" "")
2010                    (call (match_operand 1 "" "")
2011                          (match_operand 2 "" "")))
2012               (clobber (match_operand:SI 3 "" ""))])]
2013   ""
2014   "")
2016 (define_insn "call_value_internal1"
2017   [(set (match_operand 0 "register_operand" "=df")
2018         (call (mem (match_operand 1 "call_insn_operand" "ri"))
2019               (match_operand 2 "" "i")))
2020    (clobber (match_operand:SI 3 "register_operand" "=d"))]
2021   ""
2022   "*
2024   register rtx target = operands[1];
2026   if (GET_CODE (target) == CONST_INT)
2027     return \"li\\t%@,%1\\n\\tjalr\\t%3,%@\";
2028   else if (CONSTANT_ADDRESS_P (target))
2029     return \"jal\\t%1\";
2030   else
2031     return \"jalr\\t%3,%1\";
2033   [(set_attr "type"     "call")
2034    (set_attr "mode"     "none")])
2036 (define_expand "call_value_multiple_internal0"
2037   [(parallel [(set (match_operand 0 "" "")
2038                    (call (match_operand 1 "" "")
2039                          (match_operand 2 "" "")))
2040               (set (match_operand 3 "" "")
2041                    (call (match_dup 1)
2042                          (match_dup 2)))
2043               (clobber (match_operand:SI 4 "" ""))])]
2044   ""
2045   "")
2047 ;; ??? May eventually need all 6 versions of the call patterns with multiple
2048 ;; return values.
2050 (define_insn "call_value_multiple_internal1"
2051   [(set (match_operand 0 "register_operand" "=df")
2052         (call (mem (match_operand 1 "call_insn_operand" "ri"))
2053               (match_operand 2 "" "i")))
2054    (set (match_operand 3 "register_operand" "=df")
2055         (call (mem (match_dup 1))
2056               (match_dup 2)))
2057   (clobber (match_operand:SI 4 "register_operand" "=d"))]
2058   ""
2059   "*
2061   register rtx target = operands[1];
2063   if (GET_CODE (target) == CONST_INT)
2064     return \"li\\t%@,%1\\n\\tjalr\\t%4,%@\";
2065   else if (CONSTANT_ADDRESS_P (target))
2066     return \"jal\\t%1\";
2067   else
2068     return \"jalr\\t%4,%1\";
2070   [(set_attr "type"     "call")
2071    (set_attr "mode"     "none")])
2073 ;; Call subroutine returning any type.
2075 (define_expand "untyped_call"
2076   [(parallel [(call (match_operand 0 "" "")
2077                     (const_int 0))
2078               (match_operand 1 "" "")
2079               (match_operand 2 "" "")])]
2080   ""
2081   "
2083   if (operands[0])              /* silence statement not reached warnings */
2084     {
2085       int i;
2087       emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
2089       for (i = 0; i < XVECLEN (operands[2], 0); i++)
2090         {
2091           rtx set = XVECEXP (operands[2], 0, i);
2092           emit_move_insn (SET_DEST (set), SET_SRC (set));
2093         }
2095       emit_insn (gen_blockage ());
2096       DONE;
2097     }
2101 ;;  ....................
2103 ;;      MISC.
2105 ;;  ....................
2108 (define_insn "nop"
2109   [(const_int 0)]
2110   ""
2111   "nop"
2112   [(set_attr "type"     "nop")
2113    (set_attr "mode"     "none")])
2116 ;; For the rare case where we need to load an address into a register
2117 ;; that can not be recognized by the normal movsi/addsi instructions.
2118 ;; I have no idea how many insns this can actually generate.  It should
2119 ;; be rare, so over-estimating as 10 instructions should not have any
2120 ;; real performance impact.
2121 (define_insn "leasi"
2122   [(set (match_operand:SI 0 "register_operand" "=d")
2123         (match_operand:SI 1 "address_operand" "p"))]
2124   "Pmode == SImode"
2125   "*
2127   rtx xoperands [3];
2129   xoperands[0] = operands[0];
2130   xoperands[1] = XEXP (operands[1], 0);
2131   xoperands[2] = XEXP (operands[1], 1);
2132   output_asm_insn (\"addiu\\t%0,%1,%2\", xoperands);
2133   return \"\";
2135   [(set_attr "type"     "arith")
2136    (set_attr "mode"     "SI")
2137    (set_attr "length"   "40")])
2139 (define_insn "ado16"
2140   [(set (match_operand:SI             0 "register_operand" "=r")
2141         (unspec:SI [(match_operand:SI 1 "register_operand" "r")
2142                     (match_operand:SI 2 "register_operand" "r")]
2143                 UNSPEC_ADO16))]
2144   ""
2145   "ado16\\t%0, %1, %2"
2148 (define_insn "ram"
2149   [(set (match_operand:SI             0 "register_operand" "=r")
2150               (unspec:SI [(match_operand:SI 1 "register_operand" "r")
2151                                 (match_operand:SI 2 "const_int_operand" "I")
2152                                 (match_operand:SI 3 "const_int_operand" "I")
2153                                 (match_operand:SI 4 "const_int_operand" "I")]
2154                      UNSPEC_RAM))]
2155   ""
2156   "ram\\t%0, %1, %2, %3, %4"
2159 (define_insn "chkhdr"
2160   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "=r")
2161                 (match_operand:SI 1 "register_operand" "r")]
2162                 UNSPEC_CHKHDR)]
2163   ""
2164   "* return iq2000_fill_delay_slot (\"chkhdr\\t%0, %1\", DELAY_LOAD, operands, insn);"
2165   [(set_attr "dslot"    "not_in_dslot")]
2168 (define_insn "pkrl"
2169   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2170                 (match_operand:SI 1 "register_operand" "r")]
2171                 UNSPEC_PKRL)]
2172   ""
2173   "* return iq2000_fill_delay_slot (\"pkrl\\t%0, %1\", DELAY_NONE, operands, insn);"
2174   [(set_attr "dslot"    "not_in_dslot")]
2177 (define_insn "cfc0"
2178    [(set (match_operand:SI                0 "register_operand" "=r")
2179     (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2180                 UNSPEC_CFC0))]
2181   ""
2182   "* return iq2000_fill_delay_slot (\"cfc0\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2183   [(set_attr "dslot"    "ok_in_dslot")]
2186 (define_insn "cfc1"
2187    [(set (match_operand:SI                0 "register_operand" "=r")
2188    (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2189                 UNSPEC_CFC1))]
2190   ""
2191   "* return iq2000_fill_delay_slot (\"cfc1\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2192   [(set_attr "dslot"    "ok_in_dslot")]
2195 (define_insn "cfc2"
2196    [(set (match_operand:SI                0 "register_operand" "=r")
2197    (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2198                 UNSPEC_CFC2))]
2199   ""
2200   "* return iq2000_fill_delay_slot (\"cfc2\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2201   [(set_attr "dslot"    "not_in_dslot")]
2204 (define_insn "cfc3"
2205    [(set (match_operand:SI                0 "register_operand" "=r")
2206    (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2207                 UNSPEC_CFC3))]
2208   ""
2209   "* return iq2000_fill_delay_slot (\"cfc3\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2210   [(set_attr "dslot"    "not_in_dslot")]
2213 (define_insn "ctc0"
2214   [(unspec_volatile:SI [(match_operand:SI 0 "reg_or_0_operand" "rJ")
2215                 (match_operand:SI 1 "const_int_operand" "I")]
2216                 UNSPEC_CTC0)]
2217   ""
2218   "* return iq2000_fill_delay_slot (\"ctc0\\t%z0, %%%1\", DELAY_NONE, operands, insn);"
2219   [(set_attr "dslot"    "ok_in_dslot")]
2222 (define_insn "ctc1"
2223   [(unspec_volatile:SI [(match_operand:SI 0 "reg_or_0_operand" "rJ")
2224                 (match_operand:SI 1 "const_int_operand" "I")]
2225                 UNSPEC_CTC1)]
2226   ""
2227   "* return iq2000_fill_delay_slot (\"ctc1\\t%z0, %%%1\", DELAY_NONE, operands, insn);"
2228   [(set_attr "dslot"    "ok_in_dslot")]
2231 (define_insn "ctc2"
2232   [(unspec_volatile:SI [(match_operand:SI 0 "reg_or_0_operand" "rJ")
2233                 (match_operand:SI 1 "const_int_operand" "I")]
2234                 UNSPEC_CTC2)]
2235   ""
2236   "* return iq2000_fill_delay_slot (\"ctc2\\t%z0, %%%1\", DELAY_NONE, operands, insn);"
2237   [(set_attr "dslot"    "ok_in_dslot")]
2240 (define_insn "ctc3"
2241   [(unspec_volatile:SI [(match_operand:SI 0 "reg_or_0_operand" "rJ")
2242                 (match_operand:SI 1 "const_int_operand" "I")]
2243                 UNSPEC_CTC3)]
2244   ""
2245   "* return iq2000_fill_delay_slot (\"ctc3\\t%z0, %%%1\", DELAY_NONE, operands, insn);"
2246   [(set_attr "dslot"    "ok_in_dslot")]
2249 (define_insn "mfc0"
2250    [(set (match_operand:SI                0 "register_operand" "=r")
2251    (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2252                 UNSPEC_MFC0))]
2253   ""
2254   "* return iq2000_fill_delay_slot (\"mfc0\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2255   [(set_attr "dslot"    "ok_in_dslot")]
2258 (define_insn "mfc1"
2259    [(set (match_operand:SI                0 "register_operand" "=r")
2260    (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2261                 UNSPEC_MFC1))]
2262   ""
2263   "* return iq2000_fill_delay_slot (\"mfc1\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2264   [(set_attr "dslot"    "ok_in_dslot")]
2267 (define_insn "mfc2"
2268    [(set (match_operand:SI                0 "register_operand" "=r")
2269    (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2270                 UNSPEC_MFC2))]
2271   ""
2272   "* return iq2000_fill_delay_slot (\"mfc2\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2273   [(set_attr "dslot"    "not_in_dslot")]
2276 (define_insn "mfc3"
2277    [(set (match_operand:SI                0 "register_operand" "=r")
2278    (unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "I")]
2279                 UNSPEC_MFC3))]
2280   ""
2281   "* return iq2000_fill_delay_slot (\"mfc3\\t%0, %%%1\", DELAY_LOAD, operands, insn);"
2282   [(set_attr "dslot"    "not_in_dslot")]
2285 (define_insn "mtc0"
2286   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2287                 (match_operand:SI 1 "const_int_operand" "I")]
2288                 UNSPEC_MTC0)]
2289   ""
2290   "* return iq2000_fill_delay_slot (\"mtc0\\t%0, %%%1\", DELAY_NONE, operands, insn);"
2291   [(set_attr "dslot"    "ok_in_dslot")]
2294 (define_insn "mtc1"
2295   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2296                 (match_operand:SI 1 "const_int_operand" "I")]
2297                 UNSPEC_MTC1)]
2298   ""
2299   "* return iq2000_fill_delay_slot (\"mtc1\\t%0, %%%1\", DELAY_NONE, operands, insn);"
2300   [(set_attr "dslot"    "ok_in_dslot")]
2303 (define_insn "mtc2"
2304   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2305                 (match_operand:SI 1 "const_int_operand" "I")]
2306                 UNSPEC_MTC2)]
2307   ""
2308   "* return iq2000_fill_delay_slot (\"mtc2\\t%0, %%%1\", DELAY_NONE, operands, insn);"
2309   [(set_attr "dslot"    "ok_in_dslot")]
2312 (define_insn "mtc3"
2313   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2314                 (match_operand:SI 1 "const_int_operand" "I")]
2315                 UNSPEC_MTC3)]
2316   ""
2317   "* return iq2000_fill_delay_slot (\"mtc3\\t%0, %%%1\", DELAY_NONE, operands, insn);"
2318   [(set_attr "dslot"    "ok_in_dslot")]
2321 (define_insn "lur"
2322   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2323                 (match_operand:SI 1 "register_operand" "r")]
2324                 UNSPEC_LUR)]
2325   ""
2326   "* return iq2000_fill_delay_slot (\"lur\\t%0, %1\", DELAY_NONE, operands, insn);"
2327   [(set_attr "dslot"    "not_in_dslot")]
2330 (define_insn "rb"
2331   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2332                 (match_operand:SI 1 "register_operand" "r")]
2333                 UNSPEC_RB)]
2334   ""
2335   "* return iq2000_fill_delay_slot (\"rb\\t%0, %1\", DELAY_NONE, operands, insn);"
2336   [(set_attr "dslot"    "not_in_dslot")]
2339 (define_insn "rx"
2340   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2341                 (match_operand:SI 1 "register_operand" "r")]
2342                 UNSPEC_RX)]
2343   ""
2344   "* return iq2000_fill_delay_slot (\"rx\\t%0, %1\", DELAY_NONE, operands, insn);"
2345   [(set_attr "dslot"    "not_in_dslot")]
2348 (define_insn "srrd"
2349   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")]
2350                 UNSPEC_SRRD)]
2351   ""
2352   "* return iq2000_fill_delay_slot (\"srrd\\t%0\", DELAY_NONE, operands, insn);"
2353   [(set_attr "dslot"    "not_in_dslot")]
2356 (define_insn "srwr"
2357   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2358                 (match_operand:SI 1 "register_operand" "r")]
2359                 UNSPEC_SRWR)]
2360   ""
2361   "* return iq2000_fill_delay_slot (\"srwr\\t%0, %1\", DELAY_NONE, operands, insn);"
2362   [(set_attr "dslot"    "not_in_dslot")]
2365 (define_insn "wb"
2366   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2367                 (match_operand:SI 1 "register_operand" "r")]
2368                 UNSPEC_WB)]
2369   ""
2370   "* return iq2000_fill_delay_slot (\"wb\\t%0, %1\", DELAY_NONE, operands, insn);"
2371   [(set_attr "dslot"    "not_in_dslot")]
2374 (define_insn "wx"
2375   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2376                 (match_operand:SI 1 "register_operand" "r")]
2377                 UNSPEC_WX)]
2378   ""
2379   "* return iq2000_fill_delay_slot (\"wx\\t%0, %1\", DELAY_NONE, operands, insn);"
2380   [(set_attr "dslot"    "not_in_dslot")]
2383 (define_insn "luc32"
2384   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2385                 (match_operand:SI 1 "register_operand" "r")]
2386                 UNSPEC_LUC32)]
2387   ""
2388   "* return iq2000_fill_delay_slot (\"luc32\\t%0, %1\", DELAY_NONE, operands, insn);"
2389   [(set_attr "dslot"    "not_in_dslot")]
2392 (define_insn "luc32l"
2393   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2394                 (match_operand:SI 1 "register_operand" "r")]
2395                 UNSPEC_LUC32L)]
2396   ""
2397   "* return iq2000_fill_delay_slot (\"luc32l\\t%0, %1\", DELAY_NONE, operands, insn);"
2398   [(set_attr "dslot"    "not_in_dslot")]
2401 (define_insn "luc64"
2402   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2403                 (match_operand:SI 1 "register_operand" "r")]
2404                 UNSPEC_LUC64)]
2405   ""
2406   "* return iq2000_fill_delay_slot (\"luc64\\t%0, %1\", DELAY_NONE, operands, insn);"
2407   [(set_attr "dslot"    "not_in_dslot")]
2410 (define_insn "luc64l"
2411   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2412                 (match_operand:SI 1 "register_operand" "r")]
2413                 UNSPEC_LUC64L)]
2414   ""
2415   "* return iq2000_fill_delay_slot (\"luc64l\\t%0, %1\", DELAY_NONE, operands, insn);"
2416   [(set_attr "dslot"    "not_in_dslot")]
2419 (define_insn "luk"
2420   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2421                 (match_operand:SI 1 "register_operand" "r")]
2422                 UNSPEC_LUK)]
2423   ""
2424   "* return iq2000_fill_delay_slot (\"luk\\t%0, %1\", DELAY_NONE, operands, insn);"
2425   [(set_attr "dslot"    "ok_in_dslot")]
2428 (define_insn "lulck"
2429   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")]
2430                 UNSPEC_LULCK)]
2431   ""
2432   "* return iq2000_fill_delay_slot (\"lulck\\t%0\", DELAY_NONE, operands, insn);"
2433   [(set_attr "dslot"    "not_in_dslot")]
2436 (define_insn "lum32"
2437   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2438                 (match_operand:SI 1 "register_operand" "r")]
2439                 UNSPEC_LUM32)]
2440   ""
2441   "* return iq2000_fill_delay_slot (\"lum32\\t%0, %1\", DELAY_NONE, operands, insn);"
2442   [(set_attr "dslot"    "not_in_dslot")]
2445 (define_insn "lum32l"
2446   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2447                 (match_operand:SI 1 "register_operand" "r")]
2448                 UNSPEC_LUM32L)]
2449   ""
2450   "* return iq2000_fill_delay_slot (\"lum32l\\t%0, %1\", DELAY_NONE, operands, insn);" 
2451   [(set_attr "dslot"    "not_in_dslot")]
2454 (define_insn "lum64"
2455   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2456                 (match_operand:SI 1 "register_operand" "r")]
2457                 UNSPEC_LUM64)]
2458   ""
2459   "* return iq2000_fill_delay_slot (\"lum64\\t%0, %1\", DELAY_NONE, operands, insn);"
2460   [(set_attr "dslot"    "not_in_dslot")]
2463 (define_insn "lum64l"
2464   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2465                 (match_operand:SI 1 "register_operand" "r")]
2466                 UNSPEC_LUM64L)]
2467   ""
2468   "* return iq2000_fill_delay_slot (\"lum64l\\t%0, %1\", DELAY_NONE, operands, insn);"
2469   [(set_attr "dslot"    "not_in_dslot")]
2472 (define_insn "lurl"
2473   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2474                 (match_operand:SI 1 "register_operand" "r")]
2475                 UNSPEC_LURL)]
2476   ""
2477   "* return iq2000_fill_delay_slot (\"lurl\\t%0, %1\", DELAY_NONE, operands, insn);"
2478   [(set_attr "dslot"    "not_in_dslot")]
2481 (define_insn "mrgb"
2482   [(set (match_operand:SI                 0 "register_operand" "=r")
2483         (unspec_volatile:SI [(match_operand:SI 1 "register_operand" "r")
2484                 (match_operand:SI 2 "register_operand" "r")
2485                 (match_operand:SI 3 "const_int_operand" "I")]
2486                 UNSPEC_MRGB))]
2487   ""
2488   "* return iq2000_fill_delay_slot (\"mrgb\\t%0, %1, %2, %3\", DELAY_LOAD, operands, insn);"
2489   [(set_attr "dslot"    "ok_in_dslot")]
2492 (define_insn "srrdl"
2493   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")]
2494                 UNSPEC_SRRDL)]
2495   ""
2496   "* return iq2000_fill_delay_slot (\"srrdl\\t%0\", DELAY_NONE, operands, insn);"
2497   [(set_attr "dslot"    "not_in_dslot")]
2500 (define_insn "srulck"
2501   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")]
2502                 UNSPEC_SRULCK)]
2503   ""
2504   "* return iq2000_fill_delay_slot (\"srulck\\t%0\", DELAY_NONE, operands, insn);"
2505   [(set_attr "dslot"    "not_in_dslot")]
2508 (define_insn "srwru"
2509   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2510                 (match_operand:SI 1 "register_operand" "r")]
2511                 UNSPEC_SRWRU)]
2512   ""
2513   "* return iq2000_fill_delay_slot (\"srwru\\t%0, %1\", DELAY_NONE, operands, insn);"
2514   [(set_attr "dslot"    "not_in_dslot")]
2517 (define_insn "trapqfl"
2518   [(unspec_volatile:SI [(const_int 1)] UNSPEC_TRAPQFL)]
2519   ""
2520   "* return iq2000_fill_delay_slot (\"trapqfl\", DELAY_NONE, operands, insn);"
2521   [(set_attr "dslot"    "not_in_dslot")]
2524 (define_insn "trapqne"
2525   [(unspec_volatile:SI [(const_int 2)] UNSPEC_TRAPQNE)]
2526   ""
2527   "* return iq2000_fill_delay_slot (\"trapqne\", DELAY_NONE, operands, insn);"
2528   [(set_attr "dslot"    "not_in_dslot")]
2531 (define_insn "traprel"
2532   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")]
2533                 UNSPEC_TRAPREL)]
2534   ""
2535   "* return iq2000_fill_delay_slot (\"traprel %0\", DELAY_NONE, operands, insn);"
2536   [(set_attr "dslot"    "not_in_dslot")]
2539 (define_insn "wbu"
2540   [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")
2541                 (match_operand:SI 1 "register_operand" "r")]
2542                 UNSPEC_WBU)]
2543   ""
2544   "* return iq2000_fill_delay_slot (\"wbu\\t%0, %1\", DELAY_NONE, operands, insn);"
2545   [(set_attr "dslot"    "not_in_dslot")]
2548 (define_insn "syscall"
2549   [(unspec_volatile:SI [(const_int 2)] UNSPEC_SYSCALL)]
2550   ""
2551   "syscall"
2552   [(set_attr "dslot"    "not_in_dslot")]