home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / bbs / gnu / gcc-2.6.0-src.lha / GNU / src / amiga / gcc-2.6.0 / config / sparc / sparc.md < prev    next >
Encoding:
Text File  |  1994-06-28  |  169.1 KB  |  5,679 lines

  1. ;;- Machine description for SPARC chip for GNU C compiler
  2. ;;   Copyright (C) 1987, 88, 89, 92, 93, 1994 Free Software Foundation, Inc.
  3. ;;   Contributed by Michael Tiemann (tiemann@cygnus.com)
  4. ;;   64 bit SPARC V9 support by Michael Tiemann, Jim Wilson, and Doug Evans,
  5. ;;   at Cygnus Support.
  6.  
  7. ;; This file is part of GNU CC.
  8.  
  9. ;; GNU CC is free software; you can redistribute it and/or modify
  10. ;; it under the terms of the GNU General Public License as published by
  11. ;; the Free Software Foundation; either version 2, or (at your option)
  12. ;; any later version.
  13.  
  14. ;; GNU CC is distributed in the hope that it will be useful,
  15. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. ;; GNU General Public License for more details.
  18.  
  19. ;; You should have received a copy of the GNU General Public License
  20. ;; along with GNU CC; see the file COPYING.  If not, write to
  21. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23.  
  24. ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
  25.  
  26. ;; Architecture type.  Arch32bit includes v7, sparclite, v8.
  27.  
  28. (define_attr "arch" "arch32bit,arch64bit"
  29.   (const (symbol_ref "sparc_arch_type")))
  30.  
  31. ;; CPU type. This is only used for instruction scheduling
  32. (define_attr "cpu" "cypress,supersparc"
  33.  (const
  34.   (cond [(symbol_ref "TARGET_SUPERSPARC") (const_string "supersparc")]
  35.     (const_string "cypress"))))
  36.  
  37. ;; Insn type.  Used to default other attribute values.
  38.  
  39. ;; type "unary" insns have one input operand (1) and one output operand (0)
  40. ;; type "binary" insns have two input operands (1,2) and one output (0)
  41. ;; type "compare" insns have one or two input operands (0,1) and no output
  42. ;; type "call_no_delay_slot" is a call followed by an unimp instruction.
  43.  
  44. (define_attr "type"
  45.   "move,unary,binary,compare,load,store,ialu,shift,uncond_branch,branch,call,call_no_delay_slot,address,imul,fpload,fpstore,fp,fpcmp,fpmul,fpdivs,fpdivd,fpsqrt,cmove,multi,misc"
  46.   (const_string "binary"))
  47.  
  48. ;; Set true if insn uses call-clobbered intermediate register.
  49. (define_attr "use_clobbered" "false,true"
  50.   (if_then_else (and (eq_attr "type" "address")
  51.              (match_operand 0 "clobbered_register" ""))
  52.          (const_string "true")
  53.         (const_string "false")))
  54.  
  55. ;; Length (in # of insns).
  56. (define_attr "length" ""
  57.   (cond [(eq_attr "type" "load,fpload")
  58.      (if_then_else (match_operand 1 "symbolic_memory_operand" "")
  59.                (const_int 2) (const_int 1))
  60.  
  61.      (eq_attr "type" "store,fpstore")
  62.      (if_then_else (match_operand 0 "symbolic_memory_operand" "")
  63.                (const_int 2) (const_int 1))
  64.  
  65.      (eq_attr "type" "address") (const_int 2)
  66.  
  67.      (eq_attr "type" "binary")
  68.      (if_then_else (ior (match_operand 2 "arith_operand" "")
  69.                 (match_operand 2 "arith_double_operand" ""))
  70.                (const_int 1) (const_int 3))
  71.  
  72.      (eq_attr "type" "multi") (const_int 2)
  73.  
  74.      (eq_attr "type" "move,unary")
  75.      (if_then_else (ior (match_operand 1 "arith_operand" "")
  76.                 (match_operand 1 "arith_double_operand" ""))
  77.                (const_int 1) (const_int 2))]
  78.  
  79.     (const_int 1)))
  80.  
  81. (define_asm_attributes
  82.   [(set_attr "length" "1")
  83.    (set_attr "type" "multi")])
  84.  
  85. ;; Attributes for instruction and branch scheduling
  86.  
  87. (define_attr "in_call_delay" "false,true"
  88.   (cond [(eq_attr "type" "uncond_branch,branch,call,call_no_delay_slot,multi")
  89.          (const_string "false")
  90.      (eq_attr "type" "load,fpload,store,fpstore")
  91.          (if_then_else (eq_attr "length" "1")
  92.                   (const_string "true")
  93.                   (const_string "false"))
  94.      (eq_attr "type" "address")
  95.          (if_then_else (eq_attr "use_clobbered" "false")
  96.                   (const_string "true")
  97.                   (const_string "false"))]
  98.     (if_then_else (eq_attr "length" "1")
  99.               (const_string "true")
  100.               (const_string "false"))))
  101.  
  102. (define_delay (eq_attr "type" "call")
  103.   [(eq_attr "in_call_delay" "true") (nil) (nil)])
  104.  
  105. ;; ??? Should implement the notion of predelay slots for floating point
  106. ;; branches.  This would allow us to remove the nop always inserted before
  107. ;; a floating point branch.
  108.  
  109. ;; ??? It is OK for fill_simple_delay_slots to put load/store instructions
  110. ;; in a delay slot, but it is not OK for fill_eager_delay_slots to do so.
  111. ;; This is because doing so will add several pipeline stalls to the path
  112. ;; that the load/store did not come from.  Unfortunately, there is no way
  113. ;; to prevent fill_eager_delay_slots from using load/store without completely
  114. ;; disabling them.  For the SPEC benchmark set, this is a serious lose,
  115. ;; because it prevents us from moving back the final store of inner loops.
  116.  
  117. (define_attr "in_branch_delay" "false,true"
  118.   (if_then_else (and (eq_attr "type" "!uncond_branch,branch,call,call_no_delay_slot,multi")
  119.              (eq_attr "length" "1"))
  120.         (const_string "true")
  121.         (const_string "false")))
  122.  
  123. (define_attr "in_uncond_branch_delay" "false,true"
  124.   (if_then_else (and (eq_attr "type" "!uncond_branch,branch,call,call_no_delay_slot,multi")
  125.              (eq_attr "length" "1"))
  126.         (const_string "true")
  127.         (const_string "false")))
  128.  
  129. (define_attr "in_annul_branch_delay" "false,true"
  130.   (if_then_else (and (eq_attr "type" "!uncond_branch,branch,call,call_no_delay_slot,multi")
  131.              (eq_attr "length" "1"))
  132.         (const_string "true")
  133.         (const_string "false")))
  134.  
  135. (define_delay (eq_attr "type" "branch")
  136.   [(eq_attr "in_branch_delay" "true")
  137.    (nil) (eq_attr "in_annul_branch_delay" "true")])
  138.  
  139. (define_delay (eq_attr "type" "uncond_branch")
  140.   [(eq_attr "in_uncond_branch_delay" "true")
  141.    (nil) (nil)])
  142.    
  143. ;; Function units of the SPARC
  144.  
  145. ;; (define_function_unit {name} {num-units} {n-users} {test}
  146. ;;                       {ready-delay} {issue-delay} [{conflict-list}])
  147.  
  148. ;; The integer ALU.
  149. ;; (Noted only for documentation; units that take one cycle do not need to
  150. ;; be specified.)
  151.  
  152. ;; On the sparclite, integer multiply takes 1, 3, or 5 cycles depending on
  153. ;; the inputs.
  154.  
  155. ;; (define_function_unit "alu" 1 0
  156. ;;  (eq_attr "type" "unary,binary,move,address") 1 0)
  157.  
  158. ;; ---- cypress CY7C602 scheduling:
  159. ;; Memory with load-delay of 1 (i.e., 2 cycle load).
  160. (define_function_unit "memory" 1 0 
  161.   (and (eq_attr "type" "load,fpload") (eq_attr "cpu" "cypress")) 2 2)
  162.  
  163. ;; SPARC has two floating-point units: the FP ALU,
  164. ;; and the FP MUL/DIV/SQRT unit.
  165. ;; Instruction timings on the CY7C602 are as follows
  166. ;; FABSs    4
  167. ;; FADDs/d    5/5
  168. ;; FCMPs/d    4/4
  169. ;; FDIVs/d    23/37
  170. ;; FMOVs    4
  171. ;; FMULs/d    5/7
  172. ;; FNEGs    4
  173. ;; FSQRTs/d    34/63
  174. ;; FSUBs/d    5/5
  175. ;; FdTOi/s    5/5
  176. ;; FsTOi/d    5/5
  177. ;; FiTOs/d    9/5
  178.  
  179. ;; The CY7C602 can only support 2 fp isnsn simultaneously.
  180. ;; More insns cause the chip to stall.
  181.  
  182. (define_function_unit "fp_alu" 1 0
  183.   (and (eq_attr "type" "fp")            (eq_attr "cpu" "cypress")) 5 5)
  184. (define_function_unit "fp_mds" 1 0
  185.   (and (eq_attr "type" "fpmul")         (eq_attr "cpu" "cypress")) 7 7)
  186. (define_function_unit "fp_mds" 1 0
  187.   (and (eq_attr "type" "fpdivs,fpdivd") (eq_attr "cpu" "cypress")) 37 37)
  188. (define_function_unit "fp_mds" 1 0
  189.   (and (eq_attr "type" "fpsqrt")        (eq_attr "cpu" "cypress")) 63 63)
  190.  
  191. ;; ----- The TMS390Z55 scheduling
  192. ;; The Supersparc can issue 1 - 3 insns per cycle; here we assume
  193. ;; three insns/cycle, and hence multiply all costs by three.
  194. ;; Combinations up to two integer, one ld/st, one fp.
  195. ;; Memory delivers its result in one cycle to IU, zero cycles to FP
  196. (define_function_unit "memory" 1 0
  197.   (and (eq_attr "type" "load")          (eq_attr "cpu" "supersparc")) 3 3)
  198. (define_function_unit "memory" 1 0
  199.   (and (eq_attr "type" "fpload")        (eq_attr "cpu" "supersparc")) 1 3)
  200. ;; at least one in three instructions can be a mem opt.
  201. (define_function_unit "memory" 1 0
  202.   (and (eq_attr "type" "store,fpstore") (eq_attr "cpu" "supersparc")) 1 3)
  203. ;; at least one in three instructions can be a shift op.
  204. (define_function_unit "shift" 1 0
  205.   (and (eq_attr "type" "shift")         (eq_attr "cpu" "supersparc")) 1 3)
  206.  
  207. ;; There are only two write ports to the integer register file
  208. ;; A store also uses a write port
  209. (define_function_unit "iwport" 2 0
  210.   (and (eq_attr "type" "load,store,shift,ialu") (eq_attr "cpu" "supersparc")) 1 3)
  211.  
  212. ;; Timings; throughput/latency
  213. ;; FADD     1/3    add/sub, format conv, compar, abs, neg
  214. ;; FMUL     1/3
  215. ;; FDIVs    4/6
  216. ;; FDIVd    7/9
  217. ;; FSQRTs   6/8
  218. ;; FSQRTd  10/12
  219. ;; IMUL     4/4
  220.  
  221. (define_function_unit "fp_alu" 1 0
  222.   (and (eq_attr "type" "fp,fpcmp") (eq_attr "cpu" "supersparc")) 9 3)
  223. (define_function_unit "fp_mds" 1 0
  224.   (and (eq_attr "type" "fpmul")    (eq_attr "cpu" "supersparc")) 9 3)
  225. (define_function_unit "fp_mds" 1 0
  226.   (and (eq_attr "type" "fpdivs")   (eq_attr "cpu" "supersparc")) 18 12)
  227. (define_function_unit "fp_mds" 1 0
  228.   (and (eq_attr "type" "fpdivd")   (eq_attr "cpu" "supersparc")) 27 21)
  229. (define_function_unit "fp_mds" 1 0
  230.   (and (eq_attr "type" "fpsqrt")   (eq_attr "cpu" "supersparc")) 36 30)
  231. (define_function_unit "fp_mds" 1 0
  232.   (and (eq_attr "type" "imul")     (eq_attr "cpu" "supersparc")) 12 12)
  233.  
  234. ;; Compare instructions.
  235. ;; This controls RTL generation and register allocation.
  236.  
  237. ;; We generate RTL for comparisons and branches by having the cmpxx 
  238. ;; patterns store away the operands.  Then, the scc and bcc patterns
  239. ;; emit RTL for both the compare and the branch.
  240. ;;
  241. ;; We do this because we want to generate different code for an sne and
  242. ;; seq insn.  In those cases, if the second operand of the compare is not
  243. ;; const0_rtx, we want to compute the xor of the two operands and test
  244. ;; it against zero.
  245. ;;
  246. ;; We start with the DEFINE_EXPANDs, then the DEFINE_INSNs to match
  247. ;; the patterns.  Finally, we have the DEFINE_SPLITs for some of the scc
  248. ;; insns that actually require more than one machine instruction.
  249.  
  250. ;; Put cmpsi first among compare insns so it matches two CONST_INT operands.
  251.  
  252. (define_expand "cmpsi"
  253.   [(set (reg:CC 0)
  254.     (compare:CC (match_operand:SI 0 "register_operand" "")
  255.             (match_operand:SI 1 "arith_operand" "")))]
  256.   ""
  257.   "
  258. {
  259.   sparc_compare_op0 = operands[0];
  260.   sparc_compare_op1 = operands[1];
  261.   DONE;
  262. }")
  263.  
  264. (define_expand "cmpdi"
  265.   [(set (reg:CCX 0)
  266.     (compare:CCX (match_operand:DI 0 "register_operand" "")
  267.              (match_operand:DI 1 "arith_double_operand" "")))]
  268.   "TARGET_V9"
  269.   "
  270. {
  271.   sparc_compare_op0 = operands[0];
  272.   sparc_compare_op1 = operands[1];
  273.   DONE;
  274. }")
  275.  
  276. (define_expand "cmpsf"
  277.   [(set (reg:CCFP 0)
  278.     (compare:CCFP (match_operand:SF 0 "register_operand" "")
  279.               (match_operand:SF 1 "register_operand" "")))]
  280.   "TARGET_FPU"
  281.   "
  282. {
  283.   sparc_compare_op0 = operands[0];
  284.   sparc_compare_op1 = operands[1];
  285.   DONE;
  286. }")
  287.  
  288. (define_expand "cmpdf"
  289.   [(set (reg:CCFP 0)
  290.     (compare:CCFP (match_operand:DF 0 "register_operand" "")
  291.               (match_operand:DF 1 "register_operand" "")))]
  292.   "TARGET_FPU"
  293.   "
  294. {
  295.   sparc_compare_op0 = operands[0];
  296.   sparc_compare_op1 = operands[1];
  297.   DONE;
  298. }")
  299.  
  300. (define_expand "cmptf"
  301.   [(set (reg:CCFP 0)
  302.     (compare:CCFP (match_operand:TF 0 "register_operand" "")
  303.               (match_operand:TF 1 "register_operand" "")))]
  304.   "TARGET_FPU"
  305.   "
  306. {
  307.   sparc_compare_op0 = operands[0];
  308.   sparc_compare_op1 = operands[1];
  309.   DONE;
  310. }")
  311.  
  312. ;; Next come the scc insns.  For seq, sne, sgeu, and sltu, we can do this
  313. ;; without jumps using the addx/subx instructions.  For seq/sne on v9 we use
  314. ;; the same code as v8 (the addx/subx method has more applications).  The
  315. ;; exception to this is "reg != 0" which can be done in one instruction on v9
  316. ;; (so we do it).  For the rest, on v9 we use conditional moves; on v8, we do
  317. ;; branches.
  318.  
  319. ;; Seq_special[_xxx] and sne_special[_xxx] clobber the CC reg, because they
  320. ;; generate addcc/subcc instructions.
  321.  
  322. (define_expand "seqsi_special"
  323.   [(set (match_dup 3)
  324.     (xor:SI (match_operand:SI 1 "register_operand" "")
  325.         (match_operand:SI 2 "register_operand" "")))
  326.    (parallel [(set (match_operand:SI 0 "register_operand" "")
  327.            (eq:SI (match_dup 3) (const_int 0)))
  328.           (clobber (reg:CC 0))])]
  329.   ""
  330.   "{ operands[3] = gen_reg_rtx (SImode); }")
  331.  
  332. (define_expand "seqdi_special"
  333.   [(set (match_dup 3)
  334.     (xor:DI (match_operand:DI 1 "register_operand" "")
  335.         (match_operand:DI 2 "register_operand" "")))
  336.    (parallel [(set (match_operand:DI 0 "register_operand" "")
  337.            (eq:DI (match_dup 3) (const_int 0)))
  338.           (clobber (reg:CCX 0))])]
  339.   ""
  340.   "{ operands[3] = gen_reg_rtx (DImode); }")
  341.  
  342. (define_expand "snesi_special"
  343.   [(set (match_dup 3)
  344.     (xor:SI (match_operand:SI 1 "register_operand" "")
  345.         (match_operand:SI 2 "register_operand" "")))
  346.    (parallel [(set (match_operand:SI 0 "register_operand" "")
  347.            (ne:SI (match_dup 3) (const_int 0)))
  348.           (clobber (reg:CC 0))])]
  349.   ""
  350.   "{ operands[3] = gen_reg_rtx (SImode); }")
  351.  
  352. (define_expand "snedi_special"
  353.   [(set (match_dup 3)
  354.     (xor:DI (match_operand:DI 1 "register_operand" "")
  355.         (match_operand:DI 2 "register_operand" "")))
  356.    (parallel [(set (match_operand:DI 0 "register_operand" "")
  357.            (ne:DI (match_dup 3) (const_int 0)))
  358.           (clobber (reg:CCX 0))])]
  359.   ""
  360.   "{ operands[3] = gen_reg_rtx (DImode); }")
  361.  
  362. (define_expand "seqdi_special_trunc"
  363.   [(set (match_dup 3)
  364.     (xor:DI (match_operand:DI 1 "register_operand" "")
  365.         (match_operand:DI 2 "register_operand" "")))
  366.    (parallel [(set (match_operand:SI 0 "register_operand" "")
  367.            (eq:SI (subreg:SI (match_dup 3) 0) (const_int 0)))
  368.           (clobber (reg:CC 0))])]
  369.   ""
  370.   "{ operands[3] = gen_reg_rtx (DImode); }")
  371.  
  372. (define_expand "snedi_special_trunc"
  373.   [(set (match_dup 3)
  374.     (xor:DI (match_operand:DI 1 "register_operand" "")
  375.         (match_operand:DI 2 "register_operand" "")))
  376.    (parallel [(set (match_operand:SI 0 "register_operand" "")
  377.            (ne:SI (subreg:SI (match_dup 3) 0) (const_int 0)))
  378.           (clobber (reg:CC 0))])]
  379.   ""
  380.   "{ operands[3] = gen_reg_rtx (DImode); }")
  381.  
  382. (define_expand "seqsi_special_extend"
  383.   [(set (subreg:SI (match_dup 3) 0)
  384.     (xor:SI (match_operand:SI 1 "register_operand" "")
  385.         (match_operand:SI 2 "register_operand" "")))
  386.    (parallel [(set (match_operand:DI 0 "register_operand" "")
  387.            (eq:DI (match_dup 3) (const_int 0)))
  388.           (clobber (reg:CCX 0))])]
  389.   ""
  390.   "{ operands[3] = gen_reg_rtx (DImode); }")
  391.  
  392. (define_expand "snesi_special_extend"
  393.   [(set (subreg:SI (match_dup 3) 0)
  394.     (xor:SI (match_operand:SI 1 "register_operand" "")
  395.         (match_operand:SI 2 "register_operand" "")))
  396.    (parallel [(set (match_operand:DI 0 "register_operand" "")
  397.            (ne:DI (match_dup 3) (const_int 0)))
  398.           (clobber (reg:CCX 0))])]
  399.   ""
  400.   "{ operands[3] = gen_reg_rtx (DImode); }")
  401.  
  402. ;; ??? v9: Operand 0 needs a mode, so SImode was chosen.
  403. ;; However, the code handles both SImode and DImode.
  404. (define_expand "seq"
  405.   [(set (match_operand:SI 0 "intreg_operand" "")
  406.     (eq:SI (match_dup 1) (const_int 0)))]
  407.   ""
  408.   "
  409. {
  410.   if (GET_MODE (sparc_compare_op0) == SImode)
  411.     {
  412.       rtx pat;
  413.  
  414.       if (GET_MODE (operands[0]) == SImode)
  415.     pat = gen_seqsi_special (operands[0], sparc_compare_op0,
  416.                  sparc_compare_op1);
  417.       else if (! TARGET_V9)
  418.     FAIL;
  419.       else
  420.     pat = gen_seqsi_special_extend (operands[0], sparc_compare_op0,
  421.                     sparc_compare_op1);
  422.       emit_insn (pat);
  423.       DONE;
  424.     }
  425.   else if (GET_MODE (sparc_compare_op0) == DImode)
  426.     {
  427.       rtx pat;
  428.  
  429.       if (GET_MODE (operands[0]) == SImode)
  430.     pat = gen_seqdi_special_trunc (operands[0], sparc_compare_op0,
  431.                        sparc_compare_op1);
  432.       else if (! TARGET_V9)
  433.     FAIL;
  434.       else
  435.     pat = gen_seqdi_special (operands[0], sparc_compare_op0,
  436.                  sparc_compare_op1);
  437.       emit_insn (pat);
  438.       DONE;
  439.     }
  440.   else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
  441.     {
  442.       emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, EQ);
  443.       emit_insn (gen_sne (operands[0]));
  444.       DONE;
  445.     }      
  446.   else if (TARGET_V9)
  447.     {
  448.       if (gen_v9_scc (EQ, operands))
  449.     DONE;
  450.       /* fall through */
  451.     }
  452.   operands[1] = gen_compare_reg (EQ, sparc_compare_op0, sparc_compare_op1);
  453. }")
  454.  
  455. ;; ??? v9: Operand 0 needs a mode, so SImode was chosen.
  456. ;; However, the code handles both SImode and DImode.
  457. (define_expand "sne"
  458.   [(set (match_operand:SI 0 "intreg_operand" "")
  459.     (ne:SI (match_dup 1) (const_int 0)))]
  460.   ""
  461.   "
  462. {
  463.   if (GET_MODE (sparc_compare_op0) == SImode)
  464.     {
  465.       rtx pat;
  466.  
  467.       if (GET_MODE (operands[0]) == SImode)
  468.     pat = gen_snesi_special (operands[0], sparc_compare_op0,
  469.                  sparc_compare_op1);
  470.       else if (! TARGET_V9)
  471.     FAIL;
  472.       else
  473.     pat = gen_snesi_special_extend (operands[0], sparc_compare_op0,
  474.                     sparc_compare_op1);
  475.       emit_insn (pat);
  476.       DONE;
  477.     }
  478.   else if (GET_MODE (sparc_compare_op0) == DImode)
  479.     {
  480.       rtx pat;
  481.  
  482.       if (GET_MODE (operands[0]) == SImode)
  483.     pat = gen_snedi_special_trunc (operands[0], sparc_compare_op0,
  484.                        sparc_compare_op1);
  485.       else if (! TARGET_V9)
  486.     FAIL;
  487.       else
  488.     pat = gen_snedi_special (operands[0], sparc_compare_op0,
  489.                  sparc_compare_op1);
  490.       emit_insn (pat);
  491.       DONE;
  492.     }
  493.   else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
  494.     {
  495.       emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, NE);
  496.       emit_insn (gen_sne (operands[0]));
  497.       DONE;
  498.     }      
  499.   else if (TARGET_V9)
  500.     {
  501.       if (gen_v9_scc (NE, operands))
  502.     DONE;
  503.       /* fall through */
  504.     }
  505.   operands[1] = gen_compare_reg (NE, sparc_compare_op0, sparc_compare_op1);
  506. }")
  507.  
  508. (define_expand "sgt"
  509.   [(set (match_operand:SI 0 "intreg_operand" "")
  510.     (gt:SI (match_dup 1) (const_int 0)))]
  511.   ""
  512.   "
  513. {
  514.   if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
  515.     {
  516.       emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, GT);
  517.       emit_insn (gen_sne (operands[0]));
  518.       DONE;
  519.     }
  520.   else if (TARGET_V9)
  521.     {
  522.       if (gen_v9_scc (GT, operands))
  523.     DONE;
  524.       /* fall through */
  525.     }
  526.   operands[1] = gen_compare_reg (GT, sparc_compare_op0, sparc_compare_op1);
  527. }")
  528.  
  529. (define_expand "slt"
  530.   [(set (match_operand:SI 0 "intreg_operand" "")
  531.     (lt:SI (match_dup 1) (const_int 0)))]
  532.   ""
  533.   "
  534. {
  535.   if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
  536.     {
  537.       emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, LT);
  538.       emit_insn (gen_sne (operands[0]));
  539.       DONE;
  540.     }
  541.   else if (TARGET_V9)
  542.     {
  543.       if (gen_v9_scc (LT, operands))
  544.     DONE;
  545.       /* fall through */
  546.     }
  547.   operands[1] = gen_compare_reg (LT, sparc_compare_op0, sparc_compare_op1);
  548. }")
  549.  
  550. (define_expand "sge"
  551.   [(set (match_operand:SI 0 "intreg_operand" "")
  552.     (ge:SI (match_dup 1) (const_int 0)))]
  553.   ""
  554.   "
  555. {
  556.   if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
  557.     {
  558.       emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, GE);
  559.       emit_insn (gen_sne (operands[0]));
  560.       DONE;
  561.     }
  562.   else if (TARGET_V9)
  563.     {
  564.       if (gen_v9_scc (GE, operands))
  565.     DONE;
  566.       /* fall through */
  567.     }
  568.   operands[1] = gen_compare_reg (GE, sparc_compare_op0, sparc_compare_op1);
  569. }")
  570.  
  571. (define_expand "sle"
  572.   [(set (match_operand:SI 0 "intreg_operand" "")
  573.     (le:SI (match_dup 1) (const_int 0)))]
  574.   ""
  575.   "
  576. {
  577.   if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
  578.     {
  579.       emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, LE);
  580.       emit_insn (gen_sne (operands[0]));
  581.       DONE;
  582.     }
  583.   else if (TARGET_V9)
  584.     {
  585.       if (gen_v9_scc (LE, operands))
  586.     DONE;
  587.       /* fall through */
  588.     }
  589.   operands[1] = gen_compare_reg (LE, sparc_compare_op0, sparc_compare_op1);
  590. }")
  591.  
  592. (define_expand "sgtu"
  593.   [(set (match_operand:SI 0 "intreg_operand" "")
  594.     (gtu:SI (match_dup 1) (const_int 0)))]
  595.   ""
  596.   "
  597. {
  598.   if (! TARGET_V9)
  599.     {
  600.       rtx tem;
  601.  
  602.       /* We can do ltu easily, so if both operands are registers, swap them and
  603.      do a LTU.  */
  604.       if ((GET_CODE (sparc_compare_op0) == REG
  605.        || GET_CODE (sparc_compare_op0) == SUBREG)
  606.       && (GET_CODE (sparc_compare_op1) == REG
  607.           || GET_CODE (sparc_compare_op1) == SUBREG))
  608.     {
  609.       tem = sparc_compare_op0;
  610.       sparc_compare_op0 = sparc_compare_op1;
  611.       sparc_compare_op1 = tem;
  612.       emit_insn (gen_sltu (operands[0]));
  613.       DONE;
  614.     }
  615.     }
  616.   else
  617.     {
  618.       if (gen_v9_scc (GTU, operands))
  619.     DONE;
  620.     }
  621.   operands[1] = gen_compare_reg (GTU, sparc_compare_op0, sparc_compare_op1);
  622. }")
  623.  
  624. (define_expand "sltu"
  625.   [(set (match_operand:SI 0 "intreg_operand" "")
  626.     (ltu:SI (match_dup 1) (const_int 0)))]
  627.   ""
  628.   "
  629. {
  630.   if (TARGET_V9)
  631.     {
  632.       if (gen_v9_scc (LTU, operands))
  633.     DONE;
  634.     }
  635.   operands[1] = gen_compare_reg (LTU, sparc_compare_op0, sparc_compare_op1);
  636. }")
  637.  
  638. (define_expand "sgeu"
  639.   [(set (match_operand:SI 0 "intreg_operand" "")
  640.     (geu:SI (match_dup 1) (const_int 0)))]
  641.   ""
  642.   "
  643. {
  644.   if (TARGET_V9)
  645.     {
  646.       if (gen_v9_scc (GEU, operands))
  647.     DONE;
  648.     }
  649.   operands[1] = gen_compare_reg (GEU, sparc_compare_op0, sparc_compare_op1);
  650. }")
  651.  
  652. (define_expand "sleu"
  653.   [(set (match_operand:SI 0 "intreg_operand" "")
  654.     (leu:SI (match_dup 1) (const_int 0)))]
  655.   ""
  656.   "
  657. {
  658.   if (! TARGET_V9)
  659.     {
  660.       rtx tem;
  661.  
  662.       /* We can do geu easily, so if both operands are registers, swap them and
  663.      do a GEU.  */
  664.       if ((GET_CODE (sparc_compare_op0) == REG
  665.        || GET_CODE (sparc_compare_op0) == SUBREG)
  666.       && (GET_CODE (sparc_compare_op1) == REG
  667.           || GET_CODE (sparc_compare_op1) == SUBREG))
  668.     {
  669.       tem = sparc_compare_op0;
  670.       sparc_compare_op0 = sparc_compare_op1;
  671.       sparc_compare_op1 = tem;
  672.       emit_insn (gen_sgeu (operands[0]));
  673.       DONE;
  674.     }
  675.     }
  676.   else
  677.     {
  678.       if (gen_v9_scc (LEU, operands))
  679.     DONE;
  680.     }
  681.   operands[1] = gen_compare_reg (LEU, sparc_compare_op0, sparc_compare_op1);
  682. }")
  683.  
  684. ;; Now the DEFINE_INSNs for the compare and scc cases.  First the compares.
  685.  
  686. (define_insn ""
  687.   [(set (reg:CC 0)
  688.     (compare:CC (match_operand:SI 0 "register_operand" "r")
  689.             (match_operand:SI 1 "arith_operand" "rI")))]
  690.   ""
  691.   "cmp %r0,%1"
  692.   [(set_attr "type" "compare")])
  693.  
  694. (define_insn ""
  695.   [(set (reg:CCFPE 0)
  696.     (compare:CCFPE (match_operand:SF 0 "register_operand" "f")
  697.                (match_operand:SF 1 "register_operand" "f")))]
  698.   "! TARGET_V9 && TARGET_FPU"
  699.   "fcmpes %0,%1"
  700.   [(set_attr "type" "fpcmp")])
  701.  
  702. (define_insn ""
  703.   [(set (reg:CCFPE 0)
  704.     (compare:CCFPE (match_operand:DF 0 "register_operand" "f")
  705.                (match_operand:DF 1 "register_operand" "f")))]
  706.   "! TARGET_V9 && TARGET_FPU"
  707.   "fcmped %0,%1"
  708.   [(set_attr "type" "fpcmp")])
  709.  
  710. (define_insn ""
  711.   [(set (reg:CCFPE 0)
  712.     (compare:CCFPE (match_operand:TF 0 "register_operand" "f")
  713.                (match_operand:TF 1 "register_operand" "f")))]
  714.   "! TARGET_V9 && TARGET_FPU && TARGET_HARD_QUAD"
  715.   "fcmpeq %0,%1"
  716.   [(set_attr "type" "fpcmp")])
  717.  
  718. (define_insn ""
  719.   [(set (reg:CCFP 0)
  720.     (compare:CCFP (match_operand:SF 0 "register_operand" "f")
  721.               (match_operand:SF 1 "register_operand" "f")))]
  722.   "! TARGET_V9 && TARGET_FPU"
  723.   "fcmps %0,%1"
  724.   [(set_attr "type" "fpcmp")])
  725.  
  726. (define_insn ""
  727.   [(set (reg:CCFP 0)
  728.     (compare:CCFP (match_operand:DF 0 "register_operand" "f")
  729.               (match_operand:DF 1 "register_operand" "f")))]
  730.   "! TARGET_V9 && TARGET_FPU"
  731.   "fcmpd %0,%1"
  732.   [(set_attr "type" "fpcmp")])
  733.  
  734. (define_insn ""
  735.   [(set (reg:CCFP 0)
  736.     (compare:CCFP (match_operand:TF 0 "register_operand" "f")
  737.               (match_operand:TF 1 "register_operand" "f")))]
  738.   "! TARGET_V9 && TARGET_FPU && TARGET_HARD_QUAD"
  739.   "fcmpq %0,%1"
  740.   [(set_attr "type" "fpcmp")])
  741.  
  742. (define_insn ""
  743.   [(set (reg:CCX 0)
  744.     (compare:CCX (match_operand:DI 0 "register_operand" "r")
  745.              (match_operand:DI 1 "arith_double_operand" "rHI")))]
  746.   "TARGET_V9"
  747.   "cmp %r0,%1"
  748.   [(set_attr "type" "compare")])
  749.  
  750. (define_insn ""
  751.   [(set (match_operand:CCFPE 0 "ccfp_reg_operand" "=c")
  752.     (compare:CCFPE (match_operand:SF 1 "register_operand" "f")
  753.                (match_operand:SF 2 "register_operand" "f")))]
  754.   "TARGET_V9 && TARGET_FPU"
  755.   "fcmpes %0,%1,%2"
  756.   [(set_attr "type" "fpcmp")])
  757.  
  758. (define_insn ""
  759.   [(set (match_operand:CCFPE 0 "ccfp_reg_operand" "=c")
  760.     (compare:CCFPE (match_operand:DF 1 "register_operand" "f")
  761.                (match_operand:DF 2 "register_operand" "f")))]
  762.   "TARGET_V9 && TARGET_FPU"
  763.   "fcmped %0,%1,%2"
  764.   [(set_attr "type" "fpcmp")])
  765.  
  766. (define_insn ""
  767.   [(set (match_operand:CCFPE 0 "ccfp_reg_operand" "=c")
  768.     (compare:CCFPE (match_operand:TF 1 "register_operand" "f")
  769.                (match_operand:TF 2 "register_operand" "f")))]
  770.   "TARGET_V9 && TARGET_FPU && TARGET_HARD_QUAD"
  771.   "fcmpeq %0,%1,%2"
  772.   [(set_attr "type" "fpcmp")])
  773.  
  774. (define_insn ""
  775.   [(set (match_operand:CCFP 0 "ccfp_reg_operand" "=c")
  776.     (compare:CCFP (match_operand:SF 1 "register_operand" "f")
  777.               (match_operand:SF 2 "register_operand" "f")))]
  778.   "TARGET_V9 && TARGET_FPU"
  779.   "fcmps %0,%1,%2"
  780.   [(set_attr "type" "fpcmp")])
  781.  
  782. (define_insn ""
  783.   [(set (match_operand:CCFP 0 "ccfp_reg_operand" "=c")
  784.     (compare:CCFP (match_operand:DF 1 "register_operand" "f")
  785.               (match_operand:DF 2 "register_operand" "f")))]
  786.   "TARGET_V9 && TARGET_FPU"
  787.   "fcmpd %0,%1,%2"
  788.   [(set_attr "type" "fpcmp")])
  789.  
  790. (define_insn ""
  791.   [(set (match_operand:CCFP 0 "ccfp_reg_operand" "=c")
  792.     (compare:CCFP (match_operand:TF 1 "register_operand" "f")
  793.               (match_operand:TF 2 "register_operand" "f")))]
  794.   "TARGET_V9 && TARGET_FPU && TARGET_HARD_QUAD"
  795.   "fcmpq %0,%1,%2"
  796.   [(set_attr "type" "fpcmp")])
  797.  
  798. ;; The SEQ and SNE patterns are special because they can be done
  799. ;; without any branching and do not involve a COMPARE.
  800.  
  801. (define_insn ""
  802.   [(set (match_operand:SI 0 "register_operand" "=r")
  803.     (ne:SI (match_operand:SI 1 "register_operand" "r")
  804.            (const_int 0)))
  805.    (clobber (reg:CC 0))]
  806.   ""
  807.   "subcc %%g0,%1,%%g0\;addx %%g0,0,%0"
  808.   [(set_attr "type" "unary")
  809.    (set_attr "length" "2")])
  810.  
  811. (define_insn ""
  812.   [(set (match_operand:SI 0 "register_operand" "=r")
  813.     (neg:SI (ne:SI (match_operand:SI 1 "register_operand" "r")
  814.                (const_int 0))))
  815.    (clobber (reg:CC 0))]
  816.   ""
  817.   "subcc %%g0,%1,%%g0\;subx %%g0,0,%0"
  818.   [(set_attr "type" "unary")
  819.    (set_attr "length" "2")])
  820.  
  821. (define_insn ""
  822.   [(set (match_operand:DI 0 "register_operand" "=r")
  823.     (ne:DI (match_operand:DI 1 "register_operand" "r")
  824.            (const_int 0)))
  825.    (clobber (reg:CCX 0))]
  826.   "TARGET_V9"
  827.   "mov 0,%0\;movrnz %1,1,%0"
  828.   [(set_attr "type" "unary")
  829.    (set_attr "length" "2")])
  830.  
  831. (define_insn ""
  832.   [(set (match_operand:DI 0 "register_operand" "=r")
  833.     (neg:DI (ne:DI (match_operand:DI 1 "register_operand" "r")
  834.                (const_int 0))))
  835.    (clobber (reg:CCX 0))]
  836.   "TARGET_V9"
  837.   "mov 0,%0\;movrnz %1,-1,%0"
  838.   [(set_attr "type" "unary")
  839.    (set_attr "length" "2")])
  840.  
  841. (define_insn ""
  842.   [(set (match_operand:SI 0 "register_operand" "=r")
  843.     (eq:SI (match_operand:SI 1 "register_operand" "r")
  844.            (const_int 0)))
  845.    (clobber (reg:CC 0))]
  846.   ""
  847.   "subcc %%g0,%1,%%g0\;subx %%g0,-1,%0"
  848.   [(set_attr "type" "unary")
  849.    (set_attr "length" "2")])
  850.  
  851. (define_insn ""
  852.   [(set (match_operand:SI 0 "register_operand" "=r")
  853.     (neg:SI (eq:SI (match_operand:SI 1 "register_operand" "r")
  854.                (const_int 0))))
  855.    (clobber (reg:CC 0))]
  856.   ""
  857.   "subcc %%g0,%1,%%g0\;addx %%g0,-1,%0"
  858.   [(set_attr "type" "unary")
  859.    (set_attr "length" "2")])
  860.  
  861. (define_insn ""
  862.   [(set (match_operand:DI 0 "register_operand" "=r")
  863.     (eq:DI (match_operand:DI 1 "register_operand" "r")
  864.            (const_int 0)))
  865.    (clobber (reg:CCX 0))]
  866.   "TARGET_V9"
  867.   "mov 0,%0\;movrz %1,1,%0"
  868.   [(set_attr "type" "unary")
  869.    (set_attr "length" "2")])
  870.  
  871. (define_insn ""
  872.   [(set (match_operand:DI 0 "register_operand" "=r")
  873.     (neg:DI (eq:DI (match_operand:DI 1 "register_operand" "r")
  874.                (const_int 0))))
  875.    (clobber (reg:CCX 0))]
  876.   "TARGET_V9"
  877.   "mov 0,%0\;movrz %1,-1,%0"
  878.   [(set_attr "type" "unary")
  879.    (set_attr "length" "2")]) 
  880.  
  881. ;; We can also do (x + (i == 0)) and related, so put them in.
  882. ;; ??? The addx/subx insns use the 32 bit carry flag so there are no DImode
  883. ;; versions for v9.
  884.  
  885. (define_insn ""
  886.   [(set (match_operand:SI 0 "register_operand" "=r")
  887.     (plus:SI (ne:SI (match_operand:SI 1 "register_operand" "r")
  888.             (const_int 0))
  889.          (match_operand:SI 2 "register_operand" "r")))
  890.    (clobber (reg:CC 0))]
  891.   ""
  892.   "subcc %%g0,%1,%%g0\;addx %2,0,%0"
  893.   [(set_attr "length" "2")])
  894.  
  895. (define_insn ""
  896.   [(set (match_operand:SI 0 "register_operand" "=r")
  897.     (minus:SI (match_operand:SI 2 "register_operand" "r")
  898.           (ne:SI (match_operand:SI 1 "register_operand" "r")
  899.              (const_int 0))))
  900.    (clobber (reg:CC 0))]
  901.   ""
  902.   "subcc %%g0,%1,%%g0\;subx %2,0,%0"
  903.   [(set_attr "length" "2")])
  904.  
  905. (define_insn ""
  906.   [(set (match_operand:SI 0 "register_operand" "=r")
  907.     (plus:SI (eq:SI (match_operand:SI 1 "register_operand" "r")
  908.             (const_int 0))
  909.          (match_operand:SI 2 "register_operand" "r")))
  910.    (clobber (reg:CC 0))]
  911.   ""
  912.   "subcc %%g0,%1,%%g0\;subx %2,-1,%0"
  913.   [(set_attr "length" "2")])
  914.  
  915. (define_insn ""
  916.   [(set (match_operand:SI 0 "register_operand" "=r")
  917.     (minus:SI (match_operand:SI 2 "register_operand" "r")
  918.           (eq:SI (match_operand:SI 1 "register_operand" "r")
  919.              (const_int 0))))
  920.    (clobber (reg:CC 0))]
  921.   ""
  922.   "subcc %%g0,%1,%%g0\;addx %2,-1,%0"
  923.   [(set_attr "length" "2")])
  924.  
  925. ;; We can also do GEU and LTU directly, but these operate after a compare.
  926. ;; ??? The addx/subx insns use the 32 bit carry flag so there are no DImode
  927. ;; versions for v9.
  928.  
  929. (define_insn ""
  930.   [(set (match_operand:SI 0 "register_operand" "=r")
  931.     (ltu:SI (reg:CC 0) (const_int 0)))]
  932.   ""
  933.   "addx %%g0,0,%0"
  934.   [(set_attr "type" "misc")])
  935.  
  936. (define_insn ""
  937.   [(set (match_operand:SI 0 "register_operand" "=r")
  938.     (neg:SI (ltu:SI (reg:CC 0) (const_int 0))))]
  939.   ""
  940.   "subx %%g0,0,%0"
  941.   [(set_attr "type" "misc")])
  942.  
  943. ;; ??? Combine should canonicalize these next two to the same pattern.
  944. (define_insn ""
  945.   [(set (match_operand:SI 0 "register_operand" "=r")
  946.     (minus:SI (neg:SI (ltu:SI (reg:CC 0) (const_int 0)))
  947.           (match_operand:SI 1 "arith_operand" "rI")))]
  948.   ""
  949.   "subx %%g0,%1,%0"
  950.   [(set_attr "type" "unary")])
  951.  
  952. (define_insn ""
  953.   [(set (match_operand:SI 0 "register_operand" "=r")
  954.     (neg:SI (plus:SI (ltu:SI (reg:CC 0) (const_int 0))
  955.              (match_operand:SI 1 "arith_operand" "rI"))))]
  956.   ""
  957.   "subx %%g0,%1,%0"
  958.   [(set_attr "type" "unary")])
  959.  
  960. (define_insn ""
  961.   [(set (match_operand:SI 0 "register_operand" "=r")
  962.     (geu:SI (reg:CC 0) (const_int 0)))]
  963.   ""
  964.   "subx %%g0,-1,%0"
  965.   [(set_attr "type" "misc")])
  966.  
  967. (define_insn ""
  968.   [(set (match_operand:SI 0 "register_operand" "=r")
  969.     (neg:SI (geu:SI (reg:CC 0) (const_int 0))))]
  970.   ""
  971.   "addx %%g0,-1,%0"
  972.   [(set_attr "type" "misc")])
  973.  
  974. ;; We can also do (x + ((unsigned) i >= 0)) and related, so put them in.
  975. ;; ??? The addx/subx insns use the 32 bit carry flag so there are no DImode
  976. ;; versions for v9.
  977.  
  978. (define_insn ""
  979.   [(set (match_operand:SI 0 "register_operand" "=r")
  980.     (plus:SI (ltu:SI (reg:CC 0) (const_int 0))
  981.          (match_operand:SI 1 "arith_operand" "rI")))]
  982.   ""
  983.   "addx %%g0,%1,%0"
  984.   [(set_attr "type" "unary")])
  985.  
  986. (define_insn ""
  987.   [(set (match_operand:SI 0 "register_operand" "=r")
  988.     (plus:SI (ltu:SI (reg:CC 0) (const_int 0))
  989.          (plus:SI (match_operand:SI 1 "arith_operand" "%r")
  990.               (match_operand:SI 2 "arith_operand" "rI"))))]
  991.   ""
  992.   "addx %1,%2,%0")
  993.  
  994. (define_insn ""
  995.   [(set (match_operand:SI 0 "register_operand" "=r")
  996.     (minus:SI (match_operand:SI 1 "register_operand" "r")
  997.           (ltu:SI (reg:CC 0) (const_int 0))))]
  998.   ""
  999.   "subx %1,0,%0"
  1000.   [(set_attr "type" "unary")])
  1001.  
  1002. ;; ??? Combine should canonicalize these next two to the same pattern.
  1003. (define_insn ""
  1004.   [(set (match_operand:SI 0 "register_operand" "=r")
  1005.     (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
  1006.                 (match_operand:SI 2 "arith_operand" "rI"))
  1007.           (ltu:SI (reg:CC 0) (const_int 0))))]
  1008.   ""
  1009.   "subx %1,%2,%0")
  1010.  
  1011. (define_insn ""
  1012.   [(set (match_operand:SI 0 "register_operand" "=r")
  1013.     (minus:SI (match_operand:SI 1 "register_operand" "r")
  1014.           (plus:SI (ltu:SI (reg:CC 0) (const_int 0))
  1015.                (match_operand:SI 2 "arith_operand" "rI"))))]
  1016.   ""
  1017.   "subx %1,%2,%0")
  1018.  
  1019. (define_insn ""
  1020.   [(set (match_operand:SI 0 "register_operand" "=r")
  1021.     (plus:SI (geu:SI (reg:CC 0) (const_int 0))
  1022.          (match_operand:SI 1 "register_operand" "r")))]
  1023.   ""
  1024.   "subx %1,-1,%0"
  1025.   [(set_attr "type" "unary")])
  1026.  
  1027. (define_insn ""
  1028.   [(set (match_operand:SI 0 "register_operand" "=r")
  1029.     (minus:SI (match_operand:SI 1 "register_operand" "r")
  1030.           (geu:SI (reg:CC 0) (const_int 0))))]
  1031.   ""
  1032.   "addx %1,-1,%0"
  1033.   [(set_attr "type" "unary")])
  1034.  
  1035. ;; Now we have the generic scc insns.
  1036. ;; !v9: These will be done using a jump.
  1037. ;; v9: Use conditional moves which are defined elsewhere.
  1038. ;; We have to exclude the cases above, since we will not want combine to
  1039. ;; turn something that does not require a jump into something that does.
  1040.  
  1041. (define_insn ""
  1042.   [(set (match_operand:SI 0 "register_operand" "=r")
  1043.     (match_operator:SI 1 "noov_compare_op" [(reg 0) (const_int 0)]))]
  1044.   ""
  1045.   "* return output_scc_insn (operands, insn); "
  1046.   [(set_attr "type" "multi")
  1047.    (set_attr "length" "3")])
  1048.  
  1049. (define_insn ""
  1050.   [(set (match_operand:DI 0 "register_operand" "=r")
  1051.     (match_operator:DI 1 "noov_compare_op" [(reg 0) (const_int 0)]))]
  1052.   "TARGET_V9"
  1053.   "* return output_scc_insn (operands, insn); "
  1054.   [(set_attr "type" "multi")
  1055.    (set_attr "length" "3")])
  1056.  
  1057. ;; These control RTL generation for conditional jump insns
  1058.  
  1059. ;; The quad-word fp compare library routines all return nonzero to indicate
  1060. ;; true, which is different from the equivalent libgcc routines, so we must
  1061. ;; handle them specially here.
  1062.  
  1063. (define_expand "beq"
  1064.   [(set (pc)
  1065.     (if_then_else (eq (match_dup 1) (const_int 0))
  1066.               (label_ref (match_operand 0 "" ""))
  1067.               (pc)))]
  1068.   ""
  1069.   "
  1070. {
  1071.   if (TARGET_V9 && sparc_compare_op1 == const0_rtx
  1072.       && GET_CODE (sparc_compare_op0) == REG
  1073.       && GET_MODE (sparc_compare_op0) == DImode)
  1074.     {
  1075.       emit_v9_brxx_insn (EQ, sparc_compare_op0, operands[0]);
  1076.       DONE;
  1077.     }
  1078.   else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
  1079.     {
  1080.       emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, EQ);
  1081.       emit_jump_insn (gen_bne (operands[0]));
  1082.       DONE;
  1083.     }      
  1084.   operands[1] = gen_compare_reg (EQ, sparc_compare_op0, sparc_compare_op1);
  1085. }")
  1086.  
  1087. (define_expand "bne"
  1088.   [(set (pc)
  1089.     (if_then_else (ne (match_dup 1) (const_int 0))
  1090.               (label_ref (match_operand 0 "" ""))
  1091.               (pc)))]
  1092.   ""
  1093.   "
  1094. {
  1095.   if (TARGET_V9 && sparc_compare_op1 == const0_rtx
  1096.       && GET_CODE (sparc_compare_op0) == REG
  1097.       && GET_MODE (sparc_compare_op0) == DImode)
  1098.     {
  1099.       emit_v9_brxx_insn (NE, sparc_compare_op0, operands[0]);
  1100.       DONE;
  1101.     }
  1102.   else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
  1103.     {
  1104.       emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, NE);
  1105.       emit_jump_insn (gen_bne (operands[0]));
  1106.       DONE;
  1107.     }      
  1108.   operands[1] = gen_compare_reg (NE, sparc_compare_op0, sparc_compare_op1);
  1109. }")
  1110.  
  1111. (define_expand "bgt"
  1112.   [(set (pc)
  1113.     (if_then_else (gt (match_dup 1) (const_int 0))
  1114.               (label_ref (match_operand 0 "" ""))
  1115.               (pc)))]
  1116.   ""
  1117.   "
  1118. {
  1119.   if (TARGET_V9 && sparc_compare_op1 == const0_rtx
  1120.       && GET_CODE (sparc_compare_op0) == REG
  1121.       && GET_MODE (sparc_compare_op0) == DImode)
  1122.     {
  1123.       emit_v9_brxx_insn (GT, sparc_compare_op0, operands[0]);
  1124.       DONE;
  1125.     }
  1126.   else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
  1127.     {
  1128.       emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, GT);
  1129.       emit_jump_insn (gen_bne (operands[0]));
  1130.       DONE;
  1131.     }      
  1132.   operands[1] = gen_compare_reg (GT, sparc_compare_op0, sparc_compare_op1);
  1133. }")
  1134.  
  1135. (define_expand "bgtu"
  1136.   [(set (pc)
  1137.     (if_then_else (gtu (match_dup 1) (const_int 0))
  1138.               (label_ref (match_operand 0 "" ""))
  1139.               (pc)))]
  1140.   ""
  1141.   "
  1142. { operands[1] = gen_compare_reg (GTU, sparc_compare_op0, sparc_compare_op1);
  1143. }")
  1144.  
  1145. (define_expand "blt"
  1146.   [(set (pc)
  1147.     (if_then_else (lt (match_dup 1) (const_int 0))
  1148.               (label_ref (match_operand 0 "" ""))
  1149.               (pc)))]
  1150.   ""
  1151.   "
  1152. {
  1153.   if (TARGET_V9 && sparc_compare_op1 == const0_rtx
  1154.       && GET_CODE (sparc_compare_op0) == REG
  1155.       && GET_MODE (sparc_compare_op0) == DImode)
  1156.     {
  1157.       emit_v9_brxx_insn (LT, sparc_compare_op0, operands[0]);
  1158.       DONE;
  1159.     }
  1160.   else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
  1161.     {
  1162.       emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, LT);
  1163.       emit_jump_insn (gen_bne (operands[0]));
  1164.       DONE;
  1165.     }      
  1166.   operands[1] = gen_compare_reg (LT, sparc_compare_op0, sparc_compare_op1);
  1167. }")
  1168.  
  1169. (define_expand "bltu"
  1170.   [(set (pc)
  1171.     (if_then_else (ltu (match_dup 1) (const_int 0))
  1172.               (label_ref (match_operand 0 "" ""))
  1173.               (pc)))]
  1174.   ""
  1175.   "
  1176. { operands[1] = gen_compare_reg (LTU, sparc_compare_op0, sparc_compare_op1);
  1177. }")
  1178.  
  1179. (define_expand "bge"
  1180.   [(set (pc)
  1181.     (if_then_else (ge (match_dup 1) (const_int 0))
  1182.               (label_ref (match_operand 0 "" ""))
  1183.               (pc)))]
  1184.   ""
  1185.   "
  1186. {
  1187.   if (TARGET_V9 && sparc_compare_op1 == const0_rtx
  1188.       && GET_CODE (sparc_compare_op0) == REG
  1189.       && GET_MODE (sparc_compare_op0) == DImode)
  1190.     {
  1191.       emit_v9_brxx_insn (GE, sparc_compare_op0, operands[0]);
  1192.       DONE;
  1193.     }
  1194.   else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
  1195.     {
  1196.       emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, GE);
  1197.       emit_jump_insn (gen_bne (operands[0]));
  1198.       DONE;
  1199.     }      
  1200.   operands[1] = gen_compare_reg (GE, sparc_compare_op0, sparc_compare_op1);
  1201. }")
  1202.  
  1203. (define_expand "bgeu"
  1204.   [(set (pc)
  1205.     (if_then_else (geu (match_dup 1) (const_int 0))
  1206.               (label_ref (match_operand 0 "" ""))
  1207.               (pc)))]
  1208.   ""
  1209.   "
  1210. { operands[1] = gen_compare_reg (GEU, sparc_compare_op0, sparc_compare_op1);
  1211. }")
  1212.  
  1213. (define_expand "ble"
  1214.   [(set (pc)
  1215.     (if_then_else (le (match_dup 1) (const_int 0))
  1216.               (label_ref (match_operand 0 "" ""))
  1217.               (pc)))]
  1218.   ""
  1219.   "
  1220. {
  1221.   if (TARGET_V9 && sparc_compare_op1 == const0_rtx
  1222.       && GET_CODE (sparc_compare_op0) == REG
  1223.       && GET_MODE (sparc_compare_op0) == DImode)
  1224.     {
  1225.       emit_v9_brxx_insn (LE, sparc_compare_op0, operands[0]);
  1226.       DONE;
  1227.     }
  1228.   else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
  1229.     {
  1230.       emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, LE);
  1231.       emit_jump_insn (gen_bne (operands[0]));
  1232.       DONE;
  1233.     }      
  1234.   operands[1] = gen_compare_reg (LE, sparc_compare_op0, sparc_compare_op1);
  1235. }")
  1236.  
  1237. (define_expand "bleu"
  1238.   [(set (pc)
  1239.     (if_then_else (leu (match_dup 1) (const_int 0))
  1240.               (label_ref (match_operand 0 "" ""))
  1241.               (pc)))]
  1242.   ""
  1243.   "
  1244. { operands[1] = gen_compare_reg (LEU, sparc_compare_op0, sparc_compare_op1);
  1245. }")
  1246.  
  1247. ;; Now match both normal and inverted jump.
  1248.  
  1249. (define_insn ""
  1250.   [(set (pc)
  1251.     (if_then_else (match_operator 0 "noov_compare_op"
  1252.                       [(reg 0) (const_int 0)])
  1253.               (label_ref (match_operand 1 "" ""))
  1254.               (pc)))]
  1255.   ""
  1256.   "*
  1257. {
  1258.   return output_cbranch (operands[0], 0, 1, 0,
  1259.              final_sequence && INSN_ANNULLED_BRANCH_P (insn),
  1260.              ! final_sequence);
  1261. }"
  1262.   [(set_attr "type" "branch")])
  1263.  
  1264. (define_insn ""
  1265.   [(set (pc)
  1266.     (if_then_else (match_operator 0 "noov_compare_op"
  1267.                       [(reg 0) (const_int 0)])
  1268.               (pc)
  1269.               (label_ref (match_operand 1 "" ""))))]
  1270.   ""
  1271.   "*
  1272. {
  1273.   return output_cbranch (operands[0], 0, 1, 1,
  1274.              final_sequence && INSN_ANNULLED_BRANCH_P (insn),
  1275.              ! final_sequence);
  1276. }"
  1277.   [(set_attr "type" "branch")])
  1278.  
  1279. (define_insn ""
  1280.   [(set (pc)
  1281.     (if_then_else (match_operator 0 "comparison_operator"
  1282.                       [(match_operand:CCFP 1 "ccfp_reg_operand" "c")
  1283.                        (const_int 0)])
  1284.               (label_ref (match_operand 2 "" ""))
  1285.               (pc)))]
  1286.   "TARGET_V9"
  1287.   "*
  1288. {
  1289.   return output_cbranch (operands[0], operands[1], 2, 0,
  1290.              final_sequence && INSN_ANNULLED_BRANCH_P (insn),
  1291.              ! final_sequence);
  1292. }"
  1293.   [(set_attr "type" "branch")])
  1294.  
  1295. (define_insn ""
  1296.   [(set (pc)
  1297.     (if_then_else (match_operator 0 "comparison_operator"
  1298.                       [(match_operand:CCFP 1 "ccfp_reg_operand" "c")
  1299.                        (const_int 0)])
  1300.               (pc)
  1301.               (label_ref (match_operand 2 "" ""))))]
  1302.   "TARGET_V9"
  1303.   "*
  1304. {
  1305.   return output_cbranch (operands[0], operands[1], 2, 1,
  1306.              final_sequence && INSN_ANNULLED_BRANCH_P (insn),
  1307.              ! final_sequence);
  1308. }"
  1309.   [(set_attr "type" "branch")])
  1310.  
  1311. (define_insn ""
  1312.   [(set (pc)
  1313.     (if_then_else (match_operator 0 "comparison_operator"
  1314.                       [(match_operand:CCFPE 1 "ccfp_reg_operand" "c")
  1315.                        (const_int 0)])
  1316.               (label_ref (match_operand 2 "" ""))
  1317.               (pc)))]
  1318.   "TARGET_V9"
  1319.   "*
  1320. {
  1321.   return output_cbranch (operands[0], operands[1], 2, 0,
  1322.              final_sequence && INSN_ANNULLED_BRANCH_P (insn),
  1323.              ! final_sequence);
  1324. }"
  1325.   [(set_attr "type" "branch")])
  1326.  
  1327. (define_insn ""
  1328.   [(set (pc)
  1329.     (if_then_else (match_operator 0 "comparison_operator"
  1330.                       [(match_operand:CCFPE 1 "ccfp_reg_operand" "c")
  1331.                        (const_int 0)])
  1332.               (pc)
  1333.               (label_ref (match_operand 2 "" ""))))]
  1334.   "TARGET_V9"
  1335.   "*
  1336. {
  1337.   return output_cbranch (operands[0], operands[1], 2, 1,
  1338.              final_sequence && INSN_ANNULLED_BRANCH_P (insn),
  1339.              ! final_sequence);
  1340. }"
  1341.   [(set_attr "type" "branch")])
  1342.  
  1343. ;; Sparc V9-specific jump insns.  None of these are guaranteed to be
  1344. ;; in the architecture.
  1345.  
  1346. ;; There are no 32 bit brreg insns.
  1347.  
  1348. (define_insn ""
  1349.   [(set (pc)
  1350.     (if_then_else (match_operator 0 "v9_regcmp_op"
  1351.                       [(match_operand:DI 1 "register_operand" "r")
  1352.                        (const_int 0)])
  1353.               (label_ref (match_operand 2 "" ""))
  1354.               (pc)))]
  1355.   "TARGET_V9"
  1356.   "*
  1357. {
  1358.   return output_v9branch (operands[0], 1, 2, 0,
  1359.               final_sequence && INSN_ANNULLED_BRANCH_P (insn),
  1360.               ! final_sequence);
  1361. }"
  1362.   [(set_attr "type" "branch")])
  1363.  
  1364. (define_insn ""
  1365.   [(set (pc)
  1366.     (if_then_else (match_operator 0 "v9_regcmp_op"
  1367.                       [(match_operand:DI 1 "register_operand" "r")
  1368.                        (const_int 0)])
  1369.               (pc)
  1370.               (label_ref (match_operand 2 "" ""))))]
  1371.   "TARGET_V9"
  1372.   "*
  1373. {
  1374.   return output_v9branch (operands[0], 1, 2, 1,
  1375.               final_sequence && INSN_ANNULLED_BRANCH_P (insn),
  1376.               ! final_sequence);
  1377. }"
  1378.   [(set_attr "type" "branch")])
  1379.  
  1380. ;; Esoteric move insns (lo_sum, high, pic).
  1381.  
  1382. (define_insn ""
  1383.   [(set (match_operand:SI 0 "register_operand" "=r")
  1384.     (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
  1385.            (match_operand:SI 2 "immediate_operand" "in")))]
  1386.   ""
  1387.   ;; V9 needs "add" because of the code models.  We still use "or" for v8
  1388.   ;; so we can compare the old compiler with the new.
  1389.   "* return TARGET_V9 ? \"add %1,%%lo(%a2),%0\" : \"or %1,%%lo(%a2),%0\";"
  1390.   ;; Need to set length for this arith insn because operand2
  1391.   ;; is not an "arith_operand".
  1392.   [(set_attr "length" "1")])
  1393.  
  1394. ;; For PIC, symbol_refs are put inside unspec so that the optimizer will not
  1395. ;; confuse them with real addresses.
  1396. (define_insn ""
  1397.   [(set (match_operand:SI 0 "register_operand" "=r")
  1398.     (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
  1399.            (unspec:SI [(match_operand:SI 2 "immediate_operand" "in")] 0)))]
  1400.   ""
  1401.   ;; V9 needs "add" because of the code models.  We still use "or" for v8
  1402.   ;; so we can compare the old compiler with the new.
  1403.   "* return TARGET_V9 ? \"add %1,%%lo(%a2),%0\" : \"or %1,%%lo(%a2),%0\";"
  1404.   ;; Need to set length for this arith insn because operand2
  1405.   ;; is not an "arith_operand".
  1406.   [(set_attr "length" "1")])
  1407.  
  1408. ;; For PIC, symbol_refs are put inside unspec so that the optimizer will not
  1409. ;; confuse them with real addresses.
  1410. (define_insn ""
  1411.   [(set (match_operand:SI 0 "register_operand" "=r")
  1412.     (high:SI (unspec:SI [(match_operand 1 "" "")] 0)))]
  1413.   "check_pic (1)"
  1414.   "sethi %%hi(%a1),%0"
  1415.   [(set_attr "type" "move")
  1416.    (set_attr "length" "1")])
  1417.  
  1418. (define_insn ""
  1419.   [(set (match_operand:SI 0 "register_operand" "=r")
  1420.     (high:SI (match_operand 1 "" "")))]
  1421.   "check_pic (1)"
  1422.   "sethi %%hi(%a1),%0"
  1423.   [(set_attr "type" "move")
  1424.    (set_attr "length" "1")])
  1425.  
  1426. (define_insn ""
  1427.   [(set (match_operand:HI 0 "register_operand" "=r")
  1428.     (high:HI (match_operand 1 "" "")))]
  1429.   "check_pic (1)"
  1430.   "sethi %%hi(%a1),%0"
  1431.   [(set_attr "type" "move")
  1432.    (set_attr "length" "1")])
  1433.  
  1434. ;; Special pic pattern, for loading the address of a label into a register.
  1435. ;; It clobbers o7 because the call puts the return address (i.e. pc value)
  1436. ;; there.
  1437.  
  1438. (define_insn ""
  1439.   [(set (match_operand:SI 0 "register_operand" "=r")
  1440.     (match_operand:SI 1 "move_pic_label" "i"))
  1441.    (set (reg:SI 15) (pc))]
  1442.   ""
  1443.   "\\n1:\;call 2f\;sethi %%hi(%l1-1b),%0\\n2:\\tor %0,%%lo(%l1-1b),%0\;add %0,%%o7,%0"
  1444.   [(set_attr "type" "multi")
  1445.    (set_attr "length" "4")])
  1446.  
  1447. ;; v9 special pic pattern, for loading the address of a label into a register.
  1448.  
  1449. (define_insn ""
  1450.   [(set (match_operand:DI 0 "register_operand" "=r")
  1451.     (match_operand:DI 1 "move_pic_label" "i"))
  1452.    (set (reg:DI 15) (pc))]
  1453.   "TARGET_V9"
  1454.   "\\n1:\;call 2f\;sethi %%hi(%l1-1b),%0\\n2:\\tor %0,%%lo(%l1-1b),%0\;add %0,%%o7,%0"
  1455.   [(set_attr "type" "multi")
  1456.    (set_attr "length" "4")])
  1457.  
  1458. (define_insn ""
  1459.   [(set (match_operand:DI 0 "register_operand" "=r")
  1460.     (lo_sum:DI (match_operand:DI 1 "register_operand" "0")
  1461.            (match_operand:DI 2 "immediate_operand" "in")))]
  1462.   "! TARGET_V9"
  1463.   "*
  1464. {
  1465.   /* Don't output a 64 bit constant, since we can't trust the assembler to
  1466.      handle it correctly.  */
  1467.   if (GET_CODE (operands[2]) == CONST_DOUBLE)
  1468.     operands[2] = gen_rtx (CONST_INT, VOIDmode, CONST_DOUBLE_LOW (operands[2]));
  1469.   return \"or %R1,%%lo(%a2),%R0\";
  1470. }"
  1471.   ;; Need to set length for this arith insn because operand2
  1472.   ;; is not an "arith_operand".
  1473.   [(set_attr "length" "1")])
  1474.  
  1475. ;; ??? Gas does not handle %lo(DI), so we use the same code for ! TARGET_V9.
  1476. ;; ??? The previous comment is obsolete.
  1477. ;; ??? Optimizer does not handle "or %o1,%lo(0),%o1". How about add?
  1478.  
  1479. (define_insn ""
  1480.   [(set (match_operand:DI 0 "register_operand" "=r")
  1481.     (lo_sum:DI (match_operand:DI 1 "register_operand" "0")
  1482.            (match_operand:DI 2 "immediate_operand" "in")))]
  1483.   "TARGET_V9"
  1484.   "*
  1485. {
  1486.   /* Don't output a 64 bit constant, since we can't trust the assembler to
  1487.      handle it correctly.  */
  1488.   if (GET_CODE (operands[2]) == CONST_DOUBLE)
  1489.     operands[2] = gen_rtx (CONST_INT, VOIDmode, CONST_DOUBLE_LOW (operands[2]));
  1490.   /* Note that we use add here.  This is important because Medium/Anywhere
  1491.      code model support depends on it.  */
  1492.   return \"add %1,%%lo(%a2),%0\";
  1493. }"
  1494.   ;; Need to set length for this arith insn because operand2
  1495.   ;; is not an "arith_operand".
  1496.   [(set_attr "length" "1")])
  1497.  
  1498. (define_insn ""
  1499.   [(set (match_operand:DI 0 "register_operand" "=r")
  1500.     (high:DI (match_operand 1 "" "")))]
  1501.   "! TARGET_V9 && check_pic (1)"
  1502.   "*
  1503. {
  1504.   rtx op0 = operands[0];
  1505.   rtx op1 = operands[1];
  1506.  
  1507.   if (GET_CODE (op1) == CONST_INT)
  1508.     {
  1509.       operands[0] = operand_subword (op0, 1, 0, DImode);
  1510.       output_asm_insn (\"sethi %%hi(%a1),%0\", operands);
  1511.  
  1512.       operands[0] = operand_subword (op0, 0, 0, DImode);
  1513.       if (INTVAL (op1) < 0)
  1514.     return \"mov -1,%0\";
  1515.       else
  1516.     return \"mov 0,%0\";
  1517.     }
  1518.   else if (GET_CODE (op1) == CONST_DOUBLE)
  1519.     {
  1520.       operands[0] = operand_subword (op0, 1, 0, DImode);
  1521.       operands[1] = gen_rtx (CONST_INT, VOIDmode, CONST_DOUBLE_LOW (op1));
  1522.       output_asm_insn (\"sethi %%hi(%a1),%0\", operands);
  1523.  
  1524.       operands[0] = operand_subword (op0, 0, 0, DImode);
  1525.       operands[1] = gen_rtx (CONST_INT, VOIDmode, CONST_DOUBLE_HIGH (op1));
  1526.       return singlemove_string (operands);
  1527.     }
  1528.   else
  1529.     abort ();
  1530.   return \"\";
  1531. }"
  1532.   [(set_attr "type" "move")
  1533.    (set_attr "length" "2")])
  1534.  
  1535. ;;; ??? This pattern originally clobbered a scratch register.  However, this
  1536. ;;; is illegal, the movdi pattern may not use a temp register because it
  1537. ;;; may be called from reload to reload a DImode value.  In that case, we
  1538. ;;; end up with a scratch register that never gets allocated.  To avoid this,
  1539. ;;; we use global register 1 which is never otherwise used by gcc as a temp.
  1540. ;;; The correct solution here might be to force DImode constants to memory,
  1541. ;;; e.g. by using a toc like the romp and rs6000 ports do for addresses, reg
  1542. ;;; 1 will then no longer need to be considered a fixed reg.
  1543.  
  1544. ;;; Gas doesn't have any 64 bit constant support, so don't use %uhi and %ulo
  1545. ;;; on constants.  Symbols have to be handled by the linker, so we must use
  1546. ;;; %uhi and %ulo for them, but gas will handle these correctly.
  1547. ;;; ??? This comment is obsolete, gas handles them now.
  1548.  
  1549. (define_insn ""
  1550.   [(set (match_operand:DI 0 "register_operand" "=r")
  1551.     (high:DI (match_operand 1 "const_double_operand" "")))
  1552.    (clobber (reg:DI 1))]
  1553.   "TARGET_V9 && check_pic (1)"
  1554.   "*
  1555. {
  1556.   rtx high, low;
  1557.   
  1558.   split_double (operands[1], &high, &low);
  1559.  
  1560.   if (high == const0_rtx)
  1561.     {
  1562.       operands[1] = low;
  1563.       output_asm_insn (\"sethi %%hi(%a1),%0\", operands);
  1564.     }
  1565.   else
  1566.     {
  1567.       operands[1] = high;
  1568.       output_asm_insn (singlemove_string (operands), operands);
  1569.  
  1570.       operands[1] = low;
  1571.       output_asm_insn (\"sllx %0,32,%0\", operands);
  1572.       if (low != const0_rtx)
  1573.     output_asm_insn (\"sethi %%hi(%a1),%%g1; or %0,%%g1,%0\", operands);
  1574.     }
  1575. }"
  1576.   [(set_attr "type" "move")
  1577.    (set_attr "length" "5")])
  1578.  
  1579. ;; Most of the required support for the various code models is here.
  1580. ;; We can do this because sparcs need the high insn to load the address.  We
  1581. ;; just need to get high to do the right thing for each code model.  Then each
  1582. ;; uses the same "%X+%lo(...)" in the load/store insn.
  1583.  
  1584. ;; When TARGET_MEDLOW, assume that the upper 32 bits of symbol addresses are
  1585. ;; always 0.
  1586. ;; When TARGET_MEDANY, the upper 32 bits of function addresses are 0.
  1587. ;; The data segment has a maximum size of 32 bits, but may be located anywhere.
  1588. ;; MEDANY_BASE_REG contains the start address, currently %g4.
  1589. ;; When TARGET_FULLANY, symbolic addresses are 64 bits.
  1590.  
  1591. (define_insn ""
  1592.   [(set (match_operand:DI 0 "register_operand" "=r")
  1593.     (high:DI (match_operand 1 "" "")))
  1594. ;; ??? Why the clobber?
  1595.    (clobber (reg:DI 1))]
  1596.   "TARGET_MEDLOW && check_pic (1)"
  1597.   "sethi %%hi(%a1),%0"
  1598.   [(set_attr "type" "move")
  1599.    (set_attr "length" "1")])
  1600.  
  1601. ;; WARNING: %0 gets %hi(%1)+%g4.
  1602. ;;          You cannot OR in %lo(%1), it must be added in.
  1603.  
  1604. (define_insn ""
  1605.   [(set (match_operand:DI 0 "register_operand" "=r")
  1606.     (high:DI (match_operand 1 "data_segment_operand" "")))
  1607. ;; ??? Why the clobber?
  1608.    (clobber (reg:DI 1))]
  1609.   "TARGET_MEDANY && check_pic (1)"
  1610.   "sethi %%hi(%a1),%0; add %0,%%g4,%0"
  1611.   [(set_attr "type" "move")
  1612.    (set_attr "length" "2")])
  1613.  
  1614. (define_insn ""
  1615.   [(set (match_operand:DI 0 "register_operand" "=r")
  1616.     (high:DI (match_operand 1 "text_segment_operand" "")))
  1617. ;; ??? Why the clobber?
  1618.    (clobber (reg:DI 1))]
  1619.   "TARGET_MEDANY && check_pic (1)"
  1620.   "sethi %%hi(%a1),%0"
  1621.   [(set_attr "type" "move")
  1622.    (set_attr "length" "1")])
  1623.  
  1624. (define_insn ""
  1625.   [(set (match_operand:DI 0 "register_operand" "=r")
  1626.     (high:DI (match_operand 1 "" "")))
  1627.    (clobber (reg:DI 1))]
  1628.   "TARGET_FULLANY && check_pic (1)"
  1629.   "sethi %%uhi(%a1),%%g1; or %%g1,%%ulo(%a1),%%g1; sllx %%g1,32,%%g1; sethi %%hi(%a1),%0; or %0,%%g1,%0"
  1630.   [(set_attr "type" "move")
  1631.    (set_attr "length" "5")])
  1632.  
  1633. ;; Move instructions
  1634.  
  1635. (define_expand "movqi"
  1636.   [(set (match_operand:QI 0 "general_operand" "")
  1637.     (match_operand:QI 1 "general_operand" ""))]
  1638.   ""
  1639.   "
  1640. {
  1641.   if (emit_move_sequence (operands, QImode))
  1642.     DONE;
  1643. }")
  1644.  
  1645. (define_insn ""
  1646.   [(set (match_operand:QI 0 "reg_or_nonsymb_mem_operand" "=r,r,r,Q")
  1647.     (match_operand:QI 1 "move_operand" "rI,K,Q,rJ"))]
  1648.   "register_operand (operands[0], QImode)
  1649.    || register_operand (operands[1], QImode)
  1650.    || operands[1] == const0_rtx"
  1651.   "@
  1652.    mov %1,%0
  1653.    sethi %%hi(%a1),%0
  1654.    ldub %1,%0
  1655.    stb %r1,%0"
  1656.   [(set_attr "type" "move,move,load,store")
  1657.    (set_attr "length" "*,1,*,1")])
  1658.  
  1659. (define_insn ""
  1660.   [(set (match_operand:QI 0 "register_operand" "=r")
  1661.     (subreg:QI (lo_sum:SI (match_operand:QI 1 "register_operand" "r")
  1662.                   (match_operand 2 "immediate_operand" "in")) 0))]
  1663.   ""
  1664.   "or %1,%%lo(%a2),%0"
  1665.   [(set_attr "length" "1")])
  1666.  
  1667. (define_insn ""
  1668.   [(set (mem:QI (match_operand:SI 0 "symbolic_operand" ""))
  1669.     (match_operand:QI 1 "reg_or_0_operand" "rJ"))
  1670.    (clobber (match_scratch:SI 2 "=&r"))]
  1671.   "(reload_completed || reload_in_progress) && ! TARGET_PTR64"
  1672.   "sethi %%hi(%a0),%2\;stb %r1,[%2+%%lo(%a0)]"
  1673.   [(set_attr "type" "store")
  1674.    (set_attr "length" "2")])
  1675.  
  1676. (define_expand "movhi"
  1677.   [(set (match_operand:HI 0 "general_operand" "")
  1678.     (match_operand:HI 1 "general_operand" ""))]
  1679.   ""
  1680.   "
  1681. {
  1682.   if (emit_move_sequence (operands, HImode))
  1683.     DONE;
  1684. }")
  1685.  
  1686. (define_insn ""
  1687.   [(set (match_operand:HI 0 "reg_or_nonsymb_mem_operand" "=r,r,r,Q")
  1688.     (match_operand:HI 1 "move_operand" "rI,K,Q,rJ"))]
  1689.   "register_operand (operands[0], HImode)
  1690.    || register_operand (operands[1], HImode)
  1691.    || operands[1] == const0_rtx"
  1692.   "@
  1693.    mov %1,%0
  1694.    sethi %%hi(%a1),%0
  1695.    lduh %1,%0
  1696.    sth %r1,%0"
  1697.   [(set_attr "type" "move,move,load,store")
  1698.    (set_attr "length" "*,1,*,1")])
  1699.  
  1700. (define_insn ""
  1701.   [(set (match_operand:HI 0 "register_operand" "=r")
  1702.     (lo_sum:HI (match_operand:HI 1 "register_operand" "r")
  1703.            (match_operand 2 "immediate_operand" "in")))]
  1704.   ""
  1705.   "or %1,%%lo(%a2),%0"
  1706.   [(set_attr "length" "1")])
  1707.  
  1708. (define_insn ""
  1709.   [(set (mem:HI (match_operand:SI 0 "symbolic_operand" ""))
  1710.     (match_operand:HI 1 "reg_or_0_operand" "rJ"))
  1711.    (clobber (match_scratch:SI 2 "=&r"))]
  1712.   "(reload_completed || reload_in_progress) && ! TARGET_PTR64"
  1713.   "sethi %%hi(%a0),%2\;sth %r1,[%2+%%lo(%a0)]"
  1714.   [(set_attr "type" "store")
  1715.    (set_attr "length" "2")])
  1716.  
  1717. (define_expand "movsi"
  1718.   [(set (match_operand:SI 0 "general_operand" "")
  1719.     (match_operand:SI 1 "general_operand" ""))]
  1720.   ""
  1721.   "
  1722. {
  1723.   if (emit_move_sequence (operands, SImode))
  1724.     DONE;
  1725. }")
  1726.  
  1727. ;; We must support both 'r' and 'f' registers here, because combine may
  1728. ;; convert SFmode hard registers to SImode hard registers when simplifying
  1729. ;; subreg sets.
  1730.  
  1731. ;; We cannot combine the similar 'r' and 'f' constraints, because it causes
  1732. ;; problems with register allocation.  Reload might try to put an integer
  1733. ;; in an fp register, or an fp number is an integer register.
  1734.  
  1735. (define_insn ""
  1736.   [(set (match_operand:SI 0 "reg_or_nonsymb_mem_operand" "=r,f,r,r,f,Q,Q")
  1737.     (match_operand:SI 1 "move_operand" "rI,!f,K,Q,!Q,rJ,!f"))]
  1738.   "register_operand (operands[0], SImode)
  1739.    || register_operand (operands[1], SImode)
  1740.    || operands[1] == const0_rtx"
  1741.   "@
  1742.    mov %1,%0
  1743.    fmovs %1,%0
  1744.    sethi %%hi(%a1),%0
  1745.    ld %1,%0
  1746.    ld %1,%0
  1747.    st %r1,%0
  1748.    st %r1,%0"
  1749.   [(set_attr "type" "move,fp,move,load,load,store,store")
  1750.    (set_attr "length" "*,*,1,*,*,*,*")])
  1751.  
  1752. (define_insn ""
  1753.   [(set (mem:SI (match_operand:SI 0 "symbolic_operand" ""))
  1754.     (match_operand:SI 1 "reg_or_0_operand" "rJ"))
  1755.    (clobber (match_scratch:SI 2 "=&r"))]
  1756.   "(reload_completed || reload_in_progress) && ! TARGET_PTR64"
  1757.   "sethi %%hi(%a0),%2\;st %r1,[%2+%%lo(%a0)]"
  1758.   [(set_attr "type" "store")
  1759.    (set_attr "length" "2")])
  1760.  
  1761. (define_expand "movdi"
  1762.   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand" "")
  1763.     (match_operand:DI 1 "general_operand" ""))]
  1764.   ""
  1765.   "
  1766. {
  1767.   if (emit_move_sequence (operands, DImode))
  1768.     DONE;
  1769. }")
  1770.  
  1771. (define_insn ""
  1772.   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand" "=r,T,U,Q,r,r,?f,?f,?Q")
  1773.     (match_operand:DI 1 "general_operand" "r,U,T,r,Q,i,f,Q,f"))]
  1774.   "! TARGET_V9
  1775.    && (register_operand (operands[0], DImode)
  1776.        || register_operand (operands[1], DImode)
  1777.        || operands[1] == const0_rtx)"
  1778.   "*
  1779. {
  1780.   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1]))
  1781.     return output_fp_move_double (operands);
  1782.   return output_move_double (operands);
  1783. }"
  1784.   [(set_attr "type" "move,store,load,store,load,multi,fp,fpload,fpstore")
  1785.    (set_attr "length" "2,1,1,3,3,3,2,3,3")])
  1786.  
  1787. ;;; ??? The trick used below can be extended to load any negative 32 bit
  1788. ;;; constant in two instructions.  Currently the compiler will use HIGH/LO_SUM
  1789. ;;; for anything not matching the HIK constraints, which results in 5
  1790. ;;; instructions.  Positive 32 bit constants can be loaded in the obvious way
  1791. ;;; with sethi/ori.  To extend the trick, in the xor instruction, use 
  1792. ;;; xor %o0, ((op1 & 0x3ff) | -0x400), %o0
  1793. ;;; This needs the original value of operands[1], not the inverted value.
  1794.  
  1795. (define_insn ""
  1796.   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand" "=r,r,r,Q,?f,?f,?Q")
  1797.     (match_operand:DI 1 "move_operand" "rI,K,Q,rJ,f,Q,f"))]
  1798.   "TARGET_V9
  1799.    && (register_operand (operands[0], DImode)
  1800.        || register_operand (operands[1], DImode)
  1801.        || operands[1] == const0_rtx)"
  1802.   "*
  1803. {
  1804.   switch (which_alternative)
  1805.     {
  1806.     case 0:
  1807.       return \"mov %1,%0\";
  1808.     case 1:
  1809.       /* Sethi does not sign extend, so we must use a little trickery
  1810.      to use it for negative numbers.  Invert the constant before
  1811.      loading it in, then use a xor immediate to invert the loaded bits
  1812.      (along with the upper 32 bits) to the desired constant.  This
  1813.      works because the sethi and immediate fields overlap.  */
  1814.  
  1815.       if ((INTVAL (operands[1]) & 0x80000000) == 0)
  1816.     return \"sethi %%hi(%a1),%0\";
  1817.       else
  1818.     {
  1819.       operands[1] = gen_rtx (CONST_INT, VOIDmode,
  1820.                  ~ INTVAL (operands[1]));
  1821.       output_asm_insn (\"sethi %%hi(%a1),%0\", operands);
  1822.       /* The low 10 bits are already zero, but invert the rest.
  1823.          Assemblers don't accept 0x1c00, so use -0x400 instead.  */
  1824.       return \"xor %0,-0x400,%0\";
  1825.     }
  1826.     case 2:
  1827.       return \"ldx %1,%0\";
  1828.     case 3:
  1829.       return \"stx %r1,%0\";
  1830.     case 4:
  1831.       return \"mov %1,%0\";
  1832.     case 5:
  1833.       return \"ldd %1,%0\";
  1834.     case 6:
  1835.       return \"std %1,%0\";
  1836.     }
  1837. }"
  1838.   [(set_attr "type" "move,move,load,store,fp,fpload,fpstore")
  1839.    (set_attr "length" "1,2,1,1,1,1,1")])
  1840.  
  1841. ;; ??? There's no symbolic (set (mem:DI ...) ...).
  1842. ;; Experimentation with v9 suggested one isn't needed.
  1843.  
  1844. ;; Block move insns.
  1845.  
  1846. ;; ??? We get better code without it.  See output_block_move in sparc.c.
  1847.  
  1848. ;; The definition of this insn does not really explain what it does,
  1849. ;; but it should suffice
  1850. ;; that anything generated as this insn will be recognized as one
  1851. ;; and that it will not successfully combine with anything.
  1852. ;(define_expand "movstrsi"
  1853. ;  [(parallel [(set (mem:BLK (match_operand:BLK 0 "general_operand" ""))
  1854. ;           (mem:BLK (match_operand:BLK 1 "general_operand" "")))
  1855. ;          (use (match_operand:SI 2 "nonmemory_operand" ""))
  1856. ;          (use (match_operand:SI 3 "immediate_operand" ""))
  1857. ;          (clobber (match_dup 0))
  1858. ;          (clobber (match_dup 1))
  1859. ;          (clobber (match_scratch:SI 4 ""))
  1860. ;          (clobber (reg:SI 0))
  1861. ;          (clobber (reg:SI 1))])]
  1862. ;  ""
  1863. ;  "
  1864. ;{
  1865. ;  /* If the size isn't known, don't emit inline code.  output_block_move
  1866. ;     would output code that's much slower than the library function.
  1867. ;     Also don't output code for large blocks.  */
  1868. ;  if (GET_CODE (operands[2]) != CONST_INT
  1869. ;      || GET_CODE (operands[3]) != CONST_INT
  1870. ;      || INTVAL (operands[2]) / INTVAL (operands[3]) > 16)
  1871. ;    FAIL;
  1872. ;
  1873. ;  operands[0] = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
  1874. ;  operands[1] = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
  1875. ;  operands[2] = force_not_mem (operands[2]);
  1876. ;}")
  1877.  
  1878. ;(define_insn ""
  1879. ;  [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r"))
  1880. ;    (mem:BLK (match_operand:SI 1 "register_operand" "+r")))
  1881. ;   (use (match_operand:SI 2 "nonmemory_operand" "rn"))
  1882. ;   (use (match_operand:SI 3 "immediate_operand" "i"))
  1883. ;   (clobber (match_dup 0))
  1884. ;   (clobber (match_dup 1))
  1885. ;   (clobber (match_scratch:SI 4 "=&r"))
  1886. ;   (clobber (reg:SI 0))
  1887. ;   (clobber (reg:SI 1))]
  1888. ;  ""
  1889. ;  "* return output_block_move (operands);"
  1890. ;  [(set_attr "type" "multi")
  1891. ;   (set_attr "length" "6")])
  1892.  
  1893. ;; Floating point move insns
  1894.  
  1895. ;; This pattern forces (set (reg:SF ...) (const_double ...))
  1896. ;; to be reloaded by putting the constant into memory.
  1897. ;; It must come before the more general movsf pattern.
  1898. (define_insn ""
  1899.   [(set (match_operand:SF 0 "general_operand" "=?r,f,m")
  1900.     (match_operand:SF 1 "" "?E,m,G"))]
  1901.   "TARGET_FPU && GET_CODE (operands[1]) == CONST_DOUBLE"
  1902.   "*
  1903. {
  1904.   switch (which_alternative)
  1905.     {
  1906.     case 0:
  1907.       return singlemove_string (operands);
  1908.     case 1:
  1909.       return \"ld %1,%0\";
  1910.     case 2:
  1911.       return \"st %%g0,%0\";
  1912.     }
  1913. }"
  1914.   [(set_attr "type" "load,fpload,store")
  1915.    (set_attr "length" "2,1,1")])
  1916.  
  1917. (define_expand "movsf"
  1918.   [(set (match_operand:SF 0 "general_operand" "")
  1919.     (match_operand:SF 1 "general_operand" ""))]
  1920.   ""
  1921.   "
  1922. {
  1923.   if (emit_move_sequence (operands, SFmode))
  1924.     DONE;
  1925. }")
  1926.  
  1927. (define_insn ""
  1928.   [(set (match_operand:SF 0 "reg_or_nonsymb_mem_operand" "=f,r,f,r,Q,Q")
  1929.     (match_operand:SF 1 "reg_or_nonsymb_mem_operand" "f,r,Q,Q,f,r"))]
  1930.   "TARGET_FPU
  1931.    && (register_operand (operands[0], SFmode)
  1932.        || register_operand (operands[1], SFmode))"
  1933.   "@
  1934.    fmovs %1,%0
  1935.    mov %1,%0
  1936.    ld %1,%0
  1937.    ld %1,%0
  1938.    st %r1,%0
  1939.    st %r1,%0"
  1940.   [(set_attr "type" "fp,move,fpload,load,fpstore,store")])
  1941.  
  1942. ;; Exactly the same as above, except that all `f' cases are deleted.
  1943. ;; This is necessary to prevent reload from ever trying to use a `f' reg
  1944. ;; when -mno-fpu.
  1945.  
  1946. (define_insn ""
  1947.   [(set (match_operand:SF 0 "reg_or_nonsymb_mem_operand" "=r,r,Q")
  1948.     (match_operand:SF 1 "reg_or_nonsymb_mem_operand" "r,Q,r"))]
  1949.   "! TARGET_FPU
  1950.    && (register_operand (operands[0], SFmode)
  1951.        || register_operand (operands[1], SFmode))"
  1952.   "@
  1953.    mov %1,%0
  1954.    ld %1,%0
  1955.    st %r1,%0"
  1956.   [(set_attr "type" "move,load,store")])
  1957.  
  1958. (define_insn ""
  1959.   [(set (mem:SF (match_operand:SI 0 "symbolic_operand" "i"))
  1960.     (match_operand:SF 1 "reg_or_0_operand" "rfG"))
  1961.    (clobber (match_scratch:SI 2 "=&r"))]
  1962.   "(reload_completed || reload_in_progress) && ! TARGET_PTR64"
  1963.   "sethi %%hi(%a0),%2\;st %r1,[%2+%%lo(%a0)]"
  1964.   [(set_attr "type" "store")
  1965.    (set_attr "length" "2")])
  1966.  
  1967. ;; This pattern forces (set (reg:DF ...) (const_double ...))
  1968. ;; to be reloaded by putting the constant into memory.
  1969. ;; It must come before the more general movdf pattern.
  1970.  
  1971. (define_insn ""
  1972.   [(set (match_operand:DF 0 "general_operand" "=?r,f,o")
  1973.     (match_operand:DF 1 "" "?E,m,G"))]
  1974.   "TARGET_FPU && GET_CODE (operands[1]) == CONST_DOUBLE"
  1975.   "*
  1976. {
  1977.   switch (which_alternative)
  1978.     {
  1979.     case 0:
  1980.       return output_move_double (operands);
  1981.     case 1:
  1982.       return output_fp_move_double (operands);
  1983.     case 2:
  1984.       if (TARGET_V9)
  1985.     {
  1986.       return \"stx %%g0,%0\";
  1987.     }
  1988.       else
  1989.     {
  1990.       operands[1] = adj_offsettable_operand (operands[0], 4);
  1991.       return \"st %%g0,%0\;st %%g0,%1\";
  1992.     }
  1993.     }
  1994. }"
  1995.   [(set_attr "type" "load,fpload,store")
  1996.    (set_attr "length" "3,3,3")])
  1997.  
  1998. (define_expand "movdf"
  1999.   [(set (match_operand:DF 0 "general_operand" "")
  2000.     (match_operand:DF 1 "general_operand" ""))]
  2001.   ""
  2002.   "
  2003. {
  2004.   if (emit_move_sequence (operands, DFmode))
  2005.     DONE;
  2006. }")
  2007.  
  2008. (define_insn ""
  2009.   [(set (match_operand:DF 0 "reg_or_nonsymb_mem_operand" "=T,U,f,r,Q,Q,f,r")
  2010.     (match_operand:DF 1 "reg_or_nonsymb_mem_operand" "U,T,f,r,f,r,Q,Q"))]
  2011.   "TARGET_FPU
  2012.    && (register_operand (operands[0], DFmode)
  2013.        || register_operand (operands[1], DFmode))"
  2014.   "*
  2015. {
  2016.   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1]))
  2017.     return output_fp_move_double (operands);
  2018.   return output_move_double (operands);
  2019. }"
  2020.   [(set_attr "type" "fpstore,fpload,fp,move,fpstore,store,fpload,load")
  2021.    (set_attr "length" "1,1,2,2,3,3,3,3")])
  2022.  
  2023. ;; Exactly the same as above, except that all `f' cases are deleted.
  2024. ;; This is necessary to prevent reload from ever trying to use a `f' reg
  2025. ;; when -mno-fpu.
  2026.  
  2027. (define_insn ""
  2028.   [(set (match_operand:DF 0 "reg_or_nonsymb_mem_operand" "=T,U,r,Q,&r")
  2029.     (match_operand:DF 1 "reg_or_nonsymb_mem_operand" "U,T,r,r,Q"))]
  2030.   "! TARGET_FPU
  2031.    && (register_operand (operands[0], DFmode)
  2032.        || register_operand (operands[1], DFmode))"
  2033.   "* return output_move_double (operands);"
  2034.   [(set_attr "type" "store,load,move,store,load")
  2035.    (set_attr "length" "1,1,2,3,3")])
  2036.  
  2037. ;; ??? Do we need a v9 version of this?
  2038. (define_split
  2039.   [(set (match_operand:DF 0 "register_operand" "")
  2040.     (match_operand:DF 1 "register_operand" ""))]
  2041.   "! TARGET_V9 && reload_completed"
  2042.   [(set (match_dup 2) (match_dup 3))
  2043.    (set (match_dup 4) (match_dup 5))]
  2044.   "
  2045. { operands[2] = operand_subword (operands[0], 0, 0, DFmode);
  2046.   operands[3] = operand_subword (operands[1], 0, 0, DFmode);
  2047.   operands[4] = operand_subword (operands[0], 1, 0, DFmode);
  2048.   operands[5] = operand_subword (operands[1], 1, 0, DFmode); }")
  2049.  
  2050. (define_insn ""
  2051.   [(set (mem:DF (match_operand:SI 0 "symbolic_operand" "i,i"))
  2052.     (match_operand:DF 1 "reg_or_0_operand" "rf,G"))
  2053.    (clobber (match_scratch:SI 2 "=&r,&r"))]
  2054.   "(reload_completed || reload_in_progress) && ! TARGET_PTR64"
  2055.   "*
  2056. {
  2057.   output_asm_insn (\"sethi %%hi(%a0),%2\", operands);
  2058.   if (which_alternative == 0)
  2059.     return \"std %1,[%2+%%lo(%a0)]\";
  2060.   else
  2061.     return \"st %%g0,[%2+%%lo(%a0)]\;st %%g0,[%2+%%lo(%a0+4)]\";
  2062. }"
  2063.   [(set_attr "type" "store")
  2064.    (set_attr "length" "3")])
  2065.  
  2066. ;; This pattern forces (set (reg:TF ...) (const_double ...))
  2067. ;; to be reloaded by putting the constant into memory.
  2068. ;; It must come before the more general movtf pattern.
  2069. (define_insn ""
  2070.   [(set (match_operand:TF 0 "general_operand" "=?r,f,o")
  2071.     (match_operand:TF 1 "" "?E,m,G"))]
  2072.   "TARGET_FPU && GET_CODE (operands[1]) == CONST_DOUBLE"
  2073.   "*
  2074. {
  2075.   switch (which_alternative)
  2076.     {
  2077.     case 0:
  2078.       return output_move_quad (operands);
  2079.     case 1:
  2080.       return output_fp_move_quad (operands);
  2081.     case 2:
  2082.       if (TARGET_V9)
  2083.     {
  2084.       operands[1] = adj_offsettable_operand (operands[0], 8);
  2085.       return \"stx %%g0,%0\;stx %%g0,%1\";
  2086.     }
  2087.       else
  2088.     {
  2089.       /* ??? Do we run off the end of the array here? */
  2090.       operands[1] = adj_offsettable_operand (operands[0], 4);
  2091.       operands[2] = adj_offsettable_operand (operands[0], 8);
  2092.       operands[3] = adj_offsettable_operand (operands[0], 12);
  2093.       return \"st %%g0,%0\;st %%g0,%1\;st %%g0,%2\;st %%g0,%3\";
  2094.     }
  2095.     }
  2096. }"
  2097.   [(set_attr "type" "load,fpload,store")
  2098.    (set_attr "length" "5,5,5")])
  2099.  
  2100. (define_expand "movtf"
  2101.   [(set (match_operand:TF 0 "general_operand" "")
  2102.     (match_operand:TF 1 "general_operand" ""))]
  2103.   ""
  2104.   "
  2105. {
  2106.   if (emit_move_sequence (operands, TFmode))
  2107.     DONE;
  2108. }")
  2109.  
  2110. (define_insn ""
  2111.   [(set (match_operand:TF 0 "reg_or_nonsymb_mem_operand" "=f,r,Q,Q,f,&r")
  2112.     (match_operand:TF 1 "reg_or_nonsymb_mem_operand" "f,r,f,r,Q,Q"))]
  2113.   "TARGET_FPU
  2114.    && (register_operand (operands[0], TFmode)
  2115.        || register_operand (operands[1], TFmode))"
  2116.   "*
  2117. {
  2118.   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1]))
  2119.     return output_fp_move_quad (operands);
  2120.   return output_move_quad (operands);
  2121. }"
  2122.   [(set_attr "type" "fp,move,fpstore,store,fpload,load")
  2123.    (set_attr "length" "4,4,5,5,5,5")])
  2124.  
  2125. ;; Exactly the same as above, except that all `f' cases are deleted.
  2126. ;; This is necessary to prevent reload from ever trying to use a `f' reg
  2127. ;; when -mno-fpu.
  2128.  
  2129. (define_insn ""
  2130.   [(set (match_operand:TF 0 "reg_or_nonsymb_mem_operand" "=r,Q,&r")
  2131.     (match_operand:TF 1 "reg_or_nonsymb_mem_operand" "r,r,Q"))]
  2132.   "! TARGET_FPU
  2133.    && (register_operand (operands[0], TFmode)
  2134.        || register_operand (operands[1], TFmode))"
  2135.   "*
  2136. {
  2137.   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1]))
  2138.     return output_fp_move_quad (operands);
  2139.   return output_move_quad (operands);
  2140. }"
  2141.   [(set_attr "type" "move,store,load")
  2142.    (set_attr "length" "4,5,5")])
  2143.  
  2144. (define_insn ""
  2145.   [(set (mem:TF (match_operand:SI 0 "symbolic_operand" "i,i"))
  2146.     (match_operand:TF 1 "reg_or_0_operand" "rf,G"))
  2147.    (clobber (match_scratch:SI 2 "=&r,&r"))]
  2148.   "(reload_completed || reload_in_progress) && ! TARGET_PTR64"
  2149.   "*
  2150. {
  2151.   output_asm_insn (\"sethi %%hi(%a0),%2\", operands);
  2152.   if (which_alternative == 0)
  2153.     return \"std %1,[%2+%%lo(%a0)]\;std %S1,[%2+%%lo(%a0+8)]\";
  2154.   else
  2155.     return \"st %%g0,[%2+%%lo(%a0)]\;st %%g0,[%2+%%lo(%a0+4)]\; st %%g0,[%2+%%lo(%a0+8)]\;st %%g0,[%2+%%lo(%a0+12)]\";
  2156. }"
  2157.   [(set_attr "type" "store")
  2158.    (set_attr "length" "5")])
  2159.  
  2160. ;; Sparc V9 conditional move instructions.
  2161.  
  2162. ; ??? There is not actually a 32 bit version of this instruction.
  2163. (define_insn ""
  2164.   [(set (match_operand:SI 0 "register_operand" "=r")
  2165.     (if_then_else (match_operator 1 "comparison_operator"
  2166.                       [(reg:CC 0) (const_int 0)])
  2167.               (match_operand:SI 2 "arith11_operand" "ri")
  2168.               (match_operand:SI 3 "register_operand" "0")))]
  2169.   "TARGET_V9"
  2170.   "mov%C1 %%icc,%2,%0"
  2171.   [(set_attr "type" "cmove")])
  2172.  
  2173. (define_insn ""
  2174.   [(set (match_operand:DI 0 "register_operand" "=r")
  2175.     (if_then_else (match_operator 1 "comparison_operator"
  2176.                       [(reg:CC 0) (const_int 0)])
  2177.               (match_operand:DI 2 "arith11_double_operand" "rHI")
  2178.               (match_operand:DI 3 "register_operand" "0")))]
  2179.   "TARGET_V9"
  2180.   "mov%C1 %%icc,%2,%0"
  2181.   [(set_attr "type" "cmove")])
  2182.  
  2183. ;; ??? There is not actually a 32 bit version of this instruction.
  2184. (define_insn ""
  2185.   [(set (match_operand:SI 0 "register_operand" "=r")
  2186.     (if_then_else (match_operator 1 "comparison_operator"
  2187.                       [(reg:CCX 0) (const_int 0)])
  2188.               (match_operand:SI 2 "arith11_operand" "ri")
  2189.               (match_operand:SI 3 "register_operand" "0")))]
  2190.   "TARGET_V9"
  2191.   "mov%C1 %%xcc,%2,%0"
  2192.   [(set_attr "type" "cmove")])
  2193.  
  2194. (define_insn ""
  2195.   [(set (match_operand:DI 0 "register_operand" "=r")
  2196.     (if_then_else (match_operator 1 "comparison_operator"
  2197.                       [(reg:CCX 0) (const_int 0)])
  2198.               (match_operand:DI 2 "arith11_double_operand" "rHI")
  2199.               (match_operand:DI 3 "register_operand" "0")))]
  2200.   "TARGET_V9"
  2201.   "mov%C1 %%xcc,%2,%0"
  2202.   [(set_attr "type" "cmove")])
  2203.  
  2204. ;; ??? There is not actually a 32 bit version of this instruction.
  2205. (define_insn ""
  2206.   [(set (match_operand:SI 0 "register_operand" "=r")
  2207.     (if_then_else (match_operator 1 "comparison_operator"
  2208.                 [(match_operand:CCFP 2 "ccfp_reg_operand" "c")
  2209.                  (const_int 0)])
  2210.               (match_operand:SI 3 "arith11_operand" "ri")
  2211.               (match_operand:SI 4 "register_operand" "0")))]
  2212.   "TARGET_V9"
  2213.   "mov%C1 %2,%3,%0"
  2214.   [(set_attr "type" "cmove")])
  2215.  
  2216. ;; ??? There is not actually a 32 bit version of this instruction.
  2217. (define_insn ""
  2218.   [(set (match_operand:SI 0 "register_operand" "=r")
  2219.     (if_then_else (match_operator 1 "comparison_operator"
  2220.                 [(match_operand:CCFPE 2 "ccfp_reg_operand" "c")
  2221.                  (const_int 0)])
  2222.               (match_operand:SI 3 "arith11_operand" "ri")
  2223.               (match_operand:SI 4 "register_operand" "0")))]
  2224.   "TARGET_V9"
  2225.   "mov%C1 %2,%3,%0"
  2226.   [(set_attr "type" "cmove")])
  2227.  
  2228. (define_insn ""
  2229.   [(set (match_operand:DI 0 "register_operand" "=r")
  2230.     (if_then_else (match_operator 1 "comparison_operator"
  2231.                 [(match_operand:CCFP 2 "ccfp_reg_operand" "c")
  2232.                  (const_int 0)])
  2233.               (match_operand:DI 3 "arith11_double_operand" "rHI")
  2234.               (match_operand:DI 4 "register_operand" "0")))]
  2235.   "TARGET_V9"
  2236.   "mov%C1 %2,%3,%0"
  2237.   [(set_attr "type" "cmove")])
  2238.  
  2239. (define_insn ""
  2240.   [(set (match_operand:DI 0 "register_operand" "=r")
  2241.     (if_then_else (match_operator 1 "comparison_operator"
  2242.                 [(match_operand:CCFPE 2 "ccfp_reg_operand" "c")
  2243.                  (const_int 0)])
  2244.               (match_operand:DI 3 "arith11_double_operand" "rHI")
  2245.               (match_operand:DI 4 "register_operand" "0")))]
  2246.   "TARGET_V9"
  2247.   "mov%C1 %2,%3,%0"
  2248.   [(set_attr "type" "cmove")])
  2249.  
  2250. ;; ??? There is not actually a 32 bit version of this instruction.
  2251. (define_insn ""
  2252.   [(set (match_operand:SI 0 "register_operand" "=r")
  2253.     (if_then_else (match_operator 1 "v9_regcmp_op"
  2254.                 [(match_operand:DI 2 "register_operand" "r")
  2255.                  (const_int 0)])
  2256.               (match_operand:SI 3 "arith10_operand" "ri")
  2257.               (match_operand:SI 4 "register_operand" "0")))]
  2258.   "TARGET_V9"
  2259.   "movr%D1 %2,%r3,%0"
  2260.   [(set_attr "type" "cmove")])
  2261.  
  2262. (define_insn ""
  2263.   [(set (match_operand:DI 0 "register_operand" "=r")
  2264.     (if_then_else (match_operator 1 "v9_regcmp_op"
  2265.                 [(match_operand:DI 2 "register_operand" "r")
  2266.                  (const_int 0)])
  2267.               (match_operand:DI 3 "arith10_double_operand" "ri")
  2268.               (match_operand:DI 4 "register_operand" "0")))]
  2269.   "TARGET_V9"
  2270.   "movr%D1 %2,%r3,%0"
  2271.   [(set_attr "type" "cmove")])
  2272.  
  2273. (define_insn ""
  2274.   [(set (match_operand:SF 0 "register_operand" "=f")
  2275.     (if_then_else (match_operator 1 "v9_regcmp_op"
  2276.                 [(match_operand:DI 2 "register_operand" "r")
  2277.                  (const_int 0)])
  2278.               (match_operand:SF 3 "register_operand" "f")
  2279.               (match_operand:SF 4 "register_operand" "0")))]
  2280.   "TARGET_V9 && TARGET_FPU"
  2281.   "fmovrs%D1 %2,%r3,%0"
  2282.   [(set_attr "type" "cmove")])
  2283.  
  2284. (define_insn ""
  2285.   [(set (match_operand:DF 0 "register_operand" "=f")
  2286.     (if_then_else (match_operator 1 "v9_regcmp_op"
  2287.                 [(match_operand:DI 2 "register_operand" "r")
  2288.                  (const_int 0)])
  2289.               (match_operand:DF 3 "register_operand" "f")
  2290.               (match_operand:DF 4 "register_operand" "0")))]
  2291.   "TARGET_V9 && TARGET_FPU"
  2292.   "fmovrd%D1 %2,%r3,%0"
  2293.   [(set_attr "type" "cmove")])
  2294.  
  2295. (define_insn ""
  2296.   [(set (match_operand:TF 0 "register_operand" "=f")
  2297.     (if_then_else (match_operator 1 "v9_regcmp_op"
  2298.                 [(match_operand:DI 2 "register_operand" "r")
  2299.                  (const_int 0)])
  2300.               (match_operand:TF 3 "register_operand" "f")
  2301.               (match_operand:TF 4 "register_operand" "0")))]
  2302.   "TARGET_V9 && TARGET_FPU"
  2303.   "fmovrq%D1 %2,%r3,%0"
  2304.   [(set_attr "type" "cmove")])
  2305.  
  2306. (define_insn ""
  2307.   [(set (match_operand:SF 0 "register_operand" "=f")
  2308.     (if_then_else (match_operator 1 "comparison_operator"
  2309.                 [(match_operand:CCFP 2 "ccfp_reg_operand" "c")
  2310.                  (const_int 0)])
  2311.               (match_operand:SF 3 "register_operand" "f")
  2312.               (match_operand:SF 4 "register_operand" "0")))]
  2313.   "TARGET_V9 && TARGET_FPU"
  2314.   "fmovs%C1 %2,%3,%0"
  2315.   [(set_attr "type" "cmove")])
  2316.  
  2317. (define_insn ""
  2318.   [(set (match_operand:SF 0 "register_operand" "=f")
  2319.     (if_then_else (match_operator 1 "comparison_operator"
  2320.                 [(match_operand:CCFPE 2 "ccfp_reg_operand" "c")
  2321.                  (const_int 0)])
  2322.               (match_operand:SF 3 "register_operand" "f")
  2323.               (match_operand:SF 4 "register_operand" "0")))]
  2324.   "TARGET_V9 && TARGET_FPU"
  2325.   "fmovs%C1 %2,%3,%0"
  2326.   [(set_attr "type" "cmove")])
  2327.  
  2328. (define_insn ""
  2329.   [(set (match_operand:DF 0 "register_operand" "=f")
  2330.     (if_then_else (match_operator 1 "comparison_operator"
  2331.                 [(match_operand:CCFP 2 "ccfp_reg_operand" "c")
  2332.                  (const_int 0)])
  2333.               (match_operand:DF 3 "register_operand" "f")
  2334.               (match_operand:DF 4 "register_operand" "0")))]
  2335.   "TARGET_V9 && TARGET_FPU"
  2336.   "fmovd%C1 %2,%3,%0"
  2337.   [(set_attr "type" "cmove")])
  2338.  
  2339. (define_insn ""
  2340.   [(set (match_operand:DF 0 "register_operand" "=f")
  2341.     (if_then_else (match_operator 1 "comparison_operator"
  2342.                 [(match_operand:CCFPE 2 "ccfp_reg_operand" "c")
  2343.                  (const_int 0)])
  2344.               (match_operand:DF 3 "register_operand" "f")
  2345.               (match_operand:DF 4 "register_operand" "0")))]
  2346.   "TARGET_V9 && TARGET_FPU"
  2347.   "fmovd%C1 %2,%3,%0"
  2348.   [(set_attr "type" "cmove")])
  2349.  
  2350. (define_insn ""
  2351.   [(set (match_operand:TF 0 "register_operand" "=f")
  2352.     (if_then_else (match_operator 1 "comparison_operator"
  2353.                 [(match_operand:CCFP 2 "ccfp_reg_operand" "c")
  2354.                  (const_int 0)])
  2355.               (match_operand:TF 3 "register_operand" "f")
  2356.               (match_operand:TF 4 "register_operand" "0")))]
  2357.   "TARGET_V9 && TARGET_FPU"
  2358.   "fmovq%C1 %2,%3,%0"
  2359.   [(set_attr "type" "cmove")])
  2360.  
  2361. (define_insn ""
  2362.   [(set (match_operand:TF 0 "register_operand" "=f")
  2363.     (if_then_else (match_operator 1 "comparison_operator"
  2364.                 [(match_operand:CCFPE 2 "ccfp_reg_operand" "c")
  2365.                  (const_int 0)])
  2366.               (match_operand:TF 3 "register_operand" "f")
  2367.               (match_operand:TF 4 "register_operand" "0")))]
  2368.   "TARGET_V9 && TARGET_FPU"
  2369.   "fmovq%C1 %2,%3,%0"
  2370.   [(set_attr "type" "cmove")])
  2371.  
  2372. (define_insn ""
  2373.   [(set (match_operand:SF 0 "register_operand" "=f")
  2374.     (if_then_else (match_operator 1 "comparison_operator"
  2375.                       [(reg:CC 0) (const_int 0)])
  2376.               (match_operand:SF 2 "register_operand" "f")
  2377.               (match_operand:SF 3 "register_operand" "0")))]
  2378.   "TARGET_V9 && TARGET_FPU"
  2379.   "fmovs%C1 %%icc,%2,%0"
  2380.   [(set_attr "type" "cmove")])
  2381.  
  2382. (define_insn ""
  2383.   [(set (match_operand:DF 0 "register_operand" "=f")
  2384.     (if_then_else (match_operator 1 "comparison_operator"
  2385.                       [(reg:CC 0) (const_int 0)])
  2386.               (match_operand:DF 2 "register_operand" "f")
  2387.               (match_operand:DF 3 "register_operand" "0")))]
  2388.   "TARGET_V9 && TARGET_FPU"
  2389.   "fmovd%C1 %%icc,%2,%0"
  2390.   [(set_attr "type" "cmove")])
  2391.  
  2392. (define_insn ""
  2393.   [(set (match_operand:TF 0 "register_operand" "=f")
  2394.     (if_then_else (match_operator 1 "comparison_operator"
  2395.                       [(reg:CC 0) (const_int 0)])
  2396.               (match_operand:TF 2 "register_operand" "f")
  2397.               (match_operand:TF 3 "register_operand" "0")))]
  2398.   "TARGET_V9 && TARGET_FPU"
  2399.   "fmovq%C1 %%icc,%2,%0"
  2400.   [(set_attr "type" "cmove")])
  2401.  
  2402. (define_insn ""
  2403.   [(set (match_operand:SF 0 "register_operand" "=f")
  2404.     (if_then_else (match_operator 1 "comparison_operator"
  2405.                       [(reg:CCX 0) (const_int 0)])
  2406.               (match_operand:SF 2 "register_operand" "f")
  2407.               (match_operand:SF 3 "register_operand" "0")))]
  2408.   "TARGET_V9 && TARGET_FPU"
  2409.   "fmovs%C1 %%xcc,%2,%0"
  2410.   [(set_attr "type" "cmove")])
  2411.  
  2412. (define_insn ""
  2413.   [(set (match_operand:DF 0 "register_operand" "=f")
  2414.     (if_then_else (match_operator 1 "comparison_operator"
  2415.                       [(reg:CCX 0) (const_int 0)])
  2416.               (match_operand:DF 2 "register_operand" "f")
  2417.               (match_operand:DF 3 "register_operand" "0")))]
  2418.   "TARGET_V9 && TARGET_FPU"
  2419.   "fmovd%C1 %%xcc,%2,%0"
  2420.   [(set_attr "type" "cmove")])
  2421.  
  2422. (define_insn ""
  2423.   [(set (match_operand:TF 0 "register_operand" "=f")
  2424.     (if_then_else (match_operator 1 "comparison_operator"
  2425.                       [(reg:CCX 0) (const_int 0)])
  2426.               (match_operand:TF 2 "register_operand" "f")
  2427.               (match_operand:TF 3 "register_operand" "0")))]
  2428.   "TARGET_V9 && TARGET_FPU"
  2429.   "fmovq%C1 %%xcc,%2,%0"
  2430.   [(set_attr "type" "cmove")])
  2431.  
  2432. ;;- zero extension instructions
  2433.  
  2434. ;; These patterns originally accepted general_operands, however, slightly
  2435. ;; better code is generated by only accepting register_operands, and then
  2436. ;; letting combine generate the ldu[hb] insns.
  2437.  
  2438. (define_expand "zero_extendhisi2"
  2439.   [(set (match_operand:SI 0 "register_operand" "")
  2440.     (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
  2441.   ""
  2442.   "
  2443. {
  2444.   rtx temp = gen_reg_rtx (SImode);
  2445.   rtx shift_16 = gen_rtx (CONST_INT, VOIDmode, 16);
  2446.   int op1_subword = 0;
  2447.  
  2448.   if (GET_CODE (operand1) == SUBREG)
  2449.     {
  2450.       op1_subword = SUBREG_WORD (operand1);
  2451.       operand1 = XEXP (operand1, 0);
  2452.     }
  2453.  
  2454.   emit_insn (gen_ashlsi3 (temp, gen_rtx (SUBREG, SImode, operand1,
  2455.                      op1_subword),
  2456.               shift_16));
  2457.   emit_insn (gen_lshrsi3 (operand0, temp, shift_16));
  2458.   DONE;
  2459. }")
  2460.  
  2461. (define_insn ""
  2462.   [(set (match_operand:SI 0 "register_operand" "=r")
  2463.     (zero_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
  2464.   ""
  2465.   "lduh %1,%0"
  2466.   [(set_attr "type" "load")])
  2467.  
  2468. (define_expand "zero_extendqihi2"
  2469.   [(set (match_operand:HI 0 "register_operand" "")
  2470.     (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
  2471.   ""
  2472.   "")
  2473.  
  2474. (define_insn ""
  2475.   [(set (match_operand:HI 0 "register_operand" "=r,r")
  2476.     (zero_extend:HI (match_operand:QI 1 "sparc_operand" "r,Q")))]
  2477.   "GET_CODE (operands[1]) != CONST_INT"
  2478.   "@
  2479.    and %1,0xff,%0
  2480.    ldub %1,%0"
  2481.   [(set_attr "type" "unary,load")
  2482.    (set_attr "length" "1")])
  2483.  
  2484. (define_expand "zero_extendqisi2"
  2485.   [(set (match_operand:SI 0 "register_operand" "")
  2486.     (zero_extend:SI (match_operand:QI 1 "register_operand" "")))]
  2487.   ""
  2488.   "")
  2489.  
  2490. (define_insn ""
  2491.   [(set (match_operand:SI 0 "register_operand" "=r,r")
  2492.     (zero_extend:SI (match_operand:QI 1 "sparc_operand" "r,Q")))]
  2493.   "GET_CODE (operands[1]) != CONST_INT"
  2494.   "@
  2495.    and %1,0xff,%0
  2496.    ldub %1,%0"
  2497.   [(set_attr "type" "unary,load")
  2498.    (set_attr "length" "1")])
  2499.  
  2500. (define_expand "zero_extendqidi2"
  2501.   [(set (match_operand:DI 0 "register_operand" "")
  2502.     (zero_extend:DI (match_operand:QI 1 "register_operand" "")))]
  2503.   "TARGET_V9"
  2504.   "")
  2505.  
  2506. (define_insn ""
  2507.   [(set (match_operand:DI 0 "register_operand" "=r,r")
  2508.     (zero_extend:DI (match_operand:QI 1 "sparc_operand" "r,Q")))]
  2509.   "TARGET_V9 && GET_CODE (operands[1]) != CONST_INT"
  2510.   "@
  2511.    and %1,0xff,%0
  2512.    ldub %1,%0"
  2513.   [(set_attr "type" "unary,load")
  2514.    (set_attr "length" "1")])
  2515.  
  2516. (define_expand "zero_extendhidi2"
  2517.   [(set (match_operand:DI 0 "register_operand" "")
  2518.     (zero_extend:DI (match_operand:HI 1 "register_operand" "")))]
  2519.   "TARGET_V9"
  2520.   "
  2521. {
  2522.   rtx temp = gen_reg_rtx (DImode);
  2523.   rtx shift_48 = gen_rtx (CONST_INT, VOIDmode, 48);
  2524.   int op1_subword = 0;
  2525.  
  2526.   if (GET_CODE (operand1) == SUBREG)
  2527.     {
  2528.       op1_subword = SUBREG_WORD (operand1);
  2529.       operand1 = XEXP (operand1, 0);
  2530.     }
  2531.  
  2532.   emit_insn (gen_ashldi3 (temp, gen_rtx (SUBREG, DImode, operand1,
  2533.                      op1_subword),
  2534.               shift_48));
  2535.   emit_insn (gen_lshrdi3 (operand0, temp, shift_48));
  2536.   DONE;
  2537. }")
  2538.  
  2539. (define_insn ""
  2540.   [(set (match_operand:DI 0 "register_operand" "=r")
  2541.     (zero_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
  2542.   "TARGET_V9"
  2543.   "lduh %1,%0"
  2544.   [(set_attr "type" "load")])
  2545.  
  2546. ;; ??? Write truncdisi pattern using sra?
  2547.  
  2548. (define_expand "zero_extendsidi2"
  2549.   [(set (match_operand:DI 0 "register_operand" "")
  2550.     (zero_extend:DI (match_operand:SI 1 "register_operand" "")))]
  2551.   "TARGET_V9"
  2552.   "")
  2553.  
  2554. (define_insn ""
  2555.   [(set (match_operand:DI 0 "register_operand" "=r,r")
  2556.     (zero_extend:DI (match_operand:SI 1 "sparc_operand" "r,Q")))]
  2557.   "TARGET_V9 && GET_CODE (operands[1]) != CONST_INT"
  2558.   "@
  2559.    srl %1,0,%0
  2560.    lduw %1,%0"
  2561.   [(set_attr "type" "unary,load")
  2562.    (set_attr "length" "1")])
  2563.  
  2564. ;; Simplify comparisons of extended values.
  2565.  
  2566. (define_insn ""
  2567.   [(set (reg:CC 0)
  2568.     (compare:CC (zero_extend:SI (match_operand:QI 0 "register_operand" "r"))
  2569.             (const_int 0)))]
  2570.   ""
  2571.   "andcc %0,0xff,%%g0"
  2572.   [(set_attr "type" "compare")])
  2573.  
  2574. (define_insn ""
  2575.   [(set (reg:CC 0)
  2576.     (compare:CC (zero_extend:SI (match_operand:QI 1 "register_operand" "r"))
  2577.             (const_int 0)))
  2578.    (set (match_operand:SI 0 "register_operand" "=r")
  2579.     (zero_extend:SI (match_dup 1)))]
  2580.   ""
  2581.   "andcc %1,0xff,%0"
  2582.   [(set_attr "type" "unary")])
  2583.  
  2584. ;; Similarly, handle SI->QI mode truncation followed by a compare.
  2585.  
  2586. (define_insn ""
  2587.   [(set (reg:CC 0)
  2588.     (compare:CC (subreg:QI (match_operand:SI 0 "register_operand" "r") 0)
  2589.             (const_int 0)))]
  2590.   ""
  2591.   "andcc %0,0xff,%%g0"
  2592.   [(set_attr "type" "compare")])
  2593.  
  2594. (define_insn ""
  2595.   [(set (reg:CC 0)
  2596.     (compare:CC (subreg:QI (match_operand:SI 1 "register_operand" "r") 0)
  2597.             (const_int 0)))
  2598.    (set (match_operand:QI 0 "register_operand" "=r")
  2599.     (match_dup 1))]
  2600.   ""
  2601.   "andcc %1,0xff,%0"
  2602.   [(set_attr "type" "unary")])
  2603.  
  2604. ;;- sign extension instructions
  2605.  
  2606. ;; These patterns originally accepted general_operands, however, slightly
  2607. ;; better code is generated by only accepting register_operands, and then
  2608. ;; letting combine generate the lds[hb] insns.
  2609.  
  2610. (define_expand "extendhisi2"
  2611.   [(set (match_operand:SI 0 "register_operand" "")
  2612.     (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
  2613.   ""
  2614.   "
  2615. {
  2616.   rtx temp = gen_reg_rtx (SImode);
  2617.   rtx shift_16 = gen_rtx (CONST_INT, VOIDmode, 16);
  2618.   int op1_subword = 0;
  2619.  
  2620.   if (GET_CODE (operand1) == SUBREG)
  2621.     {
  2622.       op1_subword = SUBREG_WORD (operand1);
  2623.       operand1 = XEXP (operand1, 0);
  2624.     }
  2625.  
  2626.   emit_insn (gen_ashlsi3 (temp, gen_rtx (SUBREG, SImode, operand1,
  2627.                      op1_subword),
  2628.               shift_16));
  2629.   emit_insn (gen_ashrsi3 (operand0, temp, shift_16));
  2630.   DONE;
  2631. }")
  2632.  
  2633. (define_insn ""
  2634.   [(set (match_operand:SI 0 "register_operand" "=r")
  2635.     (sign_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
  2636.   ""
  2637.   "ldsh %1,%0"
  2638.   [(set_attr "type" "load")])
  2639.  
  2640. (define_expand "extendqihi2"
  2641.   [(set (match_operand:HI 0 "register_operand" "")
  2642.     (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
  2643.   ""
  2644.   "
  2645. {
  2646.   rtx temp = gen_reg_rtx (SImode);
  2647.   rtx shift_24 = gen_rtx (CONST_INT, VOIDmode, 24);
  2648.   int op1_subword = 0;
  2649.   int op0_subword = 0;
  2650.  
  2651.   if (GET_CODE (operand1) == SUBREG)
  2652.     {
  2653.       op1_subword = SUBREG_WORD (operand1);
  2654.       operand1 = XEXP (operand1, 0);
  2655.     }
  2656.   if (GET_CODE (operand0) == SUBREG)
  2657.     {
  2658.       op0_subword = SUBREG_WORD (operand0);
  2659.       operand0 = XEXP (operand0, 0);
  2660.     }
  2661.   emit_insn (gen_ashlsi3 (temp, gen_rtx (SUBREG, SImode, operand1,
  2662.                      op1_subword),
  2663.               shift_24));
  2664.   if (GET_MODE (operand0) != SImode)
  2665.     operand0 = gen_rtx (SUBREG, SImode, operand0, op0_subword);
  2666.   emit_insn (gen_ashrsi3 (operand0, temp, shift_24));
  2667.   DONE;
  2668. }")
  2669.  
  2670. (define_insn ""
  2671.   [(set (match_operand:HI 0 "register_operand" "=r")
  2672.     (sign_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
  2673.   ""
  2674.   "ldsb %1,%0"
  2675.   [(set_attr "type" "load")])
  2676.  
  2677. (define_expand "extendqisi2"
  2678.   [(set (match_operand:SI 0 "register_operand" "")
  2679.     (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
  2680.   ""
  2681.   "
  2682. {
  2683.   rtx temp = gen_reg_rtx (SImode);
  2684.   rtx shift_24 = gen_rtx (CONST_INT, VOIDmode, 24);
  2685.   int op1_subword = 0;
  2686.  
  2687.   if (GET_CODE (operand1) == SUBREG)
  2688.     {
  2689.       op1_subword = SUBREG_WORD (operand1);
  2690.       operand1 = XEXP (operand1, 0);
  2691.     }
  2692.  
  2693.   emit_insn (gen_ashlsi3 (temp, gen_rtx (SUBREG, SImode, operand1,
  2694.                      op1_subword),
  2695.               shift_24));
  2696.   emit_insn (gen_ashrsi3 (operand0, temp, shift_24));
  2697.   DONE;
  2698. }")
  2699.  
  2700. (define_insn ""
  2701.   [(set (match_operand:SI 0 "register_operand" "=r")
  2702.     (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
  2703.   ""
  2704.   "ldsb %1,%0"
  2705.   [(set_attr "type" "load")])
  2706.  
  2707. (define_expand "extendqidi2"
  2708.   [(set (match_operand:DI 0 "register_operand" "")
  2709.     (sign_extend:DI (match_operand:QI 1 "register_operand" "")))]
  2710.   "TARGET_V9"
  2711.   "
  2712. {
  2713.   rtx temp = gen_reg_rtx (DImode);
  2714.   rtx shift_56 = gen_rtx (CONST_INT, VOIDmode, 56);
  2715.   int op1_subword = 0;
  2716.  
  2717.   if (GET_CODE (operand1) == SUBREG)
  2718.     {
  2719.       op1_subword = SUBREG_WORD (operand1);
  2720.       operand1 = XEXP (operand1, 0);
  2721.     }
  2722.  
  2723.   emit_insn (gen_ashldi3 (temp, gen_rtx (SUBREG, DImode, operand1,
  2724.                      op1_subword),
  2725.               shift_56));
  2726.   emit_insn (gen_ashrdi3 (operand0, temp, shift_56));
  2727.   DONE;
  2728. }")
  2729.  
  2730. (define_insn ""
  2731.   [(set (match_operand:DI 0 "register_operand" "=r")
  2732.     (sign_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
  2733.   "TARGET_V9"
  2734.   "ldsb %1,%0"
  2735.   [(set_attr "type" "load")])
  2736.  
  2737. (define_expand "extendhidi2"
  2738.   [(set (match_operand:DI 0 "register_operand" "")
  2739.     (sign_extend:DI (match_operand:HI 1 "register_operand" "")))]
  2740.   "TARGET_V9"
  2741.   "
  2742. {
  2743.   rtx temp = gen_reg_rtx (DImode);
  2744.   rtx shift_48 = gen_rtx (CONST_INT, VOIDmode, 48);
  2745.   int op1_subword = 0;
  2746.  
  2747.   if (GET_CODE (operand1) == SUBREG)
  2748.     {
  2749.       op1_subword = SUBREG_WORD (operand1);
  2750.       operand1 = XEXP (operand1, 0);
  2751.     }
  2752.  
  2753.   emit_insn (gen_ashldi3 (temp, gen_rtx (SUBREG, DImode, operand1,
  2754.                      op1_subword),
  2755.               shift_48));
  2756.   emit_insn (gen_ashrdi3 (operand0, temp, shift_48));
  2757.   DONE;
  2758. }")
  2759.  
  2760. (define_insn ""
  2761.   [(set (match_operand:DI 0 "register_operand" "=r")
  2762.     (sign_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
  2763.   "TARGET_V9"
  2764.   "ldsh %1,%0"
  2765.   [(set_attr "type" "load")])
  2766.  
  2767. (define_expand "extendsidi2"
  2768.   [(set (match_operand:DI 0 "register_operand" "")
  2769.     (sign_extend:DI (match_operand:SI 1 "register_operand" "")))]
  2770.   "TARGET_V9"
  2771.   "")
  2772.  
  2773. (define_insn ""
  2774.   [(set (match_operand:DI 0 "register_operand" "=r,r")
  2775.     (sign_extend:DI (match_operand:SI 1 "sparc_operand" "r,Q")))]
  2776.   "TARGET_V9"
  2777.   "@
  2778.   sra %1,0,%0
  2779.   ldsw %1,%0"
  2780.   [(set_attr "type" "unary,load")
  2781.    (set_attr "length" "1")])
  2782.  
  2783. ;; Special pattern for optimizing bit-field compares.  This is needed
  2784. ;; because combine uses this as a canonical form.
  2785.  
  2786. (define_insn ""
  2787.   [(set (reg:CC 0)
  2788.     (compare:CC
  2789.      (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
  2790.               (match_operand:SI 1 "small_int" "n")
  2791.               (match_operand:SI 2 "small_int" "n"))
  2792.      (const_int 0)))]
  2793.   "INTVAL (operands[2]) > 19"
  2794.   "*
  2795. {
  2796.   int len = INTVAL (operands[1]);
  2797.   int pos = 32 - INTVAL (operands[2]) - len;
  2798.   unsigned mask = ((1 << len) - 1) << pos;
  2799.  
  2800.   operands[1] = gen_rtx (CONST_INT, VOIDmode, mask);
  2801.   return \"andcc %0,%1,%%g0\";
  2802. }")
  2803.  
  2804. (define_insn ""
  2805.   [(set (reg:CCX 0)
  2806.     (compare:CCX
  2807.      (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
  2808.               (match_operand:SI 1 "small_int" "n")
  2809.               (match_operand:SI 2 "small_int" "n"))
  2810.      (const_int 0)))]
  2811.   "TARGET_V9 && INTVAL (operands[2]) > 51"
  2812.   "*
  2813. {
  2814.   int len = INTVAL (operands[1]);
  2815.   int pos = 64 - INTVAL (operands[2]) - len;
  2816.   unsigned mask = ((1 << len) - 1) << pos;
  2817.  
  2818.   operands[1] = gen_rtx (CONST_INT, VOIDmode, mask);
  2819.   return \"andcc %0,%1,%%g0\";
  2820. }")
  2821.  
  2822. ;; Conversions between float, double and long double.
  2823.  
  2824. (define_insn "extendsfdf2"
  2825.   [(set (match_operand:DF 0 "register_operand" "=f")
  2826.     (float_extend:DF
  2827.      (match_operand:SF 1 "register_operand" "f")))]
  2828.   "TARGET_FPU"
  2829.   "fstod %1,%0"
  2830.   [(set_attr "type" "fp")])
  2831.  
  2832. (define_insn "extendsftf2"
  2833.   [(set (match_operand:TF 0 "register_operand" "=f")
  2834.     (float_extend:TF
  2835.      (match_operand:SF 1 "register_operand" "f")))]
  2836.   "TARGET_FPU && TARGET_HARD_QUAD"
  2837.   "fstoq %1,%0"
  2838.   [(set_attr "type" "fp")])
  2839.  
  2840. (define_insn "extenddftf2"
  2841.   [(set (match_operand:TF 0 "register_operand" "=f")
  2842.     (float_extend:TF
  2843.      (match_operand:DF 1 "register_operand" "f")))]
  2844.   "TARGET_FPU && TARGET_HARD_QUAD"
  2845.   "fdtoq %1,%0"
  2846.   [(set_attr "type" "fp")])
  2847.  
  2848. (define_insn "truncdfsf2"
  2849.   [(set (match_operand:SF 0 "register_operand" "=f")
  2850.     (float_truncate:SF
  2851.      (match_operand:DF 1 "register_operand" "f")))]
  2852.   "TARGET_FPU"
  2853.   "fdtos %1,%0"
  2854.   [(set_attr "type" "fp")])
  2855.  
  2856. (define_insn "trunctfsf2"
  2857.   [(set (match_operand:SF 0 "register_operand" "=f")
  2858.     (float_truncate:SF
  2859.      (match_operand:TF 1 "register_operand" "f")))]
  2860.   "TARGET_FPU && TARGET_HARD_QUAD"
  2861.   "fqtos %1,%0"
  2862.   [(set_attr "type" "fp")])
  2863.  
  2864. (define_insn "trunctfdf2"
  2865.   [(set (match_operand:DF 0 "register_operand" "=f")
  2866.     (float_truncate:DF
  2867.      (match_operand:TF 1 "register_operand" "f")))]
  2868.   "TARGET_FPU && TARGET_HARD_QUAD"
  2869.   "fqtod %1,%0"
  2870.   [(set_attr "type" "fp")])
  2871.  
  2872. ;; Conversion between fixed point and floating point.
  2873.  
  2874. (define_insn "floatsisf2"
  2875.   [(set (match_operand:SF 0 "register_operand" "=f")
  2876.     (float:SF (match_operand:SI 1 "register_operand" "f")))]
  2877.   "TARGET_FPU"
  2878.   "fitos %1,%0"
  2879.   [(set_attr "type" "fp")])
  2880.  
  2881. (define_insn "floatsidf2"
  2882.   [(set (match_operand:DF 0 "register_operand" "=f")
  2883.     (float:DF (match_operand:SI 1 "register_operand" "f")))]
  2884.   "TARGET_FPU"
  2885.   "fitod %1,%0"
  2886.   [(set_attr "type" "fp")])
  2887.  
  2888. (define_insn "floatsitf2"
  2889.   [(set (match_operand:TF 0 "register_operand" "=f")
  2890.     (float:TF (match_operand:SI 1 "register_operand" "f")))]
  2891.   "TARGET_FPU && TARGET_HARD_QUAD"
  2892.   "fitoq %1,%0"
  2893.   [(set_attr "type" "fp")])
  2894.  
  2895. ;; Now the same for 64 bit sources.
  2896. ;; ??? We cannot put DImode values in fp regs (see below near fix_truncdfsi2).
  2897.  
  2898. (define_expand "floatdisf2"
  2899.   [(parallel [(set (match_operand:SF 0 "register_operand" "")
  2900.            (float:SF (match_operand:DI 1 "general_operand" "")))
  2901.           (clobber (match_dup 2))
  2902.           (clobber (match_dup 3))])]
  2903.   "TARGET_V9 && TARGET_FPU"
  2904.   "
  2905. {
  2906.   operands[2] = gen_reg_rtx (DFmode);
  2907.   operands[3] = sparc64_fpconv_stack_temp ();
  2908. }")
  2909.  
  2910. (define_expand "floatdidf2"
  2911.   [(parallel [(set (match_operand:DF 0 "register_operand" "")
  2912.            (float:DF (match_operand:DI 1 "general_operand" "")))
  2913.           (clobber (match_dup 2))
  2914.           (clobber (match_dup 3))])]
  2915.   "TARGET_V9 && TARGET_FPU"
  2916.   "
  2917. {
  2918.   operands[2] = gen_reg_rtx (DFmode);
  2919.   operands[3] = sparc64_fpconv_stack_temp ();
  2920. }")
  2921.  
  2922. (define_expand "floatditf2"
  2923.   [(parallel [(set (match_operand:TF 0 "register_operand" "")
  2924.            (float:TF (match_operand:DI 1 "general_operand" "")))
  2925.           (clobber (match_dup 2))
  2926.           (clobber (match_dup 3))])]
  2927.   "TARGET_V9 && TARGET_FPU && TARGET_HARD_QUAD"
  2928.   "
  2929. {
  2930.   operands[2] = gen_reg_rtx (DFmode);
  2931.   operands[3] = sparc64_fpconv_stack_temp ();
  2932. }")
  2933.  
  2934. (define_insn ""
  2935.   [(parallel [(set (match_operand:SF 0 "register_operand" "=f")
  2936.            (float:SF (match_operand:DI 1 "general_operand" "rm")))
  2937.           (clobber (match_operand:DF 2 "register_operand" "=&f"))
  2938.           (clobber (match_operand:DI 3 "memory_operand" "m"))])]
  2939.   "TARGET_V9 && TARGET_FPU"
  2940.   "*
  2941. {
  2942.   if (GET_CODE (operands[1]) == MEM)
  2943.     output_asm_insn (\"ldd %1,%2\", operands);
  2944.   else
  2945.     output_asm_insn (\"stx %1,%3\;ldd %3,%2\", operands);
  2946.   return \"fxtos %2,%0\";
  2947. }"
  2948.   [(set_attr "type" "fp")
  2949.    (set_attr "length" "3")])
  2950.  
  2951. (define_insn ""
  2952.   [(parallel [(set (match_operand:DF 0 "register_operand" "=f")
  2953.            (float:DF (match_operand:DI 1 "general_operand" "rm")))
  2954.           (clobber (match_operand:DF 2 "register_operand" "=&f"))
  2955.           (clobber (match_operand:DI 3 "memory_operand" "m"))])]
  2956.   "TARGET_V9 && TARGET_FPU"
  2957.   "*
  2958. {
  2959.   if (GET_CODE (operands[1]) == MEM)
  2960.     output_asm_insn (\"ldd %1,%2\", operands);
  2961.   else
  2962.     output_asm_insn (\"stx %1,%3\;ldd %3,%2\", operands);
  2963.   return \"fxtod %2,%0\";
  2964. }"
  2965.   [(set_attr "type" "fp")
  2966.    (set_attr "length" "3")])
  2967.  
  2968. (define_insn ""
  2969.   [(parallel [(set (match_operand:TF 0 "register_operand" "=f")
  2970.            (float:TF (match_operand:DI 1 "general_operand" "rm")))
  2971.           (clobber (match_operand:DF 2 "register_operand" "=&f"))
  2972.           (clobber (match_operand:DI 3 "memory_operand" "m"))])]
  2973.   "TARGET_V9 && TARGET_FPU && TARGET_HARD_QUAD"
  2974.   "*
  2975. {
  2976.   if (GET_CODE (operands[1]) == MEM)
  2977.     output_asm_insn (\"ldd %1,%2\", operands);
  2978.   else
  2979.     output_asm_insn (\"stx %1,%3\;ldd %3,%2\", operands);
  2980.   return \"fxtoq %2,%0\";
  2981. }"
  2982.   [(set_attr "type" "fp")
  2983.    (set_attr "length" "3")])
  2984.  
  2985. ;; ??? Ideally, these are what we would like to use.
  2986.  
  2987. (define_insn "floatdisf2_v9"
  2988.   [(set (match_operand:SF 0 "register_operand" "=f")
  2989.     (float:SF (match_operand:DI 1 "register_operand" "f")))]
  2990.   "0 && TARGET_V9 && TARGET_FPU"
  2991.   "fxtos %1,%0"
  2992.   [(set_attr "type" "fp")])
  2993.  
  2994. (define_insn "floatdidf2_v9"
  2995.   [(set (match_operand:DF 0 "register_operand" "=f")
  2996.     (float:DF (match_operand:DI 1 "register_operand" "f")))]
  2997.   "0 && TARGET_V9 && TARGET_FPU"
  2998.   "fxtod %1,%0"
  2999.   [(set_attr "type" "fp")])
  3000.  
  3001. (define_insn "floatditf2_v9"
  3002.   [(set (match_operand:TF 0 "register_operand" "=f")
  3003.     (float:TF (match_operand:DI 1 "register_operand" "f")))]
  3004.   "0 && TARGET_V9 && TARGET_FPU && TARGET_HARD_QUAD"
  3005.   "fxtoq %1,%0"
  3006.   [(set_attr "type" "fp")])
  3007.  
  3008. ;; Convert a float to an actual integer.
  3009. ;; Truncation is performed as part of the conversion.
  3010.  
  3011. (define_insn "fix_truncsfsi2"
  3012.   [(set (match_operand:SI 0 "register_operand" "=f")
  3013.     (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
  3014.   "TARGET_FPU"
  3015.   "fstoi %1,%0"
  3016.   [(set_attr "type" "fp")])
  3017.  
  3018. (define_insn "fix_truncdfsi2"
  3019.   [(set (match_operand:SI 0 "register_operand" "=f")
  3020.     (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
  3021.   "TARGET_FPU"
  3022.   "fdtoi %1,%0"
  3023.   [(set_attr "type" "fp")])
  3024.  
  3025. (define_insn "fix_trunctfsi2"
  3026.   [(set (match_operand:SI 0 "register_operand" "=f")
  3027.     (fix:SI (fix:TF (match_operand:TF 1 "register_operand" "f"))))]
  3028.   "TARGET_FPU && TARGET_HARD_QUAD"
  3029.   "fqtoi %1,%0"
  3030.   [(set_attr "type" "fp")])
  3031.  
  3032. ;; Now the same, for 64-bit targets
  3033. ;; ??? We try to work around an interesting problem.
  3034. ;; If gcc tries to do a subreg on the result it will get the wrong answer:
  3035. ;; "(subreg:SI (reg:DI M int-reg) 0)" is the same as
  3036. ;; "(subreg:SI (reg:DI N float-reg) 1)", but gcc does not know how to change
  3037. ;; the "0" to a "1".  One could enhance alter_subreg but it is not clear how to
  3038. ;; do this cleanly.
  3039.  
  3040. (define_expand "fix_truncsfdi2"
  3041.   [(parallel [(set (match_operand:DI 0 "general_operand" "")
  3042.            (fix:DI (fix:SF (match_operand:SF 1 "register_operand" ""))))
  3043.           (clobber (match_dup 2))
  3044.           (clobber (match_dup 3))])]
  3045.   "TARGET_V9 && TARGET_FPU"
  3046.   "
  3047. {
  3048.   operands[2] = gen_reg_rtx (DFmode);
  3049.   operands[3] = sparc64_fpconv_stack_temp ();
  3050. }")
  3051.  
  3052. (define_expand "fix_truncdfdi2"
  3053.   [(parallel [(set (match_operand:DI 0 "general_operand" "")
  3054.            (fix:DI (fix:DF (match_operand:DF 1 "register_operand" ""))))
  3055.           (clobber (match_dup 2))
  3056.           (clobber (match_dup 3))])]
  3057.   "TARGET_V9 && TARGET_FPU"
  3058.   "
  3059. {
  3060.   operands[2] = gen_reg_rtx (DFmode);
  3061.   operands[3] = sparc64_fpconv_stack_temp ();
  3062. }")
  3063.  
  3064. (define_expand "fix_trunctfdi2"
  3065.   [(parallel [(set (match_operand:DI 0 "general_operand" "")
  3066.            (fix:DI (fix:TF (match_operand:TF 1 "register_operand" ""))))
  3067.           (clobber (match_dup 2))
  3068.           (clobber (match_dup 3))])]
  3069.   "TARGET_V9 && TARGET_FPU && TARGET_HARD_QUAD"
  3070.   "
  3071. {
  3072.   operands[2] = gen_reg_rtx (DFmode);
  3073.   operands[3] = sparc64_fpconv_stack_temp ();
  3074. }")
  3075.  
  3076. (define_insn ""
  3077.   [(parallel [(set (match_operand:DI 0 "general_operand" "=rm")
  3078.            (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))
  3079.           (clobber (match_operand:DF 2 "register_operand" "=&f"))
  3080.           (clobber (match_operand:DI 3 "memory_operand" "m"))])]
  3081.   "TARGET_V9 && TARGET_FPU"
  3082.   "*
  3083. {
  3084.   output_asm_insn (\"fstox %1,%2\", operands);
  3085.   if (GET_CODE (operands[0]) == MEM)
  3086.     return \"std %2,%0\";
  3087.   else
  3088.     return \"std %2,%3\;ldx %3,%0\";
  3089. }"
  3090.   [(set_attr "type" "fp")
  3091.    (set_attr "length" "3")])
  3092.  
  3093. (define_insn ""
  3094.   [(parallel [(set (match_operand:DI 0 "general_operand" "=rm")
  3095.            (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
  3096.           (clobber (match_operand:DF 2 "register_operand" "=&f"))
  3097.           (clobber (match_operand:DI 3 "memory_operand" "m"))])]
  3098.   "TARGET_V9 && TARGET_FPU"
  3099.   "*
  3100. {
  3101.   output_asm_insn (\"fdtox %1,%2\", operands);
  3102.   if (GET_CODE (operands[0]) == MEM)
  3103.     return \"std %2,%0\";
  3104.   else
  3105.     return \"std %2,%3\;ldx %3,%0\";
  3106. }"
  3107.   [(set_attr "type" "fp")
  3108.    (set_attr "length" "3")])
  3109.  
  3110. (define_insn ""
  3111.   [(parallel [(set (match_operand:DI 0 "general_operand" "=rm")
  3112.            (fix:DI (fix:TF (match_operand:TF 1 "register_operand" "f"))))
  3113.           (clobber (match_operand:DF 2 "register_operand" "=&f"))
  3114.           (clobber (match_operand:DI 3 "memory_operand" "m"))])]
  3115.   "TARGET_V9 && TARGET_FPU && TARGET_HARD_QUAD"
  3116.   "*
  3117. {
  3118.   output_asm_insn (\"fqtox %1,%2\", operands);
  3119.   if (GET_CODE (operands[0]) == MEM)
  3120.     return \"std %2,%0\";
  3121.   else
  3122.     return \"std %2,%3\;ldx %3,%0\";
  3123. }"
  3124.   [(set_attr "type" "fp")
  3125.    (set_attr "length" "3")])
  3126.  
  3127. ;; ??? Ideally, these are what we would like to use.
  3128.  
  3129. (define_insn "fix_truncsfdi2_v9"
  3130.   [(set (match_operand:DI 0 "register_operand" "=f")
  3131.     (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
  3132.   "0 && TARGET_V9 && TARGET_FPU"
  3133.   "fstox %1,%0"
  3134.   [(set_attr "type" "fp")])
  3135.  
  3136. (define_insn "fix_truncdfdi2_v9"
  3137.   [(set (match_operand:DI 0 "register_operand" "=f")
  3138.     (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
  3139.   "0 && TARGET_V9 && TARGET_FPU"
  3140.   "fdtox %1,%0"
  3141.   [(set_attr "type" "fp")])
  3142.  
  3143. (define_insn "fix_trunctfdi2_v9"
  3144.   [(set (match_operand:DI 0 "register_operand" "=f")
  3145.     (fix:DI (fix:TF (match_operand:TF 1 "register_operand" "f"))))]
  3146.   "0 && TARGET_V9 && TARGET_FPU && TARGET_HARD_QUAD"
  3147.   "fqtox %1,%0"
  3148.   [(set_attr "type" "fp")])
  3149.  
  3150. ;;- arithmetic instructions
  3151.  
  3152. (define_expand "adddi3"
  3153.   [(set (match_operand:DI 0 "register_operand" "=r")
  3154.     (plus:DI (match_operand:DI 1 "arith_double_operand" "%r")
  3155.          (match_operand:DI 2 "arith_double_operand" "rHI")))]
  3156.   ""
  3157.   "
  3158. {
  3159.   if (! TARGET_V9)
  3160.     {
  3161.       emit_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2,
  3162.               gen_rtx (SET, VOIDmode, operands[0],
  3163.                    gen_rtx (PLUS, DImode, operands[1],
  3164.                           operands[2])),
  3165.               gen_rtx (CLOBBER, VOIDmode, gen_rtx (REG, SImode, 0)))));
  3166.       DONE;
  3167.     }
  3168. }")
  3169.  
  3170. (define_insn ""
  3171.   [(set (match_operand:DI 0 "register_operand" "=r")
  3172.     (plus:DI (match_operand:DI 1 "arith_double_operand" "%r")
  3173.          (match_operand:DI 2 "arith_double_operand" "rHI")))
  3174.    (clobber (reg:SI 0))]
  3175.   "! TARGET_V9"
  3176.   "*
  3177. {
  3178.   rtx op2 = operands[2];
  3179.  
  3180.   /* If constant is positive, upper bits zeroed, otherwise unchanged.
  3181.      Give the assembler a chance to pick the move instruction. */
  3182.   if (GET_CODE (op2) == CONST_INT)
  3183.     {
  3184.       int sign = INTVAL (op2);
  3185.       if (sign < 0)
  3186.     return \"addcc %R1,%2,%R0\;addx %1,-1,%0\";
  3187.       return \"addcc %R1,%2,%R0\;addx %1,0,%0\";
  3188.     }
  3189.   else if (GET_CODE (op2) == CONST_DOUBLE)
  3190.     {
  3191.       rtx xoperands[4];
  3192.       xoperands[0] = operands[0];
  3193.       xoperands[1] = operands[1];
  3194.       xoperands[2] = GEN_INT (CONST_DOUBLE_LOW (op2));
  3195.       xoperands[3] = GEN_INT (CONST_DOUBLE_HIGH (op2));
  3196.       if (xoperands[2] == const0_rtx && xoperands[0] == xoperands[1])
  3197.     output_asm_insn (\"add %1,%3,%0\", xoperands);
  3198.       else
  3199.     output_asm_insn (\"addcc %R1,%2,%R0\;addx %1,%3,%0\", xoperands);
  3200.       return \"\";
  3201.     }
  3202.   return \"addcc %R1,%R2,%R0\;addx %1,%2,%0\";
  3203. }"
  3204.   [(set_attr "length" "2")])
  3205.  
  3206. (define_insn ""
  3207.   [(set (match_operand:DI 0 "register_operand" "=r")
  3208.     (plus:DI (match_operand:DI 1 "arith_double_operand" "%r")
  3209.          (match_operand:DI 2 "arith_double_operand" "rHI")))]
  3210.   "TARGET_V9"
  3211.   "add %1,%2,%0")
  3212.  
  3213. (define_insn "addsi3"
  3214.   [(set (match_operand:SI 0 "register_operand" "=r")
  3215.     (plus:SI (match_operand:SI 1 "arith_operand" "%r")
  3216.          (match_operand:SI 2 "arith_operand" "rI")))]
  3217.   ""
  3218.   "add %1,%2,%0"
  3219.   [(set_attr "type" "ialu")])
  3220.  
  3221. (define_insn ""
  3222.   [(set (reg:CC_NOOV 0)
  3223.     (compare:CC_NOOV (plus:SI (match_operand:SI 0 "arith_operand" "%r")
  3224.                   (match_operand:SI 1 "arith_operand" "rI"))
  3225.              (const_int 0)))]
  3226.   ""
  3227.   "addcc %0,%1,%%g0"
  3228.   [(set_attr "type" "compare")])
  3229.  
  3230. (define_insn ""
  3231.   [(set (reg:CCX_NOOV 0)
  3232.     (compare:CCX_NOOV (plus:DI (match_operand:DI 0 "arith_double_operand" "%r")
  3233.                    (match_operand:DI 1 "arith_double_operand" "rHI"))
  3234.               (const_int 0)))]
  3235.   "TARGET_V9"
  3236.   "addcc %0,%1,%%g0"
  3237.   [(set_attr "type" "compare")])
  3238.  
  3239. (define_insn ""
  3240.   [(set (reg:CC_NOOV 0)
  3241.     (compare:CC_NOOV (plus:SI (match_operand:SI 1 "arith_operand" "%r")
  3242.                   (match_operand:SI 2 "arith_operand" "rI"))
  3243.              (const_int 0)))
  3244.    (set (match_operand:SI 0 "register_operand" "=r")
  3245.     (plus:SI (match_dup 1) (match_dup 2)))]
  3246.   ""
  3247.   "addcc %1,%2,%0")
  3248.  
  3249. (define_insn ""
  3250.   [(set (reg:CCX_NOOV 0)
  3251.     (compare:CCX_NOOV (plus:DI (match_operand:DI 1 "arith_double_operand" "%r")
  3252.                    (match_operand:DI 2 "arith_double_operand" "rHI"))
  3253.               (const_int 0)))
  3254.    (set (match_operand:DI 0 "register_operand" "=r")
  3255.     (plus:DI (match_dup 1) (match_dup 2)))]
  3256.   "TARGET_V9"
  3257.   "addcc %1,%2,%0")
  3258.  
  3259. (define_expand "subdi3"
  3260.   [(set (match_operand:DI 0 "register_operand" "=r")
  3261.     (minus:DI (match_operand:DI 1 "register_operand" "r")
  3262.           (match_operand:DI 2 "arith_double_operand" "rHI")))]
  3263.   ""
  3264.   "
  3265. {
  3266.   if (! TARGET_V9)
  3267.     {
  3268.       emit_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2,
  3269.               gen_rtx (SET, VOIDmode, operands[0],
  3270.                    gen_rtx (MINUS, DImode, operands[1],
  3271.                            operands[2])),
  3272.               gen_rtx (CLOBBER, VOIDmode, gen_rtx (REG, SImode, 0)))));
  3273.       DONE;
  3274.     }
  3275. }")
  3276.  
  3277. (define_insn ""
  3278.   [(set (match_operand:DI 0 "register_operand" "=r")
  3279.     (minus:DI (match_operand:DI 1 "register_operand" "r")
  3280.           (match_operand:DI 2 "arith_double_operand" "rHI")))
  3281.    (clobber (reg:SI 0))]
  3282.   "! TARGET_V9"
  3283.   "*
  3284. {
  3285.   rtx op2 = operands[2];
  3286.  
  3287.   /* If constant is positive, upper bits zeroed, otherwise unchanged.
  3288.      Give the assembler a chance to pick the move instruction. */
  3289.   if (GET_CODE (op2) == CONST_INT)
  3290.     {
  3291.       int sign = INTVAL (op2);
  3292.       if (sign < 0)
  3293.     return \"subcc %R1,%2,%R0\;subx %1,-1,%0\";
  3294.       return \"subcc %R1,%2,%R0\;subx %1,0,%0\";
  3295.     }
  3296.   else if (GET_CODE (op2) == CONST_DOUBLE)
  3297.     {
  3298.       rtx xoperands[4];
  3299.       xoperands[0] = operands[0];
  3300.       xoperands[1] = operands[1];
  3301.       xoperands[2] = GEN_INT (CONST_DOUBLE_LOW (op2));
  3302.       xoperands[3] = GEN_INT (CONST_DOUBLE_HIGH (op2));
  3303.       if (xoperands[2] == const0_rtx && xoperands[0] == xoperands[1])
  3304.     output_asm_insn (\"sub %1,%3,%0\", xoperands);
  3305.       else
  3306.     output_asm_insn (\"subcc %R1,%2,%R0\;subx %1,%3,%0\", xoperands);
  3307.       return \"\";
  3308.     }
  3309.   return \"subcc %R1,%R2,%R0\;subx %1,%2,%0\";
  3310. }"
  3311.   [(set_attr "length" "2")])
  3312.  
  3313. (define_insn ""
  3314.   [(set (match_operand:DI 0 "register_operand" "=r")
  3315.     (minus:DI (match_operand:DI 1 "register_operand" "r")
  3316.           (match_operand:DI 2 "arith_double_operand" "rHI")))]
  3317.   "TARGET_V9"
  3318.   "sub %1,%2,%0")
  3319.  
  3320. (define_insn "subsi3"
  3321.   [(set (match_operand:SI 0 "register_operand" "=r")
  3322.     (minus:SI (match_operand:SI 1 "register_operand" "r")
  3323.           (match_operand:SI 2 "arith_operand" "rI")))]
  3324.   ""
  3325.   "sub %1,%2,%0"
  3326.   [(set_attr "type" "ialu")])
  3327.  
  3328. (define_insn ""
  3329.   [(set (reg:CC_NOOV 0)
  3330.     (compare:CC_NOOV (minus:SI (match_operand:SI 0 "register_operand" "r")
  3331.                    (match_operand:SI 1 "arith_operand" "rI"))
  3332.              (const_int 0)))]
  3333.   ""
  3334.   "subcc %0,%1,%%g0"
  3335.   [(set_attr "type" "compare")])
  3336.  
  3337. (define_insn ""
  3338.   [(set (reg:CCX_NOOV 0)
  3339.     (compare:CCX_NOOV (minus:DI (match_operand:DI 0 "register_operand" "r")
  3340.                     (match_operand:DI 1 "arith_double_operand" "rHI"))
  3341.               (const_int 0)))]
  3342.   "TARGET_V9"
  3343.   "subcc %0,%1,%%g0"
  3344.   [(set_attr "type" "compare")])
  3345.  
  3346. (define_insn ""
  3347.   [(set (reg:CC_NOOV 0)
  3348.     (compare:CC_NOOV (minus:SI (match_operand:SI 1 "register_operand" "r")
  3349.                    (match_operand:SI 2 "arith_operand" "rI"))
  3350.              (const_int 0)))
  3351.    (set (match_operand:SI 0 "register_operand" "=r")
  3352.     (minus:SI (match_dup 1) (match_dup 2)))]
  3353.   ""
  3354.   "subcc %1,%2,%0")
  3355.  
  3356. (define_insn ""
  3357.   [(set (reg:CCX_NOOV 0)
  3358.     (compare:CCX_NOOV (minus:DI (match_operand:DI 1 "register_operand" "r")
  3359.                     (match_operand:DI 2 "arith_double_operand" "rHI"))
  3360.               (const_int 0)))
  3361.    (set (match_operand:DI 0 "register_operand" "=r")
  3362.     (minus:DI (match_dup 1) (match_dup 2)))]
  3363.   "TARGET_V9"
  3364.   "subcc %1,%2,%0")
  3365.  
  3366. ;; This is anachronistic, and should not be used in v9 software.
  3367. ;; The v9 compiler will widen the args and use muldi3.
  3368.  
  3369. (define_insn "mulsi3"
  3370.   [(set (match_operand:SI 0 "register_operand" "=r")
  3371.     (mult:SI (match_operand:SI 1 "arith_operand" "%r")
  3372.          (match_operand:SI 2 "arith_operand" "rI")))]
  3373.   "TARGET_V8 || TARGET_SPARCLITE"
  3374.   "smul %1,%2,%0"
  3375.   [(set_attr "type" "imul")])
  3376.  
  3377. (define_insn "muldi3"
  3378.   [(set (match_operand:DI 0 "register_operand" "=r")
  3379.     (mult:DI (match_operand:DI 1 "arith_double_operand" "%r")
  3380.          (match_operand:DI 2 "arith_double_operand" "rHI")))]
  3381.   "TARGET_V9"
  3382.   "mulx %1,%2,%0")
  3383.  
  3384. ;; It is not known whether this will match.
  3385.  
  3386. (define_insn ""
  3387.   [(set (match_operand:SI 0 "register_operand" "=r")
  3388.     (mult:SI (match_operand:SI 1 "arith_operand" "%r")
  3389.          (match_operand:SI 2 "arith_operand" "rI")))
  3390.    (set (reg:CC_NOOV 0)
  3391.     (compare:CC_NOOV (mult:SI (match_dup 1) (match_dup 2))
  3392.              (const_int 0)))]
  3393.   "TARGET_V8 || TARGET_SPARCLITE"
  3394.   "smulcc %1,%2,%0"
  3395.   [(set_attr "type" "imul")])
  3396.  
  3397. (define_expand "mulsidi3"
  3398.   [(set (match_operand:DI 0 "register_operand" "")
  3399.     (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
  3400.          (sign_extend:DI (match_operand:SI 2 "arith_operand" ""))))]
  3401.   "TARGET_V8 || TARGET_SPARCLITE"
  3402.   "
  3403. {
  3404.   if (CONSTANT_P (operands[2]))
  3405.     {
  3406.       emit_insn (gen_const_mulsidi3 (operands[0], operands[1], operands[2]));
  3407.       DONE;
  3408.     }
  3409. }")
  3410.  
  3411. (define_insn ""
  3412.   [(set (match_operand:DI 0 "register_operand" "=r")
  3413.     (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
  3414.          (sign_extend:DI (match_operand:SI 2 "register_operand" "r"))))]
  3415.   "TARGET_V8 || TARGET_SPARCLITE"
  3416.   "smul %1,%2,%R0\;rd %%y,%0"
  3417.   [(set_attr "length" "2")])
  3418.  
  3419. ;; Extra pattern, because sign_extend of a constant isn't legal.
  3420.  
  3421. (define_insn "const_mulsidi3"
  3422.   [(set (match_operand:DI 0 "register_operand" "=r")
  3423.     (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
  3424.          (match_operand:SI 2 "small_int" "I")))]
  3425.   "TARGET_V8 || TARGET_SPARCLITE"
  3426.   "smul %1,%2,%R0\;rd %%y,%0"
  3427.   [(set_attr "length" "2")])
  3428.  
  3429. (define_expand "smulsi3_highpart"
  3430.   [(set (match_operand:SI 0 "register_operand" "")
  3431.     (truncate:SI
  3432.      (lshiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
  3433.                    (sign_extend:DI (match_operand:SI 2 "arith_operand" "")))
  3434.               (const_int 32))))]
  3435.   "TARGET_V8 || TARGET_SPARCLITE"
  3436.   "
  3437. {
  3438.   if (CONSTANT_P (operands[2]))
  3439.     {
  3440.       emit_insn (gen_const_smulsi3_highpart (operands[0], operands[1], operands[2]));
  3441.       DONE;
  3442.     }
  3443. }")
  3444.  
  3445. (define_insn ""
  3446.   [(set (match_operand:SI 0 "register_operand" "=r")
  3447.     (truncate:SI
  3448.      (lshiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
  3449.                    (sign_extend:DI (match_operand:SI 2 "register_operand" "r")))
  3450.               (const_int 32))))]
  3451.   "TARGET_V8 || TARGET_SPARCLITE"
  3452.   "smul %1,%2,%%g0\;rd %%y,%0"
  3453.   [(set_attr "length" "2")])
  3454.  
  3455. (define_insn "const_smulsi3_highpart"
  3456.   [(set (match_operand:SI 0 "register_operand" "=r")
  3457.     (truncate:SI
  3458.      (lshiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
  3459.                    (match_operand:SI 2 "register_operand" "r"))
  3460.               (const_int 32))))]
  3461.   "TARGET_V8 || TARGET_SPARCLITE"
  3462.   "smul %1,%2,%%g0\;rd %%y,%0"
  3463.   [(set_attr "length" "2")])
  3464.  
  3465. (define_expand "umulsidi3"
  3466.   [(set (match_operand:DI 0 "register_operand" "")
  3467.     (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
  3468.          (zero_extend:DI (match_operand:SI 2 "uns_arith_operand" ""))))]
  3469.   "TARGET_V8 || TARGET_SPARCLITE"
  3470.   "
  3471. {
  3472.   if (CONSTANT_P (operands[2]))
  3473.     {
  3474.       emit_insn (gen_const_umulsidi3 (operands[0], operands[1], operands[2]));
  3475.       DONE;
  3476.     }
  3477. }")
  3478.  
  3479. (define_insn ""
  3480.   [(set (match_operand:DI 0 "register_operand" "=r")
  3481.     (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
  3482.          (zero_extend:DI (match_operand:SI 2 "register_operand" "r"))))]
  3483.   "TARGET_V8 || TARGET_SPARCLITE"
  3484.   "umul %1,%2,%R0\;rd %%y,%0"
  3485.   [(set_attr "length" "2")])
  3486.  
  3487. ;; Extra pattern, because sign_extend of a constant isn't legal.
  3488.  
  3489. (define_insn "const_umulsidi3"
  3490.   [(set (match_operand:DI 0 "register_operand" "=r")
  3491.     (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
  3492.          (match_operand:SI 2 "uns_small_int" "")))]
  3493.   "TARGET_V8 || TARGET_SPARCLITE"
  3494.   "umul %1,%2,%R0\;rd %%y,%0"
  3495.   [(set_attr "length" "2")])
  3496.  
  3497. (define_expand "umulsi3_highpart"
  3498.   [(set (match_operand:SI 0 "register_operand" "")
  3499.     (truncate:SI
  3500.      (lshiftrt:DI (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
  3501.                    (zero_extend:DI (match_operand:SI 2 "uns_arith_operand" "")))
  3502.               (const_int 32))))]
  3503.   "TARGET_V8 || TARGET_SPARCLITE"
  3504.   "
  3505. {
  3506.   if (CONSTANT_P (operands[2]))
  3507.     {
  3508.       emit_insn (gen_const_umulsi3_highpart (operands[0], operands[1], operands[2]));
  3509.       DONE;
  3510.     }
  3511. }")
  3512.  
  3513. (define_insn ""
  3514.   [(set (match_operand:SI 0 "register_operand" "=r")
  3515.     (truncate:SI
  3516.      (lshiftrt:DI (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
  3517.                    (zero_extend:DI (match_operand:SI 2 "register_operand" "r")))
  3518.               (const_int 32))))]
  3519.   "TARGET_V8 || TARGET_SPARCLITE"
  3520.   "umul %1,%2,%%g0\;rd %%y,%0"
  3521.   [(set_attr "length" "2")])
  3522.  
  3523. (define_insn "const_umulsi3_highpart"
  3524.   [(set (match_operand:SI 0 "register_operand" "=r")
  3525.     (truncate:SI
  3526.      (lshiftrt:DI (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
  3527.                    (match_operand:SI 2 "uns_small_int" ""))
  3528.               (const_int 32))))]
  3529.   "TARGET_V8 || TARGET_SPARCLITE"
  3530.   "umul %1,%2,%%g0\;rd %%y,%0"
  3531.   [(set_attr "length" "2")])
  3532.  
  3533. ;; The architecture specifies that there must be 3 instructions between
  3534. ;; a y register write and a use of it for correct results.
  3535.  
  3536. (define_insn "divsi3"
  3537.   [(set (match_operand:SI 0 "register_operand" "=r")
  3538.     (div:SI (match_operand:SI 1 "register_operand" "r")
  3539.         (match_operand:SI 2 "arith_operand" "rI")))
  3540.    (clobber (match_scratch:SI 3 "=&r"))]
  3541.   "TARGET_V8"
  3542.   "sra %1,31,%3\;wr %%g0,%3,%%y\;nop\;nop\;nop\;sdiv %1,%2,%0"
  3543.   [(set_attr "length" "6")])
  3544.  
  3545. (define_insn "divdi3"
  3546.   [(set (match_operand:DI 0 "register_operand" "=r")
  3547.     (div:DI (match_operand:DI 1 "register_operand" "r")
  3548.         (match_operand:DI 2 "arith_double_operand" "rHI")))]
  3549.   "TARGET_V9"
  3550.   "sdivx %1,%2,%0")
  3551.  
  3552. ;; It is not known whether this will match.
  3553.  
  3554. (define_insn ""
  3555.   [(set (match_operand:SI 0 "register_operand" "=r")
  3556.     (div:SI (match_operand:SI 1 "register_operand" "r")
  3557.         (match_operand:SI 2 "arith_operand" "rI")))
  3558.    (set (reg:CC 0)
  3559.     (compare:CC (div:SI (match_dup 1) (match_dup 2))
  3560.             (const_int 0)))
  3561.    (clobber (match_scratch:SI 3 "=&r"))]
  3562.   "TARGET_V8"
  3563.   "sra %1,31,%3\;wr %%g0,%3,%%y\;nop\;nop\;nop\;sdivcc %1,%2,%0"
  3564.   [(set_attr "length" "6")])
  3565.  
  3566. (define_insn "udivsi3"
  3567.   [(set (match_operand:SI 0 "register_operand" "=r")
  3568.     (udiv:SI (match_operand:SI 1 "register_operand" "r")
  3569.         (match_operand:SI 2 "arith_operand" "rI")))]
  3570.   "TARGET_V8"
  3571.   "wr %%g0,%%g0,%%y\;nop\;nop\;nop\;udiv %1,%2,%0"
  3572.   [(set_attr "length" "5")])
  3573.  
  3574. (define_insn "udivdi3"
  3575.   [(set (match_operand:DI 0 "register_operand" "=r")
  3576.     (udiv:DI (match_operand:DI 1 "register_operand" "r")
  3577.          (match_operand:DI 2 "arith_double_operand" "rHI")))]
  3578.   "TARGET_V9"
  3579.   "udivx %1,%2,%0")
  3580.  
  3581. ;; It is not known whether this will match.
  3582.  
  3583. (define_insn ""
  3584.   [(set (match_operand:SI 0 "register_operand" "=r")
  3585.     (udiv:SI (match_operand:SI 1 "register_operand" "r")
  3586.         (match_operand:SI 2 "arith_operand" "rI")))
  3587.    (set (reg:CC 0)
  3588.     (compare:CC (udiv:SI (match_dup 1) (match_dup 2))
  3589.             (const_int 0)))]
  3590.   "TARGET_V8"
  3591.   "wr %%g0,%%g0,%%y\;nop\;nop\;nop\;udivcc %1,%2,%0"
  3592.   [(set_attr "length" "5")])
  3593.  
  3594. ;;- Boolean instructions
  3595. ;; We define DImode `and` so with DImode `not` we can get
  3596. ;; DImode `andn`.  Other combinations are possible.
  3597.  
  3598. (define_expand "anddi3"
  3599.   [(set (match_operand:DI 0 "register_operand" "")
  3600.     (and:DI (match_operand:DI 1 "arith_double_operand" "")
  3601.         (match_operand:DI 2 "arith_double_operand" "")))]
  3602.   ""
  3603.   "")
  3604.  
  3605. (define_insn ""
  3606.   [(set (match_operand:DI 0 "register_operand" "=r")
  3607.     (and:DI (match_operand:DI 1 "arith_double_operand" "%r")
  3608.         (match_operand:DI 2 "arith_double_operand" "rHI")))]
  3609.   "! TARGET_V9"
  3610.   "*
  3611. {
  3612.   rtx op2 = operands[2];
  3613.  
  3614.   /* If constant is positive, upper bits zeroed, otherwise unchanged.
  3615.      Give the assembler a chance to pick the move instruction. */
  3616.   if (GET_CODE (op2) == CONST_INT)
  3617.     {
  3618.       int sign = INTVAL (op2);
  3619.       if (sign < 0)
  3620.     return \"mov %1,%0\;and %R1,%2,%R0\";
  3621.       return \"mov 0,%0\;and %R1,%2,%R0\";
  3622.     }
  3623.   else if (GET_CODE (op2) == CONST_DOUBLE)
  3624.     {
  3625.       rtx xoperands[4];
  3626.       xoperands[0] = operands[0];
  3627.       xoperands[1] = operands[1];
  3628.       xoperands[2] = GEN_INT (CONST_DOUBLE_LOW (op2));
  3629.       xoperands[3] = GEN_INT (CONST_DOUBLE_HIGH (op2));
  3630.       /* We could optimize then operands[1] == operands[0]
  3631.      and either half of the constant is -1.  */
  3632.       output_asm_insn (\"and %R1,%2,%R0\;and %1,%3,%0\", xoperands);
  3633.       return \"\";
  3634.     }
  3635.   return \"and %1,%2,%0\;and %R1,%R2,%R0\";
  3636. }"
  3637.   [(set_attr "length" "2")])
  3638.  
  3639. (define_insn ""
  3640.   [(set (match_operand:DI 0 "register_operand" "=r")
  3641.     (and:DI (match_operand:DI 1 "arith_double_operand" "%r")
  3642.         (match_operand:DI 2 "arith_double_operand" "rHI")))]
  3643.   "TARGET_V9"
  3644.   "and %1,%2,%0")
  3645.  
  3646. (define_insn "andsi3"
  3647.   [(set (match_operand:SI 0 "register_operand" "=r")
  3648.     (and:SI (match_operand:SI 1 "arith_operand" "%r")
  3649.         (match_operand:SI 2 "arith_operand" "rI")))]
  3650.   ""
  3651.   "and %1,%2,%0"
  3652.   [(set_attr "type" "ialu")])
  3653.  
  3654. (define_split
  3655.   [(set (match_operand:SI 0 "register_operand" "")
  3656.     (and:SI (match_operand:SI 1 "register_operand" "")
  3657.         (match_operand:SI 2 "" "")))
  3658.    (clobber (match_operand:SI 3 "register_operand" ""))]
  3659.   "GET_CODE (operands[2]) == CONST_INT
  3660.    && !SMALL_INT (operands[2])
  3661.    && (INTVAL (operands[2]) & 0x3ff) == 0x3ff"
  3662.   [(set (match_dup 3) (match_dup 4))
  3663.    (set (match_dup 0) (and:SI (not:SI (match_dup 3)) (match_dup 1)))]
  3664.   "
  3665. {
  3666.   operands[4] = gen_rtx (CONST_INT, VOIDmode, ~INTVAL (operands[2]));
  3667. }")
  3668.  
  3669. (define_insn ""
  3670.   [(set (match_operand:DI 0 "register_operand" "=r")
  3671.     (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
  3672.         (match_operand:DI 2 "register_operand" "r")))]
  3673.   "! TARGET_V9"
  3674.   "andn %2,%1,%0\;andn %R2,%R1,%R0"
  3675.   [(set_attr "length" "2")])
  3676.  
  3677. (define_insn ""
  3678.   [(set (match_operand:DI 0 "register_operand" "=r")
  3679.     (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
  3680.         (match_operand:DI 2 "register_operand" "r")))]
  3681.   "TARGET_V9"
  3682.   "andn %2,%1,%0")
  3683.  
  3684. (define_insn ""
  3685.   [(set (match_operand:SI 0 "register_operand" "=r")
  3686.     (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
  3687.         (match_operand:SI 2 "register_operand" "r")))]
  3688.   ""
  3689.   "andn %2,%1,%0"
  3690.   [(set_attr "type" "ialu")])
  3691.  
  3692. (define_expand "iordi3"
  3693.   [(set (match_operand:DI 0 "register_operand" "")
  3694.     (ior:DI (match_operand:DI 1 "arith_double_operand" "")
  3695.         (match_operand:DI 2 "arith_double_operand" "")))]
  3696.   ""
  3697.   "")
  3698.  
  3699. (define_insn ""
  3700.   [(set (match_operand:DI 0 "register_operand" "=r")
  3701.     (ior:DI (match_operand:DI 1 "arith_double_operand" "%r")
  3702.         (match_operand:DI 2 "arith_double_operand" "rHI")))]
  3703.   "! TARGET_V9"
  3704.   "*
  3705. {
  3706.   rtx op2 = operands[2];
  3707.  
  3708.   /* If constant is positive, upper bits zeroed, otherwise unchanged.
  3709.      Give the assembler a chance to pick the move instruction. */
  3710.   if (GET_CODE (op2) == CONST_INT)
  3711.     {
  3712.       int sign = INTVAL (op2);
  3713.       if (sign < 0)
  3714.     return \"mov -1,%0\;or %R1,%2,%R0\";
  3715.       return \"mov %1,%0\;or %R1,%2,%R0\";
  3716.     }
  3717.   else if (GET_CODE (op2) == CONST_DOUBLE)
  3718.     {
  3719.       rtx xoperands[4];
  3720.       xoperands[0] = operands[0];
  3721.       xoperands[1] = operands[1];
  3722.       xoperands[2] = GEN_INT (CONST_DOUBLE_LOW (op2));
  3723.       xoperands[3] = GEN_INT (CONST_DOUBLE_HIGH (op2));
  3724.       /* We could optimize then operands[1] == operands[0]
  3725.      and either half of the constant is 0.  */
  3726.       output_asm_insn (\"or %R1,%2,%R0\;or %1,%3,%0\", xoperands);
  3727.       return \"\";
  3728.     }
  3729.   return \"or %1,%2,%0\;or %R1,%R2,%R0\";
  3730. }"
  3731.   [(set_attr "length" "2")])
  3732.  
  3733. (define_insn ""
  3734.   [(set (match_operand:DI 0 "register_operand" "=r")
  3735.     (ior:DI (match_operand:DI 1 "arith_double_operand" "%r")
  3736.         (match_operand:DI 2 "arith_double_operand" "rHI")))]
  3737.   "TARGET_V9"
  3738.   "or %1,%2,%0")
  3739.  
  3740. (define_insn "iorsi3"
  3741.   [(set (match_operand:SI 0 "register_operand" "=r")
  3742.     (ior:SI (match_operand:SI 1 "arith_operand" "%r")
  3743.         (match_operand:SI 2 "arith_operand" "rI")))]
  3744.   ""
  3745.   "or %1,%2,%0"
  3746.   [(set_attr "type" "ialu")])
  3747.  
  3748. (define_split
  3749.   [(set (match_operand:SI 0 "register_operand" "")
  3750.     (ior:SI (match_operand:SI 1 "register_operand" "")
  3751.         (match_operand:SI 2 "" "")))
  3752.    (clobber (match_operand:SI 3 "register_operand" ""))]
  3753.   "GET_CODE (operands[2]) == CONST_INT
  3754.    && !SMALL_INT (operands[2])
  3755.    && (INTVAL (operands[2]) & 0x3ff) == 0x3ff"
  3756.   [(set (match_dup 3) (match_dup 4))
  3757.    (set (match_dup 0) (ior:SI (not:SI (match_dup 3)) (match_dup 1)))]
  3758.   "
  3759. {
  3760.   operands[4] = gen_rtx (CONST_INT, VOIDmode, ~INTVAL (operands[2]));
  3761. }")
  3762.  
  3763. (define_insn ""
  3764.   [(set (match_operand:DI 0 "register_operand" "=r")
  3765.     (ior:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
  3766.         (match_operand:DI 2 "register_operand" "r")))]
  3767.   "! TARGET_V9"
  3768.   "orn %2,%1,%0\;orn %R2,%R1,%R0"
  3769.   [(set_attr "length" "2")])
  3770.  
  3771. (define_insn ""
  3772.   [(set (match_operand:DI 0 "register_operand" "=r")
  3773.     (ior:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
  3774.         (match_operand:DI 2 "register_operand" "r")))]
  3775.   "TARGET_V9"
  3776.   "orn %2,%1,%0")
  3777.  
  3778. (define_insn ""
  3779.   [(set (match_operand:SI 0 "register_operand" "=r")
  3780.     (ior:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
  3781.         (match_operand:SI 2 "register_operand" "r")))]
  3782.   ""
  3783.   "orn %2,%1,%0"
  3784.   [(set_attr "type" "ialu")])
  3785.  
  3786. (define_expand "xordi3"
  3787.   [(set (match_operand:DI 0 "register_operand" "")
  3788.     (xor:DI (match_operand:DI 1 "arith_double_operand" "")
  3789.         (match_operand:DI 2 "arith_double_operand" "")))]
  3790.   ""
  3791.   "")
  3792.  
  3793. (define_insn ""
  3794.   [(set (match_operand:DI 0 "register_operand" "=r")
  3795.     (xor:DI (match_operand:DI 1 "arith_double_operand" "%r")
  3796.         (match_operand:DI 2 "arith_double_operand" "rHI")))]
  3797.   "! TARGET_V9"
  3798.   "*
  3799. {
  3800.   rtx op2 = operands[2];
  3801.  
  3802.   /* If constant is positive, upper bits zeroed, otherwise unchanged.
  3803.      Give the assembler a chance to pick the move instruction. */
  3804.   if (GET_CODE (op2) == CONST_INT)
  3805.     {
  3806.       int sign = INTVAL (op2);
  3807.       if (sign < 0)
  3808.     return \"xor %1,-1,%0\;xor %R1,%2,%R0\";
  3809.       return \"mov %1,%0\;xor %R1,%2,%R0\";
  3810.     }
  3811.   else if (GET_CODE (op2) == CONST_DOUBLE)
  3812.     {
  3813.       rtx xoperands[4];
  3814.       xoperands[0] = operands[0];
  3815.       xoperands[1] = operands[1];
  3816.       xoperands[2] = GEN_INT (CONST_DOUBLE_LOW (op2));
  3817.       xoperands[3] = GEN_INT (CONST_DOUBLE_HIGH (op2));
  3818.       /* We could optimize then operands[1] == operands[0]
  3819.      and either half of the constant is 0.  */
  3820.       output_asm_insn (\"xor %R1,%2,%R0\;xor %1,%3,%0\", xoperands);
  3821.       return \"\";
  3822.     }
  3823.   return \"xor %1,%2,%0\;xor %R1,%R2,%R0\";
  3824. }"
  3825.   [(set_attr "length" "2")])
  3826.  
  3827. (define_insn ""
  3828.   [(set (match_operand:DI 0 "register_operand" "=r")
  3829.     (xor:DI (match_operand:DI 1 "arith_double_operand" "%rJ")
  3830.         (match_operand:DI 2 "arith_double_operand" "rHI")))]
  3831.   "TARGET_V9"
  3832.   "xor %r1,%2,%0")
  3833.  
  3834. (define_insn "xorsi3"
  3835.   [(set (match_operand:SI 0 "register_operand" "=r")
  3836.     (xor:SI (match_operand:SI 1 "arith_operand" "%rJ")
  3837.         (match_operand:SI 2 "arith_operand" "rI")))]
  3838.   ""
  3839.   "xor %r1,%2,%0"
  3840.   [(set_attr "type" "ialu")])
  3841.  
  3842. (define_split
  3843.   [(set (match_operand:SI 0 "register_operand" "")
  3844.     (xor:SI (match_operand:SI 1 "register_operand" "")
  3845.         (match_operand:SI 2 "" "")))
  3846.    (clobber (match_operand:SI 3 "register_operand" ""))]
  3847.   "GET_CODE (operands[2]) == CONST_INT
  3848.    && !SMALL_INT (operands[2])
  3849.    && (INTVAL (operands[2]) & 0x3ff) == 0x3ff"
  3850.   [(set (match_dup 3) (match_dup 4))
  3851.    (set (match_dup 0) (not:SI (xor:SI (match_dup 3) (match_dup 1))))]
  3852.   "
  3853. {
  3854.   operands[4] = gen_rtx (CONST_INT, VOIDmode, ~INTVAL (operands[2]));
  3855. }")
  3856.  
  3857. (define_split
  3858.   [(set (match_operand:SI 0 "register_operand" "")
  3859.     (not:SI (xor:SI (match_operand:SI 1 "register_operand" "")
  3860.             (match_operand:SI 2 "" ""))))
  3861.    (clobber (match_operand:SI 3 "register_operand" ""))]
  3862.   "GET_CODE (operands[2]) == CONST_INT
  3863.    && !SMALL_INT (operands[2])
  3864.    && (INTVAL (operands[2]) & 0x3ff) == 0x3ff"
  3865.   [(set (match_dup 3) (match_dup 4))
  3866.    (set (match_dup 0) (xor:SI (match_dup 3) (match_dup 1)))]
  3867.   "
  3868. {
  3869.   operands[4] = gen_rtx (CONST_INT, VOIDmode, ~INTVAL (operands[2]));
  3870. }")
  3871.  
  3872. ;; xnor patterns.  Note that (a ^ ~b) == (~a ^ b) == ~(a ^ b).
  3873. ;; Combine now canonicalizes to the rightmost expression.
  3874. (define_insn ""
  3875.   [(set (match_operand:DI 0 "register_operand" "=r")
  3876.     (not:DI (xor:DI (match_operand:DI 1 "register_operand" "r")
  3877.             (match_operand:DI 2 "register_operand" "r"))))]
  3878.   "! TARGET_V9"
  3879.   "xnor %1,%2,%0\;xnor %R1,%R2,%R0"
  3880.   [(set_attr "length" "2")])
  3881.  
  3882. (define_insn ""
  3883.   [(set (match_operand:DI 0 "register_operand" "=r")
  3884.     (not:DI (xor:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
  3885.             (match_operand:DI 2 "arith_double_operand" "rHI"))))]
  3886.   "TARGET_V9"
  3887.   "xnor %r1,%2,%0")
  3888.  
  3889. (define_insn ""
  3890.   [(set (match_operand:SI 0 "register_operand" "=r")
  3891.     (not:SI (xor:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
  3892.             (match_operand:SI 2 "arith_operand" "rI"))))]
  3893.   ""
  3894.   "xnor %r1,%2,%0"
  3895.   [(set_attr "type" "ialu")])
  3896.  
  3897. ;; These correspond to the above in the case where we also (or only)
  3898. ;; want to set the condition code.  
  3899.  
  3900. (define_insn ""
  3901.   [(set (reg:CC 0)
  3902.     (compare:CC
  3903.      (match_operator:SI 2 "cc_arithop"
  3904.                 [(match_operand:SI 0 "arith_operand" "%r")
  3905.                  (match_operand:SI 1 "arith_operand" "rI")])
  3906.      (const_int 0)))]
  3907.   ""
  3908.   "%A2cc %0,%1,%%g0"
  3909.   [(set_attr "type" "compare")])
  3910.  
  3911. (define_insn ""
  3912.   [(set (reg:CCX 0)
  3913.     (compare:CCX
  3914.      (match_operator:DI 2 "cc_arithop"
  3915.                 [(match_operand:DI 0 "arith_double_operand" "%r")
  3916.                  (match_operand:DI 1 "arith_double_operand" "rHI")])
  3917.      (const_int 0)))]
  3918.   "TARGET_V9"
  3919.   "%A2cc %0,%1,%%g0"
  3920.   [(set_attr "type" "compare")])
  3921.  
  3922. (define_insn ""
  3923.   [(set (reg:CC 0)
  3924.     (compare:CC
  3925.      (match_operator:SI 3 "cc_arithop"
  3926.                 [(match_operand:SI 1 "arith_operand" "%r")
  3927.                  (match_operand:SI 2 "arith_operand" "rI")])
  3928.      (const_int 0)))
  3929.    (set (match_operand:SI 0 "register_operand" "=r")
  3930.     (match_dup 3))]
  3931.   ""
  3932.   "%A3cc %1,%2,%0")
  3933.  
  3934. (define_insn ""
  3935.   [(set (reg:CCX 0)
  3936.     (compare:CCX
  3937.      (match_operator:DI 3 "cc_arithop"
  3938.                 [(match_operand:DI 1 "arith_double_operand" "%r")
  3939.                  (match_operand:DI 2 "arith_double_operand" "rHI")])
  3940.      (const_int 0)))
  3941.    (set (match_operand:DI 0 "register_operand" "=r")
  3942.     (match_dup 3))]
  3943.   "TARGET_V9"
  3944.   "%A3cc %1,%2,%0")
  3945.  
  3946. (define_insn ""
  3947.   [(set (reg:CC 0)
  3948.     (compare:CC
  3949.      (not:SI (xor:SI (match_operand:SI 0 "reg_or_0_operand" "%rJ")
  3950.              (match_operand:SI 1 "arith_operand" "rI")))
  3951.      (const_int 0)))]
  3952.   ""
  3953.   "xnorcc %r0,%1,%%g0"
  3954.   [(set_attr "type" "compare")])
  3955.  
  3956. (define_insn ""
  3957.   [(set (reg:CCX 0)
  3958.     (compare:CCX
  3959.      (not:DI (xor:DI (match_operand:DI 0 "reg_or_0_operand" "%rJ")
  3960.              (match_operand:DI 1 "arith_double_operand" "rHI")))
  3961.      (const_int 0)))]
  3962.   "TARGET_V9"
  3963.   "xnorcc %r0,%1,%%g0"
  3964.   [(set_attr "type" "compare")])
  3965.  
  3966. (define_insn ""
  3967.   [(set (reg:CC 0)
  3968.     (compare:CC
  3969.      (not:SI (xor:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
  3970.              (match_operand:SI 2 "arith_operand" "rI")))
  3971.      (const_int 0)))
  3972.    (set (match_operand:SI 0 "register_operand" "=r")
  3973.     (not:SI (xor:SI (match_dup 1) (match_dup 2))))]
  3974.   ""
  3975.   "xnorcc %r1,%2,%0")
  3976.  
  3977. (define_insn ""
  3978.   [(set (reg:CCX 0)
  3979.     (compare:CCX
  3980.      (not:DI (xor:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ")
  3981.              (match_operand:DI 2 "arith_double_operand" "rHI")))
  3982.      (const_int 0)))
  3983.    (set (match_operand:DI 0 "register_operand" "=r")
  3984.     (not:DI (xor:DI (match_dup 1) (match_dup 2))))]
  3985.   "TARGET_V9"
  3986.   "xnorcc %r1,%2,%0")
  3987.  
  3988. (define_insn ""
  3989.   [(set (reg:CC 0)
  3990.     (compare:CC
  3991.      (match_operator:SI 2 "cc_arithopn"
  3992.                 [(not:SI (match_operand:SI 0 "arith_operand" "rI"))
  3993.                  (match_operand:SI 1 "reg_or_0_operand" "rJ")])
  3994.      (const_int 0)))]
  3995.   ""
  3996.   "%B2cc %r1,%0,%%g0"
  3997.   [(set_attr "type" "compare")])
  3998.  
  3999. (define_insn ""
  4000.   [(set (reg:CCX 0)
  4001.     (compare:CCX
  4002.      (match_operator:DI 2 "cc_arithopn"
  4003.                 [(not:DI (match_operand:DI 0 "arith_double_operand" "rHI"))
  4004.                  (match_operand:DI 1 "reg_or_0_operand" "rJ")])
  4005.      (const_int 0)))]
  4006.   "TARGET_V9"
  4007.   "%B2cc %r1,%0,%%g0"
  4008.   [(set_attr "type" "compare")])
  4009.  
  4010. (define_insn ""
  4011.   [(set (reg:CC 0)
  4012.     (compare:CC
  4013.      (match_operator:SI 3 "cc_arithopn"
  4014.                 [(not:SI (match_operand:SI 1 "arith_operand" "rI"))
  4015.                  (match_operand:SI 2 "reg_or_0_operand" "rJ")])
  4016.      (const_int 0)))
  4017.    (set (match_operand:SI 0 "register_operand" "=r")
  4018.     (match_dup 3))]
  4019.   ""
  4020.   "%B3cc %r2,%1,%0")
  4021.  
  4022. (define_insn ""
  4023.   [(set (reg:CCX 0)
  4024.     (compare:CCX
  4025.      (match_operator:DI 3 "cc_arithopn"
  4026.                 [(not:DI (match_operand:DI 1 "arith_double_operand" "rHI"))
  4027.                  (match_operand:DI 2 "reg_or_0_operand" "rJ")])
  4028.      (const_int 0)))
  4029.    (set (match_operand:DI 0 "register_operand" "=r")
  4030.     (match_dup 3))]
  4031.   "TARGET_V9"
  4032.   "%B3cc %r2,%1,%0")
  4033.  
  4034. ;; We cannot use the "neg" pseudo insn because the Sun assembler
  4035. ;; does not know how to make it work for constants.
  4036.  
  4037. (define_expand "negdi2"
  4038.   [(set (match_operand:DI 0 "register_operand" "=r")
  4039.     (neg:DI (match_operand:DI 1 "register_operand" "r")))]
  4040.   ""
  4041.   "
  4042. {
  4043.   if (! TARGET_V9)
  4044.     {
  4045.       emit_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2,
  4046.               gen_rtx (SET, VOIDmode, operand0,
  4047.                    gen_rtx (NEG, DImode, operand1)),
  4048.               gen_rtx (CLOBBER, VOIDmode, gen_rtx (REG, SImode, 0)))));
  4049.       DONE;
  4050.     }
  4051. }")
  4052.  
  4053. (define_insn ""
  4054.   [(set (match_operand:DI 0 "register_operand" "=r")
  4055.     (neg:DI (match_operand:DI 1 "register_operand" "r")))
  4056.    (clobber (reg:SI 0))]
  4057.   "! TARGET_V9"
  4058.   "subcc %%g0,%R1,%R0\;subx %%g0,%1,%0"
  4059.   [(set_attr "type" "unary")
  4060.    (set_attr "length" "2")])
  4061.  
  4062. (define_insn ""
  4063.   [(set (match_operand:DI 0 "register_operand" "=r")
  4064.     (neg:DI (match_operand:DI 1 "register_operand" "r")))]
  4065.   "TARGET_V9"
  4066.   "sub %%g0,%1,%0"
  4067.   [(set_attr "type" "unary")
  4068.    (set_attr "length" "1")])
  4069.  
  4070. (define_insn "negsi2"
  4071.   [(set (match_operand:SI 0 "general_operand" "=r")
  4072.     (neg:SI (match_operand:SI 1 "arith_operand" "rI")))]
  4073.   ""
  4074.   "sub %%g0,%1,%0"
  4075.   [(set_attr "type" "unary")])
  4076.  
  4077. (define_insn ""
  4078.   [(set (reg:CC_NOOV 0)
  4079.     (compare:CC_NOOV (neg:SI (match_operand:SI 0 "arith_operand" "rI"))
  4080.              (const_int 0)))]
  4081.   ""
  4082.   "subcc %%g0,%0,%%g0"
  4083.   [(set_attr "type" "compare")])
  4084.  
  4085. (define_insn ""
  4086.   [(set (reg:CCX_NOOV 0)
  4087.     (compare:CCX_NOOV (neg:DI (match_operand:DI 0 "arith_double_operand" "rHI"))
  4088.               (const_int 0)))]
  4089.   "TARGET_V9"
  4090.   "subcc %%g0,%0,%%g0"
  4091.   [(set_attr "type" "compare")])
  4092.  
  4093. (define_insn ""
  4094.   [(set (reg:CC_NOOV 0)
  4095.     (compare:CC_NOOV (neg:SI (match_operand:SI 1 "arith_operand" "rI"))
  4096.              (const_int 0)))
  4097.    (set (match_operand:SI 0 "register_operand" "=r")
  4098.     (neg:SI (match_dup 1)))]
  4099.   ""
  4100.   "subcc %%g0,%1,%0"
  4101.   [(set_attr "type" "unary")])
  4102.  
  4103. (define_insn ""
  4104.   [(set (reg:CCX_NOOV 0)
  4105.     (compare:CCX_NOOV (neg:DI (match_operand:DI 1 "arith_double_operand" "rHI"))
  4106.               (const_int 0)))
  4107.    (set (match_operand:DI 0 "register_operand" "=r")
  4108.     (neg:DI (match_dup 1)))]
  4109.   "TARGET_V9"
  4110.   "subcc %%g0,%1,%0"
  4111.   [(set_attr "type" "unary")])
  4112.  
  4113. ;; We cannot use the "not" pseudo insn because the Sun assembler
  4114. ;; does not know how to make it work for constants.
  4115. (define_expand "one_cmpldi2"
  4116.   [(set (match_operand:DI 0 "register_operand" "")
  4117.     (not:DI (match_operand:DI 1 "register_operand" "")))]
  4118.   ""
  4119.   "")
  4120.  
  4121. (define_insn ""
  4122.   [(set (match_operand:DI 0 "register_operand" "=r")
  4123.     (not:DI (match_operand:DI 1 "register_operand" "r")))]
  4124.   "! TARGET_V9"
  4125.   "xnor %%g0,%1,%0\;xnor %%g0,%R1,%R0"
  4126.   [(set_attr "type" "unary")
  4127.    (set_attr "length" "2")])
  4128.  
  4129. (define_insn ""
  4130.   [(set (match_operand:DI 0 "register_operand" "=r")
  4131.     (not:DI (match_operand:DI 1 "arith_double_operand" "rHI")))]
  4132.   "TARGET_V9"
  4133.   "xnor %%g0,%1,%0"
  4134.   [(set_attr "type" "unary")])
  4135.  
  4136. (define_insn "one_cmplsi2"
  4137.   [(set (match_operand:SI 0 "register_operand" "=r")
  4138.     (not:SI (match_operand:SI 1 "arith_operand" "rI")))]
  4139.   ""
  4140.   "xnor %%g0,%1,%0"
  4141.   [(set_attr "type" "unary")])
  4142.  
  4143. (define_insn ""
  4144.   [(set (reg:CC 0)
  4145.     (compare:CC (not:SI (match_operand:SI 0 "arith_operand" "rI"))
  4146.             (const_int 0)))]
  4147.   ""
  4148.   "xnorcc %%g0,%0,%%g0"
  4149.   [(set_attr "type" "compare")])
  4150.  
  4151. (define_insn ""
  4152.   [(set (reg:CCX 0)
  4153.     (compare:CCX (not:DI (match_operand:DI 0 "arith_double_operand" "rHI"))
  4154.              (const_int 0)))]
  4155.   "TARGET_V9"
  4156.   "xnorcc %%g0,%0,%%g0"
  4157.   [(set_attr "type" "compare")])
  4158.  
  4159. (define_insn ""
  4160.   [(set (reg:CC 0)
  4161.     (compare:CC (not:SI (match_operand:SI 1 "arith_operand" "rI"))
  4162.             (const_int 0)))
  4163.    (set (match_operand:SI 0 "register_operand" "=r")
  4164.     (not:SI (match_dup 1)))]
  4165.   ""
  4166.   "xnorcc %%g0,%1,%0"
  4167.   [(set_attr "type" "unary")])
  4168.  
  4169. (define_insn ""
  4170.   [(set (reg:CCX 0)
  4171.     (compare:CCX (not:DI (match_operand:DI 1 "arith_double_operand" "rHI"))
  4172.             (const_int 0)))
  4173.    (set (match_operand:DI 0 "register_operand" "=r")
  4174.     (not:DI (match_dup 1)))]
  4175.   "TARGET_V9"
  4176.   "xnorcc %%g0,%1,%0"
  4177.   [(set_attr "type" "unary")])
  4178.  
  4179. ;; Floating point arithmetic instructions.
  4180.  
  4181. (define_insn "addtf3"
  4182.   [(set (match_operand:TF 0 "register_operand" "=f")
  4183.     (plus:TF (match_operand:TF 1 "register_operand" "f")
  4184.          (match_operand:TF 2 "register_operand" "f")))]
  4185.   "TARGET_FPU && TARGET_HARD_QUAD"
  4186.   "faddq %1,%2,%0"
  4187.   [(set_attr "type" "fp")])
  4188.  
  4189. (define_insn "adddf3"
  4190.   [(set (match_operand:DF 0 "register_operand" "=f")
  4191.     (plus:DF (match_operand:DF 1 "register_operand" "f")
  4192.          (match_operand:DF 2 "register_operand" "f")))]
  4193.   "TARGET_FPU"
  4194.   "faddd %1,%2,%0"
  4195.   [(set_attr "type" "fp")])
  4196.  
  4197. (define_insn "addsf3"
  4198.   [(set (match_operand:SF 0 "register_operand" "=f")
  4199.     (plus:SF (match_operand:SF 1 "register_operand" "f")
  4200.          (match_operand:SF 2 "register_operand" "f")))]
  4201.   "TARGET_FPU"
  4202.   "fadds %1,%2,%0"
  4203.   [(set_attr "type" "fp")])
  4204.  
  4205. (define_insn "subtf3"
  4206.   [(set (match_operand:TF 0 "register_operand" "=f")
  4207.     (minus:TF (match_operand:TF 1 "register_operand" "f")
  4208.           (match_operand:TF 2 "register_operand" "f")))]
  4209.   "TARGET_FPU && TARGET_HARD_QUAD"
  4210.   "fsubq %1,%2,%0"
  4211.   [(set_attr "type" "fp")])
  4212.  
  4213. (define_insn "subdf3"
  4214.   [(set (match_operand:DF 0 "register_operand" "=f")
  4215.     (minus:DF (match_operand:DF 1 "register_operand" "f")
  4216.           (match_operand:DF 2 "register_operand" "f")))]
  4217.   "TARGET_FPU"
  4218.   "fsubd %1,%2,%0"
  4219.   [(set_attr "type" "fp")])
  4220.  
  4221. (define_insn "subsf3"
  4222.   [(set (match_operand:SF 0 "register_operand" "=f")
  4223.     (minus:SF (match_operand:SF 1 "register_operand" "f")
  4224.           (match_operand:SF 2 "register_operand" "f")))]
  4225.   "TARGET_FPU"
  4226.   "fsubs %1,%2,%0"
  4227.   [(set_attr "type" "fp")])
  4228.  
  4229. (define_insn "multf3"
  4230.   [(set (match_operand:TF 0 "register_operand" "=f")
  4231.     (mult:TF (match_operand:TF 1 "register_operand" "f")
  4232.          (match_operand:TF 2 "register_operand" "f")))]
  4233.   "TARGET_FPU && TARGET_HARD_QUAD"
  4234.   "fmulq %1,%2,%0"
  4235.   [(set_attr "type" "fpmul")])
  4236.  
  4237. (define_insn "muldf3"
  4238.   [(set (match_operand:DF 0 "register_operand" "=f")
  4239.     (mult:DF (match_operand:DF 1 "register_operand" "f")
  4240.          (match_operand:DF 2 "register_operand" "f")))]
  4241.   "TARGET_FPU"
  4242.   "fmuld %1,%2,%0"
  4243.   [(set_attr "type" "fpmul")])
  4244.  
  4245. (define_insn "mulsf3"
  4246.   [(set (match_operand:SF 0 "register_operand" "=f")
  4247.     (mult:SF (match_operand:SF 1 "register_operand" "f")
  4248.          (match_operand:SF 2 "register_operand" "f")))]
  4249.   "TARGET_FPU"
  4250.   "fmuls %1,%2,%0"
  4251.   [(set_attr "type" "fpmul")])
  4252.  
  4253. (define_insn ""
  4254.   [(set (match_operand:DF 0 "register_operand" "=f")
  4255.     (mult:DF (float_extend:DF (match_operand:SF 1 "register_operand" "f"))
  4256.          (float_extend:DF (match_operand:SF 2 "register_operand" "f"))))]
  4257.   "(TARGET_V8 || TARGET_V9) && TARGET_FPU"
  4258.   "fsmuld %1,%2,%0"
  4259.   [(set_attr "type" "fpmul")])
  4260.  
  4261. (define_insn ""
  4262.   [(set (match_operand:TF 0 "register_operand" "=f")
  4263.     (mult:TF (float_extend:TF (match_operand:DF 1 "register_operand" "f"))
  4264.          (float_extend:TF (match_operand:DF 2 "register_operand" "f"))))]
  4265.   "(TARGET_V8 || TARGET_V9) && TARGET_FPU"
  4266.   "fdmulq %1,%2,%0"
  4267.   [(set_attr "type" "fpmul")])
  4268.  
  4269. ;; don't have timing for quad-prec. divide.
  4270. (define_insn "divtf3"
  4271.   [(set (match_operand:TF 0 "register_operand" "=f")
  4272.     (div:TF (match_operand:TF 1 "register_operand" "f")
  4273.         (match_operand:TF 2 "register_operand" "f")))]
  4274.   "TARGET_FPU && TARGET_HARD_QUAD"
  4275.   "fdivq %1,%2,%0"
  4276.   [(set_attr "type" "fpdivd")])
  4277.  
  4278. (define_insn "divdf3"
  4279.   [(set (match_operand:DF 0 "register_operand" "=f")
  4280.     (div:DF (match_operand:DF 1 "register_operand" "f")
  4281.         (match_operand:DF 2 "register_operand" "f")))]
  4282.   "TARGET_FPU"
  4283.   "fdivd %1,%2,%0"
  4284.   [(set_attr "type" "fpdivd")])
  4285.  
  4286. (define_insn "divsf3"
  4287.   [(set (match_operand:SF 0 "register_operand" "=f")
  4288.     (div:SF (match_operand:SF 1 "register_operand" "f")
  4289.         (match_operand:SF 2 "register_operand" "f")))]
  4290.   "TARGET_FPU"
  4291.   "fdivs %1,%2,%0"
  4292.   [(set_attr "type" "fpdivs")])
  4293.  
  4294. (define_insn "negtf2"
  4295.   [(set (match_operand:TF 0 "register_operand" "=f,f")
  4296.     (neg:TF (match_operand:TF 1 "register_operand" "0,f")))]
  4297.   "TARGET_FPU"
  4298.   "*
  4299. {
  4300.   if (TARGET_V9)
  4301.     return \"fnegd %1,%0\"; /* Can't use fnegs, won't work with upper regs.  */
  4302.   else if (which_alternative == 0)
  4303.    return \"fnegs %0,%0\";
  4304.   else
  4305.    return \"fnegs %1,%0\;fmovs %R1,%R0\;fmovs %S1,%S0\;fmovs %T1,%T0\";
  4306. }"
  4307.   [(set_attr "type" "fp")
  4308.    (set_attr_alternative "length"
  4309.      [(const_int 1)
  4310.       (if_then_else (eq_attr "arch" "arch32bit") (const_int 4) (const_int 1))])])
  4311.  
  4312. (define_insn "negdf2"
  4313.   [(set (match_operand:DF 0 "register_operand" "=f,f")
  4314.     (neg:DF (match_operand:DF 1 "register_operand" "0,f")))]
  4315.   "TARGET_FPU"
  4316.   "*
  4317. {
  4318.   if (TARGET_V9)
  4319.     return \"fnegd %1,%0\";
  4320.   else if (which_alternative == 0)
  4321.    return \"fnegs %0,%0\";
  4322.   else
  4323.    return \"fnegs %1,%0\;fmovs %R1,%R0\";
  4324. }"
  4325.   [(set_attr "type" "fp")
  4326.    (set_attr_alternative "length"
  4327.      [(const_int 1)
  4328.       (if_then_else (eq_attr "arch" "arch32bit") (const_int 2) (const_int 1))])])
  4329.  
  4330. (define_insn "negsf2"
  4331.   [(set (match_operand:SF 0 "register_operand" "=f")
  4332.     (neg:SF (match_operand:SF 1 "register_operand" "f")))]
  4333.   "TARGET_FPU"
  4334.   "fnegs %1,%0"
  4335.   [(set_attr "type" "fp")])
  4336.  
  4337. (define_insn "abstf2"
  4338.   [(set (match_operand:TF 0 "register_operand" "=f,f")
  4339.     (abs:TF (match_operand:TF 1 "register_operand" "0,f")))]
  4340.   "TARGET_FPU"
  4341.   "*
  4342. {
  4343.   if (TARGET_V9)
  4344.     return \"fabsd %1,%0\"; /* Can't use fabss, won't work with upper regs.  */
  4345.   else if (which_alternative == 0)
  4346.     return \"fabss %0,%0\";
  4347.   else
  4348.     return \"fabss %1,%0\;fmovs %R1,%R0\;fmovs %S1,%S0\;fmovs %T1,%T0\";
  4349. }"
  4350.   [(set_attr "type" "fp")
  4351.    (set_attr_alternative "length"
  4352.      [(const_int 1)
  4353.       (if_then_else (eq_attr "arch" "arch32bit") (const_int 4) (const_int 1))])])
  4354.  
  4355. (define_insn "absdf2"
  4356.   [(set (match_operand:DF 0 "register_operand" "=f,f")
  4357.     (abs:DF (match_operand:DF 1 "register_operand" "0,f")))]
  4358.   "TARGET_FPU"
  4359.   "*
  4360. {
  4361.   if (TARGET_V9)
  4362.     return \"fabsd %1,%0\";
  4363.   else if (which_alternative == 0)
  4364.     return \"fabss %0,%0\";
  4365.   else
  4366.     return \"fabss %1,%0\;fmovs %R1,%R0\";
  4367. }"
  4368.   [(set_attr "type" "fp")
  4369.    (set_attr_alternative "length"
  4370.      [(const_int 1)
  4371.       (if_then_else (eq_attr "arch" "arch32bit") (const_int 2) (const_int 1))])])
  4372.  
  4373. (define_insn "abssf2"
  4374.   [(set (match_operand:SF 0 "register_operand" "=f")
  4375.     (abs:SF (match_operand:SF 1 "register_operand" "f")))]
  4376.   "TARGET_FPU"
  4377.   "fabss %1,%0"
  4378.   [(set_attr "type" "fp")])
  4379.  
  4380. (define_insn "sqrttf2"
  4381.   [(set (match_operand:TF 0 "register_operand" "=f")
  4382.     (sqrt:TF (match_operand:TF 1 "register_operand" "f")))]
  4383.   "TARGET_FPU && TARGET_HARD_QUAD"
  4384.   "fsqrtq %1,%0"
  4385.   [(set_attr "type" "fpsqrt")])
  4386.  
  4387. (define_insn "sqrtdf2"
  4388.   [(set (match_operand:DF 0 "register_operand" "=f")
  4389.     (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
  4390.   "TARGET_FPU"
  4391.   "fsqrtd %1,%0"
  4392.   [(set_attr "type" "fpsqrt")])
  4393.  
  4394. (define_insn "sqrtsf2"
  4395.   [(set (match_operand:SF 0 "register_operand" "=f")
  4396.     (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
  4397.   "TARGET_FPU"
  4398.   "fsqrts %1,%0"
  4399.   [(set_attr "type" "fpsqrt")])
  4400.  
  4401. ;;- arithmetic shift instructions
  4402.  
  4403. (define_insn "ashlsi3"
  4404.   [(set (match_operand:SI 0 "register_operand" "=r")
  4405.     (ashift:SI (match_operand:SI 1 "register_operand" "r")
  4406.            (match_operand:SI 2 "arith_operand" "rI")))]
  4407.   ""
  4408.   "*
  4409. {
  4410.   if (GET_CODE (operands[2]) == CONST_INT
  4411.       && (unsigned) INTVAL (operands[2]) > 31)
  4412.     operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
  4413.  
  4414.   return \"sll %1,%2,%0\";
  4415. }"
  4416.   [(set_attr "type" "shift")])
  4417.  
  4418. (define_insn "ashldi3"
  4419.   [(set (match_operand:DI 0 "register_operand" "=r")
  4420.     (ashift:DI (match_operand:DI 1 "register_operand" "r")
  4421.            (match_operand:SI 2 "arith_operand" "rI")))]
  4422.   "TARGET_V9"
  4423.   "*
  4424. {
  4425.   if (GET_CODE (operands[2]) == CONST_INT
  4426.       && (unsigned) INTVAL (operands[2]) > 63)
  4427.     operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
  4428.  
  4429.   return \"sllx %1,%2,%0\";
  4430. }")
  4431.  
  4432. (define_insn ""
  4433.   [(set (reg:CC_NOOV 0)
  4434.     (compare:CC_NOOV (ashift:SI (match_operand:SI 0 "register_operand" "r")
  4435.                     (const_int 1))
  4436.              (const_int 0)))]
  4437.   ""
  4438.   "addcc %0,%0,%%g0"
  4439.   [(set_attr "type" "compare")])
  4440.  
  4441. (define_insn ""
  4442.   [(set (reg:CC_NOOV 0)
  4443.     (compare:CC_NOOV (ashift:SI (match_operand:SI 1 "register_operand" "r")
  4444.                     (const_int 1))
  4445.              (const_int 0)))
  4446.    (set (match_operand:SI 0 "register_operand" "=r")
  4447.     (ashift:SI (match_dup 1) (const_int 1)))]
  4448.   ""
  4449.   "addcc %1,%1,%0")
  4450.  
  4451. (define_insn "ashrsi3"
  4452.   [(set (match_operand:SI 0 "register_operand" "=r")
  4453.     (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
  4454.              (match_operand:SI 2 "arith_operand" "rI")))]
  4455.   ""
  4456.   "*
  4457. {
  4458.   if (GET_CODE (operands[2]) == CONST_INT
  4459.       && (unsigned) INTVAL (operands[2]) > 31)
  4460.     operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
  4461.  
  4462.   return \"sra %1,%2,%0\";
  4463. }"
  4464.   [(set_attr "type" "shift")])
  4465.  
  4466. (define_insn "ashrdi3"
  4467.   [(set (match_operand:DI 0 "register_operand" "=r")
  4468.     (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
  4469.              (match_operand:SI 2 "arith_operand" "rI")))]
  4470.   "TARGET_V9"
  4471.   "*
  4472. {
  4473.   if (GET_CODE (operands[2]) == CONST_INT
  4474.       && (unsigned) INTVAL (operands[2]) > 63)
  4475.     operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
  4476.  
  4477.   return \"srax %1,%2,%0\";
  4478. }")
  4479.  
  4480. (define_insn "lshrsi3"
  4481.   [(set (match_operand:SI 0 "register_operand" "=r")
  4482.     (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
  4483.              (match_operand:SI 2 "arith_operand" "rI")))]
  4484.   ""
  4485.   "*
  4486. {
  4487.   if (GET_CODE (operands[2]) == CONST_INT
  4488.       && (unsigned) INTVAL (operands[2]) > 31)
  4489.     operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
  4490.  
  4491.   return \"srl %1,%2,%0\";
  4492. }"
  4493.   [(set_attr "type" "shift")])
  4494.  
  4495. (define_insn "lshrdi3"
  4496.   [(set (match_operand:DI 0 "register_operand" "=r")
  4497.     (lshiftrt:DI (match_operand:DI 1 "register_operand" "r")
  4498.              (match_operand:SI 2 "arith_operand" "rI")))]
  4499.   "TARGET_V9"
  4500.   "*
  4501. {
  4502.   if (GET_CODE (operands[2]) == CONST_INT
  4503.       && (unsigned) INTVAL (operands[2]) > 63)
  4504.     operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
  4505.  
  4506.   return \"srlx %1,%2,%0\";
  4507. }")
  4508.  
  4509. ;; Unconditional and other jump instructions
  4510. ;; On the Sparc, by setting the annul bit on an unconditional branch, the
  4511. ;; following insn is never executed.  This saves us a nop.  Dbx does not
  4512. ;; handle such branches though, so we only use them when optimizing.
  4513. (define_insn "jump"
  4514.   [(set (pc) (label_ref (match_operand 0 "" "")))]
  4515.   ""
  4516.   "b%* %l0%("
  4517.   [(set_attr "type" "uncond_branch")])
  4518.  
  4519. (define_expand "tablejump"
  4520.   [(parallel [(set (pc) (match_operand 0 "register_operand" "r"))
  4521.           (use (label_ref (match_operand 1 "" "")))])]
  4522.   ""
  4523.   "
  4524. {
  4525.   if (GET_MODE (operands[0]) != Pmode)
  4526.     abort ();
  4527.  
  4528.   /* We need to use the PC value in %o7 that was set up when the address
  4529.      of the label was loaded into a register, so we need different RTL.  */
  4530.   if (flag_pic)
  4531.     {
  4532.       if (!TARGET_PTR64)
  4533.     emit_jump_insn (gen_pic_tablejump_32 (operands[0], operands[1]));
  4534.       else
  4535.     emit_jump_insn (gen_pic_tablejump_64 (operands[0], operands[1]));
  4536.       DONE;
  4537.     }
  4538. }")
  4539.  
  4540. (define_insn "pic_tablejump_32"
  4541.   [(set (pc) (match_operand:SI 0 "register_operand" "r"))
  4542.    (use (label_ref (match_operand 1 "" "")))
  4543.    (use (reg:SI 15))]
  4544.   "! TARGET_PTR64"
  4545.   "jmp %%o7+%0%#"
  4546.   [(set_attr "type" "uncond_branch")])
  4547.  
  4548. (define_insn "pic_tablejump_64"
  4549.   [(set (pc) (match_operand:DI 0 "register_operand" "r"))
  4550.    (use (label_ref (match_operand 1 "" "")))
  4551.    (use (reg:DI 15))]
  4552.   "TARGET_PTR64"
  4553.   "jmp %%o7+%0%#"
  4554.   [(set_attr "type" "uncond_branch")])
  4555.  
  4556. (define_insn ""
  4557.   [(set (pc) (match_operand:SI 0 "address_operand" "p"))
  4558.    (use (label_ref (match_operand 1 "" "")))]
  4559.   "! TARGET_PTR64"
  4560.   "jmp %a0%#"
  4561.   [(set_attr "type" "uncond_branch")])
  4562.  
  4563. (define_insn ""
  4564.   [(set (pc) (match_operand:DI 0 "address_operand" "p"))
  4565.    (use (label_ref (match_operand 1 "" "")))]
  4566.   "TARGET_PTR64"
  4567.   "jmp %a0%#"
  4568.   [(set_attr "type" "uncond_branch")])
  4569.  
  4570. (define_insn ""
  4571.   [(set (pc) (label_ref (match_operand 0 "" "")))
  4572.    (set (reg:SI 15) (label_ref (match_dup 0)))]
  4573.   "! TARGET_PTR64"
  4574.   "call %l0%#"
  4575.   [(set_attr "type" "uncond_branch")])
  4576.  
  4577. (define_insn ""
  4578.   [(set (pc) (label_ref (match_operand 0 "" "")))
  4579.    (set (reg:DI 15) (label_ref (match_dup 0)))]
  4580.   "TARGET_PTR64"
  4581.   "call %l0%#"
  4582.   [(set_attr "type" "uncond_branch")])
  4583.  
  4584. ;; This pattern recognizes the "instruction" that appears in 
  4585. ;; a function call that wants a structure value, 
  4586. ;; to inform the called function if compiled with Sun CC.
  4587. ;(define_insn ""
  4588. ;  [(match_operand:SI 0 "immediate_operand" "")]
  4589. ;  "GET_CODE (operands[0]) == CONST_INT && INTVAL (operands[0]) > 0"
  4590. ;  "unimp %0"
  4591. ;  [(set_attr "type" "marker")])
  4592.  
  4593. ;;- jump to subroutine
  4594. (define_expand "call"
  4595.   ;; Note that this expression is not used for generating RTL.
  4596.   ;; All the RTL is generated explicitly below.
  4597.   [(call (match_operand 0 "call_operand" "")
  4598.      (match_operand 3 "" "i"))]
  4599.   ;; operands[2] is next_arg_register
  4600.   ;; operands[3] is struct_value_size_rtx.
  4601.   ""
  4602.   "
  4603. {
  4604.   rtx fn_rtx, nregs_rtx;
  4605.  
  4606.    if (GET_MODE (operands[0]) != FUNCTION_MODE)
  4607.     abort ();
  4608.  
  4609.  if (GET_CODE (XEXP (operands[0], 0)) == LABEL_REF)
  4610.     {
  4611.       /* This is really a PIC sequence.  We want to represent
  4612.      it as a funny jump so it's delay slots can be filled. 
  4613.  
  4614.      ??? But if this really *is* a CALL, will not it clobber the
  4615.      call-clobbered registers?  We lose this if it is a JUMP_INSN.
  4616.      Why cannot we have delay slots filled if it were a CALL?  */
  4617.  
  4618.       if (! TARGET_V9 && INTVAL (operands[3]) > 0)
  4619.     emit_jump_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (3,
  4620.                  gen_rtx (SET, VOIDmode, pc_rtx,
  4621.                       XEXP (operands[0], 0)),
  4622.                  operands[3],
  4623.                  gen_rtx (CLOBBER, VOIDmode,
  4624.                       gen_rtx (REG, Pmode, 15)))));
  4625.       else
  4626.     emit_jump_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2,
  4627.                  gen_rtx (SET, VOIDmode, pc_rtx,
  4628.                       XEXP (operands[0], 0)),
  4629.                  gen_rtx (CLOBBER, VOIDmode,
  4630.                       gen_rtx (REG, Pmode, 15)))));
  4631.       goto finish_call;
  4632.     }
  4633.  
  4634.   fn_rtx = operands[0];
  4635.  
  4636.   /* Count the number of parameter registers being used by this call.
  4637.      if that argument is NULL, it means we are using them all, which
  4638.      means 6 on the sparc.  */
  4639. #if 0
  4640.   if (operands[2])
  4641.     nregs_rtx = gen_rtx (CONST_INT, VOIDmode, REGNO (operands[2]) - 8);
  4642.   else
  4643.     nregs_rtx = gen_rtx (CONST_INT, VOIDmode, 6);
  4644. #else
  4645.   nregs_rtx = const0_rtx;
  4646. #endif
  4647.  
  4648.   if (! TARGET_V9 && INTVAL (operands[3]) > 0)
  4649.     emit_call_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (3,
  4650.                  gen_rtx (CALL, VOIDmode, fn_rtx, nregs_rtx),
  4651.                  operands[3],
  4652.                  gen_rtx (CLOBBER, VOIDmode,
  4653.                            gen_rtx (REG, Pmode, 15)))));
  4654.   else
  4655.     emit_call_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2,
  4656.                  gen_rtx (CALL, VOIDmode, fn_rtx, nregs_rtx),
  4657.                  gen_rtx (CLOBBER, VOIDmode,
  4658.                            gen_rtx (REG, Pmode, 15)))));
  4659.  
  4660.  finish_call:
  4661. #if 0
  4662.   /* If this call wants a structure value,
  4663.      emit an unimp insn to let the called function know about this.  */
  4664.   if (! TARGET_V9 && INTVAL (operands[3]) > 0)
  4665.     {
  4666.       rtx insn = emit_insn (operands[3]);
  4667.       SCHED_GROUP_P (insn) = 1;
  4668.     }
  4669. #endif
  4670.  
  4671.   DONE;
  4672. }")
  4673.  
  4674. ;; We can't use the same pattern for these two insns, because then registers
  4675. ;; in the address may not be properly reloaded.
  4676.  
  4677. (define_insn ""
  4678.   [(call (mem:SI (match_operand:SI 0 "address_operand" "p"))
  4679.      (match_operand 1 "" ""))
  4680.    (clobber (reg:SI 15))]
  4681.   ;;- Do not use operand 1 for most machines.
  4682.   "! TARGET_PTR64"
  4683.   "*
  4684. {
  4685.   return \"call %a0,%1%#\";
  4686. }"
  4687.   [(set_attr "type" "call")])
  4688.  
  4689. (define_insn ""
  4690.   [(call (mem:SI (match_operand:SI 0 "immediate_operand" "i"))
  4691.      (match_operand 1 "" ""))
  4692.    (clobber (reg:SI 15))]
  4693.   ;;- Do not use operand 1 for most machines.
  4694.   "! TARGET_PTR64"
  4695.   "*
  4696. {
  4697.   return \"call %a0,%1%#\";
  4698. }"
  4699.   [(set_attr "type" "call")])
  4700.  
  4701. (define_insn ""
  4702.   [(call (mem:SI (match_operand:DI 0 "address_operand" "p"))
  4703.      (match_operand 1 "" ""))
  4704.    (clobber (reg:DI 15))]
  4705.   ;;- Do not use operand 1 for most machines.
  4706.   "TARGET_PTR64"
  4707.   "*
  4708. {
  4709.   return \"call %a0,%1%#\";
  4710. }"
  4711.   [(set_attr "type" "call")])
  4712.  
  4713. (define_insn ""
  4714.   [(call (mem:SI (match_operand:DI 0 "immediate_operand" "i"))
  4715.      (match_operand 1 "" ""))
  4716.    (clobber (reg:DI 15))]
  4717.   ;;- Do not use operand 1 for most machines.
  4718.   "TARGET_PTR64"
  4719.   "*
  4720. {
  4721.   return \"call %a0,%1%#\";
  4722. }"
  4723.   [(set_attr "type" "call")])
  4724.  
  4725. ;; This is a call that wants a structure value.
  4726. ;; There is no such critter for v9 (??? we may need one anyway).
  4727. (define_insn ""
  4728.   [(call (mem:SI (match_operand:SI 0 "address_operand" "p"))
  4729.      (match_operand 1 "" ""))
  4730.    (match_operand 2 "immediate_operand" "")
  4731.    (clobber (reg:SI 15))]
  4732.   ;;- Do not use operand 1 for most machines.
  4733.   "! TARGET_V9 && GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) > 0"
  4734.   "*
  4735. {
  4736.   return \"call %a0,%1\;nop\;unimp %2\";
  4737. }"
  4738.   [(set_attr "type" "call_no_delay_slot")])
  4739.  
  4740. ;; This is a call that wants a structure value.
  4741. ;; There is no such critter for v9 (??? we may need one anyway).
  4742. (define_insn ""
  4743.   [(call (mem:SI (match_operand:SI 0 "immediate_operand" "i"))
  4744.      (match_operand 1 "" ""))
  4745.    (match_operand 2 "immediate_operand" "")
  4746.    (clobber (reg:SI 15))]
  4747.   ;;- Do not use operand 1 for most machines.
  4748.   "! TARGET_V9 && GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) > 0"
  4749.   "*
  4750. {
  4751.   return \"call %a0,%1\;nop\;unimp %2\";
  4752. }"
  4753.   [(set_attr "type" "call_no_delay_slot")])
  4754.  
  4755. (define_expand "call_value"
  4756.   ;; Note that this expression is not used for generating RTL.
  4757.   ;; All the RTL is generated explicitly below.
  4758.   [(set (match_operand 0 "register_operand" "=rf")
  4759.     (call (match_operand:SI 1 "" "")
  4760.           (match_operand 4 "" "")))]
  4761.   ;; operand 2 is stack_size_rtx
  4762.   ;; operand 3 is next_arg_register
  4763.   ""
  4764.   "
  4765. {
  4766.   rtx fn_rtx, nregs_rtx;
  4767.   rtvec vec;
  4768.  
  4769.   if (GET_MODE (operands[1]) != FUNCTION_MODE)
  4770.     abort ();
  4771.  
  4772.   fn_rtx = operands[1];
  4773.  
  4774. #if 0
  4775.   if (operands[3])
  4776.     nregs_rtx = gen_rtx (CONST_INT, VOIDmode, REGNO (operands[3]) - 8);
  4777.   else
  4778.     nregs_rtx = gen_rtx (CONST_INT, VOIDmode, 6);
  4779. #else
  4780.   nregs_rtx = const0_rtx;
  4781. #endif
  4782.  
  4783.   vec = gen_rtvec (2,
  4784.            gen_rtx (SET, VOIDmode, operands[0],
  4785.                 gen_rtx (CALL, VOIDmode, fn_rtx, nregs_rtx)),
  4786.            gen_rtx (CLOBBER, VOIDmode, gen_rtx (REG, Pmode, 15)));
  4787.  
  4788.   emit_call_insn (gen_rtx (PARALLEL, VOIDmode, vec));
  4789.  
  4790.   DONE;
  4791. }")
  4792.  
  4793. (define_insn ""
  4794.   [(set (match_operand 0 "" "=rf")
  4795.     (call (mem:SI (match_operand:SI 1 "address_operand" "p"))
  4796.           (match_operand 2 "" "")))
  4797.    (clobber (reg:SI 15))]
  4798.   ;;- Do not use operand 2 for most machines.
  4799.   "! TARGET_PTR64"
  4800.   "*
  4801. {
  4802.   return \"call %a1,%2%#\";
  4803. }"
  4804.   [(set_attr "type" "call")])
  4805.  
  4806. (define_insn ""
  4807.   [(set (match_operand 0 "" "=rf")
  4808.     (call (mem:SI (match_operand:SI 1 "immediate_operand" "i"))
  4809.           (match_operand 2 "" "")))
  4810.    (clobber (reg:SI 15))]
  4811.   ;;- Do not use operand 2 for most machines.
  4812.   "! TARGET_PTR64"
  4813.   "*
  4814. {
  4815.   return \"call %a1,%2%#\";
  4816. }"
  4817.   [(set_attr "type" "call")])
  4818.  
  4819. (define_insn ""
  4820.   [(set (match_operand 0 "" "=rf")
  4821.     (call (mem:SI (match_operand:DI 1 "address_operand" "p"))
  4822.           (match_operand 2 "" "")))
  4823.    (clobber (reg:DI 15))]
  4824.   ;;- Do not use operand 2 for most machines.
  4825.   "TARGET_PTR64"
  4826.   "*
  4827. {
  4828.   return \"call %a1,%2%#\";
  4829. }"
  4830.   [(set_attr "type" "call")])
  4831.  
  4832. (define_insn ""
  4833.   [(set (match_operand 0 "" "=rf")
  4834.     (call (mem:SI (match_operand:DI 1 "immediate_operand" "i"))
  4835.           (match_operand 2 "" "")))
  4836.    (clobber (reg:DI 15))]
  4837.   ;;- Do not use operand 2 for most machines.
  4838.   "TARGET_PTR64"
  4839.   "*
  4840. {
  4841.   return \"call %a1,%2%#\";
  4842. }"
  4843.   [(set_attr "type" "call")])
  4844.  
  4845. (define_expand "untyped_call"
  4846.   [(parallel [(call (match_operand:SI 0 "call_operand" "")
  4847.             (const_int 0))
  4848.           (match_operand:BLK 1 "memory_operand" "")
  4849.           (match_operand 2 "" "")
  4850. ;; ??? v9: mode is wrong here.
  4851.           (clobber (reg:SI 15))])]
  4852.   ""
  4853.   "
  4854. {
  4855.   operands[1] = change_address (operands[1], DImode, XEXP (operands[1], 0));
  4856. }")
  4857.  
  4858. ;; Make a call followed by two nops in case the function being called
  4859. ;; returns a structure value and expects to skip an unimp instruction.
  4860.  
  4861. (define_insn ""
  4862.   [(call (mem:SI (match_operand:SI 0 "address_operand" "p"))
  4863.      (const_int 0))
  4864.    (match_operand:DI 1 "memory_operand" "o")
  4865.    (match_operand 2 "" "")
  4866.    (clobber (reg:SI 15))]
  4867.   "! TARGET_V9"
  4868.   "*
  4869. {
  4870.   operands[2] = adj_offsettable_operand (operands[1], 8);
  4871.   return \"call %a0,0\;nop\;nop\;std %%o0,%1\;std %%f0,%2\";
  4872. }"
  4873.   [(set_attr "type" "multi")])
  4874.  
  4875. ;; Make a call followed by two nops in case the function being called
  4876. ;; returns a structure value and expects to skip an unimp instruction.
  4877.  
  4878. (define_insn ""
  4879.   [(call (mem:SI (match_operand:SI 0 "immediate_operand" "i"))
  4880.      (const_int 0))
  4881.    (match_operand:DI 1 "memory_operand" "o")
  4882.    (match_operand 2 "" "")
  4883.    (clobber (reg:SI 15))]
  4884.   ""
  4885.   "*
  4886. {
  4887.   operands[2] = adj_offsettable_operand (operands[1], 8);
  4888.   return \"call %a0,0\;nop\;nop\;std %%o0,%1\;std %%f0,%2\";
  4889. }"
  4890.   [(set_attr "type" "multi")])
  4891.  
  4892. ;; V9 version of untyped_call.
  4893.  
  4894. (define_insn ""
  4895.   [(call (mem:SI (match_operand:DI 0 "address_operand" "p"))
  4896.      (const_int 0))
  4897.    (match_operand:DI 1 "memory_operand" "o")
  4898.    (match_operand 2 "" "")
  4899. ;; ??? Mode is wrong here, but it must match the define_expand.
  4900.    (clobber (reg:SI 15))]
  4901.   "TARGET_V9"
  4902.   "*
  4903. {
  4904.   operands[2] = adj_offsettable_operand (operands[1], 8);
  4905.   return \"call %a0,0\;nop\;stx %%o0,%1\;stq %%f0,%2\";
  4906. }"
  4907.   [(set_attr "type" "multi")])
  4908.  
  4909. (define_insn ""
  4910.   [(call (mem:SI (match_operand:DI 0 "immediate_operand" "i"))
  4911.      (const_int 0))
  4912.    (match_operand:DI 1 "memory_operand" "o")
  4913.    (match_operand 2 "" "")
  4914. ;; ??? Mode is wrong here, but it must match the define_expand.
  4915.    (clobber (reg:SI 15))]
  4916.   "TARGET_V9"
  4917.   "*
  4918. {
  4919.   operands[2] = adj_offsettable_operand (operands[1], 8);
  4920.   return \"call %a0,0\;nop\;stx %%o0,%1\;stq %%f0,%2\";
  4921. }"
  4922.   [(set_attr "type" "multi")])
  4923.  
  4924. ;; Prepare to return any type including a structure value.
  4925.  
  4926. (define_expand "untyped_return"
  4927.   [(match_operand:BLK 0 "memory_operand" "")
  4928.    (match_operand 1 "" "")]
  4929.   ""
  4930.   "
  4931. {
  4932.   rtx valreg1 = gen_rtx (REG, DImode, 24);
  4933.   rtx valreg2 = gen_rtx (REG, TARGET_V9 ? TFmode : DFmode, 32);
  4934.   rtx result = operands[0];
  4935.  
  4936.   if (! TARGET_V9)
  4937.     {
  4938.       rtx rtnreg = gen_rtx (REG, SImode, (leaf_function ? 15 : 31));
  4939.       rtx value = gen_reg_rtx (SImode);
  4940.  
  4941.       /* Fetch the instruction where we will return to and see if it's an unimp
  4942.      instruction (the most significant 10 bits will be zero).  If so,
  4943.      update the return address to skip the unimp instruction.  */
  4944.       emit_move_insn (value,
  4945.               gen_rtx (MEM, SImode, plus_constant (rtnreg, 8)));
  4946.       emit_insn (gen_lshrsi3 (value, value, GEN_INT (22)));
  4947.       emit_insn (gen_update_return (rtnreg, value));
  4948.     }
  4949.  
  4950.   /* Reload the function value registers.  */
  4951.   emit_move_insn (valreg1, change_address (result, DImode, XEXP (result, 0)));
  4952.   emit_move_insn (valreg2,
  4953.           change_address (result, TARGET_V9 ? TFmode : DFmode,
  4954.                   plus_constant (XEXP (result, 0), 8)));
  4955.  
  4956.   /* Put USE insns before the return.  */
  4957.   emit_insn (gen_rtx (USE, VOIDmode, valreg1));
  4958.   emit_insn (gen_rtx (USE, VOIDmode, valreg2));
  4959.  
  4960.   /* Construct the return.  */
  4961.   expand_null_return ();
  4962.  
  4963.   DONE;
  4964. }")
  4965.  
  4966. ;; This is a bit of a hack.  We're incrementing a fixed register (%i7),
  4967. ;; and parts of the compiler don't want to believe that the add is needed.
  4968.  
  4969. (define_insn "update_return"
  4970.   [(unspec:SI [(match_operand:SI 0 "register_operand" "r")
  4971.            (match_operand:SI 1 "register_operand" "r")] 0)]
  4972.   "! TARGET_V9"
  4973.   "cmp %1,0\;be,a .+8\;add %0,4,%0"
  4974.   [(set_attr "type" "multi")])
  4975.  
  4976. (define_insn "return"
  4977.   [(return)]
  4978.   "! TARGET_EPILOGUE"
  4979.   "* return output_return (operands);"
  4980.   [(set_attr "type" "multi")])
  4981.  
  4982. (define_insn "nop"
  4983.   [(const_int 0)]
  4984.   ""
  4985.   "nop")
  4986.  
  4987. (define_expand "indirect_jump"
  4988.   [(set (pc) (match_operand 0 "address_operand" "p"))]
  4989.   ""
  4990.   "")
  4991.  
  4992. (define_insn ""
  4993.   [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
  4994.   "! TARGET_PTR64"
  4995.  "jmp %a0%#"
  4996.  [(set_attr "type" "uncond_branch")])
  4997.  
  4998. (define_insn ""
  4999.   [(set (pc) (match_operand:DI 0 "address_operand" "p"))]
  5000.   "TARGET_PTR64"
  5001.   "jmp %a0%#"
  5002.   [(set_attr "type" "uncond_branch")])
  5003.  
  5004. ;; ??? This doesn't handle v9 yet.  It also doesn't work with -mflat.
  5005. (define_expand "nonlocal_goto"
  5006.   [(match_operand:SI 0 "general_operand" "")
  5007.    (match_operand:SI 1 "general_operand" "")
  5008.    (match_operand:SI 2 "general_operand" "")
  5009.    (match_operand:SI 3 "" "")]
  5010.   ""
  5011.   "
  5012. {
  5013.   /* Trap instruction to flush all the registers window.  */
  5014.   emit_insn (gen_flush_register_windows ());
  5015.   /* Load the fp value for the containing fn into %fp.
  5016.      This is needed because operands[2] refers to %fp.
  5017.      Virtual register instantiation fails if the virtual %fp isn't set from a
  5018.      register.  Thus we must copy operands[0] into a register if it isn't
  5019.      already one.  */
  5020.   if (GET_CODE (operands[0]) != REG)
  5021.     operands[0] = force_reg (SImode, operands[0]);
  5022.   emit_move_insn (virtual_stack_vars_rtx, operands[0]);
  5023.   /* Find the containing function's current nonlocal goto handler,
  5024.      which will do any cleanups and then jump to the label.  */
  5025.   emit_move_insn (gen_rtx (REG, SImode, 8), operands[1]);
  5026.   /* Restore %fp from stack pointer value for containing function.
  5027.      The restore insn that follows will move this to %sp,
  5028.      and reload the appropriate value into %fp.  */
  5029.   emit_move_insn (frame_pointer_rtx, operands[2]);
  5030.   /* Put in the static chain register the nonlocal label address.  */
  5031.   emit_move_insn (static_chain_rtx, operands[3]);
  5032.   /* USE of frame_pointer_rtx added for consistency; not clear if
  5033.      really needed.  */
  5034.   emit_insn (gen_rtx (USE, VOIDmode, frame_pointer_rtx));
  5035.   emit_insn (gen_rtx (USE, VOIDmode, stack_pointer_rtx));
  5036.   emit_insn (gen_rtx (USE, VOIDmode, static_chain_rtx));
  5037.   emit_insn (gen_rtx (USE, VOIDmode, gen_rtx (REG, SImode, 8)));
  5038.   /* Return, restoring reg window and jumping to goto handler.  */
  5039.   emit_insn (gen_goto_handler_and_restore ());
  5040.   DONE;
  5041. }")
  5042.  
  5043. ;; Special trap insn to flush register windows.
  5044. (define_insn "flush_register_windows"
  5045.   [(unspec_volatile [(const_int 0)] 0)]
  5046.   ""
  5047.   "* return TARGET_V9 ? \"flushw\" : \"ta 3\";"
  5048.   [(set_attr "type" "misc")])
  5049.  
  5050. (define_insn "goto_handler_and_restore"
  5051.   [(unspec_volatile [(const_int 0)] 1)]
  5052.   ""
  5053.   "jmp %%o0+0\;restore"
  5054.   [(set_attr "type" "misc")
  5055.    (set_attr "length" "2")])
  5056.  
  5057. ;; Special pattern for the FLUSH instruction.
  5058.  
  5059. (define_insn "flush"
  5060.   [(unspec_volatile [(match_operand 0 "" "")] 2)]
  5061.   ""
  5062.   "* return TARGET_V9 ? \"flush %a0\" : \"iflush %a0\";"
  5063.   [(set_attr "type" "misc")])
  5064.  
  5065. ;; find first set.
  5066.  
  5067. ;; The scan instruction searches from the most significant bit while ffs
  5068. ;; searches from the least significant bit.  The bit index and treatment of
  5069. ;; zero also differ.  It takes at least 7 instructions to get the proper
  5070. ;; result.  Here is an obvious 8 instruction seequence.
  5071.  
  5072. (define_insn "ffssi2"
  5073.   [(set (match_operand:SI 0 "register_operand" "=&r")
  5074.     (ffs:SI (match_operand:SI 1 "register_operand" "r")))
  5075.    (clobber (match_scratch:SI 2 "=&r"))]
  5076.   "TARGET_SPARCLITE"
  5077.   "sub %%g0,%1,%0\;and %0,%1,%0\;scan %0,0,%0\;mov 32,%2\;sub %2,%0,%0\;sra %0,31,%2\;and %2,31,%2\;add %2,%0,%0"
  5078.   [(set_attr "type" "multi")
  5079.    (set_attr "length" "8")])
  5080.  
  5081. ;; ??? This should be a define expand, so that the extra instruction have
  5082. ;; a chance of being optimized away.
  5083.  
  5084. (define_insn "ffsdi2"
  5085.   [(set (match_operand:DI 0 "register_operand" "=&r")
  5086.     (ffs:DI (match_operand:DI 1 "register_operand" "r")))
  5087.    (clobber (match_scratch:DI 2 "=&r"))]
  5088.   "TARGET_V9"
  5089.   "neg %1,%2\;not %2,%2\;xor %1,%2,%2\;popc %2,%0\;movrz %1,%%g0,%0"
  5090.   [(set_attr "type" "multi")
  5091.    (set_attr "length" "5")])
  5092.  
  5093. ;; Split up troublesome insns for better scheduling.  */
  5094.  
  5095. ;; The following patterns are straightforward.  They can be applied
  5096. ;; either before or after register allocation.
  5097.  
  5098. (define_split
  5099.   [(set (match_operator 0 "memop" [(match_operand:SI 1 "symbolic_operand" "")])
  5100.     (match_operand 2 "reg_or_0_operand" ""))
  5101.    (clobber (match_operand:SI 3 "register_operand" ""))]
  5102.   "! flag_pic"
  5103.   [(set (match_dup 3) (high:SI (match_dup 1)))
  5104.    (set (match_op_dup 0 [(lo_sum:SI (match_dup 3) (match_dup 1))])
  5105.     (match_dup 2))]
  5106.   "")
  5107.  
  5108. (define_split
  5109.   [(set (match_operator 0 "memop"
  5110.             [(match_operand:SI 1 "immediate_operand" "")])
  5111.     (match_operand 2 "general_operand" ""))
  5112.    (clobber (match_operand:SI 3 "register_operand" ""))]
  5113.   "flag_pic"
  5114.   [(set (match_op_dup 0 [(match_dup 1)])
  5115.     (match_dup 2))]
  5116.   "
  5117. {
  5118.   operands[1] = legitimize_pic_address (operands[1], GET_MODE (operands[0]),
  5119.                     operands[3]);
  5120. }")
  5121.  
  5122. (define_split
  5123.   [(set (match_operand 0 "register_operand" "")
  5124.     (match_operator 1 "memop"
  5125.             [(match_operand:SI 2 "immediate_operand" "")]))]
  5126.   "flag_pic"
  5127.   [(set (match_dup 0)
  5128.     (match_op_dup 1 [(match_dup 2)]))]
  5129.   "
  5130. {
  5131.   operands[2] = legitimize_pic_address (operands[2], GET_MODE (operands[1]),
  5132.                     operands[0]);
  5133. }")
  5134.  
  5135. ;; Sign- and Zero-extend operations can have symbolic memory operands.
  5136.  
  5137. (define_split
  5138.   [(set (match_operand 0 "register_operand" "")
  5139.     (match_operator 1 "extend_op"
  5140.             [(match_operator 2 "memop"
  5141.                      [(match_operand:SI 3 "immediate_operand" "")])]))]
  5142.   "flag_pic"
  5143.   [(set (match_dup 0)
  5144.     (match_op_dup 1 [(match_op_dup 2 [(match_dup 3)])]))]
  5145.   "
  5146. {
  5147.   operands[3] = legitimize_pic_address (operands[3], GET_MODE (operands[2]),
  5148.                     operands[0]);
  5149. }")
  5150.  
  5151. (define_split
  5152.   [(set (match_operand:SI 0 "register_operand" "")
  5153.     (match_operand:SI 1 "immediate_operand" ""))]
  5154.   "! flag_pic && (GET_CODE (operands[1]) == SYMBOL_REF
  5155.           || GET_CODE (operands[1]) == CONST
  5156.           || GET_CODE (operands[1]) == LABEL_REF)"
  5157.   [(set (match_dup 0) (high:SI (match_dup 1)))
  5158.    (set (match_dup 0)
  5159.     (lo_sum:SI (match_dup 0) (match_dup 1)))]
  5160.   "")
  5161.  
  5162. ;; LABEL_REFs are not modified by `legitimize_pic_address`
  5163. ;; so do not recurse infinitely in the PIC case.
  5164. (define_split
  5165.   [(set (match_operand:SI 0 "register_operand" "")
  5166.     (match_operand:SI 1 "immediate_operand" ""))]
  5167.   "flag_pic && (GET_CODE (operands[1]) == SYMBOL_REF
  5168.         || GET_CODE (operands[1]) == CONST)"
  5169.   [(set (match_dup 0) (match_dup 1))]
  5170.   "
  5171. {
  5172.   operands[1] = legitimize_pic_address (operands[1], Pmode, operands[0]);
  5173. }")
  5174.  
  5175. ;; These split sne/seq insns.  The forms of the resulting insns are 
  5176. ;; somewhat bogus, but they avoid extra patterns and show data dependency.
  5177. ;; Nothing will look at these in detail after splitting has occurred.
  5178.  
  5179. ;; ??? v9 DImode versions are missing because addc and subc use %icc.
  5180.  
  5181. (define_split
  5182.   [(set (match_operand:SI 0 "register_operand" "")
  5183.     (ne:SI (match_operand:SI 1 "register_operand" "")
  5184.            (const_int 0)))
  5185.    (clobber (reg:CC 0))]
  5186.   ""
  5187.   [(set (reg:CC_NOOV 0) (compare:CC_NOOV (neg:SI (match_dup 1))
  5188.                      (const_int 0)))
  5189.    (set (match_dup 0) (ltu:SI (reg:CC 0) (const_int 0)))]
  5190.   "")
  5191.  
  5192. (define_split
  5193.   [(set (match_operand:SI 0 "register_operand" "")
  5194.     (neg:SI (ne:SI (match_operand:SI 1 "register_operand" "")
  5195.                (const_int 0))))
  5196.    (clobber (reg:CC 0))]
  5197.   ""
  5198.   [(set (reg:CC_NOOV 0) (compare:CC_NOOV (neg:SI (match_dup 1))
  5199.                      (const_int 0)))
  5200.    (set (match_dup 0) (neg:SI (ltu:SI (reg:CC 0) (const_int 0))))]
  5201.   "")
  5202.  
  5203. (define_split
  5204.   [(set (match_operand:SI 0 "register_operand" "")
  5205.     (eq:SI (match_operand:SI 1 "register_operand" "")
  5206.            (const_int 0)))
  5207.    (clobber (reg:CC 0))]
  5208.   ""
  5209.   [(set (reg:CC_NOOV 0) (compare:CC_NOOV (neg:SI (match_dup 1))
  5210.                      (const_int 0)))
  5211.    (set (match_dup 0) (geu:SI (reg:CC 0) (const_int 0)))]
  5212.   "")
  5213.  
  5214. (define_split
  5215.   [(set (match_operand:SI 0 "register_operand" "")
  5216.     (neg:SI (eq:SI (match_operand:SI 1 "register_operand" "")
  5217.                (const_int 0))))
  5218.    (clobber (reg:CC 0))]
  5219.   ""
  5220.   [(set (reg:CC_NOOV 0) (compare:CC_NOOV (neg:SI (match_dup 1))
  5221.                      (const_int 0)))
  5222.    (set (match_dup 0) (neg:SI (geu:SI (reg:CC 0) (const_int 0))))]
  5223.   "")
  5224.  
  5225. (define_split
  5226.   [(set (match_operand:SI 0 "register_operand" "")
  5227.     (plus:SI (ne:SI (match_operand:SI 1 "register_operand" "")
  5228.             (const_int 0))
  5229.          (match_operand:SI 2 "register_operand" "")))
  5230.    (clobber (reg:CC 0))]
  5231.   ""
  5232.   [(set (reg:CC_NOOV 0) (compare:CC_NOOV (neg:SI (match_dup 1))
  5233.                      (const_int 0)))
  5234.    (set (match_dup 0) (plus:SI (ltu:SI (reg:CC 0) (const_int 0))
  5235.                    (match_dup 2)))]
  5236.   "")
  5237.  
  5238. (define_split
  5239.   [(set (match_operand:SI 0 "register_operand" "")
  5240.     (minus:SI (match_operand:SI 2 "register_operand" "")
  5241.           (ne:SI (match_operand:SI 1 "register_operand" "")
  5242.              (const_int 0))))
  5243.    (clobber (reg:CC 0))]
  5244.   ""
  5245.   [(set (reg:CC_NOOV 0) (compare:CC_NOOV (neg:SI (match_dup 1))
  5246.                      (const_int 0)))
  5247.    (set (match_dup 0) (minus:SI (match_dup 2)
  5248.                 (ltu:SI (reg:CC 0) (const_int 0))))]
  5249.   "")
  5250.  
  5251. (define_split
  5252.   [(set (match_operand:SI 0 "register_operand" "")
  5253.     (plus:SI (eq:SI (match_operand:SI 1 "register_operand" "")
  5254.             (const_int 0))
  5255.          (match_operand:SI 2 "register_operand" "")))
  5256.    (clobber (reg:CC 0))]
  5257.   ""
  5258.   [(set (reg:CC_NOOV 0) (compare:CC_NOOV (neg:SI (match_dup 1))
  5259.                      (const_int 0)))
  5260.    (set (match_dup 0) (plus:SI (geu:SI (reg:CC 0) (const_int 0))
  5261.                    (match_dup 2)))]
  5262.   "")
  5263.  
  5264. (define_split
  5265.   [(set (match_operand:SI 0 "register_operand" "")
  5266.     (minus:SI (match_operand:SI 2 "register_operand" "")
  5267.           (eq:SI (match_operand:SI 1 "register_operand" "")
  5268.              (const_int 0))))
  5269.    (clobber (reg:CC 0))]
  5270.   ""
  5271.   [(set (reg:CC_NOOV 0) (compare:CC_NOOV (neg:SI (match_dup 1))
  5272.                      (const_int 0)))
  5273.    (set (match_dup 0) (minus:SI (match_dup 2)
  5274.                 (geu:SI (reg:CC 0) (const_int 0))))]
  5275.   "")
  5276.  
  5277. ;; Peepholes go at the end.
  5278.  
  5279. ;; Optimize consecutive loads or stores into ldd and std when possible.
  5280. ;; The conditions in which we do this are very restricted and are 
  5281. ;; explained in the code for {registers,memory}_ok_for_ldd functions.
  5282.  
  5283. (define_peephole
  5284.   [(set (match_operand:SI 0 "register_operand" "=rf")
  5285.         (match_operand:SI 1 "memory_operand" ""))
  5286.    (set (match_operand:SI 2 "register_operand" "=rf")
  5287.         (match_operand:SI 3 "memory_operand" ""))]
  5288.   "! TARGET_V9
  5289.    && registers_ok_for_ldd_peep (operands[0], operands[2]) 
  5290.    && ! MEM_VOLATILE_P (operands[1]) && ! MEM_VOLATILE_P (operands[3])
  5291.    && addrs_ok_for_ldd_peep (XEXP (operands[1], 0), XEXP (operands[3], 0))" 
  5292.   "ldd %1,%0")
  5293.  
  5294. (define_peephole
  5295.   [(set (match_operand:SI 0 "memory_operand" "")
  5296.         (match_operand:SI 1 "register_operand" "rf"))
  5297.    (set (match_operand:SI 2 "memory_operand" "")
  5298.         (match_operand:SI 3 "register_operand" "rf"))]
  5299.   "! TARGET_V9
  5300.    && registers_ok_for_ldd_peep (operands[1], operands[3]) 
  5301.    && ! MEM_VOLATILE_P (operands[0]) && ! MEM_VOLATILE_P (operands[2])
  5302.    && addrs_ok_for_ldd_peep (XEXP (operands[0], 0), XEXP (operands[2], 0))"
  5303.   "std %1,%0")
  5304.  
  5305. (define_peephole
  5306.   [(set (match_operand:SF 0 "register_operand" "=fr")
  5307.         (match_operand:SF 1 "memory_operand" ""))
  5308.    (set (match_operand:SF 2 "register_operand" "=fr")
  5309.         (match_operand:SF 3 "memory_operand" ""))]
  5310.   "! TARGET_V9
  5311.    && registers_ok_for_ldd_peep (operands[0], operands[2]) 
  5312.    && ! MEM_VOLATILE_P (operands[1]) && ! MEM_VOLATILE_P (operands[3])
  5313.    && addrs_ok_for_ldd_peep (XEXP (operands[1], 0), XEXP (operands[3], 0))"
  5314.   "ldd %1,%0")
  5315.  
  5316. (define_peephole
  5317.   [(set (match_operand:SF 0 "memory_operand" "")
  5318.         (match_operand:SF 1 "register_operand" "fr"))
  5319.    (set (match_operand:SF 2 "memory_operand" "")
  5320.         (match_operand:SF 3 "register_operand" "fr"))]
  5321.   "! TARGET_V9
  5322.    && registers_ok_for_ldd_peep (operands[1], operands[3]) 
  5323.    && ! MEM_VOLATILE_P (operands[0]) && ! MEM_VOLATILE_P (operands[2])
  5324.    && addrs_ok_for_ldd_peep (XEXP (operands[0], 0), XEXP (operands[2], 0))"
  5325.   "std %1,%0")
  5326.  
  5327. (define_peephole
  5328.   [(set (match_operand:SI 0 "register_operand" "=rf")
  5329.         (match_operand:SI 1 "memory_operand" ""))
  5330.    (set (match_operand:SI 2 "register_operand" "=rf")
  5331.         (match_operand:SI 3 "memory_operand" ""))]
  5332.   "! TARGET_V9
  5333.    && registers_ok_for_ldd_peep (operands[2], operands[0]) 
  5334.    && ! MEM_VOLATILE_P (operands[3]) && ! MEM_VOLATILE_P (operands[1])
  5335.    && addrs_ok_for_ldd_peep (XEXP (operands[3], 0), XEXP (operands[1], 0))"
  5336.   "ldd %3,%2")
  5337.  
  5338. (define_peephole
  5339.   [(set (match_operand:SI 0 "memory_operand" "")
  5340.         (match_operand:SI 1 "register_operand" "rf"))
  5341.    (set (match_operand:SI 2 "memory_operand" "")
  5342.         (match_operand:SI 3 "register_operand" "rf"))]
  5343.   "! TARGET_V9
  5344.    && registers_ok_for_ldd_peep (operands[3], operands[1]) 
  5345.    && ! MEM_VOLATILE_P (operands[2]) && ! MEM_VOLATILE_P (operands[0])
  5346.    && addrs_ok_for_ldd_peep (XEXP (operands[2], 0), XEXP (operands[0], 0))" 
  5347.   "std %3,%2")
  5348.  
  5349. (define_peephole
  5350.   [(set (match_operand:SF 0 "register_operand" "=fr")
  5351.         (match_operand:SF 1 "memory_operand" ""))
  5352.    (set (match_operand:SF 2 "register_operand" "=fr")
  5353.         (match_operand:SF 3 "memory_operand" ""))]
  5354.   "! TARGET_V9
  5355.    && registers_ok_for_ldd_peep (operands[2], operands[0]) 
  5356.    && ! MEM_VOLATILE_P (operands[3]) && ! MEM_VOLATILE_P (operands[1])
  5357.    && addrs_ok_for_ldd_peep (XEXP (operands[3], 0), XEXP (operands[1], 0))"
  5358.   "ldd %3,%2")
  5359.  
  5360. (define_peephole
  5361.   [(set (match_operand:SF 0 "memory_operand" "")
  5362.         (match_operand:SF 1 "register_operand" "fr"))
  5363.    (set (match_operand:SF 2 "memory_operand" "")
  5364.         (match_operand:SF 3 "register_operand" "fr"))]
  5365.   "! TARGET_V9
  5366.    && registers_ok_for_ldd_peep (operands[3], operands[1]) 
  5367.    && ! MEM_VOLATILE_P (operands[2]) && ! MEM_VOLATILE_P (operands[0])
  5368.    && addrs_ok_for_ldd_peep (XEXP (operands[2], 0), XEXP (operands[0], 0))"
  5369.   "std %3,%2")
  5370.  
  5371. ;; Optimize the case of following a reg-reg move with a test
  5372. ;; of reg just moved.  Don't allow floating point regs for operand 0 or 1.
  5373. ;; This can result from a float to fix conversion.
  5374.  
  5375. (define_peephole
  5376.   [(set (match_operand:SI 0 "register_operand" "=r")
  5377.     (match_operand:SI 1 "register_operand" "r"))
  5378.    (set (reg:CC 0)
  5379.     (compare:CC (match_operand:SI 2 "register_operand" "r")
  5380.             (const_int 0)))]
  5381.   "(rtx_equal_p (operands[2], operands[0])
  5382.     || rtx_equal_p (operands[2], operands[1]))
  5383.    && ! FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
  5384.   "orcc %1,%%g0,%0")
  5385.  
  5386. (define_peephole
  5387.   [(set (match_operand:DI 0 "register_operand" "=r")
  5388.     (match_operand:DI 1 "register_operand" "r"))
  5389.    (set (reg:CCX 0)
  5390.     (compare:CCX (match_operand:DI 2 "register_operand" "r")
  5391.             (const_int 0)))]
  5392.   "TARGET_V9
  5393.    && (rtx_equal_p (operands[2], operands[0])
  5394.        || rtx_equal_p (operands[2], operands[1]))
  5395.    && ! FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
  5396.   "orcc %1,%%g0,%0")
  5397.  
  5398. ;; Do {sign,zero}-extended compares somewhat more efficiently.
  5399. ;; ??? Is this now the Right Way to do this?  Or will SCRATCH
  5400. ;;     eventually have some impact here?
  5401.  
  5402. (define_peephole
  5403.   [(set (match_operand:HI 0 "register_operand" "")
  5404.     (match_operand:HI 1 "memory_operand" ""))
  5405.    (set (match_operand:SI 2 "register_operand" "")
  5406.     (sign_extend:SI (match_dup 0)))
  5407.    (set (reg:CC 0)
  5408.     (compare:CC (match_dup 2)
  5409.             (const_int 0)))]
  5410.   ""
  5411.   "ldsh %1,%0\;orcc %0,%%g0,%2")
  5412.  
  5413. (define_peephole
  5414.   [(set (match_operand:HI 0 "register_operand" "")
  5415.     (match_operand:HI 1 "memory_operand" ""))
  5416.    (set (match_operand:DI 2 "register_operand" "")
  5417.     (sign_extend:DI (match_dup 0)))
  5418.    (set (reg:CCX 0)
  5419.     (compare:CCX (match_dup 2)
  5420.              (const_int 0)))]
  5421.   "TARGET_V9"
  5422.   "ldsh %1,%0\;orcc %0,%%g0,%2")
  5423.  
  5424. (define_peephole
  5425.   [(set (match_operand:QI 0 "register_operand" "")
  5426.     (match_operand:QI 1 "memory_operand" ""))
  5427.    (set (match_operand:SI 2 "register_operand" "")
  5428.     (sign_extend:SI (match_dup 0)))
  5429.    (set (reg:CC 0)
  5430.     (compare:CC (match_dup 2)
  5431.             (const_int 0)))]
  5432.   ""
  5433.   "ldsb %1,%0\;orcc %0,%%g0,%2")
  5434.  
  5435. (define_peephole
  5436.   [(set (match_operand:QI 0 "register_operand" "")
  5437.     (match_operand:QI 1 "memory_operand" ""))
  5438.    (set (match_operand:DI 2 "register_operand" "")
  5439.     (sign_extend:DI (match_dup 0)))
  5440.    (set (reg:CCX 0)
  5441.     (compare:CCX (match_dup 2)
  5442.              (const_int 0)))]
  5443.   "TARGET_V9"
  5444.   "ldsb %1,%0\;orcc %0,%%g0,%2")
  5445.  
  5446. (define_peephole
  5447.   [(set (match_operand:HI 0 "register_operand" "")
  5448.     (match_operand:HI 1 "memory_operand" ""))
  5449.    (set (match_operand:SI 2 "register_operand" "")
  5450.     (sign_extend:SI (match_dup 0)))]
  5451.   "dead_or_set_p (insn, operands[0])"
  5452.   "*
  5453. {
  5454.   warning (\"bad peephole\");
  5455.   if (! MEM_VOLATILE_P (operands[1]))
  5456.     abort ();
  5457.   return \"ldsh %1,%2\";
  5458. }")
  5459.  
  5460. (define_peephole
  5461.   [(set (match_operand:QI 0 "register_operand" "")
  5462.     (match_operand:QI 1 "memory_operand" ""))
  5463.    (set (match_operand:SI 2 "register_operand" "")
  5464.     (sign_extend:SI (match_dup 0)))]
  5465.   "dead_or_set_p (insn, operands[0])"
  5466.   "*
  5467. {
  5468.   warning (\"bad peephole\");
  5469.   if (! MEM_VOLATILE_P (operands[1]))
  5470.     abort ();
  5471.   return \"ldsb %1,%2\";
  5472. }")
  5473.  
  5474. ;; Floating-point move peepholes
  5475. ;; ??? v9: Do we want similar ones?
  5476.  
  5477. (define_peephole
  5478.   [(set (match_operand:SI 0 "register_operand" "=r")
  5479.     (lo_sum:SI (match_dup 0)
  5480.            (match_operand:SI 1 "immediate_operand" "i")))
  5481.    (set (match_operand:DF 2 "register_operand" "=fr")
  5482.     (mem:DF (match_dup 0)))]
  5483.   "RTX_UNCHANGING_P (operands[1]) && reg_unused_after (operands[0], insn)"
  5484.   "*
  5485. {
  5486.   /* Go by way of output_move_double in case the register in operand 2
  5487.      is not properly aligned for ldd.  */
  5488.   operands[1] = gen_rtx (MEM, DFmode,
  5489.              gen_rtx (LO_SUM, SImode, operands[0], operands[1]));
  5490.   operands[0] = operands[2];
  5491.   return output_move_double (operands);
  5492. }")
  5493.  
  5494. (define_peephole
  5495.   [(set (match_operand:SI 0 "register_operand" "=r")
  5496.     (lo_sum:SI (match_dup 0)
  5497.            (match_operand:SI 1 "immediate_operand" "i")))
  5498.    (set (match_operand:SF 2 "register_operand" "=fr")
  5499.     (mem:SF (match_dup 0)))]
  5500.   "RTX_UNCHANGING_P (operands[1]) && reg_unused_after (operands[0], insn)"
  5501.   "ld [%0+%%lo(%a1)],%2")
  5502.  
  5503. ;; Return peepholes.  First the "normal" ones
  5504.  
  5505. ;; ??? There are QImode, HImode, and SImode versions of this pattern.
  5506. ;; It might be possible to write one more general pattern instead of three.
  5507.  
  5508. (define_insn ""
  5509.   [(set (match_operand:QI 0 "restore_operand" "")
  5510.     (match_operand:QI 1 "arith_operand" "rI"))
  5511.    (return)]
  5512.   "! TARGET_EPILOGUE"
  5513.   "*
  5514. {
  5515.   if (! TARGET_V9 && current_function_returns_struct)
  5516.     return \"jmp %%i7+12\;restore %%g0,%1,%Y0\";
  5517.   else
  5518.     return \"ret\;restore %%g0,%1,%Y0\";
  5519. }"
  5520.   [(set_attr "type" "multi")])
  5521.  
  5522. (define_insn ""
  5523.   [(set (match_operand:HI 0 "restore_operand" "")
  5524.     (match_operand:HI 1 "arith_operand" "rI"))
  5525.    (return)]
  5526.   "! TARGET_EPILOGUE"
  5527.   "*
  5528. {
  5529.   if (! TARGET_V9 && current_function_returns_struct)
  5530.     return \"jmp %%i7+12\;restore %%g0,%1,%Y0\";
  5531.   else
  5532.     return \"ret\;restore %%g0,%1,%Y0\";
  5533. }"
  5534.   [(set_attr "type" "multi")])
  5535.  
  5536. (define_insn ""
  5537.   [(set (match_operand:SI 0 "restore_operand" "")
  5538.     (match_operand:SI 1 "arith_operand" "rI"))
  5539.    (return)]
  5540.   "! TARGET_EPILOGUE"
  5541.   "*
  5542. {
  5543.   if (! TARGET_V9 && current_function_returns_struct)
  5544.     return \"jmp %%i7+12\;restore %%g0,%1,%Y0\";
  5545.   else
  5546.     return \"ret\;restore %%g0,%1,%Y0\";
  5547. }"
  5548.   [(set_attr "type" "multi")])
  5549.  
  5550. ;; The following pattern is only generated by delayed-branch scheduling,
  5551. ;; when the insn winds up in the epilogue.  This can only happen when
  5552. ;; ! TARGET_FPU because otherwise fp return values are in %f0.
  5553. (define_insn ""
  5554.   [(set (match_operand:SF 0 "restore_operand" "r")
  5555.     (match_operand:SF 1 "register_operand" "r"))
  5556.    (return)]
  5557.   "! TARGET_FPU && ! TARGET_EPILOGUE"
  5558.   "*
  5559. {
  5560.   if (! TARGET_V9 && current_function_returns_struct)
  5561.     return \"jmp %%i7+12\;restore %%g0,%1,%Y0\";
  5562.   else
  5563.     return \"ret\;restore %%g0,%1,%Y0\";
  5564. }"
  5565.   [(set_attr "type" "multi")])
  5566.  
  5567. (define_insn ""
  5568.   [(set (match_operand:SI 0 "restore_operand" "")
  5569.     (plus:SI (match_operand:SI 1 "arith_operand" "%r")
  5570.          (match_operand:SI 2 "arith_operand" "rI")))
  5571.    (return)]
  5572.   "! TARGET_EPILOGUE"
  5573.   "*
  5574. {
  5575.   if (! TARGET_V9 && current_function_returns_struct)
  5576.     return \"jmp %%i7+12\;restore %r1,%2,%Y0\";
  5577.   else
  5578.     return \"ret\;restore %r1,%2,%Y0\";
  5579. }"
  5580.   [(set_attr "type" "multi")])
  5581.  
  5582. (define_insn ""
  5583.   [(set (match_operand:DI 0 "restore_operand" "")
  5584.     (match_operand:DI 1 "arith_double_operand" "rHI"))
  5585.    (return)]
  5586.   "TARGET_V9 && ! TARGET_EPILOGUE"
  5587.   "ret\;restore %%g0,%1,%Y0"
  5588.   [(set_attr "type" "multi")])
  5589.  
  5590. (define_insn ""
  5591.   [(set (match_operand:DI 0 "restore_operand" "")
  5592.     (plus:DI (match_operand:DI 1 "arith_operand" "%r")
  5593.          (match_operand:DI 2 "arith_double_operand" "rHI")))
  5594.    (return)]
  5595.   "TARGET_V9 && ! TARGET_EPILOGUE"
  5596.   "ret\;restore %r1,%2,%Y0"
  5597.   [(set_attr "type" "multi")])
  5598.  
  5599. ;; Turned off because it should never match (subtracting a constant
  5600. ;; is turned into addition) and because it would do the wrong thing
  5601. ;; when operand 2 is -4096 (--4096 == 4096 is not a valid immediate).
  5602. ;;(define_insn ""
  5603. ;;  [(set (match_operand:SI 0 "restore_operand" "")
  5604. ;;    (minus:SI (match_operand:SI 1 "register_operand" "r")
  5605. ;;          (match_operand:SI 2 "small_int" "I")))
  5606. ;;   (return)]
  5607. ;;  "! TARGET_EPILOGUE"
  5608. ;;  "ret\;restore %1,-(%2),%Y0"
  5609. ;;  [(set_attr "type" "multi")])
  5610.  
  5611. ;; The following pattern is only generated by delayed-branch scheduling,
  5612. ;; when the insn winds up in the epilogue.
  5613. (define_insn ""
  5614.   [(set (reg:SF 32)
  5615.     (match_operand:SF 0 "register_operand" "f"))
  5616.    (return)]
  5617.   "! TARGET_EPILOGUE"
  5618.   "ret\;fmovs %0,%%f0"
  5619.   [(set_attr "type" "multi")])
  5620.  
  5621. ;; Now peepholes to do a call followed by a jump.
  5622.  
  5623. (define_peephole
  5624.   [(parallel [(set (match_operand 0 "" "")
  5625.            (call (mem:SI (match_operand:SI 1 "call_operand_address" "pi"))
  5626.              (match_operand 2 "" "")))
  5627.           (clobber (reg:SI 15))])
  5628.    (set (pc) (label_ref (match_operand 3 "" "")))]
  5629.   "short_branch (INSN_UID (insn), INSN_UID (operands[3]))"
  5630.   "*
  5631. {
  5632.   return \"call %a1,%2\;add %%o7,(%l3-.-4),%%o7\";
  5633. }")
  5634.  
  5635. (define_peephole
  5636.   [(parallel [(call (mem:SI (match_operand:SI 0 "call_operand_address" "pi"))
  5637.             (match_operand 1 "" ""))
  5638.           (clobber (reg:SI 15))])
  5639.    (set (pc) (label_ref (match_operand 2 "" "")))]
  5640.   "short_branch (INSN_UID (insn), INSN_UID (operands[2]))"
  5641.   "*
  5642. {
  5643.   return \"call %a0,%1\;add %%o7,(%l2-.-4),%%o7\";
  5644. }")
  5645.  
  5646. (define_peephole
  5647.   [(parallel [(set (match_operand 0 "" "")
  5648.            (call (mem:SI (match_operand:DI 1 "call_operand_address" "pi"))
  5649.              (match_operand 2 "" "")))
  5650.           (clobber (reg:DI 15))])
  5651.    (set (pc) (label_ref (match_operand 3 "" "")))]
  5652.   "TARGET_V9 && short_branch (INSN_UID (insn), INSN_UID (operands[3]))"
  5653.   "*
  5654. {
  5655.   return \"call %a1,%2\;add %%o7,(%l3-.-4),%%o7\";
  5656. }")
  5657.  
  5658. (define_peephole
  5659.   [(parallel [(call (mem:SI (match_operand:DI 0 "call_operand_address" "pi"))
  5660.             (match_operand 1 "" ""))
  5661.           (clobber (reg:DI 15))])
  5662.    (set (pc) (label_ref (match_operand 2 "" "")))]
  5663.   "TARGET_V9 && short_branch (INSN_UID (insn), INSN_UID (operands[2]))"
  5664.   "*
  5665. {
  5666.   return \"call %a0,%1\;add %%o7,(%l2-.-4),%%o7\";
  5667. }")
  5668.  
  5669. ;; Other miscellaneous peepholes.
  5670.  
  5671. (define_peephole
  5672.   [(parallel [(set (match_operand:SI 0 "register_operand" "=r")
  5673.            (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
  5674.                  (reg:SI 0)))
  5675.           (clobber (reg:CC 0))])
  5676.    (set (reg:CC 0) (compare (match_dup 0) (const_int 0)))]
  5677.   ""
  5678.   "subxcc %r1,0,%0")
  5679.