OSDN Git Service

(cpu): Add r4600.
[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 ;;  64 bit r4000 support by Ian Lance Taylor, ian@cygnus.com, and
5 ;;  Brendan Eich, brendan@microunity.com.
6 ;;  Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
7
8 ;; This file is part of GNU CC.
9
10 ;; GNU CC is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU CC is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU CC; see the file COPYING.  If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 \f
25
26 ;; ....................
27 ;;
28 ;;      Attributes
29 ;;
30 ;; ....................
31
32 ;; Classification of each insn.
33 ;; branch       conditional branch
34 ;; jump         unconditional jump
35 ;; call         unconditional call
36 ;; load         load instruction(s)
37 ;; store        store instruction(s)
38 ;; move         data movement within same register set
39 ;; xfer         transfer to/from coprocessor
40 ;; hilo         transfer of hi/lo registers
41 ;; arith        integer arithmetic instruction
42 ;; darith       double precision integer arithmetic instructions
43 ;; imul         integer multiply
44 ;; idiv         integer divide
45 ;; icmp         integer compare
46 ;; fadd         floating point add/subtract
47 ;; fmul         floating point multiply
48 ;; fdiv         floating point divide
49 ;; fabs         floating point absolute value
50 ;; fneg         floating point negation
51 ;; fcmp         floating point compare
52 ;; fcvt         floating point convert
53 ;; fsqrt        floating point square root
54 ;; multi        multiword sequence (or user asm statements)
55 ;; nop          no operation
56
57 (define_attr "type"
58   "unknown,branch,jump,call,load,store,move,xfer,hilo,arith,darith,imul,idiv,icmp,fadd,fmul,fdiv,fabs,fneg,fcmp,fcvt,fsqrt,multi,nop"
59   (const_string "unknown"))
60
61 ;; Main data type used by the insn
62 (define_attr "mode" "unknown,none,QI,HI,SI,DI,SF,DF,FPSW" (const_string "unknown"))
63
64 ;; # instructions (4 bytes each)
65 (define_attr "length" "" (const_int 1))
66
67 ;; whether or not an instruction has a mandatory delay slot
68 (define_attr "dslot" "no,yes"
69   (if_then_else (eq_attr "type" "branch,jump,call,load,xfer,hilo,fcmp")
70                 (const_string "yes")
71                 (const_string "no")))
72
73 ;; Attribute describing the processor.  This attribute must match exactly
74 ;; with the processor_type enumeration in mips.h.
75
76 ;; Attribute describing the processor
77 ;; (define_attr "cpu" "default,r3000,r6000,r4000"
78 ;;   (const
79 ;;    (cond [(eq (symbol_ref "mips_cpu") (symbol_ref "PROCESSOR_R3000"))   (const_string "r3000")
80 ;;           (eq (symbol_ref "mips_cpu") (symbol_ref "PROCESSOR_R4000"))   (const_string "r4000")
81 ;;           (eq (symbol_ref "mips_cpu") (symbol_ref "PROCESSOR_R6000"))   (const_string "r6000")]
82 ;;          (const_string "default"))))
83
84 (define_attr "cpu" "default,r3000,r6000,r4000,r4600"
85   (const (symbol_ref "mips_cpu_attr")))
86
87 ;; Attribute defining whether or not we can use the branch-likely instructions
88 ;; (MIPS ISA level 2)
89
90 (define_attr "branch_likely" "no,yes"
91   (const
92    (if_then_else (ge (symbol_ref "mips_isa") (const_int 2))
93                  (const_string "yes")
94                  (const_string "no"))))
95
96
97 ;; Describe a user's asm statement.
98 (define_asm_attributes
99   [(set_attr "type" "multi")])
100
101 ;; whether or not generating calls to position independent functions
102 (define_attr "abicalls" "no,yes"
103   (const (symbol_ref "mips_abicalls_attr")))
104
105 \f
106
107 ;; .........................
108 ;;
109 ;;      Delay slots, can't describe load/fcmp/xfer delay slots here
110 ;;
111 ;; .........................
112
113 (define_delay (eq_attr "type" "branch")
114   [(and (eq_attr "dslot" "no") (eq_attr "length" "1"))
115    (nil)
116    (and (eq_attr "branch_likely" "yes") (and (eq_attr "dslot" "no") (eq_attr "length" "1")))])
117
118 (define_delay (eq_attr "type" "jump")
119   [(and (eq_attr "dslot" "no") (eq_attr "length" "1"))
120    (nil)
121    (nil)])
122
123 (define_delay (and (eq_attr "type" "call") (eq_attr "abicalls" "no"))
124   [(and (eq_attr "dslot" "no") (eq_attr "length" "1"))
125    (nil)
126    (nil)])
127
128 \f
129
130 ;; .........................
131 ;;
132 ;;      Functional units
133 ;;
134 ;; .........................
135
136 ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
137 ;                       TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
138
139 ;; Make the default case (PROCESSOR_DEFAULT) handle the worst case
140
141 (define_function_unit "memory" 1 0
142   (and (eq_attr "type" "load") (eq_attr "cpu" "!r3000"))
143   3 0)
144
145 (define_function_unit "memory" 1 0
146   (and (eq_attr "type" "load") (eq_attr "cpu" "r3000,r4600"))
147   2 0)
148
149 (define_function_unit "memory"   1 0 (eq_attr "type" "store") 1 0)
150
151 (define_function_unit "memory"   1 0 (eq_attr "type" "xfer") 2 0)
152
153 (define_function_unit "imuldiv"  1 0
154   (eq_attr "type" "hilo")
155   1 3)
156
157 (define_function_unit "imuldiv"  1 0
158   (and (eq_attr "type" "imul") (eq_attr "cpu" "!r3000,r4000,r4600"))
159   17 17)
160
161 (define_function_unit "imuldiv"  1 0
162   (and (eq_attr "type" "imul") (eq_attr "cpu" "r3000"))
163   12 12)
164
165 (define_function_unit "imuldiv"  1 0
166   (and (eq_attr "type" "imul") (eq_attr "cpu" "r4000,r4600"))
167   10 10)
168
169 (define_function_unit "imuldiv"  1 0
170   (and (eq_attr "type" "idiv") (eq_attr "cpu" "!r3000,r4000,r4600"))
171   38 38)
172
173 (define_function_unit "imuldiv"  1 0
174   (and (eq_attr "type" "idiv") (eq_attr "cpu" "r3000"))
175   35 35)
176
177 (define_function_unit "imuldiv"  1 0
178   (and (eq_attr "type" "idiv") (eq_attr "cpu" "r4600"))
179   42 42)
180
181 (define_function_unit "imuldiv"  1 0
182   (and (eq_attr "type" "idiv") (eq_attr "cpu" "r4000"))
183   69 69)
184
185 (define_function_unit "adder" 1 1
186   (and (eq_attr "type" "fcmp") (eq_attr "cpu" "!r3000,r6000"))
187   3 0)
188
189 (define_function_unit "adder" 1 1
190   (and (eq_attr "type" "fcmp") (eq_attr "cpu" "r3000,r6000"))
191   2 0)
192
193 (define_function_unit "adder" 1 1
194   (and (eq_attr "type" "fadd") (eq_attr "cpu" "!r3000,r6000"))
195   4 0)
196
197 (define_function_unit "adder" 1 1
198   (and (eq_attr "type" "fadd") (eq_attr "cpu" "r3000"))
199   2 0)
200
201 (define_function_unit "adder" 1 1
202   (and (eq_attr "type" "fadd") (eq_attr "cpu" "r6000"))
203   3 0)
204
205 (define_function_unit "adder" 1 1
206   (and (eq_attr "type" "fabs,fneg") (eq_attr "cpu" "!r3000,r4600"))
207   2 0)
208
209 (define_function_unit "adder" 1 1
210   (and (eq_attr "type" "fabs,fneg") (eq_attr "cpu" "r3000,r4600"))
211   1 0)
212
213 (define_function_unit "mult" 1 1
214   (and (eq_attr "type" "fmul") (and (eq_attr "mode" "SF") (eq_attr "cpu" "!r3000,r6000,r4600")))
215   7 0)
216
217 (define_function_unit "mult" 1 1
218   (and (eq_attr "type" "fmul") (and (eq_attr "mode" "SF") (eq_attr "cpu" "r3000")))
219   4 0)
220
221 (define_function_unit "mult" 1 1
222   (and (eq_attr "type" "fmul") (and (eq_attr "mode" "SF") (eq_attr "cpu" "r6000")))
223   5 0)
224
225 (define_function_unit "mult" 1 1
226   (and (eq_attr "type" "fmul") (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4600")))
227   8 0)
228
229 (define_function_unit "mult" 1 1
230   (and (eq_attr "type" "fmul") (and (eq_attr "mode" "DF") (eq_attr "cpu" "!r3000,r6000")))
231   8 0)
232
233 (define_function_unit "mult" 1 1
234   (and (eq_attr "type" "fmul") (and (eq_attr "mode" "DF") (eq_attr "cpu" "r3000")))
235   5 0)
236
237 (define_function_unit "mult" 1 1
238   (and (eq_attr "type" "fmul") (and (eq_attr "mode" "DF") (eq_attr "cpu" "r6000")))
239   6 0)
240
241 (define_function_unit "divide" 1 1
242   (and (eq_attr "type" "fdiv") (and (eq_attr "mode" "SF") (eq_attr "cpu" "!r3000,r6000,r4600")))
243   23 0)
244
245 (define_function_unit "divide" 1 1
246   (and (eq_attr "type" "fdiv") (and (eq_attr "mode" "SF") (eq_attr "cpu" "r3000")))
247   12 0)
248
249 (define_function_unit "divide" 1 1
250   (and (eq_attr "type" "fdiv") (and (eq_attr "mode" "SF") (eq_attr "cpu" "r6000")))
251   15 0)
252
253 (define_function_unit "divide" 1 1
254   (and (eq_attr "type" "fdiv") (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4600")))
255   32 0)
256
257 (define_function_unit "divide" 1 1
258   (and (eq_attr "type" "fdiv") (and (eq_attr "mode" "DF") (eq_attr "cpu" "!r3000,r6000,r4600")))
259   36 0)
260
261 (define_function_unit "divide" 1 1
262   (and (eq_attr "type" "fdiv") (and (eq_attr "mode" "DF") (eq_attr "cpu" "r3000")))
263   19 0)
264
265 (define_function_unit "divide" 1 1
266   (and (eq_attr "type" "fdiv") (and (eq_attr "mode" "DF") (eq_attr "cpu" "r6000")))
267   16 0)
268
269 (define_function_unit "divide" 1 1
270   (and (eq_attr "type" "fdiv") (and (eq_attr "mode" "DF") (eq_attr "cpu" "r4600")))
271   61 0)
272
273 ;;; ??? Is this number right?
274 (define_function_unit "divide" 1 1
275   (and (eq_attr "type" "fsqrt") (and (eq_attr "mode" "SF") (eq_attr "cpu" "!r4600")))
276   54 0)
277 (define_function_unit "divide" 1 1
278   (and (eq_attr "type" "fsqrt") (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4600")))
279   31 0)
280
281 ;;; ??? Is this number right?
282 (define_function_unit "divide" 1 1
283   (and (eq_attr "type" "fsqrt") (and (eq_attr "mode" "DF") (eq_attr "cpu" "!r4600")))
284   112 0)
285 (define_function_unit "divide" 1 1
286   (and (eq_attr "type" "fsqrt") (and (eq_attr "mode" "DF") (eq_attr "cpu" "r4600")))
287   60 0)
288
289 \f
290 ;; The following functional units do not use the cpu type, and use
291 ;; much less memory in genattrtab.c.
292
293 ;; (define_function_unit "memory"   1 0 (eq_attr "type" "load")                                3 0)
294 ;; (define_function_unit "memory"   1 0 (eq_attr "type" "store")                               1 0)
295 ;;       
296 ;; (define_function_unit "fp_comp"  1 0 (eq_attr "type" "fcmp")                                2 0)
297 ;;       
298 ;; (define_function_unit "transfer" 1 0 (eq_attr "type" "xfer")                                2 0)
299 ;; (define_function_unit "transfer" 1 0 (eq_attr "type" "hilo")                                3 0)
300 ;;   
301 ;; (define_function_unit "imuldiv"  1 1 (eq_attr "type" "imul")                               17 0)
302 ;; (define_function_unit "imuldiv"  1 1 (eq_attr "type" "idiv")                               38 0)
303 ;;   
304 ;; (define_function_unit "adder"    1 1 (eq_attr "type" "fadd")                                4 0)
305 ;; (define_function_unit "adder"    1 1 (eq_attr "type" "fabs,fneg")                           2 0)
306 ;;   
307 ;; (define_function_unit "mult"     1 1 (and (eq_attr "type" "fmul") (eq_attr "mode" "SF"))    7 0)
308 ;; (define_function_unit "mult"     1 1 (and (eq_attr "type" "fmul") (eq_attr "mode" "DF"))    8 0)
309 ;;   
310 ;; (define_function_unit "divide"   1 1 (and (eq_attr "type" "fdiv") (eq_attr "mode" "SF"))   23 0)
311 ;; (define_function_unit "divide"   1 1 (and (eq_attr "type" "fdiv") (eq_attr "mode" "DF"))   36 0)
312 ;; 
313 ;; (define_function_unit "sqrt"     1 1 (and (eq_attr "type" "fsqrt") (eq_attr "mode" "SF"))  54 0)
314 ;; (define_function_unit "sqrt"     1 1 (and (eq_attr "type" "fsqrt") (eq_attr "mode" "DF")) 112 0)
315
316 \f
317 ;;
318 ;;  ....................
319 ;;
320 ;;      ADDITION
321 ;;
322 ;;  ....................
323 ;;
324
325 (define_insn "adddf3"
326   [(set (match_operand:DF 0 "register_operand" "=f")
327         (plus:DF (match_operand:DF 1 "register_operand" "f")
328                  (match_operand:DF 2 "register_operand" "f")))]
329   "TARGET_HARD_FLOAT"
330   "add.d\\t%0,%1,%2"
331   [(set_attr "type"     "fadd")
332    (set_attr "mode"     "DF")
333    (set_attr "length"   "1")])
334
335 (define_insn "addsf3"
336   [(set (match_operand:SF 0 "register_operand" "=f")
337         (plus:SF (match_operand:SF 1 "register_operand" "f")
338                  (match_operand:SF 2 "register_operand" "f")))]
339   "TARGET_HARD_FLOAT"
340   "add.s\\t%0,%1,%2"
341   [(set_attr "type"     "fadd")
342    (set_attr "mode"     "SF")
343    (set_attr "length"   "1")])
344
345 (define_expand "addsi3"
346   [(set (match_operand:SI 0 "register_operand" "=d")
347         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
348                  (match_operand:SI 2 "arith_operand" "dI")))]
349   ""
350   "
351 {
352   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == -32768)
353     operands[2] = force_reg (SImode, operands[2]);
354 }")
355
356 (define_insn "addsi3_internal"
357   [(set (match_operand:SI 0 "register_operand" "=d")
358         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
359                  (match_operand:SI 2 "arith_operand" "dI")))]
360   "GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != -32768"
361   "*
362 {
363   return (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
364     ? \"subu\\t%0,%z1,%n2\"
365     : \"addu\\t%0,%z1,%2\";
366 }"
367   [(set_attr "type"     "arith")
368    (set_attr "mode"     "SI")
369    (set_attr "length"   "1")])
370
371 (define_expand "adddi3"
372   [(parallel [(set (match_operand:DI 0 "register_operand" "")
373                    (plus:DI (match_operand:DI 1 "register_operand" "")
374                             (match_operand:DI 2 "arith_operand" "")))
375               (clobber (match_dup 3))])]
376   "TARGET_64BIT || !TARGET_DEBUG_G_MODE"
377   "
378 {
379   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == -32768)
380     operands[2] = force_reg (DImode, operands[2]);
381
382   if (TARGET_64BIT)
383     {
384       emit_insn (gen_adddi3_internal_3 (operands[0], operands[1],
385                                         operands[2]));
386       DONE;
387     }
388
389   operands[3] = gen_reg_rtx (SImode);
390 }")
391
392 (define_insn "adddi3_internal_1"
393   [(set (match_operand:DI 0 "register_operand" "=d,&d")
394         (plus:DI (match_operand:DI 1 "register_operand" "0,d")
395                  (match_operand:DI 2 "register_operand" "d,d")))
396    (clobber (match_operand:SI 3 "register_operand" "=d,d"))]
397   "!TARGET_64BIT && !TARGET_DEBUG_G_MODE"
398   "*
399 {
400   return (REGNO (operands[0]) == REGNO (operands[1])
401           && REGNO (operands[0]) == REGNO (operands[2]))
402     ? \"srl\\t%3,%L0,31\;sll\\t%M0,%M0,1\;sll\\t%L0,%L1,1\;addu\\t%M0,%M0,%3\"
403     : \"addu\\t%L0,%L1,%L2\;sltu\\t%3,%L0,%L2\;addu\\t%M0,%M1,%M2\;addu\\t%M0,%M0,%3\";
404 }"
405   [(set_attr "type"     "darith")
406    (set_attr "mode"     "DI")
407    (set_attr "length"   "4")])
408
409 (define_split
410   [(set (match_operand:DI 0 "register_operand" "")
411         (plus:DI (match_operand:DI 1 "register_operand" "")
412                  (match_operand:DI 2 "register_operand" "")))
413    (clobber (match_operand:SI 3 "register_operand" ""))]
414   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
415    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
416    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
417    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))
418    && (REGNO (operands[0]) != REGNO (operands[1])
419        || REGNO (operands[0]) != REGNO (operands[2]))"
420
421   [(set (subreg:SI (match_dup 0) 0)
422         (plus:SI (subreg:SI (match_dup 1) 0)
423                  (subreg:SI (match_dup 2) 0)))
424
425    (set (match_dup 3)
426         (ltu:SI (subreg:SI (match_dup 0) 0)
427                 (subreg:SI (match_dup 2) 0)))
428
429    (set (subreg:SI (match_dup 0) 1)
430         (plus:SI (subreg:SI (match_dup 1) 1)
431                  (subreg:SI (match_dup 2) 1)))
432
433    (set (subreg:SI (match_dup 0) 1)
434         (plus:SI (subreg:SI (match_dup 0) 1)
435                  (match_dup 3)))]
436   "")
437
438 (define_split
439   [(set (match_operand:DI 0 "register_operand" "")
440         (plus:DI (match_operand:DI 1 "register_operand" "")
441                  (match_operand:DI 2 "register_operand" "")))
442    (clobber (match_operand:SI 3 "register_operand" ""))]
443   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
444    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
445    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
446    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))
447    && (REGNO (operands[0]) != REGNO (operands[1])
448        || REGNO (operands[0]) != REGNO (operands[2]))"
449
450   [(set (subreg:SI (match_dup 0) 1)
451         (plus:SI (subreg:SI (match_dup 1) 1)
452                  (subreg:SI (match_dup 2) 1)))
453
454    (set (match_dup 3)
455         (ltu:SI (subreg:SI (match_dup 0) 1)
456                 (subreg:SI (match_dup 2) 1)))
457
458    (set (subreg:SI (match_dup 0) 0)
459         (plus:SI (subreg:SI (match_dup 1) 0)
460                  (subreg:SI (match_dup 2) 0)))
461
462    (set (subreg:SI (match_dup 0) 0)
463         (plus:SI (subreg:SI (match_dup 0) 0)
464                  (match_dup 3)))]
465   "")
466
467 (define_insn "adddi3_internal_2"
468   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
469         (plus:DI (match_operand:DI 1 "register_operand" "%d,%d,%d")
470                  (match_operand:DI 2 "small_int" "P,J,N")))
471    (clobber (match_operand:SI 3 "register_operand" "=d,d,d"))]
472   "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && INTVAL (operands[2]) != -32768"
473   "@
474    addu\\t%L0,%L1,%2\;sltu\\t%3,%L0,%2\;addu\\t%M0,%M1,%3
475    move\\t%L0,%L1\;move\\t%M0,%M1
476    subu\\t%L0,%L1,%n2\;sltu\\t%3,%L0,%2\;subu\\t%M0,%M1,1\;addu\\t%M0,%M0,%3"
477   [(set_attr "type"     "darith")
478    (set_attr "mode"     "DI")
479    (set_attr "length"   "3,2,4")])
480
481 (define_split
482   [(set (match_operand:DI 0 "register_operand" "")
483         (plus:DI (match_operand:DI 1 "register_operand" "")
484                  (match_operand:DI 2 "small_int" "")))
485    (clobber (match_operand:SI 3 "register_operand" "=d"))]
486   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
487    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
488    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
489    && INTVAL (operands[2]) > 0"
490
491   [(set (subreg:SI (match_dup 0) 0)
492         (plus:SI (subreg:SI (match_dup 1) 0)
493                  (match_dup 2)))
494
495    (set (match_dup 3)
496         (ltu:SI (subreg:SI (match_dup 0) 0)
497                 (match_dup 2)))
498
499    (set (subreg:SI (match_dup 0) 1)
500         (plus:SI (subreg:SI (match_dup 1) 1)
501                  (match_dup 3)))]
502   "")
503
504 (define_split
505   [(set (match_operand:DI 0 "register_operand" "")
506         (plus:DI (match_operand:DI 1 "register_operand" "")
507                  (match_operand:DI 2 "small_int" "")))
508    (clobber (match_operand:SI 3 "register_operand" "=d"))]
509   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
510    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
511    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
512    && INTVAL (operands[2]) > 0"
513
514   [(set (subreg:SI (match_dup 0) 1)
515         (plus:SI (subreg:SI (match_dup 1) 1)
516                  (match_dup 2)))
517
518    (set (match_dup 3)
519         (ltu:SI (subreg:SI (match_dup 0) 1)
520                 (match_dup 2)))
521
522    (set (subreg:SI (match_dup 0) 0)
523         (plus:SI (subreg:SI (match_dup 1) 0)
524                  (match_dup 3)))]
525   "")
526
527 (define_insn "adddi3_internal_3"
528   [(set (match_operand:DI 0 "register_operand" "=d")
529         (plus:DI (match_operand:DI 1 "reg_or_0_operand" "dJ")
530                  (match_operand:DI 2 "arith_operand" "dI")))]
531   "TARGET_64BIT && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != -32768)"
532   "*
533 {
534   return (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
535     ? \"dsubu\\t%0,%z1,%n2\"
536     : \"daddu\\t%0,%z1,%2\";
537 }"
538   [(set_attr "type"     "darith")
539    (set_attr "mode"     "DI")
540    (set_attr "length"   "1")])
541
542
543 (define_insn "addsi3_internal_2"
544   [(set (match_operand:DI 0 "register_operand" "=d")
545         (sign_extend:DI (plus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
546                                  (match_operand:SI 2 "arith_operand" "dI"))))]
547   "TARGET_64BIT && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != -32768)"
548   "*
549 {
550   return (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
551     ? \"subu\\t%0,%z1,%n2\"
552     : \"addu\\t%0,%z1,%2\";
553 }"
554   [(set_attr "type"     "arith")
555    (set_attr "mode"     "SI")
556    (set_attr "length"   "1")])
557
558 \f
559 ;;
560 ;;  ....................
561 ;;
562 ;;      SUBTRACTION
563 ;;
564 ;;  ....................
565 ;;
566
567 (define_insn "subdf3"
568   [(set (match_operand:DF 0 "register_operand" "=f")
569         (minus:DF (match_operand:DF 1 "register_operand" "f")
570                   (match_operand:DF 2 "register_operand" "f")))]
571   "TARGET_HARD_FLOAT"
572   "sub.d\\t%0,%1,%2"
573   [(set_attr "type"     "fadd")
574    (set_attr "mode"     "DF")
575    (set_attr "length"   "1")])
576
577 (define_insn "subsf3"
578   [(set (match_operand:SF 0 "register_operand" "=f")
579         (minus:SF (match_operand:SF 1 "register_operand" "f")
580                   (match_operand:SF 2 "register_operand" "f")))]
581   "TARGET_HARD_FLOAT"
582   "sub.s\\t%0,%1,%2"
583   [(set_attr "type"     "fadd")
584    (set_attr "mode"     "SF")
585    (set_attr "length"   "1")])
586
587 (define_expand "subsi3"
588   [(set (match_operand:SI 0 "register_operand" "=d")
589         (minus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
590                   (match_operand:SI 2 "arith_operand" "dI")))]
591   ""
592   "
593 {
594   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == -32768)
595     operands[2] = force_reg (SImode, operands[2]);
596 }")
597
598 (define_insn "subsi3_internal"
599   [(set (match_operand:SI 0 "register_operand" "=d")
600         (minus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
601                   (match_operand:SI 2 "arith_operand" "dI")))]
602   "GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != -32768"
603   "*
604 {
605   return (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
606     ? \"addu\\t%0,%z1,%n2\"
607     : \"subu\\t%0,%z1,%2\";
608 }"
609   [(set_attr "type"     "arith")
610    (set_attr "mode"     "SI")
611    (set_attr "length"   "1")])
612
613 (define_expand "subdi3"
614   [(parallel [(set (match_operand:DI 0 "register_operand" "=d")
615                    (minus:DI (match_operand:DI 1 "register_operand" "d")
616                              (match_operand:DI 2 "register_operand" "d")))
617               (clobber (match_dup 3))])]
618   "TARGET_64BIT || !TARGET_DEBUG_G_MODE"
619   "
620 {
621   if (TARGET_64BIT)
622     {
623       emit_insn (gen_subdi3_internal_3 (operands[0], operands[1],
624                                         operands[2]));
625       DONE;
626     }
627
628   operands[3] = gen_reg_rtx (SImode);
629 }")
630
631 (define_insn "subdi3_internal"
632   [(set (match_operand:DI 0 "register_operand" "=d")
633         (minus:DI (match_operand:DI 1 "register_operand" "d")
634                   (match_operand:DI 2 "register_operand" "d")))
635    (clobber (match_operand:SI 3 "register_operand" "=d"))]
636   "!TARGET_64BIT && !TARGET_DEBUG_G_MODE"
637   "sltu\\t%3,%L1,%L2\;subu\\t%L0,%L1,%L2\;subu\\t%M0,%M1,%M2\;subu\\t%M0,%M0,%3"
638   [(set_attr "type"     "darith")
639    (set_attr "mode"     "DI")
640    (set_attr "length"   "4")])
641
642 (define_split
643   [(set (match_operand:DI 0 "register_operand" "")
644         (minus:DI (match_operand:DI 1 "register_operand" "")
645                   (match_operand:DI 2 "register_operand" "")))
646    (clobber (match_operand:SI 3 "register_operand" ""))]
647   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
648    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
649    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
650    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
651
652   [(set (match_dup 3)
653         (ltu:SI (subreg:SI (match_dup 1) 0)
654                 (subreg:SI (match_dup 2) 0)))
655
656    (set (subreg:SI (match_dup 0) 0)
657         (minus:SI (subreg:SI (match_dup 1) 0)
658                   (subreg:SI (match_dup 2) 0)))
659
660    (set (subreg:SI (match_dup 0) 1)
661         (minus:SI (subreg:SI (match_dup 1) 1)
662                   (subreg:SI (match_dup 2) 1)))
663
664    (set (subreg:SI (match_dup 0) 1)
665         (minus:SI (subreg:SI (match_dup 0) 1)
666                   (match_dup 3)))]
667   "")
668
669 (define_split
670   [(set (match_operand:DI 0 "register_operand" "")
671         (minus:DI (match_operand:DI 1 "register_operand" "")
672                   (match_operand:DI 2 "register_operand" "")))
673    (clobber (match_operand:SI 3 "register_operand" ""))]
674   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
675    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
676    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
677    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
678
679   [(set (match_dup 3)
680         (ltu:SI (subreg:SI (match_dup 1) 1)
681                 (subreg:SI (match_dup 2) 1)))
682
683    (set (subreg:SI (match_dup 0) 1)
684         (minus:SI (subreg:SI (match_dup 1) 1)
685                   (subreg:SI (match_dup 2) 1)))
686
687    (set (subreg:SI (match_dup 0) 0)
688         (minus:SI (subreg:SI (match_dup 1) 0)
689                   (subreg:SI (match_dup 2) 0)))
690
691    (set (subreg:SI (match_dup 0) 0)
692         (minus:SI (subreg:SI (match_dup 0) 0)
693                   (match_dup 3)))]
694   "")
695
696 (define_insn "subdi3_internal_2"
697   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
698         (minus:DI (match_operand:DI 1 "register_operand" "d,d,d")
699                   (match_operand:DI 2 "small_int" "P,J,N")))
700    (clobber (match_operand:SI 3 "register_operand" "=d,d,d"))]
701   "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && INTVAL (operands[2]) != -32768"
702   "@
703    sltu\\t%3,%L1,%2\;subu\\t%L0,%L1,%2\;subu\\t%M0,%M1,%3
704    move\\t%L0,%L1\;move\\t%M0,%M1
705    sltu\\t%3,%L1,%2\;subu\\t%L0,%L1,%2\;subu\\t%M0,%M1,1\;subu\\t%M0,%M0,%3"
706   [(set_attr "type"     "darith")
707    (set_attr "mode"     "DI")
708    (set_attr "length"   "3,2,4")])
709
710 (define_split
711   [(set (match_operand:DI 0 "register_operand" "")
712         (minus:DI (match_operand:DI 1 "register_operand" "")
713                   (match_operand:DI 2 "small_int" "")))
714    (clobber (match_operand:SI 3 "register_operand" ""))]
715   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
716    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
717    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
718    && INTVAL (operands[2]) > 0"
719
720   [(set (match_dup 3)
721         (ltu:SI (subreg:SI (match_dup 1) 0)
722                 (match_dup 2)))
723
724    (set (subreg:SI (match_dup 0) 0)
725         (minus:SI (subreg:SI (match_dup 1) 0)
726                   (match_dup 2)))
727
728    (set (subreg:SI (match_dup 0) 1)
729         (minus:SI (subreg:SI (match_dup 1) 1)
730                   (match_dup 3)))]
731   "")
732
733 (define_split
734   [(set (match_operand:DI 0 "register_operand" "")
735         (minus:DI (match_operand:DI 1 "register_operand" "")
736                   (match_operand:DI 2 "small_int" "")))
737    (clobber (match_operand:SI 3 "register_operand" ""))]
738   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
739    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
740    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
741    && INTVAL (operands[2]) > 0"
742
743   [(set (match_dup 3)
744         (ltu:SI (subreg:SI (match_dup 1) 1)
745                 (match_dup 2)))
746
747    (set (subreg:SI (match_dup 0) 1)
748         (minus:SI (subreg:SI (match_dup 1) 1)
749                   (match_dup 2)))
750
751    (set (subreg:SI (match_dup 0) 0)
752         (minus:SI (subreg:SI (match_dup 1) 0)
753                   (match_dup 3)))]
754   "")
755
756 (define_insn "subdi3_internal_3"
757   [(set (match_operand:DI 0 "register_operand" "=d")
758         (minus:DI (match_operand:DI 1 "reg_or_0_operand" "dJ")
759                   (match_operand:DI 2 "arith_operand" "dI")))]
760   "TARGET_64BIT && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != -32768)"
761   "*
762 {
763   return (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
764     ? \"daddu\\t%0,%z1,%n2\"
765     : \"dsubu\\t%0,%z1,%2\";
766 }"
767   [(set_attr "type"     "darith")
768    (set_attr "mode"     "DI")
769    (set_attr "length"   "1")])
770
771
772 (define_insn "subsi3_internal_2"
773   [(set (match_operand:DI 0 "register_operand" "=d")
774         (sign_extend:DI (minus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
775                                   (match_operand:SI 2 "arith_operand" "dI"))))]
776   "TARGET_64BIT && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != -32768)"
777   "*
778 {
779   return (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
780     ? \"addu\\t%0,%z1,%n2\"
781     : \"subu\\t%0,%z1,%2\";
782 }"
783   [(set_attr "type"     "arith")
784    (set_attr "mode"     "DI")
785    (set_attr "length"   "1")])
786
787 \f
788 ;;
789 ;;  ....................
790 ;;
791 ;;      MULTIPLICATION
792 ;;
793 ;;  ....................
794 ;;
795
796 (define_insn "muldf3"
797   [(set (match_operand:DF 0 "register_operand" "=f")
798         (mult:DF (match_operand:DF 1 "register_operand" "f")
799                  (match_operand:DF 2 "register_operand" "f")))]
800   "TARGET_HARD_FLOAT"
801   "mul.d\\t%0,%1,%2"
802   [(set_attr "type"     "fmul")
803    (set_attr "mode"     "DF")
804    (set_attr "length"   "1")])
805
806 (define_insn "mulsf3"
807   [(set (match_operand:SF 0 "register_operand" "=f")
808         (mult:SF (match_operand:SF 1 "register_operand" "f")
809                  (match_operand:SF 2 "register_operand" "f")))]
810   "TARGET_HARD_FLOAT"
811   "mul.s\\t%0,%1,%2"
812   [(set_attr "type"     "fmul")
813    (set_attr "mode"     "SF")
814    (set_attr "length"   "1")])
815
816 (define_insn "mulsi3"
817   [(set (match_operand:SI 0 "register_operand" "=d")
818         (mult:SI (match_operand:SI 1 "register_operand" "d")
819                  (match_operand:SI 2 "register_operand" "d")))
820    (clobber (reg:SI 64))
821    (clobber (reg:SI 65))]
822   ""
823   "*
824 {
825   rtx xoperands[10];
826
827   xoperands[0] = operands[0];
828   xoperands[1] = gen_rtx (REG, SImode, LO_REGNUM);
829
830   output_asm_insn (\"mult\\t%1,%2\", operands);
831   output_asm_insn (mips_move_1word (xoperands, insn, FALSE), xoperands);
832   return \"\";
833 }"
834   [(set_attr "type"     "imul")
835    (set_attr "mode"     "SI")
836    (set_attr "length"   "3")])          ;; mult + mflo + delay
837
838 ;; ??? The R4000 (only) has a cpu bug.  If a double-word shift executes while
839 ;; a multiply is in progress, it may give an incorrect result.  We solve
840 ;; this by not splitting on the r4000.
841
842 (define_split
843   [(set (match_operand:SI 0 "register_operand" "")
844         (mult:SI (match_operand:SI 1 "register_operand" "")
845                  (match_operand:SI 2 "register_operand" "")))
846    (clobber (reg:SI 64))
847    (clobber (reg:SI 65))]
848   "!TARGET_DEBUG_D_MODE && mips_cpu != PROCESSOR_R4000"
849   [(parallel [(set (reg:SI 65)          ;; low register
850                    (mult:SI (match_dup 1)
851                             (match_dup 2)))
852               (clobber (reg:SI 64))])
853    (set (match_dup 0)
854         (reg:SI 65))]
855   "")
856
857 (define_insn "mulsi3_internal"
858   [(set (reg:SI 65)             ;; low register
859         (mult:SI (match_operand:SI 0 "register_operand" "d")
860                  (match_operand:SI 1 "register_operand" "d")))
861    (clobber (reg:SI 64))]
862   ""
863   "mult\\t%0,%1"
864   [(set_attr "type"     "imul")
865    (set_attr "mode"     "SI")
866    (set_attr "length"   "1")])
867
868 (define_insn "muldi3"
869   [(set (match_operand:DI 0 "register_operand" "=d")
870         (mult:DI (match_operand:DI 1 "register_operand" "d")
871                  (match_operand:DI 2 "register_operand" "d")))
872    (clobber (reg:DI 64))
873    (clobber (reg:DI 65))]
874   "TARGET_64BIT"
875   "*
876 {
877   rtx xoperands[10];
878
879   xoperands[0] = operands[0];
880   xoperands[1] = gen_rtx (REG, DImode, LO_REGNUM);
881
882   output_asm_insn (\"dmult\\t%1,%2\", operands);
883   output_asm_insn (mips_move_1word (xoperands, insn, FALSE), xoperands);
884   return \"\";
885 }"
886   [(set_attr "type"     "imul")
887    (set_attr "mode"     "DI")
888    (set_attr "length"   "3")])          ;; mult + mflo + delay
889
890 ;; ??? The R4000 (only) has a cpu bug.  If a double-word shift executes while
891 ;; a multiply is in progress, it may give an incorrect result.  We solve
892 ;; this by not splitting on the r4000.
893
894 (define_split
895   [(set (match_operand:DI 0 "register_operand" "")
896         (mult:DI (match_operand:DI 1 "register_operand" "")
897                  (match_operand:DI 2 "register_operand" "")))
898    (clobber (reg:DI 64))
899    (clobber (reg:DI 65))]
900   "TARGET_64BIT && !TARGET_DEBUG_D_MODE && mips_cpu != PROCESSOR_R4000"
901   [(parallel [(set (reg:DI 65)          ;; low register
902                    (mult:DI (match_dup 1)
903                             (match_dup 2)))
904               (clobber (reg:DI 64))])
905    (set (match_dup 0)
906         (reg:DI 65))]
907   "")
908
909 (define_insn "muldi3_internal"
910   [(set (reg:DI 65)             ;; low register
911         (mult:DI (match_operand:DI 0 "register_operand" "d")
912                  (match_operand:DI 1 "register_operand" "d")))
913    (clobber (reg:DI 64))]
914   "TARGET_64BIT"
915   "dmult\\t%0,%1"
916   [(set_attr "type"     "imul")
917    (set_attr "mode"     "DI")
918    (set_attr "length"   "1")])
919
920 ;; In 64 bit mode the mult instruction still writes 32 bits each to HI
921 ;; and LO, so to do mulsidi3 and umultsidi3 we need to pull the values
922 ;; out and combine them by hand into the single output register.  Not
923 ;; supported for now.
924
925 ;; ??? We could define a mulditi3 pattern when TARGET_64BIT.
926
927 (define_insn "mulsidi3"
928   [(set (match_operand:DI 0 "register_operand" "=d")
929         (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
930                  (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))
931    (clobber (reg:SI 64))
932    (clobber (reg:SI 65))]
933   "!TARGET_64BIT"
934   "*
935 {
936   rtx xoperands[10];
937
938   xoperands[0] = operands[0];
939   xoperands[1] = gen_rtx (REG, DImode, MD_REG_FIRST);
940
941   output_asm_insn (\"mult\\t%1,%2\", operands);
942   output_asm_insn (mips_move_2words (xoperands, insn), xoperands);
943   return \"\";
944 }"
945   [(set_attr "type"     "imul")
946    (set_attr "mode"     "SI")
947    (set_attr "length"   "4")])          ;; mult + mflo + mfhi + delay
948
949 (define_insn "umulsidi3"
950   [(set (match_operand:DI 0 "register_operand" "=d")
951         (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
952                  (zero_extend:DI (match_operand:SI 2 "register_operand" "d"))))
953    (clobber (reg:SI 64))
954    (clobber (reg:SI 65))]
955   "!TARGET_64BIT"
956   "*
957 {
958   rtx xoperands[10];
959
960   xoperands[0] = operands[0];
961   xoperands[1] = gen_rtx (REG, DImode, MD_REG_FIRST);
962
963   output_asm_insn (\"multu\\t%1,%2\", operands);
964   output_asm_insn (mips_move_2words (xoperands, insn), xoperands);
965   return \"\";
966 }"
967   [(set_attr "type"     "imul")
968    (set_attr "mode"     "SI")
969    (set_attr "length"   "4")])          ;; mult + mflo + mfhi + delay
970
971 \f
972 ;;
973 ;;  ....................
974 ;;
975 ;;      DIVISION and REMAINDER
976 ;;
977 ;;  ....................
978 ;;
979
980 (define_insn "divdf3"
981   [(set (match_operand:DF 0 "register_operand" "=f")
982         (div:DF (match_operand:DF 1 "register_operand" "f")
983                 (match_operand:DF 2 "register_operand" "f")))]
984   "TARGET_HARD_FLOAT"
985   "div.d\\t%0,%1,%2"
986   [(set_attr "type"     "fdiv")
987    (set_attr "mode"     "DF")
988    (set_attr "length"   "1")])
989
990 (define_insn "divsf3"
991   [(set (match_operand:SF 0 "register_operand" "=f")
992         (div:SF (match_operand:SF 1 "register_operand" "f")
993                 (match_operand:SF 2 "register_operand" "f")))]
994   "TARGET_HARD_FLOAT"
995   "div.s\\t%0,%1,%2"
996   [(set_attr "type"     "fdiv")
997    (set_attr "mode"     "SF")
998    (set_attr "length"   "1")])
999
1000 ;; If optimizing, prefer the divmod functions over separate div and
1001 ;; mod functions, since this will allow using one instruction for both
1002 ;; the quotient and remainder.  At present, the divmod is not moved out
1003 ;; of loops if it is constant within the loop, so allow -mdebugc to
1004 ;; use the old method of doing things.
1005
1006 ;; 64 is the multiply/divide hi register
1007 ;; 65 is the multiply/divide lo register
1008
1009 ;; ??? We can't accept constants here, because the MIPS assembler will replace
1010 ;; a divide by power of 2 with a shift, and then the remainder is no longer
1011 ;; available.
1012
1013 (define_insn "divmodsi4"
1014   [(set (match_operand:SI 0 "register_operand" "=d")
1015         (div:SI (match_operand:SI 1 "register_operand" "d")
1016                 (match_operand:SI 2 "register_operand" "d")))
1017    (set (match_operand:SI 3 "register_operand" "=d")
1018         (mod:SI (match_dup 1)
1019                 (match_dup 2)))
1020    (clobber (reg:SI 64))
1021    (clobber (reg:SI 65))]
1022   "optimize"
1023   "*
1024 {
1025   if (find_reg_note (insn, REG_UNUSED, operands[3]))
1026     return \"div\\t%0,%1,%2\";
1027
1028   if (find_reg_note (insn, REG_UNUSED, operands[0]))
1029     return \"rem\\t%3,%1,%2\";
1030
1031   return \"div\\t%0,%1,%2\;mfhi\\t%3\";
1032 }"
1033   [(set_attr "type"     "idiv")
1034    (set_attr "mode"     "SI")
1035    (set_attr "length"   "14")])         ;; various tests for dividing by 0 and such
1036
1037 (define_insn "divmoddi4"
1038   [(set (match_operand:DI 0 "register_operand" "=d")
1039         (div:DI (match_operand:DI 1 "register_operand" "d")
1040                 (match_operand:DI 2 "register_operand" "d")))
1041    (set (match_operand:DI 3 "register_operand" "=d")
1042         (mod:DI (match_dup 1)
1043                 (match_dup 2)))
1044    (clobber (reg:DI 64))
1045    (clobber (reg:DI 65))]
1046   "TARGET_64BIT && optimize"
1047   "*
1048 {
1049   if (find_reg_note (insn, REG_UNUSED, operands[3]))
1050     return \"ddiv\\t%0,%1,%2\";
1051
1052   if (find_reg_note (insn, REG_UNUSED, operands[0]))
1053     return \"drem\\t%3,%1,%2\";
1054
1055   return \"ddiv\\t%0,%1,%2\;mfhi\\t%3\";
1056 }"
1057   [(set_attr "type"     "idiv")
1058    (set_attr "mode"     "DI")
1059    (set_attr "length"   "15")])         ;; various tests for dividing by 0 and such
1060
1061 (define_insn "udivmodsi4"
1062   [(set (match_operand:SI 0 "register_operand" "=d")
1063         (udiv:SI (match_operand:SI 1 "register_operand" "d")
1064                  (match_operand:SI 2 "register_operand" "d")))
1065    (set (match_operand:SI 3 "register_operand" "=d")
1066         (umod:SI (match_dup 1)
1067                  (match_dup 2)))
1068    (clobber (reg:SI 64))
1069    (clobber (reg:SI 65))]
1070   "optimize"
1071   "*
1072 {
1073   if (find_reg_note (insn, REG_UNUSED, operands[3]))
1074     return \"divu\\t%0,%1,%2\";
1075
1076   if (find_reg_note (insn, REG_UNUSED, operands[0]))
1077     return \"remu\\t%3,%1,%2\";
1078
1079   return \"divu\\t%0,%1,%2\;mfhi\\t%3\";
1080 }"
1081   [(set_attr "type"     "idiv")
1082    (set_attr "mode"     "SI")
1083    (set_attr "length"   "8")])          ;; various tests for dividing by 0 and such
1084
1085 (define_insn "udivmoddi4"
1086   [(set (match_operand:DI 0 "register_operand" "=d")
1087         (udiv:DI (match_operand:DI 1 "register_operand" "d")
1088                  (match_operand:DI 2 "register_operand" "d")))
1089    (set (match_operand:DI 3 "register_operand" "=d")
1090         (umod:DI (match_dup 1)
1091                  (match_dup 2)))
1092    (clobber (reg:DI 64))
1093    (clobber (reg:DI 65))]
1094   "TARGET_64BIT && optimize"
1095   "*
1096 {
1097   if (find_reg_note (insn, REG_UNUSED, operands[3]))
1098     return \"ddivu\\t%0,%1,%2\";
1099
1100   if (find_reg_note (insn, REG_UNUSED, operands[0]))
1101     return \"dremu\\t%3,%1,%2\";
1102
1103   return \"ddivu\\t%0,%1,%2\;mfhi\\t%3\";
1104 }"
1105   [(set_attr "type"     "idiv")
1106    (set_attr "mode"     "DI")
1107    (set_attr "length"   "8")])          ;; various tests for dividing by 0 and such
1108
1109 (define_insn "divsi3"
1110   [(set (match_operand:SI 0 "register_operand" "=d")
1111         (div:SI (match_operand:SI 1 "register_operand" "d")
1112                 (match_operand:SI 2 "nonmemory_operand" "di")))
1113    (clobber (reg:SI 64))
1114    (clobber (reg:SI 65))]
1115   "!optimize"
1116   "div\\t%0,%1,%2"
1117   [(set_attr "type"     "idiv")
1118    (set_attr "mode"     "SI")
1119    (set_attr "length"   "13")])         ;; various tests for dividing by 0 and such
1120
1121 (define_insn "divdi3"
1122   [(set (match_operand:DI 0 "register_operand" "=d")
1123         (div:DI (match_operand:DI 1 "register_operand" "d")
1124                 (match_operand:DI 2 "nonmemory_operand" "di")))
1125    (clobber (reg:DI 64))
1126    (clobber (reg:DI 65))]
1127   "TARGET_64BIT && !optimize"
1128   "ddiv\\t%0,%1,%2"
1129   [(set_attr "type"     "idiv")
1130    (set_attr "mode"     "DI")
1131    (set_attr "length"   "14")])         ;; various tests for dividing by 0 and such
1132
1133 (define_insn "modsi3"
1134   [(set (match_operand:SI 0 "register_operand" "=d")
1135         (mod:SI (match_operand:SI 1 "register_operand" "d")
1136                 (match_operand:SI 2 "nonmemory_operand" "di")))
1137    (clobber (reg:SI 64))
1138    (clobber (reg:SI 65))]
1139   "!optimize"
1140   "rem\\t%0,%1,%2"
1141   [(set_attr "type"     "idiv")
1142    (set_attr "mode"     "SI")
1143    (set_attr "length"   "13")])         ;; various tests for dividing by 0 and such
1144
1145 (define_insn "moddi3"
1146   [(set (match_operand:DI 0 "register_operand" "=d")
1147         (mod:DI (match_operand:DI 1 "register_operand" "d")
1148                 (match_operand:DI 2 "nonmemory_operand" "di")))
1149    (clobber (reg:DI 64))
1150    (clobber (reg:DI 65))]
1151   "TARGET_64BIT && !optimize"
1152   "drem\\t%0,%1,%2"
1153   [(set_attr "type"     "idiv")
1154    (set_attr "mode"     "DI")
1155    (set_attr "length"   "14")])         ;; various tests for dividing by 0 and such
1156
1157 (define_insn "udivsi3"
1158   [(set (match_operand:SI 0 "register_operand" "=d")
1159         (udiv:SI (match_operand:SI 1 "register_operand" "d")
1160                  (match_operand:SI 2 "nonmemory_operand" "di")))
1161    (clobber (reg:SI 64))
1162    (clobber (reg:SI 65))]
1163   "!optimize"
1164   "divu\\t%0,%1,%2"
1165   [(set_attr "type"     "idiv")
1166    (set_attr "mode"     "SI")
1167    (set_attr "length"   "7")])          ;; various tests for dividing by 0 and such
1168
1169 (define_insn "udivdi3"
1170   [(set (match_operand:DI 0 "register_operand" "=d")
1171         (udiv:DI (match_operand:DI 1 "register_operand" "d")
1172                  (match_operand:DI 2 "nonmemory_operand" "di")))
1173    (clobber (reg:DI 64))
1174    (clobber (reg:DI 65))]
1175   "TARGET_64BIT && !optimize"
1176   "ddivu\\t%0,%1,%2"
1177   [(set_attr "type"     "idiv")
1178    (set_attr "mode"     "DI")
1179    (set_attr "length"   "7")])          ;; various tests for dividing by 0 and such
1180
1181 (define_insn "umodsi3"
1182   [(set (match_operand:SI 0 "register_operand" "=d")
1183         (umod:SI (match_operand:SI 1 "register_operand" "d")
1184                  (match_operand:SI 2 "nonmemory_operand" "di")))
1185    (clobber (reg:SI 64))
1186    (clobber (reg:SI 65))]
1187   "!optimize"
1188   "remu\\t%0,%1,%2"
1189   [(set_attr "type"     "idiv")
1190    (set_attr "mode"     "SI")
1191    (set_attr "length"   "7")])          ;; various tests for dividing by 0 and such
1192
1193 (define_insn "umoddi3"
1194   [(set (match_operand:DI 0 "register_operand" "=d")
1195         (umod:DI (match_operand:DI 1 "register_operand" "d")
1196                  (match_operand:DI 2 "nonmemory_operand" "di")))
1197    (clobber (reg:DI 64))
1198    (clobber (reg:DI 65))]
1199   "TARGET_64BIT && !optimize"
1200   "dremu\\t%0,%1,%2"
1201   [(set_attr "type"     "idiv")
1202    (set_attr "mode"     "DI")
1203    (set_attr "length"   "7")])          ;; various tests for dividing by 0 and such
1204
1205 \f
1206 ;;
1207 ;;  ....................
1208 ;;
1209 ;;      SQUARE ROOT
1210 ;;
1211 ;;  ....................
1212
1213 (define_insn "sqrtdf2"
1214   [(set (match_operand:DF 0 "register_operand" "=f")
1215         (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
1216   "TARGET_HARD_FLOAT && HAVE_SQRT_P()"
1217   "sqrt.d\\t%0,%1"
1218   [(set_attr "type"     "fsqrt")
1219    (set_attr "mode"     "DF")
1220    (set_attr "length"   "1")])
1221
1222 (define_insn "sqrtsf2"
1223   [(set (match_operand:SF 0 "register_operand" "=f")
1224         (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
1225   "TARGET_HARD_FLOAT && HAVE_SQRT_P()"
1226   "sqrt.s\\t%0,%1"
1227   [(set_attr "type"     "fsqrt")
1228    (set_attr "mode"     "SF")
1229    (set_attr "length"   "1")])
1230
1231 \f
1232 ;;
1233 ;;  ....................
1234 ;;
1235 ;;      ABSOLUTE VALUE
1236 ;;
1237 ;;  ....................
1238
1239 ;; Do not use the integer abs macro instruction, since that signals an
1240 ;; exception on -2147483648 (sigh).
1241
1242 (define_insn "abssi2"
1243   [(set (match_operand:SI 0 "register_operand" "=d")
1244         (abs:SI (match_operand:SI 1 "register_operand" "d")))]
1245   ""
1246   "*
1247 {
1248   dslots_jump_total++;
1249   dslots_jump_filled++;
1250   operands[2] = const0_rtx;
1251
1252   if (REGNO (operands[0]) == REGNO (operands[1]))
1253     {
1254       if (mips_isa >= 2)
1255         return \"%(bltzl\\t%1,1f\\n\\tsubu\\t%0,%z2,%0\\n1:%)\";
1256       else
1257         return \"bgez\\t%1,1f%#\\n\\tsubu\\t%0,%z2,%0\\n1:\";
1258     }     
1259   else
1260     return \"%(bgez\\t%1,1f\\n\\tmove\\t%0,%1\\n\\tsubu\\t%0,%z2,%0\\n1:%)\";
1261 }"
1262   [(set_attr "type"     "multi")
1263    (set_attr "mode"     "SI")
1264    (set_attr "length"   "3")])
1265
1266 (define_insn "absdi2"
1267   [(set (match_operand:DI 0 "register_operand" "=d")
1268         (abs:DI (match_operand:DI 1 "register_operand" "d")))]
1269   "TARGET_64BIT"
1270   "*
1271 {
1272   dslots_jump_total++;
1273   dslots_jump_filled++;
1274   operands[2] = const0_rtx;
1275
1276   if (REGNO (operands[0]) == REGNO (operands[1]))
1277     return \"%(bltzl\\t%1,1f\\n\\tdsubu\\t%0,%z2,%0\\n1:%)\";
1278   else
1279     return \"%(bgez\\t%1,1f\\n\\tmove\\t%0,%1\\n\\tdsubu\\t%0,%z2,%0\\n1:%)\";
1280 }"
1281   [(set_attr "type"     "multi")
1282    (set_attr "mode"     "DI")
1283    (set_attr "length"   "3")])
1284
1285 (define_insn "absdf2"
1286   [(set (match_operand:DF 0 "register_operand" "=f")
1287         (abs:DF (match_operand:DF 1 "register_operand" "f")))]
1288   "TARGET_HARD_FLOAT"
1289   "abs.d\\t%0,%1"
1290   [(set_attr "type"     "fabs")
1291    (set_attr "mode"     "DF")
1292    (set_attr "length"   "1")])
1293
1294 (define_insn "abssf2"
1295   [(set (match_operand:SF 0 "register_operand" "=f")
1296         (abs:SF (match_operand:SF 1 "register_operand" "f")))]
1297   "TARGET_HARD_FLOAT"
1298   "abs.s\\t%0,%1"
1299   [(set_attr "type"     "fabs")
1300    (set_attr "mode"     "SF")
1301    (set_attr "length"   "1")])
1302
1303 \f
1304 ;;
1305 ;;  ....................
1306 ;;
1307 ;;      FIND FIRST BIT INSTRUCTION
1308 ;;
1309 ;;  ....................
1310 ;;
1311
1312 (define_insn "ffssi2"
1313   [(set (match_operand:SI 0 "register_operand" "=&d")
1314         (ffs:SI (match_operand:SI 1 "register_operand" "d")))
1315    (clobber (match_scratch:SI 2 "=&d"))
1316    (clobber (match_scratch:SI 3 "=&d"))]
1317   ""
1318   "*
1319 {
1320   dslots_jump_total += 2;
1321   dslots_jump_filled += 2;
1322   operands[4] = const0_rtx;
1323
1324   if (optimize && find_reg_note (insn, REG_DEAD, operands[1]))
1325     return \"%(\\
1326 move\\t%0,%z4\\n\\
1327 \\tbeq\\t%1,%z4,2f\\n\\
1328 1:\\tand\\t%2,%1,0x0001\\n\\
1329 \\taddu\\t%0,%0,1\\n\\
1330 \\tbeq\\t%2,%z4,1b\\n\\
1331 \\tsrl\\t%1,%1,1\\n\\
1332 2:%)\";
1333
1334   return \"%(\\
1335 move\\t%0,%z4\\n\\
1336 \\tmove\\t%3,%1\\n\\
1337 \\tbeq\\t%3,%z4,2f\\n\\
1338 1:\\tand\\t%2,%3,0x0001\\n\\
1339 \\taddu\\t%0,%0,1\\n\\
1340 \\tbeq\\t%2,%z4,1b\\n\\
1341 \\tsrl\\t%3,%3,1\\n\\
1342 2:%)\";
1343 }"
1344   [(set_attr "type"     "multi")
1345    (set_attr "mode"     "SI")
1346    (set_attr "length"   "6")])
1347
1348 (define_insn "ffsdi2"
1349   [(set (match_operand:DI 0 "register_operand" "=&d")
1350         (ffs:DI (match_operand:DI 1 "register_operand" "d")))
1351    (clobber (match_scratch:DI 2 "=&d"))
1352    (clobber (match_scratch:DI 3 "=&d"))]
1353   "TARGET_64BIT"
1354   "*
1355 {
1356   dslots_jump_total += 2;
1357   dslots_jump_filled += 2;
1358   operands[4] = const0_rtx;
1359
1360   if (optimize && find_reg_note (insn, REG_DEAD, operands[1]))
1361     return \"%(\\
1362 move\\t%0,%z4\\n\\
1363 \\tbeq\\t%1,%z4,2f\\n\\
1364 1:\\tand\\t%2,%1,0x0001\\n\\
1365 \\tdaddu\\t%0,%0,1\\n\\
1366 \\tbeq\\t%2,%z4,1b\\n\\
1367 \\tdsrl\\t%1,%1,1\\n\\
1368 2:%)\";
1369
1370   return \"%(\\
1371 move\\t%0,%z4\\n\\
1372 \\tmove\\t%3,%1\\n\\
1373 \\tbeq\\t%3,%z4,2f\\n\\
1374 1:\\tand\\t%2,%3,0x0001\\n\\
1375 \\tdaddu\\t%0,%0,1\\n\\
1376 \\tbeq\\t%2,%z4,1b\\n\\
1377 \\tdsrl\\t%3,%3,1\\n\\
1378 2:%)\";
1379 }"
1380   [(set_attr "type"     "multi")
1381    (set_attr "mode"     "DI")
1382    (set_attr "length"   "6")])
1383
1384 \f
1385 ;;
1386 ;;  ....................
1387 ;;
1388 ;;      NEGATION and ONE'S COMPLEMENT
1389 ;;
1390 ;;  ....................
1391
1392 (define_insn "negsi2"
1393   [(set (match_operand:SI 0 "register_operand" "=d")
1394         (neg:SI (match_operand:SI 1 "register_operand" "d")))]
1395   ""
1396   "*
1397 {
1398   operands[2] = const0_rtx;
1399   return \"subu\\t%0,%z2,%1\";
1400 }"
1401   [(set_attr "type"     "arith")
1402    (set_attr "mode"     "SI")
1403    (set_attr "length"   "1")])
1404
1405 (define_expand "negdi2"
1406   [(parallel [(set (match_operand:DI 0 "register_operand" "=d")
1407                    (neg:DI (match_operand:DI 1 "register_operand" "d")))
1408               (clobber (match_dup 2))])]
1409   "TARGET_64BIT || !TARGET_DEBUG_G_MODE"
1410   "
1411 {
1412   if (TARGET_64BIT)
1413     {
1414       emit_insn (gen_negdi2_internal_2 (operands[0], operands[1]));
1415       DONE;
1416     }
1417
1418   operands[2] = gen_reg_rtx (SImode);
1419 }")
1420
1421 (define_insn "negdi2_internal"
1422   [(set (match_operand:DI 0 "register_operand" "=d")
1423         (neg:DI (match_operand:DI 1 "register_operand" "d")))
1424    (clobber (match_operand:SI 2 "register_operand" "=d"))]
1425   "! TARGET_64BIT && !TARGET_DEBUG_G_MODE"
1426   "*
1427 {
1428   operands[3] = const0_rtx;
1429   return \"subu\\t%L0,%z3,%L1\;subu\\t%M0,%z3,%M1\;sltu\\t%2,%z3,%L0\;subu\\t%M0,%M0,%2\";
1430 }"
1431   [(set_attr "type"     "darith")
1432    (set_attr "mode"     "DI")
1433    (set_attr "length"   "4")])
1434
1435 (define_insn "negdi2_internal_2"
1436   [(set (match_operand:DI 0 "register_operand" "=d")
1437         (neg:DI (match_operand:DI 1 "register_operand" "d")))]
1438   "TARGET_64BIT"
1439   "*
1440 {
1441   operands[2] = const0_rtx;
1442   return \"dsubu\\t%0,%z2,%1\";
1443 }"
1444   [(set_attr "type"     "arith")
1445    (set_attr "mode"     "DI")
1446    (set_attr "length"   "1")])
1447
1448 (define_insn "negdf2"
1449   [(set (match_operand:DF 0 "register_operand" "=f")
1450         (neg:DF (match_operand:DF 1 "register_operand" "f")))]
1451   "TARGET_HARD_FLOAT"
1452   "neg.d\\t%0,%1"
1453   [(set_attr "type"     "fneg")
1454    (set_attr "mode"     "DF")
1455    (set_attr "length"   "1")])
1456
1457 (define_insn "negsf2"
1458   [(set (match_operand:SF 0 "register_operand" "=f")
1459         (neg:SF (match_operand:SF 1 "register_operand" "f")))]
1460   "TARGET_HARD_FLOAT"
1461   "neg.s\\t%0,%1"
1462   [(set_attr "type"     "fneg")
1463    (set_attr "mode"     "SF")
1464    (set_attr "length"   "1")])
1465
1466 (define_insn "one_cmplsi2"
1467   [(set (match_operand:SI 0 "register_operand" "=d")
1468         (not:SI (match_operand:SI 1 "register_operand" "d")))]
1469   ""
1470   "*
1471 {
1472   operands[2] = const0_rtx;
1473   return \"nor\\t%0,%z2,%1\";
1474 }"
1475   [(set_attr "type"     "arith")
1476    (set_attr "mode"     "SI")
1477    (set_attr "length"   "1")])
1478
1479 (define_insn "one_cmpldi2"
1480   [(set (match_operand:DI 0 "register_operand" "=d")
1481         (not:DI (match_operand:DI 1 "register_operand" "d")))]
1482   ""
1483   "*
1484 {
1485   operands[2] = const0_rtx;
1486   if (TARGET_64BIT)
1487     return \"nor\\t%0,%z2,%1\";
1488   return \"nor\\t%M0,%z2,%M1\;nor\\t%L0,%z2,%L1\";
1489 }"
1490   [(set_attr "type"     "darith")
1491    (set_attr "mode"     "DI")
1492    (set (attr "length")
1493         (if_then_else (ge (symbol_ref "mips_isa") (const_int 3))
1494                        (const_int 1)
1495                        (const_int 2)))])
1496
1497 (define_split
1498   [(set (match_operand:DI 0 "register_operand" "")
1499         (not:DI (match_operand:DI 1 "register_operand" "")))]
1500   "reload_completed && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
1501    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1502    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))"
1503
1504   [(set (subreg:SI (match_dup 0) 0) (not:SI (subreg:SI (match_dup 1) 0)))
1505    (set (subreg:SI (match_dup 0) 1) (not:SI (subreg:SI (match_dup 1) 1)))]
1506   "")
1507
1508 ;; Simple hack to recognize the "nor" instruction on the MIPS
1509 ;; This must appear before the normal or patterns, so that the
1510 ;; combiner will correctly fold things.
1511
1512 (define_insn "norsi3"
1513   [(set (match_operand:SI 0 "register_operand" "=d")
1514         (not:SI (ior:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
1515                         (match_operand:SI 2 "reg_or_0_operand" "dJ"))))]
1516   ""
1517   "nor\\t%0,%z1,%z2"
1518   [(set_attr "type"     "arith")
1519    (set_attr "mode"     "SI")
1520    (set_attr "length"   "1")])
1521
1522 (define_insn "nordi3"
1523   [(set (match_operand:DI 0 "register_operand" "=d")
1524         (not:DI (ior:DI (match_operand:DI 1 "register_operand" "d")
1525                         (match_operand:DI 2 "register_operand" "d"))))]
1526   ""
1527   "*
1528 {
1529   if (TARGET_64BIT)
1530     return \"nor\\t%0,%z1,%z2\";
1531   return \"nor\\t%M0,%M1,%M2\;nor\\t%L0,%L1,%L2\";
1532 }"
1533   [(set_attr "type"     "darith")
1534    (set_attr "mode"     "DI")
1535    (set (attr "length")
1536         (if_then_else (ge (symbol_ref "mips_isa") (const_int 3))
1537                        (const_int 1)
1538                        (const_int 2)))])
1539
1540 (define_split
1541   [(set (match_operand:DI 0 "register_operand" "")
1542         (not:DI (ior:DI (match_operand:DI 1 "register_operand" "")
1543                         (match_operand:DI 2 "register_operand" ""))))]
1544   "reload_completed && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
1545    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1546    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1547    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
1548
1549   [(set (subreg:SI (match_dup 0) 0) (not:SI (ior:SI (subreg:SI (match_dup 1) 0) (subreg:SI (match_dup 2) 0))))
1550    (set (subreg:SI (match_dup 0) 1) (not:SI (ior:SI (subreg:SI (match_dup 1) 1) (subreg:SI (match_dup 2) 1))))]
1551   "")
1552
1553 \f
1554 ;;
1555 ;;  ....................
1556 ;;
1557 ;;      LOGICAL
1558 ;;
1559 ;;  ....................
1560 ;;
1561
1562 (define_insn "andsi3"
1563   [(set (match_operand:SI 0 "register_operand" "=d,d")
1564         (and:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
1565                 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
1566   ""
1567   "@
1568    and\\t%0,%1,%2
1569    andi\\t%0,%1,%x2"
1570   [(set_attr "type"     "arith")
1571    (set_attr "mode"     "SI")
1572    (set_attr "length"   "1")])
1573
1574 (define_insn "anddi3"
1575   [(set (match_operand:DI 0 "register_operand" "=d")
1576         (and:DI (match_operand:DI 1 "register_operand" "d")
1577                 (match_operand:DI 2 "register_operand" "d")))]
1578   "TARGET_64BIT || !TARGET_DEBUG_G_MODE"
1579   "*
1580 {
1581   if (TARGET_64BIT)
1582     return \"and\\t%0,%1,%2\";
1583   return \"and\\t%M0,%M1,%M2\;and\\t%L0,%L1,%L2\";
1584 }"
1585   [(set_attr "type"     "darith")
1586    (set_attr "mode"     "DI")
1587    (set (attr "length")
1588         (if_then_else (ge (symbol_ref "mips_isa") (const_int 3))
1589                        (const_int 1)
1590                        (const_int 2)))])
1591
1592 (define_split
1593   [(set (match_operand:DI 0 "register_operand" "")
1594         (and:DI (match_operand:DI 1 "register_operand" "")
1595                 (match_operand:DI 2 "register_operand" "")))]
1596   "reload_completed && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
1597    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1598    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1599    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
1600
1601   [(set (subreg:SI (match_dup 0) 0) (and:SI (subreg:SI (match_dup 1) 0) (subreg:SI (match_dup 2) 0)))
1602    (set (subreg:SI (match_dup 0) 1) (and:SI (subreg:SI (match_dup 1) 1) (subreg:SI (match_dup 2) 1)))]
1603   "")
1604
1605 (define_insn "anddi3_internal1"
1606   [(set (match_operand:DI 0 "register_operand" "=d,d")
1607         (and:DI (match_operand:DI 1 "register_operand" "%d,d")
1608                 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
1609   "TARGET_64BIT"
1610   "@
1611    and\\t%0,%1,%2
1612    andi\\t%0,%1,%x2"
1613   [(set_attr "type"     "arith")
1614    (set_attr "mode"     "DI")
1615    (set_attr "length"   "1")])
1616
1617 (define_insn "iorsi3"
1618   [(set (match_operand:SI 0 "register_operand" "=d,d")
1619         (ior:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
1620                 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
1621   ""
1622   "@
1623    or\\t%0,%1,%2
1624    ori\\t%0,%1,%x2"
1625   [(set_attr "type"     "arith")
1626    (set_attr "mode"     "SI")
1627    (set_attr "length"   "1")])
1628
1629 ;;; ??? There is no iordi3 pattern which accepts 'K' constants when
1630 ;;; TARGET_64BIT
1631
1632 (define_insn "iordi3"
1633   [(set (match_operand:DI 0 "register_operand" "=d")
1634         (ior:DI (match_operand:DI 1 "register_operand" "d")
1635                 (match_operand:DI 2 "register_operand" "d")))]
1636   "TARGET_64BIT || !TARGET_DEBUG_G_MODE"
1637   "*
1638 {
1639   if (TARGET_64BIT)
1640     return \"or\\t%0,%1,%2\";
1641   return \"or\\t%M0,%M1,%M2\;or\\t%L0,%L1,%L2\";
1642 }"
1643   [(set_attr "type"     "darith")
1644    (set_attr "mode"     "DI")
1645    (set (attr "length")
1646         (if_then_else (ge (symbol_ref "mips_isa") (const_int 3))
1647                        (const_int 1)
1648                        (const_int 2)))])
1649
1650 (define_split
1651   [(set (match_operand:DI 0 "register_operand" "")
1652         (ior:DI (match_operand:DI 1 "register_operand" "")
1653                 (match_operand:DI 2 "register_operand" "")))]
1654   "reload_completed && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
1655    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1656    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1657    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
1658
1659   [(set (subreg:SI (match_dup 0) 0) (ior:SI (subreg:SI (match_dup 1) 0) (subreg:SI (match_dup 2) 0)))
1660    (set (subreg:SI (match_dup 0) 1) (ior:SI (subreg:SI (match_dup 1) 1) (subreg:SI (match_dup 2) 1)))]
1661   "")
1662
1663 (define_insn "xorsi3"
1664   [(set (match_operand:SI 0 "register_operand" "=d,d")
1665         (xor:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
1666                 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
1667   ""
1668   "@
1669    xor\\t%0,%1,%2
1670    xori\\t%0,%1,%x2"
1671   [(set_attr "type"     "arith")
1672    (set_attr "mode"     "SI")
1673    (set_attr "length"   "1")])
1674
1675 ;; ??? If delete the 32-bit long long patterns, then could merge this with
1676 ;; the following xordi3_internal pattern.
1677 (define_insn "xordi3"
1678   [(set (match_operand:DI 0 "register_operand" "=d")
1679         (xor:DI (match_operand:DI 1 "register_operand" "d")
1680                 (match_operand:DI 2 "register_operand" "d")))]
1681   "TARGET_64BIT || !TARGET_DEBUG_G_MODE"
1682   "*
1683 {
1684   if (TARGET_64BIT)
1685     return \"xor\\t%0,%1,%2\";
1686   return \"xor\\t%M0,%M1,%M2\;xor\\t%L0,%L1,%L2\";
1687 }"
1688   [(set_attr "type"     "darith")
1689    (set_attr "mode"     "DI")
1690    (set (attr "length")
1691         (if_then_else (ge (symbol_ref "mips_isa") (const_int 3))
1692                        (const_int 1)
1693                        (const_int 2)))])
1694
1695 (define_split
1696   [(set (match_operand:DI 0 "register_operand" "")
1697         (xor:DI (match_operand:DI 1 "register_operand" "")
1698                 (match_operand:DI 2 "register_operand" "")))]
1699   "reload_completed && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
1700    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1701    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1702    && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
1703
1704   [(set (subreg:SI (match_dup 0) 0) (xor:SI (subreg:SI (match_dup 1) 0) (subreg:SI (match_dup 2) 0)))
1705    (set (subreg:SI (match_dup 0) 1) (xor:SI (subreg:SI (match_dup 1) 1) (subreg:SI (match_dup 2) 1)))]
1706   "")
1707
1708 (define_insn "xordi3_immed"
1709   [(set (match_operand:DI 0 "register_operand" "d")
1710         (xor:DI (match_operand:DI 1 "register_operand" "d")
1711                 (match_operand:DI 2 "uns_arith_operand" "K")))]
1712   "TARGET_64BIT"
1713   "xori\\t%0,%1,%x2"
1714   [(set_attr "type"     "arith")
1715    (set_attr "mode"     "DI")
1716    (set_attr "length"   "1")])
1717
1718 \f
1719 ;;
1720 ;;  ....................
1721 ;;
1722 ;;      TRUNCATION
1723 ;;
1724 ;;  ....................
1725
1726 (define_insn "truncdfsf2"
1727   [(set (match_operand:SF 0 "register_operand" "=f")
1728         (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
1729   "TARGET_HARD_FLOAT"
1730   "cvt.s.d\\t%0,%1"
1731   [(set_attr "type"     "fcvt")
1732    (set_attr "mode"     "SF")
1733    (set_attr "length"   "1")])
1734
1735 ;; ??? This should be a define expand.
1736 ;; See the zero_extendsidi2 pattern.
1737 (define_insn "truncdisi2"
1738   [(set (match_operand:SI 0 "register_operand" "=d")
1739         (truncate:SI (match_operand:DI 1 "register_operand" "d")))]
1740   "TARGET_64BIT"
1741   "dsll\\t%0,%1,32\;dsra\\t%0,%0,32"
1742   [(set_attr "type"     "darith")
1743    (set_attr "mode"     "SI")
1744    (set_attr "length"   "2")])
1745
1746 (define_insn "truncdihi2"
1747   [(set (match_operand:HI 0 "register_operand" "=d")
1748         (truncate:HI (match_operand:DI 1 "register_operand" "d")))]
1749   "TARGET_64BIT"
1750   "andi\\t%0,%1,0xffff"
1751   [(set_attr "type"     "darith")
1752    (set_attr "mode"     "HI")
1753    (set_attr "length"   "1")])
1754
1755 (define_insn "truncdiqi2"
1756   [(set (match_operand:QI 0 "register_operand" "=d")
1757         (truncate:QI (match_operand:DI 1 "register_operand" "d")))]
1758   "TARGET_64BIT"
1759   "andi\\t%0,%1,0x00ff"
1760   [(set_attr "type"     "darith")
1761    (set_attr "mode"     "QI")
1762    (set_attr "length"   "1")])
1763 \f
1764 ;;
1765 ;;  ....................
1766 ;;
1767 ;;      ZERO EXTENSION
1768 ;;
1769 ;;  ....................
1770
1771 ;; Extension insns.
1772 ;; Those for integer source operand
1773 ;; are ordered widest source type first.
1774
1775 (define_expand "zero_extendsidi2"
1776   [(set (match_operand:DI 0 "register_operand" "")
1777         (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
1778   "TARGET_64BIT"
1779   "
1780 {
1781   if (optimize && GET_CODE (operands[1]) == MEM)
1782     operands[1] = force_not_mem (operands[1]);
1783
1784   if (GET_CODE (operands[1]) != MEM)
1785     {
1786       rtx op1   = gen_lowpart (DImode, operands[1]);
1787       rtx temp  = gen_reg_rtx (DImode);
1788       rtx shift = gen_rtx (CONST_INT, VOIDmode, 32);
1789
1790       emit_insn (gen_ashldi3 (temp, op1, shift));
1791       emit_insn (gen_lshrdi3 (operands[0], temp, shift));
1792       DONE;
1793     }
1794 }")
1795
1796 (define_insn "zero_extendsidi2_internal"
1797   [(set (match_operand:DI 0 "register_operand" "=d,d")
1798         (zero_extend:DI (match_operand:SI 1 "memory_operand" "R,m")))]
1799   "TARGET_64BIT"
1800   "* return mips_move_1word (operands, insn, TRUE);"
1801   [(set_attr "type"     "load")
1802    (set_attr "mode"     "DI")
1803    (set_attr "length"   "1,2")])
1804
1805
1806 (define_insn "zero_extendhisi2"
1807   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
1808         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "d,R,m")))]
1809   ""
1810   "*
1811 {
1812   if (which_alternative == 0)
1813     return \"andi\\t%0,%1,0xffff\";
1814   else
1815     return mips_move_1word (operands, insn, TRUE);
1816 }"
1817   [(set_attr "type"     "arith,load,load")
1818    (set_attr "mode"     "SI")
1819    (set_attr "length"   "1,1,2")])
1820
1821 (define_insn "zero_extendhidi2"
1822   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1823         (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "d,R,m")))]
1824   "TARGET_64BIT"
1825   "*
1826 {
1827   if (which_alternative == 0)
1828     return \"andi\\t%0,%1,0xffff\";
1829   else
1830     return mips_move_1word (operands, insn, TRUE);
1831 }"
1832   [(set_attr "type"     "arith,load,load")
1833    (set_attr "mode"     "DI")
1834    (set_attr "length"   "1,1,2")])
1835
1836 (define_insn "zero_extendqihi2"
1837   [(set (match_operand:HI 0 "register_operand" "=d,d,d")
1838         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,R,m")))]
1839   ""
1840   "*
1841 {
1842   if (which_alternative == 0)
1843     return \"andi\\t%0,%1,0x00ff\";
1844   else
1845     return mips_move_1word (operands, insn, TRUE);
1846 }"
1847   [(set_attr "type"     "arith,load,load")
1848    (set_attr "mode"     "HI")
1849    (set_attr "length"   "1,1,2")])
1850
1851 (define_insn "zero_extendqisi2"
1852   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
1853         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "d,R,m")))]
1854   ""
1855   "*
1856 {
1857   if (which_alternative == 0)
1858     return \"andi\\t%0,%1,0x00ff\";
1859   else
1860     return mips_move_1word (operands, insn, TRUE);
1861 }"
1862   [(set_attr "type"     "arith,load,load")
1863    (set_attr "mode"     "SI")
1864    (set_attr "length"   "1,1,2")])
1865
1866 (define_insn "zero_extendqidi2"
1867   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1868         (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "d,R,m")))]
1869   "TARGET_64BIT"
1870   "*
1871 {
1872   if (which_alternative == 0)
1873     return \"andi\\t%0,%1,0x00ff\";
1874   else
1875     return mips_move_1word (operands, insn, TRUE);
1876 }"
1877   [(set_attr "type"     "arith,load,load")
1878    (set_attr "mode"     "DI")
1879    (set_attr "length"   "1,1,2")])
1880
1881 \f
1882 ;;
1883 ;;  ....................
1884 ;;
1885 ;;      SIGN EXTENSION
1886 ;;
1887 ;;  ....................
1888
1889 ;; Extension insns.
1890 ;; Those for integer source operand
1891 ;; are ordered widest source type first.
1892
1893 ;; ??? This should be a define_expand.
1894
1895 (define_insn "extendsidi2"
1896   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1897         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,R,m")))]
1898   "TARGET_64BIT"
1899   "*
1900 {
1901   if (which_alternative == 0)
1902     return \"dsll\\t%0,%1,32\;dsra\\t%0,%0,32\";
1903   return mips_move_1word (operands, insn, FALSE);
1904 }"
1905   [(set_attr "type"     "arith,load,load")
1906    (set_attr "mode"     "DI")
1907    (set_attr "length"   "2,1,2")])
1908
1909 ;; These patterns originally accepted general_operands, however, slightly
1910 ;; better code is generated by only accepting register_operands, and then
1911 ;; letting combine generate the lh and lb insns.
1912
1913 (define_expand "extendhidi2"
1914   [(set (match_operand:DI 0 "register_operand" "")
1915         (sign_extend:DI (match_operand:HI 1 "nonimmediate_operand" "")))]
1916   "TARGET_64BIT"
1917   "
1918 {
1919   if (optimize && GET_CODE (operands[1]) == MEM)
1920     operands[1] = force_not_mem (operands[1]);
1921
1922   if (GET_CODE (operands[1]) != MEM)
1923     {
1924       rtx op1   = gen_lowpart (DImode, operands[1]);
1925       rtx temp  = gen_reg_rtx (DImode);
1926       rtx shift = gen_rtx (CONST_INT, VOIDmode, 48);
1927
1928       emit_insn (gen_ashldi3 (temp, op1, shift));
1929       emit_insn (gen_ashrdi3 (operands[0], temp, shift));
1930       DONE;
1931     }
1932 }")
1933
1934 (define_insn "extendhidi2_internal"
1935   [(set (match_operand:DI 0 "register_operand" "=d,d")
1936         (sign_extend:DI (match_operand:HI 1 "memory_operand" "R,m")))]
1937   "TARGET_64BIT"
1938   "* return mips_move_1word (operands, insn, FALSE);"
1939   [(set_attr "type"     "load")
1940    (set_attr "mode"     "DI")
1941    (set_attr "length"   "1,2")])
1942
1943 (define_expand "extendhisi2"
1944   [(set (match_operand:SI 0 "register_operand" "")
1945         (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
1946   ""
1947   "
1948 {
1949   if (optimize && GET_CODE (operands[1]) == MEM)
1950     operands[1] = force_not_mem (operands[1]);
1951
1952   if (GET_CODE (operands[1]) != MEM)
1953     {
1954       rtx op1   = gen_lowpart (SImode, operands[1]);
1955       rtx temp  = gen_reg_rtx (SImode);
1956       rtx shift = gen_rtx (CONST_INT, VOIDmode, 16);
1957
1958       emit_insn (gen_ashlsi3 (temp, op1, shift));
1959       emit_insn (gen_ashrsi3 (operands[0], temp, shift));
1960       DONE;
1961     }
1962 }")
1963
1964 (define_insn "extendhisi2_internal"
1965   [(set (match_operand:SI 0 "register_operand" "=d,d")
1966         (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,m")))]
1967   ""
1968   "* return mips_move_1word (operands, insn, FALSE);"
1969   [(set_attr "type"     "load")
1970    (set_attr "mode"     "SI")
1971    (set_attr "length"   "1,2")])
1972
1973 (define_expand "extendqihi2"
1974   [(set (match_operand:HI 0 "register_operand" "")
1975         (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
1976   ""
1977   "
1978 {
1979   if (optimize && GET_CODE (operands[1]) == MEM)
1980     operands[1] = force_not_mem (operands[1]);
1981
1982   if (GET_CODE (operands[1]) != MEM)
1983     {
1984       rtx op0   = gen_lowpart (SImode, operands[0]);
1985       rtx op1   = gen_lowpart (SImode, operands[1]);
1986       rtx temp  = gen_reg_rtx (SImode);
1987       rtx shift = gen_rtx (CONST_INT, VOIDmode, 24);
1988
1989       emit_insn (gen_ashlsi3 (temp, op1, shift));
1990       emit_insn (gen_ashrsi3 (op0, temp, shift));
1991       DONE;
1992     }
1993 }")
1994
1995 (define_insn "extendqihi2_internal"
1996   [(set (match_operand:HI 0 "register_operand" "=d,d")
1997         (sign_extend:HI (match_operand:QI 1 "memory_operand" "R,m")))]
1998   ""
1999   "* return mips_move_1word (operands, insn, FALSE);"
2000   [(set_attr "type"     "load")
2001    (set_attr "mode"     "SI")
2002    (set_attr "length"   "1,2")])
2003
2004
2005 (define_expand "extendqisi2"
2006   [(set (match_operand:SI 0 "register_operand" "")
2007         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
2008   ""
2009   "
2010 {
2011   if (optimize && GET_CODE (operands[1]) == MEM)
2012     operands[1] = force_not_mem (operands[1]);
2013
2014   if (GET_CODE (operands[1]) != MEM)
2015     {
2016       rtx op1   = gen_lowpart (SImode, operands[1]);
2017       rtx temp  = gen_reg_rtx (SImode);
2018       rtx shift = gen_rtx (CONST_INT, VOIDmode, 24);
2019
2020       emit_insn (gen_ashlsi3 (temp, op1, shift));
2021       emit_insn (gen_ashrsi3 (operands[0], temp, shift));
2022       DONE;
2023     }
2024 }")
2025
2026 (define_insn "extendqisi2_insn"
2027   [(set (match_operand:SI 0 "register_operand" "=d,d")
2028         (sign_extend:SI (match_operand:QI 1 "memory_operand" "R,m")))]
2029   ""
2030   "* return mips_move_1word (operands, insn, FALSE);"
2031   [(set_attr "type"     "load")
2032    (set_attr "mode"     "SI")
2033    (set_attr "length"   "1,2")])
2034
2035 (define_expand "extendqidi2"
2036   [(set (match_operand:DI 0 "register_operand" "")
2037         (sign_extend:DI (match_operand:QI 1 "nonimmediate_operand" "")))]
2038   "TARGET_64BIT"
2039   "
2040 {
2041   if (optimize && GET_CODE (operands[1]) == MEM)
2042     operands[1] = force_not_mem (operands[1]);
2043
2044   if (GET_CODE (operands[1]) != MEM)
2045     {
2046       rtx op1   = gen_lowpart (DImode, operands[1]);
2047       rtx temp  = gen_reg_rtx (DImode);
2048       rtx shift = gen_rtx (CONST_INT, VOIDmode, 56);
2049
2050       emit_insn (gen_ashldi3 (temp, op1, shift));
2051       emit_insn (gen_ashrdi3 (operands[0], temp, shift));
2052       DONE;
2053     }
2054 }")
2055
2056 (define_insn "extendqidi2_insn"
2057   [(set (match_operand:DI 0 "register_operand" "=d,d")
2058         (sign_extend:DI (match_operand:QI 1 "memory_operand" "R,m")))]
2059   "TARGET_64BIT"
2060   "* return mips_move_1word (operands, insn, FALSE);"
2061   [(set_attr "type"     "load")
2062    (set_attr "mode"     "DI")
2063    (set_attr "length"   "1,2")])
2064
2065
2066 (define_insn "extendsfdf2"
2067   [(set (match_operand:DF 0 "register_operand" "=f")
2068         (float_extend:DF (match_operand:SF 1 "register_operand" "f")))]
2069   "TARGET_HARD_FLOAT"
2070   "cvt.d.s\\t%0,%1"
2071   [(set_attr "type"     "fcvt")
2072    (set_attr "mode"     "DF")
2073    (set_attr "length"   "1")])
2074
2075 \f
2076
2077 ;;
2078 ;;  ....................
2079 ;;
2080 ;;      CONVERSIONS
2081 ;;
2082 ;;  ....................
2083
2084 ;; The SImode scratch register can not be shared with address regs used for
2085 ;; operand zero, because then the address in the move instruction will be
2086 ;; clobbered.  We mark the scratch register as early clobbered to prevent this.
2087
2088 (define_insn "fix_truncdfsi2"
2089   [(set (match_operand:SI 0 "general_operand" "=d,*f,R,o")
2090         (fix:SI (match_operand:DF 1 "register_operand" "f,*f,f,f")))
2091    (clobber (match_scratch:SI 2 "=d,*d,&d,&d"))
2092    (clobber (match_scratch:DF 3 "=f,*X,f,f"))]
2093   "TARGET_HARD_FLOAT"
2094   "*
2095 {
2096   rtx xoperands[10];
2097
2098   if (which_alternative == 1)
2099     return \"trunc.w.d %0,%1,%2\";
2100
2101   output_asm_insn (\"trunc.w.d %3,%1,%2\", operands);
2102
2103   xoperands[0] = operands[0];
2104   xoperands[1] = operands[3];
2105   output_asm_insn (mips_move_1word (xoperands, insn, FALSE), xoperands);
2106   return \"\";
2107 }"
2108   [(set_attr "type"     "fcvt")
2109    (set_attr "mode"     "DF")
2110    (set_attr "length"   "11,9,10,11")])
2111
2112
2113 (define_insn "fix_truncsfsi2"
2114   [(set (match_operand:SI 0 "general_operand" "=d,*f,R,o")
2115         (fix:SI (match_operand:SF 1 "register_operand" "f,*f,f,f")))
2116    (clobber (match_scratch:SI 2 "=d,*d,&d,&d"))
2117    (clobber (match_scratch:SF 3 "=f,*X,f,f"))]
2118   "TARGET_HARD_FLOAT"
2119   "*
2120 {
2121   rtx xoperands[10];
2122
2123   if (which_alternative == 1)
2124     return \"trunc.w.s %0,%1,%2\";
2125
2126   output_asm_insn (\"trunc.w.s %3,%1,%2\", operands);
2127
2128   xoperands[0] = operands[0];
2129   xoperands[1] = operands[3];
2130   output_asm_insn (mips_move_1word (xoperands, insn, FALSE), xoperands);
2131   return \"\";
2132 }"
2133   [(set_attr "type"     "fcvt")
2134    (set_attr "mode"     "SF")
2135    (set_attr "length"   "11,9,10,11")])
2136
2137
2138 ;;; ??? trunc.l.d is mentioned in the appendix of the 1993 r4000/r4600 manuals
2139 ;;; but not in the chapter that describes the FPU.  It is not mentioned at all
2140 ;;; in the 1991 manuals.  The r4000 at Cygnus does not have this instruction.
2141
2142 ;;; Deleting this means that we now need two libgcc2.a libraries.  One for
2143 ;;; the 32 bit calling convention and one for the 64 bit calling convention.
2144
2145 ;;; If this is disabled, then fixuns_truncdfdi2 must be disabled also.
2146
2147 (define_insn "fix_truncdfdi2"
2148   [(set (match_operand:DI 0 "general_operand" "=d,*f,R,o")
2149         (fix:DI (match_operand:DF 1 "register_operand" "f,*f,f,f")))
2150    (clobber (match_scratch:DF 2 "=f,*X,f,f"))]
2151   "TARGET_HARD_FLOAT && TARGET_64BIT"
2152   "*
2153 {
2154   rtx xoperands[10];
2155
2156   if (which_alternative == 1)
2157     return \"trunc.l.d %0,%1\";
2158
2159   output_asm_insn (\"trunc.l.d %2,%1\", operands);
2160
2161   xoperands[0] = operands[0];
2162   xoperands[1] = operands[2];
2163   output_asm_insn (mips_move_2words (xoperands, insn, FALSE), xoperands);
2164   return \"\";
2165 }"
2166   [(set_attr "type"     "fcvt")
2167    (set_attr "mode"     "DF")
2168    (set_attr "length"   "2,1,2,3")])
2169
2170
2171 ;;; ??? trunc.l.s is mentioned in the appendix of the 1993 r4000/r4600 manuals
2172 ;;; but not in the chapter that describes the FPU.  It is not mentioned at all
2173 ;;; in the 1991 manuals.  The r4000 at Cygnus does not have this instruction.
2174 (define_insn "fix_truncsfdi2"
2175   [(set (match_operand:DI 0 "general_operand" "=d,*f,R,o")
2176         (fix:DI (match_operand:SF 1 "register_operand" "f,*f,f,f")))
2177    (clobber (match_scratch:DF 2 "=f,*X,f,f"))]
2178   "TARGET_HARD_FLOAT && TARGET_64BIT"
2179   "*
2180 {
2181   rtx xoperands[10];
2182
2183   if (which_alternative == 1)
2184     return \"trunc.l.s %0,%1\";
2185
2186   output_asm_insn (\"trunc.l.s %2,%1\", operands);
2187
2188   xoperands[0] = operands[0];
2189   xoperands[1] = operands[2];
2190   output_asm_insn (mips_move_2words (xoperands, insn, FALSE), xoperands);
2191   return \"\";
2192 }"
2193   [(set_attr "type"     "fcvt")
2194    (set_attr "mode"     "SF")
2195    (set_attr "length"   "2,1,2,3")])
2196
2197
2198 (define_insn "floatsidf2"
2199   [(set (match_operand:DF 0 "register_operand" "=f,f,f")
2200         (float:DF (match_operand:SI 1 "nonimmediate_operand" "d,R,m")))]
2201   "TARGET_HARD_FLOAT"
2202   "*
2203 {
2204   dslots_load_total++;
2205   if (GET_CODE (operands[1]) == MEM)
2206     return \"l.s\\t%0,%1%#\;cvt.d.w\\t%0,%0\";
2207
2208   return \"mtc1\\t%1,%0%#\;cvt.d.w\\t%0,%0\";
2209 }"
2210   [(set_attr "type"     "fcvt")
2211    (set_attr "mode"     "DF")
2212    (set_attr "length"   "3,4,3")])
2213
2214
2215 (define_insn "floatdidf2"
2216   [(set (match_operand:DF 0 "register_operand" "=f,f,f")
2217         (float:DF (match_operand:DI 1 "nonimmediate_operand" "d,R,m")))]
2218   "TARGET_HARD_FLOAT && TARGET_64BIT"
2219   "*
2220 {
2221   dslots_load_total++;
2222   if (GET_CODE (operands[1]) == MEM)
2223     return \"l.d\\t%0,%1%#\;cvt.d.l\\t%0,%0\";
2224
2225   return \"dmtc1\\t%1,%0%#\;cvt.d.l\\t%0,%0\";
2226 }"
2227   [(set_attr "type"     "fcvt")
2228    (set_attr "mode"     "DF")
2229    (set_attr "length"   "3,4,3")])
2230
2231
2232 (define_insn "floatsisf2"
2233   [(set (match_operand:SF 0 "register_operand" "=f,f,f")
2234         (float:SF (match_operand:SI 1 "nonimmediate_operand" "d,R,m")))]
2235   "TARGET_HARD_FLOAT"
2236   "*
2237 {
2238   dslots_load_total++;
2239   if (GET_CODE (operands[1]) == MEM)
2240     return \"l.s\\t%0,%1%#\;cvt.s.w\\t%0,%0\";
2241
2242   return \"mtc1\\t%1,%0%#\;cvt.s.w\\t%0,%0\";
2243 }"
2244   [(set_attr "type"     "fcvt")
2245    (set_attr "mode"     "SF")
2246    (set_attr "length"   "3,4,3")])
2247
2248
2249 (define_insn "floatdisf2"
2250   [(set (match_operand:SF 0 "register_operand" "=f,f,f")
2251         (float:SF (match_operand:DI 1 "nonimmediate_operand" "d,R,m")))]
2252   "TARGET_HARD_FLOAT && TARGET_64BIT"
2253   "*
2254 {
2255   dslots_load_total++;
2256   if (GET_CODE (operands[1]) == MEM)
2257     return \"l.d\\t%0,%1%#\;cvt.s.l\\t%0,%0\";
2258
2259   return \"dmtc1\\t%1,%0%#\;cvt.s.l\\t%0,%0\";
2260 }"
2261   [(set_attr "type"     "fcvt")
2262    (set_attr "mode"     "SF")
2263    (set_attr "length"   "3,4,3")])
2264
2265
2266 (define_expand "fixuns_truncdfsi2"
2267   [(set (match_operand:SI 0 "register_operand" "")
2268         (unsigned_fix:SI (match_operand:DF 1 "register_operand" "")))]
2269   "TARGET_HARD_FLOAT"
2270   "
2271 {
2272   rtx reg1 = gen_reg_rtx (DFmode);
2273   rtx reg2 = gen_reg_rtx (DFmode);
2274   rtx reg3 = gen_reg_rtx (SImode);
2275   rtx label1 = gen_label_rtx ();
2276   rtx label2 = gen_label_rtx ();
2277   REAL_VALUE_TYPE offset = REAL_VALUE_LDEXP (1.0, 31);
2278
2279   if (reg1)                     /* turn off complaints about unreached code */
2280     {
2281       emit_move_insn (reg1, immed_real_const_1 (offset, DFmode));
2282       do_pending_stack_adjust ();
2283
2284       emit_insn (gen_cmpdf (operands[1], reg1));
2285       emit_jump_insn (gen_bge (label1));
2286
2287       emit_insn (gen_fix_truncdfsi2 (operands[0], operands[1]));
2288       emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx,
2289                                gen_rtx (LABEL_REF, VOIDmode, label2)));
2290       emit_barrier ();
2291
2292       emit_label (label1);
2293       emit_move_insn (reg2, gen_rtx (MINUS, DFmode, operands[1], reg1));
2294       emit_move_insn (reg3, gen_rtx (CONST_INT, VOIDmode, 0x80000000));
2295
2296       emit_insn (gen_fix_truncdfsi2 (operands[0], reg2));
2297       emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
2298
2299       emit_label (label2);
2300
2301       /* allow REG_NOTES to be set on last insn (labels don't have enough
2302          fields, and can't be used for REG_NOTES anyway).  */
2303       emit_insn (gen_rtx (USE, VOIDmode, stack_pointer_rtx));
2304       DONE;
2305     }
2306 }")
2307
2308
2309 (define_expand "fixuns_truncdfdi2"
2310   [(set (match_operand:DI 0 "register_operand" "")
2311         (unsigned_fix:DI (match_operand:DF 1 "register_operand" "")))]
2312   "TARGET_HARD_FLOAT && TARGET_64BIT"
2313   "
2314 {
2315   rtx reg1 = gen_reg_rtx (DFmode);
2316   rtx reg2 = gen_reg_rtx (DFmode);
2317   rtx reg3 = gen_reg_rtx (DImode);
2318   rtx label1 = gen_label_rtx ();
2319   rtx label2 = gen_label_rtx ();
2320   REAL_VALUE_TYPE offset = REAL_VALUE_LDEXP (1.0, 63);
2321
2322   if (reg1)                     /* turn off complaints about unreached code */
2323     {
2324       emit_move_insn (reg1, immed_real_const_1 (offset, DFmode));
2325       do_pending_stack_adjust ();
2326
2327       emit_insn (gen_cmpdf (operands[1], reg1));
2328       emit_jump_insn (gen_bge (label1));
2329
2330       emit_insn (gen_fix_truncdfdi2 (operands[0], operands[1]));
2331       emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx,
2332                                gen_rtx (LABEL_REF, VOIDmode, label2)));
2333       emit_barrier ();
2334
2335       emit_label (label1);
2336       emit_move_insn (reg2, gen_rtx (MINUS, DFmode, operands[1], reg1));
2337       emit_move_insn (reg3, gen_rtx (CONST_INT, VOIDmode, 0x80000000));
2338       emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
2339
2340       emit_insn (gen_fix_truncdfdi2 (operands[0], reg2));
2341       emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
2342
2343       emit_label (label2);
2344
2345       /* allow REG_NOTES to be set on last insn (labels don't have enough
2346          fields, and can't be used for REG_NOTES anyway).  */
2347       emit_insn (gen_rtx (USE, VOIDmode, stack_pointer_rtx));
2348       DONE;
2349     }
2350 }")
2351
2352
2353 (define_expand "fixuns_truncsfsi2"
2354   [(set (match_operand:SI 0 "register_operand" "")
2355         (unsigned_fix:SI (match_operand:SF 1 "register_operand" "")))]
2356   "TARGET_HARD_FLOAT"
2357   "
2358 {
2359   rtx reg1 = gen_reg_rtx (SFmode);
2360   rtx reg2 = gen_reg_rtx (SFmode);
2361   rtx reg3 = gen_reg_rtx (SImode);
2362   rtx label1 = gen_label_rtx ();
2363   rtx label2 = gen_label_rtx ();
2364   REAL_VALUE_TYPE offset = REAL_VALUE_LDEXP (1.0, 31);
2365
2366   if (reg1)                     /* turn off complaints about unreached code */
2367     {
2368       emit_move_insn (reg1, immed_real_const_1 (offset, SFmode));
2369       do_pending_stack_adjust ();
2370
2371       emit_insn (gen_cmpsf (operands[1], reg1));
2372       emit_jump_insn (gen_bge (label1));
2373
2374       emit_insn (gen_fix_truncsfsi2 (operands[0], operands[1]));
2375       emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx,
2376                                gen_rtx (LABEL_REF, VOIDmode, label2)));
2377       emit_barrier ();
2378
2379       emit_label (label1);
2380       emit_move_insn (reg2, gen_rtx (MINUS, SFmode, operands[1], reg1));
2381       emit_move_insn (reg3, gen_rtx (CONST_INT, VOIDmode, 0x80000000));
2382
2383       emit_insn (gen_fix_truncsfsi2 (operands[0], reg2));
2384       emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
2385
2386       emit_label (label2);
2387
2388       /* allow REG_NOTES to be set on last insn (labels don't have enough
2389          fields, and can't be used for REG_NOTES anyway).  */
2390       emit_insn (gen_rtx (USE, VOIDmode, stack_pointer_rtx));
2391       DONE;
2392     }
2393 }")
2394
2395
2396 (define_expand "fixuns_truncsfdi2"
2397   [(set (match_operand:DI 0 "register_operand" "")
2398         (unsigned_fix:DI (match_operand:SF 1 "register_operand" "")))]
2399   "TARGET_HARD_FLOAT && TARGET_64BIT"
2400   "
2401 {
2402   rtx reg1 = gen_reg_rtx (SFmode);
2403   rtx reg2 = gen_reg_rtx (SFmode);
2404   rtx reg3 = gen_reg_rtx (DImode);
2405   rtx label1 = gen_label_rtx ();
2406   rtx label2 = gen_label_rtx ();
2407   REAL_VALUE_TYPE offset = REAL_VALUE_LDEXP (1.0, 63);
2408
2409   if (reg1)                     /* turn off complaints about unreached code */
2410     {
2411       emit_move_insn (reg1, immed_real_const_1 (offset, SFmode));
2412       do_pending_stack_adjust ();
2413
2414       emit_insn (gen_cmpsf (operands[1], reg1));
2415       emit_jump_insn (gen_bge (label1));
2416
2417       emit_insn (gen_fix_truncsfdi2 (operands[0], operands[1]));
2418       emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx,
2419                                gen_rtx (LABEL_REF, VOIDmode, label2)));
2420       emit_barrier ();
2421
2422       emit_label (label1);
2423       emit_move_insn (reg2, gen_rtx (MINUS, SFmode, operands[1], reg1));
2424       emit_move_insn (reg3, gen_rtx (CONST_INT, VOIDmode, 0x80000000));
2425       emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
2426
2427       emit_insn (gen_fix_truncsfdi2 (operands[0], reg2));
2428       emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
2429
2430       emit_label (label2);
2431
2432       /* allow REG_NOTES to be set on last insn (labels don't have enough
2433          fields, and can't be used for REG_NOTES anyway).  */
2434       emit_insn (gen_rtx (USE, VOIDmode, stack_pointer_rtx));
2435       DONE;
2436     }
2437 }")
2438
2439 \f
2440 ;;
2441 ;;  ....................
2442 ;;
2443 ;;      DATA MOVEMENT
2444 ;;
2445 ;;  ....................
2446
2447 ;; unaligned word moves generated by the block moves.
2448
2449 ;; I don't think these are used anymore.  Ian Taylor 30 Sep 93
2450
2451 ;;(define_expand "movsi_unaligned"
2452 ;;  [(set (match_operand:SI 0 "general_operand" "")
2453 ;;      (unspec [(match_operand:SI 1 "general_operand" "")] 0))]
2454 ;;  ""
2455 ;;  "
2456 ;;{
2457 ;;  /* Handle stores.  */
2458 ;;  if (GET_CODE (operands[0]) == MEM)
2459 ;;    {
2460 ;;      rtx reg = gen_reg_rtx (SImode);
2461 ;;      rtx insn = emit_insn (gen_movsi_ulw (reg, operands[1]));
2462 ;;      rtx addr = XEXP (operands[0], 0);
2463 ;;      if (CONSTANT_P (addr))
2464 ;;      REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_EQUIV, addr, REG_NOTES (insn));
2465 ;;
2466 ;;      if (reg_or_0_operand (operands[1], SImode))
2467 ;;      DONE;
2468 ;;
2469 ;;      operands[1] = reg;
2470 ;;    }
2471 ;;
2472 ;;  /* Generate appropriate load, store.  If not a load or store,
2473 ;;     do a normal movsi.  */
2474 ;;  if (GET_CODE (operands[0]) != MEM && GET_CODE (operands[1]) != MEM)
2475 ;;    {
2476 ;;      emit_insn (gen_movsi (operands[0], operands[1]));
2477 ;;      DONE;
2478 ;;    }
2479 ;;
2480 ;;  /* Fall through and generate normal code.  */
2481 ;;}")
2482 ;;
2483 ;;(define_insn "movsi_ulw"
2484 ;;  [(set (match_operand:SI 0 "register_operand" "=&d,&d,d,d")
2485 ;;      (unspec [(match_operand:SI 1 "general_operand" "R,o,dIKL,M")] 0))]
2486 ;;  ""
2487 ;;  "*
2488 ;;{
2489 ;;  enum rtx_code code;
2490 ;;  char *ret;
2491 ;;  rtx offset;
2492 ;;  rtx addr;
2493 ;;  rtx mem_addr;
2494 ;;
2495 ;;  if (which_alternative != 0)
2496 ;;    return mips_move_1word (operands, insn, FALSE);
2497 ;;
2498 ;;  if (TARGET_STATS)
2499 ;;    mips_count_memory_refs (operands[1], 2);
2500 ;;
2501 ;;  /* The stack/frame pointers are always aligned, so we can convert
2502 ;;     to the faster lw if we are referencing an aligned stack location.  */
2503 ;;
2504 ;;  offset = const0_rtx;
2505 ;;  addr = XEXP (operands[1], 0);
2506 ;;  mem_addr = eliminate_constant_term (addr, &offset);
2507 ;;
2508 ;;  if ((INTVAL (offset) & (UNITS_PER_WORD-1)) == 0
2509 ;;      && (mem_addr == stack_pointer_rtx || mem_addr == frame_pointer_rtx))
2510 ;;    ret = \"lw\\t%0,%1\";
2511 ;;
2512 ;;  else
2513 ;;    {
2514 ;;      ret = \"ulw\\t%0,%1\";
2515 ;;      if (TARGET_GAS)
2516 ;;      {
2517 ;;        enum rtx_code code = GET_CODE (addr);
2518 ;;
2519 ;;        if (code == CONST || code == SYMBOL_REF || code == LABEL_REF)
2520 ;;          {
2521 ;;            operands[2] = gen_rtx (REG, SImode, GP_REG_FIRST + 1);
2522 ;;            ret = \"%[la\\t%2,%1\;ulw\\t%0,0(%2)%]\";
2523 ;;          }
2524 ;;      }
2525 ;;    }
2526 ;;
2527 ;;  return mips_fill_delay_slot (ret, DELAY_LOAD, operands, insn);
2528 ;;}"
2529 ;;  [(set_attr "type"   "load,load,move,arith")
2530 ;;   (set_attr "mode"   "SI")
2531 ;;   (set_attr "length" "2,4,1,2")])
2532 ;;
2533 ;;(define_insn "movsi_usw"
2534 ;;  [(set (match_operand:SI 0 "memory_operand" "=R,o")
2535 ;;      (unspec [(match_operand:SI 1 "reg_or_0_operand" "dJ,dJ")] 0))]
2536 ;;  ""
2537 ;;  "*
2538 ;;{
2539 ;;  rtx offset = const0_rtx;
2540 ;;  rtx addr = XEXP (operands[0], 0);
2541 ;;  rtx mem_addr = eliminate_constant_term (addr, &offset);
2542 ;;
2543 ;;  if (TARGET_STATS)
2544 ;;    mips_count_memory_refs (operands[0], 2);
2545 ;;
2546 ;;  /* The stack/frame pointers are always aligned, so we can convert
2547 ;;     to the faster sw if we are referencing an aligned stack location.  */
2548 ;;
2549 ;;  if ((INTVAL (offset) & (UNITS_PER_WORD-1)) == 0
2550 ;;      && (mem_addr == stack_pointer_rtx || mem_addr == frame_pointer_rtx))
2551 ;;    return \"sw\\t%1,%0\";
2552 ;;
2553 ;;
2554 ;;  if (TARGET_GAS)
2555 ;;    {
2556 ;;      enum rtx_code code = GET_CODE (XEXP (operands[0], 0));
2557 ;;
2558 ;;      if (code == CONST || code == SYMBOL_REF || code == LABEL_REF)
2559 ;;      {
2560 ;;        operands[2] = gen_rtx (REG, SImode, GP_REG_FIRST + 1);
2561 ;;        return \"%[la\\t%2,%0\;usw\\t%z1,0(%2)%]\";
2562 ;;      }
2563 ;;    }
2564 ;;
2565 ;;  return \"usw\\t%z1,%0\";
2566 ;;}"
2567 ;;  [(set_attr "type"   "store")
2568 ;;   (set_attr "mode"   "SI")
2569 ;;   (set_attr "length" "2,4")])
2570
2571
2572 ;; 64-bit integer moves
2573
2574 ;; Unlike most other insns, the move insns can't be split with
2575 ;; different predicates, because register spilling and other parts of
2576 ;; the compiler, have memoized the insn number already.
2577
2578 (define_expand "movdi"
2579   [(set (match_operand:DI 0 "nonimmediate_operand" "")
2580         (match_operand:DI 1 "general_operand" ""))]
2581   ""
2582   "
2583 {
2584   if ((reload_in_progress | reload_completed) == 0
2585       && !register_operand (operands[0], DImode)
2586       && !register_operand (operands[1], DImode)
2587       && (GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0)
2588       && operands[1] != CONST0_RTX (DImode))
2589     {
2590       rtx temp = force_reg (DImode, operands[1]);
2591       emit_move_insn (operands[0], temp);
2592       DONE;
2593     }
2594 }")
2595
2596 (define_insn "movdi_internal"
2597   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,R,o,*d,*x")
2598         (match_operand:DI 1 "general_operand" "d,iF,R,o,d,d,*x,*d"))]
2599   "!TARGET_64BIT
2600    && (register_operand (operands[0], DImode)
2601        || register_operand (operands[1], DImode)
2602        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0)
2603        || operands[1] == CONST0_RTX (DImode))"
2604   "* return mips_move_2words (operands, insn); "
2605   [(set_attr "type"     "move,arith,load,load,store,store,hilo,hilo")
2606    (set_attr "mode"     "DI")
2607    (set_attr "length"   "2,4,2,4,2,4,2,2")])
2608
2609 (define_split
2610   [(set (match_operand:DI 0 "register_operand" "")
2611         (match_operand:DI 1 "register_operand" ""))]
2612   "reload_completed && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
2613    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
2614    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))"
2615
2616   [(set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))
2617    (set (subreg:SI (match_dup 0) 1) (subreg:SI (match_dup 1) 1))]
2618   "")
2619
2620 (define_insn "movdi_internal2"
2621   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,R,m,*d,*x")
2622         (match_operand:DI 1 "general_operand" " d,S,IKL,Mnis,R,m,dJ,dJ,*x,*d"))]
2623   "TARGET_64BIT
2624    && (register_operand (operands[0], DImode)
2625        || register_operand (operands[1], DImode)
2626        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0)
2627        || operands[1] == CONST0_RTX (DImode))"
2628   "* return mips_move_2words (operands, insn); "
2629   [(set_attr "type"     "move,load,arith,arith,load,load,store,store,hilo,hilo")
2630    (set_attr "mode"     "DI")
2631    (set_attr "length"   "1,2,1,2,1,2,1,2,1,1")])
2632
2633
2634 ;; 32-bit Integer moves
2635
2636 (define_split
2637   [(set (match_operand:SI 0 "register_operand" "")
2638         (match_operand:SI 1 "large_int" ""))]
2639   "!TARGET_DEBUG_D_MODE"
2640   [(set (match_dup 0)
2641         (match_dup 2))
2642    (set (match_dup 0)
2643         (ior:SI (match_dup 0)
2644                 (match_dup 3)))]
2645   "
2646 {
2647   operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) & 0xffff0000);
2648   operands[3] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) & 0x0000ffff);
2649 }")
2650
2651 ;; Unlike most other insns, the move insns can't be split with
2652 ;; different predicates, because register spilling and other parts of
2653 ;; the compiler, have memoized the insn number already.
2654
2655 (define_expand "movsi"
2656   [(set (match_operand:SI 0 "nonimmediate_operand" "")
2657         (match_operand:SI 1 "general_operand" ""))]
2658   ""
2659   "
2660 {
2661   if ((reload_in_progress | reload_completed) == 0
2662       && !register_operand (operands[0], SImode)
2663       && !register_operand (operands[1], SImode)
2664       && (GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0))
2665     {
2666       rtx temp = force_reg (SImode, operands[1]);
2667       emit_move_insn (operands[0], temp);
2668       DONE;
2669     }
2670 }")
2671
2672 ;; The difference between these two is whether or not ints are allowed
2673 ;; in FP registers (off by default, use -mdebugh to enable).
2674
2675 (define_insn "movsi_internal1"
2676   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,R,m,*d,*f*z,*f,*f,*f,*R,*m,*x,*d")
2677         (match_operand:SI 1 "general_operand" "d,S,IKL,Mnis,R,m,dJ,dJ,*f*z,*d,*f,*R,*m,*f,*f,*d,*x"))]
2678   "TARGET_DEBUG_H_MODE
2679    && (register_operand (operands[0], SImode)
2680        || register_operand (operands[1], SImode)
2681        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
2682   "* return mips_move_1word (operands, insn, FALSE);"
2683   [(set_attr "type"     "move,load,arith,arith,load,load,store,store,xfer,xfer,move,load,load,store,store,hilo,hilo")
2684    (set_attr "mode"     "SI")
2685    (set_attr "length"   "1,2,1,2,1,2,1,2,1,1,1,1,2,1,2,1,1")])
2686
2687 (define_insn "movsi_internal2"
2688   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,R,m,*d,*z,*d,*x")
2689         (match_operand:SI 1 "general_operand" "d,S,IKL,Mnis,R,m,dJ,dJ,*z,*d,*x,*d"))]
2690   "!TARGET_DEBUG_H_MODE
2691    && (register_operand (operands[0], SImode)
2692        || register_operand (operands[1], SImode)
2693        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
2694   "* return mips_move_1word (operands, insn, FALSE);"
2695   [(set_attr "type"     "move,load,arith,arith,load,load,store,store,xfer,xfer,hilo,hilo")
2696    (set_attr "mode"     "SI")
2697    (set_attr "length"   "1,2,1,2,1,2,1,2,1,1,1,1")])
2698
2699
2700 ;; 16-bit Integer moves
2701
2702 ;; Unlike most other insns, the move insns can't be split with
2703 ;; different predicates, because register spilling and other parts of
2704 ;; the compiler, have memoized the insn number already.
2705 ;; Unsigned loads are used because BYTE_LOADS_ZERO_EXTEND is defined
2706
2707 (define_expand "movhi"
2708   [(set (match_operand:HI 0 "nonimmediate_operand" "")
2709         (match_operand:HI 1 "general_operand" ""))]
2710   ""
2711   "
2712 {
2713   if ((reload_in_progress | reload_completed) == 0
2714       && !register_operand (operands[0], HImode)
2715       && !register_operand (operands[1], HImode)
2716       && (GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0))
2717     {
2718       rtx temp = force_reg (HImode, operands[1]);
2719       emit_move_insn (operands[0], temp);
2720       DONE;
2721     }
2722 }")
2723
2724 ;; The difference between these two is whether or not ints are allowed
2725 ;; in FP registers (off by default, use -mdebugh to enable).
2726
2727 (define_insn "movhi_internal1"
2728   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,R,m,*d,*f,*f*z,*x,*d")
2729         (match_operand:HI 1 "general_operand"       "d,IK,R,m,dJ,dJ,*f*z,*d,*f,*d,*x"))]
2730   "TARGET_DEBUG_H_MODE
2731    && (register_operand (operands[0], HImode)
2732        || register_operand (operands[1], HImode)
2733        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
2734   "* return mips_move_1word (operands, insn, TRUE);"
2735   [(set_attr "type"     "move,arith,load,load,store,store,xfer,xfer,move,hilo,hilo")
2736    (set_attr "mode"     "HI")
2737    (set_attr "length"   "1,1,1,2,1,2,1,1,1,1,1")])
2738
2739 (define_insn "movhi_internal2"
2740   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,R,m,*d,*z,*x,*d")
2741         (match_operand:HI 1 "general_operand"       "d,IK,R,m,dJ,dJ,*z,*d,*d,*x"))]
2742   "!TARGET_DEBUG_H_MODE
2743    && (register_operand (operands[0], HImode)
2744        || register_operand (operands[1], HImode)
2745        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
2746   "* return mips_move_1word (operands, insn, TRUE);"
2747   [(set_attr "type"     "move,arith,load,load,store,store,xfer,xfer,hilo,hilo")
2748    (set_attr "mode"     "HI")
2749    (set_attr "length"   "1,1,1,2,1,2,1,1,1,1")])
2750
2751
2752 ;; 8-bit Integer moves
2753
2754 ;; Unlike most other insns, the move insns can't be split with
2755 ;; different predicates, because register spilling and other parts of
2756 ;; the compiler, have memoized the insn number already.
2757 ;; Unsigned loads are used because BYTE_LOADS_ZERO_EXTEND is defined
2758
2759 (define_expand "movqi"
2760   [(set (match_operand:QI 0 "nonimmediate_operand" "")
2761         (match_operand:QI 1 "general_operand" ""))]
2762   ""
2763   "
2764 {
2765   if ((reload_in_progress | reload_completed) == 0
2766       && !register_operand (operands[0], QImode)
2767       && !register_operand (operands[1], QImode)
2768       && (GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0))
2769     {
2770       rtx temp = force_reg (QImode, operands[1]);
2771       emit_move_insn (operands[0], temp);
2772       DONE;
2773     }
2774 }")
2775
2776 ;; The difference between these two is whether or not ints are allowed
2777 ;; in FP registers (off by default, use -mdebugh to enable).
2778
2779 (define_insn "movqi_internal1"
2780   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,m,*d,*f*z,*f,*x,*d")
2781         (match_operand:QI 1 "general_operand"       "d,IK,R,m,dJ,dJ,*f*z,*d,*f,*d,*x"))]
2782   "TARGET_DEBUG_H_MODE
2783    && (register_operand (operands[0], QImode)
2784        || register_operand (operands[1], QImode)
2785        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
2786   "* return mips_move_1word (operands, insn, TRUE);"
2787   [(set_attr "type"     "move,arith,load,load,store,store,xfer,xfer,move,hilo,hilo")
2788    (set_attr "mode"     "QI")
2789    (set_attr "length"   "1,1,1,2,1,2,1,1,1,1,1")])
2790
2791 (define_insn "movqi_internal2"
2792   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,m,*d,*z,*x,*d")
2793         (match_operand:QI 1 "general_operand"       "d,IK,R,m,dJ,dJ,*z,*d,*d,*x"))]
2794   "!TARGET_DEBUG_H_MODE
2795    && (register_operand (operands[0], QImode)
2796        || register_operand (operands[1], QImode)
2797        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
2798   "* return mips_move_1word (operands, insn, TRUE);"
2799   [(set_attr "type"     "move,arith,load,load,store,store,xfer,xfer,hilo,hilo")
2800    (set_attr "mode"     "QI")
2801    (set_attr "length"   "1,1,1,2,1,2,1,1,1,1")])
2802
2803
2804 ;; 32-bit floating point moves
2805
2806 (define_expand "movsf"
2807   [(set (match_operand:SF 0 "nonimmediate_operand" "")
2808         (match_operand:SF 1 "general_operand" ""))]
2809   ""
2810   "
2811 {
2812   if ((reload_in_progress | reload_completed) == 0
2813       && !register_operand (operands[0], SFmode)
2814       && !register_operand (operands[1], SFmode)
2815       && (GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0)
2816       && operands[1] != CONST0_RTX (SFmode))
2817     {
2818       rtx temp = force_reg (SFmode, operands[1]);
2819       emit_move_insn (operands[0], temp);
2820       DONE;
2821     }
2822 }")
2823
2824 (define_insn "movsf_internal1"
2825   [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,f,R,m,*f,*d,*d,*d,*d,*R,*m")
2826         (match_operand:SF 1 "general_operand" "f,G,R,Fm,fG,fG,*d,*f,*G*d,*R,*F*m,*d,*d"))]
2827   "TARGET_HARD_FLOAT
2828    && (register_operand (operands[0], SFmode)
2829        || register_operand (operands[1], SFmode)
2830        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0)
2831        || operands[1] == CONST0_RTX (SFmode))"
2832   "* return mips_move_1word (operands, insn, FALSE);"
2833   [(set_attr "type"     "move,xfer,load,load,store,store,xfer,xfer,move,load,load,store,store")
2834    (set_attr "mode"     "SF")
2835    (set_attr "length"   "1,1,1,2,1,2,1,1,1,1,2,1,2")])
2836
2837
2838 (define_insn "movsf_internal2"
2839   [(set (match_operand:SF 0 "nonimmediate_operand" "=d,d,d,R,m")
2840         (match_operand:SF 1 "general_operand" "      Gd,R,Fm,d,d"))]
2841   "TARGET_SOFT_FLOAT
2842    && (register_operand (operands[0], SFmode)
2843        || register_operand (operands[1], SFmode)
2844        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0)
2845        || operands[1] == CONST0_RTX (SFmode))"
2846   "* return mips_move_1word (operands, insn, FALSE);"
2847   [(set_attr "type"     "move,load,load,store,store")
2848    (set_attr "mode"     "SF")
2849    (set_attr "length"   "1,1,2,1,2")])
2850
2851
2852 ;; 64-bit floating point moves
2853
2854 (define_expand "movdf"
2855   [(set (match_operand:DF 0 "nonimmediate_operand" "")
2856         (match_operand:DF 1 "general_operand" ""))]
2857   ""
2858   "
2859 {
2860   if ((reload_in_progress | reload_completed) == 0
2861       && !register_operand (operands[0], DFmode)
2862       && !register_operand (operands[1], DFmode)
2863       && (GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0)
2864       && operands[1] != CONST0_RTX (DFmode))
2865     {
2866       rtx temp = force_reg (DFmode, operands[1]);
2867       emit_move_insn (operands[0], temp);
2868       DONE;
2869     }
2870 }")
2871
2872 (define_insn "movdf_internal1"
2873   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,R,o,f,*f,*d,*d,*d,*d,*R,*o")
2874         (match_operand:DF 1 "general_operand" "f,R,o,fG,fG,F,*d,*f,*d*G,*R,*o*F,*d,*d"))]
2875   "TARGET_HARD_FLOAT
2876    && (register_operand (operands[0], DFmode)
2877        || register_operand (operands[1], DFmode)
2878        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0)
2879        || operands[1] == CONST0_RTX (DFmode))"
2880   "* return mips_move_2words (operands, insn); "
2881   [(set_attr "type"     "move,load,load,store,store,load,xfer,xfer,move,load,load,store,store")
2882    (set_attr "mode"     "DF")
2883    (set_attr "length"   "1,2,4,2,4,4,2,2,2,2,4,2,4")])
2884
2885 (define_insn "movdf_internal2"
2886   [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,R,o")
2887         (match_operand:DF 1 "general_operand" "dG,R,oF,d,d"))]
2888   "TARGET_SOFT_FLOAT
2889    && (register_operand (operands[0], DFmode)
2890        || register_operand (operands[1], DFmode)
2891        || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0)
2892        || operands[1] == CONST0_RTX (DFmode))"
2893   "* return mips_move_2words (operands, insn); "
2894   [(set_attr "type"     "move,load,load,store,store")
2895    (set_attr "mode"     "DF")
2896    (set_attr "length"   "2,2,4,2,4")])
2897
2898 (define_split
2899   [(set (match_operand:DF 0 "register_operand" "")
2900         (match_operand:DF 1 "register_operand" ""))]
2901   "reload_completed && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
2902    && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
2903    && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))"
2904
2905   [(set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))
2906    (set (subreg:SI (match_dup 0) 1) (subreg:SI (match_dup 1) 1))]
2907   "")
2908
2909 \f
2910 ;; Block moves, see mips.c for more details.
2911 ;; Argument 0 is the destination
2912 ;; Argument 1 is the source
2913 ;; Argument 2 is the length
2914 ;; Argument 3 is the alignment
2915
2916 (define_expand "movstrsi"
2917   [(parallel [(set (mem:BLK (match_operand:BLK 0 "general_operand" ""))
2918                    (mem:BLK (match_operand:BLK 1 "general_operand" "")))
2919               (use (match_operand:SI 2 "arith32_operand" ""))
2920               (use (match_operand:SI 3 "immediate_operand" ""))])]
2921   ""
2922   "
2923 {
2924   if (operands[0])              /* avoid unused code messages */
2925     {
2926       expand_block_move (operands);
2927       DONE;
2928     }
2929 }")
2930
2931 ;; Insn generated by block moves
2932
2933 (define_insn "movstrsi_internal"
2934   [(set (match_operand:BLK 0 "memory_operand" "=Ro")    ;; destination
2935         (match_operand:BLK 1 "memory_operand" "Ro"))    ;; source
2936    (clobber (match_scratch:SI 4 "=&d"))                 ;; temp 1
2937    (clobber (match_scratch:SI 5 "=&d"))                 ;; temp 2
2938    (clobber (match_scratch:SI 6 "=&d"))                 ;; temp 3
2939    (clobber (match_scratch:SI 7 "=&d"))                 ;; temp 4
2940    (use (match_operand:SI 2 "small_int" "I"))           ;; # bytes to move
2941    (use (match_operand:SI 3 "small_int" "I"))           ;; alignment
2942    (use (const_int 0))]                                 ;; normal block move
2943   ""
2944   "* return output_block_move (insn, operands, 4, BLOCK_MOVE_NORMAL);"
2945   [(set_attr "type"     "multi")
2946    (set_attr "mode"     "none")
2947    (set_attr "length"   "20")])
2948
2949 ;; Split a block move into 2 parts, the first part is everything
2950 ;; except for the last move, and the second part is just the last
2951 ;; store, which is exactly 1 instruction (ie, not a usw), so it can
2952 ;; fill a delay slot.  This also prevents a bug in delayed branches
2953 ;; from showing up, which reuses one of the registers in our clobbers.
2954
2955 (define_split
2956   [(set (mem:BLK (match_operand:SI 0 "register_operand" ""))
2957         (mem:BLK (match_operand:SI 1 "register_operand" "")))
2958    (clobber (match_operand:SI 4 "register_operand" ""))
2959    (clobber (match_operand:SI 5 "register_operand" ""))
2960    (clobber (match_operand:SI 6 "register_operand" ""))
2961    (clobber (match_operand:SI 7 "register_operand" ""))
2962    (use (match_operand:SI 2 "small_int" ""))
2963    (use (match_operand:SI 3 "small_int" ""))
2964    (use (const_int 0))]
2965
2966   "reload_completed && !TARGET_DEBUG_D_MODE && INTVAL (operands[2]) > 0"
2967
2968   ;; All but the last move
2969   [(parallel [(set (mem:BLK (match_dup 0))
2970                    (mem:BLK (match_dup 1)))
2971               (clobber (match_dup 4))
2972               (clobber (match_dup 5))
2973               (clobber (match_dup 6))
2974               (clobber (match_dup 7))
2975               (use (match_dup 2))
2976               (use (match_dup 3))
2977               (use (const_int 1))])
2978
2979    ;; The last store, so it can fill a delay slot
2980    (parallel [(set (mem:BLK (match_dup 0))
2981                    (mem:BLK (match_dup 1)))
2982               (clobber (match_dup 4))
2983               (clobber (match_dup 5))
2984               (clobber (match_dup 6))
2985               (clobber (match_dup 7))
2986               (use (match_dup 2))
2987               (use (match_dup 3))
2988               (use (const_int 2))])]
2989
2990   "")
2991
2992 (define_insn "movstrsi_internal2"
2993   [(set (match_operand:BLK 0 "memory_operand" "=Ro")    ;; destination
2994         (match_operand:BLK 1 "memory_operand" "Ro"))    ;; source
2995    (clobber (match_scratch:SI 4 "=&d"))                 ;; temp 1
2996    (clobber (match_scratch:SI 5 "=&d"))                 ;; temp 2
2997    (clobber (match_scratch:SI 6 "=&d"))                 ;; temp 3
2998    (clobber (match_scratch:SI 7 "=&d"))                 ;; temp 4
2999    (use (match_operand:SI 2 "small_int" "I"))           ;; # bytes to move
3000    (use (match_operand:SI 3 "small_int" "I"))           ;; alignment
3001    (use (const_int 1))]                                 ;; all but last store
3002   ""
3003   "* return output_block_move (insn, operands, 4, BLOCK_MOVE_NOT_LAST);"
3004   [(set_attr "type"     "multi")
3005    (set_attr "mode"     "none")
3006    (set_attr "length"   "20")])
3007
3008 (define_insn "movstrsi_internal3"
3009   [(set (match_operand:BLK 0 "memory_operand" "=Ro")    ;; destination
3010         (match_operand:BLK 1 "memory_operand" "Ro"))    ;; source
3011    (clobber (match_scratch:SI 4 "=&d"))                 ;; temp 1
3012    (clobber (match_scratch:SI 5 "=&d"))                 ;; temp 2
3013    (clobber (match_scratch:SI 6 "=&d"))                 ;; temp 3
3014    (clobber (match_scratch:SI 7 "=&d"))                 ;; temp 4
3015    (use (match_operand:SI 2 "small_int" "I"))           ;; # bytes to move
3016    (use (match_operand:SI 3 "small_int" "I"))           ;; alignment
3017    (use (const_int 2))]                                 ;; just last store of block move
3018   ""
3019   "* return output_block_move (insn, operands, 4, BLOCK_MOVE_LAST);"
3020   [(set_attr "type"     "store")
3021    (set_attr "mode"     "none")
3022    (set_attr "length"   "1")])
3023
3024 \f
3025 ;;
3026 ;;  ....................
3027 ;;
3028 ;;      SHIFTS
3029 ;;
3030 ;;  ....................
3031
3032 (define_insn "ashlsi3"
3033   [(set (match_operand:SI 0 "register_operand" "=d")
3034         (ashift:SI (match_operand:SI 1 "register_operand" "d")
3035                    (match_operand:SI 2 "arith_operand" "dI")))]
3036   ""
3037   "*
3038 {
3039   if (GET_CODE (operands[2]) == CONST_INT)
3040     operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);
3041
3042   return \"sll\\t%0,%1,%2\";
3043 }"
3044   [(set_attr "type"     "arith")
3045    (set_attr "mode"     "SI")
3046    (set_attr "length"   "1")])
3047
3048
3049 (define_expand "ashldi3"
3050   [(parallel [(set (match_operand:DI 0 "register_operand" "")
3051                    (ashift:DI (match_operand:DI 1 "register_operand" "")
3052                               (match_operand:SI 2 "arith_operand" "")))
3053               (clobber (match_dup  3))])]
3054   "TARGET_64BIT || !TARGET_DEBUG_G_MODE"
3055   "
3056 {
3057   if (TARGET_64BIT)
3058     {
3059       emit_insn (gen_ashldi3_internal4 (operands[0], operands[1],
3060                                         operands[2]));
3061       DONE;
3062     }
3063
3064   operands[3] = gen_reg_rtx (SImode);
3065 }")
3066
3067
3068 (define_insn "ashldi3_internal"
3069   [(set (match_operand:DI 0 "register_operand" "=&d")
3070         (ashift:DI (match_operand:DI 1 "register_operand" "d")
3071                    (match_operand:SI 2 "register_operand" "d")))
3072    (clobber (match_operand:SI 3 "register_operand" "=d"))]
3073   "!TARGET_64BIT && !TARGET_DEBUG_G_MODE"
3074   "* 
3075 {
3076   operands[4] = const0_rtx;
3077   dslots_jump_total += 3;
3078   dslots_jump_filled += 2;
3079
3080   return \"sll\\t%3,%2,26\\n\\
3081 \\tbgez\\t%3,1f\\n\\
3082 \\tsll\\t%M0,%L1,%2\\n\\
3083 \\t%(b\\t3f\\n\\
3084 \\tmove\\t%L0,%z4%)\\n\\
3085 \\n\\
3086 1:\\n\\
3087 \\t%(beq\\t%3,%z4,2f\\n\\
3088 \\tsll\\t%M0,%M1,%2%)\\n\\
3089 \\n\\
3090 \\tsubu\\t%3,%z4,%2\\n\\
3091 \\tsrl\\t%3,%L1,%3\\n\\
3092 \\tor\\t%M0,%M0,%3\\n\\
3093 2:\\n\\
3094 \\tsll\\t%L0,%L1,%2\\n\\
3095 3:\";
3096 }"
3097   [(set_attr "type"     "darith")
3098    (set_attr "mode"     "SI")
3099    (set_attr "length"   "12")])
3100
3101
3102 (define_insn "ashldi3_internal2"
3103   [(set (match_operand:DI 0 "register_operand" "=d")
3104         (ashift:DI (match_operand:DI 1 "register_operand" "d")
3105                    (match_operand:SI 2 "small_int" "IJK")))
3106    (clobber (match_operand:SI 3 "register_operand" "=d"))]
3107   "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && (INTVAL (operands[2]) & 32) != 0"
3108   "*
3109 {
3110   operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);
3111   operands[4] = const0_rtx;
3112   return \"sll\\t%M0,%L1,%2\;move\\t%L0,%z4\";
3113 }"
3114   [(set_attr "type"     "darith")
3115    (set_attr "mode"     "DI")
3116    (set_attr "length"   "2")])
3117
3118
3119 (define_split
3120   [(set (match_operand:DI 0 "register_operand" "")
3121         (ashift:DI (match_operand:DI 1 "register_operand" "")
3122                    (match_operand:SI 2 "small_int" "")))
3123    (clobber (match_operand:SI 3 "register_operand" ""))]
3124   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
3125    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
3126    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
3127    && (INTVAL (operands[2]) & 32) != 0"
3128
3129   [(set (subreg:SI (match_dup 0) 1) (ashift:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
3130    (set (subreg:SI (match_dup 0) 0) (const_int 0))]
3131
3132   "operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);")
3133
3134
3135 (define_split
3136   [(set (match_operand:DI 0 "register_operand" "")
3137         (ashift:DI (match_operand:DI 1 "register_operand" "")
3138                    (match_operand:SI 2 "small_int" "")))
3139    (clobber (match_operand:SI 3 "register_operand" ""))]
3140   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
3141    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
3142    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
3143    && (INTVAL (operands[2]) & 32) != 0"
3144
3145   [(set (subreg:SI (match_dup 0) 0) (ashift:SI (subreg:SI (match_dup 1) 1) (match_dup 2)))
3146    (set (subreg:SI (match_dup 0) 1) (const_int 0))]
3147
3148   "operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);")
3149
3150
3151 (define_insn "ashldi3_internal3"
3152   [(set (match_operand:DI 0 "register_operand" "=d")
3153         (ashift:DI (match_operand:DI 1 "register_operand" "d")
3154                    (match_operand:SI 2 "small_int" "IJK")))
3155    (clobber (match_operand:SI 3 "register_operand" "=d"))]
3156   "!TARGET_64BIT && !TARGET_DEBUG_G_MODE
3157    && (INTVAL (operands[2]) & 63) < 32
3158    && (INTVAL (operands[2]) & 63) != 0"
3159   "*
3160 {
3161   int amount = INTVAL (operands[2]);
3162
3163   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
3164   operands[4] = const0_rtx;
3165   operands[5] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
3166
3167   return \"sll\\t%M0,%M1,%2\;srl\\t%3,%L1,%5\;or\\t%M0,%M0,%3\;sll\\t%L0,%L1,%2\";
3168 }"
3169   [(set_attr "type"     "darith")
3170    (set_attr "mode"     "DI")
3171    (set_attr "length"   "4")])
3172
3173
3174 (define_split
3175   [(set (match_operand:DI 0 "register_operand" "")
3176         (ashift:DI (match_operand:DI 1 "register_operand" "")
3177                    (match_operand:SI 2 "small_int" "")))
3178    (clobber (match_operand:SI 3 "register_operand" ""))]
3179   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
3180    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
3181    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
3182    && (INTVAL (operands[2]) & 63) < 32
3183    && (INTVAL (operands[2]) & 63) != 0"
3184
3185   [(set (subreg:SI (match_dup 0) 1)
3186         (ashift:SI (subreg:SI (match_dup 1) 1)
3187                    (match_dup 2)))
3188
3189    (set (match_dup 3)
3190         (lshiftrt:SI (subreg:SI (match_dup 1) 0)
3191                      (match_dup 4)))
3192
3193    (set (subreg:SI (match_dup 0) 1)
3194         (ior:SI (subreg:SI (match_dup 0) 1)
3195                 (match_dup 3)))
3196
3197    (set (subreg:SI (match_dup 0) 0)
3198         (ashift:SI (subreg:SI (match_dup 1) 0)
3199                    (match_dup 2)))]
3200   "
3201 {
3202   int amount = INTVAL (operands[2]);
3203   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
3204   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
3205 }")
3206
3207
3208 (define_split
3209   [(set (match_operand:DI 0 "register_operand" "")
3210         (ashift:DI (match_operand:DI 1 "register_operand" "")
3211                    (match_operand:SI 2 "small_int" "")))
3212    (clobber (match_operand:SI 3 "register_operand" ""))]
3213   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
3214    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
3215    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
3216    && (INTVAL (operands[2]) & 63) < 32
3217    && (INTVAL (operands[2]) & 63) != 0"
3218
3219   [(set (subreg:SI (match_dup 0) 0)
3220         (ashift:SI (subreg:SI (match_dup 1) 0)
3221                    (match_dup 2)))
3222
3223    (set (match_dup 3)
3224         (lshiftrt:SI (subreg:SI (match_dup 1) 1)
3225                      (match_dup 4)))
3226
3227    (set (subreg:SI (match_dup 0) 0)
3228         (ior:SI (subreg:SI (match_dup 0) 0)
3229                 (match_dup 3)))
3230
3231    (set (subreg:SI (match_dup 0) 1)
3232         (ashift:SI (subreg:SI (match_dup 1) 1)
3233                    (match_dup 2)))]
3234   "
3235 {
3236   int amount = INTVAL (operands[2]);
3237   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
3238   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
3239 }")
3240
3241
3242 (define_insn "ashldi3_internal4"
3243   [(set (match_operand:DI 0 "register_operand" "=d")
3244         (ashift:DI (match_operand:DI 1 "register_operand" "d")
3245                    (match_operand:SI 2 "arith_operand" "dI")))]
3246   "TARGET_64BIT"
3247   "*
3248 {
3249   if (GET_CODE (operands[2]) == CONST_INT)
3250     operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
3251
3252   return \"dsll\\t%0,%1,%2\";
3253 }"
3254   [(set_attr "type"     "arith")
3255    (set_attr "mode"     "DI")
3256    (set_attr "length"   "1")])
3257
3258
3259 (define_insn "ashrsi3"
3260   [(set (match_operand:SI 0 "register_operand" "=d")
3261         (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
3262                      (match_operand:SI 2 "arith_operand" "dI")))]
3263   ""
3264   "*
3265 {
3266   if (GET_CODE (operands[2]) == CONST_INT)
3267     operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);
3268
3269   return \"sra\\t%0,%1,%2\";
3270 }"
3271   [(set_attr "type"     "arith")
3272    (set_attr "mode"     "SI")
3273    (set_attr "length"   "1")])
3274
3275
3276 (define_expand "ashrdi3"
3277   [(parallel [(set (match_operand:DI 0 "register_operand" "")
3278                    (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
3279                                 (match_operand:SI 2 "arith_operand" "")))
3280               (clobber (match_dup  3))])]
3281   "TARGET_64BIT || !TARGET_DEBUG_G_MODE"
3282   "
3283 {
3284   if (TARGET_64BIT)
3285     {
3286       emit_insn (gen_ashrdi3_internal4 (operands[0], operands[1],
3287                                         operands[2]));
3288       DONE;
3289     }
3290
3291   operands[3] = gen_reg_rtx (SImode);
3292 }")
3293
3294
3295 (define_insn "ashrdi3_internal"
3296   [(set (match_operand:DI 0 "register_operand" "=&d")
3297         (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
3298                      (match_operand:SI 2 "register_operand" "d")))
3299    (clobber (match_operand:SI 3 "register_operand" "=d"))]
3300   "!TARGET_64BIT && !TARGET_DEBUG_G_MODE"
3301   "* 
3302 {
3303   operands[4] = const0_rtx;
3304   dslots_jump_total += 3;
3305   dslots_jump_filled += 2;
3306
3307   return \"sll\\t%3,%2,26\\n\\
3308 \\tbgez\\t%3,1f\\n\\
3309 \\tsra\\t%L0,%M1,%2\\n\\
3310 \\t%(b\\t3f\\n\\
3311 \\tsra\\t%M0,%M1,31%)\\n\\
3312 \\n\\
3313 1:\\n\\
3314 \\t%(beq\\t%3,%z4,2f\\n\\
3315 \\tsrl\\t%L0,%L1,%2%)\\n\\
3316 \\n\\
3317 \\tsubu\\t%3,%z4,%2\\n\\
3318 \\tsll\\t%3,%M1,%3\\n\\
3319 \\tor\\t%L0,%L0,%3\\n\\
3320 2:\\n\\
3321 \\tsra\\t%M0,%M1,%2\\n\\
3322 3:\";
3323 }"
3324   [(set_attr "type"     "darith")
3325    (set_attr "mode"     "DI")
3326    (set_attr "length"   "12")])
3327
3328
3329 (define_insn "ashrdi3_internal2"
3330   [(set (match_operand:DI 0 "register_operand" "=d")
3331         (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
3332                      (match_operand:SI 2 "small_int" "IJK")))
3333    (clobber (match_operand:SI 3 "register_operand" "=d"))]
3334   "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && (INTVAL (operands[2]) & 32) != 0"
3335   "*
3336 {
3337   operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);
3338   return \"sra\\t%L0,%M1,%2\;sra\\t%M0,%M1,31\";
3339 }"
3340   [(set_attr "type"     "darith")
3341    (set_attr "mode"     "DI")
3342    (set_attr "length"   "2")])
3343
3344
3345 (define_split
3346   [(set (match_operand:DI 0 "register_operand" "")
3347         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
3348                      (match_operand:SI 2 "small_int" "")))
3349    (clobber (match_operand:SI 3 "register_operand" ""))]
3350   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
3351    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
3352    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
3353    && (INTVAL (operands[2]) & 32) != 0"
3354
3355   [(set (subreg:SI (match_dup 0) 0) (ashiftrt:SI (subreg:SI (match_dup 1) 1) (match_dup 2)))
3356    (set (subreg:SI (match_dup 0) 1) (ashiftrt:SI (subreg:SI (match_dup 1) 1) (const_int 31)))]
3357
3358   "operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);")
3359
3360
3361 (define_split
3362   [(set (match_operand:DI 0 "register_operand" "")
3363         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
3364                      (match_operand:SI 2 "small_int" "")))
3365    (clobber (match_operand:SI 3 "register_operand" ""))]
3366   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
3367    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
3368    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
3369    && (INTVAL (operands[2]) & 32) != 0"
3370
3371   [(set (subreg:SI (match_dup 0) 1) (ashiftrt:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
3372    (set (subreg:SI (match_dup 0) 0) (ashiftrt:SI (subreg:SI (match_dup 1) 0) (const_int 31)))]
3373
3374   "operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);")
3375
3376
3377 (define_insn "ashrdi3_internal3"
3378   [(set (match_operand:DI 0 "register_operand" "=d")
3379         (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
3380                      (match_operand:SI 2 "small_int" "IJK")))
3381    (clobber (match_operand:SI 3 "register_operand" "=d"))]
3382   "!TARGET_64BIT && !TARGET_DEBUG_G_MODE
3383    && (INTVAL (operands[2]) & 63) < 32
3384    && (INTVAL (operands[2]) & 63) != 0"
3385   "*
3386 {
3387   int amount = INTVAL (operands[2]);
3388
3389   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
3390   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
3391
3392   return \"srl\\t%L0,%L1,%2\;sll\\t%3,%M1,%4\;or\\t%L0,%L0,%3\;sra\\t%M0,%M1,%2\";
3393 }"
3394   [(set_attr "type"     "darith")
3395    (set_attr "mode"     "DI")
3396    (set_attr "length"   "4")])
3397
3398
3399 (define_split
3400   [(set (match_operand:DI 0 "register_operand" "")
3401         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
3402                      (match_operand:SI 2 "small_int" "")))
3403    (clobber (match_operand:SI 3 "register_operand" ""))]
3404   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
3405    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
3406    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
3407    && (INTVAL (operands[2]) & 63) < 32
3408    && (INTVAL (operands[2]) & 63) != 0"
3409
3410   [(set (subreg:SI (match_dup 0) 0)
3411         (lshiftrt:SI (subreg:SI (match_dup 1) 0)
3412                      (match_dup 2)))
3413
3414    (set (match_dup 3)
3415         (ashift:SI (subreg:SI (match_dup 1) 1)
3416                    (match_dup 4)))
3417
3418    (set (subreg:SI (match_dup 0) 0)
3419         (ior:SI (subreg:SI (match_dup 0) 0)
3420                 (match_dup 3)))
3421
3422    (set (subreg:SI (match_dup 0) 1)
3423         (ashiftrt:SI (subreg:SI (match_dup 1) 1)
3424                      (match_dup 2)))]
3425   "
3426 {
3427   int amount = INTVAL (operands[2]);
3428   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
3429   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
3430 }")
3431
3432
3433 (define_split
3434   [(set (match_operand:DI 0 "register_operand" "")
3435         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
3436                      (match_operand:SI 2 "small_int" "")))
3437    (clobber (match_operand:SI 3 "register_operand" ""))]
3438   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
3439    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
3440    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
3441    && (INTVAL (operands[2]) & 63) < 32
3442    && (INTVAL (operands[2]) & 63) != 0"
3443
3444   [(set (subreg:SI (match_dup 0) 1)
3445         (lshiftrt:SI (subreg:SI (match_dup 1) 1)
3446                      (match_dup 2)))
3447
3448    (set (match_dup 3)
3449         (ashift:SI (subreg:SI (match_dup 1) 0)
3450                    (match_dup 4)))
3451
3452    (set (subreg:SI (match_dup 0) 1)
3453         (ior:SI (subreg:SI (match_dup 0) 1)
3454                 (match_dup 3)))
3455
3456    (set (subreg:SI (match_dup 0) 0)
3457         (ashiftrt:SI (subreg:SI (match_dup 1) 0)
3458                      (match_dup 2)))]
3459   "
3460 {
3461   int amount = INTVAL (operands[2]);
3462   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
3463   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
3464 }")
3465
3466
3467 (define_insn "ashrdi3_internal4"
3468   [(set (match_operand:DI 0 "register_operand" "=d")
3469         (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
3470                      (match_operand:SI 2 "arith_operand" "dI")))]
3471   "TARGET_64BIT"
3472   "*
3473 {
3474   if (GET_CODE (operands[2]) == CONST_INT)
3475     operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
3476
3477   return \"dsra\\t%0,%1,%2\";
3478 }"
3479   [(set_attr "type"     "arith")
3480    (set_attr "mode"     "DI")
3481    (set_attr "length"   "1")])
3482
3483
3484 (define_insn "lshrsi3"
3485   [(set (match_operand:SI 0 "register_operand" "=d")
3486         (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
3487                      (match_operand:SI 2 "arith_operand" "dI")))]
3488   ""
3489   "*
3490 {
3491   if (GET_CODE (operands[2]) == CONST_INT)
3492     operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);
3493
3494   return \"srl\\t%0,%1,%2\";
3495 }"
3496   [(set_attr "type"     "arith")
3497    (set_attr "mode"     "SI")
3498    (set_attr "length"   "1")])
3499
3500
3501 (define_expand "lshrdi3"
3502   [(parallel [(set (match_operand:DI 0 "register_operand" "")
3503                    (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
3504                                 (match_operand:SI 2 "arith_operand" "")))
3505               (clobber (match_dup  3))])]
3506   "TARGET_64BIT || !TARGET_DEBUG_G_MODE"
3507   "
3508 {
3509   if (TARGET_64BIT)
3510     {
3511       emit_insn (gen_lshrdi3_internal4 (operands[0], operands[1],
3512                                         operands[2]));
3513       DONE;
3514     }
3515
3516   operands[3] = gen_reg_rtx (SImode);
3517 }")
3518
3519
3520 (define_insn "lshrdi3_internal"
3521   [(set (match_operand:DI 0 "register_operand" "=&d")
3522         (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
3523                      (match_operand:SI 2 "register_operand" "d")))
3524    (clobber (match_operand:SI 3 "register_operand" "=d"))]
3525   "!TARGET_64BIT && !TARGET_DEBUG_G_MODE"
3526   "* 
3527 {
3528   operands[4] = const0_rtx;
3529   dslots_jump_total += 3;
3530   dslots_jump_filled += 2;
3531
3532   return \"sll\\t%3,%2,26\\n\\
3533 \\tbgez\\t%3,1f\\n\\
3534 \\tsrl\\t%L0,%M1,%2\\n\\
3535 \\t%(b\\t3f\\n\\
3536 \\tmove\\t%M0,%z4%)\\n\\
3537 \\n\\
3538 1:\\n\\
3539 \\t%(beq\\t%3,%z4,2f\\n\\
3540 \\tsrl\\t%L0,%L1,%2%)\\n\\
3541 \\n\\
3542 \\tsubu\\t%3,%z4,%2\\n\\
3543 \\tsll\\t%3,%M1,%3\\n\\
3544 \\tor\\t%L0,%L0,%3\\n\\
3545 2:\\n\\
3546 \\tsrl\\t%M0,%M1,%2\\n\\
3547 3:\";
3548 }"
3549   [(set_attr "type"     "darith")
3550    (set_attr "mode"     "DI")
3551    (set_attr "length"   "12")])
3552
3553
3554 (define_insn "lshrdi3_internal2"
3555   [(set (match_operand:DI 0 "register_operand" "=d")
3556         (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
3557                      (match_operand:SI 2 "small_int" "IJK")))
3558    (clobber (match_operand:SI 3 "register_operand" "=d"))]
3559   "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && (INTVAL (operands[2]) & 32) != 0"
3560   "*
3561 {
3562   operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);
3563   operands[4] = const0_rtx;
3564   return \"srl\\t%L0,%M1,%2\;move\\t%M0,%z4\";
3565 }"
3566   [(set_attr "type"     "darith")
3567    (set_attr "mode"     "DI")
3568    (set_attr "length"   "2")])
3569
3570
3571 (define_split
3572   [(set (match_operand:DI 0 "register_operand" "")
3573         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
3574                      (match_operand:SI 2 "small_int" "")))
3575    (clobber (match_operand:SI 3 "register_operand" ""))]
3576   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
3577    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
3578    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
3579    && (INTVAL (operands[2]) & 32) != 0"
3580
3581   [(set (subreg:SI (match_dup 0) 0) (lshiftrt:SI (subreg:SI (match_dup 1) 1) (match_dup 2)))
3582    (set (subreg:SI (match_dup 0) 1) (const_int 0))]
3583
3584   "operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);")
3585
3586
3587 (define_split
3588   [(set (match_operand:DI 0 "register_operand" "")
3589         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
3590                      (match_operand:SI 2 "small_int" "")))
3591    (clobber (match_operand:SI 3 "register_operand" ""))]
3592   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
3593    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
3594    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
3595    && (INTVAL (operands[2]) & 32) != 0"
3596
3597   [(set (subreg:SI (match_dup 0) 1) (lshiftrt:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
3598    (set (subreg:SI (match_dup 0) 0) (const_int 0))]
3599
3600   "operands[2] = gen_rtx (CONST_INT, VOIDmode, (XINT (operands[2], 0))& 0x1f);")
3601
3602
3603 (define_insn "lshrdi3_internal3"
3604   [(set (match_operand:DI 0 "register_operand" "=d")
3605         (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
3606                    (match_operand:SI 2 "small_int" "IJK")))
3607    (clobber (match_operand:SI 3 "register_operand" "=d"))]
3608   "!TARGET_64BIT && !TARGET_DEBUG_G_MODE
3609    && (INTVAL (operands[2]) & 63) < 32
3610    && (INTVAL (operands[2]) & 63) != 0"
3611   "*
3612 {
3613   int amount = INTVAL (operands[2]);
3614
3615   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
3616   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
3617
3618   return \"srl\\t%L0,%L1,%2\;sll\\t%3,%M1,%4\;or\\t%L0,%L0,%3\;srl\\t%M0,%M1,%2\";
3619 }"
3620   [(set_attr "type"     "darith")
3621    (set_attr "mode"     "DI")
3622    (set_attr "length"   "4")])
3623
3624
3625 (define_split
3626   [(set (match_operand:DI 0 "register_operand" "")
3627         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
3628                      (match_operand:SI 2 "small_int" "")))
3629    (clobber (match_operand:SI 3 "register_operand" ""))]
3630   "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
3631    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
3632    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
3633    && (INTVAL (operands[2]) & 63) < 32
3634    && (INTVAL (operands[2]) & 63) != 0"
3635
3636   [(set (subreg:SI (match_dup 0) 0)
3637         (lshiftrt:SI (subreg:SI (match_dup 1) 0)
3638                      (match_dup 2)))
3639
3640    (set (match_dup 3)
3641         (ashift:SI (subreg:SI (match_dup 1) 1)
3642                    (match_dup 4)))
3643
3644    (set (subreg:SI (match_dup 0) 0)
3645         (ior:SI (subreg:SI (match_dup 0) 0)
3646                 (match_dup 3)))
3647
3648    (set (subreg:SI (match_dup 0) 1)
3649         (lshiftrt:SI (subreg:SI (match_dup 1) 1)
3650                      (match_dup 2)))]
3651   "
3652 {
3653   int amount = INTVAL (operands[2]);
3654   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
3655   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
3656 }")
3657
3658
3659 (define_split
3660   [(set (match_operand:DI 0 "register_operand" "")
3661         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
3662                      (match_operand:SI 2 "small_int" "")))
3663    (clobber (match_operand:SI 3 "register_operand" ""))]
3664   "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
3665    && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
3666    && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
3667    && (INTVAL (operands[2]) & 63) < 32
3668    && (INTVAL (operands[2]) & 63) != 0"
3669
3670   [(set (subreg:SI (match_dup 0) 1)
3671         (lshiftrt:SI (subreg:SI (match_dup 1) 1)
3672                      (match_dup 2)))
3673
3674    (set (match_dup 3)
3675         (ashift:SI (subreg:SI (match_dup 1) 0)
3676                    (match_dup 4)))
3677
3678    (set (subreg:SI (match_dup 0) 1)
3679         (ior:SI (subreg:SI (match_dup 0) 1)
3680                 (match_dup 3)))
3681
3682    (set (subreg:SI (match_dup 0) 0)
3683         (lshiftrt:SI (subreg:SI (match_dup 1) 0)
3684                      (match_dup 2)))]
3685   "
3686 {
3687   int amount = INTVAL (operands[2]);
3688   operands[2] = gen_rtx (CONST_INT, VOIDmode, (amount & 31));
3689   operands[4] = gen_rtx (CONST_INT, VOIDmode, ((-amount) & 31));
3690 }")
3691
3692
3693 (define_insn "lshrdi3_internal4"
3694   [(set (match_operand:DI 0 "register_operand" "=d")
3695         (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
3696                      (match_operand:SI 2 "arith_operand" "dI")))]
3697   "TARGET_64BIT"
3698   "*
3699 {
3700   if (GET_CODE (operands[2]) == CONST_INT)
3701     operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
3702
3703   return \"dsrl\\t%0,%1,%2\";
3704 }"
3705   [(set_attr "type"     "arith")
3706    (set_attr "mode"     "DI")
3707    (set_attr "length"   "1")])
3708
3709 \f
3710 ;;
3711 ;;  ....................
3712 ;;
3713 ;;      COMPARISONS
3714 ;;
3715 ;;  ....................
3716
3717 ;; Flow here is rather complex:
3718 ;;
3719 ;;  1)  The cmp{si,di,sf,df} routine is called.  It deposits the
3720 ;;      arguments into the branch_cmp array, and the type into
3721 ;;      branch_type.  No RTL is generated.
3722 ;;
3723 ;;  2)  The appropriate branch define_expand is called, which then
3724 ;;      creates the appropriate RTL for the comparison and branch.
3725 ;;      Different CC modes are used, based on what type of branch is
3726 ;;      done, so that we can constrain things appropriately.  There
3727 ;;      are assumptions in the rest of GCC that break if we fold the
3728 ;;      operands into the branchs for integer operations, and use cc0
3729 ;;      for floating point, so we use the fp status register instead.
3730 ;;      If needed, an appropriate temporary is created to hold the
3731 ;;      of the integer compare.
3732
3733 (define_expand "cmpsi"
3734   [(set (cc0)
3735         (compare:CC (match_operand:SI 0 "register_operand" "")
3736                     (match_operand:SI 1 "arith_operand" "")))]
3737   ""
3738   "
3739 {
3740   if (operands[0])              /* avoid unused code message */
3741     {
3742       branch_cmp[0] = operands[0];
3743       branch_cmp[1] = operands[1];
3744       branch_type = CMP_SI;
3745       DONE;
3746     }
3747 }")
3748
3749 (define_expand "tstsi"
3750   [(set (cc0)
3751         (match_operand:SI 0 "register_operand" ""))]
3752   ""
3753   "
3754 {
3755   if (operands[0])              /* avoid unused code message */
3756     {
3757       branch_cmp[0] = operands[0];
3758       branch_cmp[1] = const0_rtx;
3759       branch_type = CMP_SI;
3760       DONE;
3761     }
3762 }")
3763
3764 (define_expand "cmpdi"
3765   [(set (cc0)
3766         (compare:CC (match_operand:DI 0 "register_operand" "")
3767                     (match_operand:DI 1 "arith_operand" "")))]
3768   "TARGET_64BIT"
3769   "
3770 {
3771   if (operands[0])              /* avoid unused code message */
3772     {
3773       branch_cmp[0] = operands[0];
3774       branch_cmp[1] = operands[1];
3775       branch_type = CMP_DI;
3776       DONE;
3777     }
3778 }")
3779
3780 (define_expand "tstdi"
3781   [(set (cc0)
3782         (match_operand:DI 0 "register_operand" ""))]
3783   "TARGET_64BIT"
3784   "
3785 {
3786   if (operands[0])              /* avoid unused code message */
3787     {
3788       branch_cmp[0] = operands[0];
3789       branch_cmp[1] = const0_rtx;
3790       branch_type = CMP_DI;
3791       DONE;
3792     }
3793 }")
3794
3795 (define_expand "cmpdf"
3796   [(set (cc0)
3797         (compare:CC_FP (match_operand:DF 0 "register_operand" "")
3798                        (match_operand:DF 1 "register_operand" "")))]
3799   "TARGET_HARD_FLOAT"
3800   "
3801 {
3802   if (operands[0])              /* avoid unused code message */
3803     {
3804       branch_cmp[0] = operands[0];
3805       branch_cmp[1] = operands[1];
3806       branch_type = CMP_DF;
3807       DONE;
3808     }
3809 }")
3810
3811 (define_expand "cmpsf"
3812   [(set (cc0)
3813         (compare:CC_FP (match_operand:SF 0 "register_operand" "")
3814                        (match_operand:SF 1 "register_operand" "")))]
3815   "TARGET_HARD_FLOAT"
3816   "
3817 {
3818   if (operands[0])              /* avoid unused code message */
3819     {
3820       branch_cmp[0] = operands[0];
3821       branch_cmp[1] = operands[1];
3822       branch_type = CMP_SF;
3823       DONE;
3824     }
3825 }")
3826
3827 \f
3828 ;;
3829 ;;  ....................
3830 ;;
3831 ;;      CONDITIONAL BRANCHES
3832 ;;
3833 ;;  ....................
3834
3835 (define_insn "branch_fp_ne"
3836   [(set (pc)
3837         (if_then_else (ne:CC_FP (reg:CC_FP 66)
3838                                 (const_int 0))
3839                       (match_operand 0 "pc_or_label_operand" "")
3840                       (match_operand 1 "pc_or_label_operand" "")))]
3841   "TARGET_HARD_FLOAT"
3842   "*
3843 {
3844   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
3845   return (operands[0] != pc_rtx) ? \"%*bc1t%?\\t%0\" : \"%*bc1f%?\\t%1\";
3846 }"
3847   [(set_attr "type"     "branch")
3848    (set_attr "mode"     "none")
3849    (set_attr "length"   "1")])
3850
3851 (define_insn "branch_fp_ne_rev"
3852   [(set (pc)
3853         (if_then_else (ne:CC_REV_FP (reg:CC_REV_FP 66)
3854                                     (const_int 0))
3855                       (match_operand 0 "pc_or_label_operand" "")
3856                       (match_operand 1 "pc_or_label_operand" "")))]
3857   "TARGET_HARD_FLOAT"
3858   "*
3859 {
3860   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
3861   return (operands[0] != pc_rtx) ? \"%*bc1f%?\\t%0\" : \"%*bc1t%?\\t%1\";
3862 }"
3863   [(set_attr "type"     "branch")
3864    (set_attr "mode"     "none")
3865    (set_attr "length"   "1")])
3866
3867 (define_insn "branch_fp_eq"
3868   [(set (pc)
3869         (if_then_else (eq:CC_FP (reg:CC_FP 66)
3870                                 (const_int 0))
3871                       (match_operand 0 "pc_or_label_operand" "")
3872                       (match_operand 1 "pc_or_label_operand" "")))]
3873   "TARGET_HARD_FLOAT"
3874   "*
3875 {
3876   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
3877   return (operands[0] != pc_rtx) ? \"%*bc1f%?\\t%0\" : \"%*bc1t%?\\t%1\";
3878 }"
3879   [(set_attr "type"     "branch")
3880    (set_attr "mode"     "none")
3881    (set_attr "length"   "1")])
3882
3883 (define_insn "branch_fp_eq_rev"
3884   [(set (pc)
3885         (if_then_else (eq:CC_REV_FP (reg:CC_REV_FP 66)
3886                                     (const_int 0))
3887                       (match_operand 0 "pc_or_label_operand" "")
3888                       (match_operand 1 "pc_or_label_operand" "")))]
3889   "TARGET_HARD_FLOAT"
3890   "*
3891 {
3892   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
3893   return (operands[0] != pc_rtx) ? \"%*bc1t%?\\t%0\" : \"%*bc1f%?\\t%1\";
3894 }"
3895   [(set_attr "type"     "branch")
3896    (set_attr "mode"     "none")
3897    (set_attr "length"   "1")])
3898
3899
3900 (define_insn "branch_zero"
3901   [(set (pc)
3902         (if_then_else (match_operator:SI 0 "cmp_op"
3903                                          [(match_operand:SI 1 "register_operand" "d")
3904                                           (const_int 0)])
3905         (match_operand 2 "pc_or_label_operand" "")
3906         (match_operand 3 "pc_or_label_operand" "")))]
3907   ""
3908   "*
3909 {
3910   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
3911   if (operands[2] != pc_rtx)
3912     {                           /* normal jump */
3913       switch (GET_CODE (operands[0]))
3914         {
3915         case EQ:  return \"%*beq%?\\t%z1,%.,%2\";
3916         case NE:  return \"%*bne%?\\t%z1,%.,%2\";
3917         case GTU: return \"%*bne%?\\t%z1,%.,%2\";
3918         case LEU: return \"%*beq%?\\t%z1,%.,%2\";
3919         case GEU: return \"%*j\\t%2\";
3920         case LTU: return \"%*bne%?\\t%.,%.,%2\";
3921         }
3922
3923       return \"%*b%C0z%?\\t%z1,%2\";
3924     }
3925   else
3926     {                           /* inverted jump */
3927       switch (GET_CODE (operands[0]))
3928         {
3929         case EQ:  return \"%*bne%?\\t%z1,%.,%3\";
3930         case NE:  return \"%*beq%?\\t%z1,%.,%3\";
3931         case GTU: return \"%*beq%?\\t%z1,%.,%3\";
3932         case LEU: return \"%*bne%?\\t%z1,%.,%3\";
3933         case GEU: return \"%*beq%?\\t%.,%.,%3\";
3934         case LTU: return \"%*j\\t%3\";
3935         }
3936
3937       return \"%*b%N0z%?\\t%z1,%3\";
3938     }
3939 }"
3940   [(set_attr "type"     "branch")
3941    (set_attr "mode"     "none")
3942    (set_attr "length"   "1")])
3943
3944
3945 (define_insn "branch_zero_di"
3946   [(set (pc)
3947         (if_then_else (match_operator:DI 0 "cmp_op"
3948                                          [(match_operand:DI 1 "register_operand" "d")
3949                                           (const_int 0)])
3950         (match_operand 2 "pc_or_label_operand" "")
3951         (match_operand 3 "pc_or_label_operand" "")))]
3952   ""
3953   "*
3954 {
3955   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
3956   if (operands[2] != pc_rtx)
3957     {                           /* normal jump */
3958       switch (GET_CODE (operands[0]))
3959         {
3960         case EQ:  return \"%*beq%?\\t%z1,%.,%2\";
3961         case NE:  return \"%*bne%?\\t%z1,%.,%2\";
3962         case GTU: return \"%*bne%?\\t%z1,%.,%2\";
3963         case LEU: return \"%*beq%?\\t%z1,%.,%2\";
3964         case GEU: return \"%*j\\t%2\";
3965         case LTU: return \"%*bne%?\\t%.,%.,%2\";
3966         }
3967
3968       return \"%*b%C0z%?\\t%z1,%2\";
3969     }
3970   else
3971     {                           /* inverted jump */
3972       switch (GET_CODE (operands[0]))
3973         {
3974         case EQ:  return \"%*bne%?\\t%z1,%.,%3\";
3975         case NE:  return \"%*beq%?\\t%z1,%.,%3\";
3976         case GTU: return \"%*beq%?\\t%z1,%.,%3\";
3977         case LEU: return \"%*bne%?\\t%z1,%.,%3\";
3978         case GEU: return \"%*beq%?\\t%.,%.,%3\";
3979         case LTU: return \"%*j\\t%3\";
3980         }
3981
3982       return \"%*b%N0z%?\\t%z1,%3\";
3983     }
3984 }"
3985   [(set_attr "type"     "branch")
3986    (set_attr "mode"     "none")
3987    (set_attr "length"   "1")])
3988
3989
3990 (define_insn "branch_equality"
3991   [(set (pc)
3992         (if_then_else (match_operator:SI 0 "equality_op"
3993                                          [(match_operand:SI 1 "register_operand" "d")
3994                                           (match_operand:SI 2 "register_operand" "d")])
3995         (match_operand 3 "pc_or_label_operand" "")
3996         (match_operand 4 "pc_or_label_operand" "")))]
3997   ""
3998   "*
3999 {
4000   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
4001   return (operands[3] != pc_rtx)
4002         ? \"%*b%C0%?\\t%z1,%z2,%3\"
4003         : \"%*b%N0%?\\t%z1,%z2,%4\";
4004 }"
4005   [(set_attr "type"     "branch")
4006    (set_attr "mode"     "none")
4007    (set_attr "length"   "1")])
4008
4009
4010 (define_insn "branch_equality_di"
4011   [(set (pc)
4012         (if_then_else (match_operator:DI 0 "equality_op"
4013                                          [(match_operand:DI 1 "register_operand" "d")
4014                                           (match_operand:DI 2 "register_operand" "d")])
4015         (match_operand 3 "pc_or_label_operand" "")
4016         (match_operand 4 "pc_or_label_operand" "")))]
4017   ""
4018   "*
4019 {
4020   mips_branch_likely = (final_sequence && INSN_ANNULLED_BRANCH_P (insn));
4021   return (operands[3] != pc_rtx)
4022         ? \"%*b%C0%?\\t%z1,%z2,%3\"
4023         : \"%*b%N0%?\\t%z1,%z2,%4\";
4024 }"
4025   [(set_attr "type"     "branch")
4026    (set_attr "mode"     "none")
4027    (set_attr "length"   "1")])
4028
4029
4030 (define_expand "beq"
4031   [(set (pc)
4032         (if_then_else (eq:CC_EQ (cc0)
4033                                 (const_int 0))
4034                       (label_ref (match_operand 0 "" ""))
4035                       (pc)))]
4036   ""
4037   "
4038 {
4039   if (operands[0])              /* avoid unused code warning */
4040     {
4041       gen_conditional_branch (operands, EQ);
4042       DONE;
4043     }
4044 }")
4045
4046 (define_expand "bne"
4047   [(set (pc)
4048         (if_then_else (ne:CC_EQ (cc0)
4049                                 (const_int 0))
4050                       (label_ref (match_operand 0 "" ""))
4051                       (pc)))]
4052   ""
4053   "
4054 {
4055   if (operands[0])              /* avoid unused code warning */
4056     {
4057       gen_conditional_branch (operands, NE);
4058       DONE;
4059     }
4060 }")
4061
4062 (define_expand "bgt"
4063   [(set (pc)
4064         (if_then_else (gt:CC (cc0)
4065                              (const_int 0))
4066                       (label_ref (match_operand 0 "" ""))
4067                       (pc)))]
4068   ""
4069   "
4070 {
4071   if (operands[0])              /* avoid unused code warning */
4072     {
4073       gen_conditional_branch (operands, GT);
4074       DONE;
4075     }
4076 }")
4077
4078 (define_expand "bge"
4079   [(set (pc)
4080         (if_then_else (ge:CC (cc0)
4081                              (const_int 0))
4082                       (label_ref (match_operand 0 "" ""))
4083                       (pc)))]
4084   ""
4085   "
4086 {
4087   if (operands[0])              /* avoid unused code warning */
4088     {
4089       gen_conditional_branch (operands, GE);
4090       DONE;
4091     }
4092 }")
4093
4094 (define_expand "blt"
4095   [(set (pc)
4096         (if_then_else (lt:CC (cc0)
4097                              (const_int 0))
4098                       (label_ref (match_operand 0 "" ""))
4099                       (pc)))]
4100   ""
4101   "
4102 {
4103   if (operands[0])              /* avoid unused code warning */
4104     {
4105       gen_conditional_branch (operands, LT);
4106       DONE;
4107     }
4108 }")
4109
4110 (define_expand "ble"
4111   [(set (pc)
4112         (if_then_else (le:CC (cc0)
4113                              (const_int 0))
4114                       (label_ref (match_operand 0 "" ""))
4115                       (pc)))]
4116   ""
4117   "
4118 {
4119   if (operands[0])              /* avoid unused code warning */
4120     {
4121       gen_conditional_branch (operands, LE);
4122       DONE;
4123     }
4124 }")
4125
4126 (define_expand "bgtu"
4127   [(set (pc)
4128         (if_then_else (gtu:CC (cc0)
4129                               (const_int 0))
4130                       (label_ref (match_operand 0 "" ""))
4131                       (pc)))]
4132   ""
4133   "
4134 {
4135   if (operands[0])              /* avoid unused code warning */
4136     {
4137       gen_conditional_branch (operands, GTU);
4138       DONE;
4139     }
4140 }")
4141
4142 (define_expand "bgeu"
4143   [(set (pc)
4144         (if_then_else (geu:CC (cc0)
4145                               (const_int 0))
4146                       (label_ref (match_operand 0 "" ""))
4147                       (pc)))]
4148   ""
4149   "
4150 {
4151   if (operands[0])              /* avoid unused code warning */
4152     {
4153       gen_conditional_branch (operands, GEU);
4154       DONE;
4155     }
4156 }")
4157
4158
4159 (define_expand "bltu"
4160   [(set (pc)
4161         (if_then_else (ltu:CC (cc0)
4162                               (const_int 0))
4163                       (label_ref (match_operand 0 "" ""))
4164                       (pc)))]
4165   ""
4166   "
4167 {
4168   if (operands[0])              /* avoid unused code warning */
4169     {
4170       gen_conditional_branch (operands, LTU);
4171       DONE;
4172     }
4173 }")
4174
4175 (define_expand "bleu"
4176   [(set (pc)
4177         (if_then_else (leu:CC (cc0)
4178                               (const_int 0))
4179                       (label_ref (match_operand 0 "" ""))
4180                       (pc)))]
4181   ""
4182   "
4183 {
4184   if (operands[0])              /* avoid unused code warning */
4185     {
4186       gen_conditional_branch (operands, LEU);
4187       DONE;
4188     }
4189 }")
4190
4191 \f
4192 ;;
4193 ;;  ....................
4194 ;;
4195 ;;      SETTING A REGISTER FROM A COMPARISON
4196 ;;
4197 ;;  ....................
4198
4199 (define_expand "seq"
4200   [(set (match_operand:SI 0 "register_operand" "=d")
4201         (eq:SI (match_dup 1)
4202                (match_dup 2)))]
4203   ""
4204   "
4205 {
4206   if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
4207     FAIL;
4208
4209   /* set up operands from compare.  */
4210   operands[1] = branch_cmp[0];
4211   operands[2] = branch_cmp[1];
4212
4213   if (TARGET_64BIT || !TARGET_DEBUG_C_MODE)
4214     {
4215       gen_int_relational (EQ, operands[0], operands[1], operands[2], (int *)0);
4216       DONE;
4217     }
4218
4219   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
4220     operands[2] = force_reg (SImode, operands[2]);
4221
4222   /* fall through and generate default code */
4223 }")
4224
4225
4226 (define_insn "seq_si_zero"
4227   [(set (match_operand:SI 0 "register_operand" "=d")
4228         (eq:SI (match_operand:SI 1 "register_operand" "d")
4229                (const_int 0)))]
4230   ""
4231   "sltu\\t%0,%1,1"
4232   [(set_attr "type"     "arith")
4233    (set_attr "mode"     "SI")
4234    (set_attr "length"   "1")])
4235
4236 (define_insn "seq_di_zero"
4237   [(set (match_operand:DI 0 "register_operand" "=d")
4238         (eq:DI (match_operand:DI 1 "register_operand" "d")
4239                (const_int 0)))]
4240   "TARGET_64BIT"
4241   "sltu\\t%0,%1,1"
4242   [(set_attr "type"     "arith")
4243    (set_attr "mode"     "DI")
4244    (set_attr "length"   "1")])
4245
4246 (define_insn "seq_si"
4247   [(set (match_operand:SI 0 "register_operand" "=d,d")
4248         (eq:SI (match_operand:SI 1 "register_operand" "%d,d")
4249                (match_operand:SI 2 "uns_arith_operand" "d,K")))]
4250   "TARGET_DEBUG_C_MODE"
4251   "@
4252    xor\\t%0,%1,%2\;sltu\\t%0,%0,1
4253    xori\\t%0,%1,%2\;sltu\\t%0,%0,1"
4254   [(set_attr "type"     "arith")
4255    (set_attr "mode"     "SI")
4256    (set_attr "length"   "2")])
4257
4258 (define_split
4259   [(set (match_operand:SI 0 "register_operand" "")
4260         (eq:SI (match_operand:SI 1 "register_operand" "")
4261                (match_operand:SI 2 "uns_arith_operand" "")))]
4262   "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
4263     && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
4264   [(set (match_dup 0)
4265         (xor:SI (match_dup 1)
4266                 (match_dup 2)))
4267    (set (match_dup 0)
4268         (ltu:SI (match_dup 0)
4269                 (const_int 1)))]
4270   "")
4271
4272 (define_insn "seq_di"
4273   [(set (match_operand:DI 0 "register_operand" "=d,d")
4274         (eq:DI (match_operand:DI 1 "register_operand" "%d,d")
4275                (match_operand:DI 2 "uns_arith_operand" "d,K")))]
4276   "TARGET_64BIT && TARGET_DEBUG_C_MODE"
4277   "@
4278    xor\\t%0,%1,%2\;sltu\\t%0,%0,1
4279    xori\\t%0,%1,%2\;sltu\\t%0,%0,1"
4280   [(set_attr "type"     "arith")
4281    (set_attr "mode"     "DI")
4282    (set_attr "length"   "2")])
4283
4284 (define_split
4285   [(set (match_operand:DI 0 "register_operand" "")
4286         (eq:DI (match_operand:DI 1 "register_operand" "")
4287                (match_operand:DI 2 "uns_arith_operand" "")))]
4288   "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
4289     && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
4290   [(set (match_dup 0)
4291         (xor:DI (match_dup 1)
4292                 (match_dup 2)))
4293    (set (match_dup 0)
4294         (ltu:DI (match_dup 0)
4295                 (const_int 1)))]
4296   "")
4297
4298 (define_expand "sne"
4299   [(set (match_operand:SI 0 "register_operand" "=d")
4300         (ne:SI (match_dup 1)
4301                (match_dup 2)))]
4302   ""
4303   "
4304 {
4305   if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
4306     FAIL;
4307
4308   /* set up operands from compare.  */
4309   operands[1] = branch_cmp[0];
4310   operands[2] = branch_cmp[1];
4311
4312   if (TARGET_64BIT || !TARGET_DEBUG_C_MODE)
4313     {
4314       gen_int_relational (NE, operands[0], operands[1], operands[2], (int *)0);
4315       DONE;
4316     }
4317
4318   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
4319     operands[2] = force_reg (SImode, operands[2]);
4320
4321   /* fall through and generate default code */
4322 }")
4323
4324 (define_insn "sne_si_zero"
4325   [(set (match_operand:SI 0 "register_operand" "=d")
4326         (ne:SI (match_operand:SI 1 "register_operand" "d")
4327                (const_int 0)))]
4328   ""
4329   "sltu\\t%0,%.,%1"
4330   [(set_attr "type"     "arith")
4331    (set_attr "mode"     "SI")
4332    (set_attr "length"   "1")])
4333
4334 (define_insn "sne_di_zero"
4335   [(set (match_operand:DI 0 "register_operand" "=d")
4336         (ne:DI (match_operand:DI 1 "register_operand" "d")
4337                (const_int 0)))]
4338   "TARGET_64BIT"
4339   "sltu\\t%0,%.,%1"
4340   [(set_attr "type"     "arith")
4341    (set_attr "mode"     "DI")
4342    (set_attr "length"   "1")])
4343
4344 (define_insn "sne_si"
4345   [(set (match_operand:SI 0 "register_operand" "=d,d")
4346         (ne:SI (match_operand:SI 1 "register_operand" "%d,d")
4347                (match_operand:SI 2 "uns_arith_operand" "d,K")))]
4348   "TARGET_DEBUG_C_MODE"
4349   "@
4350     xor\\t%0,%1,%2\;sltu\\t%0,%.,%0
4351     xori\\t%0,%1,%x2\;sltu\\t%0,%.,%0"
4352   [(set_attr "type"     "arith")
4353    (set_attr "mode"     "SI")
4354    (set_attr "length"   "2")])
4355
4356 (define_split
4357   [(set (match_operand:SI 0 "register_operand" "")
4358         (ne:SI (match_operand:SI 1 "register_operand" "")
4359                (match_operand:SI 2 "uns_arith_operand" "")))]
4360   "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
4361     && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
4362   [(set (match_dup 0)
4363         (xor:SI (match_dup 1)
4364                 (match_dup 2)))
4365    (set (match_dup 0)
4366         (gtu:SI (match_dup 0)
4367                 (const_int 0)))]
4368   "")
4369
4370 (define_insn "sne_di"
4371   [(set (match_operand:DI 0 "register_operand" "=d,d")
4372         (ne:DI (match_operand:DI 1 "register_operand" "%d,d")
4373                (match_operand:DI 2 "uns_arith_operand" "d,K")))]
4374   "TARGET_64BIT && TARGET_DEBUG_C_MODE"
4375   "@
4376     xor\\t%0,%1,%2\;sltu\\t%0,%.,%0
4377     xori\\t%0,%1,%x2\;sltu\\t%0,%.,%0"
4378   [(set_attr "type"     "arith")
4379    (set_attr "mode"     "DI")
4380    (set_attr "length"   "2")])
4381
4382 (define_split
4383   [(set (match_operand:DI 0 "register_operand" "")
4384         (ne:DI (match_operand:DI 1 "register_operand" "")
4385                (match_operand:DI 2 "uns_arith_operand" "")))]
4386   "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
4387     && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
4388   [(set (match_dup 0)
4389         (xor:DI (match_dup 1)
4390                 (match_dup 2)))
4391    (set (match_dup 0)
4392         (gtu:DI (match_dup 0)
4393                 (const_int 0)))]
4394   "")
4395
4396 (define_expand "sgt"
4397   [(set (match_operand:SI 0 "register_operand" "=d")
4398         (gt:SI (match_dup 1)
4399                (match_dup 2)))]
4400   ""
4401   "
4402 {
4403   if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
4404     FAIL;
4405
4406   /* set up operands from compare.  */
4407   operands[1] = branch_cmp[0];
4408   operands[2] = branch_cmp[1];
4409
4410   if (TARGET_64BIT || !TARGET_DEBUG_C_MODE)
4411     {
4412       gen_int_relational (GT, operands[0], operands[1], operands[2], (int *)0);
4413       DONE;
4414     }
4415
4416   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) != 0)
4417     operands[2] = force_reg (SImode, operands[2]);
4418
4419   /* fall through and generate default code */
4420 }")
4421
4422 (define_insn "sgt_si"
4423   [(set (match_operand:SI 0 "register_operand" "=d")
4424         (gt:SI (match_operand:SI 1 "register_operand" "d")
4425                (match_operand:SI 2 "reg_or_0_operand" "dJ")))]
4426   ""
4427   "slt\\t%0,%z2,%1"
4428   [(set_attr "type"     "arith")
4429    (set_attr "mode"     "SI")
4430    (set_attr "length"   "1")])
4431
4432 (define_insn "sgt_di"
4433   [(set (match_operand:DI 0 "register_operand" "=d")
4434         (gt:DI (match_operand:DI 1 "register_operand" "d")
4435                (match_operand:DI 2 "reg_or_0_operand" "dJ")))]
4436   "TARGET_64BIT"
4437   "slt\\t%0,%z2,%1"
4438   [(set_attr "type"     "arith")
4439    (set_attr "mode"     "DI")
4440    (set_attr "length"   "1")])
4441
4442 (define_expand "sge"
4443   [(set (match_operand:SI 0 "register_operand" "=d")
4444         (ge:SI (match_dup 1)
4445                (match_dup 2)))]
4446   ""
4447   "
4448 {
4449   if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
4450     FAIL;
4451
4452   /* set up operands from compare.  */
4453   operands[1] = branch_cmp[0];
4454   operands[2] = branch_cmp[1];
4455
4456   if (TARGET_64BIT || !TARGET_DEBUG_C_MODE)
4457     {
4458       gen_int_relational (GE, operands[0], operands[1], operands[2], (int *)0);
4459       DONE;
4460     }
4461
4462   /* fall through and generate default code */
4463 }")
4464
4465 (define_insn "sge_si"
4466   [(set (match_operand:SI 0 "register_operand" "=d")
4467         (ge:SI (match_operand:SI 1 "register_operand" "d")
4468                (match_operand:SI 2 "arith_operand" "dI")))]
4469   "TARGET_DEBUG_C_MODE"
4470   "slt\\t%0,%1,%2\;xori\\t%0,%0,0x0001"
4471   [(set_attr "type"     "arith")
4472    (set_attr "mode"     "SI")
4473    (set_attr "length"   "2")])
4474
4475 (define_split
4476   [(set (match_operand:SI 0 "register_operand" "")
4477         (ge:SI (match_operand:SI 1 "register_operand" "")
4478                (match_operand:SI 2 "arith_operand" "")))]
4479   "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE"
4480   [(set (match_dup 0)
4481         (lt:SI (match_dup 1)
4482                (match_dup 2)))
4483    (set (match_dup 0)
4484         (xor:SI (match_dup 0)
4485                 (const_int 1)))]
4486   "")
4487
4488 (define_insn "sge_di"
4489   [(set (match_operand:DI 0 "register_operand" "=d")
4490         (ge:DI (match_operand:DI 1 "register_operand" "d")
4491                (match_operand:DI 2 "arith_operand" "dI")))]
4492   "TARGET_64BIT && TARGET_DEBUG_C_MODE"
4493   "slt\\t%0,%1,%2\;xori\\t%0,%0,0x0001"
4494   [(set_attr "type"     "arith")
4495    (set_attr "mode"     "DI")
4496    (set_attr "length"   "2")])
4497
4498 (define_split
4499   [(set (match_operand:DI 0 "register_operand" "")
4500         (ge:DI (match_operand:DI 1 "register_operand" "")
4501                (match_operand:DI 2 "arith_operand" "")))]
4502   "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE"
4503   [(set (match_dup 0)
4504         (lt:DI (match_dup 1)
4505                (match_dup 2)))
4506    (set (match_dup 0)
4507         (xor:DI (match_dup 0)
4508                 (const_int 1)))]
4509   "")
4510
4511 (define_expand "slt"
4512   [(set (match_operand:SI 0 "register_operand" "=d")
4513         (lt:SI (match_dup 1)
4514                (match_dup 2)))]
4515   ""
4516   "
4517 {
4518   if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
4519     FAIL;
4520
4521   /* set up operands from compare.  */
4522   operands[1] = branch_cmp[0];
4523   operands[2] = branch_cmp[1];
4524
4525   if (TARGET_64BIT || !TARGET_DEBUG_C_MODE)
4526     {
4527       gen_int_relational (LT, operands[0], operands[1], operands[2], (int *)0);
4528       DONE;
4529     }
4530
4531   /* fall through and generate default code */
4532 }")
4533
4534 (define_insn "slt_si"
4535   [(set (match_operand:SI 0 "register_operand" "=d")
4536         (lt:SI (match_operand:SI 1 "register_operand" "d")
4537                (match_operand:SI 2 "arith_operand" "dI")))]
4538   ""
4539   "slt\\t%0,%1,%2"
4540   [(set_attr "type"     "arith")
4541    (set_attr "mode"     "SI")
4542    (set_attr "length"   "1")])
4543
4544 (define_insn "slt_di"
4545   [(set (match_operand:DI 0 "register_operand" "=d")
4546         (lt:DI (match_operand:DI 1 "register_operand" "d")
4547                (match_operand:DI 2 "arith_operand" "dI")))]
4548   "TARGET_64BIT"
4549   "slt\\t%0,%1,%2"
4550   [(set_attr "type"     "arith")
4551    (set_attr "mode"     "DI")
4552    (set_attr "length"   "1")])
4553
4554 (define_expand "sle"
4555   [(set (match_operand:SI 0 "register_operand" "=d")
4556         (le:SI (match_dup 1)
4557                (match_dup 2)))]
4558   ""
4559   "
4560 {
4561   if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
4562     FAIL;
4563
4564   /* set up operands from compare.  */
4565   operands[1] = branch_cmp[0];
4566   operands[2] = branch_cmp[1];
4567
4568   if (TARGET_64BIT || !TARGET_DEBUG_C_MODE)
4569     {
4570       gen_int_relational (LE, operands[0], operands[1], operands[2], (int *)0);
4571       DONE;
4572     }
4573
4574   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32767)
4575     operands[2] = force_reg (SImode, operands[2]);
4576
4577   /* fall through and generate default code */
4578 }")
4579
4580 (define_insn "sle_si_const"
4581   [(set (match_operand:SI 0 "register_operand" "=d")
4582         (le:SI (match_operand:SI 1 "register_operand" "d")
4583                (match_operand:SI 2 "small_int" "I")))]
4584   "INTVAL (operands[2]) < 32767"
4585   "*
4586 {
4587   operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2])+1);
4588   return \"slt\\t%0,%1,%2\";
4589 }"
4590   [(set_attr "type"     "arith")
4591    (set_attr "mode"     "SI")
4592    (set_attr "length"   "1")])
4593
4594 (define_insn "sle_di_const"
4595   [(set (match_operand:DI 0 "register_operand" "=d")
4596         (le:DI (match_operand:DI 1 "register_operand" "d")
4597                (match_operand:DI 2 "small_int" "I")))]
4598   "TARGET_64BIT && INTVAL (operands[2]) < 32767"
4599   "*
4600 {
4601   operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2])+1);
4602   return \"slt\\t%0,%1,%2\";
4603 }"
4604   [(set_attr "type"     "arith")
4605    (set_attr "mode"     "DI")
4606    (set_attr "length"   "1")])
4607
4608 (define_insn "sle_si_reg"
4609   [(set (match_operand:SI 0 "register_operand" "=d")
4610         (le:SI (match_operand:SI 1 "register_operand" "d")
4611                (match_operand:SI 2 "register_operand" "d")))]
4612   "TARGET_DEBUG_C_MODE"
4613   "slt\\t%0,%z2,%1\;xori\\t%0,%0,0x0001"
4614   [(set_attr "type"     "arith")
4615    (set_attr "mode"     "SI")
4616    (set_attr "length"   "2")])
4617
4618 (define_split
4619   [(set (match_operand:SI 0 "register_operand" "")
4620         (le:SI (match_operand:SI 1 "register_operand" "")
4621                (match_operand:SI 2 "register_operand" "")))]
4622   "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE"
4623   [(set (match_dup 0)
4624         (lt:SI (match_dup 2)
4625                (match_dup 1)))
4626    (set (match_dup 0)
4627         (xor:SI (match_dup 0)
4628                 (const_int 1)))]
4629   "")
4630
4631 (define_insn "sle_di_reg"
4632   [(set (match_operand:DI 0 "register_operand" "=d")
4633         (le:DI (match_operand:DI 1 "register_operand" "d")
4634                (match_operand:DI 2 "register_operand" "d")))]
4635   "TARGET_64BIT && TARGET_DEBUG_C_MODE"
4636   "slt\\t%0,%z2,%1\;xori\\t%0,%0,0x0001"
4637   [(set_attr "type"     "arith")
4638    (set_attr "mode"     "DI")
4639    (set_attr "length"   "2")])
4640
4641 (define_split
4642   [(set (match_operand:DI 0 "register_operand" "")
4643         (le:DI (match_operand:DI 1 "register_operand" "")
4644                (match_operand:DI 2 "register_operand" "")))]
4645   "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE"
4646   [(set (match_dup 0)
4647         (lt:DI (match_dup 2)
4648                (match_dup 1)))
4649    (set (match_dup 0)
4650         (xor:DI (match_dup 0)
4651                 (const_int 1)))]
4652   "")
4653
4654 (define_expand "sgtu"
4655   [(set (match_operand:SI 0 "register_operand" "=d")
4656         (gtu:SI (match_dup 1)
4657                 (match_dup 2)))]
4658   ""
4659   "
4660 {
4661   if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
4662     FAIL;
4663
4664   /* set up operands from compare.  */
4665   operands[1] = branch_cmp[0];
4666   operands[2] = branch_cmp[1];
4667
4668   if (TARGET_64BIT || !TARGET_DEBUG_C_MODE)
4669     {
4670       gen_int_relational (GTU, operands[0], operands[1], operands[2], (int *)0);
4671       DONE;
4672     }
4673
4674   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) != 0)
4675     operands[2] = force_reg (SImode, operands[2]);
4676
4677   /* fall through and generate default code */
4678 }")
4679
4680 (define_insn "sgtu_si"
4681   [(set (match_operand:SI 0 "register_operand" "=d")
4682         (gtu:SI (match_operand:SI 1 "register_operand" "d")
4683                 (match_operand:SI 2 "reg_or_0_operand" "dJ")))]
4684   ""
4685   "sltu\\t%0,%z2,%1"
4686   [(set_attr "type"     "arith")
4687    (set_attr "mode"     "SI")
4688    (set_attr "length"   "1")])
4689
4690 (define_insn "sgtu_di"
4691   [(set (match_operand:DI 0 "register_operand" "=d")
4692         (gtu:DI (match_operand:DI 1 "register_operand" "d")
4693                 (match_operand:DI 2 "reg_or_0_operand" "dJ")))]
4694   "TARGET_64BIT"
4695   "sltu\\t%0,%z2,%1"
4696   [(set_attr "type"     "arith")
4697    (set_attr "mode"     "DI")
4698    (set_attr "length"   "1")])
4699
4700 (define_expand "sgeu"
4701   [(set (match_operand:SI 0 "register_operand" "=d")
4702         (geu:SI (match_dup 1)
4703                 (match_dup 2)))]
4704   ""
4705   "
4706 {
4707   if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
4708     FAIL;
4709
4710   /* set up operands from compare.  */
4711   operands[1] = branch_cmp[0];
4712   operands[2] = branch_cmp[1];
4713
4714   if (TARGET_64BIT || !TARGET_DEBUG_C_MODE)
4715     {
4716       gen_int_relational (GEU, operands[0], operands[1], operands[2], (int *)0);
4717       DONE;
4718     }
4719
4720   /* fall through and generate default code */
4721 }")
4722
4723 (define_insn "sgeu_si"
4724   [(set (match_operand:SI 0 "register_operand" "=d")
4725         (geu:SI (match_operand:SI 1 "register_operand" "d")
4726                 (match_operand:SI 2 "arith_operand" "dI")))]
4727   "TARGET_DEBUG_C_MODE"
4728   "sltu\\t%0,%1,%2\;xori\\t%0,%0,0x0001"
4729   [(set_attr "type"     "arith")
4730    (set_attr "mode"     "SI")
4731    (set_attr "length"   "2")])
4732
4733 (define_split
4734   [(set (match_operand:SI 0 "register_operand" "")
4735         (geu:SI (match_operand:SI 1 "register_operand" "")
4736                 (match_operand:SI 2 "arith_operand" "")))]
4737   "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE"
4738   [(set (match_dup 0)
4739         (ltu:SI (match_dup 1)
4740                 (match_dup 2)))
4741    (set (match_dup 0)
4742         (xor:SI (match_dup 0)
4743                 (const_int 1)))]
4744   "")
4745
4746 (define_insn "sgeu_di"
4747   [(set (match_operand:DI 0 "register_operand" "=d")
4748         (geu:DI (match_operand:DI 1 "register_operand" "d")
4749                 (match_operand:DI 2 "arith_operand" "dI")))]
4750   "TARGET_64BIT && TARGET_DEBUG_C_MODE"
4751   "sltu\\t%0,%1,%2\;xori\\t%0,%0,0x0001"
4752   [(set_attr "type"     "arith")
4753    (set_attr "mode"     "DI")
4754    (set_attr "length"   "2")])
4755
4756 (define_split
4757   [(set (match_operand:DI 0 "register_operand" "")
4758         (geu:DI (match_operand:DI 1 "register_operand" "")
4759                 (match_operand:DI 2 "arith_operand" "")))]
4760   "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE"
4761   [(set (match_dup 0)
4762         (ltu:DI (match_dup 1)
4763                 (match_dup 2)))
4764    (set (match_dup 0)
4765         (xor:DI (match_dup 0)
4766                 (const_int 1)))]
4767   "")
4768
4769 (define_expand "sltu"
4770   [(set (match_operand:SI 0 "register_operand" "=d")
4771         (ltu:SI (match_dup 1)
4772                 (match_dup 2)))]
4773   ""
4774   "
4775 {
4776   if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
4777     FAIL;
4778
4779   /* set up operands from compare.  */
4780   operands[1] = branch_cmp[0];
4781   operands[2] = branch_cmp[1];
4782
4783   if (TARGET_64BIT || !TARGET_DEBUG_C_MODE)
4784     {
4785       gen_int_relational (LTU, operands[0], operands[1], operands[2], (int *)0);
4786       DONE;
4787     }
4788
4789   /* fall through and generate default code */
4790 }")
4791
4792 (define_insn "sltu_si"
4793   [(set (match_operand:SI 0 "register_operand" "=d")
4794         (ltu:SI (match_operand:SI 1 "register_operand" "d")
4795                 (match_operand:SI 2 "arith_operand" "dI")))]
4796   ""
4797   "sltu\\t%0,%1,%2"
4798   [(set_attr "type"     "arith")
4799    (set_attr "mode"     "SI")
4800    (set_attr "length"   "1")])
4801
4802 (define_insn "sltu_di"
4803   [(set (match_operand:DI 0 "register_operand" "=d")
4804         (ltu:DI (match_operand:DI 1 "register_operand" "d")
4805                 (match_operand:DI 2 "arith_operand" "dI")))]
4806   "TARGET_64BIT"
4807   "sltu\\t%0,%1,%2"
4808   [(set_attr "type"     "arith")
4809    (set_attr "mode"     "DI")
4810    (set_attr "length"   "1")])
4811
4812 (define_expand "sleu"
4813   [(set (match_operand:SI 0 "register_operand" "=d")
4814         (leu:SI (match_dup 1)
4815                 (match_dup 2)))]
4816   ""
4817   "
4818 {
4819   if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
4820     FAIL;
4821
4822   /* set up operands from compare.  */
4823   operands[1] = branch_cmp[0];
4824   operands[2] = branch_cmp[1];
4825
4826   if (TARGET_64BIT || !TARGET_DEBUG_C_MODE)
4827     {
4828       gen_int_relational (LEU, operands[0], operands[1], operands[2], (int *)0);
4829       DONE;
4830     }
4831
4832   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32767)
4833     operands[2] = force_reg (SImode, operands[2]);
4834
4835   /* fall through and generate default code */
4836 }")
4837
4838 (define_insn "sleu_si_const"
4839   [(set (match_operand:SI 0 "register_operand" "=d")
4840         (leu:SI (match_operand:SI 1 "register_operand" "d")
4841                 (match_operand:SI 2 "small_int" "I")))]
4842   "INTVAL (operands[2]) < 32767"
4843   "*
4844 {
4845   operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2])+1);
4846   return \"sltu\\t%0,%1,%2\";
4847 }"
4848   [(set_attr "type"     "arith")
4849    (set_attr "mode"     "SI")
4850    (set_attr "length"   "1")])
4851
4852 (define_insn "sleu_di_const"
4853   [(set (match_operand:DI 0 "register_operand" "=d")
4854         (leu:DI (match_operand:DI 1 "register_operand" "d")
4855                 (match_operand:DI 2 "small_int" "I")))]
4856   "TARGET_64BIT && INTVAL (operands[2]) < 32767"
4857   "*
4858 {
4859   operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2])+1);
4860   return \"sltu\\t%0,%1,%2\";
4861 }"
4862   [(set_attr "type"     "arith")
4863    (set_attr "mode"     "DI")
4864    (set_attr "length"   "1")])
4865
4866 (define_insn "sleu_si_reg"
4867   [(set (match_operand:SI 0 "register_operand" "=d")
4868         (leu:SI (match_operand:SI 1 "register_operand" "d")
4869                 (match_operand:SI 2 "register_operand" "d")))]
4870   "TARGET_DEBUG_C_MODE"
4871   "sltu\\t%0,%z2,%1\;xori\\t%0,%0,0x0001"
4872   [(set_attr "type"     "arith")
4873    (set_attr "mode"     "SI")
4874    (set_attr "length"   "2")])
4875
4876 (define_split
4877   [(set (match_operand:SI 0 "register_operand" "")
4878         (leu:SI (match_operand:SI 1 "register_operand" "")
4879                 (match_operand:SI 2 "register_operand" "")))]
4880   "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE"
4881   [(set (match_dup 0)
4882         (ltu:SI (match_dup 2)
4883                 (match_dup 1)))
4884    (set (match_dup 0)
4885         (xor:SI (match_dup 0)
4886                 (const_int 1)))]
4887   "")
4888
4889 (define_insn "sleu_di_reg"
4890   [(set (match_operand:DI 0 "register_operand" "=d")
4891         (leu:DI (match_operand:DI 1 "register_operand" "d")
4892                 (match_operand:DI 2 "register_operand" "d")))]
4893   "TARGET_64BIT && TARGET_DEBUG_C_MODE"
4894   "sltu\\t%0,%z2,%1\;xori\\t%0,%0,0x0001"
4895   [(set_attr "type"     "arith")
4896    (set_attr "mode"     "DI")
4897    (set_attr "length"   "2")])
4898
4899 (define_split
4900   [(set (match_operand:DI 0 "register_operand" "")
4901         (leu:DI (match_operand:DI 1 "register_operand" "")
4902                 (match_operand:DI 2 "register_operand" "")))]
4903   "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE"
4904   [(set (match_dup 0)
4905         (ltu:DI (match_dup 2)
4906                 (match_dup 1)))
4907    (set (match_dup 0)
4908         (xor:DI (match_dup 0)
4909                 (const_int 1)))]
4910   "")
4911
4912 \f
4913 ;;
4914 ;;  ....................
4915 ;;
4916 ;;      FLOATING POINT COMPARISONS
4917 ;;
4918 ;;  ....................
4919
4920 (define_insn "seq_df"
4921   [(set (reg:CC_FP 66)
4922         (eq:CC_FP (match_operand:DF 0 "register_operand" "f")
4923                   (match_operand:DF 1 "register_operand" "f")))]
4924   "TARGET_HARD_FLOAT"
4925   "*
4926 {
4927   rtx xoperands[10];
4928   xoperands[0] = gen_rtx (REG, CC_FPmode, FPSW_REGNUM);
4929   xoperands[1] = operands[0];
4930   xoperands[2] = operands[1];
4931
4932   return mips_fill_delay_slot (\"c.eq.d\\t%0,%1\", DELAY_FCMP, xoperands, insn);
4933 }"
4934  [(set_attr "type"      "fcmp")
4935   (set_attr "mode"      "FPSW")
4936   (set_attr "length"    "1")])
4937
4938 (define_insn "sne_df"
4939   [(set (reg:CC_REV_FP 66)
4940         (ne:CC_REV_FP (match_operand:DF 0 "register_operand" "f")
4941                       (match_operand:DF 1 "register_operand" "f")))]
4942   "TARGET_HARD_FLOAT"
4943   "*
4944 {
4945   rtx xoperands[10];
4946   xoperands[0] = gen_rtx (REG, CC_FPmode, FPSW_REGNUM);
4947   xoperands[1] = operands[0];
4948   xoperands[2] = operands[1];
4949
4950   return mips_fill_delay_slot (\"c.eq.d\\t%0,%1\", DELAY_FCMP, xoperands, insn);
4951 }"
4952  [(set_attr "type"      "fcmp")
4953   (set_attr "mode"      "FPSW")
4954   (set_attr "length"    "1")])
4955
4956 (define_insn "slt_df"
4957   [(set (reg:CC_FP 66)
4958         (lt:CC_FP (match_operand:DF 0 "register_operand" "f")
4959                   (match_operand:DF 1 "register_operand" "f")))]
4960   "TARGET_HARD_FLOAT"
4961   "*
4962 {
4963   rtx xoperands[10];
4964   xoperands[0] = gen_rtx (REG, CC_FPmode, FPSW_REGNUM);
4965   xoperands[1] = operands[0];
4966   xoperands[2] = operands[1];
4967
4968   return mips_fill_delay_slot (\"c.lt.d\\t%0,%1\", DELAY_FCMP, xoperands, insn);
4969 }"
4970  [(set_attr "type"      "fcmp")
4971   (set_attr "mode"      "FPSW")
4972   (set_attr "length"    "1")])
4973
4974 (define_insn "sle_df"
4975   [(set (reg:CC_FP 66)
4976         (le:CC_FP (match_operand:DF 0 "register_operand" "f")
4977                   (match_operand:DF 1 "register_operand" "f")))]
4978   "TARGET_HARD_FLOAT"
4979   "*
4980 {
4981   rtx xoperands[10];
4982   xoperands[0] = gen_rtx (REG, CC_FPmode, FPSW_REGNUM);
4983   xoperands[1] = operands[0];
4984   xoperands[2] = operands[1];
4985
4986   return mips_fill_delay_slot (\"c.le.d\\t%0,%1\", DELAY_FCMP, xoperands, insn);
4987 }"
4988  [(set_attr "type"      "fcmp")
4989   (set_attr "mode"      "FPSW")
4990   (set_attr "length"    "1")])
4991
4992 (define_insn "sgt_df"
4993   [(set (reg:CC_FP 66)
4994         (gt:CC_FP (match_operand:DF 0 "register_operand" "f")
4995                   (match_operand:DF 1 "register_operand" "f")))]
4996   "TARGET_HARD_FLOAT"
4997   "*
4998 {
4999   rtx xoperands[10];
5000   xoperands[0] = gen_rtx (REG, CC_FPmode, FPSW_REGNUM);
5001   xoperands[1] = operands[0];
5002   xoperands[2] = operands[1];
5003
5004   return mips_fill_delay_slot (\"c.lt.d\\t%1,%0\", DELAY_FCMP, xoperands, insn);
5005 }"
5006  [(set_attr "type"      "fcmp")
5007   (set_attr "mode"      "FPSW")
5008   (set_attr "length"    "1")])
5009
5010 (define_insn "sge_df"
5011   [(set (reg:CC_FP 66)
5012         (ge:CC_FP (match_operand:DF 0 "register_operand" "f")
5013                   (match_operand:DF 1 "register_operand" "f")))]
5014   "TARGET_HARD_FLOAT"
5015   "*
5016 {
5017   rtx xoperands[10];
5018   xoperands[0] = gen_rtx (REG, CC_FPmode, FPSW_REGNUM);
5019   xoperands[1] = operands[0];
5020   xoperands[2] = operands[1];
5021
5022   return mips_fill_delay_slot (\"c.le.d\\t%1,%0\", DELAY_FCMP, xoperands, insn);
5023 }"
5024  [(set_attr "type"      "fcmp")
5025   (set_attr "mode"      "FPSW")
5026   (set_attr "length"    "1")])
5027
5028 (define_insn "seq_sf"
5029   [(set (reg:CC_FP 66)
5030         (eq:CC_FP (match_operand:SF 0 "register_operand" "f")
5031                   (match_operand:SF 1 "register_operand" "f")))]
5032   "TARGET_HARD_FLOAT"
5033   "*
5034 {
5035   rtx xoperands[10];
5036   xoperands[0] = gen_rtx (REG, CC_FPmode, FPSW_REGNUM);
5037   xoperands[1] = operands[0];
5038   xoperands[2] = operands[1];
5039
5040   return mips_fill_delay_slot (\"c.eq.s\\t%0,%1\", DELAY_FCMP, xoperands, insn);
5041 }"
5042  [(set_attr "type"      "fcmp")
5043   (set_attr "mode"      "FPSW")
5044   (set_attr "length"    "1")])
5045
5046 (define_insn "sne_sf"
5047   [(set (reg:CC_REV_FP 66)
5048         (ne:CC_REV_FP (match_operand:SF 0 "register_operand" "f")
5049                       (match_operand:SF 1 "register_operand" "f")))]
5050   "TARGET_HARD_FLOAT"
5051   "*
5052 {
5053   rtx xoperands[10];
5054   xoperands[0] = gen_rtx (REG, CC_FPmode, FPSW_REGNUM);
5055   xoperands[1] = operands[0];
5056   xoperands[2] = operands[1];
5057
5058   return mips_fill_delay_slot (\"c.eq.s\\t%0,%1\", DELAY_FCMP, xoperands, insn);
5059 }"
5060  [(set_attr "type"      "fcmp")
5061   (set_attr "mode"      "FPSW")
5062   (set_attr "length"    "1")])
5063
5064 (define_insn "slt_sf"
5065   [(set (reg:CC_FP 66)
5066         (lt:CC_FP (match_operand:SF 0 "register_operand" "f")
5067                   (match_operand:SF 1 "register_operand" "f")))]
5068   "TARGET_HARD_FLOAT"
5069   "*
5070 {
5071   rtx xoperands[10];
5072   xoperands[0] = gen_rtx (REG, CC_FPmode, FPSW_REGNUM);
5073   xoperands[1] = operands[0];
5074   xoperands[2] = operands[1];
5075
5076   return mips_fill_delay_slot (\"c.lt.s\\t%0,%1\", DELAY_FCMP, xoperands, insn);
5077 }"
5078  [(set_attr "type"      "fcmp")
5079   (set_attr "mode"      "FPSW")
5080   (set_attr "length"    "1")])
5081
5082 (define_insn "sle_sf"
5083   [(set (reg:CC_FP 66)
5084         (le:CC_FP (match_operand:SF 0 "register_operand" "f")
5085                   (match_operand:SF 1 "register_operand" "f")))]
5086   "TARGET_HARD_FLOAT"
5087   "*
5088 {
5089   rtx xoperands[10];
5090   xoperands[0] = gen_rtx (REG, CC_FPmode, FPSW_REGNUM);
5091   xoperands[1] = operands[0];
5092   xoperands[2] = operands[1];
5093
5094   return mips_fill_delay_slot (\"c.le.s\\t%0,%1\", DELAY_FCMP, xoperands, insn);
5095 }"
5096  [(set_attr "type"      "fcmp")
5097   (set_attr "mode"      "FPSW")
5098   (set_attr "length"    "1")])
5099
5100 (define_insn "sgt_sf"
5101   [(set (reg:CC_FP 66)
5102         (gt:CC_FP (match_operand:SF 0 "register_operand" "f")
5103                   (match_operand:SF 1 "register_operand" "f")))]
5104   "TARGET_HARD_FLOAT"
5105   "*
5106 {
5107   rtx xoperands[10];
5108   xoperands[0] = gen_rtx (REG, CC_FPmode, FPSW_REGNUM);
5109   xoperands[1] = operands[0];
5110   xoperands[2] = operands[1];
5111
5112   return mips_fill_delay_slot (\"c.lt.s\\t%1,%0\", DELAY_FCMP, xoperands, insn);
5113 }"
5114  [(set_attr "type"      "fcmp")
5115   (set_attr "mode"      "FPSW")
5116   (set_attr "length"    "1")])
5117
5118 (define_insn "sge_sf"
5119   [(set (reg:CC_FP 66)
5120         (ge:CC_FP (match_operand:SF 0 "register_operand" "f")
5121                   (match_operand:SF 1 "register_operand" "f")))]
5122   "TARGET_HARD_FLOAT"
5123   "*
5124 {
5125   rtx xoperands[10];
5126   xoperands[0] = gen_rtx (REG, CC_FPmode, FPSW_REGNUM);
5127   xoperands[1] = operands[0];
5128   xoperands[2] = operands[1];
5129
5130   return mips_fill_delay_slot (\"c.le.s\\t%1,%0\", DELAY_FCMP, xoperands, insn);
5131 }"
5132  [(set_attr "type"      "fcmp")
5133   (set_attr "mode"      "FPSW")
5134   (set_attr "length"    "1")])
5135
5136 \f
5137 ;;
5138 ;;  ....................
5139 ;;
5140 ;;      UNCONDITIONAL BRANCHES
5141 ;;
5142 ;;  ....................
5143
5144 ;; Unconditional branches.
5145
5146 (define_insn "jump"
5147   [(set (pc)
5148         (label_ref (match_operand 0 "" "")))]
5149   ""
5150   "*
5151 {
5152   if (GET_CODE (operands[0]) == REG)
5153     return \"%*j\\t%0\";
5154   else
5155     return \"%*j\\t%l0\";
5156 }"
5157   [(set_attr "type"     "jump")
5158    (set_attr "mode"     "none")
5159    (set_attr "length"   "1")])
5160
5161 (define_expand "indirect_jump"
5162   [(set (pc) (match_operand 0 "register_operand" "d"))]
5163   ""
5164   "
5165 {
5166   rtx dest;
5167
5168   if (operands[0])              /* eliminate unused code warnings */
5169     {
5170       dest = operands[0];
5171       if (GET_CODE (dest) != REG || GET_MODE (dest) != Pmode)
5172         operands[0] = copy_to_mode_reg (Pmode, dest);
5173
5174       if (!TARGET_LONG64)
5175         emit_jump_insn (gen_indirect_jump_internal1 (operands[0]));
5176       else
5177         emit_jump_insn (gen_indirect_jump_internal2 (operands[0]));
5178
5179       DONE;
5180     }
5181 }")
5182
5183 (define_insn "indirect_jump_internal1"
5184   [(set (pc) (match_operand:SI 0 "register_operand" "d"))]
5185   "!TARGET_LONG64"
5186   "%*j\\t%0"
5187   [(set_attr "type"     "jump")
5188    (set_attr "mode"     "none")
5189    (set_attr "length"   "1")])
5190
5191 (define_insn "indirect_jump_internal2"
5192   [(set (pc) (match_operand:DI 0 "register_operand" "d"))]
5193   "TARGET_LONG64"
5194   "%*j\\t%0"
5195   [(set_attr "type"     "jump")
5196    (set_attr "mode"     "none")
5197    (set_attr "length"   "1")])
5198
5199 (define_expand "tablejump"
5200   [(set (pc)
5201         (match_operand 0 "register_operand" "d"))
5202    (use (label_ref (match_operand 1 "" "")))]
5203   ""
5204   "
5205 {
5206   rtx dest;
5207
5208   if (operands[0])              /* eliminate unused code warnings */
5209     {
5210       if (GET_MODE (operands[0]) != Pmode)
5211         abort ();
5212
5213       if (!TARGET_LONG64)
5214         emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
5215       else
5216         emit_jump_insn (gen_tablejump_internal2 (operands[0], operands[1]));
5217
5218       DONE;
5219     }
5220 }")
5221
5222 (define_insn "tablejump_internal1"
5223   [(set (pc)
5224         (match_operand:SI 0 "register_operand" "d"))
5225    (use (label_ref (match_operand 1 "" "")))]
5226   "!TARGET_LONG64"
5227   "%*j\\t%0"
5228   [(set_attr "type"     "jump")
5229    (set_attr "mode"     "none")
5230    (set_attr "length"   "1")])
5231
5232 (define_insn "tablejump_internal2"
5233   [(set (pc)
5234         (match_operand:DI 0 "register_operand" "d"))
5235    (use (label_ref (match_operand 1 "" "")))]
5236   "TARGET_LONG64"
5237   "%*j\\t%0"
5238   [(set_attr "type"     "jump")
5239    (set_attr "mode"     "none")
5240    (set_attr "length"   "1")])
5241
5242 ;; Function return, only allow after optimization, so that we can
5243 ;; eliminate jumps to jumps if no stack space is used.
5244
5245 ;; (define_expand "return"
5246 ;;   [(set (pc) (reg:SI 31))]
5247 ;;   "simple_epilogue_p ()"
5248 ;;   "")
5249
5250 (define_expand "return"
5251   [(parallel [(return)
5252               (use (reg:SI 31))])]
5253   "simple_epilogue_p ()"
5254   "")
5255
5256 (define_insn "return_internal"
5257   [(parallel [(return)
5258               (use (match_operand:SI 0 "register_operand" "d"))])]
5259   ""
5260   "%*j\\t%0"
5261   [(set_attr "type"     "jump")
5262    (set_attr "mode"     "none")
5263    (set_attr "length"   "1")])
5264
5265 \f
5266 ;;
5267 ;;  ....................
5268 ;;
5269 ;;      Function prologue/epilogue
5270 ;;
5271 ;;  ....................
5272 ;;
5273
5274 (define_expand "prologue"
5275   [(const_int 1)]
5276   ""
5277   "
5278 {
5279   if (mips_isa >= 0)            /* avoid unused code warnings */
5280     {
5281       mips_expand_prologue ();
5282       DONE;
5283     }
5284 }")
5285
5286 ;; Block any insns from being moved before this point, since the
5287 ;; profiling call to mcount can use various registers that aren't
5288 ;; saved or used to pass arguments.
5289
5290 (define_insn "blockage"
5291   [(unspec_volatile [(const_int 0)] 0)]
5292   ""
5293   ""
5294   [(set_attr "type"     "unknown")
5295    (set_attr "mode"     "none")
5296    (set_attr "length"   "0")])
5297
5298 ;; At present, don't expand the epilogue, reorg.c will clobber the
5299 ;; return register in compiling gen_lowpart (emit-rtl.c).
5300 ;; 
5301 ;; (define_expand "epilogue"
5302 ;;   [(const_int 2)]
5303 ;;   ""
5304 ;;   "
5305 ;; {
5306 ;;   if (mips_isa >= 0)            /* avoid unused code warnings */
5307 ;;     {
5308 ;;       mips_expand_epilogue ();
5309 ;;       DONE;
5310 ;;     }
5311 ;; }")
5312
5313 \f
5314 ;;
5315 ;;  ....................
5316 ;;
5317 ;;      FUNCTION CALLS
5318 ;;
5319 ;;  ....................
5320
5321 ;; calls.c now passes a third argument, make saber happy
5322
5323 (define_expand "call"
5324   [(parallel [(call (match_operand 0 "memory_operand" "m")
5325                     (match_operand 1 "" "i"))
5326               (clobber (reg:SI 31))
5327               (use (match_operand 2 "" ""))             ;; next_arg_reg
5328               (use (match_operand 3 "" ""))])]          ;; struct_value_size_rtx
5329   ""
5330   "
5331 {
5332   rtx addr;
5333
5334   if (operands[0])              /* eliminate unused code warnings */
5335     {
5336       addr = XEXP (operands[0], 0);
5337       if ((GET_CODE (addr) != REG && (!CONSTANT_ADDRESS_P (addr) || TARGET_LONG_CALLS))
5338           || ! call_insn_operand (operands[0], VOIDmode))
5339         XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, addr);
5340
5341       /* In order to pass small structures by value in registers
5342          compatibly with the MIPS compiler, we need to shift the value
5343          into the high part of the register.  Function_arg has encoded
5344          a PARALLEL rtx, holding a vector of adjustments to be made
5345          as the next_arg_reg variable, so we split up the insns,
5346          and emit them separately.  */
5347
5348       if (operands[2] != (rtx)0 && GET_CODE (operands[2]) == PARALLEL)
5349         {
5350           rtvec adjust = XVEC (operands[2], 0);
5351           int num = GET_NUM_ELEM (adjust);
5352           int i;
5353
5354           for (i = 0; i < num; i++)
5355             emit_insn (RTVEC_ELT (adjust, i));
5356         }
5357
5358       emit_call_insn (gen_call_internal1 (operands[0], operands[1],
5359                                           gen_rtx (REG, SImode, GP_REG_FIRST + 31)));
5360       DONE;
5361     }
5362 }")
5363
5364 (define_insn "call_internal1"
5365   [(call (match_operand 0 "call_insn_operand" "m")
5366          (match_operand 1 "" "i"))
5367    (clobber (match_operand:SI 2 "register_operand" "=d"))]
5368   "!TARGET_ABICALLS && !TARGET_LONG_CALLS"
5369   "*
5370 {
5371   register rtx target = XEXP (operands[0], 0);
5372
5373   if (GET_CODE (target) == SYMBOL_REF)
5374     return \"%*jal\\t%0\";
5375
5376   else if (GET_CODE (target) == CONST_INT)
5377     {
5378       operands[0] = target;
5379       return \"%*%[li\\t%@,%0\\n\\tjal\\t%2,%@%]\";
5380     }
5381
5382   else
5383     {
5384       operands[0] = target;
5385       return \"%*jal\\t%2,%0\";
5386     }
5387 }"
5388   [(set_attr "type"     "call")
5389    (set_attr "mode"     "none")
5390    (set_attr "length"   "1")])
5391
5392 (define_insn "call_internal2"
5393   [(call (match_operand 0 "call_insn_operand" "m")
5394          (match_operand 1 "" "i"))
5395    (clobber (match_operand:SI 2 "register_operand" "=d"))]
5396   "TARGET_ABICALLS && !TARGET_LONG_CALLS"
5397   "*
5398 {
5399   register rtx target = XEXP (operands[0], 0);
5400
5401   if (GET_CODE (target) == SYMBOL_REF)
5402     return \"jal\\t%0\";
5403
5404   else if (GET_CODE (target) == CONST_INT)
5405     {
5406       operands[0] = target;
5407       return \"li\\t%^,%0\\n\\tjal\\t%2,%^\";
5408     }
5409
5410   else
5411     {
5412       operands[0] = target;
5413       if (REGNO (target) != PIC_FUNCTION_ADDR_REGNUM)
5414         return \"move\\t%^,%0\\n\\tjal\\t%2,%^\";
5415       else
5416         return \"jal\\t%2,%0\";
5417     }
5418 }"
5419   [(set_attr "type"     "call")
5420    (set_attr "mode"     "none")
5421    (set_attr "length"   "2")])
5422
5423 (define_insn "call_internal3a"
5424   [(call (mem:SI (match_operand:SI 0 "register_operand" "r"))
5425          (match_operand 1 "" "i"))
5426    (clobber (match_operand:SI 2 "register_operand" "=d"))]
5427   "!TARGET_LONG64 && !TARGET_ABICALLS && TARGET_LONG_CALLS"
5428   "%*jal\\t%2,%0"
5429   [(set_attr "type"     "call")
5430    (set_attr "mode"     "none")
5431    (set_attr "length"   "1")])
5432
5433 (define_insn "call_internal3b"
5434   [(call (mem:DI (match_operand:DI 0 "register_operand" "r"))
5435          (match_operand 1 "" "i"))
5436    (clobber (match_operand:SI 2 "register_operand" "=d"))]
5437   "TARGET_LONG64 && !TARGET_ABICALLS && TARGET_LONG_CALLS"
5438   "%*jal\\t%2,%0"
5439   [(set_attr "type"     "call")
5440    (set_attr "mode"     "none")
5441    (set_attr "length"   "1")])
5442
5443 (define_insn "call_internal4a"
5444   [(call (mem:SI (match_operand:SI 0 "register_operand" "r"))
5445          (match_operand 1 "" "i"))
5446    (clobber (match_operand:SI 2 "register_operand" "=d"))]
5447   "!TARGET_LONG64 && TARGET_ABICALLS && TARGET_LONG_CALLS"
5448   "*
5449 {
5450   if (REGNO (operands[0]) != PIC_FUNCTION_ADDR_REGNUM)
5451     return \"move\\t%^,%0\\n\\tjal\\t%2,%^\";
5452   else
5453     return \"jal\\t%2,%0\";
5454 }"
5455   [(set_attr "type"     "call")
5456    (set_attr "mode"     "none")
5457    (set_attr "length"   "2")])
5458
5459 (define_insn "call_internal4b"
5460   [(call (mem:DI (match_operand:DI 0 "register_operand" "r"))
5461          (match_operand 1 "" "i"))
5462    (clobber (match_operand:SI 2 "register_operand" "=d"))]
5463   "TARGET_LONG64 && TARGET_ABICALLS && TARGET_LONG_CALLS"
5464   "*
5465 {
5466   if (REGNO (operands[0]) != PIC_FUNCTION_ADDR_REGNUM)
5467     return \"move\\t%^,%0\\n\\tjal\\t%2,%^\";
5468   else
5469     return \"jal\\t%2,%0\";
5470 }"
5471   [(set_attr "type"     "call")
5472    (set_attr "mode"     "none")
5473    (set_attr "length"   "2")])
5474
5475 ;; calls.c now passes a fourth argument, make saber happy
5476
5477 (define_expand "call_value"
5478   [(parallel [(set (match_operand 0 "register_operand" "=df")
5479                    (call (match_operand 1 "memory_operand" "m")
5480                          (match_operand 2 "" "i")))
5481               (clobber (reg:SI 31))
5482               (use (match_operand 3 "" ""))])]          ;; next_arg_reg
5483   ""
5484   "
5485 {
5486   rtx addr;
5487
5488   if (operands[0])              /* eliminate unused code warning */
5489     {
5490       addr = XEXP (operands[1], 0);
5491       if ((GET_CODE (addr) != REG && (!CONSTANT_ADDRESS_P (addr) || TARGET_LONG_CALLS))
5492           || ! call_insn_operand (operands[1], VOIDmode))
5493         XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, addr);
5494
5495       /* In order to pass small structures by value in registers
5496          compatibly with the MIPS compiler, we need to shift the value
5497          into the high part of the register.  Function_arg has encoded
5498          a PARALLEL rtx, holding a vector of adjustments to be made
5499          as the next_arg_reg variable, so we split up the insns,
5500          and emit them separately.  */
5501
5502       if (operands[3] != (rtx)0 && GET_CODE (operands[3]) == PARALLEL)
5503         {
5504           rtvec adjust = XVEC (operands[3], 0);
5505           int num = GET_NUM_ELEM (adjust);
5506           int i;
5507
5508           for (i = 0; i < num; i++)
5509             emit_insn (RTVEC_ELT (adjust, i));
5510         }
5511
5512       emit_call_insn (gen_call_value_internal1 (operands[0], operands[1], operands[2],
5513                                                 gen_rtx (REG, SImode, GP_REG_FIRST + 31)));
5514
5515       DONE;
5516     }
5517
5518 }")
5519
5520 (define_insn "call_value_internal1"
5521   [(set (match_operand 0 "register_operand" "=df")
5522         (call (match_operand 1 "call_insn_operand" "m")
5523               (match_operand 2 "" "i")))
5524    (clobber (match_operand:SI 3 "register_operand" "=d"))]
5525   "!TARGET_ABICALLS && !TARGET_LONG_CALLS"
5526   "*
5527 {
5528   register rtx target = XEXP (operands[1], 0);
5529
5530   if (GET_CODE (target) == SYMBOL_REF)
5531     return \"%*jal\\t%1\";
5532
5533   else if (GET_CODE (target) == CONST_INT)
5534     {
5535       operands[1] = target;
5536       return \"%*%[li\\t%@,%1\\n\\tjal\\t%3,%@%]\";
5537     }
5538
5539   else
5540     {
5541       operands[1] = target;
5542       return \"%*jal\\t%3,%1\";
5543     }
5544 }"
5545   [(set_attr "type"     "call")
5546    (set_attr "mode"     "none")
5547    (set_attr "length"   "1")])
5548
5549 (define_insn "call_value_internal2"
5550   [(set (match_operand 0 "register_operand" "=df")
5551         (call (match_operand 1 "call_insn_operand" "m")
5552               (match_operand 2 "" "i")))
5553    (clobber (match_operand:SI 3 "register_operand" "=d"))]
5554   "TARGET_ABICALLS && !TARGET_LONG_CALLS"
5555   "*
5556 {
5557   register rtx target = XEXP (operands[1], 0);
5558
5559   if (GET_CODE (target) == SYMBOL_REF)
5560     return \"jal\\t%1\";
5561
5562   else if (GET_CODE (target) == CONST_INT)
5563     {
5564       operands[1] = target;
5565       return \"li\\t%^,%1\\n\\tjal\\t%3,%^\";
5566     }
5567
5568   else
5569     {
5570       operands[1] = target;
5571       if (REGNO (target) != PIC_FUNCTION_ADDR_REGNUM)
5572         return \"move\\t%^,%1\\n\\tjal\\t%3,%^\";
5573       else
5574         return \"jal\\t%3,%1\";
5575     }
5576 }"
5577   [(set_attr "type"     "call")
5578    (set_attr "mode"     "none")
5579    (set_attr "length"   "2")])
5580
5581 (define_insn "call_value_internal3a"
5582   [(set (match_operand 0 "register_operand" "=df")
5583         (call (mem:SI (match_operand:SI 1 "register_operand" "r"))
5584               (match_operand 2 "" "i")))
5585    (clobber (match_operand:SI 3 "register_operand" "=d"))]
5586   "!TARGET_LONG64 && !TARGET_ABICALLS && TARGET_LONG_CALLS"
5587   "%*jal\\t%3,%1"
5588   [(set_attr "type"     "call")
5589    (set_attr "mode"     "none")
5590    (set_attr "length"   "1")])
5591
5592 (define_insn "call_value_internal3b"
5593   [(set (match_operand 0 "register_operand" "=df")
5594         (call (mem:DI (match_operand:DI 1 "register_operand" "r"))
5595               (match_operand 2 "" "i")))
5596    (clobber (match_operand:SI 3 "register_operand" "=d"))]
5597   "TARGET_LONG64 && !TARGET_ABICALLS && TARGET_LONG_CALLS"
5598   "%*jal\\t%3,%1"
5599   [(set_attr "type"     "call")
5600    (set_attr "mode"     "none")
5601    (set_attr "length"   "1")])
5602
5603 (define_insn "call_value_internal4a"
5604   [(set (match_operand 0 "register_operand" "=df")
5605         (call (mem:SI (match_operand:SI 1 "register_operand" "r"))
5606               (match_operand 2 "" "i")))
5607    (clobber (match_operand:SI 3 "register_operand" "=d"))]
5608   "!TARGET_LONG64 && TARGET_ABICALLS && TARGET_LONG_CALLS"
5609   "*
5610 {
5611   if (REGNO (operands[1]) != PIC_FUNCTION_ADDR_REGNUM)
5612     return \"move\\t%^,%1\\n\\tjal\\t%3,%^\";
5613   else
5614     return \"jal\\t%3,%1\";
5615 }"
5616   [(set_attr "type"     "call")
5617    (set_attr "mode"     "none")
5618    (set_attr "length"   "2")])
5619
5620 (define_insn "call_value_internal4b"
5621   [(set (match_operand 0 "register_operand" "=df")
5622         (call (mem:DI (match_operand:DI 1 "register_operand" "r"))
5623               (match_operand 2 "" "i")))
5624    (clobber (match_operand:SI 3 "register_operand" "=d"))]
5625   "TARGET_LONG64 && TARGET_ABICALLS && TARGET_LONG_CALLS"
5626   "*
5627 {
5628   if (REGNO (operands[1]) != PIC_FUNCTION_ADDR_REGNUM)
5629     return \"move\\t%^,%1\\n\\tjal\\t%3,%^\";
5630   else
5631     return \"jal\\t%3,%1\";
5632 }"
5633   [(set_attr "type"     "call")
5634    (set_attr "mode"     "none")
5635    (set_attr "length"   "2")])
5636
5637 ;; Call subroutine returning any type.
5638
5639 (define_expand "untyped_call"
5640   [(parallel [(call (match_operand 0 "" "")
5641                     (const_int 0))
5642               (match_operand 1 "" "")
5643               (match_operand 2 "" "")])]
5644   ""
5645   "
5646 {
5647   if (operands[0])              /* silence statement not reached warnings */
5648     {
5649       int i;
5650
5651       emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx));
5652
5653       for (i = 0; i < XVECLEN (operands[2], 0); i++)
5654         {
5655           rtx set = XVECEXP (operands[2], 0, i);
5656           emit_move_insn (SET_DEST (set), SET_SRC (set));
5657         }
5658
5659       emit_insn (gen_blockage ());
5660       DONE;
5661     }
5662 }")
5663 \f
5664 ;;
5665 ;;  ....................
5666 ;;
5667 ;;      MISC.
5668 ;;
5669 ;;  ....................
5670 ;;
5671
5672 (define_insn "nop"
5673   [(const_int 0)]
5674   ""
5675   "%(nop%)"
5676   [(set_attr "type"     "nop")
5677    (set_attr "mode"     "none")
5678    (set_attr "length"   "1")])
5679
5680 (define_expand "probe"
5681   [(set (match_dup 0)
5682         (match_dup 1))]
5683   ""
5684   "
5685 {
5686   operands[0] = gen_reg_rtx (SImode);
5687   operands[1] = gen_rtx (MEM, SImode, stack_pointer_rtx);
5688   MEM_VOLATILE_P (operands[1]) = TRUE;
5689
5690   /* fall through and generate default code */
5691 }")