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