OSDN Git Service

*** empty log message ***
[pf3gnuchains/gcc-fork.git] / gcc / config / mips / mips.md
1 ;;  Mips.md          Machine Description for MIPS based processors
2 ;;  Contributed by   A. Lichnewsky, lich@inria.inria.fr
3 ;;  Changes by       Michael Meissner, meissner@osf.org
4 ;;  Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
5
6 ;; This file is part of GNU CC.
7
8 ;; GNU CC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
11 ;; any later version.
12
13 ;; GNU CC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU CC; see the file COPYING.  If not, write to
20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 \f
23
24 ;; ....................
25 ;;
26 ;;      Attributes
27 ;;
28 ;; ....................
29
30 ;; Classification of each insn.
31 ;; branch       conditional branch
32 ;; jump         unconditional jump
33 ;; call         unconditional call
34 ;; load         load instruction(s)
35 ;; store        store instruction(s)
36 ;; move         data movement within same register set
37 ;; xfer         transfer to/from coprocessor
38 ;; hilo         transfer of hi/lo registers
39 ;; arith        integer arithmetic instruction
40 ;; darith       double precision integer arithmetic instructions
41 ;; imul         integer multiply
42 ;; idiv         integer divide
43 ;; icmp         integer compare
44 ;; fadd         floating point add/subtract
45 ;; fmul         floating point multiply
46 ;; fdiv         floating point divide
47 ;; fabs         floating point absolute value
48 ;; fneg         floating point negation
49 ;; fcmp         floating point compare
50 ;; fcvt         floating point convert
51 ;; fsqrt        floating point square root
52 ;; multi        multiword sequence (or user asm statements)
53 ;; nop          no operation
54 ;; pic          OSF/rose half pic load
55
56 (define_attr "type"
57   "unknown,branch,jump,call,load,store,move,xfer,hilo,arith,darith,imul,idiv,icmp,fadd,fmul,fdiv,fabs,fneg,fcmp,fcvt,fsqrt,multi,nop,pic"
58   (const_string "unknown"))
59
60 ;; Main data type used by the insn
61 (define_attr "mode" "unknown,none,QI,HI,SI,DI,SF,DF" (const_string "unknown"))
62
63 ;; # instructions (4 bytes each)
64 (define_attr "length" "" (const_int 1))
65
66 ;; whether or not an instruction has a mandatory delay slot
67 (define_attr "dslot" "no,yes"
68   (if_then_else (eq_attr "type" "branch,jump,call,load,xfer,hilo,fcmp,pic")
69                 (const_string "yes")
70                 (const_string "no")))
71
72 ;; Attribute describing the processor
73 (define_attr "cpu" "default,r3000,r4000,r6000"
74   (const
75    (cond [(eq (symbol_ref "mips_cpu") (symbol_ref "PROCESSOR_DEFAULT")) (const_string "default")
76           (eq (symbol_ref "mips_cpu") (symbol_ref "PROCESSOR_R3000"))   (const_string "r3000")
77           (eq (symbol_ref "mips_cpu") (symbol_ref "PROCESSOR_R4000"))   (const_string "r4000")
78           (eq (symbol_ref "mips_cpu") (symbol_ref "PROCESSOR_R6000"))   (const_string "r6000")]
79          (const_string "default"))))
80
81 ;; Attribute defining whether or not we can use the branch-likely instructions
82 ;; (MIPS ISA level 2)
83
84 (define_attr "branch_likely" "no,yes"
85   (const
86    (if_then_else (ge (symbol_ref "mips_isa") (const_int 2))
87                  (const_string "yes")
88                  (const_string "no"))))
89
90
91 ;; Describe a user's asm statement.
92 (define_asm_attributes
93   [(set_attr "type" "multi")])
94
95 \f
96
97 ;; .........................
98 ;;
99 ;;      Delay slots, can't describe load/fcmp/xfer delay slots here
100 ;;
101 ;; .........................
102
103 (define_delay (eq_attr "type" "branch")
104   [(and (eq_attr "dslot" "no") (eq_attr "length" "1"))
105    (nil)
106    (eq_attr "branch_likely" "yes")])
107
108 (define_delay (eq_attr "type" "call,jump")
109   [(and (eq_attr "dslot" "no") (eq_attr "length" "1"))
110    (nil)
111    (nil)])
112
113 \f
114
115 ;; .........................
116 ;;
117 ;;      Functional units
118 ;;
119 ;; .........................
120
121 ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
122 ;                       TEST READY-DELAY BUSY-DELAY [CONFLICT-LIST])
123
124 ;; Make the default case (PROCESSOR_DEFAULT) handle the worst case
125
126 (define_function_unit "memory" 1 0
127   (and (eq_attr "type" "load,pic") (eq_attr "cpu" "!r3000"))
128   3 0)
129
130 (define_function_unit "memory" 1 0
131   (and (eq_attr "type" "load,pic") (eq_attr "cpu" "r3000"))
132   2 0)
133
134 (define_function_unit "memory"   1 0 (eq_attr "type" "store") 1 0)
135
136 (define_function_unit "transfer" 1 0 (eq_attr "type" "xfer")     2 0)
137 (define_function_unit "transfer" 1 0 (eq_attr "type" "hilo")     3 0)
138
139 (define_function_unit "imuldiv"  1 1
140   (and (eq_attr "type" "imul") (eq_attr "cpu" "!r3000,r4000"))
141   17 34)
142
143 (define_function_unit "imuldiv"  1 1
144   (and (eq_attr "type" "imul") (eq_attr "cpu" "r3000"))
145   12 24)
146
147 (define_function_unit "imuldiv" 1 1
148   (and (eq_attr "type" "imul") (eq_attr "cpu" "r4000"))
149   10 20)
150
151 (define_function_unit "imuldiv"  1 1
152   (and (eq_attr "type" "idiv") (eq_attr "cpu" "!r3000,r4000"))
153   38 76)
154
155 (define_function_unit "imuldiv"  1 1
156   (and (eq_attr "type" "idiv") (eq_attr "cpu" "r3000"))
157   35 70)
158
159 (define_function_unit "imuldiv" 1 1
160   (and (eq_attr "type" "idiv") (eq_attr "cpu" "r4000"))
161   69 138)
162
163 (define_function_unit "adder" 1 1
164   (and (eq_attr "type" "fadd") (eq_attr "cpu" "!r3000,r6000"))
165   4 8)
166
167 (define_function_unit "adder" 1 1
168   (and (eq_attr "type" "fadd") (eq_attr "cpu" "r3000"))
169   2 4)
170
171 (define_function_unit "adder" 1 1
172   (and (eq_attr "type" "fadd") (eq_attr "cpu" "r6000"))
173   3 6)
174
175 (define_function_unit "fast" 1 1
176   (and (eq_attr "type" "fabs,fneg") (eq_attr "cpu" "!r3000"))
177   2 4)
178
179 (define_function_unit "fast" 1 1
180   (and (eq_attr "type" "fabs,fneg") (eq_attr "cpu" "r3000"))
181   1 2)
182
183 (define_function_unit "mult" 1 1
184   (and (eq_attr "type" "fmul") (and (eq_attr "mode" "SF") (eq_attr "cpu" "!r3000,r6000")))
185   7 14)
186
187 (define_function_unit "mult" 1 1
188   (and (eq_attr "type" "fmul") (and (eq_attr "mode" "SF") (eq_attr "cpu" "r3000")))
189   4 8)
190
191 (define_function_unit "mult" 1 1
192   (and (eq_attr "type" "fmul") (and (eq_attr "mode" "SF") (eq_attr "cpu" "r6000")))
193   5 10)
194
195 (define_function_unit "mult" 1 1
196   (and (eq_attr "type" "fmul") (and (eq_attr "mode" "DF") (eq_attr "cpu" "!r3000,r6000")))
197   8 16)
198
199 (define_function_unit "mult" 1 1
200   (and (eq_attr "type" "fmul") (and (eq_attr "mode" "DF") (eq_attr "cpu" "r3000")))
201   5 10)
202
203 (define_function_unit "mult" 1 1
204   (and (eq_attr "type" "fmul") (and (eq_attr "mode" "DF") (eq_attr "cpu" "r6000")))
205   6 12)
206
207 (define_function_unit "divide" 1 1
208   (and (eq_attr "type" "fdiv") (and (eq_attr "mode" "SF") (eq_attr "cpu" "!r3000,r6000")))
209   23 46)
210
211 (define_function_unit "divide" 1 1
212   (and (eq_attr "type" "fdiv") (and (eq_attr "mode" "SF") (eq_attr "cpu" "r3000")))
213   12 24)
214
215 (define_function_unit "divide" 1 1
216   (and (eq_attr "type" "fdiv") (and (eq_attr "mode" "SF") (eq_attr "cpu" "r6000")))
217   15 30)
218
219 (define_function_unit "divide" 1 1
220   (and (eq_attr "type" "fdiv") (and (eq_attr "mode" "DF") (eq_attr "cpu" "!r3000,r6000")))
221   36 72)
222
223 (define_function_unit "divide" 1 1
224   (and (eq_attr "type" "fdiv") (and (eq_attr "mode" "DF") (eq_attr "cpu" "r3000")))
225   19 34)
226
227 (define_function_unit "divide" 1 1
228   (and (eq_attr "type" "fdiv") (and (eq_attr "mode" "DF") (eq_attr "cpu" "r6000")))
229   16 32)
230
231 (define_function_unit "sqrt" 1 1 (and (eq_attr "type" "fsqrt") (eq_attr "mode" "SF"))  54 108)
232 (define_function_unit "sqrt" 1 1 (and (eq_attr "type" "fsqrt") (eq_attr "mode" "DF")) 112 224)
233
234 \f
235 ;;
236 ;;  ....................
237 ;;
238 ;;      ADDITION
239 ;;
240 ;;  ....................
241 ;;
242
243 (define_insn "adddf3"
244   [(set (match_operand:DF 0 "register_operand" "=f")
245         (plus:DF (match_operand:DF 1 "register_operand" "f")
246                  (match_operand:DF 2 "register_operand" "f")))]
247   "TARGET_HARD_FLOAT"
248   "add.d\\t%0,%1,%2"
249   [(set_attr "type"     "fadd")
250    (set_attr "mode"     "DF")
251    (set_attr "length"   "1")])
252
253 (define_insn "addsf3"
254   [(set (match_operand:SF 0 "register_operand" "=f")
255         (plus:SF (match_operand:SF 1 "register_operand" "f")
256                  (match_operand:SF 2 "register_operand" "f")))]
257   "TARGET_HARD_FLOAT"
258   "add.s\\t%0,%1,%2"
259   [(set_attr "type"     "fadd")
260    (set_attr "mode"     "SF")
261    (set_attr "length"   "1")])
262
263 (define_insn "addsi3"
264   [(set (match_operand:SI 0 "register_operand" "=d")
265         (plus:SI (match_operand:SI 1 "arith_operand" "%d")
266                  (match_operand:SI 2 "arith_operand" "dI")))]
267   ""
268   "*
269 {
270   return (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
271     ? \"subu\\t%0,%1,%n2\"
272     : \"addu\\t%0,%1,%2\";
273 }"
274   [(set_attr "type"     "arith")
275    (set_attr "mode"     "SI")
276    (set_attr "length"   "1")])
277
278 (define_expand "adddi3"
279   [(parallel [(set (match_operand:DI 0 "register_operand" "")
280                    (plus:DI (match_operand:DI 1 "register_operand" "")
281                             (match_operand:DI 2 "arith_operand" "")))
282               (clobber (match_dup 3))])]
283   "!TARGET_DEBUG_G_MODE"
284   "operands[3] = gen_reg_rtx (SImode);")
285
286 (define_insn "adddi3_internal_1"
287   [(set (match_operand:DI 0 "register_operand" "=d,&d")
288         (plus:DI (match_operand:DI 1 "register_operand" "0,d")
289                  (match_operand:DI 2 "register_operand" "d,d")))
290    (clobber (match_operand:SI 3 "register_operand" "=d,d"))]
291   "!TARGET_DEBUG_G_MODE"
292   "*
293 {
294   return (REGNO (operands[0]) == REGNO (operands[1])
295           && REGNO (operands[0]) == REGNO (operands[2]))
296     ? \"srl\\t%3,%L0,31\;sll\\t%M0,%M0,1\;sll\\t%L0,%L1,1\;addu\\t%M0,%M0,%3\"
297     : \"addu\\t%L0,%L1,%L2\;sltu\\t%3,%L0,%L2\;addu\\t%M0,%M1,%M2\;addu\\t%M0,%M0,%3\";
298 }"
299   [(set_attr "type"     "darith,darith")
300    (set_attr "mode"     "DI,DI")
301    (set_attr "length"   "4,4")])
302
303 (define_split
304   [(set (match_operand:DI 0 "register_operand" "")
305         (plus:DI (match_operand:DI 1 "register_operand" "")
306                  (match_operand:DI 2 "register_operand" "")))
307    (clobber (match_operand:SI 3 "register_operand" ""))]
308   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
309    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
310    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
311    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))
312    && (REGNO (operands[0]) != REGNO (operands[1])
313        || REGNO (operands[0]) != REGNO (operands[2]))"
314
315   [(set (subreg:SI (match_dup 0) 0)
316         (plus:SI (subreg:SI (match_dup 1) 0)
317                  (subreg:SI (match_dup 2) 0)))
318
319    (set (match_dup 3)
320         (ltu:CC (subreg:SI (match_dup 0) 0)
321                 (subreg:SI (match_dup 2) 0)))
322
323    (set (subreg:SI (match_dup 0) 1)
324         (plus:SI (subreg:SI (match_dup 1) 1)
325                  (subreg:SI (match_dup 2) 1)))
326
327    (set (subreg:SI (match_dup 0) 1)
328         (plus:SI (subreg:SI (match_dup 0) 1)
329                  (match_dup 3)))]
330   "")
331
332 (define_split
333   [(set (match_operand:DI 0 "register_operand" "")
334         (plus:DI (match_operand:DI 1 "register_operand" "")
335                  (match_operand:DI 2 "register_operand" "")))
336    (clobber (match_operand:SI 3 "register_operand" ""))]
337   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
338    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
339    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
340    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))
341    && (REGNO (operands[0]) != REGNO (operands[1])
342        || REGNO (operands[0]) != REGNO (operands[2]))"
343
344   [(set (subreg:SI (match_dup 0) 1)
345         (plus:SI (subreg:SI (match_dup 1) 1)
346                  (subreg:SI (match_dup 2) 1)))
347
348    (set (match_dup 3)
349         (ltu:CC (subreg:SI (match_dup 0) 1)
350                 (subreg:SI (match_dup 2) 1)))
351
352    (set (subreg:SI (match_dup 0) 0)
353         (plus:SI (subreg:SI (match_dup 1) 0)
354                  (subreg:SI (match_dup 2) 0)))
355
356    (set (subreg:SI (match_dup 0) 0)
357         (plus:SI (subreg:SI (match_dup 0) 0)
358                  (match_dup 3)))]
359   "")
360
361 (define_insn "adddi3_internal_2"
362   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
363         (plus:DI (match_operand:DI 1 "register_operand" "%d,%d,%d")
364                  (match_operand:DI 2 "small_int" "P,J,N")))
365    (clobber (match_operand:SI 3 "register_operand" "=d,d,d"))]
366   "!TARGET_DEBUG_G_MODE && INTVAL (operands[2]) != -32768"
367   "@
368    addu\\t%L0,%L1,%2\;sltu\\t%3,%L0,%2\;addu\\t%M0,%M1,%3
369    move\\t%L0,%L1\;move\\t%M0,%M1
370    subu\\t%L0,%L1,%n2\;sltu\\t%3,%L0,%2\;subu\\t%M0,%M1,1\;addu\\t%M0,%M0,%3"
371   [(set_attr "type"     "darith,darith,darith")
372    (set_attr "mode"     "DI,DI,DI")
373    (set_attr "length"   "3,2,4")])
374
375 (define_split
376   [(set (match_operand:DI 0 "register_operand" "")
377         (plus:DI (match_operand:DI 1 "register_operand" "")
378                  (match_operand:DI 2 "small_int" "")))
379    (clobber (match_operand:SI 3 "register_operand" "=d"))]
380   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
381    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
382    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
383    && INTVAL (operands[2]) > 0"
384
385   [(set (subreg:SI (match_dup 0) 0)
386         (plus:SI (subreg:SI (match_dup 1) 0)
387                  (match_dup 2)))
388
389    (set (match_dup 3)
390         (ltu:CC (subreg:SI (match_dup 0) 0)
391                 (match_dup 2)))
392
393    (set (subreg:SI (match_dup 0) 1)
394         (plus:SI (subreg:SI (match_dup 1) 1)
395                  (match_dup 3)))]
396   "")
397
398 (define_split
399   [(set (match_operand:DI 0 "register_operand" "")
400         (plus:DI (match_operand:DI 1 "register_operand" "")
401                  (match_operand:DI 2 "small_int" "")))
402    (clobber (match_operand:SI 3 "register_operand" "=d"))]
403   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
404    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
405    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
406    && INTVAL (operands[2]) > 0"
407
408   [(set (subreg:SI (match_dup 0) 1)
409         (plus:SI (subreg:SI (match_dup 1) 1)
410                  (match_dup 2)))
411
412    (set (match_dup 3)
413         (ltu:CC (subreg:SI (match_dup 0) 1)
414                 (match_dup 2)))
415
416    (set (subreg:SI (match_dup 0) 0)
417         (plus:SI (subreg:SI (match_dup 1) 0)
418                  (match_dup 3)))]
419   "")
420 \f
421 ;;
422 ;;  ....................
423 ;;
424 ;;      SUBTRACTION
425 ;;
426 ;;  ....................
427 ;;
428
429 (define_insn "subdf3"
430   [(set (match_operand:DF 0 "register_operand" "=f")
431         (minus:DF (match_operand:DF 1 "register_operand" "f")
432                   (match_operand:DF 2 "register_operand" "f")))]
433   "TARGET_HARD_FLOAT"
434   "sub.d\\t%0,%1,%2"
435   [(set_attr "type"     "fadd")
436    (set_attr "mode"     "DF")
437    (set_attr "length"   "1")])
438
439 (define_insn "subsf3"
440   [(set (match_operand:SF 0 "register_operand" "=f")
441         (minus:SF (match_operand:SF 1 "register_operand" "f")
442                   (match_operand:SF 2 "register_operand" "f")))]
443   "TARGET_HARD_FLOAT"
444   "sub.s\\t%0,%1,%2"
445   [(set_attr "type"     "fadd")
446    (set_attr "mode"     "SF")
447    (set_attr "length"   "1")])
448
449 (define_insn "subsi3"
450   [(set (match_operand:SI 0 "register_operand" "=d")
451         (minus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
452                   (match_operand:SI 2 "arith_operand" "dI")))]
453   ""
454   "*
455 {
456   return (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
457     ? \"addu\\t%0,%z1,%n2\"
458     : \"subu\\t%0,%z1,%2\";
459 }"
460   [(set_attr "type"     "arith")
461    (set_attr "mode"     "SI")
462    (set_attr "length"   "1")])
463
464 (define_expand "subdi3"
465   [(parallel [(set (match_operand:DI 0 "register_operand" "=d")
466                    (minus:DI (match_operand:DI 1 "register_operand" "d")
467                              (match_operand:DI 2 "register_operand" "d")))
468               (clobber (match_dup 3))])]
469   "!TARGET_DEBUG_G_MODE"
470   "operands[3] = gen_reg_rtx (SImode);")
471
472 (define_insn "subdi3_internal"
473   [(set (match_operand:DI 0 "register_operand" "=d")
474         (minus:DI (match_operand:DI 1 "register_operand" "d")
475                   (match_operand:DI 2 "register_operand" "d")))
476    (clobber (match_operand:SI 3 "register_operand" "=d"))]
477   "!TARGET_DEBUG_G_MODE"
478   "sltu\\t%3,%L1,%L2\;subu\\t%L0,%L1,%L2\;subu\\t%M0,%M1,%M2\;subu\\t%M0,%M0,%3"
479   [(set_attr "type"     "darith")
480    (set_attr "mode"     "DI")
481    (set_attr "length"   "4")])
482
483 (define_split
484   [(set (match_operand:DI 0 "register_operand" "")
485         (minus:DI (match_operand:DI 1 "register_operand" "")
486                   (match_operand:DI 2 "register_operand" "")))
487    (clobber (match_operand:SI 3 "register_operand" ""))]
488   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
489    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
490    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
491    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
492
493   [(set (match_dup 3)
494         (ltu:CC (subreg:SI (match_dup 1) 0)
495                 (subreg:SI (match_dup 2) 0)))
496
497    (set (subreg:SI (match_dup 0) 0)
498         (minus:SI (subreg:SI (match_dup 1) 0)
499                   (subreg:SI (match_dup 2) 0)))
500
501    (set (subreg:SI (match_dup 0) 1)
502         (minus:SI (subreg:SI (match_dup 1) 1)
503                   (subreg:SI (match_dup 2) 1)))
504
505    (set (subreg:SI (match_dup 0) 1)
506         (minus:SI (subreg:SI (match_dup 0) 1)
507                   (match_dup 3)))]
508   "")
509
510 (define_split
511   [(set (match_operand:DI 0 "register_operand" "")
512         (minus:DI (match_operand:DI 1 "register_operand" "")
513                   (match_operand:DI 2 "register_operand" "")))
514    (clobber (match_operand:SI 3 "register_operand" ""))]
515   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
516    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
517    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
518    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
519
520   [(set (match_dup 3)
521         (ltu:CC (subreg:SI (match_dup 1) 1)
522                 (subreg:SI (match_dup 2) 1)))
523
524    (set (subreg:SI (match_dup 0) 1)
525         (minus:SI (subreg:SI (match_dup 1) 1)
526                   (subreg:SI (match_dup 2) 1)))
527
528    (set (subreg:SI (match_dup 0) 0)
529         (minus:SI (subreg:SI (match_dup 1) 0)
530                   (subreg:SI (match_dup 2) 0)))
531
532    (set (subreg:SI (match_dup 0) 0)
533         (minus:SI (subreg:SI (match_dup 0) 0)
534                   (match_dup 3)))]
535   "")
536
537 (define_insn "subdi3_internal_2"
538   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
539         (minus:DI (match_operand:DI 1 "register_operand" "d,d,d")
540                   (match_operand:DI 2 "small_int" "P,J,N")))
541    (clobber (match_operand:SI 3 "register_operand" "=d,d,d"))]
542   "!TARGET_DEBUG_G_MODE && INTVAL (operands[2]) != -32768"
543   "@
544    sltu\\t%3,%L1,%2\;subu\\t%L0,%L1,%2\;subu\\t%M0,%M1,%3
545    move\\t%L0,%L1\;move\\t%M0,%M1
546    sltu\\t%3,%L1,%2\;subu\\t%L0,%L1,%2\;subu\\t%M0,%M1,1\;subu\\t%M0,%M0,%3"
547   [(set_attr "type"     "darith,darith,darith")
548    (set_attr "mode"     "DI,DI,DI")
549    (set_attr "length"   "3,2,4")])
550
551 (define_split
552   [(set (match_operand:DI 0 "register_operand" "")
553         (minus:DI (match_operand:DI 1 "register_operand" "")
554                   (match_operand:DI 2 "small_int" "")))
555    (clobber (match_operand:SI 3 "register_operand" ""))]
556   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
557    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
558    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
559    && INTVAL (operands[2]) > 0"
560
561   [(set (match_dup 3)
562         (ltu:CC (subreg:SI (match_dup 1) 0)
563                 (match_dup 2)))
564
565    (set (subreg:SI (match_dup 0) 0)
566         (minus:SI (subreg:SI (match_dup 1) 0)
567                   (match_dup 2)))
568
569    (set (subreg:SI (match_dup 0) 1)
570         (minus:SI (subreg:SI (match_dup 1) 1)
571                   (match_dup 3)))]
572   "")
573
574 (define_split
575   [(set (match_operand:DI 0 "register_operand" "")
576         (minus:DI (match_operand:DI 1 "register_operand" "")
577                   (match_operand:DI 2 "small_int" "")))
578    (clobber (match_operand:SI 3 "register_operand" ""))]
579   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
580    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
581    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
582    && INTVAL (operands[2]) > 0"
583
584   [(set (match_dup 3)
585         (ltu:CC (subreg:SI (match_dup 1) 1)
586                 (match_dup 2)))
587
588    (set (subreg:SI (match_dup 0) 1)
589         (minus:SI (subreg:SI (match_dup 1) 1)
590                   (match_dup 2)))
591
592    (set (subreg:SI (match_dup 0) 0)
593         (minus:SI (subreg:SI (match_dup 1) 0)
594                   (match_dup 3)))]
595   "")
596
597 \f
598 ;;
599 ;;  ....................
600 ;;
601 ;;      MULTIPLICATION
602 ;;
603 ;;  ....................
604 ;;
605
606 (define_insn "muldf3"
607   [(set (match_operand:DF 0 "register_operand" "=f")
608         (mult:DF (match_operand:DF 1 "register_operand" "f")
609                  (match_operand:DF 2 "register_operand" "f")))]
610   "TARGET_HARD_FLOAT"
611   "mul.d\\t%0,%1,%2"
612   [(set_attr "type"     "fmul")
613    (set_attr "mode"     "DF")
614    (set_attr "length"   "1")])
615
616 (define_insn "mulsf3"
617   [(set (match_operand:SF 0 "register_operand" "=f")
618         (mult:SF (match_operand:SF 1 "register_operand" "f")
619                  (match_operand:SF 2 "register_operand" "f")))]
620   "TARGET_HARD_FLOAT"
621   "mul.s\\t%0,%1,%2"
622   [(set_attr "type"     "fmul")
623    (set_attr "mode"     "SF")
624    (set_attr "length"   "1")])
625
626 (define_insn "mulsi3"
627   [(set (match_operand:SI 0 "register_operand" "=d")
628         (mult:SI (match_operand:SI 1 "register_operand" "d")
629                  (match_operand:SI 2 "register_operand" "d")))
630    (clobber (reg:SI 64))
631    (clobber (reg:SI 65))]
632   ""
633   "*
634 {
635   rtx xoperands[10];
636
637   xoperands[0] = operands[0];
638   xoperands[1] = gen_rtx (REG, SImode, LO_REGNUM);
639
640   output_asm_insn (\"mult\\t%1,%2\", operands);
641   output_asm_insn (mips_move_1word (xoperands, insn), xoperands);
642   return \"\";
643 }"
644   [(set_attr "type"     "imul")
645    (set_attr "mode"     "SI")
646    (set_attr "length"   "3")])          ;; mult + mflo + delay
647
648 (define_split
649   [(set (match_operand:SI 0 "register_operand" "")
650         (mult:SI (match_operand:SI 1 "register_operand" "")
651                  (match_operand:SI 2 "register_operand" "")))
652    (clobber (reg:SI 64))
653    (clobber (reg:SI 65))]
654   ""
655   [(parallel [(set (reg:SI 65)          ;; low register
656                    (mult:SI (match_dup 1)
657                             (match_dup 2)))
658               (clobber (reg:SI 64))])
659    (set (match_dup 0)
660         (reg:SI 65))]
661   "")
662
663 (define_insn "mulsi3_internal"
664   [(set (reg:SI 65)             ;; low register
665         (mult:SI (match_operand:SI 0 "register_operand" "d")
666                  (match_operand:SI 1 "register_operand" "d")))
667    (clobber (reg:SI 64))]
668   ""
669   "mult\\t%0,%1"
670   [(set_attr "type"     "imul")
671    (set_attr "mode"     "SI")
672    (set_attr "length"   "1")])
673
674 (define_insn "mulsidi3"
675   [(set (match_operand:DI 0 "register_operand" "=d")
676         (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
677                  (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))
678    (clobber (reg:DI 64))]
679   ""
680   "*
681 {
682   rtx xoperands[10];
683
684   xoperands[0] = operands[0];
685   xoperands[1] = gen_rtx (REG, DImode, MD_REG_FIRST);
686
687   output_asm_insn (\"mult\\t%1,%2\", operands);
688   output_asm_insn (mips_move_2words (xoperands, insn), xoperands);
689   return \"\";
690 }"
691   [(set_attr "type"     "imul")
692    (set_attr "mode"     "SI")
693    (set_attr "length"   "4")])          ;; mult + mflo + mfhi + delay
694
695 (define_insn "umulsidi3"
696   [(set (match_operand:DI 0 "register_operand" "=d")
697         (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
698                  (zero_extend:DI (match_operand:SI 2 "register_operand" "d"))))
699    (clobber (reg:DI 64))]
700   ""
701   "*
702 {
703   rtx xoperands[10];
704
705   xoperands[0] = operands[0];
706   xoperands[1] = gen_rtx (REG, DImode, MD_REG_FIRST);
707
708   output_asm_insn (\"multu\\t%1,%2\", operands);
709   output_asm_insn (mips_move_2words (xoperands, insn), xoperands);
710   return \"\";
711 }"
712   [(set_attr "type"     "imul")
713    (set_attr "mode"     "SI")
714    (set_attr "length"   "4")])          ;; mult + mflo + mfhi + delay
715
716 \f
717 ;;
718 ;;  ....................
719 ;;
720 ;;      DIVISION and REMAINDER
721 ;;
722 ;;  ....................
723 ;;
724
725 (define_insn "divdf3"
726   [(set (match_operand:DF 0 "register_operand" "=f")
727         (div:DF (match_operand:DF 1 "register_operand" "f")
728                 (match_operand:DF 2 "register_operand" "f")))]
729   "TARGET_HARD_FLOAT"
730   "div.d\\t%0,%1,%2"
731   [(set_attr "type"     "fdiv")
732    (set_attr "mode"     "DF")
733    (set_attr "length"   "1")])
734
735 (define_insn "divsf3"
736   [(set (match_operand:SF 0 "register_operand" "=f")
737         (div:SF (match_operand:SF 1 "register_operand" "f")
738                 (match_operand:SF 2 "register_operand" "f")))]
739   "TARGET_HARD_FLOAT"
740   "div.s\\t%0,%1,%2"
741   [(set_attr "type"     "fdiv")
742    (set_attr "mode"     "SF")
743    (set_attr "length"   "1")])
744
745 ;; If optimizing, prefer the divmod functions over separate div and
746 ;; mod functions, since this will allow using one instruction for both
747 ;; the quotient and remainder.  At present, the divmod is not moved out
748 ;; of loops if it is constant within the loop, so allow -mdebugc to
749 ;; use the old method of doing things.
750
751 ;; 64 is the multiply/divide hi register
752 ;; 65 is the multiply/divide lo register
753
754 (define_insn "divmodsi4"
755   [(parallel [(set (match_operand:SI 0 "register_operand" "=d")
756                    (div:SI (match_operand:SI 1 "register_operand" "d")
757                            (match_operand:SI 2 "register_operand" "d")))
758               (set (match_operand:SI 3 "register_operand" "=d")
759                    (mod:SI (match_dup 1)
760                            (match_dup 2)))
761               (clobber (reg:SI 64))
762               (clobber (reg:SI 65))])]
763   "optimize && !TARGET_DEBUG_C_MODE"
764   "*
765 {
766   if (find_reg_note (insn, REG_UNUSED, operands[3]))
767     return \"div\\t%0,%1,%2\";
768
769   if (find_reg_note (insn, REG_UNUSED, operands[0]))
770     return \"rem\\t%3,%1,%2\";
771
772   return \"div\\t%0,%1,%2\;mfhi\\t%3\";
773 }"
774   [(set_attr "type"     "idiv")
775    (set_attr "mode"     "SI")
776    (set_attr "length"   "13")])         ;; various tests for dividing by 0 and such
777
778 (define_insn "udivmodsi4"
779   [(parallel [(set (match_operand:SI 0 "register_operand" "=d")
780                    (udiv:SI (match_operand:SI 1 "register_operand" "d")
781                             (match_operand:SI 2 "register_operand" "d")))
782               (set (match_operand:SI 3 "register_operand" "=d")
783                    (umod:SI (match_dup 1)
784                             (match_dup 2)))
785               (clobber (reg:SI 64))
786               (clobber (reg:SI 65))])]
787   "optimize && !TARGET_DEBUG_C_MODE"
788   "*
789 {
790   if (find_reg_note (insn, REG_UNUSED, operands[3]))
791     return \"divu\\t%0,%1,%2\";
792
793   if (find_reg_note (insn, REG_UNUSED, operands[0]))
794     return \"remu\\t%3,%1,%2\";
795
796   return \"divu\\t%0,%1,%2\;mfhi\\t%3\";
797 }"
798   [(set_attr "type"     "idiv")
799    (set_attr "mode"     "SI")
800    (set_attr "length"   "13")])         ;; various tests for dividing by 0 and such
801
802 (define_insn "divsi3"
803   [(set (match_operand:SI 0 "register_operand" "=d")
804         (div:SI (match_operand:SI 1 "register_operand" "d")
805                 (match_operand:SI 2 "register_operand" "d")))
806    (clobber (reg:SI 64))
807    (clobber (reg:SI 65))]
808   "!optimize || TARGET_DEBUG_C_MODE"
809   "div\\t%0,%1,%2"
810   [(set_attr "type"     "idiv")
811    (set_attr "mode"     "SI")
812    (set_attr "length"   "13")])         ;; various tests for dividing by 0 and such
813
814 (define_insn "modsi3"
815   [(set (match_operand:SI 0 "register_operand" "=d")
816         (mod:SI (match_operand:SI 1 "register_operand" "d")
817                 (match_operand:SI 2 "register_operand" "d")))
818    (clobber (reg:SI 64))
819    (clobber (reg:SI 65))]
820   "!optimize || TARGET_DEBUG_C_MODE"
821   "rem\\t%0,%1,%2"
822   [(set_attr "type"     "idiv")
823    (set_attr "mode"     "SI")
824    (set_attr "length"   "14")])         ;; various tests for dividing by 0 and such
825
826 (define_insn "udivsi3"
827   [(set (match_operand:SI 0 "register_operand" "=d")
828         (udiv:SI (match_operand:SI 1 "register_operand" "d")
829                  (match_operand:SI 2 "register_operand" "d")))
830    (clobber (reg:SI 64))
831    (clobber (reg:SI 65))]
832   "!optimize || TARGET_DEBUG_C_MODE"
833   "divu\\t%0,%1,%2"
834   [(set_attr "type"     "idiv")
835    (set_attr "mode"     "SI")
836    (set_attr "length"   "14")])         ;; various tests for dividing by 0 and such
837
838 (define_insn "umodsi3"
839   [(set (match_operand:SI 0 "register_operand" "=d")
840         (umod:SI (match_operand:SI 1 "register_operand" "d")
841                  (match_operand:SI 2 "register_operand" "d")))
842    (clobber (reg:SI 64))
843    (clobber (reg:SI 65))]
844   "!optimize || TARGET_DEBUG_C_MODE"
845   "remu\\t%0,%1,%2"
846   [(set_attr "type"     "idiv")
847    (set_attr "mode"     "SI")
848    (set_attr "length"   "14")])         ;; various tests for dividing by 0 and such
849
850 \f
851 ;;
852 ;;  ....................
853 ;;
854 ;;      SQUARE ROOT
855 ;;
856 ;;  ....................
857
858 (define_insn "sqrtdf2"
859   [(set (match_operand:DF 0 "register_operand" "=f")
860         (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
861   "TARGET_HARD_FLOAT && HAVE_SQRT_P()"
862   "sqrt.d\\t%0,%1"
863   [(set_attr "type"     "fabs")
864    (set_attr "mode"     "DF")
865    (set_attr "length"   "1")])
866
867 (define_insn "sqrtsf2"
868   [(set (match_operand:SF 0 "register_operand" "=f")
869         (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
870   "TARGET_HARD_FLOAT && HAVE_SQRT_P()"
871   "sqrt.s\\t%0,%1"
872   [(set_attr "type"     "fabs")
873    (set_attr "mode"     "SF")
874    (set_attr "length"   "1")])
875
876 \f
877 ;;
878 ;;  ....................
879 ;;
880 ;;      ABSOLUTE VALUE
881 ;;
882 ;;  ....................
883
884 ;; Do not use the integer abs macro instruction, since that signals an
885 ;; exception on -2147483648 (sigh).
886
887 (define_insn "abssi2"
888   [(set (match_operand:SI 0 "register_operand" "=d")
889         (abs:SI (match_operand:SI 1 "register_operand" "d")))]
890   ""
891   "*
892 {
893   dslots_jump_total++;
894   dslots_jump_filled++;
895   operands[2] = const0_rtx;
896
897   return (REGNO (operands[0]) == REGNO (operands[1]))
898                 ? \"bgez\\t%1,1f%#\\n\\tsubu\\t%0,%z2,%0\\n1:\"
899                 : \"%(bgez\\t%1,1f\\n\\tmove\\t%0,%1\\n\\tsubu\\t%0,%z2,%0\\n1:%)\";
900 }"
901   [(set_attr "type"     "multi")
902    (set_attr "mode"     "SI")
903    (set_attr "length"   "3")])
904
905 (define_insn "absdf2"
906   [(set (match_operand:DF 0 "register_operand" "=f")
907         (abs:DF (match_operand:DF 1 "register_operand" "f")))]
908   "TARGET_HARD_FLOAT"
909   "abs.d\\t%0,%1"
910   [(set_attr "type"     "fabs")
911    (set_attr "mode"     "DF")
912    (set_attr "length"   "1")])
913
914 (define_insn "abssf2"
915   [(set (match_operand:SF 0 "register_operand" "=f")
916         (abs:SF (match_operand:SF 1 "register_operand" "f")))]
917   "TARGET_HARD_FLOAT"
918   "abs.s\\t%0,%1"
919   [(set_attr "type"     "fabs")
920    (set_attr "mode"     "SF")
921    (set_attr "length"   "1")])
922
923 \f
924 ;;
925 ;;  ....................
926 ;;
927 ;;      FIND FIRST BIT INSTRUCTION
928 ;;
929 ;;  ....................
930 ;;
931
932 (define_insn "ffssi2"
933   [(set (match_operand:SI 0 "register_operand" "=&d")
934         (ffs:SI (match_operand:SI 1 "register_operand" "d")))
935    (clobber (match_scratch:SI 2 "d"))
936    (clobber (match_scratch:SI 3 "d"))]
937   ""
938   "*
939 {
940   dslots_jump_total += 2;
941   dslots_jump_filled += 2;
942   operands[4] = const0_rtx;
943
944   if (optimize && find_reg_note (insn, REG_DEAD, operands[1]))
945     return \"%(\\
946 move\\t%0,%z4\\n\\
947 \\tbeq\\t%1,%z4,2f\\n\\
948 1:\\tand\\t%2,%1,0x0001\\n\\
949 \\taddu\\t%0,%0,1\\n\\
950 \\tbeq\\t%2,%z4,1b\\n\\
951 \\tsrl\\t%1,%1,1\\n\\
952 2:%)\";
953
954   return \"%(\\
955 move\\t%0,%z4\\n\\
956 \\tmove\\t%3,%1\\n\\
957 \\tbeq\\t%3,%z4,2f\\n\\
958 1:\\tand\\t%2,%3,0x0001\\n\\
959 \\taddu\\t%0,%0,1\\n\\
960 \\tbeq\\t%2,%z4,1b\\n\\
961 \\tsrl\\t%3,%3,1\\n\\
962 2:%)\";
963 }"
964   [(set_attr "type"     "multi")
965    (set_attr "mode"     "SI")
966    (set_attr "length"   "6")])
967
968 \f
969 ;;
970 ;;  ....................
971 ;;
972 ;;      NEGATION and ONE'S COMPLEMENT
973 ;;
974 ;;  ....................
975
976 (define_insn "negsi2"
977   [(set (match_operand:SI 0 "register_operand" "=d")
978         (neg:SI (match_operand:SI 1 "register_operand" "d")))]
979   ""
980   "*
981 {
982   operands[2] = const0_rtx;
983   return \"subu\\t%0,%z2,%1\";
984 }"
985   [(set_attr "type"     "arith")
986    (set_attr "mode"     "SI")
987    (set_attr "length"   "1")])
988
989 (define_expand "negdi3"
990   [(parallel [(set (match_operand:DI 0 "register_operand" "=d")
991                    (neg:DI (match_operand:DI 1 "register_operand" "d")))
992               (clobber (match_dup 2))])]
993   "!TARGET_DEBUG_G_MODE"
994   "operands[2] = gen_reg_rtx (SImode);")
995
996 (define_insn "negdi3_internal"
997   [(set (match_operand:DI 0 "register_operand" "=d")
998         (neg:DI (match_operand:DI 1 "register_operand" "d")))
999    (clobber (match_operand:SI 2 "register_operand" "=d"))]
1000   "!TARGET_DEBUG_G_MODE"
1001   "*
1002 {
1003   operands[3] = const0_rtx;
1004   return \"subu\\t%L0,%z3,%L1\;subu\\t%M0,%z3,%M1\;sltu\\t%2,%z3,%L0\;subu\\t%M0,%M0,%2\";
1005 }"
1006   [(set_attr "type"     "darith")
1007    (set_attr "mode"     "DI")
1008    (set_attr "length"   "4")])
1009
1010 (define_insn "negdf2"
1011   [(set (match_operand:DF 0 "register_operand" "=f")
1012         (neg:DF (match_operand:DF 1 "register_operand" "f")))]
1013   "TARGET_HARD_FLOAT"
1014   "neg.d\\t%0,%1"
1015   [(set_attr "type"     "fneg")
1016    (set_attr "mode"     "DF")
1017    (set_attr "length"   "1")])
1018
1019 (define_insn "negsf2"
1020   [(set (match_operand:SF 0 "register_operand" "=f")
1021         (neg:SF (match_operand:SF 1 "register_operand" "f")))]
1022   "TARGET_HARD_FLOAT"
1023   "neg.s\\t%0,%1"
1024   [(set_attr "type"     "fneg")
1025    (set_attr "mode"     "SF")
1026    (set_attr "length"   "1")])
1027
1028 (define_insn "one_cmplsi2"
1029   [(set (match_operand:SI 0 "register_operand" "=d")
1030         (not:SI (match_operand:SI 1 "register_operand" "d")))]
1031   ""
1032   "*
1033 {
1034   operands[2] = const0_rtx;
1035   return \"nor\\t%0,%z2,%1\";
1036 }"
1037   [(set_attr "type"     "arith")
1038    (set_attr "mode"     "SI")
1039    (set_attr "length"   "1")])
1040
1041 (define_insn "one_cmpldi2"
1042   [(set (match_operand:DI 0 "register_operand" "=d")
1043         (not:SI (match_operand:DI 1 "register_operand" "d")))]
1044   ""
1045   "*
1046 {
1047   operands[2] = const0_rtx;
1048   return \"nor\\t%M0,%z2,%M1\;nor\\t%L0,%z2,%L1\";
1049 }"
1050   [(set_attr "type"     "darith")
1051    (set_attr "mode"     "DI")
1052    (set_attr "length"   "2")])
1053
1054 (define_split
1055   [(set (match_operand:DI 0 "register_operand" "")
1056         (not:DI (match_operand:DI 1 "register_operand" "")))]
1057   "reload_completed && !TARGET_DEBUG_G_MODE
1058    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1059    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))"
1060
1061   [(set (subreg:SI (match_dup 0) 0) (not:SI (subreg:SI (match_dup 1) 0)))
1062    (set (subreg:SI (match_dup 0) 1) (not:SI (subreg:SI (match_dup 1) 1)))]
1063   "")
1064
1065 ;; Simple hack to recognize the "nor" instruction on the MIPS
1066 ;; This must appear before the normal or patterns, so that the
1067 ;; combiner will correctly fold things.
1068
1069 (define_insn "norsi3"
1070   [(set (match_operand:SI 0 "register_operand" "=d")
1071         (not:SI (ior:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
1072                         (match_operand:SI 2 "reg_or_0_operand" "dJ"))))]
1073   ""
1074   "nor\\t%0,%z1,%z2"
1075   [(set_attr "type"     "arith")
1076    (set_attr "mode"     "SI")
1077    (set_attr "length"   "1")])
1078
1079 (define_insn "nordi3"
1080   [(set (match_operand:DI 0 "register_operand" "=d")
1081         (not:DI (ior:DI (match_operand:DI 1 "register_operand" "d")
1082                         (match_operand:DI 2 "register_operand" "d"))))]
1083   ""
1084   "nor\\t%M0,%M1,%M2\;nor\\t%L0,%L1,%L2"
1085   [(set_attr "type"     "darith")
1086    (set_attr "mode"     "DI")
1087    (set_attr "length"   "2")])
1088
1089 (define_split
1090   [(set (match_operand:DI 0 "register_operand" "")
1091         (not:DI (ior:DI (match_operand:DI 1 "register_operand" "")
1092                         (match_operand:DI 2 "register_operand" ""))))]
1093   "reload_completed && !TARGET_DEBUG_G_MODE
1094    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1095    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1096    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
1097
1098   [(set (subreg:SI (match_dup 0) 0) (not:SI (ior:SI (subreg:SI (match_dup 1) 0) (subreg:SI (match_dup 2) 0))))
1099    (set (subreg:SI (match_dup 0) 1) (not:SI (ior:SI (subreg:SI (match_dup 1) 1) (subreg:SI (match_dup 2) 1))))]
1100   "")
1101
1102 \f
1103 ;;
1104 ;;  ....................
1105 ;;
1106 ;;      LOGICAL
1107 ;;
1108 ;;  ....................
1109 ;;
1110
1111 ;; Be more liberal in allowing logical operations than the machine actually
1112 ;; supports.  This causes better code to be generated for bitfields, since
1113 ;; the optimizer can fold things together, at the expense of not moving the
1114 ;; constant out of loops.
1115
1116 (define_insn "andsi3"
1117   [(set (match_operand:SI 0 "register_operand" "=d,d,?d,?d")
1118         (and:SI (match_operand:SI 1 "arith32_operand" "%d,d,d,d")
1119                 (match_operand:SI 2 "arith32_operand" "d,K,I,M")))]
1120   ""
1121   "@
1122    and\\t%0,%1,%2
1123    andi\\t%0,%1,%x2
1124    %[li\\t%@,%X2\;and\\t%0,%1,%@%]
1125    %[li\\t%@,%X2\;and\\t%0,%1,%@%]"
1126   [(set_attr "type"     "arith,arith,multi,multi")
1127    (set_attr "mode"     "SI,SI,SI,SI")
1128    (set_attr "length"   "1,1,2,3")])
1129
1130 (define_insn "anddi3"
1131   [(set (match_operand:DI 0 "register_operand" "=d")
1132         (and:DI (match_operand:DI 1 "register_operand" "d")
1133                 (match_operand:DI 2 "register_operand" "d")))]
1134   "!TARGET_DEBUG_G_MODE"
1135   "and\\t%M0,%M1,%M2\;and\\t%L0,%L1,%L2"
1136   [(set_attr "type"     "darith")
1137    (set_attr "mode"     "DI")
1138    (set_attr "length"   "2")])
1139
1140 (define_split
1141   [(set (match_operand:DI 0 "register_operand" "")
1142         (and:DI (match_operand:DI 1 "register_operand" "")
1143                 (match_operand:DI 2 "register_operand" "")))]
1144   "reload_completed && !TARGET_DEBUG_G_MODE
1145    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1146    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1147    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
1148
1149   [(set (subreg:SI (match_dup 0) 0) (and:SI (subreg:SI (match_dup 1) 0) (subreg:SI (match_dup 2) 0)))
1150    (set (subreg:SI (match_dup 0) 1) (and:SI (subreg:SI (match_dup 1) 1) (subreg:SI (match_dup 2) 1)))]
1151   "")
1152
1153 (define_insn "iorsi3"
1154   [(set (match_operand:SI 0 "register_operand" "=d,d,?d,?d")
1155         (ior:SI (match_operand:SI 1 "arith32_operand" "%d,d,d,d")
1156                 (match_operand:SI 2 "arith32_operand" "d,K,I,M")))]
1157   ""
1158   "@
1159    or\\t%0,%1,%2
1160    ori\\t%0,%1,%x2
1161    %[li\\t%@,%X2\;or\\t%0,%1,%@%]
1162    %[li\\t%@,%X2\;or\\t%0,%1,%@%]"
1163   [(set_attr "type"     "arith,arith,multi,multi")
1164    (set_attr "mode"     "SI,SI,SI,SI")
1165    (set_attr "length"   "1,1,2,3")])
1166
1167 (define_insn "iordi3"
1168   [(set (match_operand:DI 0 "register_operand" "=d")
1169         (ior:DI (match_operand:DI 1 "register_operand" "d")
1170                 (match_operand:DI 2 "register_operand" "d")))]
1171   "!TARGET_DEBUG_G_MODE"
1172   "or\\t%M0,%M1,%M2\;or\\t%L0,%L1,%L2"
1173   [(set_attr "type"     "darith")
1174    (set_attr "mode"     "DI")
1175    (set_attr "length"   "2")])
1176
1177 (define_split
1178   [(set (match_operand:DI 0 "register_operand" "")
1179         (ior:DI (match_operand:DI 1 "register_operand" "")
1180                 (match_operand:DI 2 "register_operand" "")))]
1181   "reload_completed && !TARGET_DEBUG_G_MODE
1182    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1183    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1184    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
1185
1186   [(set (subreg:SI (match_dup 0) 0) (ior:SI (subreg:SI (match_dup 1) 0) (subreg:SI (match_dup 2) 0)))
1187    (set (subreg:SI (match_dup 0) 1) (ior:SI (subreg:SI (match_dup 1) 1) (subreg:SI (match_dup 2) 1)))]
1188   "")
1189
1190 (define_insn "xorsi3"
1191   [(set (match_operand:SI 0 "register_operand" "=d,d,?d,?d")
1192         (xor:SI (match_operand:SI 1 "arith32_operand" "%d,d,d,d")
1193                 (match_operand:SI 2 "arith32_operand" "d,K,I,M")))]
1194   ""
1195   "@
1196    xor\\t%0,%1,%2
1197    xori\\t%0,%1,%x2
1198    %[li\\t%@,%X2\;xor\\t%0,%1,%@%]
1199    %[li\\t%@,%X2\;xor\\t%0,%1,%@%]"
1200   [(set_attr "type"     "arith,arith,multi,multi")
1201    (set_attr "mode"     "SI,SI,SI,SI")
1202    (set_attr "length"   "1,1,2,3")])
1203
1204 (define_insn "xordi3"
1205   [(set (match_operand:DI 0 "register_operand" "=d")
1206         (xor:DI (match_operand:DI 1 "register_operand" "d")
1207                 (match_operand:DI 2 "register_operand" "d")))]
1208   "!TARGET_DEBUG_G_MODE"
1209   "xor\\t%M0,%M1,%M2\;xor\\t%L0,%L1,%L2"
1210   [(set_attr "type"     "darith")
1211    (set_attr "mode"     "DI")
1212    (set_attr "length"   "2")])
1213
1214 (define_split
1215   [(set (match_operand:DI 0 "register_operand" "")
1216         (xor:DI (match_operand:DI 1 "register_operand" "")
1217                 (match_operand:DI 2 "register_operand" "")))]
1218   "reload_completed && !TARGET_DEBUG_G_MODE
1219    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1220    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1221    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
1222
1223   [(set (subreg:SI (match_dup 0) 0) (xor:SI (subreg:SI (match_dup 1) 0) (subreg:SI (match_dup 2) 0)))
1224    (set (subreg:SI (match_dup 0) 1) (xor:SI (subreg:SI (match_dup 1) 1) (subreg:SI (match_dup 2) 1)))]
1225   "")
1226
1227 \f
1228 ;;
1229 ;;  ....................
1230 ;;
1231 ;;      TRUNCATION
1232 ;;
1233 ;;  ....................
1234
1235 (define_insn "truncdfsf2"
1236   [(set (match_operand:SF 0 "register_operand" "=f")
1237         (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
1238   "TARGET_HARD_FLOAT"
1239   "cvt.s.d\\t%0,%1"
1240   [(set_attr "type"     "fcvt")
1241    (set_attr "mode"     "SF")
1242    (set_attr "length"   "1")])
1243
1244 \f
1245 ;;
1246 ;;  ....................
1247 ;;
1248 ;;      ZERO EXTENSION
1249 ;;
1250 ;;  ....................
1251
1252 ;; Extension insns.
1253 ;; Those for integer source operand
1254 ;; are ordered widest source type first.
1255
1256 (define_insn "zero_extendhisi2"
1257   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
1258         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "d,R,m")))]
1259   ""
1260   "*
1261 {
1262   if (which_alternative == 0)
1263     return \"andi\\t%0,%1,0xffff\";
1264   else
1265     return mips_move_1word (operands, insn, TRUE);
1266 }"
1267   [(set_attr "type"     "arith,load,load")
1268    (set_attr "mode"     "SI,SI,SI")
1269    (set_attr "length"   "1,1,2")])
1270
1271 (define_insn "zero_extendqihi2"
1272   [(set (match_operand:HI 0 "register_operand" "=d,d,d")
1273         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,R,m")))]
1274   ""
1275   "*
1276 {
1277   if (which_alternative == 0)
1278     return \"andi\\t%0,%1,0x00ff\";
1279   else
1280     return mips_move_1word (operands, insn, TRUE);
1281 }"
1282   [(set_attr "type"     "arith,load,load")
1283    (set_attr "mode"     "HI,HI,HI")
1284    (set_attr "length"   "1,1,2")])
1285
1286 (define_insn "zero_extendqisi2"
1287   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
1288         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "d,R,m")))]
1289   ""
1290   "*
1291 {
1292   if (which_alternative == 0)
1293     return \"andi\\t%0,%1,0x00ff\";
1294   else
1295     return mips_move_1word (operands, insn, TRUE);
1296 }"
1297   [(set_attr "type"     "arith,load,load")
1298    (set_attr "mode"     "SI,SI,SI")
1299    (set_attr "length"   "1,1,2")])
1300
1301 \f
1302 ;;
1303 ;;  ....................
1304 ;;
1305 ;;      SIGN EXTENSION
1306 ;;
1307 ;;  ....................
1308
1309 ;; Extension insns.
1310 ;; Those for integer source operand
1311 ;; are ordered widest source type first.
1312
1313 ;; These patterns originally accepted general_operands, however, slightly
1314 ;; better code is generated by only accepting register_operands, and then
1315 ;; letting combine generate the lh and lb insns.
1316
1317 (define_expand "extendhisi2"
1318   [(set (match_operand:SI 0 "register_operand" "")
1319         (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
1320   ""
1321   "
1322 {
1323   if (optimize && GET_CODE (operands[1]) == MEM)
1324     operands[1] = force_not_mem (operands[1]);
1325
1326   if (GET_CODE (operands[1]) != MEM)
1327     {
1328       rtx op1   = gen_lowpart (SImode, operands[1]);
1329       rtx temp  = gen_reg_rtx (SImode);
1330       rtx shift = gen_rtx (CONST_INT, VOIDmode, 16);
1331
1332       emit_insn (gen_ashlsi3 (temp, op1, shift));
1333       emit_insn (gen_ashrsi3 (operands[0], temp, shift));
1334       DONE;
1335     }
1336 }")
1337
1338 (define_insn "extendhisi2_internal"
1339   [(set (match_operand:SI 0 "register_operand" "=d,d")
1340         (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,m")))]
1341   ""
1342   "* return mips_move_1word (operands, insn, FALSE);"
1343   [(set_attr "type"     "load,load")
1344    (set_attr "mode"     "SI,SI")
1345    (set_attr "length"   "1,2")])
1346
1347 (define_expand "extendqihi2"
1348   [(set (match_operand:HI 0 "register_operand" "")
1349         (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
1350   ""
1351   "
1352 {
1353   if (optimize && GET_CODE (operands[1]) == MEM)
1354     operands[1] = force_not_mem (operands[1]);
1355
1356   if (GET_CODE (operands[1]) != MEM)
1357     {
1358       rtx op0   = gen_lowpart (SImode, operands[0]);
1359       rtx op1   = gen_lowpart (SImode, operands[1]);
1360       rtx temp  = gen_reg_rtx (SImode);
1361       rtx shift = gen_rtx (CONST_INT, VOIDmode, 24);
1362
1363       emit_insn (gen_ashlsi3 (temp, op1, shift));
1364       emit_insn (gen_ashrsi3 (op0, temp, shift));
1365       DONE;
1366     }
1367 }")
1368
1369 (define_insn "extendqihi2_internal"
1370   [(set (match_operand:HI 0 "register_operand" "=d,d")
1371         (sign_extend:HI (match_operand:QI 1 "memory_operand" "R,m")))]
1372   ""
1373   "* return mips_move_1word (operands, insn, FALSE);"
1374   [(set_attr "type"     "load,load")
1375    (set_attr "mode"     "SI,SI")
1376    (set_attr "length"   "1,2")])
1377
1378
1379 (define_expand "extendqisi2"
1380   [(set (match_operand:SI 0 "register_operand" "")
1381         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1382   ""
1383   "
1384 {
1385   if (optimize && GET_CODE (operands[1]) == MEM)
1386     operands[1] = force_not_mem (operands[1]);
1387
1388   if (GET_CODE (operands[1]) != MEM)
1389     {
1390       rtx op1   = gen_lowpart (SImode, operands[1]);
1391       rtx temp  = gen_reg_rtx (SImode);
1392       rtx shift = gen_rtx (CONST_INT, VOIDmode, 24);
1393
1394       emit_insn (gen_ashlsi3 (temp, op1, shift));
1395       emit_insn (gen_ashrsi3 (operands[0], temp, shift));
1396       DONE;
1397     }
1398 }")
1399
1400 (define_insn "extendqisi2_insn"
1401   [(set (match_operand:SI 0 "register_operand" "=d,d")
1402         (sign_extend:SI (match_operand:QI 1 "memory_operand" "R,m")))]
1403   ""
1404   "* return mips_move_1word (operands, insn, FALSE);"
1405   [(set_attr "type"     "load,load")
1406    (set_attr "mode"     "SI,SI")
1407    (set_attr "length"   "1,2")])
1408
1409
1410 (define_insn "extendsfdf2"
1411   [(set (match_operand:DF 0 "register_operand" "=f")
1412         (float_extend:DF (match_operand:SF 1 "register_operand" "f")))]
1413   "TARGET_HARD_FLOAT"
1414   "cvt.d.s\\t%0,%1"
1415   [(set_attr "type"     "fcvt")
1416    (set_attr "mode"     "DF")
1417    (set_attr "length"   "1")])
1418
1419 \f
1420
1421 ;;
1422 ;;  ....................
1423 ;;
1424 ;;      CONVERSIONS
1425 ;;
1426 ;;  ....................
1427
1428 (define_insn "fix_truncdfsi2_internal"
1429   [(set (match_operand:SI 0 "general_operand" "=d,*f,R,o")
1430         (fix:SI (match_operand:DF 1 "register_operand" "f,*f,f,f")))
1431    (clobber (match_operand:SI 2 "register_operand" "d,*d,d,d"))
1432    (clobber (match_operand:DF 3 "register_operand" "f,*f,f,f"))]
1433   "TARGET_HARD_FLOAT"
1434   "*
1435 {
1436   rtx xoperands[10];
1437
1438   if (which_alternative == 1)
1439     return \"trunc.w.d %0,%1,%2\";
1440
1441   output_asm_insn (\"trunc.w.d %3,%1,%2\", operands);
1442
1443   xoperands[0] = operands[0];
1444   xoperands[1] = operands[3];
1445   output_asm_insn (mips_move_1word (xoperands, insn, FALSE), xoperands);
1446   return \"\";
1447 }"
1448   [(set_attr "type"     "fcvt,fcvt,fcvt,fcvt")
1449    (set_attr "mode"     "DF,DF,DF,DF")
1450    (set_attr "length"   "14,12,13,14")])
1451
1452
1453 (define_expand "fix_truncdfsi2"
1454   [(parallel [(set (match_operand:SI 0 "register_operand" "=d")
1455                    (fix:SI (match_operand:DF 1 "register_operand" "f")))
1456               (clobber (match_dup 2))
1457               (clobber (match_dup 3))])]
1458   "TARGET_HARD_FLOAT"
1459   "
1460 {
1461   operands[2] = gen_reg_rtx (SImode);   /* gp reg that saves FP status bits */
1462   operands[3] = gen_reg_rtx (DFmode);   /* fp reg that gets the conversion */
1463
1464   /* Fall through and generate default code */
1465 }")
1466
1467 (define_insn "fix_truncsfsi2_internal"
1468   [(set (match_operand:SI 0 "general_operand" "=d,*f,R,o")
1469         (fix:SI (match_operand:SF 1 "register_operand" "f,*f,f,f")))
1470    (clobber (match_operand:SI 2 "register_operand" "d,*d,d,d"))
1471    (clobber (match_operand:SF 3 "register_operand" "f,*f,f,f"))]
1472   "TARGET_HARD_FLOAT"
1473   "*
1474 {
1475   rtx xoperands[10];
1476
1477   if (which_alternative == 1)
1478     return \"trunc.w.s %0,%1,%2\";
1479
1480   output_asm_insn (\"trunc.w.s %3,%1,%2\", operands);
1481
1482   xoperands[0] = operands[0];
1483   xoperands[1] = operands[3];
1484   output_asm_insn (mips_move_1word (xoperands, insn, FALSE), xoperands);
1485   return \"\";
1486 }"
1487   [(set_attr "type"     "fcvt,fcvt,fcvt,fcvt")
1488    (set_attr "mode"     "SF,SF,SF,SF")
1489    (set_attr "length"   "14,12,13,14")])
1490
1491
1492 (define_expand "fix_truncsfsi2"
1493   [(parallel [(set (match_operand:SI 0 "register_operand" "=f")
1494                    (fix:SI (match_operand:SF 1 "register_operand" "f")))
1495               (clobber (match_dup 2))
1496               (clobber (match_dup 3))])]
1497   "TARGET_HARD_FLOAT"
1498   "
1499 {
1500   operands[2] = gen_reg_rtx (SImode);   /* gp reg that saves FP status bits */
1501   operands[3] = gen_reg_rtx (SFmode);   /* fp reg that gets the conversion */
1502
1503   /* Fall through and generate default code */
1504 }")
1505
1506
1507 (define_insn "floatsidf2"
1508   [(set (match_operand:DF 0 "register_operand" "=f")
1509         (float:DF (match_operand:SI 1 "register_operand" "d")))]
1510   "TARGET_HARD_FLOAT"
1511   "mtc1\\t%1,%0\;cvt.d.w\\t%0,%0"
1512   [(set_attr "type"     "fcvt")
1513    (set_attr "mode"     "DF")
1514    (set_attr "length"   "13")])
1515
1516 (define_insn "floatsisf2"
1517   [(set (match_operand:SF 0 "register_operand" "=f")
1518         (float:SF (match_operand:SI 1 "register_operand" "d")))]
1519   "TARGET_HARD_FLOAT"
1520   "mtc1\\t%1,%0\;cvt.s.w\\t%0,%0"
1521   [(set_attr "type"     "fcvt")
1522    (set_attr "mode"     "SF")
1523    (set_attr "length"   "13")])
1524
1525 (define_expand "fixuns_truncdfsi2"
1526   [(set (match_operand:SI 0 "register_operand" "")
1527         (unsigned_fix:SI (match_operand:DF 1 "register_operand" "")))]
1528   "TARGET_HARD_FLOAT"
1529   "
1530 {
1531   rtx reg1 = gen_reg_rtx (DFmode);
1532   rtx reg2 = gen_reg_rtx (DFmode);
1533   rtx reg3 = gen_reg_rtx (SImode);
1534   rtx label1 = gen_label_rtx ();
1535   rtx label2 = gen_label_rtx ();
1536   REAL_VALUE_TYPE offset = REAL_VALUE_LDEXP (1.0, 31);
1537
1538   if (reg1)                     /* turn off complaints about unreached code */
1539     {
1540       extern rtx gen_cmpdf ();
1541       emit_move_insn (reg1, immed_real_const_1 (offset, DFmode));
1542       do_pending_stack_adjust ();
1543
1544       emit_insn (gen_cmpdf (operands[1], reg1));
1545       emit_jump_insn (gen_bge (label1));
1546
1547       emit_insn (gen_fix_truncdfsi2 (operands[0], operands[1]));
1548       emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx,
1549                                gen_rtx (LABEL_REF, VOIDmode, label2)));
1550       emit_barrier ();
1551
1552       emit_label (label1);
1553       emit_move_insn (reg2, gen_rtx (MINUS, DFmode, operands[1], reg1));
1554       emit_move_insn (reg3, gen_rtx (CONST_INT, VOIDmode, 0x80000000));
1555
1556       emit_insn (gen_fix_truncdfsi2 (operands[0], reg2));
1557       emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
1558
1559       emit_label (label2);
1560
1561       /* allow REG_NOTES to be set on last insn (labels don't have enough
1562          fields, and can't be used for REG_NOTES anyway).  */
1563       emit_insn (gen_rtx (USE, VOIDmode, stack_pointer_rtx));
1564       DONE;
1565     }
1566 }")
1567
1568 (define_expand "fixuns_truncsfsi2"
1569   [(set (match_operand:SI 0 "register_operand" "")
1570         (unsigned_fix:SI (match_operand:SF 1 "register_operand" "")))]
1571   "TARGET_HARD_FLOAT"
1572   "
1573 {
1574   rtx reg1 = gen_reg_rtx (SFmode);
1575   rtx reg2 = gen_reg_rtx (SFmode);
1576   rtx reg3 = gen_reg_rtx (SImode);
1577   rtx label1 = gen_label_rtx ();
1578   rtx label2 = gen_label_rtx ();
1579   REAL_VALUE_TYPE offset = REAL_VALUE_LDEXP (1.0, 31);
1580
1581   if (reg1)                     /* turn off complaints about unreached code */
1582     {
1583       extern rtx gen_cmpsf ();
1584       emit_move_insn (reg1, immed_real_const_1 (offset, SFmode));
1585       do_pending_stack_adjust ();
1586
1587       emit_insn (gen_cmpsf (operands[1], reg1));
1588       emit_jump_insn (gen_bge (label1));
1589
1590       emit_insn (gen_fix_truncsfsi2 (operands[0], operands[1]));
1591       emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx,
1592                                gen_rtx (LABEL_REF, VOIDmode, label2)));
1593       emit_barrier ();
1594
1595       emit_label (label1);
1596       emit_move_insn (reg2, gen_rtx (MINUS, SFmode, operands[1], reg1));
1597       emit_move_insn (reg3, gen_rtx (CONST_INT, VOIDmode, 0x80000000));
1598
1599       emit_insn (gen_fix_truncsfsi2 (operands[0], reg2));
1600       emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
1601
1602       emit_label (label2);
1603
1604       /* allow REG_NOTES to be set on last insn (labels don't have enough
1605          fields, and can't be used for REG_NOTES anyway).  */
1606       emit_insn (gen_rtx (USE, VOIDmode, stack_pointer_rtx));
1607       DONE;
1608     }
1609 }")
1610
1611 \f
1612 ;;
1613 ;;  ....................
1614 ;;
1615 ;;      DATA MOVEMENT
1616 ;;
1617 ;;  ....................
1618
1619 ;; unaligned word moves generated by the block moves.
1620
1621 (define_expand "movsi_unaligned"
1622   [(set (match_operand:SI 0 "general_operand" "")
1623         (unspec [(match_operand:SI 1 "general_operand" "")] 0))]
1624   ""
1625   "
1626 {
1627   extern rtx force_reg ();
1628   extern rtx gen_movsi_ulw ();
1629   extern rtx gen_movsi ();
1630
1631   /* Handle loads.  */
1632   if (GET_CODE (operands[0]) == MEM)
1633     {
1634       rtx reg = gen_reg_rtx (SImode);
1635       rtx insn = emit_insn (gen_movsi_ulw (reg, operands[1]));
1636       rtx addr = XEXP (operands[0], 0);
1637       if (CONSTANT_P (addr))
1638         REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_EQUIV, addr, REG_NOTES (insn));
1639
1640       if (reg_or_0_operand (operands[1], SImode))
1641         DONE;
1642
1643       operands[1] = reg;
1644     }
1645
1646   /* Generate appropriate load, store.  If not a load or store,
1647      do a normal movsi.  */
1648   if (GET_CODE (operands[0]) != MEM && GET_CODE (operands[1]) != MEM)
1649     {
1650       emit_insn (gen_movsi (operands[0], operands[1]));
1651       DONE;
1652     }
1653
1654   /* Fall through and generate normal code.  */
1655 }")
1656
1657 (define_insn "movsi_ulw"
1658   [(set (match_operand:SI 0 "register_operand" "=&d,&d,d,d")
1659         (unspec [(match_operand:SI 1 "general_operand" "R,o,dIKL,M")] 0))]
1660   ""
1661   "*
1662 {
1663   extern rtx eliminate_constant_term ();
1664   enum rtx_code code;
1665   char *ret;
1666   rtx offset;
1667   rtx addr;
1668   rtx mem_addr;
1669
1670   if (which_alternative != 0)
1671     return mips_move_1word (operands, insn, FALSE);
1672
1673   if (TARGET_STATS)
1674     mips_count_memory_refs (operands[1], 2);
1675
1676   /* The stack/frame pointers are always aligned, so we can convert
1677      to the faster lw if we are referencing an aligned stack location.  */
1678
1679   offset = const0_rtx;
1680   addr = XEXP (operands[1], 0);
1681   mem_addr = eliminate_constant_term (addr, &offset);
1682
1683   if ((INTVAL (offset) & (UNITS_PER_WORD-1)) == 0
1684       && (mem_addr == stack_pointer_rtx || mem_addr == frame_pointer_rtx))
1685     ret = \"lw\\t%0,%1\";
1686
1687   else
1688     {
1689       ret = \"ulw\\t%0,%1\";
1690       if (TARGET_GAS)
1691         {
1692           enum rtx_code code = GET_CODE (addr);
1693
1694           if (code == CONST || code == SYMBOL_REF || code == LABEL_REF)
1695             {
1696               operands[2] = gen_rtx (REG, SImode, GP_REG_FIRST + 1);
1697               ret = \"%[la\\t%2,%1\;ulw\\t%0,0(%2)%]\";
1698             }
1699         }
1700     }
1701
1702   return mips_fill_delay_slot (ret, DELAY_LOAD, operands, insn);
1703 }"
1704   [(set_attr "type"     "load,load,move,arith")
1705    (set_attr "mode"     "SI,SI,SI,SI")
1706    (set_attr "length"   "2,4,1,2")])
1707
1708 (define_insn "movsi_usw"
1709   [(set (match_operand:SI 0 "memory_operand" "=R,o")
1710         (unspec [(match_operand:SI 1 "reg_or_0_operand" "dJ,dJ")] 0))]
1711   ""
1712   "*
1713 {
1714   extern rtx eliminate_constant_term ();
1715   rtx offset = const0_rtx;
1716   rtx addr = XEXP (operands[0], 0);
1717   rtx mem_addr = eliminate_constant_term (addr, &offset);
1718
1719   if (TARGET_STATS)
1720     mips_count_memory_refs (operands[0], 2);
1721
1722   /* The stack/frame pointers are always aligned, so we can convert
1723      to the faster sw if we are referencing an aligned stack location.  */
1724
1725   if ((INTVAL (offset) & (UNITS_PER_WORD-1)) == 0
1726       && (mem_addr == stack_pointer_rtx || mem_addr == frame_pointer_rtx))
1727     return \"sw\\t%1,%0\";
1728
1729
1730   if (TARGET_GAS)
1731     {
1732       enum rtx_code code = GET_CODE (XEXP (operands[0], 0));
1733
1734       if (code == CONST || code == SYMBOL_REF || code == LABEL_REF)
1735         {
1736           operands[2] = gen_rtx (REG, SImode, GP_REG_FIRST + 1);
1737           return \"%[la\\t%2,%0\;usw\\t%z1,0(%2)%]\";
1738         }
1739     }
1740
1741   return \"usw\\t%z1,%0\";
1742 }"
1743   [(set_attr "type"     "store,store")
1744    (set_attr "mode"     "SI,SI")
1745    (set_attr "length"   "2,4")])
1746
1747 ;; 64-bit integer moves
1748
1749 ;; Unlike most other insns, the move insns can't be split with
1750 ;; different predicates, because register spilling and other parts of
1751 ;; the compiler, have memoized the insn number already.
1752
1753 (define_insn "movdi"
1754   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,R,o,*d,*x")
1755         (match_operand:DI 1 "general_operand" "d,iF,R,o,d,d,*x,*d"))]
1756   ""
1757   "* return mips_move_2words (operands, insn); "
1758   [(set_attr "type"     "move,arith,load,load,store,store,hilo,hilo")
1759    (set_attr "mode"     "DI,DI,DI,DI,DI,DI,DI,DI")
1760    (set_attr "length"   "2,4,2,4,2,4,2,2")])
1761
1762 (define_split
1763   [(set (match_operand:DI 0 "register_operand" "")
1764         (match_operand:DI 1 "register_operand" ""))]
1765   "reload_completed && !TARGET_DEBUG_G_MODE
1766    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1767    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))"
1768
1769   [(set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))
1770    (set (subreg:SI (match_dup 0) 1) (subreg:SI (match_dup 1) 1))]
1771   "")
1772
1773
1774 ;; 32-bit Integer moves
1775
1776 (define_split
1777   [(set (match_operand:SI 0 "register_operand" "")
1778         (match_operand:SI 1 "large_int" ""))]
1779   ""
1780   [(set (match_dup 0)
1781         (match_dup 2))
1782    (set (match_dup 0)
1783         (ior:SI (match_dup 0)
1784                 (match_dup 3)))]
1785   "
1786 {
1787   operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) & 0xffff0000);
1788   operands[3] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) & 0x0000ffff);
1789 }")
1790
1791 ;; Unlike most other insns, the move insns can't be split with
1792 ;; different predicates, because register spilling and other parts of
1793 ;; the compiler, have memoized the insn number already.
1794
1795 (define_expand "movsi"
1796   [(set (match_operand:SI 0 "nonimmediate_operand" "")
1797         (match_operand:SI 1 "general_operand" ""))]
1798   ""
1799   "
1800 {
1801   /* If this is a half-pic address being moved to a register, convert the
1802      address into a load, so that scheduling and stuff works properly.  */
1803
1804   if (HALF_PIC_P()
1805       && GET_CODE (operands[0]) == REG
1806       && GET_CODE (operands[1]) == SYMBOL_REF
1807       && HALF_PIC_ADDRESS_P (operands[1]))
1808     {
1809       rtx ptr = HALF_PIC_PTR (operands[1]);
1810       if (XSTR (ptr, 0) != XSTR (operands[1], 0))
1811         {
1812           emit_move_insn (operands[0], gen_rtx (MEM, Pmode, ptr));
1813           DONE;
1814         }
1815     }
1816 }")
1817
1818 (define_insn "movsi_internal"
1819   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,R,m,*d,*fs,*f,*f,*f,*R,*m,*x,*d")
1820         (match_operand:SI 1 "general_operand" "d,S,IKL,Mnis,R,m,dJ,dJ,*fs,*d,*f,*R,*m,*f,*f,*d,*x"))]
1821   ""
1822   "* return mips_move_1word (operands, insn, TRUE);"
1823   [(set_attr "type"     "move,pic,arith,arith,load,load,store,store,xfer,xfer,move,load,load,store,store,hilo,hilo")
1824    (set_attr "mode"     "SI,SI,SI,SI,SI,SI,SI,SI,SI,SI,SI,SI,SI,SI,SI,SI,SI")
1825    (set_attr "length"   "1,4,1,2,1,2,1,2,1,1,1,1,2,1,2,1,1")])
1826
1827 ;; 16-bit Integer moves
1828
1829 ;; Unlike most other insns, the move insns can't be split with
1830 ;; different predicates, because register spilling and other parts of
1831 ;; the compiler, have memoized the insn number already.
1832 ;; Unsigned loads are used because BYTE_LOADS_ZERO_EXTEND is defined
1833
1834 (define_insn "movhi"
1835   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,R,m,*d,*f,*f,*x,*d")
1836         (match_operand:HI 1 "general_operand"       "d,IK,R,m,dJ,dJ,*fs,*d,*f,*d,*x"))]
1837   ""
1838   "* return mips_move_1word (operands, insn, TRUE);"
1839   [(set_attr "type"     "move,arith,load,load,store,store,xfer,xfer,move,hilo,hilo")
1840    (set_attr "mode"     "HI,HI,HI,HI,HI,HI,HI,HI,HI,HI,HI")
1841    (set_attr "length"   "1,1,1,2,1,2,1,1,1,1,1")])
1842
1843 ;; 8-bit Integer moves
1844
1845 ;; Unlike most other insns, the move insns can't be split with
1846 ;; different predicates, because register spilling and other parts of
1847 ;; the compiler, have memoized the insn number already.
1848 ;; Unsigned loads are used because BYTE_LOADS_ZERO_EXTEND is defined
1849
1850 (define_insn "movqi"
1851   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,m,*d,*f,*f,*x,*d")
1852         (match_operand:QI 1 "general_operand"       "d,IK,R,m,dJ,dJ,*fs,*d,*f,*d,*x"))]
1853   ""
1854   "* return mips_move_1word (operands, insn, TRUE);"
1855   [(set_attr "type"     "move,arith,load,load,store,store,xfer,xfer,move,hilo,hilo")
1856    (set_attr "mode"     "QI,QI,QI,QI,QI,QI,QI,QI,QI,QI,QI")
1857    (set_attr "length"   "1,1,1,2,1,2,1,1,1,1,1")])
1858
1859
1860 ;; 32-bit floating point moves
1861
1862 (define_insn "movsf"
1863   [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,f,R,m,*f,*d,*d,*d,*d,*R,*m")
1864         (match_operand:SF 1 "general_operand" "f,G,R,Em,fG,fG,*d,*f,*Gd,*R,*Em,*d,*d"))]
1865   ""
1866   "* return mips_move_1word (operands, insn, FALSE);"
1867   [(set_attr "type"     "move,xfer,load,load,store,store,xfer,xfer,move,load,load,store,store")
1868    (set_attr "mode"     "SF,SF,SF,SF,SF,SF,SF,SF,SF,SF,SF,SF,SF")
1869    (set_attr "length"   "1,1,1,2,1,2,1,1,1,1,2,1,2")])
1870
1871 ;; 64-bit floating point moves
1872
1873 (define_insn "movdf"
1874   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,R,o,f,*f,*d,*d,*d,*d,*R,*o")
1875         (match_operand:DF 1 "general_operand" "f,R,o,fG,fG,E,*d,*f,*dG,*R,*oE,*d,*d"))]
1876   ""
1877   "* return mips_move_2words (operands, insn); "
1878   [(set_attr "type"     "move,load,load,store,store,load,xfer,xfer,move,load,load,store,store")
1879    (set_attr "mode"     "DF,DF,DF,DF,DF,DF,DF,DF,DF,DF,DF,DF,DF")
1880    (set_attr "length"   "1,2,4,2,4,4,2,2,2,2,4,2,4")])
1881
1882 (define_split
1883   [(set (match_operand:DF 0 "register_operand" "")
1884         (match_operand:DF 1 "register_operand" ""))]
1885   "reload_completed && !TARGET_DEBUG_G_MODE
1886    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1887    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))"
1888
1889   [(set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))
1890    (set (subreg:SI (match_dup 0) 1) (subreg:SI (match_dup 1) 1))]
1891   "")
1892
1893 ;; Block moves, see mips.c for more details.
1894 ;; Argument 0 is the destination
1895 ;; Argument 1 is the source
1896 ;; Argument 2 is the length
1897 ;; Argument 3 is the alignment
1898
1899 (define_expand "movstrsi"
1900   [(parallel [(set (mem:BLK (match_operand:BLK 0 "general_operand" ""))
1901                    (mem:BLK (match_operand:BLK 1 "general_operand" "")))
1902               (use (match_operand:SI 2 "arith32_operand" ""))
1903               (use (match_operand:SI 3 "immediate_operand" ""))])]
1904   ""
1905   "
1906 {
1907   if (operands[0])              /* avoid unused code messages */
1908     {
1909       expand_block_move (operands);
1910       DONE;
1911     }
1912 }")
1913
1914 ;; Insn generated by block moves
1915
1916 (define_insn "movstrsi_internal"
1917   [(set (match_operand:BLK 0 "memory_operand" "=Ro")
1918         (match_operand:BLK 1 "memory_operand" "Ro"))
1919    (clobber (match_scratch:SI 4 "=&d"))
1920    (clobber (match_scratch:SI 5 "=&d"))
1921    (clobber (match_scratch:SI 6 "=&d"))
1922    (clobber (match_scratch:SI 7 "=&d"))
1923    (use (match_operand:SI 2 "small_int" "I"))
1924    (use (match_operand:SI 3 "small_int" "I"))]
1925   ""
1926   "* return output_block_move (insn, operands, 4);"
1927   [(set_attr "type"     "multi")
1928    (set_attr "mode"     "none")
1929    (set_attr "length"   "20")])
1930
1931 \f
1932 ;;
1933 ;;  ....................
1934 ;;
1935 ;;      SHIFTS
1936 ;;
1937 ;;  ....................
1938
1939 (define_insn "ashlsi3"
1940   [(set (match_operand:SI 0 "register_operand" "=d")
1941         (ashift:SI (match_operand:SI 1 "register_operand" "d")
1942                    (match_operand:SI 2 "arith_operand" "dI")))]
1943   ""
1944   "*
1945 {
1946   if (GET_CODE (operands[2]) == CONST_INT)
1947     operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);
1948
1949   return \"sll\\t%0,%1,%2\";
1950 }"
1951   [(set_attr "type"     "arith")
1952    (set_attr "mode"     "SI")
1953    (set_attr "length"   "1")])
1954
1955
1956 (define_expand "ashldi3"
1957   [(parallel [(set (match_operand:DI 0 "register_operand" "")
1958                    (ashift:DI (match_operand:DI 1 "register_operand" "")
1959                               (match_operand:SI 2 "arith_operand" "")))
1960               (clobber (match_dup  3))])]
1961   "!TARGET_DEBUG_G_MODE"
1962   "operands[3] = gen_reg_rtx (SImode);")
1963
1964
1965 (define_insn "ashldi3_internal"
1966   [(set (match_operand:DI 0 "register_operand" "=d")
1967         (ashift:DI (match_operand:DI 1 "register_operand" "d")
1968                    (match_operand:SI 2 "register_operand" "d")))
1969    (clobber (match_operand:SI 3 "register_operand" "=d"))]
1970   "!TARGET_DEBUG_G_MODE"
1971   "* 
1972 {
1973   operands[4] = const0_rtx;
1974   dslots_jump_total += 3;
1975   dslots_jump_filled += 2;
1976
1977   return \"sll\\t%3,%2,26\\n\\
1978 \\tbgez\\t%3,1f\\n\\
1979 \\tsll\\t%M0,%L1,%2\\n\\
1980 \\t%(b\\t3f\\n\\
1981 \\tmove\\t%L0,%z4%)\\n\\
1982 \\n\\
1983 1:\\n\\
1984 \\t%(beq\\t%3,%z4,2f\\n\\
1985 \\tsll\\t%M0,%M1,%2%)\\n\\
1986 \\n\\
1987 \\tsubu\\t%3,%z4,%2\\n\\
1988 \\tsrl\\t%3,%L1,%3\\n\\
1989 \\tor\\t%M0,%M0,%3\\n\\
1990 2:\\n\\
1991 \\tsll\\t%L0,%L1,%2\\n\\
1992 3:\";
1993 }"
1994   [(set_attr "type"     "darith")
1995    (set_attr "mode"     "SI")
1996    (set_attr "length"   "12")])
1997
1998
1999 (define_insn "ashldi3_internal2"
2000   [(set (match_operand:DI 0 "register_operand" "=d")
2001         (ashift:DI (match_operand:DI 1 "register_operand" "d")
2002                    (match_operand:SI 2 "small_int" "IJK")))
2003    (clobber (match_operand:SI 3 "register_operand" "=d"))]
2004   "!TARGET_DEBUG_G_MODE && (INTVAL (operands[2]) & 32) != 0"
2005   "*
2006 {
2007   operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);
2008   operands[4] = const0_rtx;
2009   return \"sll\\t%M0,%L1,%2\;move\\t%L0,%z4\";
2010 }"
2011   [(set_attr "type"     "darith")
2012    (set_attr "mode"     "DI")
2013    (set_attr "length"   "2")])
2014
2015
2016 (define_split
2017   [(set (match_operand:DI 0 "register_operand" "")
2018         (ashift:DI (match_operand:DI 1 "register_operand" "")
2019                    (match_operand:SI 2 "small_int" "")))
2020    (clobber (match_operand:SI 3 "register_operand" ""))]
2021   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
2022    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
2023    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
2024    && (INTVAL (operands[2]) & 32) != 0"
2025
2026   [(set (subreg:SI (match_dup 0) 1) (ashift:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
2027    (set (subreg:SI (match_dup 0) 0) (const_int 0))]
2028
2029   "operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);")
2030
2031
2032 (define_split
2033   [(set (match_operand:DI 0 "register_operand" "")
2034         (ashift:DI (match_operand:DI 1 "register_operand" "")
2035                    (match_operand:SI 2 "small_int" "")))
2036    (clobber (match_operand:SI 3 "register_operand" ""))]
2037   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
2038    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
2039    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
2040    && (INTVAL (operands[2]) & 32) != 0"
2041
2042   [(set (subreg:SI (match_dup 0) 0) (ashift:SI (subreg:SI (match_dup 1) 1) (match_dup 2)))
2043    (set (subreg:SI (match_dup 0) 1) (const_int 0))]
2044
2045   "operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);")
2046
2047
2048 (define_insn "ashldi3_internal3"
2049   [(set (match_operand:DI 0 "register_operand" "=d")
2050         (ashift:DI (match_operand:DI 1 "register_operand" "d")
2051                    (match_operand:SI 2 "small_int" "IJK")))
2052    (clobber (match_operand:SI 3 "register_operand" "=d"))]
2053   "!TARGET_DEBUG_G_MODE
2054    && (INTVAL (operands[2]) & 63) < 32
2055    && (INTVAL (operands[2]) & 63) != 0"
2056   "*
2057 {
2058   int amount = INTVAL (operands[2]);
2059
2060   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
2061   operands[4] = const0_rtx;
2062   operands[5] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
2063
2064   return \"sll\\t%M0,%M1,%2\;srl\\t%3,%L1,%5\;or\\t%M0,%M0,%3\;sll\\t%L0,%L1,%2\";
2065 }"
2066   [(set_attr "type"     "darith")
2067    (set_attr "mode"     "DI")
2068    (set_attr "length"   "4")])
2069
2070
2071 (define_split
2072   [(set (match_operand:DI 0 "register_operand" "")
2073         (ashift:DI (match_operand:DI 1 "register_operand" "")
2074                    (match_operand:SI 2 "small_int" "")))
2075    (clobber (match_operand:SI 3 "register_operand" ""))]
2076   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
2077    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
2078    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
2079    && (INTVAL (operands[2]) & 63) < 32
2080    && (INTVAL (operands[2]) & 63) != 0"
2081
2082   [(set (subreg:SI (match_dup 0) 1)
2083         (ashift:SI (subreg:SI (match_dup 1) 1)
2084                    (match_dup 2)))
2085
2086    (set (match_dup 3)
2087         (lshiftrt:SI (subreg:SI (match_dup 1) 0)
2088                      (match_dup 4)))
2089
2090    (set (subreg:SI (match_dup 0) 1)
2091         (ior:SI (subreg:SI (match_dup 0) 1)
2092                 (match_dup 3)))
2093
2094    (set (subreg:SI (match_dup 0) 0)
2095         (ashift:SI (subreg:SI (match_dup 1) 0)
2096                    (match_dup 2)))]
2097   "
2098 {
2099   int amount = INTVAL (operands[2]);
2100   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
2101   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
2102 }")
2103
2104
2105 (define_split
2106   [(set (match_operand:DI 0 "register_operand" "")
2107         (ashift:DI (match_operand:DI 1 "register_operand" "")
2108                    (match_operand:SI 2 "small_int" "")))
2109    (clobber (match_operand:SI 3 "register_operand" ""))]
2110   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
2111    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
2112    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
2113    && (INTVAL (operands[2]) & 63) < 32
2114    && (INTVAL (operands[2]) & 63) != 0"
2115
2116   [(set (subreg:SI (match_dup 0) 0)
2117         (ashift:SI (subreg:SI (match_dup 1) 0)
2118                    (match_dup 2)))
2119
2120    (set (match_dup 3)
2121         (lshiftrt:SI (subreg:SI (match_dup 1) 1)
2122                      (match_dup 4)))
2123
2124    (set (subreg:SI (match_dup 0) 0)
2125         (ior:SI (subreg:SI (match_dup 0) 0)
2126                 (match_dup 3)))
2127
2128    (set (subreg:SI (match_dup 0) 1)
2129         (ashift:SI (subreg:SI (match_dup 1) 1)
2130                    (match_dup 2)))]
2131   "
2132 {
2133   int amount = INTVAL (operands[2]);
2134   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
2135   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
2136 }")
2137
2138
2139 (define_insn "ashrsi3"
2140   [(set (match_operand:SI 0 "register_operand" "=d")
2141         (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
2142                      (match_operand:SI 2 "arith_operand" "dI")))]
2143   ""
2144   "*
2145 {
2146   if (GET_CODE (operands[2]) == CONST_INT)
2147     operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);
2148
2149   return \"sra\\t%0,%1,%2\";
2150 }"
2151   [(set_attr "type"     "arith")
2152    (set_attr "mode"     "SI")
2153    (set_attr "length"   "1")])
2154
2155
2156 (define_expand "ashrdi3"
2157   [(parallel [(set (match_operand:DI 0 "register_operand" "")
2158                    (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
2159                                 (match_operand:SI 2 "arith_operand" "")))
2160               (clobber (match_dup  3))])]
2161   "!TARGET_DEBUG_G_MODE"
2162   "operands[3] = gen_reg_rtx (SImode);")
2163
2164
2165 (define_insn "ashrdi3_internal"
2166   [(set (match_operand:DI 0 "register_operand" "=d")
2167         (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
2168                      (match_operand:SI 2 "register_operand" "d")))
2169    (clobber (match_operand:SI 3 "register_operand" "=d"))]
2170   "!TARGET_DEBUG_G_MODE"
2171   "* 
2172 {
2173   operands[4] = const0_rtx;
2174   dslots_jump_total += 3;
2175   dslots_jump_filled += 2;
2176
2177   return \"sll\\t%3,%2,26\\n\\
2178 \\tbgez\\t%3,1f\\n\\
2179 \\tsra\\t%L0,%M1,%2\\n\\
2180 \\t%(b\\t3f\\n\\
2181 \\tsra\\t%M0,%M1,31%)\\n\\
2182 \\n\\
2183 1:\\n\\
2184 \\t%(beq\\t%3,%z4,2f\\n\\
2185 \\tsrl\\t%L0,%L1,%2%)\\n\\
2186 \\n\\
2187 \\tsubu\\t%3,%z4,%2\\n\\
2188 \\tsll\\t%3,%M1,%3\\n\\
2189 \\tor\\t%L0,%L0,%3\\n\\
2190 2:\\n\\
2191 \\tsra\\t%M0,%M1,%2\\n\\
2192 3:\";
2193 }"
2194   [(set_attr "type"     "darith")
2195    (set_attr "mode"     "DI")
2196    (set_attr "length"   "12")])
2197
2198
2199 (define_insn "ashrdi3_internal2"
2200   [(set (match_operand:DI 0 "register_operand" "=d")
2201         (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
2202                      (match_operand:SI 2 "small_int" "IJK")))
2203    (clobber (match_operand:SI 3 "register_operand" "=d"))]
2204   "!TARGET_DEBUG_G_MODE && (INTVAL (operands[2]) & 32) != 0"
2205   "*
2206 {
2207   operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);
2208   return \"sra\\t%L0,%M1,%2\;sra\\t%M0,%M1,31\";
2209 }"
2210   [(set_attr "type"     "darith")
2211    (set_attr "mode"     "DI")
2212    (set_attr "length"   "2")])
2213
2214
2215 (define_split
2216   [(set (match_operand:DI 0 "register_operand" "")
2217         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
2218                      (match_operand:SI 2 "small_int" "")))
2219    (clobber (match_operand:SI 3 "register_operand" ""))]
2220   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
2221    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
2222    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
2223    && (INTVAL (operands[2]) & 32) != 0"
2224
2225   [(set (subreg:SI (match_dup 0) 0) (ashiftrt:SI (subreg:SI (match_dup 1) 1) (match_dup 2)))
2226    (set (subreg:SI (match_dup 0) 1) (ashiftrt:SI (subreg:SI (match_dup 1) 1) (const_int 31)))]
2227
2228   "operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);")
2229
2230
2231 (define_split
2232   [(set (match_operand:DI 0 "register_operand" "")
2233         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
2234                      (match_operand:SI 2 "small_int" "")))
2235    (clobber (match_operand:SI 3 "register_operand" ""))]
2236   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
2237    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
2238    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
2239    && (INTVAL (operands[2]) & 32) != 0"
2240
2241   [(set (subreg:SI (match_dup 0) 1) (ashiftrt:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
2242    (set (subreg:SI (match_dup 0) 0) (ashiftrt:SI (subreg:SI (match_dup 1) 0) (const_int 31)))]
2243
2244   "operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);")
2245
2246
2247 (define_insn "ashrdi3_internal3"
2248   [(set (match_operand:DI 0 "register_operand" "=d")
2249         (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
2250                      (match_operand:SI 2 "small_int" "IJK")))
2251    (clobber (match_operand:SI 3 "register_operand" "=d"))]
2252   "!TARGET_DEBUG_G_MODE
2253    && (INTVAL (operands[2]) & 63) < 32
2254    && (INTVAL (operands[2]) & 63) != 0"
2255   "*
2256 {
2257   int amount = INTVAL (operands[2]);
2258
2259   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
2260   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
2261
2262   return \"srl\\t%L0,%L1,%2\;sll\\t%3,%M1,%4\;or\\t%L0,%L0,%3\;sra\\t%M0,%M1,%2\";
2263 }"
2264   [(set_attr "type"     "darith")
2265    (set_attr "mode"     "DI")
2266    (set_attr "length"   "4")])
2267
2268
2269 (define_split
2270   [(set (match_operand:DI 0 "register_operand" "")
2271         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
2272                      (match_operand:SI 2 "small_int" "")))
2273    (clobber (match_operand:SI 3 "register_operand" ""))]
2274   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
2275    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
2276    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
2277    && (INTVAL (operands[2]) & 63) < 32
2278    && (INTVAL (operands[2]) & 63) != 0"
2279
2280   [(set (subreg:SI (match_dup 0) 0)
2281         (lshiftrt:SI (subreg:SI (match_dup 1) 0)
2282                      (match_dup 2)))
2283
2284    (set (match_dup 3)
2285         (ashift:SI (subreg:SI (match_dup 1) 1)
2286                    (match_dup 4)))
2287
2288    (set (subreg:SI (match_dup 0) 0)
2289         (ior:SI (subreg:SI (match_dup 0) 0)
2290                 (match_dup 3)))
2291
2292    (set (subreg:SI (match_dup 0) 1)
2293         (ashiftrt:SI (subreg:SI (match_dup 1) 1)
2294                      (match_dup 2)))]
2295   "
2296 {
2297   int amount = INTVAL (operands[2]);
2298   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
2299   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
2300 }")
2301
2302
2303 (define_split
2304   [(set (match_operand:DI 0 "register_operand" "")
2305         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
2306                      (match_operand:SI 2 "small_int" "")))
2307    (clobber (match_operand:SI 3 "register_operand" ""))]
2308   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
2309    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
2310    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
2311    && (INTVAL (operands[2]) & 63) < 32
2312    && (INTVAL (operands[2]) & 63) != 0"
2313
2314   [(set (subreg:SI (match_dup 0) 1)
2315         (lshiftrt:SI (subreg:SI (match_dup 1) 1)
2316                      (match_dup 2)))
2317
2318    (set (match_dup 3)
2319         (ashift:SI (subreg:SI (match_dup 1) 0)
2320                    (match_dup 4)))
2321
2322    (set (subreg:SI (match_dup 0) 1)
2323         (ior:SI (subreg:SI (match_dup 0) 1)
2324                 (match_dup 3)))
2325
2326    (set (subreg:SI (match_dup 0) 0)
2327         (ashiftrt:SI (subreg:SI (match_dup 1) 0)
2328                      (match_dup 2)))]
2329   "
2330 {
2331   int amount = INTVAL (operands[2]);
2332   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
2333   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
2334 }")
2335
2336
2337 (define_insn "lshrsi3"
2338   [(set (match_operand:SI 0 "register_operand" "=d")
2339         (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
2340                      (match_operand:SI 2 "arith_operand" "dI")))]
2341   ""
2342   "*
2343 {
2344   if (GET_CODE (operands[2]) == CONST_INT)
2345     operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);
2346
2347   return \"srl\\t%0,%1,%2\";
2348 }"
2349   [(set_attr "type"     "arith")
2350    (set_attr "mode"     "SI")
2351    (set_attr "length"   "1")])
2352
2353
2354 (define_expand "lshrdi3"
2355   [(parallel [(set (match_operand:DI 0 "register_operand" "")
2356                    (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
2357                                 (match_operand:SI 2 "arith_operand" "")))
2358               (clobber (match_dup  3))])]
2359   "!TARGET_DEBUG_G_MODE"
2360   "operands[3] = gen_reg_rtx (SImode);")
2361
2362
2363 (define_insn "lshrdi3_internal"
2364   [(set (match_operand:DI 0 "register_operand" "=&d")
2365         (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
2366                      (match_operand:SI 2 "register_operand" "d")))
2367    (clobber (match_operand:SI 3 "register_operand" "=d"))]
2368   "!TARGET_DEBUG_G_MODE"
2369   "* 
2370 {
2371   operands[4] = const0_rtx;
2372   dslots_jump_total += 3;
2373   dslots_jump_filled += 2;
2374
2375   return \"sll\\t%3,%2,26\\n\\
2376 \\tbgez\\t%3,1f\\n\\
2377 \\tsrl\\t%L0,%M1,%2\\n\\
2378 \\t%(b\\t3f\\n\\
2379 \\tmove\\t%M0,%z4%)\\n\\
2380 \\n\\
2381 1:\\n\\
2382 \\t%(beq\\t%3,%z4,2f\\n\\
2383 \\tsrl\\t%L0,%L1,%2%)\\n\\
2384 \\n\\
2385 \\tsubu\\t%3,%z4,%2\\n\\
2386 \\tsll\\t%3,%M1,%3\\n\\
2387 \\tor\\t%L0,%L0,%3\\n\\
2388 2:\\n\\
2389 \\tsrl\\t%M0,%M1,%2\\n\\
2390 3:\";
2391 }"
2392   [(set_attr "type"     "darith")
2393    (set_attr "mode"     "DI")
2394    (set_attr "length"   "12")])
2395
2396
2397 (define_insn "lshrdi3_internal2"
2398   [(set (match_operand:DI 0 "register_operand" "=d")
2399         (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
2400                      (match_operand:SI 2 "small_int" "IJK")))
2401    (clobber (match_operand:SI 3 "register_operand" "=d"))]
2402   "!TARGET_DEBUG_G_MODE && (INTVAL (operands[2]) & 32) != 0"
2403   "*
2404 {
2405   operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);
2406   operands[4] = const0_rtx;
2407   return \"srl\\t%L0,%M1,%2\;move\\t%M0,%z4\";
2408 }"
2409   [(set_attr "type"     "darith")
2410    (set_attr "mode"     "DI")
2411    (set_attr "length"   "2")])
2412
2413
2414 (define_split
2415   [(set (match_operand:DI 0 "register_operand" "")
2416         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
2417                      (match_operand:SI 2 "small_int" "")))
2418    (clobber (match_operand:SI 3 "register_operand" ""))]
2419   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
2420    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
2421    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
2422    && (INTVAL (operands[2]) & 32) != 0"
2423
2424   [(set (subreg:SI (match_dup 0) 0) (lshiftrt:SI (subreg:SI (match_dup 1) 1) (match_dup 2)))
2425    (set (subreg:SI (match_dup 0) 1) (const_int 0))]
2426
2427   "operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);")
2428
2429
2430 (define_split
2431   [(set (match_operand:DI 0 "register_operand" "")
2432         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
2433                      (match_operand:SI 2 "small_int" "")))
2434    (clobber (match_operand:SI 3 "register_operand" ""))]
2435   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
2436    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
2437    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
2438    && (INTVAL (operands[2]) & 32) != 0"
2439
2440   [(set (subreg:SI (match_dup 0) 1) (lshiftrt:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
2441    (set (subreg:SI (match_dup 0) 0) (const_int 0))]
2442
2443   "operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);")
2444
2445
2446 (define_insn "lshrdi3_internal3"
2447   [(set (match_operand:DI 0 "register_operand" "=d")
2448         (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
2449                    (match_operand:SI 2 "small_int" "IJK")))
2450    (clobber (match_operand:SI 3 "register_operand" "=d"))]
2451   "!TARGET_DEBUG_G_MODE
2452    && (INTVAL (operands[2]) & 63) < 32
2453    && (INTVAL (operands[2]) & 63) != 0"
2454   "*
2455 {
2456   int amount = INTVAL (operands[2]);
2457
2458   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
2459   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
2460
2461   return \"srl\\t%L0,%L1,%2\;sll\\t%3,%M1,%4\;or\\t%L0,%L0,%3\;srl\\t%M0,%M1,%2\";
2462 }"
2463   [(set_attr "type"     "darith")
2464    (set_attr "mode"     "DI")
2465    (set_attr "length"   "4")])
2466
2467
2468 (define_split
2469   [(set (match_operand:DI 0 "register_operand" "")
2470         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
2471                      (match_operand:SI 2 "small_int" "")))
2472    (clobber (match_operand:SI 3 "register_operand" ""))]
2473   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
2474    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
2475    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
2476    && (INTVAL (operands[2]) & 63) < 32
2477    && (INTVAL (operands[2]) & 63) != 0"
2478
2479   [(set (subreg:SI (match_dup 0) 0)
2480         (lshiftrt:SI (subreg:SI (match_dup 1) 0)
2481                      (match_dup 2)))
2482
2483    (set (match_dup 3)
2484         (ashift:SI (subreg:SI (match_dup 1) 1)
2485                    (match_dup 4)))
2486
2487    (set (subreg:SI (match_dup 0) 0)
2488         (ior:SI (subreg:SI (match_dup 0) 0)
2489                 (match_dup 3)))
2490
2491    (set (subreg:SI (match_dup 0) 1)
2492         (lshiftrt:SI (subreg:SI (match_dup 1) 1)
2493                      (match_dup 2)))]
2494   "
2495 {
2496   int amount = INTVAL (operands[2]);
2497   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
2498   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
2499 }")
2500
2501
2502 (define_split
2503   [(set (match_operand:DI 0 "register_operand" "")
2504         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
2505                      (match_operand:SI 2 "small_int" "")))
2506    (clobber (match_operand:SI 3 "register_operand" ""))]
2507   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_DEBUG_G_MODE
2508    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
2509    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
2510    && (INTVAL (operands[2]) & 63) < 32
2511    && (INTVAL (operands[2]) & 63) != 0"
2512
2513   [(set (subreg:SI (match_dup 0) 1)
2514         (lshiftrt:SI (subreg:SI (match_dup 1) 1)
2515                      (match_dup 2)))
2516
2517    (set (match_dup 3)
2518         (ashift:SI (subreg:SI (match_dup 1) 0)
2519                    (match_dup 4)))
2520
2521    (set (subreg:SI (match_dup 0) 1)
2522         (ior:SI (subreg:SI (match_dup 0) 1)
2523                 (match_dup 3)))
2524
2525    (set (subreg:SI (match_dup 0) 0)
2526         (lshiftrt:SI (subreg:SI (match_dup 1) 0)
2527                      (match_dup 2)))]
2528   "
2529 {
2530   int amount = INTVAL (operands[2]);
2531   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
2532   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
2533 }")
2534
2535 \f
2536 ;;
2537 ;;  ....................
2538 ;;
2539 ;;      COMPARISONS
2540 ;;
2541 ;;  ....................
2542
2543 ;; Flow here is rather complex:
2544 ;;
2545 ;;  1)  The cmp{si,sf,df} routine is called.  It deposits the
2546 ;;      arguments into the branch_cmp array, and the type into
2547 ;;      branch_type.  No RTL is generated.
2548 ;;
2549 ;;  2)  The appropriate branch define_expand is called, which then
2550 ;;      creates the appropriate RTL for the comparison and branch.
2551 ;;      Different CC modes are used, based on what type of branch is
2552 ;;      done, so that we can constrain things appropriately.  There
2553 ;;      are assumptions in the rest of GCC that break if we fold the
2554 ;;      operands into the branchs for integer operations, and use cc0
2555 ;;      for floating point.
2556 ;;
2557 ;;  3)  The compare define_insns then once again set branch_cmp and
2558 ;;      branch_type, and the branch define_insns use them.
2559 ;;
2560 ;;  4)  If a set condition code is done instead of a branch, then the
2561 ;;      operands are folded into the RTL, and a separate set of cc0 is
2562 ;;      not done.  This allows slt's to be put into delay slots.
2563
2564 (define_expand "cmpsi"
2565   [(set (cc0)
2566         (compare:CC (match_operand:SI 0 "register_operand" "")
2567                     (match_operand:SI 1 "arith_operand" "")))]
2568   ""
2569   "
2570 {
2571   if (operands[0])              /* avoid unused code message */
2572     {
2573       branch_cmp[0] = operands[0];
2574       branch_cmp[1] = operands[1];
2575       branch_type = CMP_SI;
2576       DONE;
2577     }
2578 }")
2579
2580 (define_expand "tstsi"
2581   [(set (cc0)
2582         (match_operand:SI 0 "register_operand" ""))]
2583   ""
2584   "
2585 {
2586   if (operands[0])              /* avoid unused code message */
2587     {
2588       branch_cmp[0] = operands[0];
2589       branch_cmp[1] = const0_rtx;
2590       branch_type = CMP_SI;
2591       DONE;
2592     }
2593 }")
2594
2595 (define_insn "cmpsi_eqne"
2596   [(set (cc0)
2597         (compare:CC_EQ (match_operand:SI 0 "register_operand" "dJ")
2598                        (match_operand:SI 1 "reg_or_0_operand" "dJ")))]
2599   ""
2600   "*
2601 {
2602   branch_cmp[0] = operands[0];
2603   branch_cmp[1] = operands[1];
2604   branch_type = CMP_SI;
2605   return \"\";
2606 }"
2607   [(set_attr "type"     "icmp")
2608    (set_attr "mode"     "none")
2609    (set_attr "length"   "0")])
2610
2611 (define_insn "cmpsi_zero"
2612   [(set (cc0)
2613         (match_operand:SI 0 "reg_or_0_operand" "dJ"))]
2614   ""
2615   "*
2616 {
2617   branch_cmp[0] = operands[0];
2618   branch_cmp[1] = const0_rtx;
2619   branch_type = CMP_SI;
2620   return \"\";
2621 }"
2622   [(set_attr "type"     "icmp")
2623    (set_attr "mode"     "none")
2624    (set_attr "length"   "0")])
2625
2626 (define_insn "cmpsi_relational"
2627   [(set (cc0)
2628         (compare:CC (match_operand:SI 0 "register_operand" "dJ")
2629                     (match_operand:SI 1 "arith_operand" "dI")))]
2630   ""
2631   "*
2632 {
2633   branch_cmp[0] = operands[0];
2634   branch_cmp[1] = operands[1];
2635   branch_type = CMP_SI;
2636   return \"\";
2637 }"
2638   [(set_attr "type"     "icmp")
2639    (set_attr "mode"     "none")
2640    (set_attr "length"   "0")])
2641
2642 (define_expand "cmpdf"
2643   [(set (cc0)
2644         (compare:CC_FP (match_operand:DF 0 "register_operand" "")
2645                        (match_operand:DF 1 "register_operand" "")))]
2646   "TARGET_HARD_FLOAT"
2647   "
2648 {
2649   if (operands[0])              /* avoid unused code message */
2650     {
2651       branch_cmp[0] = operands[0];
2652       branch_cmp[1] = operands[1];
2653       branch_type = CMP_DF;
2654       DONE;
2655     }
2656 }")
2657
2658 (define_insn "cmpdf_internal"
2659   [(set (cc0)
2660         (compare:CC_FP (match_operand:DF 0 "register_operand" "f")
2661                        (match_operand:DF 1 "register_operand" "f")))]
2662   "TARGET_HARD_FLOAT"
2663   "*
2664 {
2665   branch_cmp[0] = operands[0];
2666   branch_cmp[1] = operands[1];
2667   branch_type = CMP_DF;
2668   return \"\";
2669 }"
2670   [(set_attr "type"     "fcmp")
2671    (set_attr "mode"     "none")
2672    (set_attr "length"   "0")])
2673
2674
2675 (define_expand "cmpsf"
2676   [(set (cc0)
2677         (compare:CC_FP (match_operand:SF 0 "register_operand" "")
2678                        (match_operand:SF 1 "register_operand" "")))]
2679   "TARGET_HARD_FLOAT"
2680   "
2681 {
2682   if (operands[0])              /* avoid unused code message */
2683     {
2684       branch_cmp[0] = operands[0];
2685       branch_cmp[1] = operands[1];
2686       branch_type = CMP_SF;
2687       DONE;
2688     }
2689 }")
2690
2691 (define_insn "cmpsf_internal"
2692   [(set (cc0)
2693         (compare:CC_FP (match_operand:SF 0 "register_operand" "f")
2694                        (match_operand:SF 1 "register_operand" "f")))]
2695   "TARGET_HARD_FLOAT"
2696   "*
2697 {
2698   branch_cmp[0] = operands[0];
2699   branch_cmp[1] = operands[1];
2700   branch_type = CMP_SF;
2701   return \"\";
2702 }"
2703   [(set_attr "type"     "fcmp")
2704    (set_attr "mode"     "none")
2705    (set_attr "length"   "0")])
2706
2707 \f
2708 ;;
2709 ;;  ....................
2710 ;;
2711 ;;      CONDITIONAL BRANCHES
2712 ;;
2713 ;;  ....................
2714
2715 ;; We really can't note that integer branches clobber $at, and FP
2716 ;; branches clobber $fcr31 because if we use a parallel operation, a
2717 ;; normal insn is used to hold the value instead of jump_insn.  See
2718 ;; above for cmpxx saving the operands in branch_cmp and branch_type.
2719
2720 (define_insn "branch_fp_true"
2721   [(set (pc)
2722         (if_then_else (match_operator:CC_FP 0 "fcmp_op" [(cc0) (const_int 0)])
2723                       (label_ref (match_operand 1 "" ""))
2724                       (pc)))]
2725   ""
2726   "*
2727 {
2728   operands[2] = branch_cmp[0];
2729   operands[3] = branch_cmp[1];
2730
2731   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
2732   if (branch_type == CMP_DF)
2733     {
2734       switch (GET_CODE (operands[0]))
2735         {
2736         case EQ: return \"c.eq.d\\t%2,%3%#\;%*bc1t%?\\t%l1\";
2737         case NE: return \"c.eq.d\\t%2,%3%#\;%*bc1f%?\\t%l1\";
2738         case LT: return \"c.lt.d\\t%2,%3%#\;%*bc1t%?\\t%l1\";
2739         case LE: return \"c.le.d\\t%2,%3%#\;%*bc1t%?\\t%l1\";
2740         case GT: return \"c.lt.d\\t%3,%2%#\;%*bc1t%?\\t%l1\";
2741         case GE: return \"c.le.d\\t%3,%2%#\;%*bc1t%?\\t%l1\";
2742         }
2743     }
2744
2745   else if (branch_type == CMP_SF)
2746     {
2747       switch (GET_CODE (operands[0]))
2748         {
2749         case EQ: return \"c.eq.s\\t%2,%3%#\;%*bc1t%?\\t%l1\";
2750         case NE: return \"c.eq.s\\t%2,%3%#\;%*bc1f%?\\t%l1\";
2751         case LT: return \"c.lt.s\\t%2,%3%#\;%*bc1t%?\\t%l1\";
2752         case LE: return \"c.le.s\\t%2,%3%#\;%*bc1t%?\\t%l1\";
2753         case GT: return \"c.lt.s\\t%3,%2%#\;%*bc1t%?\\t%l1\";
2754         case GE: return \"c.le.s\\t%3,%2%#\;%*bc1t%?\\t%l1\";
2755         }
2756     }
2757
2758   abort_with_insn (insn, \"Bad floating compare/branch\");
2759   return (char *)0;
2760 }"
2761   [(set_attr "type"     "branch")
2762    (set_attr "mode"     "none")
2763    (set_attr "length"   "3")])
2764
2765 (define_insn "branch_fp_false"
2766   [(set (pc)
2767         (if_then_else (match_operator:CC_FP 0 "fcmp_op" [(cc0) (const_int 0)])
2768                       (pc)
2769                       (label_ref (match_operand 1 "" ""))))]
2770   ""
2771   "*
2772 {
2773   operands[2] = branch_cmp[0];
2774   operands[3] = branch_cmp[1];
2775
2776   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
2777   if (branch_type == CMP_DF)
2778     {
2779       switch (GET_CODE (operands[0]))
2780         {
2781         case EQ: return \"c.eq.d\\t%2,%3%#\;%*bc1f%?\\t%l1\";
2782         case NE: return \"c.eq.d\\t%2,%3%#\;%*bc1t%?\\t%l1\";
2783         case LT: return \"c.lt.d\\t%2,%3%#\;%*bc1f%?\\t%l1\";
2784         case LE: return \"c.le.d\\t%2,%3%#\;%*bc1f%?\\t%l1\";
2785         case GT: return \"c.lt.d\\t%3,%2%#\;%*bc1f%?\\t%l1\";
2786         case GE: return \"c.le.d\\t%3,%2%#\;%*bc1f%?\\t%l1\";
2787         }
2788     }
2789
2790   else if (branch_type == CMP_SF)
2791     {
2792       switch (GET_CODE (operands[0]))
2793         {
2794         case EQ: return \"c.eq.s\\t%2,%3%#\;%*bc1f%?\\t%l1\";
2795         case NE: return \"c.eq.s\\t%2,%3%#\;%*bc1t%?\\t%l1\";
2796         case LT: return \"c.lt.s\\t%2,%3%#\;%*bc1f%?\\t%l1\";
2797         case LE: return \"c.le.s\\t%2,%3%#\;%*bc1f%?\\t%l1\";
2798         case GT: return \"c.lt.s\\t%3,%2%#\;%*bc1f%?\\t%l1\";
2799         case GE: return \"c.le.s\\t%3,%2%#\;%*bc1f%?\\t%l1\";
2800         }
2801     }
2802
2803   abort_with_insn (insn, \"Bad floating compare/branch\");
2804   return (char *)0;
2805 }"
2806   [(set_attr "type"     "branch")
2807    (set_attr "mode"     "none")
2808    (set_attr "length"   "3")])
2809
2810
2811 (define_insn "branch_eqne_true"
2812   [(set (pc)
2813         (if_then_else (match_operator:CC_EQ 0 "equality_op" [(cc0) (const_int 0)])
2814                       (label_ref (match_operand 1 "" ""))
2815                       (pc)))]
2816   ""
2817   "*
2818 {
2819   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
2820   operands[2] = branch_cmp[0];
2821   operands[3] = branch_cmp[1];
2822   return \"%*b%C0%?\\t%z2,%z3,%1\";
2823 }"
2824   [(set_attr "type"     "branch")
2825    (set_attr "mode"     "none")
2826    (set_attr "length"   "1")])
2827
2828 (define_insn "branch_eqne_false"
2829   [(set (pc)
2830         (if_then_else (match_operator:CC_EQ 0 "equality_op" [(cc0) (const_int 0)])
2831                       (pc)
2832                       (label_ref (match_operand 1 "" ""))))]
2833   ""
2834   "*
2835 {
2836   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
2837   operands[2] = branch_cmp[0];
2838   operands[3] = branch_cmp[1];
2839   return \"%*b%N0%?\\t%z2,%z3,%1\";
2840 }"
2841   [(set_attr "type"     "branch")
2842    (set_attr "mode"     "none")
2843    (set_attr "length"   "1")])
2844
2845 (define_insn "branch_zero_true"
2846   [(set (pc)
2847         (if_then_else (match_operator:CC_0 0 "cmp_op" [(cc0) (const_int 0)])
2848                       (label_ref (match_operand 1 "" ""))
2849                       (pc)))]
2850   ""
2851   "*
2852 {
2853   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
2854   operands[2] = branch_cmp[0];
2855
2856   switch (GET_CODE (operands[0]))
2857     {
2858     case EQ:  return \"%*beq%?\\t%z2,%.,%1\";
2859     case NE:  return \"%*bne%?\\t%z2,%.,%1\";
2860     case GTU: return \"%*bne%?\\t%z2,%.,%1\";
2861     case LEU: return \"%*beq%?\\t%z2,%.,%1\";
2862     case GEU: return \"%*j\\t%1\";
2863     case LTU: return \"#%*bltuz\\t%z2,%1\";
2864     }
2865
2866   return \"%*b%C0z%?\\t%z2,%1\";
2867 }"
2868   [(set_attr "type"     "branch")
2869    (set_attr "mode"     "none")
2870    (set_attr "length"   "1")])
2871
2872 (define_insn "branch_zero_false"
2873   [(set (pc)
2874         (if_then_else (match_operator:CC_0 0 "cmp_op" [(cc0) (const_int 0)])
2875                       (pc)
2876                       (label_ref (match_operand 1 "" ""))))]
2877   ""
2878   "*
2879 {
2880   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
2881   operands[2] = branch_cmp[0];
2882   switch (GET_CODE (operands[0]))
2883     {
2884     case EQ:  return \"%*bne%?\\t%z2,%.,%1\";
2885     case NE:  return \"%*beq%?\\t%z2,%.,%1\";
2886     case GTU: return \"%*beq%?\\t%z2,%.,%1\";
2887     case LEU: return \"%*bne\\t%z2,%.,%1\";
2888     case GEU: return \"#%*bgeuz\\t%z2,%1\";
2889     case LTU: return \"%*j\\t%1\";
2890     }
2891
2892   return \"%*b%N0z%?\\t%z2,%1\";
2893 }"
2894   [(set_attr "type"     "branch")
2895    (set_attr "mode"     "none")
2896    (set_attr "length"   "1")])
2897
2898 (define_insn "branch_relop_true"
2899   [(set (pc)
2900         (if_then_else (match_operator:CC 0 "cmp2_op" [(cc0) (const_int 0)])
2901                       (label_ref (match_operand 1 "" ""))
2902                       (pc)))]
2903   ""
2904   "*
2905 {
2906   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
2907   operands[2] = branch_cmp[0];
2908   operands[3] = branch_cmp[1];
2909
2910   return \"%&b%C0%?\\t%z2,%z3,%1%!\";
2911 }"
2912   [(set_attr "type"     "branch")
2913    (set_attr "mode"     "none")
2914    (set_attr "length"   "2")])
2915
2916 (define_insn "branch_relop_false"
2917   [(set (pc)
2918         (if_then_else (match_operator:CC 0 "cmp2_op" [(cc0) (const_int 0)])
2919                       (pc)
2920                       (label_ref (match_operand 1 "" ""))))]
2921   ""
2922   "*
2923 {
2924   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
2925   operands[2] = branch_cmp[0];
2926   operands[3] = branch_cmp[1];
2927
2928   return \"%&b%N0%?\\t%z2,%z3,%1%!\";
2929 }"
2930   [(set_attr "type"     "branch")
2931    (set_attr "mode"     "none")
2932    (set_attr "length"   "2")])
2933
2934 (define_expand "beq"
2935   [(set (pc)
2936         (if_then_else (eq:CC_EQ (cc0)
2937                                 (const_int 0))
2938                       (label_ref (match_operand 0 "" ""))
2939                       (pc)))]
2940   ""
2941   "
2942 {
2943   if (operands[0])              /* avoid unused code warning */
2944     {
2945       gen_conditional_branch (operands, EQ);
2946       DONE;
2947     }
2948 }")
2949
2950 (define_expand "bne"
2951   [(set (pc)
2952         (if_then_else (ne:CC_EQ (cc0)
2953                                 (const_int 0))
2954                       (label_ref (match_operand 0 "" ""))
2955                       (pc)))]
2956   ""
2957   "
2958 {
2959   if (operands[0])              /* avoid unused code warning */
2960     {
2961       gen_conditional_branch (operands, NE);
2962       DONE;
2963     }
2964 }")
2965
2966 (define_expand "bgt"
2967   [(set (pc)
2968         (if_then_else (gt:CC (cc0)
2969                              (const_int 0))
2970                       (label_ref (match_operand 0 "" ""))
2971                       (pc)))]
2972   ""
2973   "
2974 {
2975   if (operands[0])              /* avoid unused code warning */
2976     {
2977       gen_conditional_branch (operands, GT);
2978       DONE;
2979     }
2980 }")
2981
2982 (define_expand "bge"
2983   [(set (pc)
2984         (if_then_else (ge:CC (cc0)
2985                              (const_int 0))
2986                       (label_ref (match_operand 0 "" ""))
2987                       (pc)))]
2988   ""
2989   "
2990 {
2991   if (operands[0])              /* avoid unused code warning */
2992     {
2993       gen_conditional_branch (operands, GE);
2994       DONE;
2995     }
2996 }")
2997
2998 (define_expand "blt"
2999   [(set (pc)
3000         (if_then_else (lt:CC (cc0)
3001                              (const_int 0))
3002                       (label_ref (match_operand 0 "" ""))
3003                       (pc)))]
3004   ""
3005   "
3006 {
3007   if (operands[0])              /* avoid unused code warning */
3008     {
3009       gen_conditional_branch (operands, LT);
3010       DONE;
3011     }
3012 }")
3013
3014 (define_expand "ble"
3015   [(set (pc)
3016         (if_then_else (le:CC (cc0)
3017                              (const_int 0))
3018                       (label_ref (match_operand 0 "" ""))
3019                       (pc)))]
3020   ""
3021   "
3022 {
3023   if (operands[0])              /* avoid unused code warning */
3024     {
3025       gen_conditional_branch (operands, LE);
3026       DONE;
3027     }
3028 }")
3029
3030 (define_expand "bgtu"
3031   [(set (pc)
3032         (if_then_else (gtu:CC (cc0)
3033                               (const_int 0))
3034                       (label_ref (match_operand 0 "" ""))
3035                       (pc)))]
3036   ""
3037   "
3038 {
3039   if (operands[0])              /* avoid unused code warning */
3040     {
3041       gen_conditional_branch (operands, GTU);
3042       DONE;
3043     }
3044 }")
3045
3046 (define_expand "bgeu"
3047   [(set (pc)
3048         (if_then_else (geu:CC (cc0)
3049                               (const_int 0))
3050                       (label_ref (match_operand 0 "" ""))
3051                       (pc)))]
3052   ""
3053   "
3054 {
3055   if (operands[0])              /* avoid unused code warning */
3056     {
3057       gen_conditional_branch (operands, GEU);
3058       DONE;
3059     }
3060 }")
3061
3062
3063 (define_expand "bltu"
3064   [(set (pc)
3065         (if_then_else (ltu:CC (cc0)
3066                               (const_int 0))
3067                       (label_ref (match_operand 0 "" ""))
3068                       (pc)))]
3069   ""
3070   "
3071 {
3072   if (operands[0])              /* avoid unused code warning */
3073     {
3074       gen_conditional_branch (operands, LTU);
3075       DONE;
3076     }
3077 }")
3078
3079 (define_expand "bleu"
3080   [(set (pc)
3081         (if_then_else (leu:CC (cc0)
3082                               (const_int 0))
3083                       (label_ref (match_operand 0 "" ""))
3084                       (pc)))]
3085   ""
3086   "
3087 {
3088   if (operands[0])              /* avoid unused code warning */
3089     {
3090       gen_conditional_branch (operands, LEU);
3091       DONE;
3092     }
3093 }")
3094
3095 \f
3096 ;;
3097 ;;  ....................
3098 ;;
3099 ;;      SETTING A REGISTER FROM A COMPARISON
3100 ;;
3101 ;;  ....................
3102
3103 (define_expand "seq"
3104   [(set (match_operand:SI 0 "register_operand" "=d")
3105         (eq:CC_EQ (match_dup 1)
3106                   (match_dup 2)))]
3107   ""
3108   "
3109 {
3110   extern rtx force_reg ();
3111
3112   if (branch_type != CMP_SI)
3113     FAIL;
3114
3115   /* set up operands from compare.  */
3116   operands[1] = branch_cmp[0];
3117   operands[2] = branch_cmp[1];
3118
3119   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
3120     operands[2] = force_reg (SImode, operands[2]);
3121
3122   /* fall through and generate default code */
3123 }")
3124
3125 (define_insn "seq_si"
3126   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
3127         (eq:CC_EQ (match_operand:SI 1 "register_operand" "%d,d,d")
3128                   (match_operand:SI 2 "uns_arith_operand" "J,d,K")))]
3129   ""
3130   "@
3131    sltu\\t%0,%1,1
3132    xor\\t%0,%1,%2\;sltu\\t%0,%0,1
3133    xori\\t%0,%1,%x2\;sltu\\t%0,%0,1"
3134  [(set_attr "type"      "arith,arith,arith")
3135    (set_attr "mode"     "SI,SI,SI")
3136    (set_attr "length"   "1,2,2")])
3137
3138 (define_split
3139   [(set (match_operand:SI 0 "register_operand" "")
3140         (eq:CC_EQ (match_operand:SI 1 "register_operand" "")
3141                   (match_operand:SI 2 "uns_arith_operand" "")))]
3142   "GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0"
3143   [(set (match_dup 0)
3144         (xor:SI (match_dup 1)
3145                 (match_dup 2)))
3146    (set (match_dup 0)
3147         (ltu:CC (match_dup 0)
3148                 (const_int 1)))]
3149   "")
3150
3151 (define_expand "sne"
3152   [(set (match_operand:SI 0 "register_operand" "=d")
3153         (ne:CC_EQ (match_dup 1)
3154                   (match_dup 2)))]
3155   ""
3156   "
3157 {
3158   extern rtx force_reg ();
3159
3160   if (branch_type != CMP_SI)
3161     FAIL;
3162
3163   /* set up operands from compare.  */
3164   operands[1] = branch_cmp[0];
3165   operands[2] = branch_cmp[1];
3166
3167   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
3168     operands[2] = force_reg (SImode, operands[2]);
3169
3170   /* fall through and generate default code */
3171 }")
3172
3173 (define_insn "sne_si"
3174   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
3175         (ne:CC_EQ (match_operand:SI 1 "register_operand" "%d,d,d")
3176                   (match_operand:SI 2 "uns_arith_operand" "J,d,K")))]
3177   ""
3178   "*
3179 {
3180   if (GET_CODE (operands[2]) != CONST_INT)
3181     return \"xor\\t%0,%1,%2\;sltu\\t%0,%.,%0\";
3182
3183   if (INTVAL (operands[2]) == 0)
3184     return \"sltu\\t%0,%.,%1\";
3185
3186   return \"xori\\t%0,%1,%x2\;sltu\\t%0,%.,%0\";
3187 }"
3188  [(set_attr "type"      "arith,arith,arith")
3189    (set_attr "mode"     "SI,SI,SI")
3190    (set_attr "length"   "1,2,2")])
3191
3192 (define_split
3193   [(set (match_operand:SI 0 "register_operand" "")
3194         (ne:CC_EQ (match_operand:SI 1 "register_operand" "")
3195                   (match_operand:SI 2 "uns_arith_operand" "")))]
3196   "GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0"
3197   [(set (match_dup 0)
3198         (xor:SI (match_dup 1)
3199                 (match_dup 2)))
3200    (set (match_dup 0)
3201         (gtu:CC (match_dup 0)
3202                 (const_int 0)))]
3203   "")
3204
3205 (define_expand "sgt"
3206   [(set (match_operand:SI 0 "register_operand" "=d")
3207         (gt:CC (match_dup 1)
3208                (match_dup 2)))]
3209   ""
3210   "
3211 {
3212   extern rtx force_reg ();
3213
3214   if (branch_type != CMP_SI)
3215     FAIL;
3216
3217   /* set up operands from compare.  */
3218   operands[1] = branch_cmp[0];
3219   operands[2] = branch_cmp[1];
3220
3221   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) != 0)
3222     operands[2] = force_reg (SImode, operands[2]);
3223
3224   /* fall through and generate default code */
3225 }")
3226
3227 (define_insn "sgt_si"
3228   [(set (match_operand:SI 0 "register_operand" "=d")
3229         (gt:CC (match_operand:SI 1 "register_operand" "d")
3230                (match_operand:SI 2 "reg_or_0_operand" "dJ")))]
3231   ""
3232   "slt\\t%0,%z2,%1"
3233  [(set_attr "type"      "arith")
3234    (set_attr "mode"     "SI")
3235    (set_attr "length"   "1")])
3236
3237 (define_expand "sge"
3238   [(set (match_operand:SI 0 "register_operand" "=d")
3239         (ge:CC (match_dup 1)
3240                (match_dup 2)))]
3241   ""
3242   "
3243 {
3244   if (branch_type != CMP_SI)
3245     FAIL;
3246
3247   /* set up operands from compare.  */
3248   operands[1] = branch_cmp[0];
3249   operands[2] = branch_cmp[1];
3250
3251   /* fall through and generate default code */
3252 }")
3253
3254 (define_insn "sge_si"
3255   [(set (match_operand:SI 0 "register_operand" "=d")
3256         (ge:CC (match_operand:SI 1 "register_operand" "d")
3257                (match_operand:SI 2 "arith_operand" "dI")))]
3258   ""
3259   "slt\\t%0,%1,%2\;xori\\t%0,%0,0x0001"
3260  [(set_attr "type"      "arith")
3261    (set_attr "mode"     "SI")
3262    (set_attr "length"   "2")])
3263
3264 (define_split
3265   [(set (match_operand:SI 0 "register_operand" "")
3266         (ge:CC (match_operand:SI 1 "register_operand" "")
3267                (match_operand:SI 2 "arith_operand" "")))]
3268   ""
3269   [(set (match_dup 0)
3270         (lt:CC (match_dup 1)
3271                (match_dup 2)))
3272    (set (match_dup 0)
3273         (xor:SI (match_dup 0)
3274                 (const_int 1)))]
3275   "")
3276
3277 (define_expand "slt"
3278   [(set (match_operand:SI 0 "register_operand" "=d")
3279         (lt:CC (match_dup 1)
3280                (match_dup 2)))]
3281   ""
3282   "
3283 {
3284   if (branch_type != CMP_SI)
3285     FAIL;
3286
3287   /* set up operands from compare.  */
3288   operands[1] = branch_cmp[0];
3289   operands[2] = branch_cmp[1];
3290
3291   /* fall through and generate default code */
3292 }")
3293
3294 (define_insn "slt_si"
3295   [(set (match_operand:SI 0 "register_operand" "=d")
3296         (lt:CC (match_operand:SI 1 "register_operand" "d")
3297                (match_operand:SI 2 "arith_operand" "dI")))]
3298   ""
3299   "slt\\t%0,%1,%2"
3300  [(set_attr "type"      "arith")
3301    (set_attr "mode"     "SI")
3302    (set_attr "length"   "1")])
3303
3304 (define_expand "sle"
3305   [(set (match_operand:SI 0 "register_operand" "=d")
3306         (le:CC (match_dup 1)
3307                (match_dup 2)))]
3308   ""
3309   "
3310 {
3311   extern rtx force_reg ();
3312
3313   if (branch_type != CMP_SI)
3314     FAIL;
3315
3316   /* set up operands from compare.  */
3317   operands[1] = branch_cmp[0];
3318   operands[2] = branch_cmp[1];
3319
3320   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32767)
3321     operands[2] = force_reg (SImode, operands[2]);
3322
3323   /* fall through and generate default code */
3324 }")
3325
3326 (define_insn "sle_si"
3327   [(set (match_operand:SI 0 "register_operand" "=d,d")
3328         (le:CC (match_operand:SI 1 "register_operand" "d,d")
3329                (match_operand:SI 2 "arith_operand" "d,I")))]
3330   "GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 32767"
3331   "@
3332    slt\\t%0,%z2,%1\;xori\\t%0,%0,0x0001
3333    slt\\t%0,%1,(%2+1)"
3334  [(set_attr "type"      "arith,arith")
3335    (set_attr "mode"     "SI,SI")
3336    (set_attr "length"   "2,1")])
3337
3338 (define_split
3339   [(set (match_operand:SI 0 "register_operand" "")
3340         (le:CC (match_operand:SI 1 "register_operand" "")
3341                (match_operand:SI 2 "register_operand" "")))]
3342   ""
3343   [(set (match_dup 0)
3344         (lt:CC (match_dup 2)
3345                (match_dup 1)))
3346    (set (match_dup 0)
3347         (xor:SI (match_dup 0)
3348                 (const_int 1)))]
3349   "")
3350
3351 (define_expand "sgtu"
3352   [(set (match_operand:SI 0 "register_operand" "=d")
3353         (gtu:CC (match_dup 1)
3354                 (match_dup 2)))]
3355   ""
3356   "
3357 {
3358   extern rtx force_reg ();
3359
3360   if (branch_type != CMP_SI)
3361     FAIL;
3362
3363   /* set up operands from compare.  */
3364   operands[1] = branch_cmp[0];
3365   operands[2] = branch_cmp[1];
3366
3367   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) != 0)
3368     operands[2] = force_reg (SImode, operands[2]);
3369
3370   /* fall through and generate default code */
3371 }")
3372
3373 (define_insn "sgtu_si"
3374   [(set (match_operand:SI 0 "register_operand" "=d")
3375         (gtu:CC (match_operand:SI 1 "register_operand" "d")
3376                 (match_operand:SI 2 "reg_or_0_operand" "dJ")))]
3377   ""
3378   "sltu\\t%0,%z2,%1"
3379  [(set_attr "type"      "arith")
3380    (set_attr "mode"     "SI")
3381    (set_attr "length"   "1")])
3382
3383 (define_expand "sgeu"
3384   [(set (match_operand:SI 0 "register_operand" "=d")
3385         (geu:CC (match_dup 1)
3386                 (match_dup 2)))]
3387   ""
3388   "
3389 {
3390   if (branch_type != CMP_SI)
3391     FAIL;
3392
3393   /* set up operands from compare.  */
3394   operands[1] = branch_cmp[0];
3395   operands[2] = branch_cmp[1];
3396
3397   /* fall through and generate default code */
3398 }")
3399
3400 (define_insn "sgeu_si"
3401   [(set (match_operand:SI 0 "register_operand" "=d")
3402         (geu:CC (match_operand:SI 1 "register_operand" "d")
3403                 (match_operand:SI 2 "arith_operand" "dI")))]
3404   ""
3405   "sltu\\t%0,%1,%2\;xori\\t%0,%0,0x0001"
3406  [(set_attr "type"      "arith")
3407    (set_attr "mode"     "SI")
3408    (set_attr "length"   "2")])
3409
3410 (define_split
3411   [(set (match_operand:SI 0 "register_operand" "")
3412         (geu:CC (match_operand:SI 1 "register_operand" "")
3413                 (match_operand:SI 2 "arith_operand" "")))]
3414   ""
3415   [(set (match_dup 0)
3416         (ltu:CC (match_dup 1)
3417                 (match_dup 2)))
3418    (set (match_dup 0)
3419         (xor:SI (match_dup 0)
3420                 (const_int 1)))]
3421   "")
3422
3423 (define_expand "sltu"
3424   [(set (match_operand:SI 0 "register_operand" "=d")
3425         (ltu:CC (match_dup 1)
3426                 (match_dup 2)))]
3427   ""
3428   "
3429 {
3430   if (branch_type != CMP_SI)
3431     FAIL;
3432
3433   /* set up operands from compare.  */
3434   operands[1] = branch_cmp[0];
3435   operands[2] = branch_cmp[1];
3436
3437   /* fall through and generate default code */
3438 }")
3439
3440 (define_insn "sltu_si"
3441   [(set (match_operand:SI 0 "register_operand" "=d")
3442         (ltu:CC (match_operand:SI 1 "register_operand" "d")
3443                 (match_operand:SI 2 "arith_operand" "dI")))]
3444   ""
3445   "sltu\\t%0,%1,%2"
3446  [(set_attr "type"      "arith")
3447    (set_attr "mode"     "SI")
3448    (set_attr "length"   "1")])
3449
3450 (define_expand "sleu"
3451   [(set (match_operand:SI 0 "register_operand" "=d")
3452         (leu:CC (match_dup 1)
3453                 (match_dup 2)))]
3454   ""
3455   "
3456 {
3457   extern rtx force_reg ();
3458
3459   if (branch_type != CMP_SI)
3460     FAIL;
3461
3462   /* set up operands from compare.  */
3463   operands[1] = branch_cmp[0];
3464   operands[2] = branch_cmp[1];
3465
3466   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32767)
3467     operands[2] = force_reg (SImode, operands[2]);
3468
3469   /* fall through and generate default code */
3470 }")
3471
3472 (define_insn "sleu_si"
3473   [(set (match_operand:SI 0 "register_operand" "=d,d")
3474         (leu:CC (match_operand:SI 1 "register_operand" "d,d")
3475                 (match_operand:SI 2 "arith_operand" "d,I")))]
3476   "GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 32767"
3477   "@
3478    sltu\\t%0,%z2,%1\;xori\\t%0,%0,0x0001
3479    sltu\\t%0,%1,(%2+1)"
3480  [(set_attr "type"      "arith,arith")
3481    (set_attr "mode"     "SI,SI")
3482    (set_attr "length"   "2,1")])
3483
3484 (define_split
3485   [(set (match_operand:SI 0 "register_operand" "")
3486         (leu:CC (match_operand:SI 1 "register_operand" "")
3487                 (match_operand:SI 2 "register_operand" "")))]
3488   ""
3489   [(set (match_dup 0)
3490         (ltu:CC (match_dup 2)
3491                 (match_dup 1)))
3492    (set (match_dup 0)
3493         (xor:SI (match_dup 0)
3494                 (const_int 1)))]
3495   "")
3496
3497 \f
3498 ;;
3499 ;;  ....................
3500 ;;
3501 ;;      UNCONDITIONAL BRANCHES
3502 ;;
3503 ;;  ....................
3504
3505 ;; Unconditional branches.
3506
3507 (define_insn "jump"
3508   [(set (pc)
3509         (label_ref (match_operand 0 "" "")))]
3510   ""
3511   "*
3512 {
3513   if (GET_CODE (operands[0]) == REG)
3514     return \"%*j\\t%0\";
3515   else
3516     return \"%*j\\t%l0\";
3517 }"
3518   [(set_attr "type"     "jump")
3519    (set_attr "mode"     "none")
3520    (set_attr "length"   "1")])
3521
3522 (define_insn "indirect_jump"
3523   [(set (pc) (match_operand:SI 0 "register_operand" "d"))]
3524   ""
3525   "%*j\\t%0"
3526   [(set_attr "type"     "jump")
3527    (set_attr "mode"     "none")
3528    (set_attr "length"   "1")])
3529
3530 (define_insn "tablejump"
3531   [(set (pc)
3532         (match_operand:SI 0 "register_operand" "d"))
3533    (use (label_ref (match_operand 1 "" "")))]
3534   ""
3535   "%*j\\t%0"
3536   [(set_attr "type"     "jump")
3537    (set_attr "mode"     "none")
3538    (set_attr "length"   "1")])
3539
3540 ;; Function return, only allow after optimization, so that we can
3541 ;; eliminate jumps to jumps if no stack space is used.
3542
3543 (define_insn "return"
3544   [(return)]
3545   "null_epilogue ()"
3546   "*
3547 {
3548   operands[0] = gen_rtx (REG, SImode, GP_REG_FIRST + 31);
3549   return \"%*j\\t%0\";
3550 }"
3551   [(set_attr "type"     "jump")
3552    (set_attr "mode"     "none")
3553    (set_attr "length"   "1")])
3554
3555 \f
3556 ;;
3557 ;;  ....................
3558 ;;
3559 ;;      FUNCTION CALLS
3560 ;;
3561 ;;  ....................
3562
3563 ;; calls.c now passes a third argument, make saber happy
3564
3565 (define_expand "call"
3566   [(parallel [(call (match_operand 0 "memory_operand" "m")
3567                     (match_operand 1 "" "i"))
3568               (clobber (match_operand 2 "" ""))])]      ;; overwrite op2 with $31
3569   ""
3570   "
3571 {
3572   rtx addr;
3573
3574   operands[2] = gen_rtx (REG, SImode, GP_REG_FIRST + 31);
3575
3576   addr = XEXP (operands[0], 0);
3577   if (GET_CODE (addr) != REG && !CONSTANT_ADDRESS_P (addr))
3578     XEXP (operands[0], 0) = force_reg (FUNCTION_MODE, addr);
3579 }")
3580
3581 (define_insn "call_internal"
3582   [(call (match_operand 0 "memory_operand" "m")
3583          (match_operand 1 "" "i"))
3584    (clobber (match_operand:SI 2 "register_operand" "=d"))]
3585   ""
3586   "*
3587 {
3588   register rtx target = XEXP (operands[0], 0);
3589
3590   if (GET_CODE (target) == SYMBOL_REF)
3591     return \"%*jal\\t%0\";
3592
3593   else
3594     {
3595       operands[0] = target;
3596       operands[1] = gen_rtx (REG, SImode, GP_REG_FIRST + 31);
3597       return \"%*jal\\t%1,%0\";
3598     }
3599 }"
3600   [(set_attr "type"     "call")
3601    (set_attr "mode"     "none")
3602    (set_attr "length"   "1")])
3603
3604 ;; calls.c now passes a fourth argument, make saber happy
3605
3606 (define_expand "call_value"
3607   [(parallel [(set (match_operand 0 "register_operand" "=df")
3608                    (call (match_operand 1 "memory_operand" "m")
3609                          (match_operand 2 "" "i")))
3610               (clobber (match_operand 3 "" ""))])]      ;; overwrite op3 with $31
3611   ""
3612   "
3613 {
3614   rtx addr;
3615
3616   operands[3] = gen_rtx (REG, SImode, GP_REG_FIRST + 31);
3617
3618   addr = XEXP (operands[1], 0);
3619   if (GET_CODE (addr) != REG && !CONSTANT_ADDRESS_P (addr))
3620     XEXP (operands[1], 0) = force_reg (FUNCTION_MODE, addr);
3621 }")
3622
3623 (define_insn "call_value_internal"
3624   [(set (match_operand 0 "register_operand" "=df")
3625         (call (match_operand 1 "memory_operand" "m")
3626               (match_operand 2 "" "i")))
3627    (clobber (match_operand:SI 3 "register_operand" "=d"))]
3628   ""
3629   "*
3630 {
3631   register rtx target = XEXP (operands[1], 0);
3632
3633   if (GET_CODE (target) == SYMBOL_REF)
3634     return \"%*jal\\t%1\";
3635
3636   else
3637     {
3638       operands[1] = target;
3639       operands[2] = gen_rtx (REG, SImode, GP_REG_FIRST + 31);
3640       return \"%*jal\\t%2,%1\";
3641     }
3642 }"
3643   [(set_attr "type"     "call")
3644    (set_attr "mode"     "none")
3645    (set_attr "length"   "1")])
3646
3647 \f
3648 ;;
3649 ;;  ....................
3650 ;;
3651 ;;      MISC.
3652 ;;
3653 ;;  ....................
3654 ;;
3655
3656 (define_insn "nop"
3657   [(const_int 0)]
3658   ""
3659   "%(nop%)"
3660   [(set_attr "type"     "nop")
3661    (set_attr "mode"     "none")
3662    (set_attr "length"   "1")])
3663
3664 (define_expand "probe"
3665   [(set (match_dup 0)
3666         (match_dup 1))]
3667   ""
3668   "
3669 {
3670   operands[0] = gen_reg_rtx (SImode);
3671   operands[1] = gen_rtx (MEM, SImode, stack_pointer_rtx);
3672   MEM_VOLATILE_P (operands[1]) = TRUE;
3673
3674   /* fall through and generate default code */
3675 }")
3676
3677 \f
3678 ;;
3679 ;; Local variables:
3680 ;; mode:emacs-lisp
3681 ;; comment-start: ";; "
3682 ;; eval: (set-syntax-table (copy-sequence (syntax-table)))
3683 ;; eval: (modify-syntax-entry ?[ "(]")
3684 ;; eval: (modify-syntax-entry ?] ")[")
3685 ;; eval: (modify-syntax-entry ?{ "(}")
3686 ;; eval: (modify-syntax-entry ?} "){")
3687 ;; End: