xref: /openbsd/gnu/gcc/gcc/config/m88k/m88k.md (revision 5780af82)
11f5e8f30Smiod;;- Machine description for the Motorola 88000 for GNU C compiler
21f5e8f30Smiod;;  Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000
31f5e8f30Smiod;;  Free Software Foundation, Inc.
41f5e8f30Smiod;;  Contributed by Michael Tiemann (tiemann@mcc.com)
51f5e8f30Smiod
61f5e8f30Smiod;; This file is part of GCC.
71f5e8f30Smiod
81f5e8f30Smiod;; GCC is free software; you can redistribute it and/or modify
91f5e8f30Smiod;; it under the terms of the GNU General Public License as published by
101f5e8f30Smiod;; the Free Software Foundation; either version 2, or (at your option)
111f5e8f30Smiod;; any later version.
121f5e8f30Smiod
131f5e8f30Smiod;; GCC is distributed in the hope that it will be useful,
141f5e8f30Smiod;; but WITHOUT ANY WARRANTY; without even the implied warranty of
151f5e8f30Smiod;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
161f5e8f30Smiod;; GNU General Public License for more details.
171f5e8f30Smiod
181f5e8f30Smiod;; You should have received a copy of the GNU General Public License
191f5e8f30Smiod;; along with GCC; see the file COPYING.  If not, write to
201f5e8f30Smiod;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
211f5e8f30Smiod;; Boston, MA 02110-1301, USA.
221f5e8f30Smiod
231f5e8f30Smiod
241f5e8f30Smiod;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
251f5e8f30Smiod
261f5e8f30Smiod(define_constants
271f5e8f30Smiod  [(UNSPEC_ABDIFF	0)
281f5e8f30Smiod   (UNSPEC_GOT_REL	1)
291f5e8f30Smiod  ])
301f5e8f30Smiod
311f5e8f30Smiod(include "predicates.md")
321f5e8f30Smiod(include "constraints.md")
331f5e8f30Smiod
341f5e8f30Smiod;; Attribute describing the processor.  This attribute must match exactly
351f5e8f30Smiod;; with the processor_type enumeration in m88k.h.
361f5e8f30Smiod
371f5e8f30Smiod; Target CPU.
381f5e8f30Smiod(define_attr "cpu" "m88100,m88110,m88000"
391f5e8f30Smiod  (const (symbol_ref "m88k_cpu")))
401f5e8f30Smiod
411f5e8f30Smiod; Type of each instruction.  Default is arithmetic.
421f5e8f30Smiod; I'd like to write the list as this, but genattrtab won't accept it.
431f5e8f30Smiod;
441f5e8f30Smiod; "branch,jump,call,			; flow-control instructions
451f5e8f30Smiod;  load,store,loadd,loada,		; data unit instructions
461f5e8f30Smiod;  spadd,dpadd,spcmp,dpcmp,spdiv,dpdiv,idiv, ; FPU add instructions
471f5e8f30Smiod;  spmul,dpmul,imul,			; FPU multiply instructions
481f5e8f30Smiod;  arith,bit,mov			; integer unit instructions
491f5e8f30Smiod;  marith,weird"			; multi-word instructions
501f5e8f30Smiod
511f5e8f30Smiod; Classification of each insn.  Some insns of TYPE_BRANCH are multi-word.
521f5e8f30Smiod(define_attr "type"
531f5e8f30Smiod  "branch,jump,call,load,store,loadd,loada,spadd,dpadd,spcmp,dpcmp,spdiv,dpdiv,idiv,spmul,dpmul,imul,arith,bit,mov,marith,weird"
541f5e8f30Smiod  (const_string "arith"))
551f5e8f30Smiod
561f5e8f30Smiod(define_attr "fpu" "yes,no"
571f5e8f30Smiod  (if_then_else
581f5e8f30Smiod   (eq_attr "type" "spmul,dpmul,imul,spadd,dpadd,spcmp,dpcmp,spdiv,dpdiv,idiv")
591f5e8f30Smiod   (const_string "yes") (const_string "no")))
601f5e8f30Smiod
611f5e8f30Smiod; Length in # of instructions of each insn.  The values are not exact, but
621f5e8f30Smiod; are safe.
631f5e8f30Smiod(define_attr "length" ""
641f5e8f30Smiod  (cond [(eq_attr "type" "marith,weird,branch")
651f5e8f30Smiod	 (const_int 2)]
661f5e8f30Smiod	(const_int 1)))
671f5e8f30Smiod
681f5e8f30Smiod; Describe a user's asm statement.
691f5e8f30Smiod(define_asm_attributes
7024ed4e7eSmiod  [(set_attr "type" "weird")
7124ed4e7eSmiod   (set_attr "length" "1")])
721f5e8f30Smiod
731f5e8f30Smiod; Define the delay slot requirements for branches and calls.
741f5e8f30Smiod; The m88100 annuls instructions if a conditional branch is taken.
751f5e8f30Smiod; For insns of TYPE_BRANCH that are multi-word instructions, the
761f5e8f30Smiod; delay slot applies to the first instruction.
771f5e8f30Smiod
781f5e8f30Smiod; @@ For the moment, reorg.c requires that the delay slot of a branch not
791f5e8f30Smiod; be a call or branch.
801f5e8f30Smiod
811f5e8f30Smiod(define_delay (eq_attr "type" "branch,jump")
821f5e8f30Smiod  [(and (and (eq_attr "type" "!branch,jump,call,marith,weird") ; required.
831f5e8f30Smiod	     (eq_attr "type" "!load,loadd")) ; issue as-soon-as-possible.
841f5e8f30Smiod	(eq_attr "fpu" "no")) ; issue as-soon-as-possible.
851f5e8f30Smiod   (eq_attr "type" "!call,branch,jump") (nil)])
861f5e8f30Smiod
871f5e8f30Smiod; output_call supports an unconditional branch in the delay slot of
881f5e8f30Smiod; a call.  (@@ Support for this case is expected in reorg.c soon.)
891f5e8f30Smiod
901f5e8f30Smiod(define_delay (eq_attr "type" "call")
911f5e8f30Smiod  [(eq_attr "type" "!branch,call,marith,weird") ; required.
921f5e8f30Smiod   (nil) (nil)])
931f5e8f30Smiod
94*5780af82Smiod;; Scheduling information
95*5780af82Smiod
96*5780af82Smiod;; This section is derived from the old define_function_unit description.
97*5780af82Smiod;; Each reservation can be overriden on a processor-by-processor basis.
98*5780af82Smiod
99*5780af82Smiod; An abstract block diagram of the function units for the m88100.
100*5780af82Smiod;
101*5780af82Smiod;			    *
102*5780af82Smiod;			    |
103*5780af82Smiod;			+---v----+
104*5780af82Smiod;			| decode |
105*5780af82Smiod;			+-vv-v-v-+	 fpu
106*5780af82Smiod;	       ,----------'| | `----------------------.
107*5780af82Smiod;	       |	   | |			      |	,-----.
108*5780af82Smiod;	  load |     store | | arith		      |	|     |
109*5780af82Smiod;	       |	   | |			    +-v-v-+   |	dp source
110*5780af82Smiod;	       |	   | |			    | fp1 |---'
111*5780af82Smiod;     store    |	   | |	    div		    +-v-v-+
112*5780af82Smiod;   ,------.   |	   | |	  ,-----. ,-----------'	`-----------.
113*5780af82Smiod;   |	   |   |	   | |	  |	| |			    |
114*5780af82Smiod;   |	+--v---v--+    ,---' |	  |   +-v-v---+			+---v---+
115*5780af82Smiod;   |	| stage	2 |    |     |	  `---|	add 2 |			| mul 2	|
116*5780af82Smiod;   |	+---------+    |  +--v--+     +-------+		  imul	+-------+
117*5780af82Smiod;   |	| stage	1 |    |  | alu	|     |	add 3 |	       ,--------| mul 3	|
118*5780af82Smiod;   |	+---------+    |  +--v--+     +-------+	       |	+-------+
119*5780af82Smiod;   |	| stage	0 |    |     |	      |	add 4 |	       |	| mul 4	|
120*5780af82Smiod;   |	+--v---v--+    |     |	      +---v---+	       |	+-------+
121*5780af82Smiod;   |	   |   |       |     |		  |	       |	| mul 5	|
122*5780af82Smiod;   |	   *   |       |     |		  |	       |	+---v---+
123*5780af82Smiod;   |	       |       |     |		  |	  +----v----+	    |
124*5780af82Smiod;   |	  load |       |     |	   fp add `------>| fp last |<------' fp mul
125*5780af82Smiod;   |	       |       |     |			  +---v-v--^+
126*5780af82Smiod;   |	       |       |     |			      |	|  |
127*5780af82Smiod;   |	       |       |     |			      |	`--' dp	dest
128*5780af82Smiod;   |	       |    +--v-----v--+		      |
129*5780af82Smiod;   |	       `--->| writeback	|<--------------------'
130*5780af82Smiod;   |		    +--v-----v--+
131*5780af82Smiod;   |		       |     |
132*5780af82Smiod;   `------------------'     *
133*5780af82Smiod;
134*5780af82Smiod; The decode unit need not be specified.
135*5780af82Smiod; Consideration of writeback contention is critical to superb scheduling.
136*5780af82Smiod
137*5780af82Smiod(define_automaton "alu,fpu")
138*5780af82Smiod
139*5780af82Smiod(define_cpu_unit "alu" "alu")
140*5780af82Smiod(define_cpu_unit "fpu" "fpu")
141*5780af82Smiod
142*5780af82Smiod(define_insn_reservation "generic_alu" 1
143*5780af82Smiod (eq_attr "type" "!store,marith,weird")
144*5780af82Smiod "alu")
145*5780af82Smiod
146*5780af82Smiod(define_insn_reservation "generic_alu_2" 2
147*5780af82Smiod (eq_attr "type" "marith,weird")
148*5780af82Smiod "alu")
149*5780af82Smiod
150*5780af82Smiod; 88100 specific
151*5780af82Smiod
152*5780af82Smiod(define_insn_reservation "store_88100" 1
153*5780af82Smiod (and (eq_attr "cpu" "m88100")
154*5780af82Smiod      (eq_attr "type" "store,loada"))
155*5780af82Smiod "alu")
156*5780af82Smiod
157*5780af82Smiod(define_insn_reservation "load_88100" 3
158*5780af82Smiod (and (eq_attr "cpu" "m88100")
159*5780af82Smiod      (eq_attr "type" "load"))
160*5780af82Smiod "alu")
161*5780af82Smiod
162*5780af82Smiod(define_insn_reservation "loadd_88100" 3
163*5780af82Smiod (and (eq_attr "cpu" "m88100")
164*5780af82Smiod      (eq_attr "type" "loadd"))
165*5780af82Smiod "alu*2")
166*5780af82Smiod
167*5780af82Smiod; The times are adjusted to include fp1 and fplast, but then are further
168*5780af82Smiod; adjusted based on the actual generated code.  The notation to the right
169*5780af82Smiod; is the total latency.  A range denotes a group of instructions and/or
170*5780af82Smiod; conditions (the extra clock of fplast time with some sequences).
171*5780af82Smiod
172*5780af82Smiod(define_insn_reservation "spmul_88100" 4
173*5780af82Smiod (and (eq_attr "cpu" "m88100")
174*5780af82Smiod      (eq_attr "type" "spmul"))
175*5780af82Smiod "fpu")									; 6-8
176*5780af82Smiod(define_insn_reservation "dpmul_88100" 7
177*5780af82Smiod (and (eq_attr "cpu" "m88100")
178*5780af82Smiod      (eq_attr "type" "dpmul"))
179*5780af82Smiod "fpu")									; 9-10
180*5780af82Smiod(define_insn_reservation "imul_88100" 3
181*5780af82Smiod (and (eq_attr "cpu" "m88100")
182*5780af82Smiod      (eq_attr "type" "imul"))
183*5780af82Smiod "fpu")									; 4
184*5780af82Smiod
185*5780af82Smiod(define_insn_reservation "spdiv_88100" 30
186*5780af82Smiod (and (eq_attr "cpu" "m88100")
187*5780af82Smiod      (eq_attr "type" "spdiv"))
188*5780af82Smiod "fpu")									; 30-31
189*5780af82Smiod(define_insn_reservation "dpdiv_88100" 60
190*5780af82Smiod (and (eq_attr "cpu" "m88100")
191*5780af82Smiod      (eq_attr "type" "dpdiv"))
192*5780af82Smiod "fpu")									; 60-61
193*5780af82Smiod(define_insn_reservation "idiv_88100" 38
194*5780af82Smiod (and (eq_attr "cpu" "m88100")
195*5780af82Smiod      (eq_attr "type" "idiv"))
196*5780af82Smiod "fpu")									; 38
197*5780af82Smiod
198*5780af82Smiod(define_insn_reservation "spadd_88100" 3
199*5780af82Smiod (and (eq_attr "cpu" "m88100")
200*5780af82Smiod      (eq_attr "type" "spadd,spcmp"))
201*5780af82Smiod "fpu")									; 5-6
202*5780af82Smiod(define_insn_reservation "dpadd_88100" 4
203*5780af82Smiod (and (eq_attr "cpu" "m88100")
204*5780af82Smiod      (eq_attr "type" "dpadd,dpcmp"))
205*5780af82Smiod "fpu")									; 6-7
206*5780af82Smiod
207*5780af82Smiod; 88110 specific
208*5780af82Smiod
209*5780af82Smiod(define_insn_reservation "alu_88110" 2
210*5780af82Smiod (and (eq_attr "cpu" "!m88100")
211*5780af82Smiod      (eq_attr "type" "loada,arith,mov"))
212*5780af82Smiod "alu")
213*5780af82Smiod(define_insn_reservation "arith_88110" 4
214*5780af82Smiod (and (eq_attr "cpu" "!m88100")
215*5780af82Smiod      (eq_attr "type" "marith,weird"))
216*5780af82Smiod "alu")
217*5780af82Smiod
218*5780af82Smiod(define_insn_reservation "bit_88110" 2
219*5780af82Smiod (and (eq_attr "cpu" "!m88100")
220*5780af82Smiod      (eq_attr "type" "bit"))
221*5780af82Smiod "alu*2")
222*5780af82Smiod
223*5780af82Smiod(define_insn_reservation "load_88110" 3
224*5780af82Smiod (and (eq_attr "cpu" "!m88100")
225*5780af82Smiod      (eq_attr "type" "load,loadd"))
226*5780af82Smiod "alu*2")
227*5780af82Smiod(define_insn_reservation "store_88110" 1
228*5780af82Smiod (and (eq_attr "cpu" "!m88100")
229*5780af82Smiod      (eq_attr "type" "store"))
230*5780af82Smiod "alu*2")
231*5780af82Smiod
232*5780af82Smiod(define_insn_reservation "spdiv_88110" 25
233*5780af82Smiod (and (eq_attr "cpu" "!m88100")
234*5780af82Smiod      (eq_attr "type" "spdiv"))
235*5780af82Smiod "fpu*2")								; 13
236*5780af82Smiod(define_insn_reservation "dpdiv_88110" 45
237*5780af82Smiod (and (eq_attr "cpu" "!m88100")
238*5780af82Smiod      (eq_attr "type" "dpdiv"))
239*5780af82Smiod "fpu*2")								; 23
240*5780af82Smiod(define_insn_reservation "idiv_88110" 35
241*5780af82Smiod (and (eq_attr "cpu" "!m88100")
242*5780af82Smiod      (eq_attr "type" "idiv"))
243*5780af82Smiod "fpu*2")								; 18
244*5780af82Smiod
245*5780af82Smiod(define_insn_reservation "mul_88110" 5
246*5780af82Smiod (and (eq_attr "cpu" "!m88100")
247*5780af82Smiod      (eq_attr "type" "imul,spmul,dpmul"))
248*5780af82Smiod "fpu*2")								; 3
249*5780af82Smiod
250*5780af82Smiod(define_insn_reservation "fpadd_88110" 5
251*5780af82Smiod (and (eq_attr "cpu" "!m88100")
252*5780af82Smiod      (eq_attr "type" "spadd,dpadd"))
253*5780af82Smiod "fpu*2")								; 3
254*5780af82Smiod(define_insn_reservation "fpcmp_88110" 2
255*5780af82Smiod (and (eq_attr "cpu" "!m88100")
256*5780af82Smiod      (eq_attr "type" "spcmp,dpcmp"))
257*5780af82Smiod "fpu*2")								; 1
258*5780af82Smiod
2591f5e8f30Smiod;; Superoptimizer sequences
2601f5e8f30Smiod
2611f5e8f30Smiod;; geu+: { r = ((unsigned_word) v0 >= (unsigned_word) v1) + v2; }
2621f5e8f30Smiod;;      subu.co r5,r2,r3
2631f5e8f30Smiod;;      addu.cio r6,r4,r0
2641f5e8f30Smiod
2651f5e8f30Smiod(define_split
2661f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
2671f5e8f30Smiod	(minus:SI (match_operand:SI 1 "register_operand" "")
2681f5e8f30Smiod		  (geu:SI (match_operand:SI 2 "register_operand" "")
2691f5e8f30Smiod			  (match_operand:SI 3 "register_operand" ""))))]
2701f5e8f30Smiod  "GET_CODE (operands[0]) == REG
2711f5e8f30Smiod   && GET_CODE (operands[1]) == REG
2721f5e8f30Smiod   && GET_CODE (operands[2]) == REG
2731f5e8f30Smiod   && GET_CODE (operands[3]) == REG"
2741f5e8f30Smiod  [(set (reg:CC 0) (unspec:CC [(match_dup 2) (match_dup 3)] 1))
2751f5e8f30Smiod   (set (match_dup 0)
2761f5e8f30Smiod	(plus:SI (match_dup 1)
2771f5e8f30Smiod		 (unspec:SI [(const_int 0)
2781f5e8f30Smiod			     (reg:CC 0)] 0)))]
2791f5e8f30Smiod  "")
2801f5e8f30Smiod
2811f5e8f30Smiod;; leu+: { r = ((unsigned_word) v0 <= (unsigned_word) v1) + v2; }
2821f5e8f30Smiod;;      subu.co r5,r3,r2
2831f5e8f30Smiod;;      addu.cio r6,r4,r0
2841f5e8f30Smiod
2851f5e8f30Smiod(define_split
2861f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
2871f5e8f30Smiod	(minus:SI (match_operand:SI 1 "register_operand" "")
2881f5e8f30Smiod		  (leu:SI (match_operand:SI 3 "register_operand" "")
2891f5e8f30Smiod			  (match_operand:SI 2 "register_operand" ""))))]
2901f5e8f30Smiod  "GET_CODE (operands[0]) == REG
2911f5e8f30Smiod   && GET_CODE (operands[1]) == REG
2921f5e8f30Smiod   && GET_CODE (operands[2]) == REG
2931f5e8f30Smiod   && GET_CODE (operands[3]) == REG"
2941f5e8f30Smiod  [(set (reg:CC 0) (unspec:CC [(match_dup 2) (match_dup 3)] 1))
2951f5e8f30Smiod   (set (match_dup 0)
2961f5e8f30Smiod	(plus:SI (match_dup 1)
2971f5e8f30Smiod		 (unspec:SI [(const_int 0)
2981f5e8f30Smiod			     (reg:CC 0)] 0)))]
2991f5e8f30Smiod  "")
3001f5e8f30Smiod
3011f5e8f30Smiod;; eq0+: { r = (v0 == 0) + v1; }
3021f5e8f30Smiod;;      subu.co r4,r0,r2
3031f5e8f30Smiod;;      addu.cio r5,r3,r0
3041f5e8f30Smiod
3051f5e8f30Smiod(define_split
3061f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
3071f5e8f30Smiod	(minus:SI (match_operand:SI 1 "register_operand" "")
3081f5e8f30Smiod		  (eq:SI (match_operand:SI 2 "register_operand" "")
3091f5e8f30Smiod			 (const_int 0))))]
3101f5e8f30Smiod  "GET_CODE (operands[0]) == REG
3111f5e8f30Smiod   && GET_CODE (operands[1]) == REG
3121f5e8f30Smiod   && GET_CODE (operands[2]) == REG"
3131f5e8f30Smiod  [(set (reg:CC 0) (unspec:CC [(const_int 0) (match_dup 2)] 1))
3141f5e8f30Smiod   (set (match_dup 0)
3151f5e8f30Smiod	(plus:SI (match_dup 1)
3161f5e8f30Smiod		 (unspec:SI [(const_int 0)
3171f5e8f30Smiod			     (reg:CC 0)] 0)))]
3181f5e8f30Smiod  "")
3191f5e8f30Smiod
3201f5e8f30Smiod;; ltu-:  { r = v2 - ((unsigned_word) v0 < (unsigned_word) v1); }
3211f5e8f30Smiod;;      subu.co r5,r2,r3
3221f5e8f30Smiod;;      subu.cio r6,r4,r0
3231f5e8f30Smiod
3241f5e8f30Smiod(define_split
3251f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
3261f5e8f30Smiod	(plus:SI (ltu:SI (match_operand:SI 2 "register_operand" "")
3271f5e8f30Smiod			 (match_operand:SI 3 "register_operand" ""))
3281f5e8f30Smiod		 (match_operand:SI 1 "register_operand" "")))]
3291f5e8f30Smiod  "GET_CODE (operands[0]) == REG
3301f5e8f30Smiod   && GET_CODE (operands[1]) == REG
3311f5e8f30Smiod   && GET_CODE (operands[2]) == REG
3321f5e8f30Smiod   && GET_CODE (operands[3]) == REG"
3331f5e8f30Smiod  [(set (reg:CC 0) (unspec:CC [(match_dup 2) (match_dup 3)] 1))
3341f5e8f30Smiod   (set (match_dup 0)
3351f5e8f30Smiod	(minus:SI (match_dup 1)
3361f5e8f30Smiod		  (unspec:SI [(const_int 0)
3371f5e8f30Smiod			      (reg:CC 0)] 1)))]
3381f5e8f30Smiod  "")
3391f5e8f30Smiod
3401f5e8f30Smiod;; gtu-: { r = v2 - ((unsigned_word) v0 > (unsigned_word) v1); }
3411f5e8f30Smiod;;      subu.co r5,r3,r2
3421f5e8f30Smiod;;      subu.cio r6,r4,r0
3431f5e8f30Smiod
3441f5e8f30Smiod(define_split
3451f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
3461f5e8f30Smiod	(plus:SI (gtu:SI (match_operand:SI 3 "register_operand" "")
3471f5e8f30Smiod			 (match_operand:SI 2 "register_operand" ""))
3481f5e8f30Smiod		 (match_operand:SI 1 "register_operand" "")))]
3491f5e8f30Smiod  "GET_CODE (operands[0]) == REG
3501f5e8f30Smiod   && GET_CODE (operands[1]) == REG
3511f5e8f30Smiod   && GET_CODE (operands[2]) == REG
3521f5e8f30Smiod   && GET_CODE (operands[3]) == REG"
3531f5e8f30Smiod  [(set (reg:CC 0) (unspec:CC [(match_dup 2) (match_dup 3)] 1))
3541f5e8f30Smiod   (set (match_dup 0)
3551f5e8f30Smiod	(minus:SI (match_dup 1)
3561f5e8f30Smiod		 (unspec:SI [(const_int 0)
3571f5e8f30Smiod			     (reg:CC 0)] 1)))]
3581f5e8f30Smiod  "")
3591f5e8f30Smiod
3601f5e8f30Smiod;; ne0-: { r = v1 - (v0 != 0); }
3611f5e8f30Smiod;;      subu.co r4,r0,r2
3621f5e8f30Smiod;;      subu.cio r5,r3,r0
3631f5e8f30Smiod
3641f5e8f30Smiod(define_split
3651f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
3661f5e8f30Smiod	(plus:SI (ne:SI (match_operand:SI 2 "register_operand" "")
3671f5e8f30Smiod			(const_int 0))
3681f5e8f30Smiod		 (match_operand:SI 1 "register_operand" "")))]
3691f5e8f30Smiod  "GET_CODE (operands[0]) == REG
3701f5e8f30Smiod   && GET_CODE (operands[1]) == REG
3711f5e8f30Smiod   && GET_CODE (operands[2]) == REG"
3721f5e8f30Smiod  [(set (reg:CC 0) (unspec:CC [(const_int 0) (match_dup 2)] 1))
3731f5e8f30Smiod   (set (match_dup 0)
3741f5e8f30Smiod	(minus:SI (match_dup 1)
3751f5e8f30Smiod		  (unspec:SI [(const_int 0)
3761f5e8f30Smiod			      (reg:CC 0)] 1)))]
3771f5e8f30Smiod  "")
3781f5e8f30Smiod
3791f5e8f30Smiod;; ges0-: { r = v1 - ((signed_word) v0 >= 0); }
3801f5e8f30Smiod;;	addu.co	r4,r2,r2
3811f5e8f30Smiod;;	subu.cio r5,r3,r0
3821f5e8f30Smiod
3831f5e8f30Smiod(define_split
3841f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
3851f5e8f30Smiod	(minus:SI (match_operand:SI 1 "register_operand" "")
3861f5e8f30Smiod		  (xor:SI (lshiftrt:SI
3871f5e8f30Smiod			   (match_operand:SI 2 "register_operand" "")
3881f5e8f30Smiod			   (const_int 31))
3891f5e8f30Smiod			  (const_int 1))))]
3901f5e8f30Smiod  "GET_CODE (operands[0]) == REG
3911f5e8f30Smiod   && GET_CODE (operands[1]) == REG
3921f5e8f30Smiod   && GET_CODE (operands[2]) == REG"
3931f5e8f30Smiod  [(set (reg:CC 0) (unspec:CC [(match_dup 2) (match_dup 2)] 0))
3941f5e8f30Smiod   (set (match_dup 0)
3951f5e8f30Smiod	(minus:SI (match_dup 1)
3961f5e8f30Smiod		  (unspec:SI [(const_int 0)
3971f5e8f30Smiod			      (reg:CC 0)] 1)))]
3981f5e8f30Smiod  "")
3991f5e8f30Smiod
4001f5e8f30Smiod;; This rich set of complex patterns are mostly due to Torbjorn Granlund
4011f5e8f30Smiod;; (tege@sics.se).  They've changed since then, so don't complain to him
4021f5e8f30Smiod;; if they don't work right.
4031f5e8f30Smiod
4041f5e8f30Smiod;; Regarding shifts, gen_lshlsi3 generates ASHIFT.  The gen functions
4051f5e8f30Smiod;; produce the necessary insns to support TARGET_*_LARGE_SHIFT, so nothing
4061f5e8f30Smiod;; special needs to be done here.
4071f5e8f30Smiod
4081f5e8f30Smiod;; Optimize possible cases of the set instruction.
4091f5e8f30Smiod
4101f5e8f30Smiod(define_insn ""
4111f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
4121f5e8f30Smiod        (ashift:SI (const_int -1)
4131f5e8f30Smiod       	    (match_operand:SI 1 "register_operand" "r")))]
4141f5e8f30Smiod  ""
4151f5e8f30Smiod  "set %0,%#r0,%1"
4161f5e8f30Smiod  [(set_attr "type" "bit")])
4171f5e8f30Smiod
4181f5e8f30Smiod(define_insn ""
4191f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
4201f5e8f30Smiod        (ior:SI (ashift:SI (const_int -1)
4211f5e8f30Smiod       		    (match_operand:SI 1 "register_operand" "r"))
4221f5e8f30Smiod       	 (match_operand:SI 2 "register_operand" "r")))]
4231f5e8f30Smiod  ""
4241f5e8f30Smiod  "set %0,%2,%1"
4251f5e8f30Smiod  [(set_attr "type" "bit")])
4261f5e8f30Smiod
4271f5e8f30Smiod(define_insn ""
4281f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
4291f5e8f30Smiod        (ior:SI (match_operand:SI 1 "register_operand" "r")
4301f5e8f30Smiod       	 (ashift:SI (const_int -1)
4311f5e8f30Smiod       		    (match_operand:SI 2 "register_operand" "r"))))]
4321f5e8f30Smiod  ""
4331f5e8f30Smiod  "set %0,%1,%2"
4341f5e8f30Smiod  [(set_attr "type" "bit")])
4351f5e8f30Smiod
4361f5e8f30Smiod;; Optimize possible cases of the mak instruction.
4371f5e8f30Smiod
4381f5e8f30Smiod(define_insn ""
4391f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
4401f5e8f30Smiod	(and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
4411f5e8f30Smiod			   (match_operand:SI 2 "int5_operand" ""))
4421f5e8f30Smiod		(match_operand:SI 3 "immediate_operand" "n")))]
4431f5e8f30Smiod  "mak_mask_p (INTVAL (operands[3]) >> INTVAL (operands[2]))"
4441f5e8f30Smiod{
4451f5e8f30Smiod  operands[4] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3])
4461f5e8f30Smiod					  >> INTVAL(operands[2]))));
4471f5e8f30Smiod  return "mak %0,%1,%4<%2>";
4481f5e8f30Smiod}
4491f5e8f30Smiod  [(set_attr "type" "bit")])
4501f5e8f30Smiod
4511f5e8f30Smiod;; Optimize possible cases of output_and.
4521f5e8f30Smiod
4531f5e8f30Smiod(define_insn ""
4541f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
4551f5e8f30Smiod	(ashift:SI (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
4561f5e8f30Smiod				    (match_operand:SI 2 "int5_operand" "")
4571f5e8f30Smiod				    (match_operand:SI 3 "int5_operand" ""))
4581f5e8f30Smiod		   (match_operand:SI 4 "int5_operand" "")))]
4591f5e8f30Smiod  "INTVAL (operands[2]) + INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
4601f5e8f30Smiod{
4611f5e8f30Smiod  operands[2]
4621f5e8f30Smiod    = GEN_INT (((1 << INTVAL (operands[2])) - 1) << INTVAL (operands[4]));
4631f5e8f30Smiod  return output_and (operands);
4641f5e8f30Smiod}
4651f5e8f30Smiod  [(set_attr "type" "marith")]) ; arith,bit,marith.  length is 1 or 2.
4661f5e8f30Smiod
4671f5e8f30Smiod;; Improve logical operations on compare words
4681f5e8f30Smiod;;
4691f5e8f30Smiod;; We define all logical operations on CCmode values to preserve the pairwise
4701f5e8f30Smiod;; relationship of the compare bits.  This allows a future branch prediction
4711f5e8f30Smiod;; pass the degree of freedom needed to change and/bb0-le into or/bb1-gt.
4721f5e8f30Smiod;; THIS IS CURRENTLY FALSE!
4731f5e8f30Smiod;;
4741f5e8f30Smiod;; Opportunities arise when conditional expressions using && and || are made
4751f5e8f30Smiod;; unconditional.  When these are used to branch, the sequence is
4761f5e8f30Smiod;; cmp/cmp/extu/extu/{and,or}/bcnd-{eq0,ne0}.  When these are used to create
4771f5e8f30Smiod;; a value, the sequence is cmp/cmp/extu/extu/{and,or} for 1 or 0 or
4781f5e8f30Smiod;; cmp/cmp/ext/ext/{and,or} for -1 or 0.
4791f5e8f30Smiod;;
4801f5e8f30Smiod;; When the extracted conditions are the same, the define_split patterns
4811f5e8f30Smiod;; below change extu/extu/{and,or} into {and,or}/extu.  If the reversed
4821f5e8f30Smiod;; conditions match, one compare word can be complemented, resulting in
4831f5e8f30Smiod;; {and.c,or.c}/extu.  These changes are done for ext/ext/{and,or} as well.
4841f5e8f30Smiod;; If the conditions don't line up, one can be rotated.  To keep the pairwise
4851f5e8f30Smiod;; relationship, it may be necessary to both rotate and complement.  Rotating
4861f5e8f30Smiod;; makes branching cheaper, but doesn't help (or hurt) creating a value, so
4871f5e8f30Smiod;; we don't do this for ext/ext/{and,or}.
4881f5e8f30Smiod;;
4891f5e8f30Smiod;; These changes result in the sequence extu/bcnd-{eq0,ne0} which is combined
4901f5e8f30Smiod;; into an alternate form of bb0 and bb1.
4911f5e8f30Smiod
4921f5e8f30Smiod(define_split
4931f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
4941f5e8f30Smiod	(ior:SI (neg:SI
4951f5e8f30Smiod		 (match_operator 1 "even_relop"
4961f5e8f30Smiod				 [(match_operand 2 "partial_ccmode_register_operand" "%r")
4971f5e8f30Smiod				  (const_int 0)]))
4981f5e8f30Smiod		(neg:SI
4991f5e8f30Smiod		 (match_operator 3 "relop"
5001f5e8f30Smiod				 [(match_operand 4 "partial_ccmode_register_operand" "r")
5011f5e8f30Smiod				  (const_int 0)]))))
5021f5e8f30Smiod   (clobber (match_operand:SI 5 "register_operand" ""))]
5031f5e8f30Smiod  "reload_completed
5041f5e8f30Smiod   && GET_CODE (operands[0]) == REG"
5051f5e8f30Smiod  [(set (match_dup 5)
5061f5e8f30Smiod	(ior:CCEVEN (match_dup 4)
5071f5e8f30Smiod		    (match_dup 2)))
5081f5e8f30Smiod   (set (match_dup 0)
5091f5e8f30Smiod	(neg:SI (match_op_dup 1 [(match_dup 5) (const_int 0)])))]
5101f5e8f30Smiod  "operands[5] = gen_rtx_SUBREG (CCEVENmode, operands[5], 0);
5111f5e8f30Smiod   if (GET_CODE (operands[1]) == GET_CODE (operands[3]))
5121f5e8f30Smiod     ; /* The conditions match.  */
5131f5e8f30Smiod   else if (GET_CODE (operands[1])
5141f5e8f30Smiod	    == reverse_condition (GET_CODE (operands[3])))
5151f5e8f30Smiod     /* Reverse the condition by complementing the compare word.  */
5161f5e8f30Smiod     operands[4] = gen_rtx_NOT (CCmode, operands[4]);
5171f5e8f30Smiod   else
5181f5e8f30Smiod     {
5191f5e8f30Smiod       /* Make the condition pairs line up by rotating the compare word.  */
5201f5e8f30Smiod       int cv1 = condition_value (operands[1]);
5211f5e8f30Smiod       int cv2 = condition_value (operands[3]);
5221f5e8f30Smiod
5231f5e8f30Smiod       operands[4] = gen_rtx_ROTATE (CCEVENmode, operands[4],
5241f5e8f30Smiod				     GEN_INT (((cv2 & ~1) - (cv1 & ~1))
5251f5e8f30Smiod					      & 0x1f));
5261f5e8f30Smiod       /* Reverse the condition if needed.  */
5271f5e8f30Smiod       if ((cv1 & 1) != (cv2 & 1))
5281f5e8f30Smiod	 operands[4] = gen_rtx_NOT (CCmode, operands[4]);
5291f5e8f30Smiod     }")
5301f5e8f30Smiod
5311f5e8f30Smiod(define_split
5321f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
5331f5e8f30Smiod	(ior:SI (neg:SI
5341f5e8f30Smiod		 (match_operator 1 "odd_relop"
5351f5e8f30Smiod				 [(match_operand 2 "partial_ccmode_register_operand" "%r")
5361f5e8f30Smiod				  (const_int 0)]))
5371f5e8f30Smiod		(neg:SI
5381f5e8f30Smiod		 (match_operator 3 "odd_relop"
5391f5e8f30Smiod				 [(match_operand 4 "partial_ccmode_register_operand" "r")
5401f5e8f30Smiod				  (const_int 0)]))))
5411f5e8f30Smiod   (clobber (match_operand:SI 5 "register_operand" ""))]
5421f5e8f30Smiod  "reload_completed
5431f5e8f30Smiod   && GET_CODE (operands[0]) == REG"
5441f5e8f30Smiod  [(set (match_dup 5)
5451f5e8f30Smiod	(and:CCEVEN (match_dup 4)
5461f5e8f30Smiod		    (match_dup 2)))
5471f5e8f30Smiod   (set (match_dup 0)
5481f5e8f30Smiod	(neg:SI (match_op_dup 1 [(match_dup 5) (const_int 0)])))]
5491f5e8f30Smiod  "operands[5] = gen_rtx_SUBREG (CCEVENmode, operands[5], 0);
5501f5e8f30Smiod   if (GET_CODE (operands[1]) == GET_CODE (operands[3]))
5511f5e8f30Smiod     ; /* The conditions match.  */
5521f5e8f30Smiod   else
5531f5e8f30Smiod     {
5541f5e8f30Smiod       /* Make the condition pairs line up by rotating the compare word.  */
5551f5e8f30Smiod       int cv1 = condition_value (operands[1]);
5561f5e8f30Smiod       int cv2 = condition_value (operands[3]);
5571f5e8f30Smiod
5581f5e8f30Smiod       operands[4] = gen_rtx_ROTATE (CCEVENmode, operands[4],
5591f5e8f30Smiod				     GEN_INT ((cv2 - cv1) & 0x1f));
5601f5e8f30Smiod     }")
5611f5e8f30Smiod
5621f5e8f30Smiod(define_split
5631f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
5641f5e8f30Smiod	(ior:SI (neg:SI
5651f5e8f30Smiod		 (match_operator 1 "odd_relop"
5661f5e8f30Smiod				 [(match_operand 2 "partial_ccmode_register_operand" "%r")
5671f5e8f30Smiod				  (const_int 0)]))
5681f5e8f30Smiod		(neg:SI
5691f5e8f30Smiod		 (match_operator 3 "even_relop"
5701f5e8f30Smiod				 [(match_operand 4 "partial_ccmode_register_operand" "r")
5711f5e8f30Smiod				  (const_int 0)]))))
5721f5e8f30Smiod   (clobber (match_operand:SI 5 "register_operand" ""))]
5731f5e8f30Smiod  "reload_completed
5741f5e8f30Smiod   && GET_CODE (operands[0]) == REG"
5751f5e8f30Smiod  [(set (match_dup 5)
5761f5e8f30Smiod	(ior:CCEVEN (not:CC (match_dup 2))
5771f5e8f30Smiod		    (match_dup 4)))
5781f5e8f30Smiod   (set (match_dup 0)
5791f5e8f30Smiod	(neg:SI (match_op_dup 3 [(match_dup 5) (const_int 0)])))]
5801f5e8f30Smiod  "operands[5] = gen_rtx_SUBREG (CCEVENmode, operands[5], 0);
5811f5e8f30Smiod  if (GET_CODE (operands[1])
5821f5e8f30Smiod	    == reverse_condition (GET_CODE (operands[3])))
5831f5e8f30Smiod     ;
5841f5e8f30Smiod   else
5851f5e8f30Smiod     {
5861f5e8f30Smiod       /* Make the condition pairs line up by rotating the compare word.  */
5871f5e8f30Smiod       int cv1 = condition_value (operands[1]);
5881f5e8f30Smiod       int cv2 = condition_value (operands[3]);
5891f5e8f30Smiod
5901f5e8f30Smiod       operands[2] = gen_rtx_ROTATE (CCEVENmode, operands[2],
5911f5e8f30Smiod				     GEN_INT (((cv1 & ~1) - (cv2 & ~1))
5921f5e8f30Smiod					      & 0x1f));
5931f5e8f30Smiod     }")
5941f5e8f30Smiod
5951f5e8f30Smiod(define_split
5961f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
5971f5e8f30Smiod	(ior:SI (match_operator 1 "even_relop"
5981f5e8f30Smiod				[(match_operand 2 "partial_ccmode_register_operand" "%r")
5991f5e8f30Smiod				 (const_int 0)])
6001f5e8f30Smiod		(match_operator 3 "relop"
6011f5e8f30Smiod				[(match_operand 4 "partial_ccmode_register_operand" "r")
6021f5e8f30Smiod				 (const_int 0)])))
6031f5e8f30Smiod   (clobber (match_operand:SI 5 "register_operand" ""))]
6041f5e8f30Smiod  "reload_completed
6051f5e8f30Smiod   && GET_CODE (operands[0]) == REG
6061f5e8f30Smiod   && (GET_CODE (operands[1]) == GET_CODE (operands[3])
6071f5e8f30Smiod       || GET_CODE (operands[1]) == reverse_condition (GET_CODE (operands[3])))"
6081f5e8f30Smiod  [(set (match_dup 5)
6091f5e8f30Smiod	(ior:CCEVEN (match_dup 4)
6101f5e8f30Smiod		    (match_dup 2)))
6111f5e8f30Smiod   (set (match_dup 0)
6121f5e8f30Smiod	(match_op_dup 1 [(match_dup 5) (const_int 0)]))]
6131f5e8f30Smiod  "operands[5] = gen_rtx_SUBREG (CCEVENmode, operands[5], 0);
6141f5e8f30Smiod   /* Reverse the condition by complementing the compare word.  */
6151f5e8f30Smiod   if (GET_CODE (operands[1]) != GET_CODE (operands[3]))
6161f5e8f30Smiod      operands[4] = gen_rtx_NOT (CCmode, operands[4]);")
6171f5e8f30Smiod
6181f5e8f30Smiod(define_split
6191f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
6201f5e8f30Smiod	(ior:SI (match_operator 1 "odd_relop"
6211f5e8f30Smiod				[(match_operand 2 "partial_ccmode_register_operand" "%r")
6221f5e8f30Smiod				 (const_int 0)])
6231f5e8f30Smiod		(match_operator 3 "odd_relop"
6241f5e8f30Smiod				[(match_operand 4 "partial_ccmode_register_operand" "r")
6251f5e8f30Smiod				 (const_int 0)])))
6261f5e8f30Smiod   (clobber (match_operand:SI 5 "register_operand" ""))]
6271f5e8f30Smiod  "reload_completed
6281f5e8f30Smiod   && GET_CODE (operands[0]) == REG
6291f5e8f30Smiod   && GET_CODE (operands[1]) == GET_CODE (operands[3])"
6301f5e8f30Smiod  [(set (match_dup 5)
6311f5e8f30Smiod	(and:CCEVEN (match_dup 4)
6321f5e8f30Smiod		    (match_dup 2)))
6331f5e8f30Smiod   (set (match_dup 0)
6341f5e8f30Smiod	(match_op_dup 1 [(match_dup 5) (const_int 0)]))]
6351f5e8f30Smiod  "operands[5] = gen_rtx_SUBREG (CCEVENmode, operands[5], 0);")
6361f5e8f30Smiod
6371f5e8f30Smiod(define_split
6381f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
6391f5e8f30Smiod	(ior:SI (match_operator 1 "odd_relop"
6401f5e8f30Smiod				[(match_operand 2 "partial_ccmode_register_operand" "%r")
6411f5e8f30Smiod				 (const_int 0)])
6421f5e8f30Smiod		(match_operator 3 "even_relop"
6431f5e8f30Smiod				[(match_operand 4 "partial_ccmode_register_operand" "r")
6441f5e8f30Smiod				 (const_int 0)])))
6451f5e8f30Smiod   (clobber (match_operand:SI 5 "register_operand" ""))]
6461f5e8f30Smiod  "reload_completed
6471f5e8f30Smiod   && GET_CODE (operands[0]) == REG
6481f5e8f30Smiod   && GET_CODE (operands[1]) == reverse_condition (GET_CODE (operands[3]))"
6491f5e8f30Smiod  [(set (match_dup 5)
6501f5e8f30Smiod	(ior:CCEVEN (not:CC (match_dup 4))
6511f5e8f30Smiod		    (match_dup 2)))
6521f5e8f30Smiod   (set (match_dup 0)
6531f5e8f30Smiod	(match_op_dup 1 [(match_dup 5) (const_int 0)]))]
6541f5e8f30Smiod  "operands[5] = gen_rtx_SUBREG (CCEVENmode, operands[5], 0);")
6551f5e8f30Smiod
6561f5e8f30Smiod(define_split
6571f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
6581f5e8f30Smiod	(and:SI (neg:SI
6591f5e8f30Smiod		 (match_operator 1 "even_relop"
6601f5e8f30Smiod				 [(match_operand 2 "partial_ccmode_register_operand" "%r")
6611f5e8f30Smiod				  (const_int 0)]))
6621f5e8f30Smiod		(neg:SI
6631f5e8f30Smiod		 (match_operator 3 "relop"
6641f5e8f30Smiod				 [(match_operand 4 "partial_ccmode_register_operand" "r")
6651f5e8f30Smiod				  (const_int 0)]))))
6661f5e8f30Smiod   (clobber (match_operand:SI 5 "register_operand" ""))]
6671f5e8f30Smiod  "reload_completed
6681f5e8f30Smiod   && GET_CODE (operands[0]) == REG"
6691f5e8f30Smiod  [(set (match_dup 5)
6701f5e8f30Smiod	(and:CCEVEN (match_dup 4)
6711f5e8f30Smiod		    (match_dup 2)))
6721f5e8f30Smiod   (set (match_dup 0)
6731f5e8f30Smiod	(neg:SI (match_op_dup 1 [(match_dup 5) (const_int 0)])))]
6741f5e8f30Smiod  "operands[5] = gen_rtx_SUBREG (CCEVENmode, operands[5], 0);
6751f5e8f30Smiod   if (GET_CODE (operands[1]) == GET_CODE (operands[3]))
6761f5e8f30Smiod     ; /* The conditions match.  */
6771f5e8f30Smiod   else if (GET_CODE (operands[1])
6781f5e8f30Smiod	    == reverse_condition (GET_CODE (operands[3])))
6791f5e8f30Smiod     /* Reverse the condition by complementing the compare word.  */
6801f5e8f30Smiod     operands[4] = gen_rtx_NOT (CCmode, operands[4]);
6811f5e8f30Smiod   else
6821f5e8f30Smiod     {
6831f5e8f30Smiod       /* Make the condition pairs line up by rotating the compare word.  */
6841f5e8f30Smiod       int cv1 = condition_value (operands[1]);
6851f5e8f30Smiod       int cv2 = condition_value (operands[3]);
6861f5e8f30Smiod       operands[4] = gen_rtx_ROTATE (CCmode, operands[4],
6871f5e8f30Smiod				     GEN_INT (((cv2 & ~1) - (cv1 & ~1))
6881f5e8f30Smiod					      & 0x1f));
6891f5e8f30Smiod       /* Reverse the condition if needed.  */
6901f5e8f30Smiod       if ((cv1 & 1) != (cv2 & 1))
6911f5e8f30Smiod	 operands[4] = gen_rtx_NOT (CCmode, operands[4]);
6921f5e8f30Smiod     }")
6931f5e8f30Smiod
6941f5e8f30Smiod(define_split
6951f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
6961f5e8f30Smiod	(and:SI (neg:SI
6971f5e8f30Smiod		 (match_operator 1 "odd_relop"
6981f5e8f30Smiod				 [(match_operand 2 "partial_ccmode_register_operand" "%r")
6991f5e8f30Smiod				  (const_int 0)]))
7001f5e8f30Smiod		(neg:SI
7011f5e8f30Smiod		 (match_operator 3 "odd_relop"
7021f5e8f30Smiod				 [(match_operand 4 "partial_ccmode_register_operand" "r")
7031f5e8f30Smiod				  (const_int 0)]))))
7041f5e8f30Smiod   (clobber (match_operand:SI 5 "register_operand" ""))]
7051f5e8f30Smiod  "reload_completed
7061f5e8f30Smiod   && GET_CODE (operands[0]) == REG"
7071f5e8f30Smiod  [(set (match_dup 5)
7081f5e8f30Smiod	(ior:CCEVEN (match_dup 4)
7091f5e8f30Smiod		    (match_dup 2)))
7101f5e8f30Smiod   (set (match_dup 0)
7111f5e8f30Smiod	(neg:SI (match_op_dup 1 [(match_dup 5) (const_int 0)])))]
7121f5e8f30Smiod  "operands[5] = gen_rtx_SUBREG (CCEVENmode, operands[5], 0);
7131f5e8f30Smiod   if (GET_CODE (operands[1]) == GET_CODE (operands[3]))
7141f5e8f30Smiod     ; /* The conditions match.  */
7151f5e8f30Smiod   else
7161f5e8f30Smiod     {
7171f5e8f30Smiod       /* Make the condition pairs line up by rotating the compare word.  */
7181f5e8f30Smiod       int cv1 = condition_value (operands[1]);
7191f5e8f30Smiod       int cv2 = condition_value (operands[3]);
7201f5e8f30Smiod       operands[4] = gen_rtx_ROTATE (CCEVENmode, operands[4],
7211f5e8f30Smiod				     GEN_INT ((cv2 - cv1) & 0x1f));
7221f5e8f30Smiod     }")
7231f5e8f30Smiod
7241f5e8f30Smiod(define_split
7251f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
7261f5e8f30Smiod	(and:SI (neg:SI
7271f5e8f30Smiod		 (match_operator 1 "odd_relop"
7281f5e8f30Smiod				 [(match_operand 2 "partial_ccmode_register_operand" "%r")
7291f5e8f30Smiod				  (const_int 0)]))
7301f5e8f30Smiod		(neg:SI
7311f5e8f30Smiod		 (match_operator 3 "even_relop"
7321f5e8f30Smiod				 [(match_operand 4 "partial_ccmode_register_operand" "r")
7331f5e8f30Smiod				  (const_int 0)]))))
7341f5e8f30Smiod   (clobber (match_operand:SI 5 "register_operand" ""))]
7351f5e8f30Smiod  "reload_completed
7361f5e8f30Smiod   && GET_CODE (operands[0]) == REG"
7371f5e8f30Smiod  [(set (match_dup 5)
7381f5e8f30Smiod	(and:CCEVEN (not:CC (match_dup 2))
7391f5e8f30Smiod		    (match_dup 4)))
7401f5e8f30Smiod   (set (match_dup 0)
7411f5e8f30Smiod	(neg:SI (match_op_dup 3 [(match_dup 5) (const_int 0)])))]
7421f5e8f30Smiod  "operands[5] = gen_rtx_SUBREG (CCEVENmode, operands[5], 0);
7431f5e8f30Smiod   if (GET_CODE (operands[1])
7441f5e8f30Smiod	    == reverse_condition (GET_CODE (operands[3])))
7451f5e8f30Smiod	;
7461f5e8f30Smiod   else
7471f5e8f30Smiod     {
7481f5e8f30Smiod       /* Make the condition pairs line up by rotating the compare word.  */
7491f5e8f30Smiod       int cv1 = condition_value (operands[1]);
7501f5e8f30Smiod       int cv2 = condition_value (operands[3]);
7511f5e8f30Smiod       operands[2] = gen_rtx_ROTATE (CCEVENmode, operands[2],
7521f5e8f30Smiod				     GEN_INT (((cv1 & ~1) - (cv2 & ~1))
7531f5e8f30Smiod					      & 0x1f));
7541f5e8f30Smiod     }")
7551f5e8f30Smiod
7561f5e8f30Smiod(define_split
7571f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
7581f5e8f30Smiod	(and:SI (match_operator 1 "even_relop"
7591f5e8f30Smiod				[(match_operand 2 "partial_ccmode_register_operand" "%r")
7601f5e8f30Smiod				 (const_int 0)])
7611f5e8f30Smiod		(match_operator 3 "relop"
7621f5e8f30Smiod				[(match_operand 4 "partial_ccmode_register_operand" "r")
7631f5e8f30Smiod				 (const_int 0)])))
7641f5e8f30Smiod   (clobber (match_operand:SI 5 "register_operand" ""))]
7651f5e8f30Smiod  "reload_completed
7661f5e8f30Smiod   && GET_CODE (operands[0]) == REG
7671f5e8f30Smiod   && (GET_CODE (operands[1]) == GET_CODE (operands[3])
7681f5e8f30Smiod       || GET_CODE (operands[1]) == reverse_condition (GET_CODE (operands[3])))"
7691f5e8f30Smiod  [(set (match_dup 5)
7701f5e8f30Smiod	(and:CCEVEN (match_dup 4)
7711f5e8f30Smiod		    (match_dup 2)))
7721f5e8f30Smiod   (set (match_dup 0)
7731f5e8f30Smiod	(match_op_dup 1 [(match_dup 5) (const_int 0)]))]
7741f5e8f30Smiod  "operands[5] = gen_rtx_SUBREG (CCEVENmode, operands[5], 0);
7751f5e8f30Smiod   /* Reverse the condition by complementing the compare word.  */
7761f5e8f30Smiod   if (GET_CODE (operands[1]) != GET_CODE (operands[3]))
7771f5e8f30Smiod      operands[4] = gen_rtx_NOT (CCmode, operands[4]);")
7781f5e8f30Smiod
7791f5e8f30Smiod(define_split
7801f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
7811f5e8f30Smiod	(and:SI (match_operator 1 "odd_relop"
7821f5e8f30Smiod				[(match_operand 2 "partial_ccmode_register_operand" "%r")
7831f5e8f30Smiod				 (const_int 0)])
7841f5e8f30Smiod		(match_operator 3 "odd_relop"
7851f5e8f30Smiod				[(match_operand 4 "partial_ccmode_register_operand" "r")
7861f5e8f30Smiod				 (const_int 0)])))
7871f5e8f30Smiod   (clobber (match_operand:SI 5 "register_operand" ""))]
7881f5e8f30Smiod  "reload_completed
7891f5e8f30Smiod   && GET_CODE (operands[0]) == REG
7901f5e8f30Smiod   && GET_CODE (operands[1]) == GET_CODE (operands[3])"
7911f5e8f30Smiod  [(set (match_dup 5)
7921f5e8f30Smiod	(ior:CCEVEN (match_dup 4)
7931f5e8f30Smiod		    (match_dup 2)))
7941f5e8f30Smiod   (set (match_dup 0)
7951f5e8f30Smiod	(match_op_dup 1 [(match_dup 5) (const_int 0)]))]
7961f5e8f30Smiod  "operands[5] = gen_rtx_SUBREG (CCEVENmode, operands[5], 0);")
7971f5e8f30Smiod
7981f5e8f30Smiod(define_split
7991f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
8001f5e8f30Smiod	(and:SI (match_operator 1 "odd_relop"
8011f5e8f30Smiod				[(match_operand 2 "partial_ccmode_register_operand" "%r")
8021f5e8f30Smiod				 (const_int 0)])
8031f5e8f30Smiod		(match_operator 3 "even_relop"
8041f5e8f30Smiod				[(match_operand 4 "partial_ccmode_register_operand" "r")
8051f5e8f30Smiod				 (const_int 0)])))
8061f5e8f30Smiod   (clobber (match_operand:SI 5 "register_operand" ""))]
8071f5e8f30Smiod  "reload_completed
8081f5e8f30Smiod   && GET_CODE (operands[0]) == REG
8091f5e8f30Smiod   && GET_CODE (operands[1]) == reverse_condition (GET_CODE (operands[3]))"
8101f5e8f30Smiod  [(set (match_dup 5)
8111f5e8f30Smiod	(and:CCEVEN (not:CC (match_dup 2))
8121f5e8f30Smiod		    (match_dup 4)))
8131f5e8f30Smiod   (set (match_dup 0)
8141f5e8f30Smiod	(match_op_dup 3 [(match_dup 5) (const_int 0)]))]
8151f5e8f30Smiod  "operands[5] = gen_rtx_SUBREG (CCEVENmode, operands[5], 0);")
8161f5e8f30Smiod
8171f5e8f30Smiod
8181f5e8f30Smiod;; Logical operations on compare words.
8191f5e8f30Smiod
8201f5e8f30Smiod(define_insn ""
8211f5e8f30Smiod  [(set (match_operand:CCEVEN 0 "register_operand" "=r")
8221f5e8f30Smiod	(and:CCEVEN (not:CC (match_operand 1 "partial_ccmode_register_operand" "r"))
8231f5e8f30Smiod		    (match_operand 2 "partial_ccmode_register_operand" "r")))]
8241f5e8f30Smiod  ""
8251f5e8f30Smiod  "and.c %0,%2,%1")
8261f5e8f30Smiod
8271f5e8f30Smiod(define_insn ""
8281f5e8f30Smiod  [(set (match_operand:CCEVEN 0 "register_operand" "=r")
8291f5e8f30Smiod	(and:CCEVEN (match_operand 1 "partial_ccmode_register_operand" "%r")
8301f5e8f30Smiod		    (match_operand 2 "partial_ccmode_register_operand" "r")))]
8311f5e8f30Smiod  ""
8321f5e8f30Smiod  "and %0,%1,%2")
8331f5e8f30Smiod
8341f5e8f30Smiod(define_insn ""
8351f5e8f30Smiod  [(set (match_operand:CCEVEN 0 "register_operand" "=r")
8361f5e8f30Smiod	(ior:CCEVEN (not:CC (match_operand 1 "partial_ccmode_register_operand" "r"))
8371f5e8f30Smiod		    (match_operand 2 "partial_ccmode_register_operand" "r")))]
8381f5e8f30Smiod  ""
8391f5e8f30Smiod  "or.c %0,%2,%1")
8401f5e8f30Smiod
8411f5e8f30Smiod(define_insn ""
8421f5e8f30Smiod  [(set (match_operand:CCEVEN 0 "register_operand" "=r")
8431f5e8f30Smiod	(ior:CCEVEN (match_operand 1 "partial_ccmode_register_operand" "%r")
8441f5e8f30Smiod		    (match_operand 2 "partial_ccmode_register_operand" "r")))]
8451f5e8f30Smiod  ""
8461f5e8f30Smiod  "or %0,%1,%2")
8471f5e8f30Smiod
8481f5e8f30Smiod(define_insn ""
8491f5e8f30Smiod  [(set (match_operand:CC 0 "register_operand" "=r")
8501f5e8f30Smiod	(rotate:CC (match_operand:CC 1 "register_operand" "r")
8511f5e8f30Smiod		   (match_operand:CC 2 "int5_operand" "")))]
8521f5e8f30Smiod  ""
8531f5e8f30Smiod  "rot %0,%1,%2"
8541f5e8f30Smiod  [(set_attr "type" "bit")])
8551f5e8f30Smiod
8561f5e8f30Smiod(define_insn ""
8571f5e8f30Smiod  [(set (match_operand:CCEVEN 0 "register_operand" "=r")
8581f5e8f30Smiod	(rotate:CCEVEN (match_operand 1 "partial_ccmode_register_operand" "r")
8591f5e8f30Smiod		       (match_operand:CC 2 "int5_operand" "")))]
8601f5e8f30Smiod  ""
8611f5e8f30Smiod  "rot %0,%1,%2"
8621f5e8f30Smiod  [(set_attr "type" "bit")])
8631f5e8f30Smiod
8641f5e8f30Smiod;; rotate/and[.c] and rotate/ior[.c]
8651f5e8f30Smiod
8661f5e8f30Smiod(define_split
8671f5e8f30Smiod  [(set (match_operand:CCEVEN 0 "register_operand" "")
8681f5e8f30Smiod	(ior:CCEVEN (rotate:CC (match_operand 1 "partial_ccmode_register_operand" "")
8691f5e8f30Smiod			       (match_operand:CC 2 "int5_operand" ""))
8701f5e8f30Smiod		    (match_operand 3 "partial_ccmode_register_operand" "")))
8711f5e8f30Smiod   (clobber (match_operand:CCEVEN 4 "register_operand" ""))]
8721f5e8f30Smiod  "reload_completed
8731f5e8f30Smiod   && GET_CODE (operands[0]) == REG
8741f5e8f30Smiod   && partial_ccmode_register_operand (operands[1], VOIDmode)
8751f5e8f30Smiod   && partial_ccmode_register_operand (operands[3], VOIDmode)"
8761f5e8f30Smiod  [(set (match_dup 4)
8771f5e8f30Smiod	(rotate:CC (match_dup 1) (match_dup 2)))
8781f5e8f30Smiod   (set (match_dup 0)
8791f5e8f30Smiod	(ior:CCEVEN (match_dup 4) (match_dup 3)))]
8801f5e8f30Smiod  "")
8811f5e8f30Smiod
8821f5e8f30Smiod(define_insn ""
8831f5e8f30Smiod  [(set (match_operand:CCEVEN 0 "register_operand" "=r")
8841f5e8f30Smiod	(ior:CCEVEN (rotate:CC (match_operand 1 "partial_ccmode_register_operand" "r")
8851f5e8f30Smiod			       (match_operand:CC 2 "int5_operand" ""))
8861f5e8f30Smiod		(match_operand 3 "partial_ccmode_register_operand" "r")))
8871f5e8f30Smiod   (clobber (match_scratch:CCEVEN 4 "=r"))]
8881f5e8f30Smiod  ""
8891f5e8f30Smiod  "#")
8901f5e8f30Smiod
8911f5e8f30Smiod(define_split
8921f5e8f30Smiod  [(set (match_operand:CCEVEN 0 "register_operand" "")
8931f5e8f30Smiod	(ior:CCEVEN (not:CC (rotate:CC (match_operand 1 "partial_ccmode_register_operand" "")
8941f5e8f30Smiod				       (match_operand:CC 2 "int5_operand" "")))
8951f5e8f30Smiod		(match_operand 3 "partial_ccmode_register_operand" "")))
8961f5e8f30Smiod   (clobber (match_operand:CCEVEN 4 "register_operand" ""))]
8971f5e8f30Smiod  "reload_completed
8981f5e8f30Smiod   && GET_CODE (operands[0]) == REG
8991f5e8f30Smiod   && partial_ccmode_register_operand (operands[1], VOIDmode)
9001f5e8f30Smiod   && partial_ccmode_register_operand (operands[3], VOIDmode)"
9011f5e8f30Smiod  [(set (match_dup 4)
9021f5e8f30Smiod	(rotate:CC (match_dup 1) (match_dup 2)))
9031f5e8f30Smiod   (set (match_dup 0)
9041f5e8f30Smiod	(ior:CCEVEN (not:CC (match_dup 4)) (match_dup 3)))]
9051f5e8f30Smiod  "")
9061f5e8f30Smiod
9071f5e8f30Smiod(define_insn ""
9081f5e8f30Smiod  [(set (match_operand:CCEVEN 0 "register_operand" "=r")
9091f5e8f30Smiod	(ior:CCEVEN (not:CC (rotate:CC (match_operand 1 "partial_ccmode_register_operand" "r")
9101f5e8f30Smiod				       (match_operand:CC 2 "int5_operand" "")))
9111f5e8f30Smiod		(match_operand 3 "partial_ccmode_register_operand" "r")))
9121f5e8f30Smiod   (clobber (match_scratch:CCEVEN 4 "=r"))]
9131f5e8f30Smiod  ""
9141f5e8f30Smiod  "#")
9151f5e8f30Smiod
9161f5e8f30Smiod(define_split
9171f5e8f30Smiod  [(set (match_operand:CCEVEN 0 "register_operand" "")
9181f5e8f30Smiod	(and:CCEVEN (rotate:CC (match_operand 1 "partial_ccmode_register_operand" "")
9191f5e8f30Smiod			       (match_operand:CC 2 "int5_operand" ""))
9201f5e8f30Smiod		(match_operand 3 "partial_ccmode_register_operand" "")))
9211f5e8f30Smiod   (clobber (match_operand:CCEVEN 4 "register_operand" ""))]
9221f5e8f30Smiod  "reload_completed
9231f5e8f30Smiod   && GET_CODE (operands[0]) == REG
9241f5e8f30Smiod   && partial_ccmode_register_operand (operands[1], VOIDmode)
9251f5e8f30Smiod   && partial_ccmode_register_operand (operands[3], VOIDmode)"
9261f5e8f30Smiod  [(set (match_dup 4)
9271f5e8f30Smiod	(rotate:CC (match_dup 1) (match_dup 2)))
9281f5e8f30Smiod   (set (match_dup 0)
9291f5e8f30Smiod	(and:CCEVEN (match_dup 4) (match_dup 3)))]
9301f5e8f30Smiod  "")
9311f5e8f30Smiod
9321f5e8f30Smiod(define_insn ""
9331f5e8f30Smiod  [(set (match_operand:CCEVEN 0 "register_operand" "=r")
9341f5e8f30Smiod	(and:CCEVEN (rotate:CC (match_operand 1 "partial_ccmode_register_operand" "r")
9351f5e8f30Smiod			       (match_operand:CC 2 "int5_operand" ""))
9361f5e8f30Smiod		(match_operand 3 "partial_ccmode_register_operand" "r")))
9371f5e8f30Smiod   (clobber (match_scratch:CCEVEN 4 "=r"))]
9381f5e8f30Smiod  ""
9391f5e8f30Smiod  "#")
9401f5e8f30Smiod
9411f5e8f30Smiod(define_split
9421f5e8f30Smiod  [(set (match_operand:CCEVEN 0 "register_operand" "")
9431f5e8f30Smiod	(and:CCEVEN (not:CC (rotate:CC (match_operand 1 "partial_ccmode_register_operand" "")
9441f5e8f30Smiod				       (match_operand:CC 2 "int5_operand" "")))
9451f5e8f30Smiod		(match_operand 3 "partial_ccmode_register_operand" "")))
9461f5e8f30Smiod   (clobber (match_operand:CCEVEN 4 "register_operand" ""))]
9471f5e8f30Smiod  "reload_completed
9481f5e8f30Smiod   && GET_CODE (operands[0]) == REG
9491f5e8f30Smiod   && partial_ccmode_register_operand (operands[1], VOIDmode)
9501f5e8f30Smiod   && partial_ccmode_register_operand (operands[3], VOIDmode)"
9511f5e8f30Smiod  [(set (match_dup 4)
9521f5e8f30Smiod	(rotate:CC (match_dup 1) (match_dup 2)))
9531f5e8f30Smiod   (set (match_dup 0)
9541f5e8f30Smiod	(and:CCEVEN (not:CC (match_dup 4)) (match_dup 3)))]
9551f5e8f30Smiod  "")
9561f5e8f30Smiod
9571f5e8f30Smiod(define_insn ""
9581f5e8f30Smiod  [(set (match_operand:CCEVEN 0 "register_operand" "=r")
9591f5e8f30Smiod	(and:CCEVEN (not:CC (rotate:CC (match_operand 1 "partial_ccmode_register_operand" "r")
9601f5e8f30Smiod				       (match_operand:CC 2 "int5_operand" "")))
9611f5e8f30Smiod		(match_operand 3 "partial_ccmode_register_operand" "r")))
9621f5e8f30Smiod   (clobber (match_scratch:CCEVEN 4 "=r"))]
9631f5e8f30Smiod  ""
9641f5e8f30Smiod  "#")
9651f5e8f30Smiod
9661f5e8f30Smiod
9671f5e8f30Smiod;; Recognize bcnd instructions for integer values.  This is distinguished
9681f5e8f30Smiod;; from a conditional branch instruction (below) with SImode instead of
9691f5e8f30Smiod;; CCmode.
9701f5e8f30Smiod
9711f5e8f30Smiod(define_insn ""
9721f5e8f30Smiod  [(set (pc)
9731f5e8f30Smiod	(if_then_else
9741f5e8f30Smiod	 (match_operator 0 "relop_no_unsigned"
9751f5e8f30Smiod			 [(match_operand:SI 1 "register_operand" "r")
9761f5e8f30Smiod			  (const_int 0)])
9771f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
9781f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
9791f5e8f30Smiod  ""
9801f5e8f30Smiod  "bcnd%. %R3%B0,%1,%P2%P3"
9811f5e8f30Smiod  [(set_attr "type" "branch")])
9821f5e8f30Smiod
9831f5e8f30Smiod;; Recognize tests for sign and zero.
9841f5e8f30Smiod
9851f5e8f30Smiod(define_insn ""
9861f5e8f30Smiod  [(set (pc)
9871f5e8f30Smiod	(if_then_else
9881f5e8f30Smiod	 (match_operator 0 "equality_op"
9891f5e8f30Smiod			 [(match_operand:SI 1 "register_operand" "r")
9901f5e8f30Smiod			  (const_int -2147483648)])
9911f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
9921f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
9931f5e8f30Smiod  ""
9941f5e8f30Smiod  "bcnd%. %R3%E0,%1,%P2%P3"
9951f5e8f30Smiod  [(set_attr "type" "branch")])
9961f5e8f30Smiod
9971f5e8f30Smiod(define_insn ""
9981f5e8f30Smiod  [(set (pc)
9991f5e8f30Smiod	(if_then_else
10001f5e8f30Smiod	 (match_operator 0 "equality_op"
10011f5e8f30Smiod			 [(zero_extract:SI
10021f5e8f30Smiod			   (match_operand:SI 1 "register_operand" "r")
10031f5e8f30Smiod			   (const_int 31)
10041f5e8f30Smiod			   (const_int 1))
10051f5e8f30Smiod			  (const_int 0)])
10061f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
10071f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
10081f5e8f30Smiod  ""
10091f5e8f30Smiod  "bcnd%. %R3%D0,%1,%P2%P3"
10101f5e8f30Smiod  [(set_attr "type" "branch")])
10111f5e8f30Smiod
10121f5e8f30Smiod;; Recognize bcnd instructions for double integer values
10131f5e8f30Smiod
10141f5e8f30Smiod(define_insn ""
10151f5e8f30Smiod  [(set (pc)
10161f5e8f30Smiod	(if_then_else
10171f5e8f30Smiod	 (match_operator 0 "relop_no_unsigned"
10181f5e8f30Smiod			 [(sign_extend:DI
10191f5e8f30Smiod			   (match_operand:SI 1 "register_operand" "r"))
10201f5e8f30Smiod			  (const_int 0)])
10211f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
10221f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
10231f5e8f30Smiod  ""
10241f5e8f30Smiod  "bcnd%. %R3%B0,%1,%P2%P3"
10251f5e8f30Smiod  [(set_attr "type" "branch")])
10261f5e8f30Smiod
10271f5e8f30Smiod(define_insn ""
10281f5e8f30Smiod  [(set (pc)
10291f5e8f30Smiod	(if_then_else
10301f5e8f30Smiod	 (match_operator 0 "equality_op"
10311f5e8f30Smiod			 [(zero_extend:DI
10321f5e8f30Smiod			   (match_operand:SI 1 "register_operand" "r"))
10331f5e8f30Smiod			  (const_int 0)])
10341f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
10351f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
10361f5e8f30Smiod  ""
10371f5e8f30Smiod  "bcnd%. %R3%B0,%1,%P2%P3"
10381f5e8f30Smiod  [(set_attr "type" "branch")])
10391f5e8f30Smiod
10401f5e8f30Smiod;; Recognize bcnd instructions for single precision float values
10411f5e8f30Smiod;; Exclude relational operations as they must signal NaNs.
10421f5e8f30Smiod
10431f5e8f30Smiod;; @@ These bcnd insns for float and double values don't seem to be recognized.
10441f5e8f30Smiod
10451f5e8f30Smiod(define_insn ""
10461f5e8f30Smiod  [(set (pc)
10471f5e8f30Smiod	(if_then_else
10481f5e8f30Smiod	 (match_operator 0 "equality_op"
10491f5e8f30Smiod			 [(float_extend:DF
10501f5e8f30Smiod			   (match_operand:SF 1 "register_operand" "r"))
10511f5e8f30Smiod			  (const_int 0)])
10521f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
10531f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
10541f5e8f30Smiod  ""
10551f5e8f30Smiod  "bcnd%. %R3%D0,%1,%P2%P3"
10561f5e8f30Smiod  [(set_attr "type" "branch")])
10571f5e8f30Smiod
10581f5e8f30Smiod(define_insn ""
10591f5e8f30Smiod  [(set (pc)
10601f5e8f30Smiod	(if_then_else
10611f5e8f30Smiod	 (match_operator 0 "equality_op"
10621f5e8f30Smiod			 [(match_operand:SF 1 "register_operand" "r")
10631f5e8f30Smiod			  (const_int 0)])
10641f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
10651f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
10661f5e8f30Smiod  ""
10671f5e8f30Smiod  "bcnd%. %R3%D0,%1,%P2%P3"
10681f5e8f30Smiod  [(set_attr "type" "branch")])
10691f5e8f30Smiod
10701f5e8f30Smiod;; Recognize bcnd instructions for double precision float values
10711f5e8f30Smiod;; Exclude relational operations as they must signal NaNs.
10721f5e8f30Smiod
10731f5e8f30Smiod(define_insn ""
10741f5e8f30Smiod  [(set (pc)
10751f5e8f30Smiod	(if_then_else
10761f5e8f30Smiod	 (match_operator 0 "equality_op"
10771f5e8f30Smiod			 [(match_operand:DF 1 "register_operand" "r")
10781f5e8f30Smiod			  (const_int 0)])
10791f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
10801f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
10811f5e8f30Smiod  ""
10821f5e8f30Smiod{
10831f5e8f30Smiod  if (GET_CODE (operands[0]) == NE)
10841f5e8f30Smiod    {
10851f5e8f30Smiod      rtx op2 = operands[2];
10861f5e8f30Smiod      operands[2] = operands[3];
10871f5e8f30Smiod      operands[3] = op2;
10881f5e8f30Smiod    }
10891f5e8f30Smiod  if (GET_CODE (operands[3]) == LABEL_REF)
10901f5e8f30Smiod    return "bcnd 0x5,%1,%3\;bcnd %#ne0,%d1,%3";
10911f5e8f30Smiod
10921f5e8f30Smiod  operands[3] = gen_label_rtx ();
10931f5e8f30Smiod  output_asm_insn ("bcnd 0x5,%1,%3\;bcnd %#eq0,%d1,%2", operands);
10941f5e8f30Smiod  emit_label (operands[3]);
10951f5e8f30Smiod  return "";
10961f5e8f30Smiod}
10971f5e8f30Smiod  [(set_attr "type" "weird")
10981f5e8f30Smiod   (set_attr "length" "3")])
10991f5e8f30Smiod
11001f5e8f30Smiod;; Recognize bb0 and bb1 instructions.  These use two unusual template
11011f5e8f30Smiod;; patterns, %Lx and %Px.  %Lx outputs a 1 if operand `x' is a LABEL_REF
11021f5e8f30Smiod;; otherwise it outputs a 0.  It then may print ".n" if the delay slot
11031f5e8f30Smiod;; is used.  %Px does noting if `x' is PC and outputs the operand if `x'
11041f5e8f30Smiod;; is a LABEL_REF.
11051f5e8f30Smiod
11061f5e8f30Smiod(define_insn ""
11071f5e8f30Smiod  [(set (pc)
11081f5e8f30Smiod	(if_then_else
11091f5e8f30Smiod	 (ne (sign_extract:SI (match_operand:SI 0 "register_operand" "r")
11101f5e8f30Smiod			      (const_int 1)
11111f5e8f30Smiod			      (match_operand:SI 1 "int5_operand" ""))
11121f5e8f30Smiod	     (const_int 0))
11131f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
11141f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
11151f5e8f30Smiod  ""
11161f5e8f30Smiod  "bb%L2 (31-%1),%0,%P2%P3"
11171f5e8f30Smiod  [(set_attr "type" "branch")])
11181f5e8f30Smiod
11191f5e8f30Smiod(define_insn ""
11201f5e8f30Smiod  [(set (pc)
11211f5e8f30Smiod	(if_then_else
11221f5e8f30Smiod	 (eq (sign_extract:SI (match_operand:SI 0 "register_operand" "r")
11231f5e8f30Smiod			      (const_int 1)
11241f5e8f30Smiod			      (match_operand:SI 1 "int5_operand" ""))
11251f5e8f30Smiod	     (const_int 0))
11261f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
11271f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
11281f5e8f30Smiod  ""
11291f5e8f30Smiod  "bb%L3 (31-%1),%0,%P2%P3"
11301f5e8f30Smiod  [(set_attr "type" "branch")])
11311f5e8f30Smiod
11321f5e8f30Smiod(define_insn ""
11331f5e8f30Smiod  [(set (pc)
11341f5e8f30Smiod	(if_then_else
11351f5e8f30Smiod	 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
11361f5e8f30Smiod			      (const_int 1)
11371f5e8f30Smiod			      (match_operand:SI 1 "int5_operand" ""))
11381f5e8f30Smiod	     (const_int 0))
11391f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
11401f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
11411f5e8f30Smiod  ""
11421f5e8f30Smiod  "bb%L2 (31-%1),%0,%P2%P3"
11431f5e8f30Smiod  [(set_attr "type" "branch")])
11441f5e8f30Smiod
11451f5e8f30Smiod(define_insn ""
11461f5e8f30Smiod  [(set (pc)
11471f5e8f30Smiod	(if_then_else
11481f5e8f30Smiod	 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
11491f5e8f30Smiod			      (const_int 1)
11501f5e8f30Smiod			      (match_operand:SI 1 "int5_operand" ""))
11511f5e8f30Smiod	     (const_int 0))
11521f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
11531f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
11541f5e8f30Smiod  ""
11551f5e8f30Smiod  "bb%L3 (31-%1),%0,%P2%P3"
11561f5e8f30Smiod  [(set_attr "type" "branch")])
11571f5e8f30Smiod
11581f5e8f30Smiod(define_insn ""
11591f5e8f30Smiod  [(set (pc)
11601f5e8f30Smiod	(if_then_else
11611f5e8f30Smiod	 (eq (and:SI (match_operand:SI 0 "reg_or_bbx_mask_operand" "%r")
11621f5e8f30Smiod		     (match_operand:SI 1 "reg_or_bbx_mask_operand" "n"))
11631f5e8f30Smiod	      (const_int 0))
11641f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
11651f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
11661f5e8f30Smiod  "(GET_CODE (operands[0]) == CONST_INT)
11671f5e8f30Smiod   != (GET_CODE (operands[1]) == CONST_INT)"
11681f5e8f30Smiod  "bb%L3 %p1,%0,%P2%P3"
11691f5e8f30Smiod  [(set_attr "type" "branch")])
11701f5e8f30Smiod
11711f5e8f30Smiod(define_insn ""
11721f5e8f30Smiod  [(set (pc)
11731f5e8f30Smiod	(if_then_else
11741f5e8f30Smiod	 (ne (and:SI (match_operand:SI 0 "reg_or_bbx_mask_operand" "%r")
11751f5e8f30Smiod		     (match_operand:SI 1 "reg_or_bbx_mask_operand" "n"))
11761f5e8f30Smiod	     (const_int 0))
11771f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
11781f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
11791f5e8f30Smiod  "(GET_CODE (operands[0]) == CONST_INT)
11801f5e8f30Smiod   != (GET_CODE (operands[1]) == CONST_INT)"
11811f5e8f30Smiod  "bb%L2 %p1,%0,%P2%P3"
11821f5e8f30Smiod  [(set_attr "type" "branch")])
11831f5e8f30Smiod
11841f5e8f30Smiod;; The comparison operations store the comparison into a register and
11851f5e8f30Smiod;; record that register.  The following Bxx or Sxx insn uses that
11861f5e8f30Smiod;; register as an input.  To facilitate use of bcnd instead of cmp/bb1,
11871f5e8f30Smiod;; cmpsi records its operands and produces no code when any operand
11881f5e8f30Smiod;; is constant.  In this case, the Bxx insns use gen_bcnd and the
11891f5e8f30Smiod;; Sxx insns use gen_test to ensure a cmp has been emitted.
11901f5e8f30Smiod;;
11911f5e8f30Smiod;; This could also be done for SFmode and DFmode having only beq and bne
11921f5e8f30Smiod;; use gen_bcnd.  The others must signal NaNs.  It seems though that zero
11931f5e8f30Smiod;; has already been copied into a register.
11941f5e8f30Smiod;;
11951f5e8f30Smiod;; cmpsi/beq and cmpsi/bne can always be done with bcnd if any operand
11961f5e8f30Smiod;; is a constant.  (This idea is due to Torbjorn Granlund.)  Others can
11971f5e8f30Smiod;; use bcnd only if an operand is zero.
11981f5e8f30Smiod;;
11991f5e8f30Smiod;; It is necessary to distinguish a register holding condition codes.
12001f5e8f30Smiod;; This is done by context.
12011f5e8f30Smiod
12021f5e8f30Smiod(define_expand "test"
12031f5e8f30Smiod  [(set (match_dup 2)
12041f5e8f30Smiod	(compare:CC (match_operand 0 "" "")
12051f5e8f30Smiod		    (match_operand 1 "" "")))]
12061f5e8f30Smiod  ""
12071f5e8f30Smiod  "
12081f5e8f30Smiod{
12091f5e8f30Smiod  gcc_assert (m88k_compare_reg == NULL_RTX);
12101f5e8f30Smiod
12111f5e8f30Smiod  if (GET_CODE (operands[0]) == CONST_INT
12121f5e8f30Smiod      && ! SMALL_INT (operands[0]))
12131f5e8f30Smiod    operands[0] = force_reg (SImode, operands[0]);
12141f5e8f30Smiod
12151f5e8f30Smiod  if (GET_CODE (operands[1]) == CONST_INT
12161f5e8f30Smiod      && ! SMALL_INT (operands[1]))
12171f5e8f30Smiod    operands[1] = force_reg (SImode, operands[1]);
12181f5e8f30Smiod
12191f5e8f30Smiod  operands[2] = m88k_compare_reg = gen_reg_rtx (CCmode);
12201f5e8f30Smiod}")
12211f5e8f30Smiod
12221f5e8f30Smiod(define_expand "cmpsi"
12231f5e8f30Smiod  [(set (match_dup 2)
12241f5e8f30Smiod	(compare:CC (match_operand:SI 0 "register_operand" "")
12251f5e8f30Smiod		    (match_operand:SI 1 "arith32_operand" "")))]
12261f5e8f30Smiod  ""
12271f5e8f30Smiod  "
12281f5e8f30Smiod{
12291f5e8f30Smiod  if (GET_CODE (operands[0]) == CONST_INT
12301f5e8f30Smiod      || GET_CODE (operands[1]) == CONST_INT)
12311f5e8f30Smiod    {
12321f5e8f30Smiod      m88k_compare_reg = NULL_RTX;
12331f5e8f30Smiod      m88k_compare_op0 = operands[0];
12341f5e8f30Smiod      m88k_compare_op1 = operands[1];
12351f5e8f30Smiod      DONE;
12361f5e8f30Smiod    }
12371f5e8f30Smiod  operands[2] = m88k_compare_reg = gen_reg_rtx (CCmode);
12381f5e8f30Smiod}")
12391f5e8f30Smiod
12401f5e8f30Smiod(define_expand "cmpsf"
12411f5e8f30Smiod  [(set (match_dup 2)
12421f5e8f30Smiod	(compare:CC (match_operand:SF 0 "register_operand" "")
12431f5e8f30Smiod		    (match_operand:SF 1 "register_operand" "")))]
12441f5e8f30Smiod  ""
12451f5e8f30Smiod  "operands[2] = m88k_compare_reg = gen_reg_rtx (CCmode);")
12461f5e8f30Smiod
12471f5e8f30Smiod(define_expand "cmpdf"
12481f5e8f30Smiod  [(set (match_dup 2)
12491f5e8f30Smiod	(compare:CC (match_operand:DF 0 "general_operand" "")
12501f5e8f30Smiod		    (match_operand:DF 1 "general_operand" "")))]
12511f5e8f30Smiod  ""
12521f5e8f30Smiod  "
12531f5e8f30Smiod{
12541f5e8f30Smiod  operands[0] = legitimize_operand (operands[0], DFmode);
12551f5e8f30Smiod  operands[1] = legitimize_operand (operands[1], DFmode);
12561f5e8f30Smiod  operands[2] = m88k_compare_reg = gen_reg_rtx (CCmode);
12571f5e8f30Smiod}")
12581f5e8f30Smiod
12591f5e8f30Smiod;; The actual compare instructions.
12601f5e8f30Smiod
12611f5e8f30Smiod(define_insn ""
12621f5e8f30Smiod  [(set (match_operand:CC 0 "register_operand" "=r")
12631f5e8f30Smiod	(compare:CC (match_operand:SI 1 "register_operand" "rO")
12641f5e8f30Smiod		    (match_operand:SI 2 "arith_operand" "rI")))]
12651f5e8f30Smiod  ""
12661f5e8f30Smiod  "cmp %0,%r1,%2")
12671f5e8f30Smiod
12681f5e8f30Smiod(define_insn ""
12691f5e8f30Smiod  [(set (match_operand:CC 0 "register_operand" "=r,r,r,r")
12701f5e8f30Smiod	(compare:CC (match_operand:SF 1 "register_operand" "r,r,x,x")
12711f5e8f30Smiod		    (match_operand:SF 2 "real_or_0_operand" "r,G,x,G")))]
12721f5e8f30Smiod  ""
12731f5e8f30Smiod  "@
12741f5e8f30Smiod   fcmp.sss %0,%1,%2
12751f5e8f30Smiod   fcmp.sss %0,%1,%#r0
12761f5e8f30Smiod   fcmp.sss %0,%1,%2
12771f5e8f30Smiod   fcmp.sss %0,%1,%#x0"
12781f5e8f30Smiod  [(set_attr "type" "spcmp")])
12791f5e8f30Smiod
12801f5e8f30Smiod(define_insn ""
12811f5e8f30Smiod  [(set (match_operand:CC 0 "register_operand" "=r,r")
12821f5e8f30Smiod	(compare:CC (match_operand:DF 1 "register_operand" "r,x")
12831f5e8f30Smiod		    (float_extend:DF
12841f5e8f30Smiod		     (match_operand:SF 2 "register_operand" "r,x"))))]
12851f5e8f30Smiod  ""
12861f5e8f30Smiod  "fcmp.sds %0,%1,%2"
12871f5e8f30Smiod  [(set_attr "type" "dpcmp")])
12881f5e8f30Smiod
12891f5e8f30Smiod(define_insn ""
12901f5e8f30Smiod  [(set (match_operand:CC 0 "register_operand" "=r,r")
12911f5e8f30Smiod	(compare:CC (float_extend:DF
12921f5e8f30Smiod		     (match_operand:SF 1 "register_operand" "r,x"))
12931f5e8f30Smiod		    (match_operand:DF 2 "register_operand" "r,x")))]
12941f5e8f30Smiod  ""
12951f5e8f30Smiod  "fcmp.ssd %0,%1,%2"
12961f5e8f30Smiod  [(set_attr "type" "dpcmp")])
12971f5e8f30Smiod
12981f5e8f30Smiod(define_insn ""
12991f5e8f30Smiod  [(set (match_operand:CC 0 "register_operand" "=r,r,r,r")
13001f5e8f30Smiod	(compare:CC (match_operand:DF 1 "register_operand" "r,r,x,x")
13011f5e8f30Smiod		    (match_operand:DF 2 "real_or_0_operand" "r,G,x,G")))]
13021f5e8f30Smiod  ""
13031f5e8f30Smiod  "@
13041f5e8f30Smiod   fcmp.sdd %0,%1,%2
13051f5e8f30Smiod   fcmp.sds %0,%1,%#r0
13061f5e8f30Smiod   fcmp.sdd %0,%1,%2
13071f5e8f30Smiod   fcmp.sds %0,%1,%#x0"
13081f5e8f30Smiod  [(set_attr "type" "dpcmp")])
13091f5e8f30Smiod
13101f5e8f30Smiod;; Store condition code insns.  The compare insns set a register
13111f5e8f30Smiod;; rather than cc0 and record that register for use here.  See above
13121f5e8f30Smiod;; for the special treatment of cmpsi with a constant operand.
13131f5e8f30Smiod
13141f5e8f30Smiod;; @@ For the m88110, use fcmpu for bxx sxx inequality comparisons.
13151f5e8f30Smiod
13161f5e8f30Smiod(define_expand "seq"
13171f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
13181f5e8f30Smiod	(match_dup 1))]
13191f5e8f30Smiod  ""
13201f5e8f30Smiod  "operands[1] = emit_test (EQ, SImode);")
13211f5e8f30Smiod
13221f5e8f30Smiod(define_expand "sne"
13231f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
13241f5e8f30Smiod	(match_dup 1))]
13251f5e8f30Smiod  ""
13261f5e8f30Smiod  "operands[1] = emit_test (NE, SImode);")
13271f5e8f30Smiod
13281f5e8f30Smiod(define_expand "sgt"
13291f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
13301f5e8f30Smiod	(match_dup 1))]
13311f5e8f30Smiod  ""
13321f5e8f30Smiod  "operands[1] = emit_test (GT, SImode);")
13331f5e8f30Smiod
13341f5e8f30Smiod(define_expand "sgtu"
13351f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
13361f5e8f30Smiod	(match_dup 1))]
13371f5e8f30Smiod  ""
13381f5e8f30Smiod  "operands[1] = emit_test (GTU, SImode);")
13391f5e8f30Smiod
13401f5e8f30Smiod(define_expand "slt"
13411f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
13421f5e8f30Smiod	(match_dup 1))]
13431f5e8f30Smiod  ""
13441f5e8f30Smiod  "operands[1] = emit_test (LT, SImode);")
13451f5e8f30Smiod
13461f5e8f30Smiod(define_expand "sltu"
13471f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
13481f5e8f30Smiod	(match_dup 1))]
13491f5e8f30Smiod  ""
13501f5e8f30Smiod  "operands[1] = emit_test (LTU, SImode);")
13511f5e8f30Smiod
13521f5e8f30Smiod(define_expand "sge"
13531f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
13541f5e8f30Smiod	(match_dup 1))]
13551f5e8f30Smiod  ""
13561f5e8f30Smiod  "operands[1] = emit_test (GE, SImode);")
13571f5e8f30Smiod
13581f5e8f30Smiod(define_expand "sgeu"
13591f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
13601f5e8f30Smiod	(match_dup 1))]
13611f5e8f30Smiod  ""
13621f5e8f30Smiod  "operands[1] = emit_test (GEU, SImode);")
13631f5e8f30Smiod
13641f5e8f30Smiod(define_expand "sle"
13651f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
13661f5e8f30Smiod	(match_dup 1))]
13671f5e8f30Smiod  ""
13681f5e8f30Smiod  "operands[1] = emit_test (LE, SImode);")
13691f5e8f30Smiod
13701f5e8f30Smiod(define_expand "sleu"
13711f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
13721f5e8f30Smiod	(match_dup 1))]
13731f5e8f30Smiod  ""
13741f5e8f30Smiod  "operands[1] = emit_test (LEU, SImode);")
13751f5e8f30Smiod
13761f5e8f30Smiod;; The actual set condition code instruction.
13771f5e8f30Smiod
13781f5e8f30Smiod(define_insn ""
13791f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
13801f5e8f30Smiod	(match_operator:SI 1 "relop"
13811f5e8f30Smiod			   [(match_operand:CC 2 "register_operand" "r")
13821f5e8f30Smiod			    (const_int 0)]))]
13831f5e8f30Smiod  ""
13841f5e8f30Smiod  "ext %0,%2,1<%C1>"
13851f5e8f30Smiod  [(set_attr "type" "bit")])
13861f5e8f30Smiod
13871f5e8f30Smiod(define_insn ""
13881f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
13891f5e8f30Smiod	(match_operator:SI 1 "even_relop"
13901f5e8f30Smiod			   [(match_operand:CCEVEN 2 "register_operand" "r")
13911f5e8f30Smiod			    (const_int 0)]))]
13921f5e8f30Smiod  ""
13931f5e8f30Smiod  "ext %0,%2,1<%C1>"
13941f5e8f30Smiod  [(set_attr "type" "bit")])
13951f5e8f30Smiod
13961f5e8f30Smiod(define_insn ""
13971f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
13981f5e8f30Smiod	(not:SI (match_operator:SI 1 "odd_relop"
13991f5e8f30Smiod			   [(match_operand:CCEVEN 2 "register_operand" "r")
14001f5e8f30Smiod			    (const_int 0)])))]
14011f5e8f30Smiod  ""
14021f5e8f30Smiod  "ext %0,%2,1<%!%C1>"
14031f5e8f30Smiod  [(set_attr "type" "bit")])
14041f5e8f30Smiod
14051f5e8f30Smiod(define_split
14061f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
14071f5e8f30Smiod	(match_operator:SI 1 "odd_relop"
14081f5e8f30Smiod			   [(match_operand:CCEVEN 2 "register_operand" "r")
14091f5e8f30Smiod			    (const_int 0)]))
14101f5e8f30Smiod   (clobber (match_operand:SI 3 "register_operand" ""))]
14111f5e8f30Smiod  "reload_completed
14121f5e8f30Smiod   && GET_CODE (operands[0]) == REG"
14131f5e8f30Smiod  [(set (match_dup 3) (not:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])))
14141f5e8f30Smiod   (set (match_dup 0) (not:SI (match_dup 3)))]
14151f5e8f30Smiod  "")
14161f5e8f30Smiod
14171f5e8f30Smiod(define_insn ""
14181f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
14191f5e8f30Smiod	(match_operator:SI 1 "odd_relop"
14201f5e8f30Smiod			   [(match_operand:CCEVEN 2 "register_operand" "r")
14211f5e8f30Smiod			    (const_int 0)]))
14221f5e8f30Smiod   (clobber (match_scratch:SI 3 "=r"))]
14231f5e8f30Smiod  ""
14241f5e8f30Smiod  "#")
14251f5e8f30Smiod
14261f5e8f30Smiod(define_insn ""
14271f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
14281f5e8f30Smiod	(neg:SI
14291f5e8f30Smiod	 (match_operator:SI 1 "relop"
14301f5e8f30Smiod			    [(match_operand:CC 2 "register_operand" "r")
14311f5e8f30Smiod			     (const_int 0)])))]
14321f5e8f30Smiod  ""
14331f5e8f30Smiod  "extu %0,%2,1<%C1>"
14341f5e8f30Smiod  [(set_attr "type" "bit")])
14351f5e8f30Smiod
14361f5e8f30Smiod(define_insn ""
14371f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
14381f5e8f30Smiod	(neg:SI
14391f5e8f30Smiod	 (match_operator:SI 1 "even_relop"
14401f5e8f30Smiod			    [(match_operand:CCEVEN 2 "register_operand" "r")
14411f5e8f30Smiod			     (const_int 0)])))]
14421f5e8f30Smiod  ""
14431f5e8f30Smiod  "extu %0,%2,1<%C1>"
14441f5e8f30Smiod  [(set_attr "type" "bit")])
14451f5e8f30Smiod
14461f5e8f30Smiod(define_insn ""
14471f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
14481f5e8f30Smiod	(neg:SI
14491f5e8f30Smiod	 (not:SI (match_operator:SI 1 "odd_relop"
14501f5e8f30Smiod			    [(match_operand:CCEVEN 2 "register_operand" "r")
14511f5e8f30Smiod			     (const_int 0)]))))]
14521f5e8f30Smiod  ""
14531f5e8f30Smiod  "extu %0,%2,1<%!%C1>"
14541f5e8f30Smiod  [(set_attr "type" "bit")])
14551f5e8f30Smiod
14561f5e8f30Smiod(define_split
14571f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
14581f5e8f30Smiod	(neg:SI (match_operator:SI 1 "odd_relop"
14591f5e8f30Smiod			   [(match_operand:CCEVEN 2 "register_operand" "r")
14601f5e8f30Smiod			    (const_int 0)])))
14611f5e8f30Smiod   (clobber (match_operand:SI 3 "register_operand" ""))]
14621f5e8f30Smiod  "reload_completed
14631f5e8f30Smiod   && GET_CODE (operands[0]) == REG"
14641f5e8f30Smiod  [(set (match_dup 3) (neg:SI (not:SI (match_op_dup 1 [(match_dup 2)
14651f5e8f30Smiod                                                       (const_int 0)]))))
14661f5e8f30Smiod   (set (match_dup 0) (xor:SI (match_dup 3) (const_int 1)))]
14671f5e8f30Smiod  "")
14681f5e8f30Smiod
14691f5e8f30Smiod(define_insn
14701f5e8f30Smiod ""
14711f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
14721f5e8f30Smiod	(neg:SI (match_operator:SI 1 "odd_relop"
14731f5e8f30Smiod			   [(match_operand:CCEVEN 2 "register_operand" "r")
14741f5e8f30Smiod			    (const_int 0)])))
14751f5e8f30Smiod   (clobber (match_scratch:SI 3 "=r"))]
14761f5e8f30Smiod  ""
14771f5e8f30Smiod  "#")
14781f5e8f30Smiod
14791f5e8f30Smiod
14801f5e8f30Smiod
14811f5e8f30Smiod
14821f5e8f30Smiod;; Conditional branch insns.  The compare insns set a register
14831f5e8f30Smiod;; rather than cc0 and record that register for use here.  See above
14841f5e8f30Smiod;; for the special case of cmpsi with a constant operand.
14851f5e8f30Smiod
14861f5e8f30Smiod(define_expand "bcnd"
14871f5e8f30Smiod  [(set (pc)
14881f5e8f30Smiod	(if_then_else (match_operand 0 "" "")
14891f5e8f30Smiod		      (label_ref (match_operand 1 "" ""))
14901f5e8f30Smiod		      (pc)))]
14911f5e8f30Smiod  ""
14921f5e8f30Smiod  "gcc_assert (m88k_compare_reg == NULL_RTX);")
14931f5e8f30Smiod
14941f5e8f30Smiod(define_expand "bxx"
14951f5e8f30Smiod  [(set (pc)
14961f5e8f30Smiod	(if_then_else (match_operand 0 "" "")
14971f5e8f30Smiod		      (label_ref (match_operand 1 "" ""))
14981f5e8f30Smiod		      (pc)))]
14991f5e8f30Smiod  ""
15001f5e8f30Smiod  "gcc_assert (m88k_compare_reg != NULL_RTX);")
15011f5e8f30Smiod
15021f5e8f30Smiod(define_expand "beq"
15031f5e8f30Smiod  [(set (pc)
15041f5e8f30Smiod	(if_then_else (eq (match_dup 1) (const_int 0))
15051f5e8f30Smiod		      (label_ref (match_operand 0 "" ""))
15061f5e8f30Smiod		      (pc)))]
15071f5e8f30Smiod  ""
15081f5e8f30Smiod  "if (m88k_compare_reg == NULL_RTX)
15091f5e8f30Smiod     {
15101f5e8f30Smiod       emit_bcnd (EQ, operands[0]);
15111f5e8f30Smiod       DONE;
15121f5e8f30Smiod     }
15131f5e8f30Smiod   operands[1] = m88k_compare_reg;")
15141f5e8f30Smiod
15151f5e8f30Smiod(define_expand "bne"
15161f5e8f30Smiod  [(set (pc)
15171f5e8f30Smiod	(if_then_else (ne (match_dup 1) (const_int 0))
15181f5e8f30Smiod		      (label_ref (match_operand 0 "" ""))
15191f5e8f30Smiod		      (pc)))]
15201f5e8f30Smiod  ""
15211f5e8f30Smiod  "if (m88k_compare_reg == NULL_RTX)
15221f5e8f30Smiod     {
15231f5e8f30Smiod       emit_bcnd (NE, operands[0]);
15241f5e8f30Smiod       DONE;
15251f5e8f30Smiod     }
15261f5e8f30Smiod   operands[1] = m88k_compare_reg;")
15271f5e8f30Smiod
15281f5e8f30Smiod(define_expand "bgt"
15291f5e8f30Smiod  [(set (pc)
15301f5e8f30Smiod	(if_then_else (gt (match_dup 1) (const_int 0))
15311f5e8f30Smiod		      (label_ref (match_operand 0 "" ""))
15321f5e8f30Smiod		      (pc)))]
15331f5e8f30Smiod  ""
15341f5e8f30Smiod  "if (m88k_compare_reg == NULL_RTX)
15351f5e8f30Smiod     {
15361f5e8f30Smiod       emit_bcnd (GT, operands[0]);
15371f5e8f30Smiod       DONE;
15381f5e8f30Smiod     }
15391f5e8f30Smiod   operands[1] = m88k_compare_reg;")
15401f5e8f30Smiod
15411f5e8f30Smiod(define_expand "bgtu"
15421f5e8f30Smiod  [(set (pc)
15431f5e8f30Smiod	(if_then_else (gtu (match_dup 1) (const_int 0))
15441f5e8f30Smiod		      (label_ref (match_operand 0 "" ""))
15451f5e8f30Smiod		      (pc)))]
15461f5e8f30Smiod  ""
15471f5e8f30Smiod  "if (m88k_compare_reg == NULL_RTX)
15481f5e8f30Smiod     {
15491f5e8f30Smiod       emit_jump_insn (gen_bxx (emit_test (GTU, VOIDmode), operands[0]));
15501f5e8f30Smiod       DONE;
15511f5e8f30Smiod     }
15521f5e8f30Smiod   operands[1] = m88k_compare_reg;")
15531f5e8f30Smiod
15541f5e8f30Smiod(define_expand "blt"
15551f5e8f30Smiod  [(set (pc)
15561f5e8f30Smiod	(if_then_else (lt (match_dup 1) (const_int 0))
15571f5e8f30Smiod		      (label_ref (match_operand 0 "" ""))
15581f5e8f30Smiod		      (pc)))]
15591f5e8f30Smiod  ""
15601f5e8f30Smiod  "if (m88k_compare_reg == NULL_RTX)
15611f5e8f30Smiod     {
15621f5e8f30Smiod       emit_bcnd (LT, operands[0]);
15631f5e8f30Smiod       DONE;
15641f5e8f30Smiod     }
15651f5e8f30Smiod   operands[1] = m88k_compare_reg;")
15661f5e8f30Smiod
15671f5e8f30Smiod(define_expand "bltu"
15681f5e8f30Smiod  [(set (pc)
15691f5e8f30Smiod	(if_then_else (ltu (match_dup 1) (const_int 0))
15701f5e8f30Smiod		      (label_ref (match_operand 0 "" ""))
15711f5e8f30Smiod		      (pc)))]
15721f5e8f30Smiod  ""
15731f5e8f30Smiod  "if (m88k_compare_reg == NULL_RTX)
15741f5e8f30Smiod     {
15751f5e8f30Smiod       emit_jump_insn (gen_bxx (emit_test (LTU, VOIDmode), operands[0]));
15761f5e8f30Smiod       DONE;
15771f5e8f30Smiod     }
15781f5e8f30Smiod   operands[1] = m88k_compare_reg;")
15791f5e8f30Smiod
15801f5e8f30Smiod(define_expand "bge"
15811f5e8f30Smiod  [(set (pc)
15821f5e8f30Smiod	(if_then_else (ge (match_dup 1) (const_int 0))
15831f5e8f30Smiod		      (label_ref (match_operand 0 "" ""))
15841f5e8f30Smiod		      (pc)))]
15851f5e8f30Smiod  ""
15861f5e8f30Smiod  "if (m88k_compare_reg == NULL_RTX)
15871f5e8f30Smiod     {
15881f5e8f30Smiod       emit_bcnd (GE, operands[0]);
15891f5e8f30Smiod       DONE;
15901f5e8f30Smiod     }
15911f5e8f30Smiod   operands[1] = m88k_compare_reg;")
15921f5e8f30Smiod
15931f5e8f30Smiod(define_expand "bgeu"
15941f5e8f30Smiod  [(set (pc)
15951f5e8f30Smiod	(if_then_else (geu (match_dup 1) (const_int 0))
15961f5e8f30Smiod		      (label_ref (match_operand 0 "" ""))
15971f5e8f30Smiod		      (pc)))]
15981f5e8f30Smiod  ""
15991f5e8f30Smiod  "if (m88k_compare_reg == NULL_RTX)
16001f5e8f30Smiod     {
16011f5e8f30Smiod       emit_jump_insn (gen_bxx (emit_test (GEU, VOIDmode), operands[0]));
16021f5e8f30Smiod       DONE;
16031f5e8f30Smiod     }
16041f5e8f30Smiod   operands[1] = m88k_compare_reg;")
16051f5e8f30Smiod
16061f5e8f30Smiod(define_expand "ble"
16071f5e8f30Smiod  [(set (pc)
16081f5e8f30Smiod	(if_then_else (le (match_dup 1) (const_int 0))
16091f5e8f30Smiod		      (label_ref (match_operand 0 "" ""))
16101f5e8f30Smiod		      (pc)))]
16111f5e8f30Smiod  ""
16121f5e8f30Smiod  "if (m88k_compare_reg == NULL_RTX)
16131f5e8f30Smiod     {
16141f5e8f30Smiod       emit_bcnd (LE, operands[0]);
16151f5e8f30Smiod       DONE;
16161f5e8f30Smiod     }
16171f5e8f30Smiod   operands[1] = m88k_compare_reg;")
16181f5e8f30Smiod
16191f5e8f30Smiod(define_expand "bleu"
16201f5e8f30Smiod  [(set (pc)
16211f5e8f30Smiod	(if_then_else (leu (match_dup 1) (const_int 0))
16221f5e8f30Smiod		      (label_ref (match_operand 0 "" ""))
16231f5e8f30Smiod		      (pc)))]
16241f5e8f30Smiod  ""
16251f5e8f30Smiod  "if (m88k_compare_reg == NULL_RTX)
16261f5e8f30Smiod     {
16271f5e8f30Smiod       emit_jump_insn (gen_bxx (emit_test (LEU, VOIDmode), operands[0]));
16281f5e8f30Smiod       DONE;
16291f5e8f30Smiod     }
16301f5e8f30Smiod   operands[1] = m88k_compare_reg;")
16311f5e8f30Smiod
16321f5e8f30Smiod;; The actual conditional branch instruction (both directions).  This
16331f5e8f30Smiod;; uses two unusual template patterns, %Rx and %Px.  %Rx is a prefix code
16341f5e8f30Smiod;; for the immediately following condition and reverses the condition iff
16351f5e8f30Smiod;; operand `x' is a LABEL_REF.  %Px does nothing if `x' is PC and outputs
16361f5e8f30Smiod;; the operand if `x' is a LABEL_REF.
16371f5e8f30Smiod
16381f5e8f30Smiod(define_insn ""
16391f5e8f30Smiod  [(set (pc) (if_then_else
16401f5e8f30Smiod	      (match_operator 0 "relop"
16411f5e8f30Smiod			      [(match_operand:CC 1 "register_operand" "r")
16421f5e8f30Smiod			       (const_int 0)])
16431f5e8f30Smiod	      (match_operand 2 "pc_or_label_ref" "")
16441f5e8f30Smiod	      (match_operand 3 "pc_or_label_ref" "")))]
16451f5e8f30Smiod  ""
16461f5e8f30Smiod{
16471f5e8f30Smiod  if (mostly_false_jump (insn, operands[0]))
16481f5e8f30Smiod    return "bb0%. %R2%C0,%1,%P2%P3";
16491f5e8f30Smiod  else
16501f5e8f30Smiod    return "bb1%. %R3%C0,%1,%P2%P3";
16511f5e8f30Smiod}
16521f5e8f30Smiod  [(set_attr "type" "branch")])
16531f5e8f30Smiod
16541f5e8f30Smiod;;
16551f5e8f30Smiod;; Here branch prediction is sacrificed. To get it back, you need
16561f5e8f30Smiod;;  - CCODD (CC mode where the ODD bits are valid)
16571f5e8f30Smiod;;  - several define_split that can apply De Morgan's Law.
16581f5e8f30Smiod;;  - transformations between CCEVEN and CCODD modes.
16591f5e8f30Smiod;;
16601f5e8f30Smiod
16611f5e8f30Smiod(define_insn ""
16621f5e8f30Smiod  [(set (pc) (if_then_else
16631f5e8f30Smiod	      (match_operator 0 "even_relop"
16641f5e8f30Smiod			      [(match_operand:CCEVEN 1 "register_operand" "r")
16651f5e8f30Smiod			       (const_int 0)])
16661f5e8f30Smiod	      (match_operand 2 "pc_or_label_ref" "")
16671f5e8f30Smiod	      (match_operand 3 "pc_or_label_ref" "")))]
16681f5e8f30Smiod  ""
16691f5e8f30Smiod  "bb%L2%. %C0,%1,%P2%P3"
16701f5e8f30Smiod  [(set_attr "type" "branch")])
16711f5e8f30Smiod
16721f5e8f30Smiod(define_insn ""
16731f5e8f30Smiod  [(set (pc) (if_then_else
16741f5e8f30Smiod	      (match_operator 0 "odd_relop"
16751f5e8f30Smiod			      [(match_operand:CCEVEN 1 "register_operand" "r")
16761f5e8f30Smiod			       (const_int 0)])
16771f5e8f30Smiod	      (match_operand 2 "pc_or_label_ref" "")
16781f5e8f30Smiod	      (match_operand 3 "pc_or_label_ref" "")))]
16791f5e8f30Smiod  ""
16801f5e8f30Smiod  "bb%L3%. %!%C0,%1,%P2%P3"
16811f5e8f30Smiod  [(set_attr "type" "branch")])
16821f5e8f30Smiod
16831f5e8f30Smiod;; Branch conditional on scc values.  These arise from manipulations on
16841f5e8f30Smiod;; compare words above.
16851f5e8f30Smiod;; Are these really used ?
16861f5e8f30Smiod
16871f5e8f30Smiod(define_insn ""
16881f5e8f30Smiod  [(set (pc)
16891f5e8f30Smiod	(if_then_else
16901f5e8f30Smiod	 (ne (match_operator 0 "relop"
16911f5e8f30Smiod			     [(match_operand:CC 1 "register_operand" "r")
16921f5e8f30Smiod			      (const_int 0)])
16931f5e8f30Smiod	     (const_int 0))
16941f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
16951f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
16961f5e8f30Smiod  ""
16971f5e8f30Smiod  "bb%L2 %C0,%1,%P2%P3"
16981f5e8f30Smiod  [(set_attr "type" "branch")])
16991f5e8f30Smiod
17001f5e8f30Smiod(define_insn ""
17011f5e8f30Smiod  [(set (pc)
17021f5e8f30Smiod	(if_then_else
17031f5e8f30Smiod	 (ne (match_operator 0 "even_relop"
17041f5e8f30Smiod			     [(match_operand:CCEVEN 1 "register_operand" "r")
17051f5e8f30Smiod			      (const_int 0)])
17061f5e8f30Smiod	     (const_int 0))
17071f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
17081f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
17091f5e8f30Smiod  ""
17101f5e8f30Smiod  "bb%L2 %C0,%1,%P2%P3"
17111f5e8f30Smiod  [(set_attr "type" "branch")])
17121f5e8f30Smiod
17131f5e8f30Smiod(define_insn ""
17141f5e8f30Smiod  [(set (pc)
17151f5e8f30Smiod	(if_then_else
17161f5e8f30Smiod	 (ne (match_operator 0 "odd_relop"
17171f5e8f30Smiod			     [(match_operand:CCEVEN 1 "register_operand" "r")
17181f5e8f30Smiod			      (const_int 0)])
17191f5e8f30Smiod	     (const_int 0))
17201f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
17211f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
17221f5e8f30Smiod  ""
17231f5e8f30Smiod  "bb%L3 %!%C0,%1,%P2%P3"
17241f5e8f30Smiod  [(set_attr "type" "branch")])
17251f5e8f30Smiod
17261f5e8f30Smiod(define_insn ""
17271f5e8f30Smiod  [(set (pc)
17281f5e8f30Smiod	(if_then_else
17291f5e8f30Smiod	 (eq (match_operator 0 "relop"
17301f5e8f30Smiod			     [(match_operand:CC 1 "register_operand" "r")
17311f5e8f30Smiod			      (const_int 0)])
17321f5e8f30Smiod	     (const_int 0))
17331f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
17341f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
17351f5e8f30Smiod  ""
17361f5e8f30Smiod  "bb%L3 %C0,%1,%P2%P3"
17371f5e8f30Smiod  [(set_attr "type" "branch")])
17381f5e8f30Smiod
17391f5e8f30Smiod(define_insn ""
17401f5e8f30Smiod  [(set (pc)
17411f5e8f30Smiod	(if_then_else
17421f5e8f30Smiod	 (eq (match_operator 0 "even_relop"
17431f5e8f30Smiod			     [(match_operand:CCEVEN 1 "register_operand" "r")
17441f5e8f30Smiod			      (const_int 0)])
17451f5e8f30Smiod	     (const_int 0))
17461f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
17471f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
17481f5e8f30Smiod  ""
17491f5e8f30Smiod  "bb%L3 %C0,%1,%P2%P3"
17501f5e8f30Smiod  [(set_attr "type" "branch")])
17511f5e8f30Smiod
17521f5e8f30Smiod(define_insn ""
17531f5e8f30Smiod  [(set (pc)
17541f5e8f30Smiod	(if_then_else
17551f5e8f30Smiod	 (eq (match_operator 0 "odd_relop"
17561f5e8f30Smiod			     [(match_operand:CCEVEN 1 "register_operand" "r")
17571f5e8f30Smiod			      (const_int 0)])
17581f5e8f30Smiod	     (const_int 0))
17591f5e8f30Smiod	 (match_operand 2 "pc_or_label_ref" "")
17601f5e8f30Smiod	 (match_operand 3 "pc_or_label_ref" "")))]
17611f5e8f30Smiod  ""
17621f5e8f30Smiod  "bb%L2 %!%C0,%1,%P2%P3"
17631f5e8f30Smiod  [(set_attr "type" "branch")])
17641f5e8f30Smiod
17651f5e8f30Smiod(define_insn "locate1"
17661f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
17671f5e8f30Smiod	(high:SI (unspec:SI [(label_ref (match_operand 1 "" ""))] UNSPEC_ABDIFF)))]
17681f5e8f30Smiod  "flag_pic"
17691f5e8f30Smiod  "or.u %0,%#r0,%#hi16(%1#abdiff)")
17701f5e8f30Smiod
17711f5e8f30Smiod(define_insn "locate2"
17721f5e8f30Smiod  [(parallel [(set (reg:SI 1) (pc))
17731f5e8f30Smiod	      (set (match_operand:SI 0 "register_operand" "=r")
17741f5e8f30Smiod		   (lo_sum:SI (match_dup 0)
17751f5e8f30Smiod			      (unspec:SI
17761f5e8f30Smiod			       [(label_ref (match_operand 1 "" ""))] UNSPEC_ABDIFF)))])]
17771f5e8f30Smiod  "flag_pic"
17781f5e8f30Smiod  "bsr.n %1\;or %0,%0,%#lo16(%1#abdiff)\\n%1:"
17791f5e8f30Smiod  [(set_attr "length" "2")])
17801f5e8f30Smiod
17811f5e8f30Smiod;; SImode move instructions
17821f5e8f30Smiod
17831f5e8f30Smiod(define_expand "movsi"
17841f5e8f30Smiod  [(set (match_operand:SI 0 "general_operand" "")
17851f5e8f30Smiod	(match_operand:SI 1 "general_operand" ""))]
17861f5e8f30Smiod  ""
17871f5e8f30Smiod  "
17881f5e8f30Smiod{
17891f5e8f30Smiod  if (emit_move_sequence (operands, SImode, NULL_RTX))
17901f5e8f30Smiod    DONE;
17911f5e8f30Smiod}")
17921f5e8f30Smiod
17931f5e8f30Smiod(define_expand "reload_insi"
17941f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
17951f5e8f30Smiod	(match_operand:SI 1 "general_operand" ""))
17961f5e8f30Smiod   (clobber (match_operand:SI 2 "register_operand" "=&r"))]
17971f5e8f30Smiod  ""
17981f5e8f30Smiod  "
17991f5e8f30Smiod{
18001f5e8f30Smiod  if (emit_move_sequence (operands, SImode, operands[2]))
18011f5e8f30Smiod    DONE;
18021f5e8f30Smiod
18031f5e8f30Smiod  /* We don't want the clobber emitted, so handle this ourselves.  */
18041f5e8f30Smiod  emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
18051f5e8f30Smiod  DONE;
18061f5e8f30Smiod}")
18071f5e8f30Smiod
18081f5e8f30Smiod(define_insn ""
18091f5e8f30Smiod  [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,m,r,r,r,x,x,x,m")
18101f5e8f30Smiod	(match_operand:SI 1 "move_operand" "rI,m,rO,J,M,x,r,x,m,x"))]
18111f5e8f30Smiod  "(register_operand (operands[0], SImode)
18121f5e8f30Smiod    || register_operand (operands[1], SImode)
18131f5e8f30Smiod    || operands[1] == const0_rtx)"
18141f5e8f30Smiod  "@
18151f5e8f30Smiod   or %0,%#r0,%1
18161f5e8f30Smiod   %V1ld\\t %0,%1
18171f5e8f30Smiod   %v0st\\t %r1,%0
18181f5e8f30Smiod   subu %0,%#r0,%n1
18191f5e8f30Smiod   set %0,%#r0,%s1
18201f5e8f30Smiod   mov.s %0,%1
18211f5e8f30Smiod   mov.s %0,%1
18221f5e8f30Smiod   mov %0,%1
18231f5e8f30Smiod   %V1ld\\t %0,%1
18241f5e8f30Smiod   %v0st\\t %1,%0"
18251f5e8f30Smiod  [(set_attr "type" "arith,load,store,arith,bit,mov,mov,mov,load,store")])
18261f5e8f30Smiod
18271f5e8f30Smiod(define_insn ""
18281f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r")
18291f5e8f30Smiod	(match_operand:SI 1 "arith32_operand" "rI,J,L,M,n"))]
18301f5e8f30Smiod  ""
18311f5e8f30Smiod  "@
18321f5e8f30Smiod   or %0,%#r0,%1
18331f5e8f30Smiod   subu %0,%#r0,%n1
18341f5e8f30Smiod   or.u %0,%#r0,%X1
18351f5e8f30Smiod   set %0,%#r0,%s1
18361f5e8f30Smiod   or.u %0,%#r0,%X1\;or %0,%0,%x1"
18371f5e8f30Smiod  [(set_attr "type" "arith,arith,arith,bit,marith")])
18381f5e8f30Smiod
18391f5e8f30Smiod;; @@ Why the constraint "in"?  Doesn't `i' include `n'?
18401f5e8f30Smiod(define_insn ""
18411f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
18421f5e8f30Smiod	(lo_sum:SI (match_operand:SI 1 "register_operand" "r")
18431f5e8f30Smiod		   (match_operand:SI 2 "immediate_operand" "in")))]
18441f5e8f30Smiod  ""
18451f5e8f30Smiod  "or %0,%1,%#lo16(%g2)")
18461f5e8f30Smiod
18471f5e8f30Smiod(define_insn ""
18481f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
18491f5e8f30Smiod	(high:SI (match_operand 1 "" "")))]
18501f5e8f30Smiod  ""
18511f5e8f30Smiod  "or.u %0,%#r0,%#hi16(%g1)")
18521f5e8f30Smiod
18531f5e8f30Smiod;; For PIC, symbol_refs are put inside unspec so that the optimizer won't
18541f5e8f30Smiod;; confuse them with real addresses.
18551f5e8f30Smiod
18561f5e8f30Smiod(define_insn "movsi_lo_sum_pic"
18571f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
18581f5e8f30Smiod	(lo_sum:SI (match_operand:SI 1 "register_operand" "r")
18591f5e8f30Smiod		   (unspec:SI [(match_operand:SI 2 "immediate_operand" "in")] UNSPEC_GOT_REL)))]
18601f5e8f30Smiod  "flag_pic"
18611f5e8f30Smiod  "or %0,%1,%#lo16(%g2)"
18621f5e8f30Smiod  ;; Need to set length for this arith insn because operand2
18631f5e8f30Smiod  ;; is not an "arith_operand".
18641f5e8f30Smiod  [(set_attr "length" "1")])
18651f5e8f30Smiod
18661f5e8f30Smiod(define_insn "movsi_high_pic"
18671f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
18681f5e8f30Smiod	(high:SI (unspec:SI [(match_operand 1 "" "")] UNSPEC_GOT_REL)))]
18691f5e8f30Smiod  "flag_pic"
18701f5e8f30Smiod  "or.u %0,%#r0,%#hi16(%g1)"
18711f5e8f30Smiod  ;; Need to set length for this arith insn because operand2
18721f5e8f30Smiod  ;; is not an arith_operand.
18731f5e8f30Smiod  [(set_attr "length" "1")])
18741f5e8f30Smiod
18751f5e8f30Smiod;; HImode move instructions
18761f5e8f30Smiod
18771f5e8f30Smiod(define_expand "movhi"
18781f5e8f30Smiod  [(set (match_operand:HI 0 "general_operand" "")
18791f5e8f30Smiod	(match_operand:HI 1 "general_operand" ""))]
18801f5e8f30Smiod  ""
18811f5e8f30Smiod  "
18821f5e8f30Smiod{
18831f5e8f30Smiod  if (emit_move_sequence (operands, HImode, NULL_RTX))
18841f5e8f30Smiod    DONE;
18851f5e8f30Smiod}")
18861f5e8f30Smiod
18871f5e8f30Smiod(define_insn ""
18881f5e8f30Smiod  [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r")
18891f5e8f30Smiod	(match_operand:HI 1 "move_operand" "rP,m,rO,N"))]
18901f5e8f30Smiod  "(register_operand (operands[0], HImode)
18911f5e8f30Smiod    || register_operand (operands[1], HImode)
18921f5e8f30Smiod    || operands[1] == const0_rtx)"
18931f5e8f30Smiod  "@
18941f5e8f30Smiod   or %0,%#r0,%h1
18951f5e8f30Smiod   %V1ld.hu\\t %0,%1
18961f5e8f30Smiod   %v0st.h\\t %r1,%0
18971f5e8f30Smiod   subu %0,%#r0,%H1"
18981f5e8f30Smiod  [(set_attr "type" "arith,load,store,arith")])
18991f5e8f30Smiod
19001f5e8f30Smiod(define_insn ""
19011f5e8f30Smiod  [(set (match_operand:HI 0 "register_operand" "=r")
19021f5e8f30Smiod	(subreg:HI (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
19031f5e8f30Smiod			      (match_operand:SI 2 "immediate_operand" "in")) 0))]
19041f5e8f30Smiod  "!flag_pic"
19051f5e8f30Smiod  "or %0,%1,%#lo16(%2)")
19061f5e8f30Smiod
19071f5e8f30Smiod;; QImode move instructions
19081f5e8f30Smiod
19091f5e8f30Smiod(define_expand "movqi"
19101f5e8f30Smiod  [(set (match_operand:QI 0 "general_operand" "")
19111f5e8f30Smiod	(match_operand:QI 1 "general_operand" ""))]
19121f5e8f30Smiod  ""
19131f5e8f30Smiod  "
19141f5e8f30Smiod{
19151f5e8f30Smiod  if (emit_move_sequence (operands, QImode, NULL_RTX))
19161f5e8f30Smiod    DONE;
19171f5e8f30Smiod}")
19181f5e8f30Smiod
19191f5e8f30Smiod(define_insn ""
19201f5e8f30Smiod  [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r")
19211f5e8f30Smiod	(match_operand:QI 1 "move_operand" "rP,m,rO,N"))]
19221f5e8f30Smiod  "(register_operand (operands[0], QImode)
19231f5e8f30Smiod    || register_operand (operands[1], QImode)
19241f5e8f30Smiod    || operands[1] == const0_rtx)"
19251f5e8f30Smiod  "@
19261f5e8f30Smiod   or %0,%#r0,%q1
19271f5e8f30Smiod   %V1ld.bu\\t %0,%1
19281f5e8f30Smiod   %v0st.b\\t %r1,%0
192924ed4e7eSmiod   subu %0,%#r0,%Q1"
19301f5e8f30Smiod  [(set_attr "type" "arith,load,store,arith")])
19311f5e8f30Smiod
19321f5e8f30Smiod(define_insn ""
19331f5e8f30Smiod  [(set (match_operand:QI 0 "register_operand" "=r")
19341f5e8f30Smiod	(subreg:QI (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
19351f5e8f30Smiod			      (match_operand:SI 2 "immediate_operand" "in")) 0))]
19361f5e8f30Smiod  "!flag_pic"
19371f5e8f30Smiod  "or %0,%1,%#lo16(%2)")
19381f5e8f30Smiod
19391f5e8f30Smiod;; DImode move instructions
19401f5e8f30Smiod
19411f5e8f30Smiod(define_expand "movdi"
19421f5e8f30Smiod  [(set (match_operand:DI 0 "general_operand" "")
19431f5e8f30Smiod	(match_operand:DI 1 "general_operand" ""))]
19441f5e8f30Smiod  ""
19451f5e8f30Smiod  "
19461f5e8f30Smiod{
19471f5e8f30Smiod  if (emit_move_sequence (operands, DImode, NULL_RTX))
19481f5e8f30Smiod    DONE;
19491f5e8f30Smiod}")
19501f5e8f30Smiod
19511f5e8f30Smiod(define_insn ""
19521f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r,x")
19531f5e8f30Smiod	(const_int 0))]
19541f5e8f30Smiod  ""
19551f5e8f30Smiod  "@
19561f5e8f30Smiod   or %0,%#r0,0\;or %d0,%#r0,0
19571f5e8f30Smiod   mov %0,%#x0"
19581f5e8f30Smiod  [(set_attr "type" "marith,mov")])
19591f5e8f30Smiod
19601f5e8f30Smiod(define_insn ""
19611f5e8f30Smiod  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,x,x,x,m")
19621f5e8f30Smiod	(match_operand:DI 1 "nonimmediate_operand" "r,m,r,x,r,x,m,x"))]
19631f5e8f30Smiod  ""
19641f5e8f30Smiod  "@
19651f5e8f30Smiod   or %0,%#r0,%1\;or %d0,%#r0,%d1
19661f5e8f30Smiod   %V1ld.d\\t %0,%1
19671f5e8f30Smiod   %v0st.d\\t %1,%0
19681f5e8f30Smiod   mov.d %0,%1
19691f5e8f30Smiod   mov.d %0,%1
19701f5e8f30Smiod   mov %0,%1
19711f5e8f30Smiod   %V1ld.d\\t %0,%1
19721f5e8f30Smiod   %v0st.d\\t %1,%0"
19731f5e8f30Smiod  [(set_attr "type" "marith,loadd,store,mov,mov,mov,loadd,store")])
19741f5e8f30Smiod
19751f5e8f30Smiod(define_insn ""
19761f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
19771f5e8f30Smiod	(subreg:DI (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
19781f5e8f30Smiod			      (match_operand:SI 2 "immediate_operand" "in")) 0))]
19791f5e8f30Smiod  "!flag_pic"
19801f5e8f30Smiod  "or %0,%1,%#lo16(%2)")
19811f5e8f30Smiod
19821f5e8f30Smiod(define_insn ""
19831f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
19841f5e8f30Smiod	(match_operand:DI 1 "immediate_operand" "n"))]
19851f5e8f30Smiod   ""
19861f5e8f30Smiod   "* return output_load_const_dimode (operands);"
19871f5e8f30Smiod  [(set_attr "type" "marith")
19881f5e8f30Smiod   (set_attr "length" "4")]) ; length is 2, 3 or 4.
19891f5e8f30Smiod
19901f5e8f30Smiod;; DFmode move instructions
19911f5e8f30Smiod
19921f5e8f30Smiod(define_expand "movdf"
19931f5e8f30Smiod  [(set (match_operand:DF 0 "general_operand" "")
19941f5e8f30Smiod	(match_operand:DF 1 "general_operand" ""))]
19951f5e8f30Smiod  ""
19961f5e8f30Smiod  "
19971f5e8f30Smiod{
19981f5e8f30Smiod  if (emit_move_sequence (operands, DFmode, NULL_RTX))
19991f5e8f30Smiod    DONE;
20001f5e8f30Smiod}")
20011f5e8f30Smiod
20021f5e8f30Smiod(define_split
20031f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "")
20041f5e8f30Smiod	(match_operand:DF 1 "register_operand" ""))]
20051f5e8f30Smiod  "reload_completed
20061f5e8f30Smiod   && GET_CODE (operands[0]) == REG && !XRF_REGNO_P (REGNO (operands[0]))
20071f5e8f30Smiod   && GET_CODE (operands[1]) == REG && !XRF_REGNO_P (REGNO (operands[1]))"
20081f5e8f30Smiod  [(set (match_dup 2) (match_dup 3))
20091f5e8f30Smiod   (set (match_dup 4) (match_dup 5))]
20101f5e8f30Smiod  "
20111f5e8f30Smiod{ operands[2] = operand_subword (operands[0], 0, 0, DFmode);
20121f5e8f30Smiod  operands[3] = operand_subword (operands[1], 0, 0, DFmode);
20131f5e8f30Smiod  operands[4] = operand_subword (operands[0], 1, 0, DFmode);
20141f5e8f30Smiod  operands[5] = operand_subword (operands[1], 1, 0, DFmode); }")
20151f5e8f30Smiod
20161f5e8f30Smiod(define_insn ""
20171f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
20181f5e8f30Smiod	(const_int 0))]
20191f5e8f30Smiod  ""
20201f5e8f30Smiod  "@
20211f5e8f30Smiod   or %0,%#r0,0\;or %d0,%#r0,0
20221f5e8f30Smiod   mov %0,%#x0"
20231f5e8f30Smiod  [(set_attr "type" "marith,mov")])
20241f5e8f30Smiod
20251f5e8f30Smiod(define_insn ""
20261f5e8f30Smiod  [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,x,r,x,x,m")
20271f5e8f30Smiod	(match_operand:DF 1 "nonimmediate_operand" "r,m,r,r,x,x,m,x"))]
20281f5e8f30Smiod  ""
20291f5e8f30Smiod  "@
20301f5e8f30Smiod   or %0,%#r0,%1\;or %d0,%#r0,%d1
20311f5e8f30Smiod   %V1ld.d\\t %0,%1
20321f5e8f30Smiod   %v0st.d\\t %1,%0
20331f5e8f30Smiod   mov.d %0,%1
20341f5e8f30Smiod   mov.d %0,%1
20351f5e8f30Smiod   mov %0,%1
20361f5e8f30Smiod   %V1ld.d\\t %0,%1
20371f5e8f30Smiod   %v0st.d\\t %1,%0"
20381f5e8f30Smiod  [(set_attr "type" "marith,loadd,store,mov,mov,mov,loadd,store")])
20391f5e8f30Smiod
20401f5e8f30Smiod(define_insn ""
20411f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r")
20421f5e8f30Smiod	(subreg:DF (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
20431f5e8f30Smiod			      (match_operand:SI 2 "immediate_operand" "in")) 0))]
20441f5e8f30Smiod  "!flag_pic"
20451f5e8f30Smiod  "or %0,%1,%#lo16(%2)")
20461f5e8f30Smiod
20471f5e8f30Smiod(define_insn ""
20481f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r")
20491f5e8f30Smiod	(match_operand:DF 1 "immediate_operand" "F"))]
20501f5e8f30Smiod   ""
20511f5e8f30Smiod   "* return output_load_const_double (operands);"
20521f5e8f30Smiod  [(set_attr "type" "marith")
20531f5e8f30Smiod   (set_attr "length" "4")]) ; length is 2, 3, or 4.
20541f5e8f30Smiod
20551f5e8f30Smiod;; SFmode move instructions
20561f5e8f30Smiod
20571f5e8f30Smiod(define_expand "movsf"
20581f5e8f30Smiod  [(set (match_operand:SF 0 "general_operand" "")
20591f5e8f30Smiod	(match_operand:SF 1 "general_operand" ""))]
20601f5e8f30Smiod  ""
20611f5e8f30Smiod  "
20621f5e8f30Smiod{
20631f5e8f30Smiod  if (emit_move_sequence (operands, SFmode, NULL_RTX))
20641f5e8f30Smiod    DONE;
20651f5e8f30Smiod}")
20661f5e8f30Smiod
20671f5e8f30Smiod(define_insn ""
20681f5e8f30Smiod  [(set (match_operand:SF 0 "register_operand" "=r,x")
20691f5e8f30Smiod	(const_int 0))]
20701f5e8f30Smiod  ""
20711f5e8f30Smiod  "@
20721f5e8f30Smiod   or %0,%#r0,0
20731f5e8f30Smiod   mov %0,%#x0"
20741f5e8f30Smiod  [(set_attr "type" "arith,mov")])
20751f5e8f30Smiod
20761f5e8f30Smiod(define_insn ""
20771f5e8f30Smiod  [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m,x,r,x,x,m")
20781f5e8f30Smiod	(match_operand:SF 1 "nonimmediate_operand" "r,m,r,r,x,x,m,x"))]
20791f5e8f30Smiod  ""
20801f5e8f30Smiod  "@
20811f5e8f30Smiod   or %0,%#r0,%1
20821f5e8f30Smiod   %V1ld\\t %0,%1
20831f5e8f30Smiod   %v0st\\t %r1,%0
20841f5e8f30Smiod   mov.s %0,%1
20851f5e8f30Smiod   mov.s %0,%1
20861f5e8f30Smiod   mov %0,%1
20871f5e8f30Smiod   %V1ld\\t %0,%1
20881f5e8f30Smiod   %v0st\\t %r1,%0"
20891f5e8f30Smiod  [(set_attr "type" "arith,load,store,mov,mov,mov,load,store")])
20901f5e8f30Smiod
20911f5e8f30Smiod(define_insn ""
20921f5e8f30Smiod  [(set (match_operand:SF 0 "register_operand" "=r")
20931f5e8f30Smiod	(subreg:SF (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
20941f5e8f30Smiod			      (match_operand:SI 2 "immediate_operand" "in")) 0))]
20951f5e8f30Smiod  "!flag_pic"
20961f5e8f30Smiod  "or %0,%1,%#lo16(%2)")
20971f5e8f30Smiod
20981f5e8f30Smiod(define_insn ""
20991f5e8f30Smiod  [(set (match_operand:SF 0 "register_operand" "=r")
21001f5e8f30Smiod	(match_operand:SF 1 "immediate_operand" "F"))]
21011f5e8f30Smiod  "operands[1] != const0_rtx"
21021f5e8f30Smiod  "* return output_load_const_float (operands);"
21031f5e8f30Smiod  [(set_attr "type" "marith")]) ; length is 1 or 2.
21041f5e8f30Smiod
21051f5e8f30Smiod;; CCmode move instructions
21061f5e8f30Smiod
21071f5e8f30Smiod;; These are a subset of the SImode move instructions. They are necessary
21081f5e8f30Smiod;; because the reload pass may elect to store reg:CC registers in memory,
21091f5e8f30Smiod;; and read them back.
21101f5e8f30Smiod
21111f5e8f30Smiod(define_expand "movcc"
21121f5e8f30Smiod  [(set (match_operand:CC 0 "general_operand" "")
21131f5e8f30Smiod	(match_operand:CC 1 "general_operand" ""))]
21141f5e8f30Smiod  ""
21151f5e8f30Smiod  "
21161f5e8f30Smiod{
21171f5e8f30Smiod  if (emit_move_sequence (operands, CCmode, NULL_RTX))
21181f5e8f30Smiod    DONE;
21191f5e8f30Smiod}")
21201f5e8f30Smiod
21211f5e8f30Smiod(define_insn ""
21221f5e8f30Smiod  [(set (match_operand:CC 0 "nonimmediate_operand" "=r,r,m")
21231f5e8f30Smiod	(match_operand:CC 1 "move_operand" "rI,m,rO"))]
21241f5e8f30Smiod  "(register_operand (operands[0], CCmode)
21251f5e8f30Smiod    || register_operand (operands[1], CCmode)
21261f5e8f30Smiod    || operands[1] == const0_rtx)"
21271f5e8f30Smiod  "@
21281f5e8f30Smiod   or %0,%#r0,%1
21291f5e8f30Smiod   %V1ld\\t %0,%1
21301f5e8f30Smiod   %v0st\\t %r1,%0"
21311f5e8f30Smiod  [(set_attr "type" "arith,load,store")])
21321f5e8f30Smiod
21331f5e8f30Smiod
21341f5e8f30Smiod;; String/block move insn.  See m88k.c for details.
21351f5e8f30Smiod
21361f5e8f30Smiod(define_expand "movstrsi"
21371f5e8f30Smiod  [(parallel [(set (mem:BLK (match_operand:BLK 0 "" ""))
21381f5e8f30Smiod		   (mem:BLK (match_operand:BLK 1 "" "")))
21391f5e8f30Smiod	      (use (match_operand:SI 2 "arith32_operand" ""))
21401f5e8f30Smiod	      (use (match_operand:SI 3 "immediate_operand" ""))])]
21411f5e8f30Smiod  ""
21421f5e8f30Smiod  "
21431f5e8f30Smiod{
21441f5e8f30Smiod  rtx dest_mem = operands[0];
21451f5e8f30Smiod  rtx src_mem = operands[1];
21461f5e8f30Smiod  operands[0] = copy_to_mode_reg (SImode, XEXP (operands[0], 0));
21471f5e8f30Smiod  operands[1] = copy_to_mode_reg (SImode, XEXP (operands[1], 0));
21481f5e8f30Smiod  expand_block_move (dest_mem, src_mem, operands);
21491f5e8f30Smiod  DONE;
21501f5e8f30Smiod}")
21511f5e8f30Smiod
21521f5e8f30Smiod;; Call a non-looping block move library function (e.g. __movstrSI96x64).
21531f5e8f30Smiod;; operand 0 is the function name
21541f5e8f30Smiod;; operand 1 is the destination pointer
21551f5e8f30Smiod;; operand 2 is the source pointer
21561f5e8f30Smiod;; operand 3 is the offset for the source and destination pointers
21571f5e8f30Smiod;; operand 4 is the first value to be loaded
21581f5e8f30Smiod;; operand 5 is the register to hold the value (r4 or r5, or r4 or r6 if DImode)
21591f5e8f30Smiod
21601f5e8f30Smiod(define_expand "call_block_move"
21611f5e8f30Smiod  [(set (reg:SI 3) (minus:SI (match_operand:SI 2 "register_operand" "")
21621f5e8f30Smiod			     (match_operand:SI 3 "immediate_operand" "")))
21631f5e8f30Smiod   (set (match_operand 5 "register_operand" "")
21641f5e8f30Smiod	(match_operand 4 "memory_operand" ""))
21651f5e8f30Smiod   (set (reg:SI 2) (minus:SI (match_operand:SI 1 "register_operand" "")
21661f5e8f30Smiod			     (match_dup 3)))
21671f5e8f30Smiod   (use (reg:SI 2))
21681f5e8f30Smiod   (use (reg:SI 3))
21691f5e8f30Smiod   (use (reg:SI 4))
21701f5e8f30Smiod   (use (reg:SI 5))
21711f5e8f30Smiod   (parallel [(set (reg:DI 2)
21721f5e8f30Smiod		   (call (mem:SI (match_operand 0 "" ""))
21731f5e8f30Smiod			 (const_int 0)))
21741f5e8f30Smiod	      (clobber (reg:SI 1))])]
21751f5e8f30Smiod  ""
21761f5e8f30Smiod  "")
21771f5e8f30Smiod
21781f5e8f30Smiod(define_expand "call_block_move_DI"
21791f5e8f30Smiod  [(set (reg:SI 3) (minus:SI (match_operand:SI 2 "register_operand" "")
21801f5e8f30Smiod			     (match_operand:SI 3 "immediate_operand" "")))
21811f5e8f30Smiod   (set (match_operand 5 "register_operand" "")
21821f5e8f30Smiod	(match_operand 4 "memory_operand" ""))
21831f5e8f30Smiod   (set (reg:SI 2) (minus:SI (match_operand:SI 1 "register_operand" "")
21841f5e8f30Smiod			     (match_dup 3)))
21851f5e8f30Smiod   (use (reg:SI 2))
21861f5e8f30Smiod   (use (reg:SI 3))
21871f5e8f30Smiod   (use (reg:DI 4))
21881f5e8f30Smiod   (use (reg:DI 6))
21891f5e8f30Smiod   (parallel [(set (reg:DI 2)
21901f5e8f30Smiod		   (call (mem:SI (match_operand 0 "" ""))
21911f5e8f30Smiod			 (const_int 0)))
21921f5e8f30Smiod	      (clobber (reg:SI 1))])]
21931f5e8f30Smiod  ""
21941f5e8f30Smiod  "")
21951f5e8f30Smiod
21961f5e8f30Smiod;; Call an SImode looping block move library function (e.g. __movstrSI64n68).
21971f5e8f30Smiod;; operands 0-5 as in the non-looping interface
21981f5e8f30Smiod;; operand 6 is the loop count
21991f5e8f30Smiod
22001f5e8f30Smiod(define_expand "call_movstrsi_loop"
22011f5e8f30Smiod  [(set (reg:SI 3) (minus:SI (match_operand:SI 2 "register_operand" "")
22021f5e8f30Smiod			     (match_operand:SI 3 "immediate_operand" "")))
22031f5e8f30Smiod   (set (match_operand:SI 5 "register_operand" "")
22041f5e8f30Smiod	(match_operand 4 "memory_operand" ""))
22051f5e8f30Smiod   (set (reg:SI 2) (minus:SI (match_operand:SI 1 "register_operand" "")
22061f5e8f30Smiod			     (match_dup 3)))
22071f5e8f30Smiod   (set (reg:SI 6) (match_operand:SI 6 "immediate_operand" ""))
22081f5e8f30Smiod   (use (reg:SI 2))
22091f5e8f30Smiod   (use (reg:SI 3))
22101f5e8f30Smiod   (use (match_dup 5))
22111f5e8f30Smiod   (use (reg:SI 6))
22121f5e8f30Smiod   (parallel [(set (reg:DI 2)
22131f5e8f30Smiod		   (call (mem:SI (match_operand 0 "" ""))
22141f5e8f30Smiod			 (const_int 0)))
22151f5e8f30Smiod	      (clobber (reg:SI 1))])]
22161f5e8f30Smiod  ""
22171f5e8f30Smiod  "")
22181f5e8f30Smiod
22191f5e8f30Smiod;;- zero extension instructions
22201f5e8f30Smiod
22211f5e8f30Smiod(define_expand "zero_extendhisi2"
22221f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
22231f5e8f30Smiod	(zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
22241f5e8f30Smiod  ""
22251f5e8f30Smiod  "
22261f5e8f30Smiod{
22271f5e8f30Smiod  if (GET_CODE (operands[1]) == MEM
22281f5e8f30Smiod      && symbolic_operand (XEXP (operands[1], 0), SImode))
22291f5e8f30Smiod    operands[1]
22301f5e8f30Smiod      = legitimize_address (flag_pic, operands[1], 0, 0);
22311f5e8f30Smiod}")
22321f5e8f30Smiod
22331f5e8f30Smiod(define_insn ""
22341f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,r,r")
22351f5e8f30Smiod	(zero_extend:SI (match_operand:HI 1 "move_operand" "!r,n,m")))]
22361f5e8f30Smiod  "GET_CODE (operands[1]) != CONST_INT"
22371f5e8f30Smiod  "@
22381f5e8f30Smiod   mask %0,%1,0xffff
22391f5e8f30Smiod   or %0,%#r0,%h1
22401f5e8f30Smiod   %V1ld.hu\\t %0,%1"
22411f5e8f30Smiod  [(set_attr "type" "arith,arith,load")])
22421f5e8f30Smiod
22431f5e8f30Smiod(define_expand "zero_extendqihi2"
22441f5e8f30Smiod  [(set (match_operand:HI 0 "register_operand" "")
22451f5e8f30Smiod	(zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
22461f5e8f30Smiod  ""
22471f5e8f30Smiod  "
22481f5e8f30Smiod{
22491f5e8f30Smiod  if (GET_CODE (operands[1]) == MEM
22501f5e8f30Smiod      && symbolic_operand (XEXP (operands[1], 0), HImode))
22511f5e8f30Smiod    operands[1]
22521f5e8f30Smiod      = legitimize_address (flag_pic, operands[1], 0, 0);
22531f5e8f30Smiod}")
22541f5e8f30Smiod
22551f5e8f30Smiod(define_insn ""
22561f5e8f30Smiod  [(set (match_operand:HI 0 "register_operand" "=r,r,r")
22571f5e8f30Smiod	(zero_extend:HI (match_operand:QI 1 "move_operand" "r,n,m")))]
22581f5e8f30Smiod  "GET_CODE (operands[1]) != CONST_INT"
22591f5e8f30Smiod  "@
22601f5e8f30Smiod   mask %0,%1,0xff
22611f5e8f30Smiod   or %0,%#r0,%q1
22621f5e8f30Smiod   %V1ld.bu\\t %0,%1"
22631f5e8f30Smiod  [(set_attr "type" "arith,arith,load")])
22641f5e8f30Smiod
22651f5e8f30Smiod(define_expand "zero_extendqisi2"
22661f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
22671f5e8f30Smiod	(zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
22681f5e8f30Smiod  ""
22691f5e8f30Smiod  "
22701f5e8f30Smiod{
22711f5e8f30Smiod  if (GET_CODE (operands[1]) == MEM
22721f5e8f30Smiod      && symbolic_operand (XEXP (operands[1], 0), SImode))
22731f5e8f30Smiod    {
22741f5e8f30Smiod      operands[1]
22751f5e8f30Smiod	= legitimize_address (flag_pic, operands[1], 0, 0);
22761f5e8f30Smiod      emit_insn (gen_rtx_SET (VOIDmode, operands[0],
22771f5e8f30Smiod			      gen_rtx_ZERO_EXTEND (SImode, operands[1])));
22781f5e8f30Smiod      DONE;
22791f5e8f30Smiod    }
22801f5e8f30Smiod}")
22811f5e8f30Smiod
22821f5e8f30Smiod(define_insn ""
22831f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,r,r")
22841f5e8f30Smiod	(zero_extend:SI (match_operand:QI 1 "move_operand" "r,n,m")))]
22851f5e8f30Smiod  "GET_CODE (operands[1]) != CONST_INT"
22861f5e8f30Smiod  "@
22871f5e8f30Smiod   mask %0,%1,0xff
22881f5e8f30Smiod   or %0,%#r0,%q1
22891f5e8f30Smiod   %V1ld.bu\\t %0,%1"
22901f5e8f30Smiod  [(set_attr "type" "arith,arith,load")])
22911f5e8f30Smiod
22921f5e8f30Smiod;;- sign extension instructions
22931f5e8f30Smiod
22941f5e8f30Smiod(define_insn "extendsidi2"
22951f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
22961f5e8f30Smiod	(sign_extend:DI (match_operand:SI 1 "register_operand" "r")))]
22971f5e8f30Smiod  ""
22981f5e8f30Smiod  "#")
22991f5e8f30Smiod
23001f5e8f30Smiod(define_split
23011f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "")
23021f5e8f30Smiod	(sign_extend:DI (match_operand:SI 1 "register_operand" "")))]
23031f5e8f30Smiod  "reload_completed
23041f5e8f30Smiod   && GET_CODE (operands[0]) == REG
23051f5e8f30Smiod   && GET_CODE (operands[1]) == REG"
23061f5e8f30Smiod  [(set (subreg:SI (match_dup 0) 4) (match_dup 1))
23071f5e8f30Smiod   (set (subreg:SI (match_dup 0) 0)
23081f5e8f30Smiod	(ashiftrt:SI (match_dup 1) (const_int 31)))]
23091f5e8f30Smiod  "")
23101f5e8f30Smiod
23111f5e8f30Smiod(define_expand "extendhisi2"
23121f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
23131f5e8f30Smiod	(sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
23141f5e8f30Smiod  ""
23151f5e8f30Smiod  "
23161f5e8f30Smiod{
23171f5e8f30Smiod  if (GET_CODE (operands[1]) == MEM
23181f5e8f30Smiod      && symbolic_operand (XEXP (operands[1], 0), SImode))
23191f5e8f30Smiod    operands[1]
23201f5e8f30Smiod      = legitimize_address (flag_pic, operands[1], 0, 0);
23211f5e8f30Smiod}")
23221f5e8f30Smiod
23231f5e8f30Smiod(define_insn ""
23241f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
23251f5e8f30Smiod	(sign_extend:SI (match_operand:HI 1 "move_operand" "!r,P,N,m")))]
23261f5e8f30Smiod  "GET_CODE (operands[1]) != CONST_INT"
23271f5e8f30Smiod  "@
23281f5e8f30Smiod   ext %0,%1,16<0>
23291f5e8f30Smiod   or %0,%#r0,%h1
23301f5e8f30Smiod   subu %0,%#r0,%H1
23311f5e8f30Smiod   %V1ld.h\\t %0,%1"
23321f5e8f30Smiod  [(set_attr "type" "bit,arith,arith,load")])
23331f5e8f30Smiod
23341f5e8f30Smiod(define_expand "extendqihi2"
23351f5e8f30Smiod  [(set (match_operand:HI 0 "register_operand" "")
23361f5e8f30Smiod	(sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
23371f5e8f30Smiod  ""
23381f5e8f30Smiod  "
23391f5e8f30Smiod{
23401f5e8f30Smiod  if (GET_CODE (operands[1]) == MEM
23411f5e8f30Smiod      && symbolic_operand (XEXP (operands[1], 0), HImode))
23421f5e8f30Smiod    operands[1]
23431f5e8f30Smiod      = legitimize_address (flag_pic, operands[1], 0, 0);
23441f5e8f30Smiod}")
23451f5e8f30Smiod
23461f5e8f30Smiod(define_insn ""
23471f5e8f30Smiod  [(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
23481f5e8f30Smiod	(sign_extend:HI (match_operand:QI 1 "move_operand" "!r,P,N,m")))]
23491f5e8f30Smiod  "GET_CODE (operands[1]) != CONST_INT"
23501f5e8f30Smiod  "@
23511f5e8f30Smiod   ext %0,%1,8<0>
23521f5e8f30Smiod   or %0,%#r0,%q1
23531f5e8f30Smiod   subu %0,%#r0,%Q1
23541f5e8f30Smiod   %V1ld.b\\t %0,%1"
23551f5e8f30Smiod  [(set_attr "type" "bit,arith,arith,load")])
23561f5e8f30Smiod
23571f5e8f30Smiod(define_expand "extendqisi2"
23581f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
23591f5e8f30Smiod	(sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
23601f5e8f30Smiod  ""
23611f5e8f30Smiod  "
23621f5e8f30Smiod{
23631f5e8f30Smiod  if (GET_CODE (operands[1]) == MEM
23641f5e8f30Smiod      && symbolic_operand (XEXP (operands[1], 0), SImode))
23651f5e8f30Smiod    operands[1]
23661f5e8f30Smiod      = legitimize_address (flag_pic, operands[1], 0, 0);
23671f5e8f30Smiod}")
23681f5e8f30Smiod
23691f5e8f30Smiod(define_insn ""
23701f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
23711f5e8f30Smiod	(sign_extend:SI (match_operand:QI 1 "move_operand" "!r,P,N,m")))]
23721f5e8f30Smiod  "GET_CODE (operands[1]) != CONST_INT"
23731f5e8f30Smiod  "@
23741f5e8f30Smiod   ext %0,%1,8<0>
23751f5e8f30Smiod   or %0,%#r0,%q1
23761f5e8f30Smiod   subu %0,%#r0,%Q1
23771f5e8f30Smiod   %V1ld.b\\t %0,%1"
23781f5e8f30Smiod  [(set_attr "type" "bit,arith,arith,load")])
23791f5e8f30Smiod
23801f5e8f30Smiod;; Conversions between float and double.
23811f5e8f30Smiod
23821f5e8f30Smiod;; The fadd instruction does not conform to IEEE 754 when used to
23831f5e8f30Smiod;; convert between float and double.  In particular, the sign of -0 is
23841f5e8f30Smiod;; not preserved.  Interestingly, fsub does conform.
23851f5e8f30Smiod
23861f5e8f30Smiod(define_expand "extendsfdf2"
23871f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r")
23881f5e8f30Smiod	(float_extend:DF (match_operand:SF 1 "register_operand" "r")))]
23891f5e8f30Smiod  ""
23901f5e8f30Smiod  "")
23911f5e8f30Smiod
23921f5e8f30Smiod(define_insn ""
23931f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r")
23941f5e8f30Smiod	(float_extend:DF (match_operand:SF 1 "register_operand" "r")))]
23951f5e8f30Smiod  "! TARGET_88110"
23961f5e8f30Smiod  "fsub.dss %0,%1,%#r0"
23971f5e8f30Smiod  [(set_attr "type" "spadd")])
23981f5e8f30Smiod
23991f5e8f30Smiod(define_insn ""
24001f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
24011f5e8f30Smiod	(float_extend:DF (match_operand:SF 1 "register_operand" "r,x")))]
24021f5e8f30Smiod  "TARGET_88110"
24031f5e8f30Smiod  "fcvt.ds %0,%1"
24041f5e8f30Smiod  [(set_attr "type" "spadd")])
24051f5e8f30Smiod
24061f5e8f30Smiod(define_expand "truncdfsf2"
24071f5e8f30Smiod  [(set (match_operand:SF 0 "register_operand" "=r")
24081f5e8f30Smiod	(float_truncate:SF (match_operand:DF 1 "register_operand" "r")))]
24091f5e8f30Smiod  ""
24101f5e8f30Smiod  "")
24111f5e8f30Smiod
24121f5e8f30Smiod(define_insn ""
24131f5e8f30Smiod  [(set (match_operand:SF 0 "register_operand" "=r")
24141f5e8f30Smiod	(float_truncate:SF (match_operand:DF 1 "register_operand" "r")))]
24151f5e8f30Smiod  "! TARGET_88110"
24161f5e8f30Smiod  "fsub.sds %0,%1,%#r0"
24171f5e8f30Smiod  [(set_attr "type" "dpadd")])
24181f5e8f30Smiod
24191f5e8f30Smiod(define_insn ""
24201f5e8f30Smiod  [(set (match_operand:SF 0 "register_operand" "=r,x")
24211f5e8f30Smiod	(float_truncate:SF (match_operand:DF 1 "register_operand" "r,x")))]
24221f5e8f30Smiod  "TARGET_88110"
24231f5e8f30Smiod  "fcvt.sd %0,%1"
24241f5e8f30Smiod  [(set_attr "type" "dpadd")])
24251f5e8f30Smiod
24261f5e8f30Smiod;; Conversions between floating point and integer
24271f5e8f30Smiod
24281f5e8f30Smiod(define_insn "floatsidf2"
24291f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
24301f5e8f30Smiod	(float:DF (match_operand:SI 1 "register_operand" "r,r")))]
24311f5e8f30Smiod  ""
24321f5e8f30Smiod  "flt.ds %0,%1"
24331f5e8f30Smiod  [(set_attr "type" "spadd,dpadd")])
24341f5e8f30Smiod
24351f5e8f30Smiod(define_insn "floatsisf2"
24361f5e8f30Smiod  [(set (match_operand:SF 0 "register_operand" "=r,x")
24371f5e8f30Smiod	(float:SF (match_operand:SI 1 "register_operand" "r,r")))]
24381f5e8f30Smiod  ""
24391f5e8f30Smiod  "flt.ss %0,%1"
24401f5e8f30Smiod  [(set_attr "type" "spadd,spadd")])
24411f5e8f30Smiod
24421f5e8f30Smiod(define_insn "fix_truncdfsi2"
24431f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,r")
24441f5e8f30Smiod	(fix:SI (match_operand:DF 1 "register_operand" "r,x")))]
24451f5e8f30Smiod  ""
24461f5e8f30Smiod  "trnc.sd %0,%1"
24471f5e8f30Smiod  [(set_attr "type" "dpadd,dpadd")])
24481f5e8f30Smiod
24491f5e8f30Smiod(define_insn "fix_truncsfsi2"
24501f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,r")
24511f5e8f30Smiod	(fix:SI (match_operand:SF 1 "register_operand" "r,x")))]
24521f5e8f30Smiod  ""
24531f5e8f30Smiod  "trnc.ss %0,%1"
24541f5e8f30Smiod  [(set_attr "type" "spadd,dpadd")])
24551f5e8f30Smiod
24561f5e8f30Smiod
24571f5e8f30Smiod;;- arithmetic instructions
24581f5e8f30Smiod;;- add instructions
24591f5e8f30Smiod
24601f5e8f30Smiod(define_insn "addsi3"
24611f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,r")
24621f5e8f30Smiod	(plus:SI (match_operand:SI 1 "arith32_operand" "%r,r")
24631f5e8f30Smiod		 (match_operand:SI 2 "arith32_operand" "rI,J")))]
24641f5e8f30Smiod  ""
24651f5e8f30Smiod  "@
24661f5e8f30Smiod   addu %0,%1,%2
24671f5e8f30Smiod   subu %0,%1,%n2")
24681f5e8f30Smiod
24691f5e8f30Smiod;; patterns for mixed mode floating point.
24701f5e8f30Smiod;; Do not define patterns that utilize mixed mode arithmetic that result
24711f5e8f30Smiod;; in narrowing the precision, because it loses accuracy, since the standard
24721f5e8f30Smiod;; requires double rounding, whereas the 88000 instruction only rounds once.
24731f5e8f30Smiod
24741f5e8f30Smiod(define_expand "adddf3"
24751f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
24761f5e8f30Smiod	(plus:DF (match_operand:DF 1 "general_operand" "%r,x")
24771f5e8f30Smiod		 (match_operand:DF 2 "general_operand" "r,x")))]
24781f5e8f30Smiod  ""
24791f5e8f30Smiod  "
24801f5e8f30Smiod{
24811f5e8f30Smiod  operands[1] = legitimize_operand (operands[1], DFmode);
24821f5e8f30Smiod  operands[2] = legitimize_operand (operands[2], DFmode);
24831f5e8f30Smiod}")
24841f5e8f30Smiod
24851f5e8f30Smiod(define_insn ""
24861f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
24871f5e8f30Smiod	(plus:DF (float_extend:DF (match_operand:SF 1 "register_operand" "r,x"))
24881f5e8f30Smiod		 (float_extend:DF (match_operand:SF 2 "register_operand" "r,x"))))]
24891f5e8f30Smiod  ""
24901f5e8f30Smiod  "fadd.dss %0,%1,%2"
24911f5e8f30Smiod  [(set_attr "type" "spadd")])
24921f5e8f30Smiod
24931f5e8f30Smiod(define_insn ""
24941f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
24951f5e8f30Smiod	(plus:DF (match_operand:DF 1 "register_operand" "r,x")
24961f5e8f30Smiod		 (float_extend:DF (match_operand:SF 2 "register_operand" "r,x"))))]
24971f5e8f30Smiod  ""
24981f5e8f30Smiod  "fadd.dds %0,%1,%2"
24991f5e8f30Smiod  [(set_attr "type" "dpadd")])
25001f5e8f30Smiod
25011f5e8f30Smiod(define_insn ""
25021f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
25031f5e8f30Smiod	(plus:DF (float_extend:DF (match_operand:SF 1 "register_operand" "r,x"))
25041f5e8f30Smiod		 (match_operand:DF 2 "register_operand" "r,x")))]
25051f5e8f30Smiod  ""
25061f5e8f30Smiod  "fadd.dsd %0,%1,%2"
25071f5e8f30Smiod  [(set_attr "type" "dpadd")])
25081f5e8f30Smiod
25091f5e8f30Smiod(define_insn ""
25101f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
25111f5e8f30Smiod	(plus:DF (match_operand:DF 1 "register_operand" "%r,x")
25121f5e8f30Smiod		 (match_operand:DF 2 "register_operand" "r,x")))]
25131f5e8f30Smiod  ""
25141f5e8f30Smiod  "fadd.ddd %0,%1,%2"
25151f5e8f30Smiod  [(set_attr "type" "dpadd")])
25161f5e8f30Smiod
25171f5e8f30Smiod(define_insn "addsf3"
25181f5e8f30Smiod  [(set (match_operand:SF 0 "register_operand" "=r,x")
25191f5e8f30Smiod	(plus:SF (match_operand:SF 1 "register_operand" "%r,x")
25201f5e8f30Smiod		 (match_operand:SF 2 "register_operand" "r,x")))]
25211f5e8f30Smiod  ""
25221f5e8f30Smiod  "fadd.sss %0,%1,%2"
25231f5e8f30Smiod  [(set_attr "type" "spadd")])
25241f5e8f30Smiod
25251f5e8f30Smiod(define_insn ""
25261f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
25271f5e8f30Smiod	(plus:DI (match_operand:DI 1 "register_operand" "r")
25281f5e8f30Smiod		 (zero_extend:DI
25291f5e8f30Smiod		  (match_operand:SI 2 "register_operand" "r"))))
25301f5e8f30Smiod   (clobber (reg:CC 0))]
25311f5e8f30Smiod  ""
25321f5e8f30Smiod  "addu.co %d0,%d1,%2\;addu.ci %0,%1,%#r0"
25331f5e8f30Smiod  [(set_attr "type" "marith")])
25341f5e8f30Smiod
25351f5e8f30Smiod(define_insn ""
25361f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
25371f5e8f30Smiod	(plus:DI (zero_extend:DI
25381f5e8f30Smiod		  (match_operand:SI 1 "register_operand" "r"))
25391f5e8f30Smiod		 (match_operand:DI 2 "register_operand" "r")))
25401f5e8f30Smiod   (clobber (reg:CC 0))]
25411f5e8f30Smiod  ""
25421f5e8f30Smiod  "addu.co %d0,%1,%d2\;addu.ci %0,%#r0,%2"
25431f5e8f30Smiod  [(set_attr "type" "marith")])
25441f5e8f30Smiod
25451f5e8f30Smiod(define_insn "adddi3"
25461f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
25471f5e8f30Smiod	(plus:DI (match_operand:DI 1 "register_operand" "%r")
25481f5e8f30Smiod		 (match_operand:DI 2 "register_operand" "r")))
25491f5e8f30Smiod   (clobber (reg:CC 0))]
25501f5e8f30Smiod  ""
25511f5e8f30Smiod  "addu.co %d0,%d1,%d2\;addu.ci %0,%1,%2"
25521f5e8f30Smiod  [(set_attr "type" "marith")])
25531f5e8f30Smiod
25541f5e8f30Smiod;; Add with carry insns.
25551f5e8f30Smiod
25561f5e8f30Smiod(define_insn ""
25571f5e8f30Smiod  [(parallel [(set (match_operand:SI 0 "register_operand" "=r")
25581f5e8f30Smiod		   (plus:SI (match_operand:SI 1 "reg_or_0_operand" "rO")
25591f5e8f30Smiod			    (match_operand:SI 2 "reg_or_0_operand" "rO")))
25601f5e8f30Smiod	      (set (reg:CC 0)
25611f5e8f30Smiod		   (unspec:CC [(match_dup 1) (match_dup 2)] 0))])]
25621f5e8f30Smiod  ""
256324ed4e7eSmiod  "addu.co %0,%r1,%r2")
25641f5e8f30Smiod
25651f5e8f30Smiod(define_insn ""
25661f5e8f30Smiod  [(set (reg:CC 0) (unspec:CC [(match_operand:SI 0 "reg_or_0_operand" "rO")
25671f5e8f30Smiod			       (match_operand:SI 1 "reg_or_0_operand" "rO")]
25681f5e8f30Smiod			      0))]
25691f5e8f30Smiod  ""
25701f5e8f30Smiod  "addu.co %#r0,%r0,%r1")
25711f5e8f30Smiod
25721f5e8f30Smiod(define_insn ""
25731f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
25741f5e8f30Smiod	(plus:SI (match_operand:SI 1 "reg_or_0_operand" "rO")
25751f5e8f30Smiod		 (unspec:SI [(match_operand:SI 2 "reg_or_0_operand" "rO")
25761f5e8f30Smiod			     (reg:CC 0)] 0)))]
25771f5e8f30Smiod  ""
257824ed4e7eSmiod  "addu.ci %0,%r1,%r2")
25791f5e8f30Smiod
25801f5e8f30Smiod;;- subtract instructions
25811f5e8f30Smiod
25821f5e8f30Smiod(define_insn "subsi3"
25831f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
25841f5e8f30Smiod	(minus:SI (match_operand:SI 1 "register_operand" "r")
25851f5e8f30Smiod		  (match_operand:SI 2 "arith32_operand" "rI")))]
25861f5e8f30Smiod  ""
25871f5e8f30Smiod  "subu %0,%1,%2")
25881f5e8f30Smiod
25891f5e8f30Smiod;; patterns for mixed mode floating point
25901f5e8f30Smiod;; Do not define patterns that utilize mixed mode arithmetic that result
25911f5e8f30Smiod;; in narrowing the precision, because it loses accuracy, since the standard
25921f5e8f30Smiod;; requires double rounding, whereas the 88000 instruction only rounds once.
25931f5e8f30Smiod
25941f5e8f30Smiod(define_expand "subdf3"
25951f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
25961f5e8f30Smiod	(minus:DF (match_operand:DF 1 "general_operand" "r,x")
25971f5e8f30Smiod		  (match_operand:DF 2 "general_operand" "r,x")))]
25981f5e8f30Smiod  ""
25991f5e8f30Smiod  "
26001f5e8f30Smiod{
26011f5e8f30Smiod  operands[1] = legitimize_operand (operands[1], DFmode);
26021f5e8f30Smiod  operands[2] = legitimize_operand (operands[2], DFmode);
26031f5e8f30Smiod}")
26041f5e8f30Smiod
26051f5e8f30Smiod(define_insn ""
26061f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
26071f5e8f30Smiod	(minus:DF (float_extend:DF (match_operand:SF 1 "register_operand" "r,x"))
26081f5e8f30Smiod		  (float_extend:DF (match_operand:SF 2 "register_operand" "r,x"))))]
26091f5e8f30Smiod  ""
26101f5e8f30Smiod  "fsub.dss %0,%1,%2"
26111f5e8f30Smiod  [(set_attr "type" "spadd")])
26121f5e8f30Smiod
26131f5e8f30Smiod(define_insn ""
26141f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
26151f5e8f30Smiod	(minus:DF (match_operand:DF 1 "register_operand" "r,x")
26161f5e8f30Smiod		  (float_extend:DF (match_operand:SF 2 "register_operand" "r,x"))))]
26171f5e8f30Smiod  ""
26181f5e8f30Smiod  "fsub.dds %0,%1,%2"
26191f5e8f30Smiod  [(set_attr "type" "dpadd")])
26201f5e8f30Smiod
26211f5e8f30Smiod(define_insn ""
26221f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
26231f5e8f30Smiod	(minus:DF (float_extend:DF (match_operand:SF 1 "register_operand" "r,x"))
26241f5e8f30Smiod		  (match_operand:DF 2 "register_operand" "r,x")))]
26251f5e8f30Smiod  ""
26261f5e8f30Smiod  "fsub.dsd %0,%1,%2"
26271f5e8f30Smiod  [(set_attr "type" "dpadd")])
26281f5e8f30Smiod
26291f5e8f30Smiod(define_insn ""
26301f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
26311f5e8f30Smiod	(minus:DF (match_operand:DF 1 "register_operand" "r,x")
26321f5e8f30Smiod		  (match_operand:DF 2 "register_operand" "r,x")))]
26331f5e8f30Smiod  ""
26341f5e8f30Smiod  "fsub.ddd %0,%1,%2"
26351f5e8f30Smiod  [(set_attr "type" "dpadd")])
26361f5e8f30Smiod
26371f5e8f30Smiod(define_insn "subsf3"
26381f5e8f30Smiod  [(set (match_operand:SF 0 "register_operand" "=r,x")
26391f5e8f30Smiod	(minus:SF (match_operand:SF 1 "register_operand" "r,x")
26401f5e8f30Smiod		  (match_operand:SF 2 "register_operand" "r,x")))]
26411f5e8f30Smiod  ""
26421f5e8f30Smiod  "fsub.sss %0,%1,%2"
26431f5e8f30Smiod  [(set_attr "type" "spadd")])
26441f5e8f30Smiod
26451f5e8f30Smiod(define_insn ""
26461f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
26471f5e8f30Smiod	(minus:DI (match_operand:DI 1 "register_operand" "r")
26481f5e8f30Smiod		  (zero_extend:DI
26491f5e8f30Smiod		   (match_operand:SI 2 "register_operand" "r"))))
26501f5e8f30Smiod   (clobber (reg:CC 0))]
26511f5e8f30Smiod  ""
26521f5e8f30Smiod  "subu.co %d0,%d1,%2\;subu.ci %0,%1,%#r0"
26531f5e8f30Smiod  [(set_attr "type" "marith")])
26541f5e8f30Smiod
26551f5e8f30Smiod(define_insn ""
26561f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
26571f5e8f30Smiod	(minus:DI (zero_extend:DI
26581f5e8f30Smiod		   (match_operand:SI 1 "register_operand" "r"))
26591f5e8f30Smiod		  (match_operand:DI 2 "register_operand" "r")))
26601f5e8f30Smiod   (clobber (reg:CC 0))]
26611f5e8f30Smiod  ""
26621f5e8f30Smiod  "subu.co %d0,%1,%d2\;subu.ci %0,%#r0,%2"
26631f5e8f30Smiod  [(set_attr "type" "marith")])
26641f5e8f30Smiod
26651f5e8f30Smiod(define_insn "subdi3"
26661f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
26671f5e8f30Smiod	(minus:DI (match_operand:DI 1 "register_operand" "r")
26681f5e8f30Smiod		  (match_operand:DI 2 "register_operand" "r")))
26691f5e8f30Smiod   (clobber (reg:CC 0))]
26701f5e8f30Smiod  ""
26711f5e8f30Smiod  "subu.co %d0,%d1,%d2\;subu.ci %0,%1,%2"
26721f5e8f30Smiod  [(set_attr "type" "marith")])
26731f5e8f30Smiod
26741f5e8f30Smiod;; Subtract with carry insns.
26751f5e8f30Smiod
26761f5e8f30Smiod(define_insn ""
26771f5e8f30Smiod  [(parallel [(set (match_operand:SI 0 "register_operand" "=r")
26781f5e8f30Smiod		   (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rO")
26791f5e8f30Smiod			     (match_operand:SI 2 "reg_or_0_operand" "rO")))
26801f5e8f30Smiod	      (set (reg:CC 0)
26811f5e8f30Smiod		   (unspec:CC [(match_dup 1) (match_dup 2)] 1))])]
26821f5e8f30Smiod  ""
268324ed4e7eSmiod  "subu.co %0,%r1,%r2")
26841f5e8f30Smiod
26851f5e8f30Smiod(define_insn ""
26861f5e8f30Smiod  [(set (reg:CC 0) (unspec:CC [(match_operand:SI 0 "reg_or_0_operand" "rO")
26871f5e8f30Smiod			       (match_operand:SI 1 "reg_or_0_operand" "rO")]
26881f5e8f30Smiod			      1))]
26891f5e8f30Smiod  ""
26901f5e8f30Smiod  "subu.co %#r0,%r0,%r1")
26911f5e8f30Smiod
26921f5e8f30Smiod(define_insn ""
26931f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
26941f5e8f30Smiod	(minus:SI (match_operand:SI 1 "reg_or_0_operand" "rO")
26951f5e8f30Smiod		  (unspec:SI [(match_operand:SI 2 "reg_or_0_operand" "rO")
26961f5e8f30Smiod			      (reg:CC 0)] 1)))]
26971f5e8f30Smiod  ""
269824ed4e7eSmiod  "subu.ci %0,%r1,%r2")
26991f5e8f30Smiod
27001f5e8f30Smiod;;- multiply instructions
27011f5e8f30Smiod;;
27021f5e8f30Smiod;; There is an unfounded silicon errata for E.1 requiring that an
27031f5e8f30Smiod;; immediate constant value in div/divu/mul instructions be less than
27041f5e8f30Smiod;; 0x800.  This is no longer provided for.
27051f5e8f30Smiod
27061f5e8f30Smiod(define_insn "mulsi3"
27071f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
27081f5e8f30Smiod	(mult:SI (match_operand:SI 1 "arith32_operand" "%r")
27091f5e8f30Smiod		 (match_operand:SI 2 "arith32_operand" "rI")))]
27101f5e8f30Smiod  ""
27111f5e8f30Smiod  "mul %0,%1,%2"
27121f5e8f30Smiod  [(set_attr "type" "imul")])
27131f5e8f30Smiod
27141f5e8f30Smiod(define_insn "umulsidi3"
27151f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
27161f5e8f30Smiod        (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%r"))
27171f5e8f30Smiod                 (zero_extend:DI (match_operand:SI 2 "register_operand" "r"))))]
27181f5e8f30Smiod  "TARGET_88110"
27191f5e8f30Smiod  "mulu.d %0,%1,%2"
27201f5e8f30Smiod  [(set_attr "type" "imul")])
27211f5e8f30Smiod
27221f5e8f30Smiod;; patterns for mixed mode floating point
27231f5e8f30Smiod;; Do not define patterns that utilize mixed mode arithmetic that result
27241f5e8f30Smiod;; in narrowing the precision, because it loses accuracy, since the standard
27251f5e8f30Smiod;; requires double rounding, whereas the 88000 instruction only rounds once.
27261f5e8f30Smiod
27271f5e8f30Smiod(define_expand "muldf3"
27281f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
27291f5e8f30Smiod	(mult:DF (match_operand:DF 1 "general_operand" "%r,x")
27301f5e8f30Smiod		 (match_operand:DF 2 "general_operand" "r,x")))]
27311f5e8f30Smiod  ""
27321f5e8f30Smiod  "
27331f5e8f30Smiod{
27341f5e8f30Smiod  operands[1] = legitimize_operand (operands[1], DFmode);
27351f5e8f30Smiod  operands[2] = legitimize_operand (operands[2], DFmode);
27361f5e8f30Smiod}")
27371f5e8f30Smiod
27381f5e8f30Smiod(define_insn ""
27391f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
27401f5e8f30Smiod	(mult:DF (float_extend:DF (match_operand:SF 1 "register_operand" "r,x"))
27411f5e8f30Smiod		 (float_extend:DF (match_operand:SF 2 "register_operand" "r,x"))))]
27421f5e8f30Smiod  ""
27431f5e8f30Smiod  "fmul.dss %0,%1,%2"
27441f5e8f30Smiod  [(set_attr "type" "spmul")])
27451f5e8f30Smiod
27461f5e8f30Smiod(define_insn ""
27471f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
27481f5e8f30Smiod	(mult:DF (match_operand:DF 1 "register_operand" "r,x")
27491f5e8f30Smiod		 (float_extend:DF (match_operand:SF 2 "register_operand" "r,x"))))]
27501f5e8f30Smiod  ""
27511f5e8f30Smiod  "fmul.dds %0,%1,%2"
27521f5e8f30Smiod  [(set_attr "type" "spmul")])
27531f5e8f30Smiod
27541f5e8f30Smiod(define_insn ""
27551f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
27561f5e8f30Smiod	(mult:DF (float_extend:DF (match_operand:SF 1 "register_operand" "r,x"))
27571f5e8f30Smiod		 (match_operand:DF 2 "register_operand" "r,x")))]
27581f5e8f30Smiod  ""
27591f5e8f30Smiod  "fmul.dsd %0,%1,%2"
27601f5e8f30Smiod  [(set_attr "type" "spmul")])
27611f5e8f30Smiod
27621f5e8f30Smiod(define_insn ""
27631f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
27641f5e8f30Smiod	(mult:DF (match_operand:DF 1 "register_operand" "%r,x")
27651f5e8f30Smiod		 (match_operand:DF 2 "register_operand" "r,x")))]
27661f5e8f30Smiod  ""
27671f5e8f30Smiod  "fmul.ddd %0,%1,%2"
27681f5e8f30Smiod  [(set_attr "type" "dpmul")])
27691f5e8f30Smiod
27701f5e8f30Smiod(define_insn "mulsf3"
27711f5e8f30Smiod  [(set (match_operand:SF 0 "register_operand" "=r,x")
27721f5e8f30Smiod	(mult:SF (match_operand:SF 1 "register_operand" "%r,x")
27731f5e8f30Smiod		 (match_operand:SF 2 "register_operand" "r,x")))]
27741f5e8f30Smiod  ""
27751f5e8f30Smiod  "fmul.sss %0,%1,%2"
27761f5e8f30Smiod  [(set_attr "type" "spmul")])
27771f5e8f30Smiod
27781f5e8f30Smiod;;- divide instructions
27791f5e8f30Smiod;;
27801f5e8f30Smiod;; The 88k div and divu instructions don't reliably trap on
27811f5e8f30Smiod;; divide-by-zero.  A trap to vector 503 asserts divide-by-zero.  The
27821f5e8f30Smiod;; general scheme for doing divide is to do a 4-way split based on the
27831f5e8f30Smiod;; sign of the two operand and do the appropriate negates.
27841f5e8f30Smiod;;
27851f5e8f30Smiod;; The conditional trap instruction is not used as this serializes the
27861f5e8f30Smiod;; processor.  Instead a conditional branch and an unconditional trap
27871f5e8f30Smiod;; are used, but after the divu.  Since the divu takes up to 38 cycles,
27881f5e8f30Smiod;; the conditional branch is essentially free.
27891f5e8f30Smiod;;
27901f5e8f30Smiod;; Two target options control how divide is done.  One options selects
27911f5e8f30Smiod;; whether to do the branch and negate scheme instead of using the div
27921f5e8f30Smiod;; instruction; the other option selects whether to explicitly check
27931f5e8f30Smiod;; for divide-by-zero or take your chances.  If the div instruction is
27941f5e8f30Smiod;; used, the O/S must complete the operation if the operands are
27951f5e8f30Smiod;; negative.  The O/S will signal an overflow condition if the most
27961f5e8f30Smiod;; negative number (-2147483648) is divided by negative 1.
27971f5e8f30Smiod;;
27981f5e8f30Smiod;; There is an unfounded silicon errata for E.1 requiring that an
27991f5e8f30Smiod;; immediate constant value in div/divu/mul instructions be less than
28001f5e8f30Smiod;; 0x800.  This is no longer provided for.
28011f5e8f30Smiod
28021f5e8f30Smiod;; Division by 0 trap
28031f5e8f30Smiod(define_insn "trap_divide_by_zero"
28041f5e8f30Smiod  [(trap_if (const_int 1) (const_int 503))]
28051f5e8f30Smiod  ""
28061f5e8f30Smiod  "tb0 0,%#r0,503"
280724ed4e7eSmiod  [(set_attr "type" "weird")
280824ed4e7eSmiod   (set_attr "length" "1")])
28091f5e8f30Smiod
28101f5e8f30Smiod;; Conditional division by 0 trap.
28111f5e8f30Smiod(define_expand "tcnd_divide_by_zero"
28121f5e8f30Smiod  [(set (pc)
28131f5e8f30Smiod	(if_then_else (eq (match_operand:SI 0 "register_operand" "")
28141f5e8f30Smiod			  (const_int 0))
28151f5e8f30Smiod		      (pc)
28161f5e8f30Smiod		      (match_operand 1 "" "")))
28171f5e8f30Smiod   (trap_if (const_int 1) (const_int 503))]
28181f5e8f30Smiod  ""
28191f5e8f30Smiod  "
28201f5e8f30Smiod{
28211f5e8f30Smiod  emit_insn (gen_cmpsi (operands[0], const0_rtx));
28221f5e8f30Smiod  emit_jump_insn (gen_bne (operands[1]));
28231f5e8f30Smiod  emit_insn (gen_trap_divide_by_zero ());
28241f5e8f30Smiod  DONE;
28251f5e8f30Smiod}")
28261f5e8f30Smiod
28271f5e8f30Smiod(define_expand "divsi3"
28281f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
28291f5e8f30Smiod	(div:SI (match_operand:SI 1 "arith32_operand" "")
28301f5e8f30Smiod		(match_operand:SI 2 "arith32_operand" "")))]
28311f5e8f30Smiod  ""
28321f5e8f30Smiod  "
28331f5e8f30Smiod{
28341f5e8f30Smiod  rtx op0 = operands[0];
28351f5e8f30Smiod  rtx op1 = operands[1];
28361f5e8f30Smiod  rtx op2 = operands[2];
28371f5e8f30Smiod  rtx join_label;
28381f5e8f30Smiod
28391f5e8f30Smiod  /* @@ This needs to be reworked.  Torbjorn Granlund has suggested making
28401f5e8f30Smiod     it a runtime (perhaps quite special).  */
28411f5e8f30Smiod
28421f5e8f30Smiod  if (GET_CODE (op1) == CONST_INT)
28431f5e8f30Smiod    op1 = force_reg (SImode, op1);
28441f5e8f30Smiod
28451f5e8f30Smiod  else if (GET_CODE (op2) == CONST_INT
28461f5e8f30Smiod	   && ! SMALL_INT (operands[2]))
28471f5e8f30Smiod    op2 = force_reg (SImode, op2);
28481f5e8f30Smiod
28491f5e8f30Smiod  if (op2 == const0_rtx)
28501f5e8f30Smiod    {
28511f5e8f30Smiod      emit_insn (gen_trap_divide_by_zero ());
28521f5e8f30Smiod      emit_insn (gen_dummy (op0));
28531f5e8f30Smiod      DONE;
28541f5e8f30Smiod    }
28551f5e8f30Smiod
28561f5e8f30Smiod  if (TARGET_USE_DIV)
28571f5e8f30Smiod    {
28581f5e8f30Smiod      emit_move_insn (op0, gen_rtx_DIV (SImode, op1, op2));
28591f5e8f30Smiod      if (TARGET_CHECK_ZERO_DIV && GET_CODE (op2) != CONST_INT)
28601f5e8f30Smiod	{
28611f5e8f30Smiod	  rtx label = gen_label_rtx ();
28621f5e8f30Smiod	  emit_insn (gen_tcnd_divide_by_zero (op2, label));
28631f5e8f30Smiod	  emit_label (label);
28641f5e8f30Smiod	  emit_insn (gen_dummy (op0));
28651f5e8f30Smiod	}
28661f5e8f30Smiod      DONE;
28671f5e8f30Smiod    }
28681f5e8f30Smiod
28691f5e8f30Smiod  join_label = gen_label_rtx ();
28701f5e8f30Smiod  if (GET_CODE (op1) == CONST_INT)
28711f5e8f30Smiod    {
28721f5e8f30Smiod      int neg = FALSE;
28731f5e8f30Smiod      rtx neg_op2 = gen_reg_rtx (SImode);
28741f5e8f30Smiod      rtx label1 = gen_label_rtx ();
28751f5e8f30Smiod
28761f5e8f30Smiod      if (INTVAL (op1) < 0)
28771f5e8f30Smiod	{
28781f5e8f30Smiod	  neg = TRUE;
28791f5e8f30Smiod	  op1 = GEN_INT (-INTVAL (op1));
28801f5e8f30Smiod	}
28811f5e8f30Smiod      op1 = force_reg (SImode, op1);
28821f5e8f30Smiod
28831f5e8f30Smiod      emit_insn (gen_negsi2 (neg_op2, op2));
28841f5e8f30Smiod      emit_insn (gen_cmpsi (op2, const0_rtx));
28851f5e8f30Smiod      emit_jump_insn (gen_bgt (label1));
28861f5e8f30Smiod						/* constant / 0-or-negative */
28871f5e8f30Smiod      emit_move_insn (op0, gen_rtx_UDIV (SImode, op1, neg_op2));
28881f5e8f30Smiod      if (!neg)
28891f5e8f30Smiod	emit_insn (gen_negsi2 (op0, op0));
28901f5e8f30Smiod
28911f5e8f30Smiod      if (TARGET_CHECK_ZERO_DIV)
28921f5e8f30Smiod	emit_insn (gen_tcnd_divide_by_zero (op2, join_label));
28931f5e8f30Smiod      emit_jump_insn (gen_jump (join_label));
28941f5e8f30Smiod      emit_barrier ();
28951f5e8f30Smiod
28961f5e8f30Smiod      emit_label (label1);			/* constant / positive */
28971f5e8f30Smiod      emit_move_insn (op0, gen_rtx_UDIV (SImode, op1, op2));
28981f5e8f30Smiod      if (neg)
28991f5e8f30Smiod	emit_insn (gen_negsi2 (op0, op0));
29001f5e8f30Smiod    }
29011f5e8f30Smiod
29021f5e8f30Smiod  else if (GET_CODE (op2) == CONST_INT)
29031f5e8f30Smiod    {
29041f5e8f30Smiod      int neg = FALSE;
29051f5e8f30Smiod      rtx neg_op1 = gen_reg_rtx (SImode);
29061f5e8f30Smiod      rtx label1 = gen_label_rtx ();
29071f5e8f30Smiod
29081f5e8f30Smiod      if (INTVAL (op2) < 0)
29091f5e8f30Smiod	{
29101f5e8f30Smiod	  neg = TRUE;
29111f5e8f30Smiod	  op2 = GEN_INT (-INTVAL (op2));
29121f5e8f30Smiod	}
29131f5e8f30Smiod      else if (! SMALL_INT (operands[2]))
29141f5e8f30Smiod	op2 = force_reg (SImode, op2);
29151f5e8f30Smiod
29161f5e8f30Smiod      emit_insn (gen_negsi2 (neg_op1, op1));
29171f5e8f30Smiod      emit_insn (gen_cmpsi (op1, const0_rtx));
29181f5e8f30Smiod      emit_jump_insn (gen_bge (label1));
29191f5e8f30Smiod						/* 0-or-negative / constant */
29201f5e8f30Smiod      emit_move_insn (op0, gen_rtx_UDIV (SImode, neg_op1, op2));
29211f5e8f30Smiod      if (!neg)
29221f5e8f30Smiod	emit_insn (gen_negsi2 (op0, op0));
29231f5e8f30Smiod
29241f5e8f30Smiod      emit_jump_insn (gen_jump (join_label));
29251f5e8f30Smiod      emit_barrier ();
29261f5e8f30Smiod
29271f5e8f30Smiod      emit_label (label1);			/* positive / constant */
29281f5e8f30Smiod      emit_move_insn (op0, gen_rtx_UDIV (SImode, op1, op2));
29291f5e8f30Smiod      if (neg)
29301f5e8f30Smiod	emit_insn (gen_negsi2 (op0, op0));
29311f5e8f30Smiod    }
29321f5e8f30Smiod
29331f5e8f30Smiod  else
29341f5e8f30Smiod    {
29351f5e8f30Smiod      rtx neg_op1 = gen_reg_rtx (SImode);
29361f5e8f30Smiod      rtx neg_op2 = gen_reg_rtx (SImode);
29371f5e8f30Smiod      rtx label1 = gen_label_rtx ();
29381f5e8f30Smiod      rtx label2 = gen_label_rtx ();
29391f5e8f30Smiod      rtx label3 = gen_label_rtx ();
29401f5e8f30Smiod      rtx label4 = NULL_RTX;
29411f5e8f30Smiod
29421f5e8f30Smiod      emit_insn (gen_negsi2 (neg_op2, op2));
29431f5e8f30Smiod      emit_insn (gen_cmpsi (op2, const0_rtx));
29441f5e8f30Smiod      emit_jump_insn (gen_bgt (label1));
29451f5e8f30Smiod
29461f5e8f30Smiod      emit_insn (gen_negsi2 (neg_op1, op1));
29471f5e8f30Smiod      emit_insn (gen_cmpsi (op1, const0_rtx));
29481f5e8f30Smiod      emit_jump_insn (gen_bge (label2));
29491f5e8f30Smiod						/* negative / negative-or-0 */
29501f5e8f30Smiod      emit_move_insn (op0, gen_rtx_UDIV (SImode, neg_op1, neg_op2));
29511f5e8f30Smiod
29521f5e8f30Smiod      if (TARGET_CHECK_ZERO_DIV)
29531f5e8f30Smiod	{
29541f5e8f30Smiod	  label4 = gen_label_rtx ();
29551f5e8f30Smiod	  emit_insn (gen_cmpsi (op2, const0_rtx));
29561f5e8f30Smiod	  emit_jump_insn (gen_bne (join_label));
29571f5e8f30Smiod	  emit_label (label4);
29581f5e8f30Smiod	  emit_insn (gen_trap_divide_by_zero ());
29591f5e8f30Smiod	}
29601f5e8f30Smiod      emit_jump_insn (gen_jump (join_label));
29611f5e8f30Smiod      emit_barrier ();
29621f5e8f30Smiod
29631f5e8f30Smiod      emit_label (label2);			/* pos.-or-0 / neg.-or-0 */
29641f5e8f30Smiod      emit_move_insn (op0, gen_rtx_UDIV (SImode, op1, neg_op2));
29651f5e8f30Smiod
29661f5e8f30Smiod      if (TARGET_CHECK_ZERO_DIV)
29671f5e8f30Smiod	{
29681f5e8f30Smiod	  emit_insn (gen_cmpsi (op2, const0_rtx));
29691f5e8f30Smiod	  emit_jump_insn (gen_beq (label4));
29701f5e8f30Smiod	}
29711f5e8f30Smiod
29721f5e8f30Smiod      emit_insn (gen_negsi2 (op0, op0));
29731f5e8f30Smiod      emit_jump_insn (gen_jump (join_label));
29741f5e8f30Smiod      emit_barrier ();
29751f5e8f30Smiod
29761f5e8f30Smiod      emit_label (label1);
29771f5e8f30Smiod      emit_insn (gen_negsi2 (neg_op1, op1));
29781f5e8f30Smiod      emit_insn (gen_cmpsi (op1, const0_rtx));
29791f5e8f30Smiod      emit_jump_insn (gen_bge (label3));
29801f5e8f30Smiod						/* negative / positive */
29811f5e8f30Smiod      emit_move_insn (op0, gen_rtx_UDIV (SImode, neg_op1, op2));
29821f5e8f30Smiod      emit_insn (gen_negsi2 (op0, op0));
29831f5e8f30Smiod      emit_jump_insn (gen_jump (join_label));
29841f5e8f30Smiod      emit_barrier ();
29851f5e8f30Smiod
29861f5e8f30Smiod      emit_label (label3);			/* positive-or-0 / positive */
29871f5e8f30Smiod      emit_move_insn (op0, gen_rtx_UDIV (SImode, op1, op2));
29881f5e8f30Smiod    }
29891f5e8f30Smiod
29901f5e8f30Smiod  emit_label (join_label);
29911f5e8f30Smiod
29921f5e8f30Smiod  emit_insn (gen_dummy (op0));
29931f5e8f30Smiod  DONE;
29941f5e8f30Smiod}")
29951f5e8f30Smiod
29961f5e8f30Smiod(define_insn ""
29971f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
29981f5e8f30Smiod	(div:SI (match_operand:SI 1 "register_operand" "r")
29991f5e8f30Smiod		(match_operand:SI 2 "arith_operand" "rI")))]
30001f5e8f30Smiod  ""
30011f5e8f30Smiod  "div %0,%1,%2"
30021f5e8f30Smiod  [(set_attr "type" "idiv")])
30031f5e8f30Smiod
30041f5e8f30Smiod(define_expand "udivsi3"
30051f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
30061f5e8f30Smiod	(udiv:SI (match_operand:SI 1 "register_operand" "")
30071f5e8f30Smiod		 (match_operand:SI 2 "arith32_operand" "")))]
30081f5e8f30Smiod  ""
30091f5e8f30Smiod  "
30101f5e8f30Smiod{
30111f5e8f30Smiod  rtx op2 = operands[2];
30121f5e8f30Smiod
30131f5e8f30Smiod  if (op2 == const0_rtx)
30141f5e8f30Smiod    {
30151f5e8f30Smiod      emit_insn (gen_trap_divide_by_zero ());
30161f5e8f30Smiod      emit_insn (gen_dummy (operands[0]));
30171f5e8f30Smiod      DONE;
30181f5e8f30Smiod    }
30191f5e8f30Smiod  else if (GET_CODE (op2) != CONST_INT && TARGET_CHECK_ZERO_DIV)
30201f5e8f30Smiod    {
30211f5e8f30Smiod      rtx label = gen_label_rtx ();
30221f5e8f30Smiod      emit_insn (gen_rtx_SET (VOIDmode, operands[0],
30231f5e8f30Smiod			      gen_rtx_UDIV (SImode, operands[1], op2)));
30241f5e8f30Smiod      emit_insn (gen_tcnd_divide_by_zero (op2, label));
30251f5e8f30Smiod      emit_label (label);
30261f5e8f30Smiod      emit_insn (gen_dummy (operands[0]));
30271f5e8f30Smiod      DONE;
30281f5e8f30Smiod    }
30291f5e8f30Smiod}")
30301f5e8f30Smiod
30311f5e8f30Smiod(define_insn ""
30321f5e8f30Smiod [(set (match_operand:SI 0 "register_operand" "=r")
30331f5e8f30Smiod       (udiv:SI (match_operand:SI 1 "register_operand" "r")
30341f5e8f30Smiod		(match_operand:SI 2 "arith32_operand" "rI")))]
30351f5e8f30Smiod  "operands[2] != const0_rtx"
30361f5e8f30Smiod  "divu %0,%1,%2"
30371f5e8f30Smiod  [(set_attr "type" "idiv")])
30381f5e8f30Smiod
30391f5e8f30Smiod(define_insn ""
30401f5e8f30Smiod [(set (match_operand:SI 0 "register_operand" "=r")
30411f5e8f30Smiod       (udiv:SI (match_operand:SI 1 "register_operand" "r")
30421f5e8f30Smiod		(const_int 0)))]
30431f5e8f30Smiod  ""
30441f5e8f30Smiod  "tb0 0,%#r0,503"
304524ed4e7eSmiod  [(set_attr "type" "weird")
304624ed4e7eSmiod   (set_attr "length" "1")])
30471f5e8f30Smiod
30481f5e8f30Smiod;; patterns for mixed mode floating point.
30491f5e8f30Smiod;; Do not define patterns that utilize mixed mode arithmetic that result
30501f5e8f30Smiod;; in narrowing the precision, because it loses accuracy, since the standard
30511f5e8f30Smiod;; requires double rounding, whereas the 88000 instruction only rounds once.
30521f5e8f30Smiod
30531f5e8f30Smiod(define_expand "divdf3"
30541f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
30551f5e8f30Smiod	(div:DF (match_operand:DF 1 "general_operand" "r,x")
30561f5e8f30Smiod		(match_operand:DF 2 "general_operand" "r,x")))]
30571f5e8f30Smiod  ""
30581f5e8f30Smiod  "
30591f5e8f30Smiod{
30601f5e8f30Smiod  operands[1] = legitimize_operand (operands[1], DFmode);
30611f5e8f30Smiod  if (real_power_of_2_operand (operands[2]))
30621f5e8f30Smiod    {
30631f5e8f30Smiod      REAL_VALUE_TYPE r;
30641f5e8f30Smiod      REAL_VALUE_FROM_CONST_DOUBLE (r, operands[2]);
30651f5e8f30Smiod      bool result;
30661f5e8f30Smiod
30671f5e8f30Smiod      result = exact_real_inverse (DFmode, &r);
30681f5e8f30Smiod      gcc_assert (result);
30691f5e8f30Smiod      emit_insn (gen_muldf3 (operands[0], operands[1],
30701f5e8f30Smiod			     CONST_DOUBLE_FROM_REAL_VALUE (r, DFmode)));
30711f5e8f30Smiod      DONE;
30721f5e8f30Smiod    }
30731f5e8f30Smiod  else if (! register_operand (operands[2], DFmode))
30741f5e8f30Smiod    operands[2] = force_reg (DFmode, operands[2]);
30751f5e8f30Smiod}")
30761f5e8f30Smiod
30771f5e8f30Smiod(define_insn ""
30781f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
30791f5e8f30Smiod	(div:DF (float_extend:DF (match_operand:SF 1 "register_operand" "r,x"))
30801f5e8f30Smiod		(float_extend:DF (match_operand:SF 2 "register_operand" "r,x"))))]
30811f5e8f30Smiod  ""
30821f5e8f30Smiod  "fdiv.dss %0,%1,%2"
30831f5e8f30Smiod  [(set_attr "type" "dpdiv")])
30841f5e8f30Smiod
30851f5e8f30Smiod(define_insn ""
30861f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
30871f5e8f30Smiod	(div:DF (match_operand:DF 1 "register_operand" "r,x")
30881f5e8f30Smiod		(float_extend:DF (match_operand:SF 2 "register_operand" "r,x"))))]
30891f5e8f30Smiod  ""
30901f5e8f30Smiod  "fdiv.dds %0,%1,%2"
30911f5e8f30Smiod  [(set_attr "type" "dpdiv")])
30921f5e8f30Smiod
30931f5e8f30Smiod(define_insn ""
30941f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
30951f5e8f30Smiod	(div:DF (float_extend:DF (match_operand:SF 1 "register_operand" "r,x"))
30961f5e8f30Smiod		(match_operand:DF 2 "register_operand" "r,x")))]
30971f5e8f30Smiod  ""
30981f5e8f30Smiod  "fdiv.dsd %0,%1,%2"
30991f5e8f30Smiod  [(set_attr "type" "dpdiv")])
31001f5e8f30Smiod
31011f5e8f30Smiod(define_insn "divsf3"
31021f5e8f30Smiod  [(set (match_operand:SF 0 "register_operand" "=r,x")
31031f5e8f30Smiod	(div:SF (match_operand:SF 1 "register_operand" "r,x")
31041f5e8f30Smiod		(match_operand:SF 2 "register_operand" "r,x")))]
31051f5e8f30Smiod  ""
31061f5e8f30Smiod  "fdiv.sss %0,%1,%2"
31071f5e8f30Smiod  [(set_attr "type" "spdiv")])
31081f5e8f30Smiod
31091f5e8f30Smiod(define_insn ""
31101f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=r,x")
31111f5e8f30Smiod	(div:DF (match_operand:DF 1 "register_operand" "r,x")
31121f5e8f30Smiod		(match_operand:DF 2 "register_operand" "r,x")))]
31131f5e8f30Smiod  ""
31141f5e8f30Smiod  "fdiv.ddd %0,%1,%2"
31151f5e8f30Smiod  [(set_attr "type" "dpdiv")])
31161f5e8f30Smiod
31171f5e8f30Smiod;; - remainder instructions, don't define, since the hardware doesn't have any
31181f5e8f30Smiod;; direct support, and GNU can synthesis them out of div/mul just fine.
31191f5e8f30Smiod
31201f5e8f30Smiod;;- load effective address, must come after add, so that we favor using
31211f5e8f30Smiod;;  addu reg,reg,reg  instead of:  lda reg,reg,reg (addu doesn't require
31221f5e8f30Smiod;;  the data unit), and also future 88k chips might not support unscaled
31231f5e8f30Smiod;;  lda instructions.
31241f5e8f30Smiod
31251f5e8f30Smiod(define_insn ""
31261f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
31271f5e8f30Smiod	(match_operand:HI 1 "address_operand" "p"))]
31281f5e8f30Smiod  ""
31291f5e8f30Smiod  "lda.h %0,%a1"
31301f5e8f30Smiod  [(set_attr "type" "loada")])
31311f5e8f30Smiod
31321f5e8f30Smiod(define_insn ""
31331f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
31341f5e8f30Smiod	(match_operand:SI 1 "address_operand" "p"))]
31351f5e8f30Smiod  ""
31361f5e8f30Smiod  "lda %0,%a1"
31371f5e8f30Smiod  [(set_attr "type" "loada")])
31381f5e8f30Smiod
31391f5e8f30Smiod(define_insn ""
31401f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
31411f5e8f30Smiod	(match_operand:DI 1 "address_operand" "p"))]
31421f5e8f30Smiod  ""
31431f5e8f30Smiod  "lda.d %0,%a1"
31441f5e8f30Smiod  [(set_attr "type" "loada")])
31451f5e8f30Smiod
31461f5e8f30Smiod(define_insn ""
31471f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
31481f5e8f30Smiod	(match_operand:SF 1 "address_operand" "p"))]
31491f5e8f30Smiod  ""
31501f5e8f30Smiod  "lda %0,%a1"
31511f5e8f30Smiod  [(set_attr "type" "loada")])
31521f5e8f30Smiod
31531f5e8f30Smiod(define_insn ""
31541f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
31551f5e8f30Smiod	(match_operand:DF 1 "address_operand" "p"))]
31561f5e8f30Smiod  ""
31571f5e8f30Smiod  "lda.d %0,%a1"
31581f5e8f30Smiod  [(set_attr "type" "loada")])
31591f5e8f30Smiod
31601f5e8f30Smiod;;- and instructions (with complement also)
31611f5e8f30Smiod(define_insn ""
31621f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
31631f5e8f30Smiod	(and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
31641f5e8f30Smiod		(match_operand:SI 2 "register_operand" "r")))]
31651f5e8f30Smiod  ""
31661f5e8f30Smiod  "and.c %0,%2,%1")
31671f5e8f30Smiod
31681f5e8f30Smiod;; If the operation is being performed on a 32-bit constant such that
31691f5e8f30Smiod;; it cannot be done in one insn, do it in two.  We may lose a bit on
31701f5e8f30Smiod;; CSE in pathological cases, but it seems better doing it this way.
31711f5e8f30Smiod
31721f5e8f30Smiod(define_expand "andsi3"
31731f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
31741f5e8f30Smiod	(and:SI (match_operand:SI 1 "arith32_operand" "")
31751f5e8f30Smiod		(match_operand:SI 2 "arith32_operand" "")))]
31761f5e8f30Smiod  ""
31771f5e8f30Smiod  "
31781f5e8f30Smiod{
31791f5e8f30Smiod  if (GET_CODE (operands[2]) == CONST_INT)
31801f5e8f30Smiod    {
31811f5e8f30Smiod      int value = INTVAL (operands[2]);
31821f5e8f30Smiod
31831f5e8f30Smiod      if (! (SMALL_INTVAL (value)
31841f5e8f30Smiod	     || (value & 0xffff0000) == 0xffff0000
31851f5e8f30Smiod	     || (value & 0xffff) == 0xffff
31861f5e8f30Smiod	     || (value & 0xffff) == 0
31871f5e8f30Smiod	     || integer_ok_for_set (~value)))
31881f5e8f30Smiod	{
31891f5e8f30Smiod	  emit_insn (gen_andsi3 (operands[0], operands[1],
31901f5e8f30Smiod				 GEN_INT (value | 0xffff)));
31911f5e8f30Smiod	  operands[1] = operands[0];
31921f5e8f30Smiod	  operands[2] = GEN_INT (value | 0xffff0000);
31931f5e8f30Smiod	}
31941f5e8f30Smiod    }
31951f5e8f30Smiod}")
31961f5e8f30Smiod
31971f5e8f30Smiod(define_insn ""
31981f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,r")
31991f5e8f30Smiod	(and:SI (match_operand:SI 1 "arith32_operand" "%r,r")
32001f5e8f30Smiod		(match_operand:SI 2 "arith32_operand" "rIJL,rn")))]
32011f5e8f30Smiod  ""
32021f5e8f30Smiod  "* return output_and (operands);"
32031f5e8f30Smiod  [(set_attr "type" "arith,marith")])
32041f5e8f30Smiod
32051f5e8f30Smiod(define_insn ""
32061f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
32071f5e8f30Smiod	(and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
32081f5e8f30Smiod		(match_operand:DI 2 "register_operand" "r")))]
32091f5e8f30Smiod  ""
32101f5e8f30Smiod  "and.c %d0,%d2,%d1\;and.c %0,%2,%1"
32111f5e8f30Smiod  [(set_attr "type" "marith")])
32121f5e8f30Smiod
32131f5e8f30Smiod(define_insn "anddi3"
32141f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
32151f5e8f30Smiod	(and:DI (match_operand:DI 1 "arith64_operand" "%r")
32161f5e8f30Smiod		(match_operand:DI 2 "arith64_operand" "rn")))]
32171f5e8f30Smiod  ""
32181f5e8f30Smiod{
32191f5e8f30Smiod  rtx xoperands[10];
32201f5e8f30Smiod
32211f5e8f30Smiod  xoperands[0] = operand_subword (operands[0], 1, 0, DImode);
32221f5e8f30Smiod  xoperands[1] = operand_subword (operands[1], 1, 0, DImode);
32231f5e8f30Smiod  xoperands[2] = operand_subword (operands[2], 1, 0, DImode);
32241f5e8f30Smiod
32251f5e8f30Smiod  output_asm_insn (output_and (xoperands), xoperands);
32261f5e8f30Smiod
32271f5e8f30Smiod  operands[0] = operand_subword (operands[0], 0, 0, DImode);
32281f5e8f30Smiod  operands[1] = operand_subword (operands[1], 0, 0, DImode);
32291f5e8f30Smiod  operands[2] = operand_subword (operands[2], 0, 0, DImode);
32301f5e8f30Smiod
32311f5e8f30Smiod  return output_and (operands);
32321f5e8f30Smiod}
32331f5e8f30Smiod  [(set_attr "type" "marith")
32341f5e8f30Smiod   (set_attr "length" "4")]) ; length is 2, 3, or 4.
32351f5e8f30Smiod
32361f5e8f30Smiod;;- Bit set (inclusive or) instructions (with complement also)
32371f5e8f30Smiod(define_insn ""
32381f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
32391f5e8f30Smiod	(ior:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
32401f5e8f30Smiod		(match_operand:SI 2 "register_operand" "r")))]
32411f5e8f30Smiod  ""
32421f5e8f30Smiod  "or.c %0,%2,%1")
32431f5e8f30Smiod
32441f5e8f30Smiod(define_expand "iorsi3"
32451f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
32461f5e8f30Smiod	(ior:SI (match_operand:SI 1 "arith32_operand" "")
32471f5e8f30Smiod		(match_operand:SI 2 "arith32_operand" "")))]
32481f5e8f30Smiod  ""
32491f5e8f30Smiod  "
32501f5e8f30Smiod{
32511f5e8f30Smiod  if (GET_CODE (operands[2]) == CONST_INT)
32521f5e8f30Smiod    {
32531f5e8f30Smiod      int value = INTVAL (operands[2]);
32541f5e8f30Smiod
32551f5e8f30Smiod      if (! (SMALL_INTVAL (value)
32561f5e8f30Smiod	     || (value & 0xffff) == 0
32571f5e8f30Smiod	     || integer_ok_for_set (value)))
32581f5e8f30Smiod	{
32591f5e8f30Smiod	  emit_insn (gen_iorsi3 (operands[0], operands[1],
32601f5e8f30Smiod				 GEN_INT (value & 0xffff0000)));
32611f5e8f30Smiod	  operands[1] = operands[0];
32621f5e8f30Smiod	  operands[2] = GEN_INT (value & 0xffff);
32631f5e8f30Smiod	}
32641f5e8f30Smiod    }
32651f5e8f30Smiod}")
32661f5e8f30Smiod
32671f5e8f30Smiod(define_insn ""
32681f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
32691f5e8f30Smiod	(ior:SI (match_operand:SI 1 "arith32_operand" "%r,r,r,r")
32701f5e8f30Smiod		(match_operand:SI 2 "arith32_operand" "rI,L,M,n")))]
32711f5e8f30Smiod  ""
32721f5e8f30Smiod  "@
32731f5e8f30Smiod   or %0,%1,%2
32741f5e8f30Smiod   or.u %0,%1,%X2
32751f5e8f30Smiod   set %0,%1,%s2
32761f5e8f30Smiod   or.u %0,%1,%X2\;or %0,%0,%x2"
32771f5e8f30Smiod  [(set_attr "type" "arith,arith,bit,marith")])
32781f5e8f30Smiod
32791f5e8f30Smiod(define_insn ""
32801f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
32811f5e8f30Smiod	(ior:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
32821f5e8f30Smiod		(match_operand:DI 2 "register_operand" "r")))]
32831f5e8f30Smiod  ""
32841f5e8f30Smiod  "or.c %d0,%d2,%d1\;or.c %0,%2,%1"
32851f5e8f30Smiod  [(set_attr "type" "marith")])
32861f5e8f30Smiod
32871f5e8f30Smiod(define_insn "iordi3"
32881f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
32891f5e8f30Smiod	(ior:DI (match_operand:DI 1 "arith64_operand" "%r")
32901f5e8f30Smiod		(match_operand:DI 2 "arith64_operand" "rn")))]
32911f5e8f30Smiod  ""
32921f5e8f30Smiod{
32931f5e8f30Smiod  rtx xoperands[10];
32941f5e8f30Smiod
32951f5e8f30Smiod  xoperands[0] = operand_subword (operands[0], 1, 0, DImode);
32961f5e8f30Smiod  xoperands[1] = operand_subword (operands[1], 1, 0, DImode);
32971f5e8f30Smiod  xoperands[2] = operand_subword (operands[2], 1, 0, DImode);
32981f5e8f30Smiod
32991f5e8f30Smiod  output_asm_insn (output_ior (xoperands), xoperands);
33001f5e8f30Smiod
33011f5e8f30Smiod  operands[0] = operand_subword (operands[0], 0, 0, DImode);
33021f5e8f30Smiod  operands[1] = operand_subword (operands[1], 0, 0, DImode);
33031f5e8f30Smiod  operands[2] = operand_subword (operands[2], 0, 0, DImode);
33041f5e8f30Smiod
33051f5e8f30Smiod  return output_ior (operands);
33061f5e8f30Smiod}
33071f5e8f30Smiod  [(set_attr "type" "marith")
33081f5e8f30Smiod   (set_attr "length" "4")]) ; length is 2, 3, or 4.
33091f5e8f30Smiod
33101f5e8f30Smiod;;- xor instructions (with complement also)
33111f5e8f30Smiod(define_insn ""
33121f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
33131f5e8f30Smiod	(not:SI (xor:SI (match_operand:SI 1 "register_operand" "%r")
33141f5e8f30Smiod			(match_operand:SI 2 "register_operand" "r"))))]
33151f5e8f30Smiod  ""
33161f5e8f30Smiod  "xor.c %0,%1,%2")
33171f5e8f30Smiod
33181f5e8f30Smiod(define_expand "xorsi3"
33191f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
33201f5e8f30Smiod	(xor:SI (match_operand:SI 1 "arith32_operand" "")
33211f5e8f30Smiod		(match_operand:SI 2 "arith32_operand" "")))]
33221f5e8f30Smiod  ""
33231f5e8f30Smiod  "
33241f5e8f30Smiod{
33251f5e8f30Smiod  if (GET_CODE (operands[2]) == CONST_INT)
33261f5e8f30Smiod    {
33271f5e8f30Smiod      int value = INTVAL (operands[2]);
33281f5e8f30Smiod
33291f5e8f30Smiod      if (! (SMALL_INTVAL (value)
33301f5e8f30Smiod	     || (value & 0xffff) == 0))
33311f5e8f30Smiod	{
33321f5e8f30Smiod	  emit_insn (gen_xorsi3 (operands[0], operands[1],
33331f5e8f30Smiod				 GEN_INT (value & 0xffff0000)));
33341f5e8f30Smiod	  operands[1] = operands[0];
33351f5e8f30Smiod	  operands[2] = GEN_INT (value & 0xffff);
33361f5e8f30Smiod	}
33371f5e8f30Smiod    }
33381f5e8f30Smiod}")
33391f5e8f30Smiod
33401f5e8f30Smiod(define_insn ""
33411f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,r,r")
33421f5e8f30Smiod	(xor:SI (match_operand:SI 1 "arith32_operand" "%r,r,r")
33431f5e8f30Smiod		(match_operand:SI 2 "arith32_operand" "rI,L,n")))]
33441f5e8f30Smiod  ""
33451f5e8f30Smiod  "@
33461f5e8f30Smiod   xor %0,%1,%2
33471f5e8f30Smiod   xor.u %0,%1,%X2
33481f5e8f30Smiod   xor.u %0,%1,%X2\;xor %0,%0,%x2"
33491f5e8f30Smiod  [(set_attr "type" "arith,arith,marith")])
33501f5e8f30Smiod
33511f5e8f30Smiod(define_insn ""
33521f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
33531f5e8f30Smiod	(not:DI (xor:DI (match_operand:DI 1 "register_operand" "r")
33541f5e8f30Smiod			(match_operand:DI 2 "register_operand" "r"))))]
33551f5e8f30Smiod  ""
33561f5e8f30Smiod  "xor.c %d0,%d1,%d2\;xor.c %0,%1,%2"
33571f5e8f30Smiod  [(set_attr "type" "marith")])
33581f5e8f30Smiod
33591f5e8f30Smiod(define_insn "xordi3"
33601f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
33611f5e8f30Smiod	(xor:DI (match_operand:DI 1 "arith64_operand" "%r")
33621f5e8f30Smiod		(match_operand:DI 2 "arith64_operand" "rn")))]
33631f5e8f30Smiod  ""
33641f5e8f30Smiod{
33651f5e8f30Smiod  rtx xoperands[10];
33661f5e8f30Smiod
33671f5e8f30Smiod  xoperands[0] = operand_subword (operands[0], 1, 0, DImode);
33681f5e8f30Smiod  xoperands[1] = operand_subword (operands[1], 1, 0, DImode);
33691f5e8f30Smiod  xoperands[2] = operand_subword (operands[2], 1, 0, DImode);
33701f5e8f30Smiod
33711f5e8f30Smiod  output_asm_insn (output_xor (xoperands), xoperands);
33721f5e8f30Smiod
33731f5e8f30Smiod  operands[0] = operand_subword (operands[0], 0, 0, DImode);
33741f5e8f30Smiod  operands[1] = operand_subword (operands[1], 0, 0, DImode);
33751f5e8f30Smiod  operands[2] = operand_subword (operands[2], 0, 0, DImode);
33761f5e8f30Smiod
33771f5e8f30Smiod  return output_xor (operands);
33781f5e8f30Smiod}
33791f5e8f30Smiod  [(set_attr "type" "marith")
33801f5e8f30Smiod   (set_attr "length" "4")]) ; length is 2, 3, or 4.
33811f5e8f30Smiod
33821f5e8f30Smiod;;- ones complement instructions
33831f5e8f30Smiod(define_insn "one_cmplsi2"
33841f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
33851f5e8f30Smiod	(not:SI (match_operand:SI 1 "register_operand" "r")))]
33861f5e8f30Smiod  ""
33871f5e8f30Smiod  "xor.c %0,%1,%#r0")
33881f5e8f30Smiod
33891f5e8f30Smiod(define_insn "one_cmpldi2"
33901f5e8f30Smiod  [(set (match_operand:DI 0 "register_operand" "=r")
33911f5e8f30Smiod	(not:DI (match_operand:DI 1 "register_operand" "r")))]
33921f5e8f30Smiod  ""
33931f5e8f30Smiod  "xor.c %d0,%d1,%#r0\;xor.c %0,%1,%#r0"
33941f5e8f30Smiod  [(set_attr "type" "marith")])
33951f5e8f30Smiod
33961f5e8f30Smiod;; Optimized special cases of shifting.
33971f5e8f30Smiod;; Must precede the general case.
33981f5e8f30Smiod
33991f5e8f30Smiod;; @@ What about HImode shifted by 8?
34001f5e8f30Smiod
34011f5e8f30Smiod(define_insn ""
34021f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
34031f5e8f30Smiod	(ashiftrt:SI (match_operand:SI 1 "memory_operand" "m")
34041f5e8f30Smiod		     (const_int 24)))]
34051f5e8f30Smiod  "! SCALED_ADDRESS_P (XEXP (operands[1], 0))"
34061f5e8f30Smiod  "%V1ld.b\\t %0,%1"
34071f5e8f30Smiod  [(set_attr "type" "load")])
34081f5e8f30Smiod
34091f5e8f30Smiod(define_insn ""
34101f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
34111f5e8f30Smiod	(lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
34121f5e8f30Smiod		     (const_int 24)))]
34131f5e8f30Smiod  "! SCALED_ADDRESS_P (XEXP (operands[1], 0))"
34141f5e8f30Smiod  "%V1ld.bu\\t %0,%1"
34151f5e8f30Smiod  [(set_attr "type" "load")])
34161f5e8f30Smiod
34171f5e8f30Smiod(define_insn ""
34181f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
34191f5e8f30Smiod	(ashiftrt:SI (match_operand:SI 1 "memory_operand" "m")
34201f5e8f30Smiod		     (const_int 16)))]
34211f5e8f30Smiod  "! SCALED_ADDRESS_P (XEXP (operands[1], 0))"
34221f5e8f30Smiod  "%V1ld.h\\t %0,%1"
34231f5e8f30Smiod  [(set_attr "type" "load")])
34241f5e8f30Smiod
34251f5e8f30Smiod(define_insn ""
34261f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
34271f5e8f30Smiod	(lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
34281f5e8f30Smiod		     (const_int 16)))]
34291f5e8f30Smiod  "! SCALED_ADDRESS_P (XEXP (operands[1], 0))"
34301f5e8f30Smiod  "%V1ld.hu\\t %0,%1"
34311f5e8f30Smiod  [(set_attr "type" "load")])
34321f5e8f30Smiod
34331f5e8f30Smiod;;- arithmetic shift instructions.
34341f5e8f30Smiod
34351f5e8f30Smiod;; @@ Do the optimized patterns with -1 get used?  Perhaps operand 1 should
34361f5e8f30Smiod;; be arith32_operand?
34371f5e8f30Smiod
34381f5e8f30Smiod;; Use tbnd to support TARGET_TRAP_LARGE_SHIFT.
34391f5e8f30Smiod(define_insn "tbnd"
34401f5e8f30Smiod  [(trap_if (gtu (match_operand:SI 0 "register_operand" "r")
34411f5e8f30Smiod		 (match_operand:SI 1 "arith_operand" "rI"))
34421f5e8f30Smiod	    (const_int 7))]
34431f5e8f30Smiod  ""
344424ed4e7eSmiod  "tbnd %0,%1"
344524ed4e7eSmiod  [(set_attr "type" "weird")
344624ed4e7eSmiod   (set_attr "length" "1")])
34471f5e8f30Smiod
34481f5e8f30Smiod;; Just in case the optimizer decides to fold away the test.
34491f5e8f30Smiod(define_insn ""
34501f5e8f30Smiod  [(trap_if (const_int 1) (const_int 7))]
34511f5e8f30Smiod  ""
34521f5e8f30Smiod  "tbnd %#r31,0"
345324ed4e7eSmiod  [(set_attr "type" "weird")
345424ed4e7eSmiod   (set_attr "length" "1")])
34551f5e8f30Smiod
34561f5e8f30Smiod(define_expand "ashlsi3"
34571f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
34581f5e8f30Smiod	(ashift:SI (match_operand:SI 1 "register_operand" "")
34591f5e8f30Smiod		   (match_operand:SI 2 "arith32_operand" "")))]
34601f5e8f30Smiod  ""
34611f5e8f30Smiod  "
34621f5e8f30Smiod{
34631f5e8f30Smiod  if (GET_CODE (operands[2]) == CONST_INT)
34641f5e8f30Smiod    {
34651f5e8f30Smiod      if ((unsigned) INTVAL (operands[2]) > 31)
34661f5e8f30Smiod	{
34671f5e8f30Smiod	  if (TARGET_TRAP_LARGE_SHIFT)
34681f5e8f30Smiod	    emit_insn (gen_tbnd (force_reg (SImode, operands[2]),
34691f5e8f30Smiod				 GEN_INT (31)));
34701f5e8f30Smiod	  else
34711f5e8f30Smiod	    emit_move_insn (operands[0], const0_rtx);
34721f5e8f30Smiod	  DONE;
34731f5e8f30Smiod	}
34741f5e8f30Smiod    }
34751f5e8f30Smiod
34761f5e8f30Smiod  else if (TARGET_TRAP_LARGE_SHIFT)
34771f5e8f30Smiod    emit_insn (gen_tbnd (operands[2], GEN_INT (31)));
34781f5e8f30Smiod
34791f5e8f30Smiod  else if (TARGET_HANDLE_LARGE_SHIFT)
34801f5e8f30Smiod    {
34811f5e8f30Smiod      rtx reg = gen_reg_rtx (SImode);
34821f5e8f30Smiod      emit_insn (gen_cmpsi (operands[2], GEN_INT (31)));
34831f5e8f30Smiod      emit_insn (gen_sleu (reg));
34841f5e8f30Smiod      emit_insn (gen_andsi3 (reg, operands[1], reg));
34851f5e8f30Smiod      operands[1] = reg;
34861f5e8f30Smiod    }
34871f5e8f30Smiod}")
34881f5e8f30Smiod
34891f5e8f30Smiod(define_insn ""
34901f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,r")
34911f5e8f30Smiod	(ashift:SI (match_operand:SI 1 "register_operand" "r,r")
34921f5e8f30Smiod		   (match_operand:SI 2 "arith5_operand" "r,K")))]
34931f5e8f30Smiod  ""
34941f5e8f30Smiod  "@
34951f5e8f30Smiod   mak %0,%1,%2
34961f5e8f30Smiod   mak %0,%1,0<%2>"
34971f5e8f30Smiod  [(set_attr "type" "bit")])
34981f5e8f30Smiod
34991f5e8f30Smiod(define_expand "ashrsi3"
35001f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
35011f5e8f30Smiod	(ashiftrt:SI (match_operand:SI 1 "register_operand" "")
35021f5e8f30Smiod		     (match_operand:SI 2 "arith32_operand" "")))]
35031f5e8f30Smiod  ""
35041f5e8f30Smiod  "
35051f5e8f30Smiod{
35061f5e8f30Smiod  if (GET_CODE (operands[2]) == CONST_INT)
35071f5e8f30Smiod    {
35081f5e8f30Smiod      if ((unsigned) INTVAL (operands[2]) > 31)
35091f5e8f30Smiod	{
35101f5e8f30Smiod	  if (TARGET_TRAP_LARGE_SHIFT)
35111f5e8f30Smiod	    {
35121f5e8f30Smiod	      emit_insn (gen_tbnd (force_reg (SImode, operands[2]),
35131f5e8f30Smiod				   GEN_INT (31)));
35141f5e8f30Smiod	      DONE;
35151f5e8f30Smiod	    }
35161f5e8f30Smiod	  else
35171f5e8f30Smiod	    operands[2] = GEN_INT (31);
35181f5e8f30Smiod	}
35191f5e8f30Smiod    }
35201f5e8f30Smiod
35211f5e8f30Smiod  else if (TARGET_TRAP_LARGE_SHIFT)
35221f5e8f30Smiod    emit_insn (gen_tbnd (operands[2], GEN_INT (31)));
35231f5e8f30Smiod
35241f5e8f30Smiod  else if (TARGET_HANDLE_LARGE_SHIFT)
35251f5e8f30Smiod    {
35261f5e8f30Smiod      rtx reg = gen_reg_rtx (SImode);
35271f5e8f30Smiod      emit_insn (gen_cmpsi (operands[2], GEN_INT (31)));
35281f5e8f30Smiod      emit_insn (gen_sgtu (reg));
35291f5e8f30Smiod      emit_insn (gen_iorsi3 (reg, operands[2], reg));
35301f5e8f30Smiod      operands[2] = reg;
35311f5e8f30Smiod    }
35321f5e8f30Smiod}")
35331f5e8f30Smiod
35341f5e8f30Smiod(define_insn ""
35351f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,r")
35361f5e8f30Smiod	(ashiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
35371f5e8f30Smiod		     (match_operand:SI 2 "arith5_operand" "r,K")))]
35381f5e8f30Smiod  ""
35391f5e8f30Smiod  "@
35401f5e8f30Smiod   ext %0,%1,%2
35411f5e8f30Smiod   ext %0,%1,0<%2>"
35421f5e8f30Smiod  [(set_attr "type" "bit")])
35431f5e8f30Smiod
35441f5e8f30Smiod;;- logical shift instructions.  Logical shift left becomes arithmetic
35451f5e8f30Smiod;; shift left.
35461f5e8f30Smiod
35471f5e8f30Smiod(define_expand "lshrsi3"
35481f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
35491f5e8f30Smiod	(lshiftrt:SI (match_operand:SI 1 "register_operand" "")
35501f5e8f30Smiod		     (match_operand:SI 2 "arith32_operand" "")))]
35511f5e8f30Smiod  ""
35521f5e8f30Smiod  "
35531f5e8f30Smiod{
35541f5e8f30Smiod  if (GET_CODE (operands[2]) == CONST_INT)
35551f5e8f30Smiod    {
35561f5e8f30Smiod      if ((unsigned) INTVAL (operands[2]) > 31)
35571f5e8f30Smiod	{
35581f5e8f30Smiod	  if (TARGET_TRAP_LARGE_SHIFT)
35591f5e8f30Smiod	    emit_insn (gen_tbnd (force_reg (SImode, operands[2]),
35601f5e8f30Smiod				 GEN_INT (31)));
35611f5e8f30Smiod	  else
35621f5e8f30Smiod	    emit_move_insn (operands[0], const0_rtx);
35631f5e8f30Smiod	  DONE;
35641f5e8f30Smiod	}
35651f5e8f30Smiod    }
35661f5e8f30Smiod
35671f5e8f30Smiod  else if (TARGET_TRAP_LARGE_SHIFT)
35681f5e8f30Smiod    emit_insn (gen_tbnd (operands[2], GEN_INT (31)));
35691f5e8f30Smiod
35701f5e8f30Smiod  else if (TARGET_HANDLE_LARGE_SHIFT)
35711f5e8f30Smiod    {
35721f5e8f30Smiod      rtx reg = gen_reg_rtx (SImode);
35731f5e8f30Smiod      emit_insn (gen_cmpsi (operands[2], GEN_INT (31)));
35741f5e8f30Smiod      emit_insn (gen_sleu (reg));
35751f5e8f30Smiod      emit_insn (gen_andsi3 (reg, operands[1], reg));
35761f5e8f30Smiod      operands[1] = reg;
35771f5e8f30Smiod    }
35781f5e8f30Smiod}")
35791f5e8f30Smiod
35801f5e8f30Smiod(define_insn ""
35811f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,r")
35821f5e8f30Smiod	(lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
35831f5e8f30Smiod		     (match_operand:SI 2 "arith5_operand" "r,K")))]
35841f5e8f30Smiod  ""
35851f5e8f30Smiod  "@
35861f5e8f30Smiod   extu %0,%1,%2
35871f5e8f30Smiod   extu %0,%1,0<%2>"
35881f5e8f30Smiod  [(set_attr "type" "bit")])
35891f5e8f30Smiod
35901f5e8f30Smiod;;- rotate instructions
35911f5e8f30Smiod
35921f5e8f30Smiod(define_expand "rotlsi3"
35931f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "")
35941f5e8f30Smiod	(rotatert:SI (match_operand:SI 1 "register_operand" "")
35951f5e8f30Smiod		     (match_operand:SI 2 "arith32_operand" "")))]
35961f5e8f30Smiod  ""
35971f5e8f30Smiod  "
35981f5e8f30Smiod{
35991f5e8f30Smiod  if (GET_CODE (operands[2]) == CONST_INT
36001f5e8f30Smiod      && (unsigned) INTVAL (operands[2]) >= 32)
36011f5e8f30Smiod    operands[2] = GEN_INT ((32 - INTVAL (operands[2])) % 32);
36021f5e8f30Smiod  else
36031f5e8f30Smiod    {
36041f5e8f30Smiod      rtx op = gen_reg_rtx (SImode);
36051f5e8f30Smiod      emit_insn (gen_negsi2 (op, operands[2]));
36061f5e8f30Smiod      operands[2] = op;
36071f5e8f30Smiod    }
36081f5e8f30Smiod}")
36091f5e8f30Smiod
36101f5e8f30Smiod(define_insn "rotrsi3"
36111f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
36121f5e8f30Smiod	(rotatert:SI (match_operand:SI 1 "register_operand" "r")
36131f5e8f30Smiod		     (match_operand:SI 2 "arith_operand" "rI")))]
36141f5e8f30Smiod  ""
36151f5e8f30Smiod  "rot %0,%1,%2"
36161f5e8f30Smiod  [(set_attr "type" "bit")])
36171f5e8f30Smiod
36181f5e8f30Smiod;; find first set.
36191f5e8f30Smiod
36201f5e8f30Smiod;; The ff1 instruction searches from the most significant bit while ffs
36211f5e8f30Smiod;; searches from the least significant bit.  The bit index and treatment of
36221f5e8f30Smiod;; zero also differ.  This amazing sequence was discovered using the GNU
36231f5e8f30Smiod;; Superoptimizer.
36241f5e8f30Smiod
36251f5e8f30Smiod(define_insn "ffssi2"
36261f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r,&r")
36271f5e8f30Smiod	(ffs:SI (match_operand:SI 1 "register_operand" "0,r")))
36281f5e8f30Smiod   (clobber (reg:CC 0))
36291f5e8f30Smiod   (clobber (match_scratch:SI 2 "=r,X"))]
36301f5e8f30Smiod  ""
36311f5e8f30Smiod  "@
36321f5e8f30Smiod   subu.co %2,%#r0,%1\;and %2,%2,%1\;addu.ci %2,%2,%2\;ff1 %0,%2
36331f5e8f30Smiod   subu.co %0,%#r0,%1\;and %0,%0,%1\;addu.ci %0,%0,%0\;ff1 %0,%0"
36341f5e8f30Smiod  [(set_attr "type" "marith")
36351f5e8f30Smiod   (set_attr "length" "4")])
36361f5e8f30Smiod
36371f5e8f30Smiod;; Bit field instructions.
36381f5e8f30Smiod
36391f5e8f30Smiod(define_insn ""
36401f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
36411f5e8f30Smiod	(sign_extract:SI (match_operand:SI 1 "register_operand" "r")
36421f5e8f30Smiod			 (const_int 32)
36431f5e8f30Smiod			 (const_int 0)))]
36441f5e8f30Smiod  ""
36451f5e8f30Smiod  "or %0,%#r0,%1")
36461f5e8f30Smiod
36471f5e8f30Smiod(define_insn "extv"
36481f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
36491f5e8f30Smiod	(sign_extract:SI (match_operand:SI 1 "register_operand" "r")
36501f5e8f30Smiod			 (match_operand:SI 2 "int5_operand" "")
36511f5e8f30Smiod			 (match_operand:SI 3 "int5_operand" "")))]
36521f5e8f30Smiod  ""
36531f5e8f30Smiod{
36541f5e8f30Smiod  operands[4] = GEN_INT ((32 - INTVAL (operands[2])) - INTVAL (operands[3]));
36551f5e8f30Smiod  return "ext %0,%1,%2<%4>";  /* <(32-%2-%3)> */
36561f5e8f30Smiod}
36571f5e8f30Smiod  [(set_attr "type" "bit")])
36581f5e8f30Smiod
36591f5e8f30Smiod(define_insn ""
36601f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
36611f5e8f30Smiod	(zero_extract:SI (match_operand:SI 1 "register_operand" "r")
36621f5e8f30Smiod			 (const_int 32)
36631f5e8f30Smiod			 (const_int 0)))]
36641f5e8f30Smiod  ""
36651f5e8f30Smiod  "or %0,%#r0,%1")
36661f5e8f30Smiod
36671f5e8f30Smiod(define_insn "extzv"
36681f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
36691f5e8f30Smiod	(zero_extract:SI (match_operand:SI 1 "register_operand" "r")
36701f5e8f30Smiod			 (match_operand:SI 2 "int5_operand" "")
36711f5e8f30Smiod			 (match_operand:SI 3 "int5_operand" "")))]
36721f5e8f30Smiod  ""
36731f5e8f30Smiod{
36741f5e8f30Smiod  operands[4] = GEN_INT ((32 - INTVAL (operands[2])) - INTVAL (operands[3]));
36751f5e8f30Smiod  return "extu %0,%1,%2<%4>";  /* <(32-%2-%3)> */
36761f5e8f30Smiod}
36771f5e8f30Smiod  [(set_attr "type" "bit")])
36781f5e8f30Smiod
36791f5e8f30Smiod(define_insn ""
36801f5e8f30Smiod  [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
36811f5e8f30Smiod			 (match_operand:SI 1 "int5_operand" "")
36821f5e8f30Smiod			 (match_operand:SI 2 "int5_operand" ""))
36831f5e8f30Smiod	(const_int 0))]
36841f5e8f30Smiod  ""
36851f5e8f30Smiod{
36861f5e8f30Smiod  operands[3] = GEN_INT ((32 - INTVAL (operands[1])) - INTVAL (operands[2]));
36871f5e8f30Smiod  return "clr %0,%0,%1<%3>";  /* <(32-%1-%2)> */
36881f5e8f30Smiod}
36891f5e8f30Smiod  [(set_attr "type" "bit")])
36901f5e8f30Smiod
36911f5e8f30Smiod(define_insn ""
36921f5e8f30Smiod  [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
36931f5e8f30Smiod			 (match_operand:SI 1 "int5_operand" "")
36941f5e8f30Smiod			 (match_operand:SI 2 "int5_operand" ""))
36951f5e8f30Smiod	(const_int -1))]
36961f5e8f30Smiod  ""
36971f5e8f30Smiod{
36981f5e8f30Smiod  operands[3] = GEN_INT ((32 - INTVAL (operands[1])) - INTVAL (operands[2]));
36991f5e8f30Smiod  return "set %0,%0,%1<%3>";  /* <(32-%1-%2)> */
37001f5e8f30Smiod}
37011f5e8f30Smiod  [(set_attr "type" "bit")])
37021f5e8f30Smiod
37031f5e8f30Smiod(define_insn ""
37041f5e8f30Smiod  [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
37051f5e8f30Smiod			 (match_operand:SI 1 "int5_operand" "")
37061f5e8f30Smiod			 (match_operand:SI 2 "int5_operand" ""))
37071f5e8f30Smiod	(match_operand:SI 3 "int32_operand" "n"))]
37081f5e8f30Smiod  ""
37091f5e8f30Smiod{
37101f5e8f30Smiod  int value = INTVAL (operands[3]);
37111f5e8f30Smiod
37121f5e8f30Smiod  if (INTVAL (operands[1]) < 32)
37131f5e8f30Smiod    value &= (1 << INTVAL (operands[1])) - 1;
37141f5e8f30Smiod
37151f5e8f30Smiod  operands[2] = GEN_INT (32 - (INTVAL(operands[1]) + INTVAL(operands[2])));
37161f5e8f30Smiod
37171f5e8f30Smiod  value <<= INTVAL (operands[2]);
37181f5e8f30Smiod  operands[3] = GEN_INT (value);
37191f5e8f30Smiod
37201f5e8f30Smiod  if (SMALL_INTVAL (value))
37211f5e8f30Smiod    return "clr %0,%0,%1<%2>\;or %0,%0,%3";
37221f5e8f30Smiod  else if ((value & 0x0000ffff) == 0)
37231f5e8f30Smiod    return "clr %0,%0,%1<%2>\;or.u %0,%0,%X3";
37241f5e8f30Smiod  else
37251f5e8f30Smiod    return "clr %0,%0,%1<%2>\;or.u %0,%0,%X3\;or %0,%0,%x3";
37261f5e8f30Smiod}
37271f5e8f30Smiod  [(set_attr "type" "marith")
37281f5e8f30Smiod   (set_attr "length" "3")]) ; may be 2 or 3.
37291f5e8f30Smiod
37301f5e8f30Smiod;; negate insns
37311f5e8f30Smiod(define_insn "negsi2"
37321f5e8f30Smiod  [(set (match_operand:SI 0 "register_operand" "=r")
37331f5e8f30Smiod	(neg:SI (match_operand:SI 1 "arith_operand" "rI")))]
37341f5e8f30Smiod  ""
37351f5e8f30Smiod  "subu %0,%#r0,%1")
37361f5e8f30Smiod
37371f5e8f30Smiod(define_insn ""
37381f5e8f30Smiod  [(set (match_operand:SF 0 "register_operand" "=r,x")
37391f5e8f30Smiod	(float_truncate:SF (neg:DF (match_operand:DF 1 "register_operand" "r,x"))))]
37401f5e8f30Smiod  ""
37411f5e8f30Smiod  "@
37421f5e8f30Smiod   fsub.ssd %0,%#r0,%1
37431f5e8f30Smiod   fsub.ssd %0,%#x0,%1"
37441f5e8f30Smiod  [(set_attr "type" "dpadd")])
37451f5e8f30Smiod
37461f5e8f30Smiod(define_insn "negdf2"
37471f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=&r,r")
37481f5e8f30Smiod	(neg:DF (match_operand:DF 1 "register_operand" "r,0")))]
37491f5e8f30Smiod  ""
37501f5e8f30Smiod  "@
37511f5e8f30Smiod   xor.u %0,%1,0x8000\;or %d0,%#r0,%d1
37521f5e8f30Smiod   xor.u %0,%0,0x8000"
37531f5e8f30Smiod  [(set_attr "type" "marith,arith")])
37541f5e8f30Smiod
37551f5e8f30Smiod(define_insn "negsf2"
37561f5e8f30Smiod  [(set (match_operand:SF 0 "register_operand" "=r")
37571f5e8f30Smiod	(neg:SF (match_operand:SF 1 "register_operand" "r")))]
37581f5e8f30Smiod  ""
37591f5e8f30Smiod  "xor.u %0,%1,0x8000")
37601f5e8f30Smiod
37611f5e8f30Smiod;; absolute value insns for floating-point (integer abs can be done using the
37621f5e8f30Smiod;; machine-independent sequence).
37631f5e8f30Smiod
37641f5e8f30Smiod(define_insn "absdf2"
37651f5e8f30Smiod  [(set (match_operand:DF 0 "register_operand" "=&r,r")
37661f5e8f30Smiod	(abs:DF (match_operand:DF 1 "register_operand" "r,0")))]
37671f5e8f30Smiod  ""
37681f5e8f30Smiod  "@
37691f5e8f30Smiod   and.u %0,%1,0x7fff\;or %d0,%#r0,%d1
37701f5e8f30Smiod   and.u %0,%0,0x7fff"
37711f5e8f30Smiod  [(set_attr "type" "marith,arith")])
37721f5e8f30Smiod
37731f5e8f30Smiod(define_insn "abssf2"
37741f5e8f30Smiod  [(set (match_operand:SF 0 "register_operand" "=r")
37751f5e8f30Smiod	(abs:SF (match_operand:SF 1 "register_operand" "r")))]
37761f5e8f30Smiod  ""
37771f5e8f30Smiod  "and.u %0,%1,0x7fff")
37781f5e8f30Smiod
37791f5e8f30Smiod;; Subroutines of "casesi".
37801f5e8f30Smiod
37811f5e8f30Smiod;; Operand 0 is index
37821f5e8f30Smiod;; operand 1 is the minimum bound
37831f5e8f30Smiod;; operand 2 is the maximum bound - minimum bound + 1
37841f5e8f30Smiod;; operand 3 is CODE_LABEL for the table;
37851f5e8f30Smiod;; operand 4 is the CODE_LABEL to go to if index out of range.
37861f5e8f30Smiod
37871f5e8f30Smiod(define_expand "casesi"
37881f5e8f30Smiod  ;; We don't use these for generating the RTL, but we must describe
37891f5e8f30Smiod  ;; the operands here.
37901f5e8f30Smiod  [(match_operand:SI 0 "general_operand" "")
37911f5e8f30Smiod   (match_operand:SI 1 "immediate_operand" "")
37921f5e8f30Smiod   (match_operand:SI 2 "immediate_operand" "")
37931f5e8f30Smiod   (match_operand 3 "" "")
37941f5e8f30Smiod   (match_operand 4 "" "")]
37951f5e8f30Smiod  ""
37961f5e8f30Smiod  "
37971f5e8f30Smiod{
37981f5e8f30Smiod  register rtx index_diff = gen_reg_rtx (SImode);
37991f5e8f30Smiod  register rtx low = GEN_INT (-INTVAL (operands[1]));
38001f5e8f30Smiod  register rtx label = gen_rtx_LABEL_REF (Pmode, operands[3]);
38011f5e8f30Smiod  register rtx base = NULL_RTX;
38021f5e8f30Smiod
38031f5e8f30Smiod  if (! CASE_VECTOR_INSNS)
38041f5e8f30Smiod    /* These instructions are likely to be scheduled and made loop invariant.
38051f5e8f30Smiod       This decreases the cost of the dispatch at the expense of the default
38061f5e8f30Smiod       case.  */
38071f5e8f30Smiod    base = force_reg (SImode, memory_address_noforce (SImode, label));
38081f5e8f30Smiod
38091f5e8f30Smiod  /* Compute the index difference and handle the default case.  */
38101f5e8f30Smiod  emit_insn (gen_addsi3 (index_diff,
38111f5e8f30Smiod			 force_reg (SImode, operands[0]),
38121f5e8f30Smiod			 ADD_INT (low) ? low : force_reg (SImode, low)));
38131f5e8f30Smiod  emit_insn (gen_cmpsi (index_diff, operands[2]));
38141f5e8f30Smiod  /* It's possible to replace this branch with sgtu/iorsi3 and adding a -1
38151f5e8f30Smiod     entry to the table.  However, that doesn't seem to win on the m88110.  */
38161f5e8f30Smiod  emit_jump_insn (gen_bgtu (operands[4]));
38171f5e8f30Smiod
38181f5e8f30Smiod  if (CASE_VECTOR_INSNS)
38191f5e8f30Smiod    /* Call the jump that will branch to the appropriate case.  */
38201f5e8f30Smiod    emit_jump_insn (gen_casesi_enter (label, index_diff, operands[3]));
38211f5e8f30Smiod  else
38221f5e8f30Smiod    /* Load the table entry and jump to it.  */
38231f5e8f30Smiod    emit_jump_insn (gen_casesi_jump (gen_reg_rtx (SImode), base, index_diff, operands[3]));
38241f5e8f30Smiod
38251f5e8f30Smiod  /* Claim that flow drops into the table so it will be adjacent by not
38261f5e8f30Smiod     emitting a barrier.  */
38271f5e8f30Smiod  DONE;
38281f5e8f30Smiod}")
38291f5e8f30Smiod
38301f5e8f30Smiod(define_expand "casesi_jump"
38311f5e8f30Smiod  [(set (match_operand:SI 0 "" "")
38321f5e8f30Smiod	(mem:SI (plus:SI (match_operand:SI 1 "" "")
38331f5e8f30Smiod			 (mult:SI (match_operand:SI 2 "" "")
38341f5e8f30Smiod				  (const_int 4)))))
38351f5e8f30Smiod   (parallel [(set (pc) (match_dup 0))
38361f5e8f30Smiod              (use (label_ref (match_operand 3 "" "")))])]
38371f5e8f30Smiod  ""
38381f5e8f30Smiod  "")
38391f5e8f30Smiod
38401f5e8f30Smiod(define_insn ""
38411f5e8f30Smiod  [(set (pc) (match_operand:SI 0 "register_operand" "r"))
38421f5e8f30Smiod   (use (label_ref (match_operand 1 "" "")))]
38431f5e8f30Smiod  ""
38441f5e8f30Smiod  "jmp%. %0"
38451f5e8f30Smiod  [(set_attr "type" "jump")])
38461f5e8f30Smiod
38471f5e8f30Smiod;; The bsr.n instruction is directed to the END of the table.  See
38481f5e8f30Smiod;; ASM_OUTPUT_CASE_END.
38491f5e8f30Smiod
38501f5e8f30Smiod(define_insn "casesi_enter"
38511f5e8f30Smiod  [(set (pc) (match_operand 0 "" ""))
38521f5e8f30Smiod   (use (match_operand:SI 1 "register_operand" "r"))
38531f5e8f30Smiod   ;; The USE here is so that at least one jump-insn will refer to the label,
38541f5e8f30Smiod   ;; to keep it alive in jump_optimize.
38551f5e8f30Smiod   (use (label_ref (match_operand 2 "" "")))
38561f5e8f30Smiod   (clobber (reg:SI 1))]
38571f5e8f30Smiod  ""
38581f5e8f30Smiod{
38591f5e8f30Smiod  if (flag_delayed_branch)
38601f5e8f30Smiod    return "bsr.n %0e\;lda %#r1,%#r1[%1]";
38611f5e8f30Smiod  m88k_case_index = REGNO (operands[1]);
38621f5e8f30Smiod  return "bsr %0e";
38631f5e8f30Smiod}
38641f5e8f30Smiod  [(set_attr "type" "weird")
38651f5e8f30Smiod   (set_attr "length" "3")]) ; Including the "jmp r1".
38661f5e8f30Smiod
38671f5e8f30Smiod;;- jump to subroutine
38681f5e8f30Smiod(define_expand "call"
38691f5e8f30Smiod  [(parallel [(call (match_operand:SI 0 "" "")
38701f5e8f30Smiod		    (match_operand 1 "" ""))
38711f5e8f30Smiod	      (clobber (reg:SI 1))])]
38721f5e8f30Smiod  ""
38731f5e8f30Smiod  "
38741f5e8f30Smiod{
38751f5e8f30Smiod  gcc_assert (GET_CODE (operands[0]) == MEM);
38761f5e8f30Smiod
38771f5e8f30Smiod  if (! call_address_operand (XEXP (operands[0], 0), SImode)) /* Pmode ? */
38781f5e8f30Smiod    operands[0] = gen_rtx_MEM (GET_MODE (operands[0]),
38791f5e8f30Smiod			       force_reg (Pmode, XEXP (operands[0], 0)));
38801f5e8f30Smiod}")
38811f5e8f30Smiod
38821f5e8f30Smiod(define_insn ""
38831f5e8f30Smiod  [(parallel [(call (mem:SI (match_operand:SI 0 "call_address_operand" "rQ"))
38841f5e8f30Smiod		    (match_operand 1 "" ""))
38851f5e8f30Smiod	      (clobber (reg:SI 1))])]
38861f5e8f30Smiod  ""
38871f5e8f30Smiod  "* return output_call (operands, operands[0]);"
38881f5e8f30Smiod  [(set_attr "type" "call")])
38891f5e8f30Smiod
38901f5e8f30Smiod(define_expand "call_value"
38911f5e8f30Smiod  [(parallel [(set (match_operand 0 "register_operand" "")
38921f5e8f30Smiod		   (call (match_operand:SI 1 "" "")
38931f5e8f30Smiod			 (match_operand 2 "" "")))
38941f5e8f30Smiod	      (clobber (reg:SI 1))])]
38951f5e8f30Smiod  ""
38961f5e8f30Smiod  "
38971f5e8f30Smiod{
38981f5e8f30Smiod  gcc_assert (GET_CODE (operands[1]) == MEM);
38991f5e8f30Smiod
39001f5e8f30Smiod  if (! call_address_operand (XEXP (operands[1], 0), SImode))
39011f5e8f30Smiod    operands[1] = gen_rtx_MEM (GET_MODE (operands[1]),
39021f5e8f30Smiod			       force_reg (Pmode, XEXP (operands[1], 0)));
39031f5e8f30Smiod}")
39041f5e8f30Smiod
39051f5e8f30Smiod(define_insn ""
39061f5e8f30Smiod  [(parallel [(set (match_operand 0 "register_operand" "=r")
39071f5e8f30Smiod		   (call (mem:SI
39081f5e8f30Smiod			  (match_operand:SI 1 "call_address_operand" "rQ"))
39091f5e8f30Smiod			 (match_operand 2 "" "")))
39101f5e8f30Smiod	      (clobber (reg:SI 1))])]
39111f5e8f30Smiod  ""
39121f5e8f30Smiod  "* return output_call (operands, operands[1]);"
39131f5e8f30Smiod  [(set_attr "type" "call")])
39141f5e8f30Smiod
39151f5e8f30Smiod;; Nop instruction and others
39161f5e8f30Smiod
39171f5e8f30Smiod(define_insn "nop"
39181f5e8f30Smiod  [(const_int 0)]
39191f5e8f30Smiod  ""
39201f5e8f30Smiod  "ff0 %#r0,%#r0"
39211f5e8f30Smiod  [(set_attr "type" "bit")])
39221f5e8f30Smiod
39231f5e8f30Smiod(define_insn "return"
39241f5e8f30Smiod  [(return)]
39251f5e8f30Smiod  "null_prologue()"
39261f5e8f30Smiod  "jmp%. %#r1"
39271f5e8f30Smiod  [(set_attr "type" "jump")])
39281f5e8f30Smiod
39291f5e8f30Smiod(define_expand "prologue"
39301f5e8f30Smiod  [(use (const_int 0))]
39311f5e8f30Smiod  ""
39321f5e8f30Smiod{
39331f5e8f30Smiod  m88k_expand_prologue ();
39341f5e8f30Smiod  DONE;
39351f5e8f30Smiod})
39361f5e8f30Smiod
39371f5e8f30Smiod(define_expand "epilogue"
39381f5e8f30Smiod  [(use (const_int 0))]
39391f5e8f30Smiod  ""
39401f5e8f30Smiod{
39411f5e8f30Smiod  m88k_expand_epilogue ();
39421f5e8f30Smiod})
39431f5e8f30Smiod
39441f5e8f30Smiod(define_insn "blockage"
39451f5e8f30Smiod  [(unspec_volatile [(const_int 0)] 0)]
39461f5e8f30Smiod  ""
39471f5e8f30Smiod  ""
39481f5e8f30Smiod  [(set_attr "length" "0")])
39491f5e8f30Smiod
39501f5e8f30Smiod(define_insn "indirect_jump"
39511f5e8f30Smiod  [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
39521f5e8f30Smiod  ""
39531f5e8f30Smiod  "jmp%. %0"
39541f5e8f30Smiod  [(set_attr "type" "jump")])
39551f5e8f30Smiod
39561f5e8f30Smiod(define_insn "jump"
39571f5e8f30Smiod  [(set (pc)
39581f5e8f30Smiod	(label_ref (match_operand 0 "" "")))]
39591f5e8f30Smiod  ""
39601f5e8f30Smiod  "br%. %l0"
39611f5e8f30Smiod  [(set_attr "type" "jump")])
39621f5e8f30Smiod
39631f5e8f30Smiod;; This insn is used for some loop tests, typically loops reversed when
39641f5e8f30Smiod;; strength reduction is used.  It is actually created when the instruction
39651f5e8f30Smiod;; combination phase combines the special loop test.  Since this insn
39661f5e8f30Smiod;; is both a jump insn and has an output, it must deal with its own
39671f5e8f30Smiod;; reloads, hence the `m' constraints.  The `!' constraints direct reload
39681f5e8f30Smiod;; to not choose the register alternatives in the event a reload is needed.
39691f5e8f30Smiod
39701f5e8f30Smiod(define_expand "decrement_and_branch_until_zero"
39711f5e8f30Smiod  [(parallel [(set (pc)
39721f5e8f30Smiod		   (if_then_else
39731f5e8f30Smiod		    (match_operator 0 "relop_no_unsigned"
39741f5e8f30Smiod				    [(match_operand:SI 1 "register_operand" "")
39751f5e8f30Smiod				     (const_int 0)])
39761f5e8f30Smiod		    (label_ref (match_operand 2 "" ""))
39771f5e8f30Smiod		    (pc)))
39781f5e8f30Smiod	      (set (match_dup 1)
39791f5e8f30Smiod		   (plus:SI (match_dup 1)
39801f5e8f30Smiod			    (match_operand:SI 3 "add_operand" "")))
39811f5e8f30Smiod	      (clobber (match_scratch:SI 4 ""))
39821f5e8f30Smiod	      (clobber (match_scratch:SI 5 "=X,X,&r,&r"))])]
39831f5e8f30Smiod  ""
39841f5e8f30Smiod  "")
39851f5e8f30Smiod
39861f5e8f30Smiod(define_insn ""
39871f5e8f30Smiod  [(set (pc)
39881f5e8f30Smiod	(if_then_else
39891f5e8f30Smiod	 (match_operator 0 "relop_no_unsigned"
39901f5e8f30Smiod			 [(match_operand:SI 1 "register_operand" "+!r,!r,m,m")
39911f5e8f30Smiod			  (const_int 0)])
39921f5e8f30Smiod	  (label_ref (match_operand 2 "" ""))
39931f5e8f30Smiod	  (pc)))
39941f5e8f30Smiod   (set (match_dup 1)
39951f5e8f30Smiod	(plus:SI (match_dup 1)
39961f5e8f30Smiod		 (match_operand:SI 3 "add_operand" "rI,J,rI,J")))
39971f5e8f30Smiod   (clobber (match_scratch:SI 4 "=X,X,&r,&r"))
39981f5e8f30Smiod   (clobber (match_scratch:SI 5 "=X,X,&r,&r"))]
39991f5e8f30Smiod  "find_reg_note (insn, REG_NONNEG, 0)"
40001f5e8f30Smiod  "@
40011f5e8f30Smiod   bcnd.n %B0,%1,%2\;addu %1,%1,%3
40021f5e8f30Smiod   bcnd.n %B0,%1,%2\;subu %1,%1,%n3
40031f5e8f30Smiod   ld %4,%1\;addu %5,%4,%3\;bcnd.n %B0,%4,%2\;st %5,%1
40041f5e8f30Smiod   ld %4,%1\;subu %5,%4,%n3\;bcnd.n %B0,%4,%2\;st %5,%1"
40051f5e8f30Smiod  [(set_attr "type" "weird")
40061f5e8f30Smiod   (set_attr "length" "2,2,4,4")])
40071f5e8f30Smiod
40081f5e8f30Smiod;; Special insn to serve as the last insn of a define_expand.  This insn
40091f5e8f30Smiod;; will generate no code.
40101f5e8f30Smiod
40111f5e8f30Smiod(define_expand "dummy"
40121f5e8f30Smiod  [(set (match_operand 0 "" "") (match_dup 0))]
40131f5e8f30Smiod  ""
40141f5e8f30Smiod  "")
4015