home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / config / m68k / m68k.md < prev    next >
Text File  |  1996-12-21  |  208KB  |  7,160 lines

  1. ;;- Machine description for GNU compiler, Motorola 68000 Version
  2. ;;  Copyright (C) 1987, 1988, 1993, 1994, 1995 Free Software Foundation, Inc.
  3.  
  4. ;; This file is part of GNU CC.
  5.  
  6. ;; GNU CC is free software; you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation; either version 2, or (at your option)
  9. ;; any later version.
  10.  
  11. ;; GNU CC is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;; GNU General Public License for more details.
  15.  
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU CC; see the file COPYING.  If not, write to
  18. ;; the Free Software Foundation, 59 Temple Place - Suite 330,
  19. ;; Boston, MA 02111-1307, USA.
  20.  
  21.  
  22. ;; Attribute specifications
  23.  
  24. ;; Classify each instruction as to the precision control it requires.
  25. (define_attr "fppc" "none,single,double,conflict"
  26.   (cond
  27.    [(match_operand:DF 0 "" "") (const_string "double")
  28.     (match_operand:SF 0 "" "") (const_string "single")]
  29.    (const_string "none")))
  30.  
  31. ;;- instruction definitions
  32.  
  33. ;;- @@The original PO technology requires these to be ordered by speed,
  34. ;;- @@    so that assigner will pick the fastest.
  35.  
  36. ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
  37.  
  38. ;;- When naming insn's (operand 0 of define_insn) be careful about using
  39. ;;- names from other targets machine descriptions.
  40.  
  41. ;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code
  42. ;;- updates for most instructions.
  43.  
  44. ;;- Operand classes for the register allocator:
  45. ;;- 'a' one of the address registers can be used.
  46. ;;- 'd' one of the data registers can be used.
  47. ;;- 'f' one of the m68881 registers can be used
  48. ;;- 'r' either a data or an address register can be used.
  49. ;;- 'x' if one of the Sun FPA registers                    
  50. ;;- 'y' if one of the Low Sun FPA registers (fpa0-fpa15).
  51.  
  52. ;;- Immediate Floating point operator constraints
  53. ;;- 'G' a floating point constant that is *NOT* one of the standard
  54. ;;   68881 constant values (to force calling output_move_const_double
  55. ;;   to get it from rom if it is a 68881 constant).
  56. ;;- 'H' one of the standard FPA constant values
  57. ;;
  58. ;;   See the functions standard_XXX_constant_p in output-m68k.c for more
  59. ;; info.
  60.  
  61. ;;- Immediate integer operand constraints:
  62. ;;- 'I'  1 .. 8
  63. ;;- 'J'  -32768 .. 32767
  64. ;;- 'K'  all integers EXCEPT -128 .. 127
  65. ;;- 'L'  -8 .. -1
  66.  
  67. ;;- Assembler specs:
  68. ;;- "%."    size separator ("." or "")            move%.l d0,d1
  69. ;;- "%#"    immediate separator ("#" or "")        move%.l %#0,d0
  70. ;;- "%-"    push operand "sp@-"                move%.l d0,%-
  71. ;;- "%+"    pop operand "sp@+"                move%.l d0,%+
  72. ;;- "%@"    top of stack "sp@"                move%.l d0,%@
  73. ;;- "%!"    fpcr register
  74. ;;- "%$"    single-precision fp specifier ("s" or "")    f%$add.x fp0,fp1
  75. ;;- "%&"    double-precision fp specifier ("d" or "")    f%&add.x fp0,fp1
  76.  
  77. ;; UNSPEC usage:
  78. ;; 1  This is a `sin' operation.  The mode of the UNSPEC is MODE_FLOAT.
  79. ;;    operand 1 is the argument for `sin'.
  80. ;; 2  This is a `cos' operation.  The mode of the UNSPEC is MODE_FLOAT.
  81. ;;    operand 1 is the argument for `cos'.
  82.  
  83. ;;- Information about 68040 port.
  84.  
  85. ;;- The 68040 executes all 68030 and 68881/2 instructions, but some must
  86. ;;- be emulated in software by the OS.  It is faster to avoid these
  87. ;;- instructions and issue a library call rather than trapping into
  88. ;;- the kernel.  The affected instructions are fintrz and fscale.  The
  89. ;;- TARGET_68040 flag turns the use of the opcodes off.
  90.  
  91. ;;- The '040 also implements a set of new floating-point instructions
  92. ;;- which specify the rounding precision in the opcode.  This finally
  93. ;;- permit the 68k series to be truly IEEE compliant, and solves all
  94. ;;- issues of excess precision accumulating in the extended registers.
  95. ;;- By default, GCC does not use these instructions, since such code will
  96. ;;- not run on an '030.  To use these instructions, use the -m68040-only
  97. ;;- switch.  By changing TARGET_DEFAULT to include TARGET_68040_ONLY,
  98. ;;- you can make these instructions the default.
  99.  
  100. ;;- These new instructions aren't directly in the md.  They are brought
  101. ;;- into play by defining "%$" and "%&" to expand to "s" and "d" rather
  102. ;;- than "".
  103.  
  104.  
  105. ;;-         FPA port explanation:
  106.  
  107. ;;-        Usage of the Sun FPA and the 68881 together
  108.  
  109. ;;- The current port of gcc to the sun fpa disallows use of the m68881
  110. ;;- instructions completely if code is targeted for the fpa.  This is
  111. ;;- for the following reasons:
  112.  
  113. ;;- 1) Expressing the preference hierarchy (ie. use the fpa if you
  114. ;;- can, the 68881 otherwise, and data registers only if you are
  115. ;;- forced to it) is a bitch with the current constraint scheme,
  116. ;;- especially since it would have to work for any combination of
  117. ;;- -mfpa, -m68881.
  118.  
  119. ;;- 2) There are no instructions to move between the two types of
  120. ;;- registers; the stack must be used as an intermediary.
  121.  
  122. ;;- It could indeed be done; I think the best way would be to have
  123. ;;- separate patterns for TARGET_FPA (which implies a 68881),
  124. ;;- TARGET_68881, and no floating point co-processor.  Use
  125. ;;- define_expands for all of the named instruction patterns, and
  126. ;;- include code in the FPA instruction to deal with the 68881 with
  127. ;;- preferences specifically set to favor the fpa.  Some of this has
  128. ;;- already been done:
  129. ;;-
  130. ;;-     1) Separation of most of the patterns out into a TARGET_FPA
  131. ;;- case and a TARGET_68881 case (the exceptions are the patterns
  132. ;;- which would need one define_expand and three define_insn's under
  133. ;;- it (with a lot of duplicate code between them) to replace the
  134. ;;- current single define_insn.  These are mov{[ds]f,[ds]i} and the
  135. ;;- first two patterns in the md.
  136. ;;-
  137. ;;- Some would still have to be done:
  138. ;;-
  139. ;;-    1) Add code to the fpa patterns which correspond to 68881
  140. ;;- patterns to deal with the 68881 case (including preferences!).
  141. ;;- What you might actually do here is combine the fpa and 68881 code
  142. ;;- back together into one pattern for those instructions where it's
  143. ;;- absolutely necessary and save yourself some duplicate code.  I'm
  144. ;;- not completely sure as to whether you could get away with doing
  145. ;;- this only for the mov* insns, or if you'd have to do it for all
  146. ;;- named insns.
  147. ;;-     2) Add code to the mov{[ds]f,[ds]i} instructions to handle
  148. ;;- moving between fpa regs and 68881 regs.
  149.  
  150. ;;- Since the fpa is more powerful than the 68881 and also has more
  151. ;;- registers, and since I think the resultant md would be medium ugly
  152. ;;- (lot's of duplicate code, ugly constraint strings), I elected not
  153. ;;- to do this change.
  154.  
  155. ;;- Another reason why someone *might* want to do the change is to
  156. ;;- control which register classes are accessed in a slightly cleaner
  157. ;;- way than I have.  See the blurb on CONDITIONAL_REGISTER_USAGE in
  158. ;;- the internals manual.
  159.  
  160. ;;- Yet another reason why someone might want to do this change is to
  161. ;;- allow use of some of the 68881 insns which have no equivalent on
  162. ;;- the fpa.  The sqrt instruction comes fairly quickly to mind.
  163.  
  164. ;;- If this is ever done, don't forget to change sun3.h so that
  165. ;;- it *will* define __HAVE_68881__ when the FPA is in use.
  166.  
  167. ;;-        Condition code hack
  168.  
  169. ;;- When a floating point compare is done in the fpa, the resulting
  170. ;;- condition codes are left in the fpastatus register.  The values in
  171. ;;- this register must be moved into the 68000 cc register before any
  172. ;;- jump is executed.  Once this has been done, regular jump
  173. ;;- instructions are fine (ie. floating point jumps are not necessary.
  174. ;;- They are only done if the cc is in the 68881).
  175.  
  176. ;;- The instructions that move the fpastatus register to the 68000
  177. ;;- register clobber a data register (the move cannot be done direct).
  178. ;;- These instructions might be bundled either with the compare
  179. ;;- instruction, or the branch instruction.  If we were using both the
  180. ;;- fpa and the 68881 together, we would wish to only mark the
  181. ;;- register clobbered if we were doing the compare in the fpa, but I
  182. ;;- think that that decision (whether to clobber the register or not)
  183. ;;- must be done before register allocation (makes sense) and hence we
  184. ;;- can't know if the floating point compare will be done in the fpa
  185. ;;- or the fp.  So whenever we are asked for code that uses the fpa,
  186. ;;- we will mark a data register as clobbered.  This is reasonable, as
  187. ;;- almost all floating point compare operations done with fpa code
  188. ;;- enabled will be done in the fpa.  It's even more reasonable since
  189. ;;- we decided to make the 68881 and the fpa mutually exclusive.
  190.  
  191. ;;- We place to code to move the fpastatus register inside of a
  192. ;;- define_expand so that we can do it conditionally based on whether
  193. ;;- we are targeting an fpa or not.
  194.  
  195. ;;- This still leaves us with the question of where we wish to put the
  196. ;;- code to move the fpastatus reg.  If we put it in the compare
  197. ;;- instruction, we can restrict the clobbering of the register to
  198. ;;- floating point compares, but we can't take advantage of floating
  199. ;;- point subtracts & etc. that alter the fpastatus register.  If we
  200. ;;- put it in the branch instruction, all branches compiled with fpa
  201. ;;- code enabled will clobber a data register, but we will be able to
  202. ;;- take advantage of fpa subtracts.  This balance favors putting the
  203. ;;- code in with the compare instruction.
  204.  
  205. ;;- Note that if some enterprising hacker should decide to switch
  206. ;;- this, he'll need to modify the code in NOTICE_UPDATE_CC.
  207.  
  208. ;;-        Usage of the top 16 fpa registers
  209.  
  210. ;;- The only locations which we may transfer fpa registers 16-31 from
  211. ;;- or to are the fpa registers 0-15.  (68000 registers and memory
  212. ;;- locations are impossible).  This causes problems in gcc, which
  213. ;;- assumes that mov?? instructions require no additional registers
  214. ;;- (see section 11.7) and since floating point moves *must* be
  215. ;;- supported into general registers (see section 12.3 under
  216. ;;- HARD_REGNO_OK_FOR_MODE_P) from anywhere.
  217.  
  218. ;;- My solution was to reserve fpa0 for moves into or out of these top
  219. ;;- 16 registers and to disparage the choice to reload into or out of
  220. ;;- these registers as much as I could.  That alternative is always
  221. ;;- last in the list, so it will not be used unless all else fails.  I
  222. ;;- will note that according to my current information, sun's compiler
  223. ;;- doesn't use these top 16 registers at all.
  224.  
  225. ;;- There is another possible way to do it.  I *believe* that if you
  226. ;;- make absolutely sure that the code will not be executed in the
  227. ;;- reload pass, you can support the mov?? names with define_expands
  228. ;;- which require new registers.  This may be possible by the
  229. ;;- appropriate juggling of constraints.  I may come back to this later.
  230.  
  231. ;;-         Usage of constant RAM
  232.  
  233. ;;- This has been handled correctly (I believe) but the way I've done
  234. ;;- it could use a little explanation.  The constant RAM can only be
  235. ;;- accessed when the instruction is in "command register" mode.
  236. ;;- "command register" mode means that no accessing of memory or the
  237. ;;- 68000 registers is being done.  This can be expressed easily in
  238. ;;- constraints, so generally the mode of the instruction is
  239. ;;- determined by a branch off of which_alternative.  In outputting
  240. ;;- instructions, a 'w' means to output an access to the constant ram
  241. ;;- (if the arg is CONST_DOUBLE and is one of the available
  242. ;;- constants), and 'x' means to output a register pair (if the arg is
  243. ;;- a 68000 register) and a 'y' is the combination of the above two
  244. ;;- processes.  You use a 'y' in two operand DF instructions where you
  245. ;;- *know* the other operand is an fpa register, you use an 'x' in DF
  246. ;;- instructions where the arg might be a 68000 register and the
  247. ;;- instruction is *not* in "command register" mode, and you use a 'w'
  248. ;;- in two situations: 1) The instruction *is* in command register
  249. ;;- mode (and hence won't be accessing 68000 registers), or 2) The
  250. ;;- instruction is a two operand SF instruction where you know the
  251. ;;- other operand is an fpa register.
  252.  
  253. ;;-        Optimization issues
  254.  
  255. ;;- I actually think that I've included all of the fpa instructions
  256. ;;- that should be included.  Note that if someone is interested in
  257. ;;- doing serious floating point work on the sun fpa, I would advise
  258. ;;- the use of the "asm" instruction in gcc to allow you to use the
  259. ;;- sin, cos, and exponential functions on the fpa board.
  260.  
  261. ;;- END FPA Explanation Section.
  262.  
  263.  
  264. ;;- Some of these insn's are composites of several m68000 op codes.
  265. ;;- The assembler (or final @@??) insures that the appropriate one is
  266. ;;- selected.
  267.  
  268. (define_insn ""
  269.   [(set (match_operand:DF 0 "push_operand" "=m")
  270.     (match_operand:DF 1 "general_operand" "ro<>fyE"))]
  271.   ""
  272.   "*
  273. {
  274.   if (FP_REG_P (operands[1]))
  275.     return \"fmove%.d %f1,%0\";
  276.   if (FPA_REG_P (operands[1]))
  277.     return \"fpmove%.d %1, %x0\";
  278.   return output_move_double (operands);
  279. }")
  280.  
  281. (define_insn ""
  282.   [(set (match_operand:DI 0 "push_operand" "=m")
  283.     (match_operand:DI 1 "general_operand" "ro<>Fy"))]
  284.   ""
  285.   "*
  286. {
  287.   return output_move_double (operands);
  288. }")
  289.  
  290. ;; We don't want to allow a constant operand for test insns because
  291. ;; (set (cc0) (const_int foo)) has no mode information.  Such insns will
  292. ;; be folded while optimizing anyway.
  293.  
  294. (define_expand "tstdi"
  295.   [(parallel
  296.     [(set (cc0)
  297.       (match_operand:DI 0 "nonimmediate_operand" "d"))
  298.      (clobber (match_dup 1))])]
  299.   ""
  300.   "operands[1] = gen_reg_rtx (DImode);")
  301.  
  302. (define_insn ""
  303.   [(set (cc0)
  304.     (match_operand:DI 1 "nonimmediate_operand" "0"))
  305.    (clobber (match_operand:DI 0 "register_operand" "=d"))]
  306.   ""
  307.   "*
  308. {
  309.   cc_status.flags |= CC_REVERSED;
  310.   return \"neg%.l %R0\;negx%.l %0\";
  311. }")
  312.  
  313. (define_insn "tstsi"
  314.   [(set (cc0)
  315.     (match_operand:SI 0 "nonimmediate_operand" "rm"))]
  316.   ""
  317.   "*
  318. {
  319. #ifdef ISI_OV
  320.   /* ISI's assembler fails to handle tstl a0.  */
  321.   if (! ADDRESS_REG_P (operands[0]))
  322. #else
  323.   if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
  324. #endif
  325.     return \"tst%.l %0\";
  326.   /* If you think that the 68020 does not support tstl a0,
  327.      reread page B-167 of the 68020 manual more carefully.  */
  328.   /* On an address reg, cmpw may replace cmpl.  */
  329. #ifdef SGS_CMP_ORDER
  330.   return \"cmp%.w %0,%#0\";
  331. #else
  332.   return \"cmp%.w %#0,%0\";
  333. #endif
  334. }")
  335.  
  336. ;; This can't use an address register, because comparisons
  337. ;; with address registers as second operand always test the whole word.
  338. (define_insn "tsthi"
  339.   [(set (cc0)
  340.     (match_operand:HI 0 "nonimmediate_operand" "dm"))]
  341.   ""
  342.   "tst%.w %0")
  343.  
  344. (define_insn "tstqi"
  345.   [(set (cc0)
  346.     (match_operand:QI 0 "nonimmediate_operand" "dm"))]
  347.   ""
  348.   "tst%.b %0")
  349.   
  350. (define_expand "tstsf"
  351.   [(set (cc0)
  352.     (match_operand:SF 0 "general_operand" ""))]
  353.   "TARGET_68881 || TARGET_FPA"
  354.   "
  355. {
  356.   if (TARGET_FPA)
  357.     {
  358.       emit_insn (gen_tstsf_fpa (operands[0]));
  359.       DONE;
  360.     }
  361. }")
  362.  
  363. (define_insn "tstsf_fpa"
  364.   [(set (cc0)
  365.     (match_operand:SF 0 "general_operand" "xmdF"))
  366.    (clobber (match_scratch:SI 1 "=d"))]
  367.   "TARGET_FPA"
  368.   "fptst%.s %x0\;fpmove fpastatus,%1\;movw %1,cc"
  369.   [(set_attr "fppc" "conflict")])
  370.  
  371. (define_insn ""
  372.   [(set (cc0)
  373.     (match_operand:SF 0 "general_operand" "fdm"))]
  374.   "TARGET_68881"
  375.   "*
  376. {
  377.   cc_status.flags = CC_IN_68881;
  378.   if (FP_REG_P (operands[0]))
  379.     return \"ftst%.x %0\";
  380.   return \"ftst%.s %0\";
  381. }"
  382.   [(set_attr "fppc" "conflict")])
  383.  
  384. (define_expand "tstdf"
  385.   [(set (cc0)
  386.     (match_operand:DF 0 "general_operand" ""))]
  387.   "TARGET_68881 || TARGET_FPA"
  388.   "
  389. {
  390.   if (TARGET_FPA)
  391.     {
  392.       emit_insn (gen_tstsf_fpa (operands[0]));
  393.       DONE;
  394.     }
  395. }")
  396.  
  397. (define_insn "tstdf_fpa"
  398.   [(set (cc0)
  399.     (match_operand:DF 0 "general_operand" "xrmF"))
  400.    (clobber (match_scratch:SI 1 "=d"))]
  401.   "TARGET_FPA"
  402.   "fptst%.d %x0\;fpmove fpastatus,%1\;movw %1,cc"
  403.   [(set_attr "fppc" "conflict")])
  404.  
  405. (define_insn ""
  406.   [(set (cc0)
  407.     (match_operand:DF 0 "general_operand" "fm"))]
  408.   "TARGET_68881"
  409.   "*
  410. {
  411.   cc_status.flags = CC_IN_68881;
  412.   if (FP_REG_P (operands[0]))
  413.     return \"ftst%.x %0\";
  414.   return \"ftst%.d %0\";
  415. }"
  416.   [(set_attr "fppc" "conflict")])
  417.  
  418. ;; compare instructions.
  419.  
  420. (define_expand "cmpdi"
  421.   [(parallel
  422.     [(set (cc0)
  423.       (compare (match_operand:DI 0 "nonimmediate_operand" "")
  424.            (match_operand:DI 1 "general_operand" "")))
  425.      (clobber (match_dup 2))])]
  426.   ""
  427.   "operands[2] = gen_reg_rtx (DImode);")
  428.  
  429. (define_insn ""
  430.   [(set (cc0)
  431.     (compare (match_operand:DI 1 "nonimmediate_operand" "0,d")
  432.          (match_operand:DI 2 "general_operand" "d,0")))
  433.    (clobber (match_operand:DI 0 "register_operand" "=d,d"))]
  434.   ""
  435.   "*
  436. {
  437.   if (rtx_equal_p (operands[0], operands[1]))
  438.     return \"sub%.l %R2,%R0\;subx%.l %2,%0\";
  439.   else
  440.     {
  441.       cc_status.flags |= CC_REVERSED;
  442.       return \"sub%.l %R1,%R0\;subx%.l %1,%0\";
  443.     }
  444. }")
  445.  
  446. ;; This is the second "hook" for PIC code (in addition to movsi). See
  447. ;; comment of movsi for a description of PIC handling.
  448. (define_expand "cmpsi"
  449.   [(set (cc0)
  450.     (compare (match_operand:SI 0 "nonimmediate_operand" "")
  451.          (match_operand:SI 1 "general_operand" "")))]
  452.   ""
  453.   "
  454. {
  455.   if (flag_pic && symbolic_operand (operands[1], SImode)) 
  456.     {
  457.       /* The source is an address which requires PIC relocation.  
  458.          Call legitimize_pic_address with the source, mode, and a relocation
  459.          register (a new pseudo, or the final destination if reload_in_progress
  460.          is set).   Then fall through normally */
  461.       extern rtx legitimize_pic_address();
  462.       rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
  463.       operands[1] = legitimize_pic_address (operands[1], SImode, temp);
  464.     }
  465. }")
  466.  
  467. ;; A composite of the cmp, cmpa, & cmpi m68000 op codes.
  468. (define_insn ""
  469.   [(set (cc0)
  470.     (compare (match_operand:SI 0 "nonimmediate_operand" "rKs,mr,>")
  471.          (match_operand:SI 1 "general_operand" "mr,Ksr,>")))]
  472.   ""
  473.   "*
  474. {
  475.   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
  476. #ifdef SGS_CMP_ORDER
  477.     return \"cmpm%.l %0,%1\";
  478. #else
  479.     return \"cmpm%.l %1,%0\";
  480. #endif
  481.   if (REG_P (operands[1])
  482.       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
  483.     { cc_status.flags |= CC_REVERSED;
  484. #ifdef SGS_CMP_ORDER
  485.       return \"cmp%.l %d1,%d0\";
  486. #else
  487.       return \"cmp%.l %d0,%d1\";
  488. #endif
  489.     }
  490. #ifdef SGS_CMP_ORDER
  491.   return \"cmp%.l %d0,%d1\";
  492. #else
  493.   return \"cmp%.l %d1,%d0\";
  494. #endif
  495. }")
  496.  
  497. (define_insn "cmphi"
  498.   [(set (cc0)
  499.     (compare (match_operand:HI 0 "nonimmediate_operand" "rnm,d,n,m,>")
  500.          (match_operand:HI 1 "general_operand" "d,rnm,m,n,>")))]
  501.   ""
  502.   "*
  503. {
  504.   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
  505. #ifdef SGS_CMP_ORDER
  506.     return \"cmpm%.w %0,%1\";
  507. #else
  508.     return \"cmpm%.w %1,%0\";
  509. #endif
  510.   if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
  511.       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
  512.     { cc_status.flags |= CC_REVERSED;
  513. #ifdef SGS_CMP_ORDER
  514.       return \"cmp%.w %d1,%d0\";
  515. #else
  516.       return \"cmp%.w %d0,%d1\";
  517. #endif
  518.     }
  519. #ifdef SGS_CMP_ORDER
  520.   return \"cmp%.w %d0,%d1\";
  521. #else
  522.   return \"cmp%.w %d1,%d0\";
  523. #endif
  524. }")
  525.  
  526. (define_insn "cmpqi"
  527.   [(set (cc0)
  528.     (compare (match_operand:QI 0 "nonimmediate_operand" "dn,md,>")
  529.          (match_operand:QI 1 "general_operand" "dm,nd,>")))]
  530.   ""
  531.   "*
  532. {
  533.   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
  534. #ifdef SGS_CMP_ORDER
  535.     return \"cmpm%.b %0,%1\";
  536. #else
  537.     return \"cmpm%.b %1,%0\";
  538. #endif
  539.   if (REG_P (operands[1])
  540.       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
  541.     { cc_status.flags |= CC_REVERSED;
  542. #ifdef SGS_CMP_ORDER
  543.       return \"cmp%.b %d1,%d0\";
  544. #else
  545.       return \"cmp%.b %d0,%d1\";
  546. #endif
  547.     }
  548. #ifdef SGS_CMP_ORDER
  549.   return \"cmp%.b %d0,%d1\";
  550. #else
  551.   return \"cmp%.b %d1,%d0\";
  552. #endif
  553. }")
  554.  
  555. (define_expand "cmpdf"
  556.   [(set (cc0)
  557.     (compare (match_operand:DF 0 "general_operand" "")
  558.          (match_operand:DF 1 "general_operand" "")))]
  559.   "TARGET_68881 || TARGET_FPA"
  560.   "
  561. {
  562.   if (TARGET_FPA)
  563.     {
  564.       emit_insn (gen_cmpdf_fpa (operands[0], operands[1]));
  565.       DONE;
  566.     }
  567. }")
  568.  
  569. (define_insn "cmpdf_fpa"
  570.   [(set (cc0)
  571.     (compare (match_operand:DF 0 "general_operand" "x,y")
  572.          (match_operand:DF 1 "general_operand" "xH,rmF")))
  573.    (clobber (match_scratch:SI 2 "=d,d"))]
  574.   "TARGET_FPA"
  575.   "fpcmp%.d %y1,%0\;fpmove fpastatus,%2\;movw %2,cc"
  576.   [(set_attr "fppc" "conflict")])
  577.  
  578. (define_insn ""
  579.   [(set (cc0)
  580.     (compare (match_operand:DF 0 "general_operand" "f,mG")
  581.          (match_operand:DF 1 "general_operand" "fmG,f")))]
  582.   "TARGET_68881"
  583.   "*
  584. {
  585.   cc_status.flags = CC_IN_68881;
  586. #ifdef SGS_CMP_ORDER
  587.   if (REG_P (operands[0]))
  588.     {
  589.       if (REG_P (operands[1]))
  590.     return \"fcmp%.x %0,%1\";
  591.       else
  592.         return \"fcmp%.d %0,%f1\";
  593.     }
  594.   cc_status.flags |= CC_REVERSED;
  595.   return \"fcmp%.d %1,%f0\";
  596. #else
  597.   if (REG_P (operands[0]))
  598.     {
  599.       if (REG_P (operands[1]))
  600.     return \"fcmp%.x %1,%0\";
  601.       else
  602.         return \"fcmp%.d %f1,%0\";
  603.     }
  604.   cc_status.flags |= CC_REVERSED;
  605.   return \"fcmp%.d %f0,%1\";
  606. #endif
  607. }"
  608.   [(set_attr "fppc" "conflict")])
  609.  
  610. (define_expand "cmpsf"
  611.  [(set (cc0)
  612.        (compare (match_operand:SF 0 "general_operand" "")
  613.         (match_operand:SF 1 "general_operand" "")))]
  614.  "TARGET_68881 || TARGET_FPA"
  615.  "
  616. {
  617.   if (TARGET_FPA)
  618.     {
  619.       emit_insn (gen_cmpsf_fpa (operands[0], operands[1]));
  620.       DONE;
  621.     }
  622. }")
  623.  
  624. (define_insn "cmpsf_fpa"
  625.   [(set (cc0)
  626.     (compare (match_operand:SF 0 "general_operand" "x,y")
  627.          (match_operand:SF 1 "general_operand" "xH,rmF")))
  628.    (clobber (match_scratch:SI 2 "=d,d"))]
  629.   "TARGET_FPA"
  630.   "fpcmp%.s %w1,%x0\;fpmove fpastatus,%2\;movw %2,cc"
  631.   [(set_attr "fppc" "conflict")])
  632.  
  633. (define_insn ""
  634.   [(set (cc0)
  635.     (compare (match_operand:SF 0 "general_operand" "f,mdG")
  636.          (match_operand:SF 1 "general_operand" "fmdG,f")))]
  637.   "TARGET_68881"
  638.   "*
  639. {
  640.   cc_status.flags = CC_IN_68881;
  641. #ifdef SGS_CMP_ORDER
  642.   if (FP_REG_P (operands[0]))
  643.     {
  644.       if (FP_REG_P (operands[1]))
  645.     return \"fcmp%.x %0,%1\";
  646.       else
  647.         return \"fcmp%.s %0,%f1\";
  648.     }
  649.   cc_status.flags |= CC_REVERSED;
  650.   return \"fcmp%.s %1,%f0\";
  651. #else
  652.   if (FP_REG_P (operands[0]))
  653.     {
  654.       if (FP_REG_P (operands[1]))
  655.     return \"fcmp%.x %1,%0\";
  656.       else
  657.         return \"fcmp%.s %f1,%0\";
  658.     }
  659.   cc_status.flags |= CC_REVERSED;
  660.   return \"fcmp%.s %f0,%1\";
  661. #endif
  662. }"
  663.   [(set_attr "fppc" "conflict")])
  664.  
  665. ;; Recognizers for btst instructions.
  666.  
  667. (define_insn ""
  668.   [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "do")
  669.                 (const_int 1)
  670.                 (minus:SI (const_int 7)
  671.                       (match_operand:SI 1 "general_operand" "di"))))]
  672.   ""
  673.   "* { return output_btst (operands, operands[1], operands[0], insn, 7); }")
  674.  
  675. (define_insn ""
  676.   [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "d")
  677.                 (const_int 1)
  678.                 (minus:SI (const_int 31)
  679.                       (match_operand:SI 1 "general_operand" "di"))))]
  680.   ""
  681.   "* { return output_btst (operands, operands[1], operands[0], insn, 31); }")
  682.  
  683. ;; The following two patterns are like the previous two
  684. ;; except that they use the fact that bit-number operands
  685. ;; are automatically masked to 3 or 5 bits.
  686.  
  687. (define_insn ""
  688.   [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "do")
  689.                 (const_int 1)
  690.                 (minus:SI (const_int 7)
  691.                       (and:SI
  692.                        (match_operand:SI 1 "register_operand" "d")
  693.                        (const_int 7)))))]
  694.   ""
  695.   "* { return output_btst (operands, operands[1], operands[0], insn, 7); }")
  696.  
  697. (define_insn ""
  698.   [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "d")
  699.                 (const_int 1)
  700.                 (minus:SI (const_int 31)
  701.                       (and:SI
  702.                        (match_operand:SI 1 "register_operand" "d")
  703.                        (const_int 31)))))]
  704.   ""
  705.   "* { return output_btst (operands, operands[1], operands[0], insn, 31); }")
  706.  
  707. ;; Nonoffsettable mem refs are ok in this one pattern
  708. ;; since we don't try to adjust them.
  709. (define_insn ""
  710.   [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "md")
  711.                 (const_int 1)
  712.                 (match_operand:SI 1 "const_int_operand" "n")))]
  713.   "(unsigned) INTVAL (operands[1]) < 8"
  714.   "*
  715. {
  716.   operands[1] = gen_rtx (CONST_INT, VOIDmode, 7 - INTVAL (operands[1]));
  717.   return output_btst (operands, operands[1], operands[0], insn, 7);
  718. }")
  719.  
  720. (define_insn ""
  721.   [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "do")
  722.                 (const_int 1)
  723.                 (match_operand:SI 1 "const_int_operand" "n")))]
  724.   ""
  725.   "*
  726. {
  727.   if (GET_CODE (operands[0]) == MEM)
  728.     {
  729.       operands[0] = adj_offsettable_operand (operands[0],
  730.                          INTVAL (operands[1]) / 8);
  731.       operands[1] = gen_rtx (CONST_INT, VOIDmode, 
  732.                  7 - INTVAL (operands[1]) % 8);
  733.       return output_btst (operands, operands[1], operands[0], insn, 7);
  734.     }
  735.   operands[1] = gen_rtx (CONST_INT, VOIDmode,
  736.              31 - INTVAL (operands[1]));
  737.   return output_btst (operands, operands[1], operands[0], insn, 31);
  738. }")
  739.  
  740.  
  741. ;; move instructions
  742.  
  743. ;; A special case in which it is not desirable
  744. ;; to reload the constant into a data register.
  745. (define_insn ""
  746.   [(set (match_operand:SI 0 "push_operand" "=m")
  747.     (match_operand:SI 1 "const_int_operand" "J"))]
  748.   "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
  749.   "*
  750. {
  751.   if (operands[1] == const0_rtx)
  752.     return \"clr%.l %0\";
  753.   return \"pea %a1\";
  754. }")
  755.  
  756. ;This is never used.
  757. ;(define_insn "swapsi"
  758. ;  [(set (match_operand:SI 0 "general_operand" "+r")
  759. ;    (match_operand:SI 1 "general_operand" "+r"))
  760. ;   (set (match_dup 1) (match_dup 0))]
  761. ;  ""
  762. ;  "exg %1,%0")
  763.  
  764. ;; Special case of fullword move when source is zero.
  765. ;; The reason this is special is to avoid loading a zero
  766. ;; into a data reg with moveq in order to store it elsewhere.
  767.    
  768. (define_insn ""
  769.   [(set (match_operand:SI 0 "general_operand" "=g")
  770.     (const_int 0))]
  771.   ;; clr insns on 68000 read before writing.
  772.   ;; This isn't so on the 68010, but we have no alternative for it.
  773.   "(TARGET_68020
  774.     || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))"
  775.   "*
  776. {
  777.   if (ADDRESS_REG_P (operands[0]))
  778.     return \"sub%.l %0,%0\";
  779.   /* moveq is faster on the 68000.  */
  780.   if (DATA_REG_P (operands[0]) && !TARGET_68020)
  781. #if defined(MOTOROLA) && !defined(CRDS)
  782.     return \"moveq%.l %#0,%0\";
  783. #else
  784.     return \"moveq %#0,%0\";
  785. #endif
  786.   return \"clr%.l %0\";
  787. }")
  788.  
  789. ;; General case of fullword move. 
  790. ;;
  791. ;; This is the main "hook" for PIC code.  When generating
  792. ;; PIC, movsi is responsible for determining when the source address
  793. ;; needs PIC relocation and appropriately calling legitimize_pic_address
  794. ;; to perform the actual relocation.
  795. ;;
  796. ;; In both the PIC and non-PIC cases the patterns generated will
  797. ;; matched by the next define_insn. 
  798. (define_expand "movsi"
  799.   [(set (match_operand:SI 0 "general_operand" "")
  800.     (match_operand:SI 1 "general_operand" ""))]
  801.   ""
  802.   "
  803. {
  804. #ifdef MACHO_PIC
  805.   extern rtx machopic_indirect_data_reference();
  806.   extern rtx machopic_legitimize_pic_address();
  807.  
  808.   if (MACHOPIC_PURE)
  809.     {
  810.        extern rtx legitimize_pic_address();
  811.        rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
  812.        operands[1] = machopic_indirect_data_reference (operands[1], temp);
  813.        operands[1] = machopic_legitimize_pic_address (operands[1], SImode, 
  814.                          temp == operands[1] ? 0 : temp);
  815.     }
  816.   else if (MACHOPIC_INDIRECT)
  817.     {
  818.       operands[1] = machopic_indirect_data_reference (operands[1], 0);
  819.     }
  820.   else
  821. #endif
  822.   if (flag_pic && symbolic_operand (operands[1], SImode)) 
  823.     {
  824.       /* The source is an address which requires PIC relocation.  
  825.          Call legitimize_pic_address with the source, mode, and a relocation
  826.          register (a new pseudo, or the final destination if reload_in_progress
  827.          is set).   Then fall through normally */
  828.       extern rtx legitimize_pic_address();
  829.       rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
  830.       operands[1] = legitimize_pic_address (operands[1], SImode, temp);
  831.     }
  832. }")
  833.  
  834. ;; General case of fullword move.  The register constraints
  835. ;; force integer constants in range for a moveq to be reloaded
  836. ;; if they are headed for memory.
  837. (define_insn ""
  838.   ;; Notes: make sure no alternative allows g vs g.
  839.   ;; We don't allow f-regs since fixed point cannot go in them.
  840.   ;; We do allow y and x regs since fixed point is allowed in them.
  841.   [(set (match_operand:SI 0 "general_operand" "=g,da,y,!*x*r*m")
  842.     (match_operand:SI 1 "general_operand" "daymKs,i,g,*x*r*m"))]
  843.   ""
  844.   "*
  845. {
  846.   if (which_alternative == 3)
  847.     return \"fpmove%.l %x1,fpa0\;fpmove%.l fpa0,%x0\";    
  848.   if (FPA_REG_P (operands[1]) || FPA_REG_P (operands[0]))
  849.     return \"fpmove%.l %x1,%x0\";
  850.   if (GET_CODE (operands[1]) == CONST_INT)
  851.     {
  852.       if (operands[1] == const0_rtx
  853.       && (DATA_REG_P (operands[0])
  854.           || GET_CODE (operands[0]) == MEM)
  855.       /* clr insns on 68000 read before writing.
  856.          This isn't so on the 68010, but we have no alternative for it.  */
  857.       && (TARGET_68020
  858.           || !(GET_CODE (operands[0]) == MEM
  859.            && MEM_VOLATILE_P (operands[0]))))
  860.     return \"clr%.l %0\";
  861.       else if (DATA_REG_P (operands[0]))
  862.     return output_move_const_into_data_reg (operands);
  863.       else if (ADDRESS_REG_P (operands[0])
  864.            && INTVAL (operands[1]) < 0x8000
  865.            && INTVAL (operands[1]) >= -0x8000)
  866.     return \"move%.w %1,%0\";
  867.       else if (push_operand (operands[0], SImode)
  868.            && INTVAL (operands[1]) < 0x8000
  869.            && INTVAL (operands[1]) >= -0x8000)
  870.         return \"pea %a1\";
  871.     }
  872.   else if ((GET_CODE (operands[1]) == SYMBOL_REF
  873.         || GET_CODE (operands[1]) == CONST)
  874.        && push_operand (operands[0], SImode))
  875.     return \"pea %a1\";
  876.   else if ((GET_CODE (operands[1]) == SYMBOL_REF
  877.         || GET_CODE (operands[1]) == CONST)
  878.        && ADDRESS_REG_P (operands[0]))
  879.     return \"lea %a1,%0\";
  880.   return \"move%.l %1,%0\";
  881. }")
  882.  
  883. (define_insn "movhi"
  884.   [(set (match_operand:HI 0 "general_operand" "=g")
  885.     (match_operand:HI 1 "general_operand" "g"))]
  886.   ""
  887.   "*
  888. {
  889.   if (GET_CODE (operands[1]) == CONST_INT)
  890.     {
  891.       if (operands[1] == const0_rtx
  892.       && (DATA_REG_P (operands[0])
  893.           || GET_CODE (operands[0]) == MEM)
  894.       /* clr insns on 68000 read before writing.
  895.          This isn't so on the 68010, but we have no alternative for it.  */
  896.       && (TARGET_68020
  897.           || !(GET_CODE (operands[0]) == MEM
  898.            && MEM_VOLATILE_P (operands[0]))))
  899.     return \"clr%.w %0\";
  900.       else if (DATA_REG_P (operands[0])
  901.            && INTVAL (operands[1]) < 128
  902.            && INTVAL (operands[1]) >= -128)
  903.         {
  904. #if defined(MOTOROLA) && !defined(CRDS)
  905.           return \"moveq%.l %1,%0\";
  906. #else
  907.       return \"moveq %1,%0\";
  908. #endif
  909.     }
  910.       else if (INTVAL (operands[1]) < 0x8000
  911.            && INTVAL (operands[1]) >= -0x8000)
  912.     return \"move%.w %1,%0\";
  913.     }
  914.   else if (CONSTANT_P (operands[1]))
  915.     return \"move%.l %1,%0\";
  916. #ifndef SGS_NO_LI
  917.   /* Recognize the insn before a tablejump, one that refers
  918.      to a table of offsets.  Such an insn will need to refer
  919.      to a label on the insn.  So output one.  Use the label-number
  920.      of the table of offsets to generate this label.  This code,
  921.      and similar code below, assumes that there will be at most one
  922.      reference to each table.  */
  923.   if (GET_CODE (operands[1]) == MEM
  924.       && GET_CODE (XEXP (operands[1], 0)) == PLUS
  925.       && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == LABEL_REF
  926.       && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) != PLUS)
  927.     {
  928.       rtx labelref = XEXP (XEXP (operands[1], 0), 1);
  929. #if defined (MOTOROLA) && !defined (SGS_SWITCH_TABLES)
  930. #ifdef SGS
  931.       asm_fprintf (asm_out_file, \"\\tset %LLI%d,.+2\\n\",
  932.            CODE_LABEL_NUMBER (XEXP (labelref, 0)));
  933. #else /* not SGS */
  934.       asm_fprintf (asm_out_file, \"\\t.set %LLI%d,.+2\\n\",
  935.                CODE_LABEL_NUMBER (XEXP (labelref, 0)));
  936. #endif /* not SGS */
  937. #else /* SGS_SWITCH_TABLES or not MOTOROLA */
  938.       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"LI\",
  939.                  CODE_LABEL_NUMBER (XEXP (labelref, 0)));
  940. #ifdef SGS_SWITCH_TABLES
  941.       /* Set flag saying we need to define the symbol
  942.      LD%n (with value L%n-LI%n) at the end of the switch table.  */
  943.       switch_table_difference_label_flag = 1;
  944. #endif /* SGS_SWITCH_TABLES */
  945. #endif /* SGS_SWITCH_TABLES or not MOTOROLA */
  946.     }
  947. #endif /* SGS_NO_LI */
  948.   return \"move%.w %1,%0\";
  949. }")
  950.  
  951. (define_insn "movstricthi"
  952.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm"))
  953.     (match_operand:HI 1 "general_operand" "rmn"))]
  954.   ""
  955.   "*
  956. {
  957.   if (GET_CODE (operands[1]) == CONST_INT)
  958.     {
  959.       if (operands[1] == const0_rtx
  960.       && (DATA_REG_P (operands[0])
  961.           || GET_CODE (operands[0]) == MEM)
  962.       /* clr insns on 68000 read before writing.
  963.          This isn't so on the 68010, but we have no alternative for it.  */
  964.       && (TARGET_68020
  965.           || !(GET_CODE (operands[0]) == MEM
  966.            && MEM_VOLATILE_P (operands[0]))))
  967.     return \"clr%.w %0\";
  968.     }
  969.   return \"move%.w %1,%0\";
  970. }")
  971.  
  972. (define_insn "movqi"
  973.   [(set (match_operand:QI 0 "general_operand" "=d,*a,m,m,?*a")
  974.     (match_operand:QI 1 "general_operand" "dmi*a,d*a,dmi,?*a,m"))]
  975.   ""
  976.   "*
  977. {
  978.   rtx xoperands[4];
  979.  
  980.   /* This is probably useless, since it loses for pushing a struct
  981.      of several bytes a byte at a time.  */
  982.   if (GET_CODE (operands[0]) == MEM
  983.       && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
  984.       && XEXP (XEXP (operands[0], 0), 0) == stack_pointer_rtx
  985.       && ! ADDRESS_REG_P (operands[1]))
  986.     {
  987.       xoperands[1] = operands[1];
  988.       xoperands[2]
  989.         = gen_rtx (MEM, QImode,
  990.            gen_rtx (PLUS, VOIDmode, stack_pointer_rtx, const1_rtx));
  991.       /* Just pushing a byte puts it in the high byte of the halfword.  */
  992.       /* We must put it in the low-order, high-numbered byte.  */
  993.       output_asm_insn (\"move%.b %1,%-\;move%.b %@,%2\", xoperands);
  994.       return \"\";
  995.     }
  996.  
  997.   /* Moving a byte into an address register is not possible.  */
  998.   /* Use d0 as an intermediate, but don't clobber its contents.  */
  999.   if (ADDRESS_REG_P (operands[0]) && GET_CODE (operands[1]) == MEM)
  1000.     {
  1001.       /* ??? For 2.5, don't allow this choice and use secondary reloads
  1002.      instead.
  1003.  
  1004.      See if the address register is used in the address.  If it
  1005.      is, we have to generate a more complex sequence than those below.  */
  1006.       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
  1007.                  operands[1], NULL_RTX))
  1008.     {
  1009.       /* See if the stack pointer is used in the address.  If it isn't,
  1010.          we can push d0 or d1 (the insn can't use both of them) on
  1011.          the stack, perform our move into d0/d1, copy the byte from d0/1,
  1012.          and pop d0/1.  */
  1013.       if (! reg_mentioned_p (stack_pointer_rtx, operands[1]))
  1014.         {
  1015.           if (! refers_to_regno_p (0, 1, operands[1], NULL_RTX))
  1016.         return \"move%.l %/d0,%-\;move%.b %1,%/d0\;move%.l %/d0,%0\;move%.l %+,%/d0\";
  1017.           else
  1018.         return \"move%.l %/d1,%-\;move%.b %1,%/d1\;move%.l %/d1,%0\;move%.l %+,%/d1\";
  1019.         }
  1020.       else
  1021.         {
  1022.           /* Otherwise, we know that d0 cannot be used in the address
  1023.          (since sp and one address register is).  Assume that sp is
  1024.          being used as a base register and replace the address
  1025.          register that is our operand[0] with d0.  */
  1026.           rtx reg_map[FIRST_PSEUDO_REGISTER];
  1027.           int i;
  1028.  
  1029.           for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  1030.         reg_map[i] = 0;
  1031.  
  1032.           reg_map[REGNO (operands[0])] = gen_rtx (REG, Pmode, 0);
  1033.           operands[1] = copy_rtx (operands[1]);
  1034.           replace_regs (operands[1], reg_map, FIRST_PSEUDO_REGISTER, 0);
  1035.           return \"exg %/d0,%0\;move%.b %1,%/d0\;exg %/d0,%0\";
  1036.         }
  1037.     }
  1038.  
  1039.       /* If the address of operand 1 uses d0, choose d1 as intermediate.  */
  1040.       if (refers_to_regno_p (0, 1, operands[1], NULL_RTX))
  1041.     return \"exg %/d1,%0\;move%.b %1,%/d1\;exg %/d1,%0\";
  1042.       /* Otherwise d0 is usable.
  1043.      (An effective address on the 68k can't use two d-regs.)  */
  1044.       else
  1045.     return \"exg %/d0,%0\;move%.b %1,%/d0\;exg %/d0,%0\";
  1046.     }
  1047.     
  1048.   /* Likewise for moving from an address reg.  */
  1049.   if (ADDRESS_REG_P (operands[1]) && GET_CODE (operands[0]) == MEM)
  1050.     {
  1051.       /* ??? For 2.5, don't allow this choice and use secondary reloads
  1052.      instead.
  1053.  
  1054.      See if the address register is used in the address.  If it
  1055.      is, we have to generate a more complex sequence than those below.  */
  1056.       if (refers_to_regno_p (REGNO (operands[1]), REGNO (operands[1]) + 1,
  1057.                  operands[0], NULL_RTX))
  1058.     {
  1059.       /* See if the stack pointer is used in the address.  If it isn't,
  1060.          we can push d0 or d1 (the insn can't use both of them) on
  1061.          the stack, copy the byte to d0/1, perform our move from d0/d1, 
  1062.          and pop d0/1.  */
  1063.       if (! reg_mentioned_p (stack_pointer_rtx, operands[0]))
  1064.         {
  1065.           if (! refers_to_regno_p (0, 1, operands[0], NULL_RTX))
  1066.         return \"move%.l %/d0,%-\;move%.l %1,%/d0\;move%.b %/d0,%0\;move%.l %+,%/d0\";
  1067.           else
  1068.         return \"move%.l %/d1,%-\;move%.l %1,%/d1\;move%.b %/d1,%0\;move%.l %+,%/d1\";
  1069.         }
  1070.       else
  1071.         {
  1072.           /* Otherwise, we know that d0 cannot be used in the address
  1073.          (since sp and one address register is).  Assume that sp is
  1074.          being used as a base register and replace the address
  1075.          register that is our operand[1] with d0.  */
  1076.           rtx reg_map[FIRST_PSEUDO_REGISTER];
  1077.           int i;
  1078.  
  1079.           for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  1080.         reg_map[i] = 0;
  1081.  
  1082.           reg_map[REGNO (operands[1])] = gen_rtx (REG, Pmode, 0);
  1083.           operands[0] = copy_rtx (operands[0]);
  1084.           replace_regs (operands[0], reg_map, FIRST_PSEUDO_REGISTER, 0);
  1085.           return \"exg %/d0,%1\;move%.b %/d0,%0\;exg %/d0,%1\";
  1086.         }
  1087.     }
  1088.  
  1089.       if (refers_to_regno_p (0, 1, operands[0], NULL_RTX))
  1090.         return \"exg %/d1,%1\;move%.b %/d1,%0\;exg %/d1,%1\";
  1091.       else
  1092.         return \"exg %/d0,%1\;move%.b %/d0,%0\;exg %/d0,%1\";
  1093.     }
  1094.  
  1095.   /* clr and st insns on 68000 read before writing.
  1096.      This isn't so on the 68010, but we have no alternative for it.  */
  1097.   if (TARGET_68020
  1098.       || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))
  1099.     {
  1100.       if (operands[1] == const0_rtx)
  1101.     return \"clr%.b %0\";
  1102.       if (GET_CODE (operands[1]) == CONST_INT
  1103.       && INTVAL (operands[1]) == -1)
  1104.     {
  1105.       CC_STATUS_INIT;
  1106.       return \"st %0\";
  1107.     }
  1108.     }
  1109.   if (GET_CODE (operands[1]) != CONST_INT && CONSTANT_P (operands[1]))
  1110.     return \"move%.l %1,%0\";
  1111.   if (ADDRESS_REG_P (operands[0]) || ADDRESS_REG_P (operands[1]))
  1112.     return \"move%.w %1,%0\";
  1113.   return \"move%.b %1,%0\";
  1114. }")
  1115.  
  1116. (define_insn "movstrictqi"
  1117.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm"))
  1118.     (match_operand:QI 1 "general_operand" "dmn"))]
  1119.   ""
  1120.   "*
  1121. {
  1122.   if (operands[1] == const0_rtx
  1123.       /* clr insns on 68000 read before writing.
  1124.          This isn't so on the 68010, but we have no alternative for it.  */
  1125.       && (TARGET_68020
  1126.           || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
  1127.     return \"clr%.b %0\";
  1128.   return \"move%.b %1,%0\";
  1129. }")
  1130.  
  1131. (define_insn "movsf"
  1132.   [(set (match_operand:SF 0 "general_operand" "=rmf,x,y,rm,!x,!rm")
  1133.     (match_operand:SF 1 "general_operand" "rmfF,xH,rmF,y,rm,x"))]
  1134. ;  [(set (match_operand:SF 0 "general_operand" "=rmf")
  1135. ;    (match_operand:SF 1 "general_operand" "rmfF"))]
  1136.   ""
  1137.   "*
  1138. {
  1139.   if (which_alternative >= 4)
  1140.     return \"fpmove%.s %1,fpa0\;fpmove%.s fpa0,%0\";
  1141.   if (FPA_REG_P (operands[0]))
  1142.     {
  1143.       if (FPA_REG_P (operands[1]))
  1144.     return \"fpmove%.s %x1,%x0\";
  1145.       else if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1146.     return output_move_const_single (operands);
  1147.       else if (FP_REG_P (operands[1]))
  1148.         return \"fmove%.s %1,sp@-\;fpmove%.d sp@+, %0\";
  1149.       return \"fpmove%.s %x1,%x0\";
  1150.     }
  1151.   if (FPA_REG_P (operands[1]))
  1152.     {
  1153.       if (FP_REG_P (operands[0]))
  1154.     return \"fpmove%.s %x1,sp@-\;fmove%.s sp@+,%0\";
  1155.       else
  1156.     return \"fpmove%.s %x1,%x0\";
  1157.     }
  1158.   if (FP_REG_P (operands[0]))
  1159.     {
  1160.       if (FP_REG_P (operands[1]))
  1161.     return \"f%$move%.x %1,%0\";
  1162.       else if (ADDRESS_REG_P (operands[1]))
  1163.     return \"move%.l %1,%-\;f%$move%.s %+,%0\";
  1164.       else if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1165.     return output_move_const_single (operands);
  1166.       return \"f%$move%.s %f1,%0\";
  1167.     }
  1168.   if (FP_REG_P (operands[1]))
  1169.     {
  1170.       if (ADDRESS_REG_P (operands[0]))
  1171.     return \"fmove%.s %1,%-\;move%.l %+,%0\";
  1172.       return \"fmove%.s %f1,%0\";
  1173.     }
  1174.   return \"move%.l %1,%0\";
  1175. }"
  1176.   [(set_attr "fppc" "none")])
  1177.  
  1178. (define_insn "movdf"
  1179.   [(set (match_operand:DF 0 "general_operand" "=rm,rf,rf,&rof<>,y,rm,x,!x,!rm")
  1180.     (match_operand:DF 1 "general_operand" "rf,m,0,rofE<>,rmE,y,xH,rm,x"))]
  1181. ;  [(set (match_operand:DF 0 "general_operand" "=rm,&rf,&rof<>")
  1182. ;    (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
  1183.   ""
  1184.   "*
  1185. {
  1186.   if (which_alternative == 7)
  1187.     return \"fpmove%.d %x1,fpa0\;fpmove%.d fpa0,%x0\";
  1188.   if (FPA_REG_P (operands[0]))
  1189.     {
  1190.       if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1191.     return output_move_const_double (operands);
  1192.       if (FP_REG_P (operands[1]))
  1193.         return \"fmove%.d %1,sp@-\;fpmove%.d sp@+,%x0\";
  1194.       return \"fpmove%.d %x1,%x0\";
  1195.     }
  1196.   else if (FPA_REG_P (operands[1]))
  1197.     {
  1198.       if (FP_REG_P(operands[0]))
  1199.         return \"fpmove%.d %x1,sp@-\;fmoved sp@+,%0\";
  1200.       else
  1201.         return \"fpmove%.d %x1,%x0\";
  1202.     }
  1203.   if (FP_REG_P (operands[0]))
  1204.     {
  1205.       if (FP_REG_P (operands[1]))
  1206.     return \"f%&move%.x %1,%0\";
  1207.       if (REG_P (operands[1]))
  1208.     {
  1209.       rtx xoperands[2];
  1210.       xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  1211.       output_asm_insn (\"move%.l %1,%-\", xoperands);
  1212.       output_asm_insn (\"move%.l %1,%-\", operands);
  1213.       return \"f%&move%.d %+,%0\";
  1214.     }
  1215.       if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1216.     return output_move_const_double (operands);
  1217.       return \"f%&move%.d %f1,%0\";
  1218.     }
  1219.   else if (FP_REG_P (operands[1]))
  1220.     {
  1221.       if (REG_P (operands[0]))
  1222.     {
  1223.       output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands);
  1224.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1225.       return \"move%.l %+,%0\";
  1226.     }
  1227.       else
  1228.         return \"fmove%.d %f1,%0\";
  1229.     }
  1230.   return output_move_double (operands);
  1231. }
  1232. ")
  1233.  
  1234. (define_expand "movxf"
  1235.   [(set (match_operand:XF 0 "nonimmediate_operand" "")
  1236.     (match_operand:XF 1 "general_operand" ""))]
  1237.   ""
  1238.   "
  1239. {
  1240.   if (CONSTANT_P (operands[1]))
  1241.     {
  1242.       operands[1] = force_const_mem (XFmode, operands[1]);
  1243.       if (! memory_address_p (XFmode, XEXP (operands[1], 0))
  1244.       && ! reload_in_progress)
  1245.     operands[1] = change_address (operands[1], XFmode,
  1246.                       XEXP (operands[1], 0));
  1247.     }
  1248. }")
  1249.  
  1250. (define_insn ""
  1251.   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f")
  1252.     (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r"))]
  1253.   "TARGET_68881"
  1254.   "*
  1255. {
  1256.   if (FP_REG_P (operands[0]))
  1257.     {
  1258.       if (FP_REG_P (operands[1]))
  1259.     return \"fmove%.x %1,%0\";
  1260.       if (REG_P (operands[1]))
  1261.     {
  1262.       rtx xoperands[2];
  1263.       xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2);
  1264.       output_asm_insn (\"move%.l %1,%-\", xoperands);
  1265.       xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  1266.       output_asm_insn (\"move%.l %1,%-\", xoperands);
  1267.       output_asm_insn (\"move%.l %1,%-\", operands);
  1268.       return \"fmove%.x %+,%0\";
  1269.     }
  1270.       if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1271.         return \"fmove%.x %1,%0\";
  1272.       return \"fmove%.x %f1,%0\";
  1273.     }
  1274.   if (REG_P (operands[0]))
  1275.     {
  1276.       output_asm_insn (\"fmove%.x %f1,%-\;move%.l %+,%0\", operands);
  1277.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1278.       output_asm_insn (\"move%.l %+,%0\", operands);
  1279.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1280.       return \"move%.l %+,%0\";
  1281.     }
  1282.   return \"fmove%.x %f1,%0\";
  1283. }
  1284. ")
  1285.  
  1286. (define_insn ""
  1287.   [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
  1288.     (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
  1289.   "! TARGET_68881"
  1290.   "*
  1291. {
  1292.   if (FP_REG_P (operands[0]))
  1293.     {
  1294.       if (FP_REG_P (operands[1]))
  1295.     return \"fmove%.x %1,%0\";
  1296.       if (REG_P (operands[1]))
  1297.     {
  1298.       rtx xoperands[2];
  1299.       xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2);
  1300.       output_asm_insn (\"move%.l %1,%-\", xoperands);
  1301.       xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  1302.       output_asm_insn (\"move%.l %1,%-\", xoperands);
  1303.       output_asm_insn (\"move%.l %1,%-\", operands);
  1304.       return \"fmove%.x %+,%0\";
  1305.     }
  1306.       if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1307.         return \"fmove%.x %1,%0\";
  1308.       return \"fmove%.x %f1,%0\";
  1309.     }
  1310.   if (FP_REG_P (operands[1]))
  1311.     {
  1312.       if (REG_P (operands[0]))
  1313.         {
  1314.           output_asm_insn (\"fmove%.x %f1,%-\;move%.l %+,%0\", operands);
  1315.           operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1316.           output_asm_insn (\"move%.l %+,%0\", operands);
  1317.           operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1318.           return \"move%.l %+,%0\";
  1319.         }
  1320.       else
  1321.         return \"fmove%.x %f1,%0\";
  1322.     }
  1323.   return output_move_double (operands);
  1324. }
  1325. ")
  1326.  
  1327. ;; movdi can apply to fp regs in some cases
  1328. (define_insn "movdi"
  1329.   ;; Let's see if it really still needs to handle fp regs, and, if so, why.
  1330.   [(set (match_operand:DI 0 "general_operand" "=rm,r,&ro<>,y,rm,!*x,!rm")
  1331.     (match_operand:DI 1 "general_operand" "rF,m,roi<>F,rmiF,y,rmF,*x"))]
  1332. ;  [(set (match_operand:DI 0 "general_operand" "=rm,&r,&ro<>,!&rm,!&f,y,rm,x,!x,!rm")
  1333. ;    (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfmF,rmi,y,rm,x"))]
  1334. ;  [(set (match_operand:DI 0 "general_operand" "=rm,&rf,&ro<>,!&rm,!&f")
  1335. ;    (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
  1336.   ""
  1337.   "*
  1338. {
  1339.   if (which_alternative == 8)
  1340.     return \"fpmove%.d %x1,fpa0\;fpmove%.d fpa0,%x0\";
  1341.   if (FPA_REG_P (operands[0]) || FPA_REG_P (operands[1]))
  1342.     return \"fpmove%.d %x1,%x0\";
  1343.   if (FP_REG_P (operands[0]))
  1344.     {
  1345.       if (FP_REG_P (operands[1]))
  1346.     return \"fmove%.x %1,%0\";
  1347.       if (REG_P (operands[1]))
  1348.     {
  1349.       rtx xoperands[2];
  1350.       xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  1351.       output_asm_insn (\"move%.l %1,%-\", xoperands);
  1352.       output_asm_insn (\"move%.l %1,%-\", operands);
  1353.       return \"fmove%.d %+,%0\";
  1354.     }
  1355.       if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1356.     return output_move_const_double (operands);
  1357.       return \"fmove%.d %f1,%0\";
  1358.     }
  1359.   else if (FP_REG_P (operands[1]))
  1360.     {
  1361.       if (REG_P (operands[0]))
  1362.     {
  1363.       output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands);
  1364.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1365.       return \"move%.l %+,%0\";
  1366.     }
  1367.       else
  1368.         return \"fmove%.d %f1,%0\";
  1369.     }
  1370.   return output_move_double (operands);
  1371. }
  1372. ")
  1373.  
  1374. ;; Thus goes after the move instructions
  1375. ;; because the move instructions are better (require no spilling)
  1376. ;; when they can apply.  It goes before the add/sub insns
  1377. ;; so we will prefer it to them.
  1378.  
  1379. (define_insn "pushasi"
  1380.   [(set (match_operand:SI 0 "push_operand" "=m")
  1381.     (match_operand:SI 1 "address_operand" "p"))]
  1382.   ""
  1383.   "pea %a1")
  1384.  
  1385. ;; truncation instructions
  1386. (define_insn "truncsiqi2"
  1387.   [(set (match_operand:QI 0 "general_operand" "=dm,d")
  1388.     (truncate:QI
  1389.      (match_operand:SI 1 "general_operand" "doJ,i")))]
  1390.   ""
  1391.   "*
  1392. {
  1393.   if (GET_CODE (operands[0]) == REG)
  1394.     {
  1395.       /* Must clear condition codes, since the move.l bases them on
  1396.      the entire 32 bits, not just the desired 8 bits.  */
  1397.       CC_STATUS_INIT;
  1398.       return \"move%.l %1,%0\";
  1399.     }
  1400.   if (GET_CODE (operands[1]) == MEM)
  1401.     operands[1] = adj_offsettable_operand (operands[1], 3);
  1402.   return \"move%.b %1,%0\";
  1403. }")
  1404.  
  1405. (define_insn "trunchiqi2"
  1406.   [(set (match_operand:QI 0 "general_operand" "=dm,d")
  1407.     (truncate:QI
  1408.      (match_operand:HI 1 "general_operand" "doJ,i")))]
  1409.   ""
  1410.   "*
  1411. {
  1412.   if (GET_CODE (operands[0]) == REG
  1413.       && (GET_CODE (operands[1]) == MEM
  1414.       || GET_CODE (operands[1]) == CONST_INT))
  1415.     {
  1416.       /* Must clear condition codes, since the move.w bases them on
  1417.      the entire 16 bits, not just the desired 8 bits.  */
  1418.       CC_STATUS_INIT;
  1419.       return \"move%.w %1,%0\";
  1420.     }
  1421.   if (GET_CODE (operands[0]) == REG)
  1422.     {
  1423.       /* Must clear condition codes, since the move.l bases them on
  1424.      the entire 32 bits, not just the desired 8 bits.  */
  1425.       CC_STATUS_INIT;
  1426.       return \"move%.l %1,%0\";
  1427.     }
  1428.   if (GET_CODE (operands[1]) == MEM)
  1429.     operands[1] = adj_offsettable_operand (operands[1], 1);
  1430.   return \"move%.b %1,%0\";
  1431. }")
  1432.  
  1433. (define_insn "truncsihi2"
  1434.   [(set (match_operand:HI 0 "general_operand" "=dm,d")
  1435.     (truncate:HI
  1436.      (match_operand:SI 1 "general_operand" "roJ,i")))]
  1437.   ""
  1438.   "*
  1439. {
  1440.   if (GET_CODE (operands[0]) == REG)
  1441.     {
  1442.       /* Must clear condition codes, since the move.l bases them on
  1443.      the entire 32 bits, not just the desired 8 bits.  */
  1444.       CC_STATUS_INIT;
  1445.       return \"move%.l %1,%0\";
  1446.     }
  1447.   if (GET_CODE (operands[1]) == MEM)
  1448.     operands[1] = adj_offsettable_operand (operands[1], 2);
  1449.   return \"move%.w %1,%0\";
  1450. }")
  1451.  
  1452. ;; zero extension instructions
  1453.  
  1454. ;; this is the canonical form for (lshiftrt:DI x 32)
  1455. (define_insn "zero_extendsidi2"
  1456.   [(set (match_operand:DI 0 "general_operand" "ro,<,>")
  1457.     (zero_extend:DI (match_operand:SI 1 "general_operand" "rm,rm,rm")))]
  1458.   ""
  1459.   "*
  1460. {
  1461.   CC_STATUS_INIT;
  1462.   if (which_alternative == 2)
  1463.     return \"clr%.l %0\;move%.l %1,%0\";
  1464.   if (which_alternative == 1)
  1465.     return \"move%.l %1,%0\;clr%.l %0\";
  1466.   if (GET_CODE (operands[0]) == REG)
  1467.     operands[2] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1468.   else
  1469.     operands[2] = adj_offsettable_operand (operands[0], 4);
  1470.   if (ADDRESS_REG_P (operands[0]))
  1471.     return \"move%.l %1,%2\;sub%.l %0,%0\";
  1472.   else
  1473.     return \"move%.l %1,%2\;clr%.l %0\";
  1474. }")
  1475.  
  1476. (define_expand "zero_extendhisi2"
  1477.   [(set (match_operand:SI 0 "register_operand" "")
  1478.     (const_int 0))
  1479.    (set (strict_low_part (match_dup 2))
  1480.     (match_operand:HI 1 "general_operand" ""))]
  1481.   ""
  1482.   "
  1483. {
  1484.   operands[1] = make_safe_from (operands[1], operands[0]);
  1485.   if (GET_CODE (operands[0]) == SUBREG)
  1486.     operands[2] = gen_rtx (SUBREG, HImode, SUBREG_REG (operands[0]),
  1487.                SUBREG_WORD (operands[0]));
  1488.   else
  1489.     operands[2] = gen_rtx (SUBREG, HImode, operands[0], 0);
  1490. }")
  1491.  
  1492. (define_expand "zero_extendqihi2"
  1493.   [(set (match_operand:HI 0 "register_operand" "")
  1494.     (const_int 0))
  1495.    (set (strict_low_part (match_dup 2))
  1496.     (match_operand:QI 1 "general_operand" ""))]
  1497.   ""
  1498.   "
  1499. {
  1500.   operands[1] = make_safe_from (operands[1], operands[0]);
  1501.   if (GET_CODE (operands[0]) == SUBREG)
  1502.     operands[2] = gen_rtx (SUBREG, QImode, SUBREG_REG (operands[0]),
  1503.                SUBREG_WORD (operands[0]));
  1504.   else
  1505.     operands[2] = gen_rtx (SUBREG, QImode, operands[0], 0);
  1506. }")
  1507.  
  1508. (define_expand "zero_extendqisi2"
  1509.   [(set (match_operand:SI 0 "register_operand" "")
  1510.     (const_int 0))
  1511.    (set (strict_low_part (match_dup 2))
  1512.     (match_operand:QI 1 "general_operand" ""))]
  1513.   ""
  1514.   "
  1515. {
  1516.   operands[1] = make_safe_from (operands[1], operands[0]);
  1517.   if (GET_CODE (operands[0]) == SUBREG)
  1518.     operands[2] = gen_rtx (SUBREG, QImode, SUBREG_REG (operands[0]),
  1519.                SUBREG_WORD (operands[0]));
  1520.   else
  1521.     operands[2] = gen_rtx (SUBREG, QImode, operands[0], 0);
  1522. }")
  1523.  
  1524. ;; Patterns to recognize zero-extend insns produced by the combiner.
  1525. ;; We don't allow both operands in memory, because of aliasing problems.
  1526. ;; Explicitly disallow two memory operands via the condition since reloading
  1527. ;; of this case will result in worse code than the uncombined patterns.
  1528.  
  1529. (define_insn ""
  1530.   [(set (match_operand:SI 0 "general_operand" "=do<>,d<")
  1531.     (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
  1532.   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
  1533.   "*
  1534. {
  1535.   if (DATA_REG_P (operands[0]))
  1536.     {
  1537.       if (GET_CODE (operands[1]) == REG
  1538.       && REGNO (operands[0]) == REGNO (operands[1]))
  1539.     return \"and%.l %#0xFFFF,%0\";
  1540.       if (reg_mentioned_p (operands[0], operands[1]))
  1541.         return \"move%.w %1,%0\;and%.l %#0xFFFF,%0\";
  1542.       return \"clr%.l %0\;move%.w %1,%0\";
  1543.     }
  1544.   else if (GET_CODE (operands[0]) == MEM
  1545.        && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  1546.     return \"move%.w %1,%0\;clr%.w %0\";
  1547.   else if (GET_CODE (operands[0]) == MEM
  1548.        && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  1549.     return \"clr%.w %0\;move%.w %1,%0\";
  1550.   else
  1551.     {
  1552.       output_asm_insn (\"clr%.w %0\", operands);
  1553.       operands[0] = adj_offsettable_operand (operands[0], 2);
  1554.       return \"move%.w %1,%0\";
  1555.     }
  1556. }")
  1557.  
  1558. (define_insn ""
  1559.   [(set (match_operand:HI 0 "general_operand" "=do<>,d")
  1560.     (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
  1561.   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
  1562.   "*
  1563. {
  1564.   if (DATA_REG_P (operands[0]))
  1565.     {
  1566.       if (GET_CODE (operands[1]) == REG
  1567.       && REGNO (operands[0]) == REGNO (operands[1]))
  1568.     return \"and%.w %#0xFF,%0\";
  1569.       if (reg_mentioned_p (operands[0], operands[1]))
  1570.         return \"move%.b %1,%0\;and%.w %#0xFF,%0\";
  1571.       return \"clr%.w %0\;move%.b %1,%0\";
  1572.     }
  1573.   else if (GET_CODE (operands[0]) == MEM
  1574.        && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  1575.     {
  1576.       if (REGNO (XEXP (XEXP (operands[0], 0), 0))
  1577.       == STACK_POINTER_REGNUM)
  1578.     {
  1579.       output_asm_insn (\"clr%.w %-\", operands);
  1580.       operands[0] = gen_rtx (MEM, GET_MODE (operands[0]),
  1581.                  plus_constant (stack_pointer_rtx, 1));
  1582.       return \"move%.b %1,%0\";
  1583.     }
  1584.       else
  1585.     return \"move%.b %1,%0\;clr%.b %0\";
  1586.     }
  1587.   else if (GET_CODE (operands[0]) == MEM
  1588.        && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  1589.     return \"clr%.b %0\;move%.b %1,%0\";
  1590.   else
  1591.     {
  1592.       output_asm_insn (\"clr%.b %0\", operands);
  1593.       operands[0] = adj_offsettable_operand (operands[0], 1);
  1594.       return \"move%.b %1,%0\";
  1595.     }
  1596. }")
  1597.  
  1598. (define_insn ""
  1599.   [(set (match_operand:SI 0 "general_operand" "=do<>,d")
  1600.     (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
  1601.   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
  1602.   "*
  1603. {
  1604.   if (DATA_REG_P (operands[0]))
  1605.     {
  1606.       if (GET_CODE (operands[1]) == REG
  1607.       && REGNO (operands[0]) == REGNO (operands[1]))
  1608.     return \"and%.l %#0xFF,%0\";
  1609.       if (reg_mentioned_p (operands[0], operands[1]))
  1610.         return \"move%.b %1,%0\;and%.l %#0xFF,%0\";
  1611.       return \"clr%.l %0\;move%.b %1,%0\";
  1612.     }
  1613.   else if (GET_CODE (operands[0]) == MEM
  1614.        && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  1615.     {
  1616.       operands[0] = XEXP (XEXP (operands[0], 0), 0);
  1617. #ifdef MOTOROLA
  1618. #ifdef SGS
  1619.       return \"clr%.l -(%0)\;move%.b %1,3(%0)\";
  1620. #else
  1621.       return \"clr%.l -(%0)\;move%.b %1,(3,%0)\";
  1622. #endif
  1623. #else
  1624.       return \"clrl %0@-\;moveb %1,%0@(3)\";
  1625. #endif
  1626.     }
  1627.   else if (GET_CODE (operands[0]) == MEM
  1628.        && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  1629.     {
  1630.       operands[0] = XEXP (XEXP (operands[0], 0), 0);
  1631. #ifdef MOTOROLA
  1632. #ifdef SGS
  1633.       return \"clr%.l (%0)+\;move%.b %1,-1(%0)\";
  1634. #else
  1635.       return \"clr%.l (%0)+\;move%.b %1,(-1,%0)\";
  1636. #endif
  1637. #else
  1638.       return \"clrl %0@+\;moveb %1,%0@(-1)\";
  1639. #endif
  1640.     }
  1641.   else
  1642.     {
  1643.       output_asm_insn (\"clr%.l %0\", operands);
  1644.       operands[0] = adj_offsettable_operand (operands[0], 3);
  1645.       return \"move%.b %1,%0\";
  1646.     }
  1647. }")
  1648.  
  1649. ;; sign extension instructions
  1650.  
  1651. (define_insn "extendqidi2"
  1652.   [(set (match_operand:DI 0 "general_operand" "=d")
  1653.     (sign_extend:DI
  1654.      (match_operand:QI 1 "general_operand" "rm")))]
  1655.   ""
  1656.   "*
  1657. {
  1658.   CC_STATUS_INIT;
  1659.   operands[2] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1660.   if (TARGET_68020)
  1661.     return \"move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0\";
  1662.   else
  1663.     return \"move%.b %1,%2\;ext%.w %0\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0\";
  1664. }")
  1665.  
  1666. (define_insn "extendhidi2"
  1667.   [(set (match_operand:DI 0 "general_operand" "=d")
  1668.     (sign_extend:DI
  1669.      (match_operand:HI 1 "general_operand" "rm")))]
  1670.   ""
  1671.   "*
  1672. {
  1673.   CC_STATUS_INIT;
  1674.   operands[2] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1675.   if (TARGET_68020)
  1676.     return \"move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0\";
  1677.   else
  1678.     return \"move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0\";
  1679. }")
  1680.  
  1681. (define_insn "extendsidi2"
  1682.   [(set (match_operand:DI 0 "general_operand" "=d")
  1683.     (sign_extend:DI
  1684.      (match_operand:SI 1 "general_operand" "rm")))]
  1685.   ""
  1686.   "*
  1687. {
  1688.   CC_STATUS_INIT;
  1689.   operands[2] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1690.   if (TARGET_68020)
  1691.     return \"move%.l %1,%2\;smi %0\;extb%.l %0\";
  1692.   else
  1693.     return \"move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0\";
  1694. }")
  1695.  
  1696. ;; Special case when one can avoid register clobbering, copy and test
  1697. ;; Maybe there is a way to make that the general case, by forcing the
  1698. ;; result of the SI tree to be in the lower register of the DI target
  1699.  
  1700. (define_insn "extendplussidi"
  1701.   [(set (match_operand:DI 0 "register_operand" "=d")
  1702.     (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rmn")
  1703.             (match_operand:SI 2 "general_operand" "rmn"))))]
  1704.   ""
  1705.   "*
  1706. {
  1707.   CC_STATUS_INIT;
  1708.   operands[3] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1709.   if (GET_CODE (operands[1]) == CONST_INT
  1710.   && (unsigned) INTVAL (operands[1]) > 8)
  1711.     {
  1712.       rtx tmp = operands[1];
  1713.  
  1714.       operands[1] = operands[2];
  1715.       operands[2] = tmp;
  1716.     }
  1717.   if (TARGET_68020)
  1718.     return \"move%.l %2,%3\;add%.l %1,%3\;smi %0\;extb%.l %0\";
  1719.   else
  1720.     return \"move%.l %2,%3\;add%.l %1,%3\;smi %0\;ext%.w %0\;ext%.l %0\";
  1721. }")
  1722.  
  1723. (define_insn "extendhisi2"
  1724.   [(set (match_operand:SI 0 "general_operand" "=*d,a")
  1725.     (sign_extend:SI
  1726.      (match_operand:HI 1 "nonimmediate_operand" "0,rm")))]
  1727.   ""
  1728.   "*
  1729. {
  1730.   if (ADDRESS_REG_P (operands[0]))
  1731.     return \"move%.w %1,%0\";
  1732.   return \"ext%.l %0\";
  1733. }")
  1734.  
  1735. (define_insn "extendqihi2"
  1736.   [(set (match_operand:HI 0 "general_operand" "=d")
  1737.     (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
  1738.   ""
  1739.   "ext%.w %0")
  1740.  
  1741. (define_insn "extendqisi2"
  1742.   [(set (match_operand:SI 0 "general_operand" "=d")
  1743.     (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
  1744.   "TARGET_68020"
  1745.   "extb%.l %0")
  1746.  
  1747. ;; Conversions between float and double.
  1748.  
  1749. (define_expand "extendsfdf2"
  1750.   [(set (match_operand:DF 0 "general_operand" "")
  1751.     (float_extend:DF
  1752.      (match_operand:SF 1 "general_operand" "")))]
  1753.   "TARGET_68881 || TARGET_FPA"
  1754.   "")
  1755.  
  1756. (define_insn ""
  1757.   [(set (match_operand:DF 0 "general_operand" "=x,y")
  1758.     (float_extend:DF
  1759.      (match_operand:SF 1 "general_operand" "xH,rmF")))]
  1760.   "TARGET_FPA"
  1761.   "fpstod %w1,%0")
  1762.  
  1763. (define_insn ""
  1764.   [(set (match_operand:DF 0 "general_operand" "=*fdm,f")
  1765.     (float_extend:DF
  1766.       (match_operand:SF 1 "general_operand" "f,dmF")))]
  1767.   "TARGET_68881"
  1768.   "*
  1769. {
  1770.   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
  1771.     {
  1772.       if (REGNO (operands[0]) == REGNO (operands[1]))
  1773.     {
  1774.       /* Extending float to double in an fp-reg is a no-op.
  1775.          NOTICE_UPDATE_CC has already assumed that the
  1776.          cc will be set.  So cancel what it did.  */
  1777.       cc_status = cc_prev_status;
  1778.       return \"\";
  1779.     }
  1780.       return \"f%&move%.x %1,%0\";
  1781.     }
  1782.   if (FP_REG_P (operands[0]))
  1783.     return \"f%&move%.s %f1,%0\";
  1784.   if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
  1785.     {
  1786.       output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands);
  1787.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1788.       return \"move%.l %+,%0\";
  1789.     }
  1790.   return \"fmove%.d %f1,%0\";
  1791. }")
  1792.  
  1793. ;; This cannot output into an f-reg because there is no way to be
  1794. ;; sure of truncating in that case.
  1795. ;; But on the Sun FPA, we can be sure.
  1796. (define_expand "truncdfsf2"
  1797.   [(set (match_operand:SF 0 "general_operand" "")
  1798.     (float_truncate:SF
  1799.       (match_operand:DF 1 "general_operand" "")))]
  1800.   "TARGET_68881 || TARGET_FPA"
  1801.   "")
  1802.  
  1803. (define_insn ""
  1804.   [(set (match_operand:SF 0 "general_operand" "=x,y")
  1805.     (float_truncate:SF
  1806.       (match_operand:DF 1 "general_operand" "xH,rmF")))]
  1807.   "TARGET_FPA"
  1808.   "fpdtos %y1,%0"
  1809.   [(set_attr "fppc" "single")])
  1810.  
  1811. ;; On the '040 we can truncate in a register accurately and easily.
  1812. (define_insn ""
  1813.   [(set (match_operand:SF 0 "general_operand" "=f")
  1814.     (float_truncate:SF
  1815.       (match_operand:DF 1 "general_operand" "fmG")))]
  1816.   "TARGET_68040_ONLY"
  1817.   "*
  1818. {
  1819.   if (FP_REG_P (operands[1]))
  1820.     return \"f%$move%.x %1,%0\";
  1821.   return \"f%$move%.d %f1,%0\";
  1822. }"
  1823.   [(set_attr "fppc" "double")])
  1824.  
  1825. (define_insn ""
  1826.   [(set (match_operand:SF 0 "general_operand" "=dm")
  1827.     (float_truncate:SF
  1828.       (match_operand:DF 1 "general_operand" "f")))]
  1829.   "TARGET_68881"
  1830.   "fmove%.s %f1,%0"
  1831.   [(set_attr "fppc" "double")])
  1832.  
  1833. ;; Conversion between fixed point and floating point.
  1834. ;; Note that among the fix-to-float insns
  1835. ;; the ones that start with SImode come first.
  1836. ;; That is so that an operand that is a CONST_INT
  1837. ;; (and therefore lacks a specific machine mode).
  1838. ;; will be recognized as SImode (which is always valid)
  1839. ;; rather than as QImode or HImode.
  1840.  
  1841. (define_expand "floatsisf2"
  1842.   [(set (match_operand:SF 0 "general_operand" "")
  1843.     (float:SF (match_operand:SI 1 "general_operand" "")))]
  1844.   "TARGET_68881 || TARGET_FPA"
  1845.   "")
  1846.  
  1847. (define_insn ""
  1848.   [(set (match_operand:SF 0 "general_operand" "=y,x")
  1849.     (float:SF (match_operand:SI 1 "general_operand" "rmi,x")))]
  1850.   "TARGET_FPA"
  1851.   "fpltos %1,%0")
  1852.  
  1853. (define_insn ""
  1854.   [(set (match_operand:SF 0 "general_operand" "=f")
  1855.     (float:SF (match_operand:SI 1 "general_operand" "dmi")))]
  1856.   "TARGET_68881"
  1857.   "f%$move%.l %1,%0")
  1858.  
  1859. (define_expand "floatsidf2"
  1860.   [(set (match_operand:DF 0 "general_operand" "")
  1861.     (float:DF (match_operand:SI 1 "general_operand" "")))]
  1862.   "TARGET_68881 || TARGET_FPA"
  1863.   "")
  1864.  
  1865. (define_insn ""
  1866.   [(set (match_operand:DF 0 "general_operand" "=y,x")
  1867.     (float:DF (match_operand:SI 1 "general_operand" "rmi,x")))]
  1868.   "TARGET_FPA"
  1869.   "fpltod %1,%0")
  1870.  
  1871. (define_insn ""
  1872.   [(set (match_operand:DF 0 "general_operand" "=f")
  1873.     (float:DF (match_operand:SI 1 "general_operand" "dmi")))]
  1874.   "TARGET_68881"
  1875.   "f%&move%.l %1,%0")
  1876.  
  1877. (define_insn "floathisf2"
  1878.   [(set (match_operand:SF 0 "general_operand" "=f")
  1879.     (float:SF (match_operand:HI 1 "general_operand" "dmn")))]
  1880.   "TARGET_68881"
  1881.   "f%$move%.w %1,%0")
  1882.  
  1883. (define_insn "floathidf2"
  1884.   [(set (match_operand:DF 0 "general_operand" "=f")
  1885.     (float:DF (match_operand:HI 1 "general_operand" "dmn")))]
  1886.   "TARGET_68881"
  1887.   "fmove%.w %1,%0")
  1888.  
  1889. (define_insn "floatqisf2"
  1890.   [(set (match_operand:SF 0 "general_operand" "=f")
  1891.     (float:SF (match_operand:QI 1 "general_operand" "dmn")))]
  1892.   "TARGET_68881"
  1893.   "fmove%.b %1,%0")
  1894.  
  1895. (define_insn "floatqidf2"
  1896.   [(set (match_operand:DF 0 "general_operand" "=f")
  1897.     (float:DF (match_operand:QI 1 "general_operand" "dmn")))]
  1898.   "TARGET_68881"
  1899.   "f%&move%.b %1,%0")
  1900.  
  1901. ;; New routines to convert floating-point values to integers
  1902. ;; to be used on the '040.  These should be faster than trapping
  1903. ;; into the kernel to emulate fintrz.  They should also be faster
  1904. ;; than calling the subroutines fixsfsi or fixdfsi.
  1905.  
  1906. (define_insn "fix_truncdfsi2"
  1907.   [(set (match_operand:SI 0 "general_operand" "=dm")
  1908.     (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
  1909.    (clobber (match_scratch:SI 2 "=d"))
  1910.    (clobber (match_scratch:SI 3 "=d"))]
  1911.   "TARGET_68881 && TARGET_68040"
  1912.   "*
  1913. {
  1914.   CC_STATUS_INIT;
  1915.   return \"fmovem%.l %!,%2\;moveq %#16,%3\;or%.l %2,%3\;and%.w %#-33,%3\;fmovem%.l %3,%!\;fmove%.l %1,%0\;fmovem%.l %2,%!\";
  1916. }")
  1917.  
  1918. (define_insn "fix_truncdfhi2"
  1919.   [(set (match_operand:HI 0 "general_operand" "=dm")
  1920.     (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
  1921.    (clobber (match_scratch:SI 2 "=d"))
  1922.    (clobber (match_scratch:SI 3 "=d"))]
  1923.   "TARGET_68881 && TARGET_68040"
  1924.   "*
  1925. {
  1926.   CC_STATUS_INIT;
  1927.   return \"fmovem%.l %!,%2\;moveq %#16,%3\;or%.l %2,%3\;and%.w %#-33,%3\;fmovem%.l %3,%!\;fmove%.w %1,%0\;fmovem%.l %2,%!\";
  1928. }")
  1929.  
  1930. (define_insn "fix_truncdfqi2"
  1931.   [(set (match_operand:QI 0 "general_operand" "=dm")
  1932.     (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
  1933.    (clobber (match_scratch:SI 2 "=d"))
  1934.    (clobber (match_scratch:SI 3 "=d"))]
  1935.   "TARGET_68881 && TARGET_68040"
  1936.   "*
  1937. {
  1938.   CC_STATUS_INIT;
  1939.   return \"fmovem%.l %!,%2\;moveq %#16,%3\;or%.l %2,%3\;and%.w %#-33,%3\;fmovem%.l %3,%!\;fmove%.b %1,%0\;fmovem%.l %2,%!\";
  1940. }")
  1941.  
  1942. ;; Convert a float to a float whose value is an integer.
  1943. ;; This is the first stage of converting it to an integer type.
  1944.  
  1945. (define_insn "ftruncdf2"
  1946.   [(set (match_operand:DF 0 "general_operand" "=f")
  1947.     (fix:DF (match_operand:DF 1 "general_operand" "fFm")))]
  1948.   "TARGET_68881 && !TARGET_68040"
  1949.   "*
  1950. {
  1951.   if (FP_REG_P (operands[1]))
  1952.     return \"fintrz%.x %f1,%0\";
  1953.   return \"fintrz%.d %f1,%0\";
  1954. }")
  1955.  
  1956. (define_insn "ftruncsf2"
  1957.   [(set (match_operand:SF 0 "general_operand" "=f")
  1958.     (fix:SF (match_operand:SF 1 "general_operand" "dfFm")))]
  1959.   "TARGET_68881 && !TARGET_68040"
  1960.   "*
  1961. {
  1962.   if (FP_REG_P (operands[1]))
  1963.     return \"fintrz%.x %f1,%0\";
  1964.   return \"fintrz%.s %f1,%0\";
  1965. }")
  1966.  
  1967. ;; Convert a float whose value is an integer
  1968. ;; to an actual integer.  Second stage of converting float to integer type.
  1969. (define_insn "fixsfqi2"
  1970.   [(set (match_operand:QI 0 "general_operand" "=dm")
  1971.     (fix:QI (match_operand:SF 1 "general_operand" "f")))]
  1972.   "TARGET_68881"
  1973.   "fmove%.b %1,%0")
  1974.  
  1975. (define_insn "fixsfhi2"
  1976.   [(set (match_operand:HI 0 "general_operand" "=dm")
  1977.     (fix:HI (match_operand:SF 1 "general_operand" "f")))]
  1978.   "TARGET_68881"
  1979.   "fmove%.w %1,%0")
  1980.  
  1981. (define_insn "fixsfsi2"
  1982.   [(set (match_operand:SI 0 "general_operand" "=dm")
  1983.     (fix:SI (match_operand:SF 1 "general_operand" "f")))]
  1984.   "TARGET_68881"
  1985.   "fmove%.l %1,%0")
  1986.  
  1987. (define_insn "fixdfqi2"
  1988.   [(set (match_operand:QI 0 "general_operand" "=dm")
  1989.     (fix:QI (match_operand:DF 1 "general_operand" "f")))]
  1990.   "TARGET_68881"
  1991.   "fmove%.b %1,%0")
  1992.  
  1993. (define_insn "fixdfhi2"
  1994.   [(set (match_operand:HI 0 "general_operand" "=dm")
  1995.     (fix:HI (match_operand:DF 1 "general_operand" "f")))]
  1996.   "TARGET_68881"
  1997.   "fmove%.w %1,%0")
  1998.  
  1999. (define_insn "fixdfsi2"
  2000.   [(set (match_operand:SI 0 "general_operand" "=dm")
  2001.     (fix:SI (match_operand:DF 1 "general_operand" "f")))]
  2002.   "TARGET_68881"
  2003.   "fmove%.l %1,%0")
  2004.  
  2005. ;; Convert a float to an integer.
  2006. ;; On the Sun FPA, this is done in one step.
  2007.  
  2008. (define_insn ""
  2009.   [(set (match_operand:SI 0 "general_operand" "=x,y")
  2010.     (fix:SI (fix:SF (match_operand:SF 1 "general_operand" "xH,rmF"))))]
  2011.   "TARGET_FPA"
  2012.   "fpstol %w1,%0")
  2013.  
  2014. (define_insn ""
  2015.   [(set (match_operand:SI 0 "general_operand" "=x,y")
  2016.     (fix:SI (fix:DF (match_operand:DF 1 "general_operand" "xH,rmF"))))]
  2017.   "TARGET_FPA"
  2018.   "fpdtol %y1,%0")
  2019.  
  2020. ;; add instructions
  2021.  
  2022. (define_insn "adddia_sexthishl32"
  2023.   [(set (match_operand:DI 0 "register_operand" "+a")
  2024.     (plus:DI (ashift:DI (sign_extend:DI
  2025.           (match_operand:HI 1 "general_operand" "rm"))
  2026.             (const_int 32))
  2027.         (match_dup 0)))]
  2028.   ""
  2029.   "*
  2030. {
  2031.   CC_STATUS_INIT;
  2032.   return \"add%.w %1,%0\";
  2033. } ")
  2034.  
  2035. (define_insn "adddid_sexthishl32"
  2036.   [(set (match_operand:DI 0 "general_operand" "+ro")
  2037.     (plus:DI (ashift:DI (sign_extend:DI
  2038.           (match_operand:HI 1 "general_operand" "rm"))
  2039.             (const_int 32))
  2040.         (match_dup 0)))
  2041.    (clobber (match_scratch:SI 2 "=a"))]
  2042.   ""
  2043.   "*
  2044. {
  2045.   CC_STATUS_INIT;
  2046.   return \"move%.w %1,%2\;add%.l %2,%0\";
  2047. } ")
  2048.  
  2049. (define_insn "adddi_dilshr32"
  2050.   [(set (match_operand:DI 0 "general_operand" "=do")
  2051. ;;    (plus:DI (match_operand:DI 2 "general_operand" "%0")
  2052. ;;    (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
  2053. ;;            (const_int 32))))]
  2054.     (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
  2055.             (const_int 32))
  2056.         (match_operand:DI 2 "general_operand" "0")))]
  2057.   ""
  2058.   "*
  2059. {
  2060.   CC_STATUS_INIT;
  2061.   if (GET_CODE (operands[0]) == REG)
  2062.     operands[2] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  2063.   else
  2064.     operands[2] = adj_offsettable_operand (operands[0], 4);
  2065.   return \"add%.l %1,%2\;negx%.l %0\;neg%.l %0\";
  2066. } ")
  2067.  
  2068. (define_insn "adddi_dishl32"
  2069.   [(set (match_operand:DI 0 "general_operand" "=ro")
  2070. ;;    (plus:DI (match_operand:DI 2 "general_operand" "%0")
  2071. ;;    (ashift:DI (match_operand:DI 1 "general_operand" "ro")
  2072. ;;            (const_int 32))))]
  2073.     (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro")
  2074.             (const_int 32))
  2075.         (match_operand:DI 2 "general_operand" "0")))]
  2076.   ""
  2077.   "*
  2078. {
  2079.   CC_STATUS_INIT;
  2080.   if (GET_CODE (operands[1]) == REG)
  2081.     operands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  2082.   else
  2083.     operands[1] = adj_offsettable_operand (operands[1], 4);
  2084.   return \"add%.l %1,%0\";
  2085. } ")
  2086.  
  2087. (define_insn "adddi3"
  2088.   [(set (match_operand:DI 0 "general_operand" "=d,<,d,o<>")
  2089.     (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0")
  2090.          (match_operand:DI 2 "general_operand" "d,<,*ao>,d")))
  2091.    (clobber (match_scratch:SI 3 "=X,X,&d,&d"))]
  2092.   ""
  2093.   "*
  2094. {
  2095.   if (DATA_REG_P (operands[0]))
  2096.     {
  2097.       if (DATA_REG_P (operands[2]))
  2098.     return \"add%.l %R2,%R0\;addx%.l %2,%0\";
  2099.       else if (GET_CODE (operands[2]) == MEM
  2100.       && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
  2101.     {
  2102.       return \"move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0\";
  2103.     }
  2104.       else
  2105.     {
  2106.       /* TODO : this should work also for CONST operands[2] */
  2107.       if (GET_CODE (operands[2]) == REG)
  2108.         operands[1] = gen_rtx (REG, SImode, REGNO (operands[2]) + 1);
  2109.       else
  2110.         operands[1] = adj_offsettable_operand (operands[2], 4);
  2111.       return \"move%.l %2,%3\;add%.l %1,%R0\;addx%.l %3,%0\";
  2112.     }
  2113.     }
  2114.   else if (GET_CODE (operands[0]) == MEM)
  2115.     {
  2116.       if (GET_CODE (operands[2]) == MEM
  2117.       && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
  2118.     return \"add%.l %2,%0\;addx%.l %2,%0\";
  2119.       CC_STATUS_INIT;
  2120.       if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  2121.     {
  2122.       operands[1] = gen_rtx (MEM, SImode,
  2123.            gen_rtx (PLUS, VOIDmode, XEXP(operands[0], 0),
  2124.                 gen_rtx (CONST_INT, VOIDmode, -8)));
  2125.       return \"move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1\";
  2126.     }
  2127.       else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  2128.     {
  2129.       operands[1] = XEXP(operands[0], 0);
  2130.       return \"add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1\";
  2131.     }
  2132.       else
  2133.     {
  2134.       operands[1] = adj_offsettable_operand (operands[0], 4);
  2135.       return \"add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0\";
  2136.     }
  2137.     }
  2138. } ")
  2139.  
  2140. (define_insn "addsi_lshrsi_31"
  2141.   [(set (match_operand:SI 0 "general_operand" "=dm")
  2142.     (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm")
  2143.             (const_int 31))
  2144.         (match_dup 1)))]
  2145.   ""
  2146.   "*
  2147. {
  2148.   operands[2] = operands[0];
  2149.   operands[3] = gen_label_rtx();
  2150.   if (GET_CODE (operands[0]) == MEM)
  2151.     {
  2152.       if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  2153.         operands[0] = gen_rtx (MEM, SImode, XEXP (XEXP (operands[0], 0), 0));
  2154.       else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  2155.         operands[2] = gen_rtx (MEM, SImode, XEXP (XEXP (operands[0], 0), 0));
  2156.     }
  2157.   output_asm_insn (\"move%.l %1,%0\", operands);
  2158. #ifdef MOTOROLA
  2159.   output_asm_insn (\"jbpl %l3\", operands);
  2160. #else
  2161.   output_asm_insn (\"jpl %l3\", operands);
  2162. #endif
  2163. #ifndef NO_ADDSUB_Q
  2164.   output_asm_insn (\"addq%.l %#1,%2\", operands);
  2165. #else
  2166.   output_asm_insn (\"add%.l %#1,%2\", operands);
  2167. #endif
  2168.   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
  2169.                 CODE_LABEL_NUMBER (operands[3]));
  2170.   return \"\";
  2171. }")
  2172.  
  2173. ;; Note that the middle two alternatives are near-duplicates
  2174. ;; in order to handle insns generated by reload.
  2175. ;; This is needed since they are not themselves reloaded,
  2176. ;; so commutativity won't apply to them.
  2177. (define_insn "addsi3"
  2178.   [(set (match_operand:SI 0 "general_operand" "=m,?a,?a,r")
  2179.     (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0")
  2180.          (match_operand:SI 2 "general_operand" "dIKLs,rJKi,a,mrIKLs")))]
  2181.   ""
  2182.   "*
  2183. {
  2184.   if (! operands_match_p (operands[0], operands[1]))
  2185.     {
  2186.       if (!ADDRESS_REG_P (operands[1]))
  2187.     {
  2188.       rtx tmp = operands[1];
  2189.  
  2190.       operands[1] = operands[2];
  2191.       operands[2] = tmp;
  2192.     }
  2193.  
  2194.       /* These insns can result from reloads to access
  2195.      stack slots over 64k from the frame pointer.  */
  2196.       if (GET_CODE (operands[2]) == CONST_INT
  2197.       && INTVAL (operands[2]) + 0x8000 >= (unsigned) 0x10000)
  2198.         return \"move%.l %2,%0\;add%.l %1,%0\";
  2199. #ifdef SGS
  2200.       if (GET_CODE (operands[2]) == REG)
  2201.     return \"lea 0(%1,%2.l),%0\";
  2202.       else
  2203.     return \"lea %c2(%1),%0\";
  2204. #else /* not SGS */
  2205. #ifdef MOTOROLA
  2206.       if (GET_CODE (operands[2]) == REG)
  2207.     return \"lea (%1,%2.l),%0\";
  2208.       else
  2209.     return \"lea (%c2,%1),%0\";
  2210. #else /* not MOTOROLA (MIT syntax) */
  2211.       if (GET_CODE (operands[2]) == REG)
  2212.     return \"lea %1@(0,%2:l),%0\";
  2213.       else
  2214.     return \"lea %1@(%c2),%0\";
  2215. #endif /* not MOTOROLA */
  2216. #endif /* not SGS */
  2217.     }
  2218.   if (GET_CODE (operands[2]) == CONST_INT)
  2219.     {
  2220. #ifndef NO_ADDSUB_Q
  2221.       if (INTVAL (operands[2]) > 0
  2222.       && INTVAL (operands[2]) <= 8)
  2223.     return (ADDRESS_REG_P (operands[0])
  2224.         ? \"addq%.w %2,%0\"
  2225.         : \"addq%.l %2,%0\");
  2226.       if (INTVAL (operands[2]) < 0
  2227.       && INTVAL (operands[2]) >= -8)
  2228.         {
  2229.       operands[2] = gen_rtx (CONST_INT, VOIDmode,
  2230.                      - INTVAL (operands[2]));
  2231.       return (ADDRESS_REG_P (operands[0])
  2232.           ? \"subq%.w %2,%0\"
  2233.           : \"subq%.l %2,%0\");
  2234.     }
  2235.       /* On everything except the 68000 it is faster to use two
  2236.      addqw instructions to add a small integer (8 < N <= 16)
  2237.      to an address register.  Likewise for subqw.*/
  2238.       if (INTVAL (operands[2]) > 8
  2239.       && INTVAL (operands[2]) <= 16
  2240.       && ADDRESS_REG_P (operands[0])
  2241.       && TARGET_68020) 
  2242.     {
  2243.       operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8);
  2244.       return \"addq%.w %#8,%0\;addq%.w %2,%0\";
  2245.     }
  2246.       if (INTVAL (operands[2]) < -8
  2247.       && INTVAL (operands[2]) >= -16
  2248.       && ADDRESS_REG_P (operands[0])
  2249.       && TARGET_68020) 
  2250.     {
  2251.       operands[2] = gen_rtx (CONST_INT, VOIDmode, 
  2252.                   - INTVAL (operands[2]) - 8);
  2253.       return \"subq%.w %#8,%0\;subq%.w %2,%0\";
  2254.     }
  2255. #endif
  2256.       if (ADDRESS_REG_P (operands[0])
  2257.       && INTVAL (operands[2]) >= -0x8000
  2258.       && INTVAL (operands[2]) < 0x8000)
  2259.     return \"add%.w %2,%0\";
  2260.     }
  2261.   return \"add%.l %2,%0\";
  2262. }")
  2263.  
  2264. (define_insn ""
  2265.   [(set (match_operand:SI 0 "general_operand" "=a")
  2266.     (plus:SI (match_operand:SI 1 "general_operand" "0")
  2267.          (sign_extend:SI
  2268.           (match_operand:HI 2 "nonimmediate_operand" "rm"))))]
  2269.   ""
  2270.   "add%.w %2,%0")
  2271.  
  2272. (define_insn "addhi3"
  2273.   [(set (match_operand:HI 0 "general_operand" "=m,r")
  2274.     (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
  2275.          (match_operand:HI 2 "general_operand" "dn,rmn")))]
  2276.   ""
  2277.   "*
  2278. {
  2279. #ifndef NO_ADDSUB_Q
  2280.   if (GET_CODE (operands[2]) == CONST_INT)
  2281.     {
  2282.       /* If the constant would be a negative number when interpreted as
  2283.      HImode, make it negative.  This is usually, but not always, done
  2284.      elsewhere in the compiler.  First check for constants out of range,
  2285.      which could confuse us.  */
  2286.  
  2287.       if (INTVAL (operands[2]) >= 32768)
  2288.     operands[2] = gen_rtx (CONST_INT, VOIDmode,
  2289.                    INTVAL (operands[2]) - 65536);
  2290.  
  2291.       if (INTVAL (operands[2]) > 0
  2292.       && INTVAL (operands[2]) <= 8)
  2293.     return \"addq%.w %2,%0\";
  2294.       if (INTVAL (operands[2]) < 0
  2295.       && INTVAL (operands[2]) >= -8)
  2296.     {
  2297.       operands[2] = gen_rtx (CONST_INT, VOIDmode,
  2298.                      - INTVAL (operands[2]));
  2299.       return \"subq%.w %2,%0\";
  2300.     }
  2301.       /* On everything except the 68000 it is faster to use two
  2302.      addqw instructions to add a small integer (8 < N <= 16)
  2303.      to an address register.  Likewise for subqw. */
  2304.       if (INTVAL (operands[2]) > 8
  2305.       && INTVAL (operands[2]) <= 16
  2306.       && ADDRESS_REG_P (operands[0])
  2307.       && TARGET_68020) 
  2308.     {
  2309.       operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8);
  2310.       return \"addq%.w %#8,%0\;addq%.w %2,%0\";
  2311.     }
  2312.       if (INTVAL (operands[2]) < -8
  2313.       && INTVAL (operands[2]) >= -16
  2314.       && ADDRESS_REG_P (operands[0])
  2315.       && TARGET_68020) 
  2316.     {
  2317.       operands[2] = gen_rtx (CONST_INT, VOIDmode, 
  2318.                  - INTVAL (operands[2]) - 8);
  2319.       return \"subq%.w %#8,%0\;subq%.w %2,%0\";
  2320.     }
  2321.     }
  2322. #endif
  2323.   return \"add%.w %2,%0\";
  2324. }")
  2325.  
  2326. ;; These insns must use MATCH_DUP instead of the more expected
  2327. ;; use of a matching constraint because the "output" here is also
  2328. ;; an input, so you can't use the matching constraint.  That also means
  2329. ;; that you can't use the "%", so you need patterns with the matched
  2330. ;; operand in both positions.
  2331.  
  2332. (define_insn ""
  2333.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  2334.     (plus:HI (match_dup 0)
  2335.          (match_operand:HI 1 "general_operand" "dn,rmn")))]
  2336.   ""
  2337.   "*
  2338. {
  2339. #ifndef NO_ADDSUB_Q
  2340.   if (GET_CODE (operands[1]) == CONST_INT)
  2341.     {
  2342.       /* If the constant would be a negative number when interpreted as
  2343.      HImode, make it negative.  This is usually, but not always, done
  2344.      elsewhere in the compiler.  First check for constants out of range,
  2345.      which could confuse us.  */
  2346.  
  2347.       if (INTVAL (operands[1]) >= 32768)
  2348.     operands[1] = gen_rtx (CONST_INT, VOIDmode,
  2349.                    INTVAL (operands[1]) - 65536);
  2350.  
  2351.       if (INTVAL (operands[1]) > 0
  2352.       && INTVAL (operands[1]) <= 8)
  2353.     return \"addq%.w %1,%0\";
  2354.       if (INTVAL (operands[1]) < 0
  2355.       && INTVAL (operands[1]) >= -8)
  2356.     {
  2357.       operands[1] = gen_rtx (CONST_INT, VOIDmode,
  2358.                      - INTVAL (operands[1]));
  2359.       return \"subq%.w %1,%0\";
  2360.     }
  2361.       /* On everything except the 68000 it is faster to use two
  2362.      addqw instructions to add a small integer (8 < N <= 16)
  2363.      to an address register.  Likewise for subqw. */
  2364.       if (INTVAL (operands[1]) > 8
  2365.       && INTVAL (operands[1]) <= 16
  2366.       && ADDRESS_REG_P (operands[0])
  2367.       && TARGET_68020) 
  2368.     {
  2369.       operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8);
  2370.       return \"addq%.w %#8,%0\;addq%.w %1,%0\";
  2371.     }
  2372.       if (INTVAL (operands[1]) < -8
  2373.       && INTVAL (operands[1]) >= -16
  2374.       && ADDRESS_REG_P (operands[0])
  2375.       && TARGET_68020) 
  2376.     {
  2377.       operands[1] = gen_rtx (CONST_INT, VOIDmode, 
  2378.                  - INTVAL (operands[1]) - 8);
  2379.       return \"subq%.w %#8,%0\;subq%.w %1,%0\";
  2380.     }
  2381.     }
  2382. #endif
  2383.   return \"add%.w %1,%0\";
  2384. }")
  2385.  
  2386. (define_insn ""
  2387.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  2388.     (plus:HI (match_operand:HI 1 "general_operand" "dn,rmn")
  2389.          (match_dup 0)))]
  2390.   ""
  2391.   "*
  2392. {
  2393. #ifndef NO_ADDSUB_Q
  2394.   if (GET_CODE (operands[1]) == CONST_INT)
  2395.     {
  2396.       /* If the constant would be a negative number when interpreted as
  2397.      HImode, make it negative.  This is usually, but not always, done
  2398.      elsewhere in the compiler.  First check for constants out of range,
  2399.      which could confuse us.  */
  2400.  
  2401.       if (INTVAL (operands[1]) >= 32768)
  2402.     operands[1] = gen_rtx (CONST_INT, VOIDmode,
  2403.                    INTVAL (operands[1]) - 65536);
  2404.  
  2405.       if (INTVAL (operands[1]) > 0
  2406.       && INTVAL (operands[1]) <= 8)
  2407.     return \"addq%.w %1,%0\";
  2408.       if (INTVAL (operands[1]) < 0
  2409.       && INTVAL (operands[1]) >= -8)
  2410.     {
  2411.       operands[1] = gen_rtx (CONST_INT, VOIDmode,
  2412.                      - INTVAL (operands[1]));
  2413.       return \"subq%.w %1,%0\";
  2414.     }
  2415.       /* On everything except the 68000 it is faster to use two
  2416.      addqw instructions to add a small integer (8 < N <= 16)
  2417.      to an address register.  Likewise for subqw. */
  2418.       if (INTVAL (operands[1]) > 8
  2419.       && INTVAL (operands[1]) <= 16
  2420.       && ADDRESS_REG_P (operands[0])
  2421.       && TARGET_68020) 
  2422.     {
  2423.       operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8);
  2424.       return \"addq%.w %#8,%0\;addq%.w %1,%0\";
  2425.     }
  2426.       if (INTVAL (operands[1]) < -8
  2427.       && INTVAL (operands[1]) >= -16
  2428.       && ADDRESS_REG_P (operands[0])
  2429.       && TARGET_68020) 
  2430.     {
  2431.       operands[1] = gen_rtx (CONST_INT, VOIDmode, 
  2432.                  - INTVAL (operands[1]) - 8);
  2433.       return \"subq%.w %#8,%0\;subq%.w %1,%0\";
  2434.     }
  2435.     }
  2436. #endif
  2437.   return \"add%.w %1,%0\";
  2438. }")
  2439.  
  2440. (define_insn "addqi3"
  2441.   [(set (match_operand:QI 0 "general_operand" "=m,d")
  2442.     (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
  2443.          (match_operand:QI 2 "general_operand" "dn,dmn")))]
  2444.   ""
  2445.   "*
  2446. {
  2447. #ifndef NO_ADDSUB_Q
  2448.   if (GET_CODE (operands[2]) == CONST_INT)
  2449.     {
  2450.       if (INTVAL (operands[2]) >= 128)
  2451.     operands[2] = gen_rtx (CONST_INT, VOIDmode,
  2452.                    INTVAL (operands[2]) - 256);
  2453.  
  2454.       if (INTVAL (operands[2]) > 0
  2455.       && INTVAL (operands[2]) <= 8)
  2456.     return \"addq%.b %2,%0\";
  2457.       if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
  2458.        {
  2459.      operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]));
  2460.      return \"subq%.b %2,%0\";
  2461.        }
  2462.     }
  2463. #endif
  2464.   return \"add%.b %2,%0\";
  2465. }")
  2466.  
  2467. (define_insn ""
  2468.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  2469.     (plus:QI (match_dup 0)
  2470.          (match_operand:QI 1 "general_operand" "dn,dmn")))]
  2471.   ""
  2472.   "*
  2473. {
  2474. #ifndef NO_ADDSUB_Q
  2475.   if (GET_CODE (operands[1]) == CONST_INT)
  2476.     {
  2477.       if (INTVAL (operands[1]) >= 128)
  2478.     operands[1] = gen_rtx (CONST_INT, VOIDmode,
  2479.                    INTVAL (operands[1]) - 256);
  2480.  
  2481.       if (INTVAL (operands[1]) > 0
  2482.       && INTVAL (operands[1]) <= 8)
  2483.     return \"addq%.b %1,%0\";
  2484.       if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
  2485.        {
  2486.      operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]));
  2487.      return \"subq%.b %1,%0\";
  2488.        }
  2489.     }
  2490. #endif
  2491.   return \"add%.b %1,%0\";
  2492. }")
  2493.  
  2494. (define_insn ""
  2495.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  2496.     (plus:QI (match_operand:QI 1 "general_operand" "dn,dmn")
  2497.          (match_dup 0)))]
  2498.   ""
  2499.   "*
  2500. {
  2501. #ifndef NO_ADDSUB_Q
  2502.   if (GET_CODE (operands[1]) == CONST_INT)
  2503.     {
  2504.       if (INTVAL (operands[1]) >= 128)
  2505.     operands[1] = gen_rtx (CONST_INT, VOIDmode,
  2506.                    INTVAL (operands[1]) - 256);
  2507.  
  2508.       if (INTVAL (operands[1]) > 0
  2509.       && INTVAL (operands[1]) <= 8)
  2510.     return \"addq%.b %1,%0\";
  2511.       if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
  2512.        {
  2513.      operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]));
  2514.      return \"subq%.b %1,%0\";
  2515.        }
  2516.     }
  2517. #endif
  2518.   return \"add%.b %1,%0\";
  2519. }")
  2520.  
  2521. (define_expand "adddf3"
  2522.   [(set (match_operand:DF 0 "general_operand" "")
  2523.     (plus:DF (match_operand:DF 1 "general_operand" "")
  2524.          (match_operand:DF 2 "general_operand" "")))]
  2525.   "TARGET_68881 || TARGET_FPA"
  2526.   "")
  2527.  
  2528. (define_insn ""
  2529.   [(set (match_operand:DF 0 "general_operand" "=x,y")
  2530.     (plus:DF (match_operand:DF 1 "general_operand" "%xH,y")
  2531.          (match_operand:DF 2 "general_operand" "xH,dmF")))]
  2532.   "TARGET_FPA"
  2533.   "*
  2534. {
  2535.   if (rtx_equal_p (operands[0], operands[1]))
  2536.     return \"fpadd%.d %y2,%0\";
  2537.   if (rtx_equal_p (operands[0], operands[2]))
  2538.     return \"fpadd%.d %y1,%0\";
  2539.   if (which_alternative == 0)
  2540.     return \"fpadd3%.d %w2,%w1,%0\";
  2541.   return \"fpadd3%.d %x2,%x1,%0\";
  2542. }")
  2543.  
  2544. (define_insn ""
  2545.   [(set (match_operand:DF 0 "general_operand" "=f")
  2546.     (plus:DF (float:DF (match_operand:SI 2 "general_operand" "dmi"))
  2547.          (match_operand:DF 1 "general_operand" "0")))]
  2548.   "TARGET_68881"
  2549.   "f%&add%.l %2,%0")
  2550.  
  2551. (define_insn ""
  2552.   [(set (match_operand:DF 0 "general_operand" "=f")
  2553.     (plus:DF (float:DF (match_operand:HI 2 "general_operand" "dmn"))
  2554.          (match_operand:DF 1 "general_operand" "0")))]
  2555.   "TARGET_68881"
  2556.   "f%&add%.w %2,%0")
  2557.  
  2558. (define_insn ""
  2559.   [(set (match_operand:DF 0 "general_operand" "=f")
  2560.     (plus:DF (float:DF (match_operand:QI 2 "general_operand" "dmn"))
  2561.          (match_operand:DF 1 "general_operand" "0")))]
  2562.   "TARGET_68881"
  2563.   "f%&add%.b %2,%0")
  2564.  
  2565. (define_insn ""
  2566.   [(set (match_operand:DF 0 "general_operand" "=f")
  2567.     (plus:DF (match_operand:DF 1 "general_operand" "%0")
  2568.          (match_operand:DF 2 "general_operand" "fmG")))]
  2569.   "TARGET_68881"
  2570.   "*
  2571. {
  2572.   if (REG_P (operands[2]))
  2573.     return \"f%&add%.x %2,%0\";
  2574.   return \"f%&add%.d %f2,%0\";
  2575. }")
  2576.  
  2577. (define_expand "addsf3"
  2578.   [(set (match_operand:SF 0 "general_operand" "")
  2579.     (plus:SF (match_operand:SF 1 "general_operand" "")
  2580.          (match_operand:SF 2 "general_operand" "")))]
  2581.   "TARGET_68881 || TARGET_FPA"
  2582.   "")
  2583.  
  2584. (define_insn ""
  2585.   [(set (match_operand:SF 0 "general_operand" "=x,y")
  2586.     (plus:SF (match_operand:SF 1 "general_operand" "%xH,y")
  2587.          (match_operand:SF 2 "general_operand" "xH,rmF")))]
  2588.   "TARGET_FPA"
  2589.   "*
  2590. {
  2591.   if (rtx_equal_p (operands[0], operands[1]))
  2592.     return \"fpadd%.s %w2,%0\";
  2593.   if (rtx_equal_p (operands[0], operands[2]))
  2594.     return \"fpadd%.s %w1,%0\";
  2595.   if (which_alternative == 0)
  2596.     return \"fpadd3%.s %w2,%w1,%0\";
  2597.   return \"fpadd3%.s %2,%1,%0\";
  2598. }")
  2599.  
  2600. (define_insn ""
  2601.   [(set (match_operand:SF 0 "general_operand" "=f")
  2602.     (plus:SF (float:SF (match_operand:SI 2 "general_operand" "dmi"))
  2603.          (match_operand:SF 1 "general_operand" "0")))]
  2604.   "TARGET_68881"
  2605.   "f%$add%.l %2,%0")
  2606.  
  2607. (define_insn ""
  2608.   [(set (match_operand:SF 0 "general_operand" "=f")
  2609.     (plus:SF (float:SF (match_operand:HI 2 "general_operand" "dmn"))
  2610.          (match_operand:SF 1 "general_operand" "0")))]
  2611.   "TARGET_68881"
  2612.   "f%$add%.w %2,%0")
  2613.  
  2614. (define_insn ""
  2615.   [(set (match_operand:SF 0 "general_operand" "=f")
  2616.     (plus:SF (float:SF (match_operand:QI 2 "general_operand" "dmn"))
  2617.          (match_operand:SF 1 "general_operand" "0")))]
  2618.   "TARGET_68881"
  2619.   "f%$add%.b %2,%0")
  2620.  
  2621. (define_insn ""
  2622.   [(set (match_operand:SF 0 "general_operand" "=f")
  2623.     (plus:SF (match_operand:SF 1 "general_operand" "%0")
  2624.          (match_operand:SF 2 "general_operand" "fdmF")))]
  2625.   "TARGET_68881"
  2626.   "*
  2627. {
  2628.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  2629.     return \"f%$add%.x %2,%0\";
  2630.   return \"f%$add%.s %f2,%0\";
  2631. }")
  2632.  
  2633. ;; subtract instructions
  2634.  
  2635. (define_insn "subdia_sexthishl32"
  2636.   [(set (match_operand:DI 0 "register_operand" "+a")
  2637.     (minus:DI (match_dup 0)
  2638.         (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm"))
  2639.             (const_int 32))))]
  2640.   ""
  2641.   "*
  2642. {
  2643.   CC_STATUS_INIT;
  2644.   return \"sub%.w %1,%0\";
  2645. } ")
  2646.  
  2647. (define_insn "subdid_sexthishl32"
  2648.   [(set (match_operand:DI 0 "general_operand" "+ro")
  2649.     (minus:DI (match_dup 0)
  2650.         (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm"))
  2651.             (const_int 32))))
  2652.    (clobber (match_scratch:SI 2 "=a"))]
  2653.   ""
  2654.   "*
  2655. {
  2656.   CC_STATUS_INIT;
  2657.   return \"move%.w %1,%2\;sub%.l %2,%0\";
  2658. } ")
  2659.  
  2660. (define_insn "subdi_dishl32"
  2661.   [(set (match_operand:DI 0 "general_operand" "+ro")
  2662.     (minus:DI (match_dup 0)
  2663.         (ashift:DI (match_operand:DI 1 "general_operand" "ro")
  2664.             (const_int 32))))]
  2665.   ""
  2666.   "*
  2667. {
  2668.   CC_STATUS_INIT;
  2669.   if (GET_CODE (operands[1]) == REG)
  2670.     operands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  2671.   else
  2672.     operands[1] = adj_offsettable_operand (operands[1], 4);
  2673.   return \"sub%.l %1,%0\";
  2674. } ")
  2675.  
  2676. (define_insn "subdi3"
  2677.   [(set (match_operand:DI 0 "general_operand" "=d,<,d,o<>")
  2678.     (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
  2679.          (match_operand:DI 2 "general_operand" "d,<,*ao>,d")))
  2680.    (clobber (match_scratch:SI 3 "=X,X,&d,&d"))]
  2681.   ""
  2682.   "*
  2683. {
  2684.   if (DATA_REG_P (operands[0]))
  2685.     {
  2686.       if (DATA_REG_P (operands[2]))
  2687.     return \"sub%.l %R2,%R0\;subx%.l %2,%0\";
  2688.       else if (GET_CODE (operands[2]) == MEM
  2689.       && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
  2690.     {
  2691.       return \"move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0\";
  2692.     }
  2693.       else
  2694.     {
  2695.       /* TODO : this should work also for CONST operands[2] */
  2696.       if (GET_CODE (operands[2]) == REG)
  2697.         operands[1] = gen_rtx (REG, SImode, REGNO (operands[2]) + 1);
  2698.       else
  2699.         operands[1] = adj_offsettable_operand (operands[2], 4);
  2700.       return \"move%.l %2,%3\;sub%.l %1,%R0\;subx%.l %3,%0\";
  2701.     }
  2702.     }
  2703.   else if (GET_CODE (operands[0]) == MEM)
  2704.     {
  2705.       if (GET_CODE (operands[2]) == MEM
  2706.       && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
  2707.     return \"sub%.l %2,%0\;subx%.l %2,%0\";
  2708.       CC_STATUS_INIT;
  2709.       if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  2710.     {
  2711.       operands[1] = gen_rtx (MEM, SImode,
  2712.            gen_rtx (PLUS, VOIDmode, XEXP(operands[0], 0),
  2713.                 gen_rtx (CONST_INT, VOIDmode, -8)));
  2714.       return \"move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1\";
  2715.     }
  2716.       else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  2717.     {
  2718.       operands[1] = XEXP(operands[0], 0);
  2719.       return \"sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1\";
  2720.     }
  2721.       else
  2722.     {
  2723.       operands[1] = adj_offsettable_operand (operands[0], 4);
  2724.       return \"sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0\";
  2725.     }
  2726.     }
  2727. } ")
  2728.  
  2729. (define_insn "subsi3"
  2730.   [(set (match_operand:SI 0 "general_operand" "=m,r")
  2731.     (minus:SI (match_operand:SI 1 "general_operand" "0,0")
  2732.           (match_operand:SI 2 "general_operand" "ds,mrs")))]
  2733.   ""
  2734.   "sub%.l %2,%0")
  2735.  
  2736. (define_insn ""
  2737.   [(set (match_operand:SI 0 "general_operand" "=a")
  2738.     (minus:SI (match_operand:SI 1 "general_operand" "0")
  2739.           (sign_extend:SI
  2740.            (match_operand:HI 2 "nonimmediate_operand" "rm"))))]
  2741.   ""
  2742.   "sub%.w %2,%0")
  2743.  
  2744. (define_insn "subhi3"
  2745.   [(set (match_operand:HI 0 "general_operand" "=m,r")
  2746.     (minus:HI (match_operand:HI 1 "general_operand" "0,0")
  2747.           (match_operand:HI 2 "general_operand" "dn,rmn")))]
  2748.   ""
  2749.   "sub%.w %2,%0")
  2750.  
  2751. (define_insn ""
  2752.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  2753.     (minus:HI (match_dup 0)
  2754.           (match_operand:HI 1 "general_operand" "dn,rmn")))]
  2755.   ""
  2756.   "sub%.w %1,%0")
  2757.  
  2758. (define_insn "subqi3"
  2759.   [(set (match_operand:QI 0 "general_operand" "=m,d")
  2760.     (minus:QI (match_operand:QI 1 "general_operand" "0,0")
  2761.           (match_operand:QI 2 "general_operand" "dn,dmn")))]
  2762.   ""
  2763.   "sub%.b %2,%0")
  2764.  
  2765. (define_insn ""
  2766.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  2767.     (minus:QI (match_dup 0)
  2768.           (match_operand:QI 1 "general_operand" "dn,dmn")))]
  2769.   ""
  2770.   "sub%.b %1,%0")
  2771.  
  2772. (define_expand "subdf3"
  2773.   [(set (match_operand:DF 0 "general_operand" "")
  2774.     (minus:DF (match_operand:DF 1 "general_operand" "")
  2775.           (match_operand:DF 2 "general_operand" "")))]
  2776.   "TARGET_68881 || TARGET_FPA"
  2777.   "")
  2778.  
  2779. (define_insn ""
  2780.   [(set (match_operand:DF 0 "general_operand" "=x,y,y")
  2781.     (minus:DF (match_operand:DF 1 "general_operand" "xH,y,dmF")
  2782.           (match_operand:DF 2 "general_operand" "xH,dmF,0")))]
  2783.   "TARGET_FPA"
  2784.   "*
  2785. {
  2786.   if (rtx_equal_p (operands[0], operands[2]))
  2787.     return \"fprsub%.d %y1,%0\";
  2788.   if (rtx_equal_p (operands[0], operands[1]))
  2789.     return \"fpsub%.d %y2,%0\";
  2790.   if (which_alternative == 0)
  2791.     return \"fpsub3%.d %w2,%w1,%0\";
  2792.   return \"fpsub3%.d %x2,%x1,%0\";
  2793. }")
  2794.  
  2795. (define_insn ""
  2796.   [(set (match_operand:DF 0 "general_operand" "=f")
  2797.     (minus:DF (match_operand:DF 1 "general_operand" "0")
  2798.           (float:DF (match_operand:SI 2 "general_operand" "dmi"))))]
  2799.   "TARGET_68881"
  2800.   "f%&sub%.l %2,%0")
  2801.  
  2802. (define_insn ""
  2803.   [(set (match_operand:DF 0 "general_operand" "=f")
  2804.     (minus:DF (match_operand:DF 1 "general_operand" "0")
  2805.           (float:DF (match_operand:HI 2 "general_operand" "dmn"))))]
  2806.   "TARGET_68881"
  2807.   "f%&sub%.w %2,%0")
  2808.  
  2809. (define_insn ""
  2810.   [(set (match_operand:DF 0 "general_operand" "=f")
  2811.     (minus:DF (match_operand:DF 1 "general_operand" "0")
  2812.           (float:DF (match_operand:QI 2 "general_operand" "dmn"))))]
  2813.   "TARGET_68881"
  2814.   "f%&sub%.b %2,%0")
  2815.  
  2816. (define_insn ""
  2817.   [(set (match_operand:DF 0 "general_operand" "=f")
  2818.     (minus:DF (match_operand:DF 1 "general_operand" "0")
  2819.           (match_operand:DF 2 "general_operand" "fmG")))]
  2820.   "TARGET_68881"
  2821.   "*
  2822. {
  2823.   if (REG_P (operands[2]))
  2824.     return \"f%&sub%.x %2,%0\";
  2825.   return \"f%&sub%.d %f2,%0\";
  2826. }")
  2827.  
  2828. (define_expand "subsf3"
  2829.   [(set (match_operand:SF 0 "general_operand" "")
  2830.     (minus:SF (match_operand:SF 1 "general_operand" "")
  2831.           (match_operand:SF 2 "general_operand" "")))]
  2832.   "TARGET_68881 || TARGET_FPA"
  2833.   "")
  2834.  
  2835. (define_insn ""
  2836.   [(set (match_operand:SF 0 "general_operand" "=x,y,y")
  2837.     (minus:SF (match_operand:SF 1 "general_operand" "xH,y,rmF")
  2838.           (match_operand:SF 2 "general_operand" "xH,rmF,0")))]
  2839.   "TARGET_FPA"
  2840.   "*
  2841. {
  2842.   if (rtx_equal_p (operands[0], operands[2]))
  2843.     return \"fprsub%.s %w1,%0\";
  2844.   if (rtx_equal_p (operands[0], operands[1]))
  2845.     return \"fpsub%.s %w2,%0\";
  2846.   if (which_alternative == 0)
  2847.     return \"fpsub3%.s %w2,%w1,%0\";
  2848.   return \"fpsub3%.s %2,%1,%0\";
  2849. }")
  2850.  
  2851. (define_insn ""
  2852.   [(set (match_operand:SF 0 "general_operand" "=f")
  2853.     (minus:SF (match_operand:SF 1 "general_operand" "0")
  2854.           (float:SF (match_operand:SI 2 "general_operand" "dmi"))))]
  2855.   "TARGET_68881"
  2856.   "f%$sub%.l %2,%0")
  2857.  
  2858. (define_insn ""
  2859.   [(set (match_operand:SF 0 "general_operand" "=f")
  2860.     (minus:SF (match_operand:SF 1 "general_operand" "0")
  2861.           (float:SF (match_operand:HI 2 "general_operand" "dmn"))))]
  2862.   "TARGET_68881"
  2863.   "f%$sub%.w %2,%0")
  2864.  
  2865. (define_insn ""
  2866.   [(set (match_operand:SF 0 "general_operand" "=f")
  2867.     (minus:SF (match_operand:SF 1 "general_operand" "0")
  2868.           (float:SF (match_operand:QI 2 "general_operand" "dmn"))))]
  2869.   "TARGET_68881"
  2870.   "f%$sub%.b %2,%0")
  2871.  
  2872. (define_insn ""
  2873.   [(set (match_operand:SF 0 "general_operand" "=f")
  2874.     (minus:SF (match_operand:SF 1 "general_operand" "0")
  2875.           (match_operand:SF 2 "general_operand" "fdmF")))]
  2876.   "TARGET_68881"
  2877.   "*
  2878. {
  2879.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  2880.     return \"f%$sub%.x %2,%0\";
  2881.   return \"f%$sub%.s %f2,%0\";
  2882. }")
  2883.  
  2884. ;; multiply instructions
  2885.  
  2886. (define_insn "mulhi3"
  2887.   [(set (match_operand:HI 0 "general_operand" "=d")
  2888.     (mult:HI (match_operand:HI 1 "general_operand" "%0")
  2889.          (match_operand:HI 2 "general_operand" "dmn")))]
  2890.   ""
  2891.   "*
  2892. {
  2893. #if defined(MOTOROLA) && !defined(CRDS)
  2894.   return \"muls%.w %2,%0\";
  2895. #else
  2896.   return \"muls %2,%0\";
  2897. #endif
  2898. }")
  2899.  
  2900. (define_insn "mulhisi3"
  2901.   [(set (match_operand:SI 0 "general_operand" "=d")
  2902.     (mult:SI (sign_extend:SI
  2903.           (match_operand:HI 1 "nonimmediate_operand" "%0"))
  2904.          (sign_extend:SI
  2905.           (match_operand:HI 2 "nonimmediate_operand" "dm"))))]
  2906.   ""
  2907.   "*
  2908. {
  2909. #if defined(MOTOROLA) && !defined(CRDS)
  2910.   return \"muls%.w %2,%0\";
  2911. #else
  2912.   return \"muls %2,%0\";
  2913. #endif
  2914. }")
  2915.  
  2916. (define_insn ""
  2917.   [(set (match_operand:SI 0 "general_operand" "=d")
  2918.     (mult:SI (sign_extend:SI
  2919.           (match_operand:HI 1 "nonimmediate_operand" "%0"))
  2920.          (match_operand:SI 2 "const_int_operand" "n")))]
  2921.   "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
  2922.   "*
  2923. {
  2924. #if defined(MOTOROLA) && !defined(CRDS)
  2925.   return \"muls%.w %2,%0\";
  2926. #else
  2927.   return \"muls %2,%0\";
  2928. #endif
  2929. }")
  2930.  
  2931. (define_insn "mulsi3"
  2932.   [(set (match_operand:SI 0 "general_operand" "=d")
  2933.     (mult:SI (match_operand:SI 1 "general_operand" "%0")
  2934.          (match_operand:SI 2 "general_operand" "dmsK")))]
  2935.   "TARGET_68020"
  2936.   "muls%.l %2,%0")
  2937.  
  2938. (define_insn "umulhisi3"
  2939.   [(set (match_operand:SI 0 "general_operand" "=d")
  2940.     (mult:SI (zero_extend:SI
  2941.           (match_operand:HI 1 "nonimmediate_operand" "%0"))
  2942.          (zero_extend:SI
  2943.           (match_operand:HI 2 "nonimmediate_operand" "dm"))))]
  2944.   ""
  2945.   "*
  2946. {
  2947. #if defined(MOTOROLA) && !defined(CRDS)
  2948.   return \"mulu%.w %2,%0\";
  2949. #else
  2950.   return \"mulu %2,%0\";
  2951. #endif
  2952. }")
  2953.  
  2954. (define_insn ""
  2955.   [(set (match_operand:SI 0 "general_operand" "=d")
  2956.     (mult:SI (zero_extend:SI
  2957.           (match_operand:HI 1 "nonimmediate_operand" "%0"))
  2958.          (match_operand:SI 2 "const_int_operand" "n")))]
  2959.   "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
  2960.   "*
  2961. {
  2962. #if defined(MOTOROLA) && !defined(CRDS)
  2963.   return \"mulu%.w %2,%0\";
  2964. #else
  2965.   return \"mulu %2,%0\";
  2966. #endif
  2967. }")
  2968.  
  2969. ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
  2970. ;; proper matching constraint.  This is because the matching is between
  2971. ;; the high-numbered word of the DImode operand[0] and operand[1].
  2972. (define_expand "umulsidi3"
  2973.   [(parallel
  2974.     [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 1)
  2975.       (mult:SI (match_operand:SI 1 "register_operand" "")
  2976.            (match_operand:SI 2 "nonimmediate_operand" "")))
  2977.      (set (subreg:SI (match_dup 0) 0)
  2978.       (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
  2979.                          (zero_extend:DI (match_dup 2)))
  2980.                     (const_int 32))))])]
  2981.   "TARGET_68020"
  2982.   "")
  2983.  
  2984. (define_insn ""
  2985.   [(set (match_operand:SI 0 "register_operand" "=d")
  2986.     (mult:SI (match_operand:SI 1 "register_operand" "%0")
  2987.           (match_operand:SI 2 "nonimmediate_operand" "dm")))
  2988.    (set (match_operand:SI 3 "register_operand" "=d")
  2989.     (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
  2990.                        (zero_extend:DI (match_dup 2)))
  2991.                   (const_int 32))))]
  2992.   "TARGET_68020"
  2993.   "mulu%.l %2,%3:%0")
  2994.  
  2995. ; Match immediate case.  For 2.4 only match things < 2^31.
  2996. ; It's tricky with larger values in these patterns since we need to match
  2997. ; values between the two parallel multiplies, between a CONST_DOUBLE and
  2998. ; a CONST_INT.
  2999. (define_insn ""
  3000.   [(set (match_operand:SI 0 "register_operand" "=d")
  3001.     (mult:SI (match_operand:SI 1 "register_operand" "%0")
  3002.          (match_operand:SI 2 "const_int_operand" "n")))
  3003.    (set (match_operand:SI 3 "register_operand" "=d")
  3004.     (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
  3005.                        (match_dup 2))
  3006.                   (const_int 32))))]
  3007.   "TARGET_68020
  3008.    && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
  3009.   "mulu%.l %2,%3:%0")
  3010.  
  3011. (define_expand "mulsidi3"
  3012.   [(parallel
  3013.     [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 1)
  3014.       (mult:SI (match_operand:SI 1 "register_operand" "")
  3015.            (match_operand:SI 2 "nonimmediate_operand" "")))
  3016.      (set (subreg:SI (match_dup 0) 0)
  3017.       (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
  3018.                          (sign_extend:DI (match_dup 2)))
  3019.                     (const_int 32))))])]
  3020.   "TARGET_68020"
  3021.   "")
  3022.  
  3023. (define_insn ""
  3024.   [(set (match_operand:SI 0 "register_operand" "=d")
  3025.     (mult:SI (match_operand:SI 1 "register_operand" "%0")
  3026.          (match_operand:SI 2 "nonimmediate_operand" "dm")))
  3027.    (set (match_operand:SI 3 "register_operand" "=d")
  3028.     (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
  3029.                        (sign_extend:DI (match_dup 2)))
  3030.                   (const_int 32))))]
  3031.   "TARGET_68020"
  3032.   "muls%.l %2,%3:%0")
  3033.  
  3034. (define_insn ""
  3035.   [(set (match_operand:SI 0 "register_operand" "=d")
  3036.     (mult:SI (match_operand:SI 1 "register_operand" "%0")
  3037.          (match_operand:SI 2 "const_int_operand" "n")))
  3038.    (set (match_operand:SI 3 "register_operand" "=d")
  3039.     (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
  3040.                        (match_dup 2))
  3041.                   (const_int 32))))]
  3042.   "TARGET_68020
  3043.    /* This test is a noop on 32 bit machines,
  3044.       but important for a cross-compiler hosted on 64-bit machines.  */
  3045.    && INTVAL (operands[2]) <= 0x7fffffff
  3046.    && INTVAL (operands[2]) >= -0x80000000"
  3047.   "muls%.l %2,%3:%0")
  3048.  
  3049. (define_expand "umulsi3_highpart"
  3050.   [(parallel
  3051.     [(set (match_operand:SI 0 "register_operand" "")
  3052.       (truncate:SI
  3053.        (lshiftrt:DI
  3054.         (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
  3055.              (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
  3056.         (const_int 32))))
  3057.      (clobber (match_dup 3))])]
  3058.   "TARGET_68020"
  3059.   "
  3060. {
  3061.   operands[3] = gen_reg_rtx (SImode);
  3062.   if (GET_CODE (operands[2]) == CONST_INT
  3063.       || GET_CODE (operands[2]) == CONST_DOUBLE)
  3064.     {
  3065.       if (! const_uint32_operand (operands[2], VOIDmode))
  3066.     abort ();
  3067.       /* We have to adjust the operand order for the matching constraints.  */
  3068.       emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
  3069.                          operands[1], operands[2]));
  3070.       DONE;
  3071.     }
  3072. }")
  3073.  
  3074. (define_insn ""
  3075.   [(set (match_operand:SI 0 "register_operand" "=d")
  3076.     (truncate:SI
  3077.      (lshiftrt:DI
  3078.       (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
  3079.            (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
  3080.       (const_int 32))))
  3081.    (clobber (match_operand:SI 1 "register_operand" "=d"))]
  3082.   "TARGET_68020"
  3083.   "mulu%.l %3,%0:%1")
  3084.  
  3085. (define_insn "const_umulsi3_highpart"
  3086.   [(set (match_operand:SI 0 "register_operand" "=d")
  3087.     (truncate:SI
  3088.      (lshiftrt:DI
  3089.       (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
  3090.            (match_operand 3 "const_uint32_operand" ""))
  3091.       (const_int 32))))
  3092.    (clobber (match_operand:SI 1 "register_operand" "=d"))]
  3093.   "TARGET_68020"
  3094.   "mulu%.l %3,%0:%1")
  3095.  
  3096. (define_expand "smulsi3_highpart"
  3097.   [(parallel
  3098.     [(set (match_operand:SI 0 "register_operand" "")
  3099.       (truncate:SI
  3100.        (lshiftrt:DI
  3101.         (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
  3102.              (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
  3103.         (const_int 32))))
  3104.      (clobber (match_dup 3))])]
  3105.   "TARGET_68020"
  3106.   "
  3107. {
  3108.   operands[3] = gen_reg_rtx (SImode);
  3109.   if (GET_CODE (operands[2]) == CONST_INT
  3110.       || GET_CODE (operands[2]) == CONST_DOUBLE)
  3111.     {
  3112.       if (! const_sint32_operand (operands[2], VOIDmode))
  3113.     abort ();
  3114.       /* We have to adjust the operand order for the matching constraints.  */
  3115.       emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
  3116.                          operands[1], operands[2]));
  3117.       DONE;
  3118.     }
  3119. }")
  3120.  
  3121. (define_insn ""
  3122.   [(set (match_operand:SI 0 "register_operand" "=d")
  3123.     (truncate:SI
  3124.      (lshiftrt:DI
  3125.       (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
  3126.            (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
  3127.       (const_int 32))))
  3128.    (clobber (match_operand:SI 1 "register_operand" "=d"))]
  3129.   "TARGET_68020"
  3130.   "muls%.l %3,%0:%1")
  3131.  
  3132. (define_insn "const_smulsi3_highpart"
  3133.   [(set (match_operand:SI 0 "register_operand" "=d")
  3134.     (truncate:SI
  3135.      (lshiftrt:DI
  3136.       (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
  3137.            (match_operand 3 "const_sint32_operand" ""))
  3138.       (const_int 32))))
  3139.    (clobber (match_operand:SI 1 "register_operand" "=d"))]
  3140.   "TARGET_68020"
  3141.   "muls%.l %3,%0:%1")
  3142.  
  3143. (define_expand "muldf3"
  3144.   [(set (match_operand:DF 0 "general_operand" "")
  3145.     (mult:DF (match_operand:DF 1 "general_operand" "")
  3146.          (match_operand:DF 2 "general_operand" "")))]
  3147.   "TARGET_68881 || TARGET_FPA"
  3148.   "")
  3149.  
  3150. (define_insn ""
  3151.   [(set (match_operand:DF 0 "general_operand" "=x,y")
  3152.     (mult:DF (match_operand:DF 1 "general_operand" "%xH,y")
  3153.          (match_operand:DF 2 "general_operand" "xH,rmF")))]
  3154.   "TARGET_FPA"
  3155.   "*
  3156. {
  3157.   if (rtx_equal_p (operands[1], operands[2]))
  3158.     return \"fpsqr%.d %y1,%0\";
  3159.   if (rtx_equal_p (operands[0], operands[1]))
  3160.     return \"fpmul%.d %y2,%0\";
  3161.   if (rtx_equal_p (operands[0], operands[2]))
  3162.     return \"fpmul%.d %y1,%0\";
  3163.   if (which_alternative == 0)
  3164.     return \"fpmul3%.d %w2,%w1,%0\";
  3165.   return \"fpmul3%.d %x2,%x1,%0\";
  3166. }")
  3167.  
  3168. (define_insn ""
  3169.   [(set (match_operand:DF 0 "general_operand" "=f")
  3170.     (mult:DF (float:DF (match_operand:SI 2 "general_operand" "dmi"))
  3171.          (match_operand:DF 1 "general_operand" "0")))]
  3172.   "TARGET_68881"
  3173.   "f%&mul%.l %2,%0")
  3174.  
  3175. (define_insn ""
  3176.   [(set (match_operand:DF 0 "general_operand" "=f")
  3177.     (mult:DF (float:DF (match_operand:HI 2 "general_operand" "dmn"))
  3178.          (match_operand:DF 1 "general_operand" "0")))]
  3179.   "TARGET_68881"
  3180.   "f%&mul%.w %2,%0")
  3181.  
  3182. (define_insn ""
  3183.   [(set (match_operand:DF 0 "general_operand" "=f")
  3184.     (mult:DF (float:DF (match_operand:QI 2 "general_operand" "dmn"))
  3185.          (match_operand:DF 1 "general_operand" "0")))]
  3186.   "TARGET_68881"
  3187.   "f%&mul%.b %2,%0")
  3188.  
  3189. (define_insn ""
  3190.   [(set (match_operand:DF 0 "general_operand" "=f")
  3191.     (mult:DF (match_operand:DF 1 "general_operand" "%0")
  3192.          (match_operand:DF 2 "general_operand" "fmG")))]
  3193.   "TARGET_68881"
  3194.   "*
  3195. {
  3196.   if (GET_CODE (operands[2]) == CONST_DOUBLE
  3197.       && floating_exact_log2 (operands[2]) && !TARGET_68040)
  3198.     {
  3199.       int i = floating_exact_log2 (operands[2]);
  3200.       operands[2] = gen_rtx (CONST_INT, VOIDmode, i);
  3201.       return \"fscale%.l %2,%0\";
  3202.     }
  3203.   if (REG_P (operands[2]))
  3204.     return \"f%&mul%.x %2,%0\";
  3205.   return \"f%&mul%.d %f2,%0\";
  3206. }")
  3207.  
  3208. (define_expand "mulsf3"
  3209.   [(set (match_operand:SF 0 "general_operand" "")
  3210.     (mult:SF (match_operand:SF 1 "general_operand" "")
  3211.          (match_operand:SF 2 "general_operand" "")))]
  3212.   "TARGET_68881 || TARGET_FPA"
  3213.   "")
  3214.  
  3215. (define_insn ""
  3216.   [(set (match_operand:SF 0 "general_operand" "=x,y")
  3217.     (mult:SF (match_operand:SF 1 "general_operand" "%xH,y")
  3218.          (match_operand:SF 2 "general_operand" "xH,rmF")))]
  3219.   "TARGET_FPA"
  3220.   "*
  3221. {
  3222.   if (rtx_equal_p (operands[1], operands[2]))
  3223.     return \"fpsqr%.s %w1,%0\";
  3224.   if (rtx_equal_p (operands[0], operands[1]))
  3225.     return \"fpmul%.s %w2,%0\";
  3226.   if (rtx_equal_p (operands[0], operands[2]))
  3227.     return \"fpmul%.s %w1,%0\";
  3228.   if (which_alternative == 0)
  3229.     return \"fpmul3%.s %w2,%w1,%0\";
  3230.   return \"fpmul3%.s %2,%1,%0\";
  3231. }")
  3232.  
  3233. (define_insn ""
  3234.   [(set (match_operand:SF 0 "general_operand" "=f")
  3235.     (mult:SF (float:SF (match_operand:SI 2 "general_operand" "dmi"))
  3236.          (match_operand:SF 1 "general_operand" "0")))]
  3237.   "TARGET_68881"
  3238.   "*
  3239. {
  3240.   return (TARGET_68040_ONLY
  3241.           ? \"fsmul%.l %2,%0\"
  3242.           : \"fsglmul%.l %2,%0\");
  3243. }")
  3244.  
  3245. (define_insn ""
  3246.   [(set (match_operand:SF 0 "general_operand" "=f")
  3247.     (mult:SF (float:SF (match_operand:HI 2 "general_operand" "dmn"))
  3248.          (match_operand:SF 1 "general_operand" "0")))]
  3249.   "TARGET_68881"
  3250.   "*
  3251. {
  3252.   return (TARGET_68040_ONLY
  3253.           ? \"fsmul%.w %2,%0\"
  3254.           : \"fsglmul%.w %2,%0\");
  3255. }")
  3256.  
  3257. (define_insn ""
  3258.   [(set (match_operand:SF 0 "general_operand" "=f")
  3259.     (mult:SF (float:SF (match_operand:QI 2 "general_operand" "dmn"))
  3260.          (match_operand:SF 1 "general_operand" "0")))]
  3261.   "TARGET_68881"
  3262.   "*
  3263. {
  3264.   return (TARGET_68040_ONLY
  3265.           ? \"fsmul%.b %2,%0\"
  3266.           : \"fsglmul%.b %2,%0\");
  3267. }")
  3268.  
  3269. (define_insn ""
  3270.   [(set (match_operand:SF 0 "general_operand" "=f")
  3271.     (mult:SF (match_operand:SF 1 "general_operand" "%0")
  3272.          (match_operand:SF 2 "general_operand" "fdmF")))]
  3273.   "TARGET_68881"
  3274.   "*
  3275. {
  3276. #ifdef FSGLMUL_USE_S
  3277.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  3278.     return (TARGET_68040_ONLY
  3279.         ? \"fsmul%.s %2,%0\"
  3280.         : \"fsglmul%.s %2,%0\");
  3281. #else
  3282.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  3283.     return (TARGET_68040_ONLY
  3284.         ? \"fsmul%.x %2,%0\"
  3285.         : \"fsglmul%.x %2,%0\");
  3286. #endif
  3287.   return (TARGET_68040_ONLY
  3288.       ? \"fsmul%.s %f2,%0\"
  3289.       : \"fsglmul%.s %f2,%0\");
  3290. }")
  3291.  
  3292. ;; divide instructions
  3293.  
  3294. (define_expand "divdf3"
  3295.   [(set (match_operand:DF 0 "general_operand" "")
  3296.     (div:DF (match_operand:DF 1 "general_operand" "")
  3297.         (match_operand:DF 2 "general_operand" "")))]
  3298.   "TARGET_68881 || TARGET_FPA"
  3299.   "")
  3300.  
  3301. (define_insn ""
  3302.   [(set (match_operand:DF 0 "general_operand" "=x,y,y")
  3303.     (div:DF (match_operand:DF 1 "general_operand" "xH,y,rmF")
  3304.         (match_operand:DF 2 "general_operand" "xH,rmF,0")))]
  3305.   "TARGET_FPA"
  3306.   "*
  3307. {
  3308.   if (rtx_equal_p (operands[0], operands[2]))
  3309.     return \"fprdiv%.d %y1,%0\";
  3310.   if (rtx_equal_p (operands[0], operands[1]))
  3311.     return \"fpdiv%.d %y2,%0\";
  3312.   if (which_alternative == 0)
  3313.     return \"fpdiv3%.d %w2,%w1,%0\";
  3314.   return \"fpdiv3%.d %x2,%x1,%x0\";
  3315. }")
  3316.  
  3317. (define_insn ""
  3318.   [(set (match_operand:DF 0 "general_operand" "=f")
  3319.     (div:DF (match_operand:DF 1 "general_operand" "0")
  3320.         (float:DF (match_operand:SI 2 "general_operand" "dmi"))))]
  3321.   "TARGET_68881"
  3322.   "f%&div%.l %2,%0")
  3323.  
  3324. (define_insn ""
  3325.   [(set (match_operand:DF 0 "general_operand" "=f")
  3326.     (div:DF (match_operand:DF 1 "general_operand" "0")
  3327.         (float:DF (match_operand:HI 2 "general_operand" "dmn"))))]
  3328.   "TARGET_68881"
  3329.   "f%&div%.w %2,%0")
  3330.  
  3331. (define_insn ""
  3332.   [(set (match_operand:DF 0 "general_operand" "=f")
  3333.     (div:DF (match_operand:DF 1 "general_operand" "0")
  3334.         (float:DF (match_operand:QI 2 "general_operand" "dmn"))))]
  3335.   "TARGET_68881"
  3336.   "f%&div%.b %2,%0")
  3337.  
  3338. (define_insn ""
  3339.   [(set (match_operand:DF 0 "general_operand" "=f")
  3340.     (div:DF (match_operand:DF 1 "general_operand" "0")
  3341.         (match_operand:DF 2 "general_operand" "fmG")))]
  3342.   "TARGET_68881"
  3343.   "*
  3344. {
  3345.   if (REG_P (operands[2]))
  3346.     return \"f%&div%.x %2,%0\";
  3347.   return \"f%&div%.d %f2,%0\";
  3348. }")
  3349.  
  3350. (define_expand "divsf3"
  3351.   [(set (match_operand:SF 0 "general_operand" "")
  3352.     (div:SF (match_operand:SF 1 "general_operand" "")
  3353.         (match_operand:SF 2 "general_operand" "")))]
  3354.   "TARGET_68881 || TARGET_FPA"
  3355.   "")
  3356.  
  3357. (define_insn ""
  3358.   [(set (match_operand:SF 0 "general_operand" "=x,y,y")
  3359.     (div:SF (match_operand:SF 1 "general_operand" "xH,y,rmF")
  3360.         (match_operand:SF 2 "general_operand" "xH,rmF,0")))]
  3361.   "TARGET_FPA"
  3362.   "*
  3363. {
  3364.   if (rtx_equal_p (operands[0], operands[1]))
  3365.     return \"fpdiv%.s %w2,%0\";
  3366.   if (rtx_equal_p (operands[0], operands[2]))
  3367.     return \"fprdiv%.s %w1,%0\";
  3368.   if (which_alternative == 0)
  3369.     return \"fpdiv3%.s %w2,%w1,%0\";
  3370.   return \"fpdiv3%.s %2,%1,%0\";
  3371. }")
  3372.  
  3373. (define_insn ""
  3374.   [(set (match_operand:SF 0 "general_operand" "=f")
  3375.     (div:SF (match_operand:SF 1 "general_operand" "0")
  3376.         (float:SF (match_operand:SI 2 "general_operand" "dmi"))))]
  3377.   "TARGET_68881"
  3378.   "*
  3379. {
  3380.   return (TARGET_68040_ONLY
  3381.           ? \"fsdiv%.l %2,%0\"
  3382.           : \"fsgldiv%.l %2,%0\");
  3383. }")
  3384.  
  3385. (define_insn ""
  3386.   [(set (match_operand:SF 0 "general_operand" "=f")
  3387.     (div:SF (match_operand:SF 1 "general_operand" "0")
  3388.         (float:SF (match_operand:HI 2 "general_operand" "dmn"))))]
  3389.   "TARGET_68881"
  3390.   "*
  3391. {
  3392.   return (TARGET_68040_ONLY
  3393.           ? \"fsdiv%.w %2,%0\"
  3394.           : \"fsgldiv%.w %2,%0\");
  3395. }")
  3396.  
  3397. (define_insn ""
  3398.   [(set (match_operand:SF 0 "general_operand" "=f")
  3399.     (div:SF (match_operand:SF 1 "general_operand" "0")
  3400.         (float:SF (match_operand:QI 2 "general_operand" "dmn"))))]
  3401.   "TARGET_68881"
  3402.   "*
  3403. {
  3404.   return (TARGET_68040_ONLY
  3405.           ? \"fsdiv%.b %2,%0\"
  3406.           : \"fsgldiv%.b %2,%0\");
  3407. }")
  3408.  
  3409. (define_insn ""
  3410.   [(set (match_operand:SF 0 "general_operand" "=f")
  3411.     (div:SF (match_operand:SF 1 "general_operand" "0")
  3412.         (match_operand:SF 2 "general_operand" "fdmF")))]
  3413.   "TARGET_68881"
  3414.   "*
  3415. {
  3416. #ifdef FSGLDIV_USE_S
  3417.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  3418.     return (TARGET_68040_ONLY
  3419.         ? \"fsdiv%.s %2,%0\"
  3420.         : \"fsgldiv%.s %2,%0\");
  3421. #else
  3422.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  3423.     return (TARGET_68040_ONLY
  3424.         ? \"fsdiv%.x %2,%0\"
  3425.         : \"fsgldiv%.x %2,%0\");
  3426. #endif
  3427.   return (TARGET_68040_ONLY
  3428.       ? \"fsdiv%.s %f2,%0\"
  3429.       : \"fsgldiv%.s %f2,%0\");
  3430. }")
  3431.  
  3432. ;; Remainder instructions.
  3433.  
  3434. (define_insn "divmodsi4"
  3435.   [(set (match_operand:SI 0 "general_operand" "=d")
  3436.     (div:SI (match_operand:SI 1 "general_operand" "0")
  3437.         (match_operand:SI 2 "general_operand" "dmsK")))
  3438.    (set (match_operand:SI 3 "general_operand" "=d")
  3439.     (mod:SI (match_dup 1) (match_dup 2)))]
  3440.   "TARGET_68020"
  3441.   "*
  3442. {
  3443.   if (find_reg_note (insn, REG_UNUSED, operands[3]))
  3444.     return \"divs%.l %2,%0\";
  3445.   else
  3446.     return \"divsl%.l %2,%3:%0\";
  3447. }")
  3448.  
  3449. (define_insn "udivmodsi4"
  3450.   [(set (match_operand:SI 0 "general_operand" "=d")
  3451.     (udiv:SI (match_operand:SI 1 "general_operand" "0")
  3452.          (match_operand:SI 2 "general_operand" "dmsK")))
  3453.    (set (match_operand:SI 3 "general_operand" "=d")
  3454.     (umod:SI (match_dup 1) (match_dup 2)))]
  3455.   "TARGET_68020"
  3456.   "*
  3457. {
  3458.   if (find_reg_note (insn, REG_UNUSED, operands[3]))
  3459.     return \"divu%.l %2,%0\";
  3460.   else
  3461.     return \"divul%.l %2,%3:%0\";
  3462. }")
  3463.  
  3464. (define_insn "divmodhi4"
  3465.   [(set (match_operand:HI 0 "general_operand" "=d")
  3466.     (div:HI (match_operand:HI 1 "general_operand" "0")
  3467.         (match_operand:HI 2 "general_operand" "dmsK")))
  3468.    (set (match_operand:HI 3 "general_operand" "=d")
  3469.     (mod:HI (match_dup 1) (match_dup 2)))]
  3470.   ""
  3471.   "*
  3472. {
  3473. #ifdef MOTOROLA
  3474.   output_asm_insn(\"ext%.l %0\;divs%.w %2,%0\", operands);
  3475. #else
  3476.   output_asm_insn(\"extl %0\;divs %2,%0\", operands);
  3477. #endif
  3478.   if (!find_reg_note(insn, REG_UNUSED, operands[3]))
  3479.     {
  3480.       CC_STATUS_INIT;
  3481.       return \"move%.l %0,%3\;swap %3\";
  3482.     }
  3483.   else
  3484.     return \"\";
  3485. }")
  3486.  
  3487. (define_insn "udivmodhi4"
  3488.   [(set (match_operand:HI 0 "general_operand" "=d")
  3489.     (udiv:HI (match_operand:HI 1 "general_operand" "0")
  3490.          (match_operand:HI 2 "general_operand" "dmsK")))
  3491.    (set (match_operand:HI 3 "general_operand" "=d")
  3492.     (umod:HI (match_dup 1) (match_dup 2)))]
  3493.   ""
  3494.   "*
  3495. {
  3496. #ifdef MOTOROLA
  3497.   output_asm_insn(\"and%.l %#0xFFFF,%0\;divu%.w %2,%0\", operands);
  3498. #else
  3499.   output_asm_insn(\"and%.l %#0xFFFF,%0\;divu %2,%0\", operands);
  3500. #endif
  3501.   if (!find_reg_note(insn, REG_UNUSED, operands[3]))
  3502.     {
  3503.       CC_STATUS_INIT;
  3504.       return \"move%.l %0,%3\;swap %3\";
  3505.     }
  3506.   else
  3507.     return \"\";
  3508. }")
  3509.  
  3510. ;; logical-and instructions
  3511.  
  3512. ;; Prevent AND from being made with sp.  This doesn't exist in the machine
  3513. ;; and reload will cause inefficient code.  Since sp is a FIXED_REG, we
  3514. ;; can't allocate pseudos into it.
  3515. (define_insn "andsi3"
  3516.   [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
  3517.     (and:SI (match_operand:SI 1 "general_operand" "%0,0")
  3518.         (match_operand:SI 2 "general_operand" "dKs,dmKs")))]
  3519.   ""
  3520.   "*
  3521. {
  3522.   int logval;
  3523.   if (GET_CODE (operands[2]) == CONST_INT
  3524.       && (INTVAL (operands[2]) | 0xffff) == 0xffffffff
  3525.       && (DATA_REG_P (operands[0])
  3526.       || offsettable_memref_p (operands[0])))
  3527.     { 
  3528.       if (GET_CODE (operands[0]) != REG)
  3529.         operands[0] = adj_offsettable_operand (operands[0], 2);
  3530.       operands[2] = gen_rtx (CONST_INT, VOIDmode,
  3531.                  INTVAL (operands[2]) & 0xffff);
  3532.       /* Do not delete a following tstl %0 insn; that would be incorrect.  */
  3533.       CC_STATUS_INIT;
  3534.       if (operands[2] == const0_rtx)
  3535.         return \"clr%.w %0\";
  3536.       return \"and%.w %2,%0\";
  3537.     }
  3538.   if (GET_CODE (operands[2]) == CONST_INT
  3539.       && (logval = exact_log2 (~ INTVAL (operands[2]))) >= 0
  3540.       && (DATA_REG_P (operands[0])
  3541.           || offsettable_memref_p (operands[0])))
  3542.     { 
  3543.       if (DATA_REG_P (operands[0]))
  3544.         {
  3545.           operands[1] = gen_rtx (CONST_INT, VOIDmode, logval);
  3546.         }
  3547.       else
  3548.         {
  3549.       operands[0] = adj_offsettable_operand (operands[0], 3 - (logval / 8));
  3550.       operands[1] = gen_rtx (CONST_INT, VOIDmode, logval % 8);
  3551.         }
  3552.       /* This does not set condition codes in a standard way.  */
  3553.       CC_STATUS_INIT;
  3554.       return \"bclr %1,%0\";
  3555.     }
  3556.   return \"and%.l %2,%0\";
  3557. }")
  3558.  
  3559. (define_insn "andhi3"
  3560.   [(set (match_operand:HI 0 "general_operand" "=m,d")
  3561.     (and:HI (match_operand:HI 1 "general_operand" "%0,0")
  3562.         (match_operand:HI 2 "general_operand" "dn,dmn")))]
  3563.   ""
  3564.   "and%.w %2,%0")
  3565.  
  3566. (define_insn ""
  3567.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  3568.     (and:HI (match_dup 0)
  3569.         (match_operand:HI 1 "general_operand" "dn,dmn")))]
  3570.   ""
  3571.   "and%.w %1,%0")
  3572.  
  3573. (define_insn ""
  3574.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  3575.     (and:HI (match_operand:HI 1 "general_operand" "dn,dmn")
  3576.         (match_dup 0)))]
  3577.   ""
  3578.   "and%.w %1,%0")
  3579.  
  3580. (define_insn "andqi3"
  3581.   [(set (match_operand:QI 0 "general_operand" "=m,d")
  3582.     (and:QI (match_operand:QI 1 "general_operand" "%0,0")
  3583.         (match_operand:QI 2 "general_operand" "dn,dmn")))]
  3584.   ""
  3585.   "and%.b %2,%0")
  3586.  
  3587. (define_insn ""
  3588.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  3589.     (and:QI (match_dup 0)
  3590.         (match_operand:QI 1 "general_operand" "dn,dmn")))]
  3591.   ""
  3592.   "and%.b %1,%0")
  3593.  
  3594. (define_insn ""
  3595.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  3596.     (and:QI (match_operand:QI 1 "general_operand" "dn,dmn")
  3597.         (match_dup 0)))]
  3598.   ""
  3599.   "and%.b %1,%0")
  3600.  
  3601. ;; inclusive-or instructions
  3602.  
  3603. (define_insn "iorsi3"
  3604.   [(set (match_operand:SI 0 "general_operand" "=m,d")
  3605.     (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
  3606.         (match_operand:SI 2 "general_operand" "dKs,dmKs")))]
  3607.   ""
  3608.   "*
  3609. {
  3610.   register int logval;
  3611.   if (GET_CODE (operands[2]) == CONST_INT
  3612.       && INTVAL (operands[2]) >> 16 == 0
  3613.       && (DATA_REG_P (operands[0])
  3614.       || offsettable_memref_p (operands[0])))
  3615.     { 
  3616.       if (GET_CODE (operands[0]) != REG)
  3617.         operands[0] = adj_offsettable_operand (operands[0], 2);
  3618.       /* Do not delete a following tstl %0 insn; that would be incorrect.  */
  3619.       CC_STATUS_INIT;
  3620.       return \"or%.w %2,%0\";
  3621.     }
  3622.   if (GET_CODE (operands[2]) == CONST_INT
  3623.       && (logval = exact_log2 (INTVAL (operands[2]))) >= 0
  3624.       && (DATA_REG_P (operands[0])
  3625.       || offsettable_memref_p (operands[0])))
  3626.     { 
  3627.       if (DATA_REG_P (operands[0]))
  3628.     {
  3629.       operands[1] = gen_rtx (CONST_INT, VOIDmode, logval);
  3630.     }
  3631.       else
  3632.         {
  3633.       operands[0] = adj_offsettable_operand (operands[0], 3 - (logval / 8));
  3634.       operands[1] = gen_rtx (CONST_INT, VOIDmode, logval % 8);
  3635.     }
  3636.       CC_STATUS_INIT;
  3637.       return \"bset %1,%0\";
  3638.     }
  3639.   return \"or%.l %2,%0\";
  3640. }")
  3641.  
  3642. (define_insn "iorhi3"
  3643.   [(set (match_operand:HI 0 "general_operand" "=m,d")
  3644.     (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
  3645.         (match_operand:HI 2 "general_operand" "dn,dmn")))]
  3646.   ""
  3647.   "or%.w %2,%0")
  3648.  
  3649. (define_insn ""
  3650.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  3651.     (ior:HI (match_dup 0)
  3652.         (match_operand:HI 1 "general_operand" "dn,dmn")))]
  3653.   ""
  3654.   "or%.w %1,%0")
  3655.  
  3656. (define_insn ""
  3657.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  3658.     (ior:HI (match_operand:HI 1 "general_operand" "dn,dmn")
  3659.         (match_dup 0)))]
  3660.   ""
  3661.   "or%.w %1,%0")
  3662.  
  3663. (define_insn "iorqi3"
  3664.   [(set (match_operand:QI 0 "general_operand" "=m,d")
  3665.     (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
  3666.         (match_operand:QI 2 "general_operand" "dn,dmn")))]
  3667.   ""
  3668.   "or%.b %2,%0")
  3669.  
  3670. (define_insn ""
  3671.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  3672.     (ior:QI (match_dup 0)
  3673.         (match_operand:QI 1 "general_operand" "dn,dmn")))]
  3674.   ""
  3675.   "or%.b %1,%0")
  3676.  
  3677. (define_insn ""
  3678.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  3679.     (ior:QI (match_operand:QI 1 "general_operand" "dn,dmn")
  3680.         (match_dup 0)))]
  3681.   ""
  3682.   "or%.b %1,%0")
  3683.  
  3684. (define_insn ""
  3685.   [(set (match_operand:SI 0 "general_operand" "=o,d")
  3686.     (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
  3687.         (match_operand:SI 2 "general_operand" "0,0")))]
  3688.   ""
  3689.   "*
  3690. {
  3691.   int byte_mode;
  3692.  
  3693.   CC_STATUS_INIT;
  3694.   byte_mode = (GET_MODE(operands[1]) == QImode);
  3695.   if (GET_CODE (operands[0]) == MEM)
  3696.     operands[0] = adj_offsettable_operand (operands[0], byte_mode ? 3 : 2);
  3697.   if (byte_mode)
  3698.     return \"or%.b %1,%0\";
  3699.   else
  3700.     return \"or%.w %1,%0\";
  3701. }")
  3702.  
  3703. ;; xor instructions
  3704.  
  3705. (define_insn "xorsi3"
  3706.   [(set (match_operand:SI 0 "general_operand" "=do,m")
  3707.     (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
  3708.         (match_operand:SI 2 "general_operand" "di,dKs")))]
  3709.   ""
  3710.   "*
  3711. {
  3712.   if (GET_CODE (operands[2]) == CONST_INT
  3713.       && INTVAL (operands[2]) >> 16 == 0
  3714.       && (offsettable_memref_p (operands[0]) || DATA_REG_P (operands[0])))
  3715.     { 
  3716.       if (! DATA_REG_P (operands[0]))
  3717.     operands[0] = adj_offsettable_operand (operands[0], 2);
  3718.       /* Do not delete a following tstl %0 insn; that would be incorrect.  */
  3719.       CC_STATUS_INIT;
  3720.       return \"eor%.w %2,%0\";
  3721.     }
  3722.   return \"eor%.l %2,%0\";
  3723. }")
  3724.  
  3725. (define_insn "xorhi3"
  3726.   [(set (match_operand:HI 0 "general_operand" "=dm")
  3727.     (xor:HI (match_operand:HI 1 "general_operand" "%0")
  3728.         (match_operand:HI 2 "general_operand" "dn")))]
  3729.   ""
  3730.   "eor%.w %2,%0")
  3731.  
  3732. (define_insn ""
  3733.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm"))
  3734.     (xor:HI (match_dup 0)
  3735.         (match_operand:HI 1 "general_operand" "dn")))]
  3736.   ""
  3737.   "eor%.w %1,%0")
  3738.  
  3739.  
  3740. (define_insn ""
  3741.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm"))
  3742.     (xor:HI (match_operand:HI 1 "general_operand" "dn")
  3743.         (match_dup 0)))]
  3744.   ""
  3745.   "eor%.w %1,%0")
  3746.  
  3747. (define_insn "xorqi3"
  3748.   [(set (match_operand:QI 0 "general_operand" "=dm")
  3749.     (xor:QI (match_operand:QI 1 "general_operand" "%0")
  3750.         (match_operand:QI 2 "general_operand" "dn")))]
  3751.   ""
  3752.   "eor%.b %2,%0")
  3753.  
  3754. (define_insn ""
  3755.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm"))
  3756.     (xor:QI (match_dup 0)
  3757.         (match_operand:QI 1 "general_operand" "dn")))]
  3758.   ""
  3759.   "eor%.b %1,%0")
  3760.  
  3761. (define_insn ""
  3762.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm"))
  3763.     (xor:QI (match_operand:QI 1 "general_operand" "dn")
  3764.         (match_dup 0)))]
  3765.   ""
  3766.   "eor%.b %1,%0")
  3767.  
  3768. ;; negation instructions
  3769.  
  3770. (define_insn "negdi2"
  3771.   [(set (match_operand:DI 0 "general_operand" "=d*ao,<")
  3772.     (neg:DI (match_operand:DI 1 "general_operand" "0,0")))]
  3773.   ""
  3774.   "*
  3775. {
  3776.   if (which_alternative == 1)
  3777.     return \"neg%.l %0\;negx%.l %0\";
  3778.   if (GET_CODE (operands[0]) == REG)
  3779.     operands[1] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  3780.   else
  3781.     operands[1] = adj_offsettable_operand (operands[0], 4);
  3782.   if (ADDRESS_REG_P (operands[0]))
  3783.     return \"exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0\";
  3784.   else
  3785.     return \"neg%.l %1\;negx%.l %0\";
  3786. } ")
  3787.  
  3788. (define_insn "negsi2"
  3789.   [(set (match_operand:SI 0 "general_operand" "=dm")
  3790.     (neg:SI (match_operand:SI 1 "general_operand" "0")))]
  3791.   ""
  3792.   "neg%.l %0")
  3793.  
  3794. (define_insn "neghi2"
  3795.   [(set (match_operand:HI 0 "general_operand" "=dm")
  3796.     (neg:HI (match_operand:HI 1 "general_operand" "0")))]
  3797.   ""
  3798.   "neg%.w %0")
  3799.  
  3800. (define_insn ""
  3801.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm"))
  3802.     (neg:HI (match_dup 0)))]
  3803.   ""
  3804.   "neg%.w %0")
  3805.  
  3806. (define_insn "negqi2"
  3807.   [(set (match_operand:QI 0 "general_operand" "=dm")
  3808.     (neg:QI (match_operand:QI 1 "general_operand" "0")))]
  3809.   ""
  3810.   "neg%.b %0")
  3811.  
  3812. (define_insn ""
  3813.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm"))
  3814.     (neg:QI (match_dup 0)))]
  3815.   ""
  3816.   "neg%.b %0")
  3817.  
  3818. ;; If using software floating point, just flip the sign bit.
  3819.  
  3820. (define_expand "negsf2"
  3821.   [(set (match_operand:SF 0 "general_operand" "")
  3822.     (neg:SF (match_operand:SF 1 "general_operand" "")))]
  3823.   ""
  3824.   "
  3825. {
  3826.   if (!TARGET_FPA && !TARGET_68881)
  3827.     {
  3828.       rtx result;
  3829.       rtx target;
  3830.  
  3831.       target = operand_subword_force (operands[0], 0, SFmode);
  3832.       result = expand_binop (SImode, xor_optab,
  3833.                  operand_subword_force (operands[1], 0, SFmode),
  3834.                  GEN_INT(0x80000000), target, 0, OPTAB_WIDEN);
  3835.       if (result == 0)
  3836.     abort ();
  3837.  
  3838.       if (result != target)
  3839.     emit_move_insn (result, target);
  3840.  
  3841.       /* Make a place for REG_EQUAL.  */
  3842.       emit_move_insn (operands[0], operands[0]);
  3843.       DONE;
  3844.     }
  3845. }")
  3846.  
  3847. (define_insn ""
  3848.   [(set (match_operand:SF 0 "general_operand" "=x,y")
  3849.     (neg:SF (match_operand:SF 1 "general_operand" "xH,rmF")))]
  3850.   "TARGET_FPA"
  3851.   "fpneg%.s %w1,%0")
  3852.  
  3853. (define_insn ""
  3854.   [(set (match_operand:SF 0 "general_operand" "=f,d")
  3855.     (neg:SF (match_operand:SF 1 "general_operand" "fdmF,0")))]
  3856.   "TARGET_68881"
  3857.   "*
  3858. {
  3859.   if (DATA_REG_P (operands[0]))
  3860.     {
  3861.       operands[1] = gen_rtx (CONST_INT, VOIDmode, 31);
  3862.       return \"bchg %1,%0\";
  3863.     }
  3864.   if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
  3865.     return \"f%$neg%.x %1,%0\";
  3866.   return \"f%$neg%.s %f1,%0\";
  3867. }")
  3868.  
  3869. (define_expand "negdf2"
  3870.   [(set (match_operand:DF 0 "general_operand" "")
  3871.     (neg:DF (match_operand:DF 1 "general_operand" "")))]
  3872.   ""
  3873.   "
  3874. {
  3875.   if (!TARGET_FPA && !TARGET_68881)
  3876.     {
  3877.       rtx result;
  3878.       rtx target;
  3879.       rtx insns;
  3880.  
  3881.       start_sequence ();
  3882.       target = operand_subword (operands[0], 0, 1, DFmode);
  3883.       result = expand_binop (SImode, xor_optab,
  3884.                  operand_subword_force (operands[1], 0, DFmode),
  3885.                  GEN_INT(0x80000000), target, 0, OPTAB_WIDEN);
  3886.       if (result == 0)
  3887.     abort ();
  3888.  
  3889.       if (result != target)
  3890.     emit_move_insn (result, target);
  3891.   
  3892.       emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
  3893.               operand_subword_force (operands[1], 1, DFmode));
  3894.  
  3895.       insns = get_insns ();
  3896.       end_sequence ();
  3897.  
  3898.       emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
  3899.       DONE;
  3900.     }
  3901. }")
  3902.  
  3903. (define_insn ""
  3904.   [(set (match_operand:DF 0 "general_operand" "=x,y")
  3905.     (neg:DF (match_operand:DF 1 "general_operand" "xH,rmF")))]
  3906.   "TARGET_FPA"
  3907.   "fpneg%.d %y1, %0")
  3908.  
  3909. (define_insn ""
  3910.   [(set (match_operand:DF 0 "general_operand" "=f,d")
  3911.     (neg:DF (match_operand:DF 1 "general_operand" "fmF,0")))]
  3912.   "TARGET_68881"
  3913.   "*
  3914. {
  3915.   if (DATA_REG_P (operands[0]))
  3916.     {
  3917.       operands[1] = gen_rtx (CONST_INT, VOIDmode, 31);
  3918.       return \"bchg %1,%0\";
  3919.     }
  3920.   if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
  3921.     return \"f%&neg%.x %1,%0\";
  3922.   return \"f%&neg%.d %f1,%0\";
  3923. }")
  3924.  
  3925. ;; Sqrt instruction for the 68881
  3926.  
  3927. (define_insn "sqrtsf2"
  3928.   [(set (match_operand:SF 0 "general_operand" "=f")
  3929.     (sqrt:SF (match_operand:SF 1 "general_operand" "fm")))]
  3930.   "TARGET_68881"
  3931.   "*
  3932. {
  3933.   if (FP_REG_P (operands[1]))
  3934.     return \"f%$sqrt%.x %1,%0\";
  3935.   else
  3936.     return \"f%$sqrt%.s %1,%0\";
  3937. }")
  3938.  
  3939. (define_insn "sqrtdf2"
  3940.   [(set (match_operand:DF 0 "general_operand" "=f")
  3941.     (sqrt:DF (match_operand:DF 1 "general_operand" "fm")))]
  3942.   "TARGET_68881"
  3943.   "*
  3944. {
  3945.   if (FP_REG_P (operands[1]))
  3946.     return \"f%&sqrt%.x %1,%0\";
  3947.   else
  3948.     return \"f%&sqrt%.d %1,%0\";
  3949. }")
  3950.  
  3951. ;; Absolute value instructions
  3952. ;; If using software floating point, just zero the sign bit.
  3953.  
  3954. (define_expand "abssf2"
  3955.   [(set (match_operand:SF 0 "general_operand" "")
  3956.     (abs:SF (match_operand:SF 1 "general_operand" "")))]
  3957.   ""
  3958.   "
  3959. {
  3960.   if (!TARGET_FPA && !TARGET_68881)
  3961.     {
  3962.       rtx result;
  3963.       rtx target;
  3964.  
  3965.       target = operand_subword_force (operands[0], 0, SFmode);
  3966.       result = expand_binop (SImode, and_optab,
  3967.                  operand_subword_force (operands[1], 0, SFmode),
  3968.                  GEN_INT(0x7fffffff), target, 0, OPTAB_WIDEN);
  3969.       if (result == 0)
  3970.     abort ();
  3971.  
  3972.       if (result != target)
  3973.     emit_move_insn (result, target);
  3974.  
  3975.       /* Make a place for REG_EQUAL.  */
  3976.       emit_move_insn (operands[0], operands[0]);
  3977.       DONE;
  3978.     }
  3979. }")
  3980.  
  3981. (define_insn ""
  3982.   [(set (match_operand:SF 0 "general_operand" "=x,y")
  3983.     (abs:SF (match_operand:SF 1 "general_operand" "xH,rmF")))]
  3984.   "TARGET_FPA"
  3985.   "fpabs%.s %y1,%0")
  3986.  
  3987. (define_insn ""
  3988.   [(set (match_operand:SF 0 "general_operand" "=f")
  3989.     (abs:SF (match_operand:SF 1 "general_operand" "fdmF")))]
  3990.   "TARGET_68881"
  3991.   "*
  3992. {
  3993.   if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
  3994.     return \"f%$abs%.x %1,%0\";
  3995.   return \"f%$abs%.s %f1,%0\";
  3996. }")
  3997.  
  3998. (define_expand "absdf2"
  3999.   [(set (match_operand:DF 0 "general_operand" "")
  4000.     (abs:DF (match_operand:DF 1 "general_operand" "")))]
  4001.   ""
  4002.   "
  4003. {
  4004.   if (!TARGET_FPA && !TARGET_68881)
  4005.     {
  4006.       rtx result;
  4007.       rtx target;
  4008.       rtx insns;
  4009.  
  4010.       start_sequence ();
  4011.       target = operand_subword (operands[0], 0, 1, DFmode);
  4012.       result = expand_binop (SImode, and_optab,
  4013.                  operand_subword_force (operands[1], 0, DFmode),
  4014.                  GEN_INT(0x7fffffff), target, 0, OPTAB_WIDEN);
  4015.       if (result == 0)
  4016.     abort ();
  4017.  
  4018.       if (result != target)
  4019.     emit_move_insn (result, target);
  4020.   
  4021.       emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
  4022.               operand_subword_force (operands[1], 1, DFmode));
  4023.  
  4024.       insns = get_insns ();
  4025.       end_sequence ();
  4026.  
  4027.       emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
  4028.       DONE;
  4029.     }
  4030. }")
  4031.  
  4032. (define_insn ""
  4033.   [(set (match_operand:DF 0 "general_operand" "=x,y")
  4034.     (abs:DF (match_operand:DF 1 "general_operand" "xH,rmF")))]
  4035.   "TARGET_FPA"
  4036.   "fpabs%.d %y1,%0")
  4037.  
  4038. (define_insn ""
  4039.   [(set (match_operand:DF 0 "general_operand" "=f")
  4040.     (abs:DF (match_operand:DF 1 "general_operand" "fmF")))]
  4041.   "TARGET_68881"
  4042.   "*
  4043. {
  4044.   if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
  4045.     return \"f%&abs%.x %1,%0\";
  4046.   return \"f%&abs%.d %f1,%0\";
  4047. }")
  4048.  
  4049. ;; one complement instructions
  4050.  
  4051. ;; "one_cmpldi2" is only here to help combine().
  4052. (define_insn "one_cmpldi2"
  4053.   [(set (match_operand:DI 0 "general_operand" "=dm")
  4054.     (not:DI (match_operand:DI 1 "general_operand" "0")))]
  4055.   ""
  4056.   "*
  4057. {
  4058.   CC_STATUS_INIT;
  4059.   if (GET_CODE (operands[0]) == REG)
  4060.     operands[1] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  4061.   else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC
  4062.         || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  4063.     operands[1] = operands[0];
  4064.   else
  4065.     operands[1] = adj_offsettable_operand (operands[0], 4);
  4066.   return \"not%.l %1\;not%.l %0\";
  4067. }")
  4068.  
  4069. (define_insn "one_cmplsi2"
  4070.   [(set (match_operand:SI 0 "general_operand" "=dm")
  4071.     (not:SI (match_operand:SI 1 "general_operand" "0")))]
  4072.   ""
  4073.   "not%.l %0")
  4074.  
  4075. (define_insn "one_cmplhi2"
  4076.   [(set (match_operand:HI 0 "general_operand" "=dm")
  4077.     (not:HI (match_operand:HI 1 "general_operand" "0")))]
  4078.   ""
  4079.   "not%.w %0")
  4080.  
  4081. (define_insn ""
  4082.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm"))
  4083.     (not:HI (match_dup 0)))]
  4084.   ""
  4085.   "not%.w %0")
  4086.  
  4087. (define_insn "one_cmplqi2"
  4088.   [(set (match_operand:QI 0 "general_operand" "=dm")
  4089.     (not:QI (match_operand:QI 1 "general_operand" "0")))]
  4090.   ""
  4091.   "not%.b %0")
  4092.  
  4093. (define_insn ""
  4094.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm"))
  4095.     (not:QI (match_dup 0)))]
  4096.   ""
  4097.   "not%.b %0")
  4098.  
  4099. ;; arithmetic shift instructions
  4100. ;; We don't need the shift memory by 1 bit instruction
  4101.  
  4102. (define_insn "ashldi_extsi"
  4103.   [(set (match_operand:DI 0 "general_operand" "=ro")
  4104.     (ashift:DI
  4105.       (match_operator:DI 2 "extend_operator"
  4106.         [(match_operand:SI 1 "general_operand" "rm")])
  4107.       (const_int 32)))]
  4108.   ""
  4109.   "*
  4110. {
  4111.   CC_STATUS_INIT;
  4112.   if (GET_CODE (operands[0]) == REG)
  4113.     operands[2] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  4114.   else
  4115.     operands[2] = adj_offsettable_operand (operands[0], 4);
  4116.   if (ADDRESS_REG_P (operands[0]))
  4117.     return \"move%.l %1,%0\;sub%.l %2,%2\";
  4118.   else
  4119.     return \"move%.l %1,%0\;clr%.l %2\";
  4120. } ")
  4121.  
  4122. (define_insn "ashldi_sexthi"
  4123.   [(set (match_operand:DI 0 "register_operand" "=*da")
  4124.     (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm"))
  4125.         (const_int 32)))]
  4126.   ""
  4127.   "*
  4128. {
  4129.   CC_STATUS_INIT;
  4130.   operands[2] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  4131.   if (DATA_REG_P (operands[0]))
  4132.     return \"move%.w %1,%0\;ext%.l %0\;clr%.l %2\";
  4133.   else
  4134.     return \"move%.w %1,%0\;sub%.l %2,%2\";
  4135. } ")
  4136.  
  4137. (define_insn "ashldi_const32"
  4138.   [(set (match_operand:DI 0 "general_operand" "=ro,<,>")
  4139.     (ashift:DI (match_operand:DI 1 "general_operand" "ro,ro,ro")
  4140.              (const_int 32)))]
  4141.   ""
  4142.   "*
  4143. {
  4144.   CC_STATUS_INIT;
  4145.   if (GET_CODE (operands[1]) == REG)
  4146.     operands[3] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  4147.   else
  4148.     operands[3] = adj_offsettable_operand (operands[1], 4);
  4149.   if (which_alternative == 1)
  4150.     return \"clr%.l %0\;move%.l %3,%0\";
  4151.   if (which_alternative == 2)
  4152.     return \"move%.l %3,%0\;clr%.l %0\";
  4153.   if (GET_CODE (operands[0]) == REG)
  4154.     operands[2] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  4155.   else
  4156.     operands[2] = adj_offsettable_operand (operands[0], 4);
  4157.   if (ADDRESS_REG_P (operands[2]))
  4158.     return \"move%.l %3,%0\;sub%.l %2,%2\";
  4159.   else
  4160.     return \"move%.l %3,%0\;clr%.l %2\";
  4161. } ")
  4162.  
  4163. ;; The predicate below must be general_operand, because ashldi3 allows that
  4164. (define_insn "ashldi_const"
  4165.   [(set (match_operand:DI 0 "general_operand" "=d")
  4166.     (ashift:DI (match_operand:DI 1 "general_operand" "0")
  4167.              (match_operand 2 "const_int_operand" "n")))]
  4168.   "(INTVAL (operands[2]) == 1
  4169.     || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
  4170.    || INTVAL (operands[2]) == 2 || INTVAL (operands[2]) == 3)"
  4171.   "*
  4172. {
  4173.   operands[1] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  4174.   if (INTVAL (operands[2]) == 1)
  4175.     return \"add%.l %1,%1\;addx%.l %0,%0\";
  4176.   else if (INTVAL (operands[2]) == 8)
  4177.     return \"rol%.l %#8,%1\;rol%.l %#8,%0\;move%.b %1,%0\;clr%.b %1\";
  4178.   else if (INTVAL (operands[2]) == 16)
  4179.     return \"swap %1\;swap %0\;move%.w %1,%0\;clr%.w %1\";
  4180.   else if (INTVAL (operands[2]) == 2)
  4181.     return \"add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0\";
  4182.   else/* if (INTVAL (operands[2]) == 3)*/
  4183.     return \"add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0\";
  4184. } ")
  4185.  
  4186. (define_expand "ashldi3"
  4187.   [(set (match_operand:DI 0 "general_operand" "")
  4188.     (ashift:DI (match_operand:DI 1 "general_operand" "")
  4189.              (match_operand 2 "const_int_operand" "")))]
  4190.   ""
  4191.   "
  4192. {
  4193.   if (GET_CODE (operands[2]) != CONST_INT
  4194.   || (INTVAL (operands[2]) != 1 && INTVAL (operands[2]) != 32
  4195.      && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
  4196.      && INTVAL (operands[2]) != 2 && INTVAL (operands[2]) != 3))
  4197.     FAIL;
  4198. } ")
  4199.  
  4200. ;; On all 68k models, this makes faster code in a special case.
  4201.  
  4202. (define_insn ""
  4203.   [(set (match_operand:SI 0 "register_operand" "=d")
  4204.     (ashift:SI (match_operand:SI 1 "register_operand" "0")
  4205.            (const_int 16)))]
  4206.   ""
  4207.   "*
  4208. {
  4209.   CC_STATUS_INIT;
  4210.   return \"swap %0\;clr%.w %0\";
  4211. }")
  4212.  
  4213. ;; On the 68000, this makes faster code in a special case.
  4214.  
  4215. (define_insn ""
  4216.   [(set (match_operand:SI 0 "register_operand" "=d")
  4217.     (ashift:SI (match_operand:SI 1 "register_operand" "0")
  4218.            (match_operand:SI 2 "const_int_operand" "n")))]
  4219.   "(! TARGET_68020
  4220.     && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
  4221.   "*
  4222. {
  4223.   CC_STATUS_INIT;
  4224.  
  4225.   operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16);
  4226.   return \"asl%.w %2,%0\;swap %0\;clr%.w %0\";
  4227. }")
  4228.  
  4229. (define_insn "ashlsi3"
  4230.   [(set (match_operand:SI 0 "register_operand" "=d")
  4231.     (ashift:SI (match_operand:SI 1 "register_operand" "0")
  4232.            (match_operand:SI 2 "general_operand" "dI")))]
  4233.   ""
  4234.   "*
  4235. {
  4236.   if (operands[2] == const1_rtx)
  4237.     return \"add%.l %0,%0\";
  4238.   return \"asl%.l %2,%0\";
  4239. }")
  4240.  
  4241. (define_insn "ashlhi3"
  4242.   [(set (match_operand:HI 0 "register_operand" "=d")
  4243.     (ashift:HI (match_operand:HI 1 "register_operand" "0")
  4244.            (match_operand:HI 2 "general_operand" "dI")))]
  4245.   ""
  4246.   "asl%.w %2,%0")
  4247.  
  4248. (define_insn ""
  4249.   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
  4250.     (ashift:HI (match_dup 0)
  4251.            (match_operand:HI 1 "general_operand" "dI")))]
  4252.   ""
  4253.   "asl%.w %1,%0")
  4254.  
  4255. (define_insn "ashlqi3"
  4256.   [(set (match_operand:QI 0 "register_operand" "=d")
  4257.     (ashift:QI (match_operand:QI 1 "register_operand" "0")
  4258.            (match_operand:QI 2 "general_operand" "dI")))]
  4259.   ""
  4260.   "asl%.b %2,%0")
  4261.  
  4262. (define_insn ""
  4263.   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
  4264.     (ashift:QI (match_dup 0)
  4265.            (match_operand:QI 1 "general_operand" "dI")))]
  4266.   ""
  4267.   "asl%.b %1,%0")
  4268.  
  4269. ;; On all 68k models, this makes faster code in a special case.
  4270.  
  4271. (define_insn ""
  4272.   [(set (match_operand:SI 0 "register_operand" "=d")
  4273.     (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
  4274.              (const_int 16)))]
  4275.   ""
  4276.   "swap %0\;ext%.l %0")
  4277.  
  4278. ;; On the 68000, this makes faster code in a special case.
  4279.  
  4280. (define_insn ""
  4281.   [(set (match_operand:SI 0 "register_operand" "=d")
  4282.     (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
  4283.              (match_operand:SI 2 "const_int_operand" "n")))]
  4284.   "(! TARGET_68020
  4285.     && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
  4286.   "*
  4287. {
  4288.   operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16);
  4289.   return \"swap %0\;asr%.w %2,%0\;ext%.l %0\";
  4290. }")
  4291.  
  4292. (define_insn "subreghi1ashrdi_const32"
  4293.   [(set (match_operand:HI 0 "general_operand" "=rm")
  4294.     (subreg:HI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
  4295.             (const_int 32)) 1))]
  4296.   ""
  4297.   "*
  4298. {
  4299.   if (GET_CODE (operands[1]) != REG)
  4300.     operands[1] = adj_offsettable_operand (operands[1], 2);
  4301.   return \"move%.w %1,%0\";
  4302. } ")
  4303.  
  4304. (define_insn "subregsi1ashrdi_const32"
  4305.   [(set (match_operand:SI 0 "general_operand" "=rm")
  4306.     (subreg:SI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
  4307.             (const_int 32)) 1))]
  4308.   ""
  4309.   "*
  4310. {
  4311.   return \"move%.l %1,%0\";
  4312. } ")
  4313.  
  4314. (define_insn "ashrdi_const32"
  4315.   [(set (match_operand:DI 0 "register_operand" "=d")
  4316.     (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
  4317.              (const_int 32)))]
  4318.   ""
  4319.   "*
  4320. {
  4321.   CC_STATUS_INIT;
  4322.   operands[2] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  4323.   if (TARGET_68020)
  4324.     return \"move%.l %1,%2\;smi %0\;extb%.l %0\";
  4325.   else
  4326.     return \"move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0\";
  4327. } ")
  4328.  
  4329. (define_insn "ashrdi_const32_mem"
  4330.   [(set (match_operand:DI 0 "general_operand" "=o,<")
  4331.     (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro")
  4332.              (const_int 32)))
  4333.    (clobber (match_scratch:SI 2 "=d,d"))]
  4334.   ""
  4335.   "*
  4336. {
  4337.   CC_STATUS_INIT;
  4338.   if (which_alternative == 1)
  4339.     operands[3] = operands[0];
  4340.   else
  4341.     operands[3] = adj_offsettable_operand (operands[0], 4);
  4342.   if (TARGET_68020)
  4343.     return \"move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0\";
  4344.   else
  4345.     return \"move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\";
  4346. } ")
  4347.  
  4348. ;; The predicate below must be general_operand, because ashrdi3 allows that
  4349. (define_insn "ashrdi_const"
  4350.   [(set (match_operand:DI 0 "general_operand" "=d")
  4351.     (ashiftrt:DI (match_operand:DI 1 "general_operand" "0")
  4352.              (match_operand 2 "const_int_operand" "n")))]
  4353.   "(INTVAL (operands[2]) == 1 || INTVAL (operands[2]) == 2
  4354.     || INTVAL (operands[2]) == 3 || INTVAL (operands[2]) == 8
  4355.     || INTVAL (operands[2]) == 16 || INTVAL (operands[2]) == 63)"
  4356.   "*
  4357. {
  4358.   operands[1] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  4359.   if (INTVAL (operands[2]) == 63)
  4360.     return \"add%.l %0,%0\;subx%.l %0,%0\;move%.l %0,%1\";
  4361.   CC_STATUS_INIT;
  4362.   if (INTVAL (operands[2]) == 1)
  4363.     return \"asr%.l %#1,%0\;roxr%.l %#1,%1\";
  4364.   else if (INTVAL (operands[2]) == 8)
  4365.     return \"move%.b %0,%1\;asr%.l %#8,%0\;ror%.l %#8,%1\";
  4366.   else if (INTVAL (operands[2]) == 16)
  4367.     return \"move%.w %0,%1\;clr%.w %0\;swap %1\;ext%.l %0\";
  4368.   else if (INTVAL (operands[2]) == 2)
  4369.     return \"asr%.l %#1,%0\;roxr%.l %#1,%1\;asr%.l %#1,%0\;roxr%.l %#1,%1\";
  4370.   else/* if (INTVAL (operands[2]) == 3)*/
  4371.     return \"asr%.l %#1,%0\;roxr%.l %#1,%1\;asr%.l %#1,%0\;roxr%.l %#1,%1\;asr%.l %#1,%0\;roxr%.l %#1,%1\";
  4372. } ")
  4373.  
  4374. (define_expand "ashrdi3"
  4375.   [(set (match_operand:DI 0 "general_operand" "")
  4376.     (ashiftrt:DI (match_operand:DI 1 "general_operand" "")
  4377.              (match_operand 2 "const_int_operand" "")))]
  4378.   ""
  4379.   "
  4380. {
  4381.   if (GET_CODE (operands[2]) != CONST_INT
  4382.   || (INTVAL (operands[2]) != 1 && INTVAL (operands[2]) != 2
  4383.      && INTVAL (operands[2]) != 3 && INTVAL (operands[2]) != 8
  4384.      && INTVAL (operands[2]) != 16 && INTVAL (operands[2]) != 32
  4385.      && INTVAL (operands[2]) != 63))
  4386.     FAIL;
  4387. } ")
  4388.  
  4389. (define_insn "ashrsi3"
  4390.   [(set (match_operand:SI 0 "register_operand" "=d")
  4391.     (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
  4392.              (match_operand:SI 2 "general_operand" "dI")))]
  4393.   ""
  4394.   "asr%.l %2,%0")
  4395.  
  4396. (define_insn "ashrhi3"
  4397.   [(set (match_operand:HI 0 "register_operand" "=d")
  4398.     (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
  4399.              (match_operand:HI 2 "general_operand" "dI")))]
  4400.   ""
  4401.   "asr%.w %2,%0")
  4402.  
  4403. (define_insn ""
  4404.   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
  4405.     (ashiftrt:HI (match_dup 0)
  4406.              (match_operand:HI 1 "general_operand" "dI")))]
  4407.   ""
  4408.   "asr%.w %1,%0")
  4409.  
  4410. (define_insn "ashrqi3"
  4411.   [(set (match_operand:QI 0 "register_operand" "=d")
  4412.     (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
  4413.              (match_operand:QI 2 "general_operand" "dI")))]
  4414.   ""
  4415.   "asr%.b %2,%0")
  4416.  
  4417. (define_insn ""
  4418.   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
  4419.     (ashiftrt:QI (match_dup 0)
  4420.              (match_operand:QI 1 "general_operand" "dI")))]
  4421.   ""
  4422.   "asr%.b %1,%0")
  4423.  
  4424. ;; logical shift instructions
  4425.  
  4426. ;; commented out because of reload problems in 950612-1.c
  4427. ;;(define_insn ""
  4428. ;;        [(set (cc0)
  4429. ;;            (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
  4430. ;;                    (const_int 32)) 1))
  4431. ;;        (set (match_operand:SI 1 "general_operand" "=dm")
  4432. ;;            (subreg:SI (lshiftrt:DI (match_dup 0)
  4433. ;;                    (const_int 32)) 1))]
  4434. ;;  ""
  4435. ;;  "*
  4436. ;;{
  4437. ;;  return \"move%.l %0,%1\";
  4438. ;;} ")
  4439. ;;
  4440. ;;(define_insn ""
  4441. ;;        [(set (cc0)
  4442. ;;            (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
  4443. ;;                    (const_int 32)) 0))
  4444. ;;        (set (match_operand:DI 1 "general_operand" "=do")
  4445. ;;            (lshiftrt:DI (match_dup 0)
  4446. ;;                (const_int 32)))]
  4447. ;;  ""
  4448. ;;  "*
  4449. ;;{
  4450. ;;  if (GET_CODE (operands[1]) == REG)
  4451. ;;    operands[2] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  4452. ;;  else
  4453. ;;    operands[2] = adj_offsettable_operand (operands[1], 4);
  4454. ;;  return \"move%.l %0,%2\;clr%.l %1\";
  4455. ;;} ")
  4456.  
  4457. (define_insn "subreg1lshrdi_const32"
  4458.   [(set (match_operand:SI 0 "general_operand" "=rm")
  4459.     (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
  4460.             (const_int 32)) 1))]
  4461.   ""
  4462.   "*
  4463. {
  4464.   return \"move%.l %1,%0\";
  4465. } ")
  4466.  
  4467. (define_insn "lshrdi_const32"
  4468.   [(set (match_operand:DI 0 "general_operand" "=ro,<,>")
  4469.     (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro,ro")
  4470.              (const_int 32)))]
  4471.   ""
  4472.   "*
  4473. {
  4474.   CC_STATUS_INIT;
  4475.   if (which_alternative == 1)
  4476.     return \"move%.l %1,%0\;clr%.l %0\";
  4477.   if (which_alternative == 2)
  4478.     return \"clr%.l %0\;move%.l %1,%0\";
  4479.   if (GET_CODE (operands[0]) == REG)
  4480.     operands[2] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  4481.   else
  4482.     operands[2] = adj_offsettable_operand (operands[0], 4);
  4483.   if (GET_CODE (operands[1]) == REG)
  4484.     operands[3] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  4485.   else
  4486.     operands[3] = adj_offsettable_operand (operands[1], 4);
  4487.   if (ADDRESS_REG_P (operands[0]))
  4488.     return \"move%.l %1,%2\;sub%.l %0,%0\";
  4489.   else
  4490.     return \"move%.l %1,%2\;clr%.l %0\";
  4491. } ")
  4492.  
  4493. ;; The predicate below must be general_operand, because lshrdi3 allows that
  4494. (define_insn "lshrdi_const"
  4495.   [(set (match_operand:DI 0 "general_operand" "=d")
  4496.     (lshiftrt:DI (match_operand:DI 1 "general_operand" "0")
  4497.              (match_operand 2 "const_int_operand" "n")))]
  4498.   "(INTVAL (operands[2]) == 1 || INTVAL (operands[2]) == 2
  4499.     || INTVAL (operands[2]) == 3 || INTVAL (operands[2]) == 8
  4500.     || INTVAL (operands[2]) == 16 || INTVAL (operands[2]) == 63)"
  4501.   "*
  4502. {
  4503.   operands[1] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  4504.   if (INTVAL (operands[2]) == 63)
  4505.     return \"add%.l %0,%0\;clr%.l %0\;clr%.l %1\;addx%.l %1,%1\";
  4506.   CC_STATUS_INIT;
  4507.   if (INTVAL (operands[2]) == 1)
  4508.     return \"lsr%.l %#1,%0\;roxr%.l %#1,%1\";
  4509.   else if (INTVAL (operands[2]) == 8)
  4510.     return \"move%.b %0,%1\;lsr%.l %#8,%0\;ror%.l %#8,%1\";
  4511.   else if (INTVAL (operands[2]) == 16)
  4512.     return \"move%.w %0,%1\;clr%.w %0\;swap %1\;swap %0\";
  4513.   else if (INTVAL (operands[2]) == 2)
  4514.     return \"lsr%.l %#1,%0\;roxr%.l %#1,%1\;lsr%.l %#1,%0\;roxr%.l %#1,%1\";
  4515.   else /*if (INTVAL (operands[2]) == 3)*/
  4516.     return \"lsr%.l %#1,%0\;roxr%.l %#1,%1\;lsr%.l %#1,%0\;roxr%.l %#1,%1\;lsr%.l %#1,%0\;roxr%.l %#1,%1\";
  4517. } ")
  4518.  
  4519. (define_expand "lshrdi3"
  4520.   [(set (match_operand:DI 0 "general_operand" "")
  4521.     (lshiftrt:DI (match_operand:DI 1 "general_operand" "")
  4522.              (match_operand 2 "const_int_operand" "")))]
  4523.   ""
  4524.   "
  4525. {
  4526.   if (GET_CODE (operands[2]) != CONST_INT
  4527.   || (INTVAL (operands[2]) != 1 && INTVAL (operands[2]) != 2
  4528.      && INTVAL (operands[2]) != 3 && INTVAL (operands[2]) != 8
  4529.      && INTVAL (operands[2]) != 16 && INTVAL (operands[2]) != 32
  4530.      && INTVAL (operands[2]) != 63))
  4531.     FAIL;
  4532. } ")
  4533.  
  4534. ;; On all 68k models, this makes faster code in a special case.
  4535.  
  4536. (define_insn "lshrsi_31"
  4537.   [(set (match_operand:SI 0 "register_operand" "=d")
  4538.     (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
  4539.              (const_int 31)))]
  4540.   ""
  4541.   "*
  4542. {
  4543.   return \"add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0\";
  4544. }")
  4545.  
  4546. ;; On all 68k models, this makes faster code in a special case.
  4547.  
  4548. (define_insn "lshrsi_16"
  4549.   [(set (match_operand:SI 0 "register_operand" "=d")
  4550.     (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
  4551.              (const_int 16)))]
  4552.   ""
  4553.   "*
  4554. {
  4555.   CC_STATUS_INIT;
  4556.   return \"clr%.w %0\;swap %0\";
  4557. }")
  4558.  
  4559. ;; On the 68000, this makes faster code in a special case.
  4560.  
  4561. (define_insn "lshrsi_17_24"
  4562.   [(set (match_operand:SI 0 "register_operand" "=d")
  4563.     (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
  4564.              (match_operand:SI 2 "const_int_operand" "n")))]
  4565.   "(! TARGET_68020
  4566.     && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
  4567.   "*
  4568. {
  4569.   /* I think lsr%.w sets the CC properly.  */
  4570.   operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16);
  4571.   return \"clr%.w %0\;swap %0\;lsr%.w %2,%0\";
  4572. }")
  4573.  
  4574. (define_insn "lshrsi3"
  4575.   [(set (match_operand:SI 0 "register_operand" "=d")
  4576.     (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
  4577.              (match_operand:SI 2 "general_operand" "dI")))]
  4578.   ""
  4579.   "lsr%.l %2,%0")
  4580.  
  4581. (define_insn "lshrhi3"
  4582.   [(set (match_operand:HI 0 "register_operand" "=d")
  4583.     (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
  4584.              (match_operand:HI 2 "general_operand" "dI")))]
  4585.   ""
  4586.   "lsr%.w %2,%0")
  4587.  
  4588. (define_insn ""
  4589.   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
  4590.     (lshiftrt:HI (match_dup 0)
  4591.              (match_operand:HI 1 "general_operand" "dI")))]
  4592.   ""
  4593.   "lsr%.w %1,%0")
  4594.  
  4595. (define_insn "lshrqi3"
  4596.   [(set (match_operand:QI 0 "register_operand" "=d")
  4597.     (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
  4598.              (match_operand:QI 2 "general_operand" "dI")))]
  4599.   ""
  4600.   "lsr%.b %2,%0")
  4601.  
  4602. (define_insn ""
  4603.   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
  4604.     (lshiftrt:QI (match_dup 0)
  4605.              (match_operand:QI 1 "general_operand" "dI")))]
  4606.   ""
  4607.   "lsr%.b %1,%0")
  4608.  
  4609. ;; rotate instructions
  4610.  
  4611. (define_insn "rotlsi3"
  4612.   [(set (match_operand:SI 0 "register_operand" "=d")
  4613.     (rotate:SI (match_operand:SI 1 "register_operand" "0")
  4614.            (match_operand:SI 2 "general_operand" "dI")))]
  4615.   ""
  4616.   "rol%.l %2,%0")
  4617.  
  4618. (define_insn "rotlhi3"
  4619.   [(set (match_operand:HI 0 "register_operand" "=d")
  4620.     (rotate:HI (match_operand:HI 1 "register_operand" "0")
  4621.            (match_operand:HI 2 "general_operand" "dI")))]
  4622.   ""
  4623.   "rol%.w %2,%0")
  4624.  
  4625.  
  4626. (define_insn ""
  4627.   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
  4628.     (rotate:HI (match_dup 0)
  4629.            (match_operand:HI 1 "general_operand" "dI")))]
  4630.   ""
  4631.   "rol%.w %1,%0")
  4632.  
  4633. (define_insn "rotlqi3"
  4634.   [(set (match_operand:QI 0 "register_operand" "=d")
  4635.     (rotate:QI (match_operand:QI 1 "register_operand" "0")
  4636.            (match_operand:QI 2 "general_operand" "dI")))]
  4637.   ""
  4638.   "rol%.b %2,%0")
  4639.  
  4640. (define_insn ""
  4641.   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
  4642.     (rotate:QI (match_dup 0)
  4643.            (match_operand:QI 1 "general_operand" "dI")))]
  4644.   ""
  4645.   "rol%.b %1,%0")
  4646.  
  4647. (define_insn "rotrsi3"
  4648.   [(set (match_operand:SI 0 "register_operand" "=d")
  4649.     (rotatert:SI (match_operand:SI 1 "register_operand" "0")
  4650.              (match_operand:SI 2 "general_operand" "dI")))]
  4651.   ""
  4652.   "ror%.l %2,%0")
  4653.  
  4654. (define_insn "rotrhi3"
  4655.   [(set (match_operand:HI 0 "register_operand" "=d")
  4656.     (rotatert:HI (match_operand:HI 1 "register_operand" "0")
  4657.              (match_operand:HI 2 "general_operand" "dI")))]
  4658.   ""
  4659.   "ror%.w %2,%0")
  4660.  
  4661. (define_insn ""
  4662.   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
  4663.     (rotatert:HI (match_dup 0)
  4664.              (match_operand:HI 1 "general_operand" "dI")))]
  4665.   ""
  4666.   "ror%.w %1,%0")
  4667.  
  4668. (define_insn "rotrqi3"
  4669.   [(set (match_operand:QI 0 "register_operand" "=d")
  4670.     (rotatert:QI (match_operand:QI 1 "register_operand" "0")
  4671.              (match_operand:QI 2 "general_operand" "dI")))]
  4672.   ""
  4673.   "ror%.b %2,%0")
  4674.  
  4675. (define_insn ""
  4676.   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
  4677.     (rotatert:QI (match_dup 0)
  4678.              (match_operand:QI 1 "general_operand" "dI")))]
  4679.   ""
  4680.   "ror%.b %1,%0")
  4681.  
  4682.  
  4683. ;; Bit set/clear in memory byte.
  4684.  
  4685. ;; set bit, bit number is int
  4686. (define_insn "bsetmemqi"
  4687.   [(set (match_operand:QI 0 "memory_operand" "+m")
  4688.     (ior:QI (subreg:QI (ashift:SI (const_int 1)
  4689.         (match_operand:SI 1 "general_operand" "d")) 0)
  4690.     (match_dup 0)))]
  4691.   ""
  4692.   "*
  4693. {
  4694.   CC_STATUS_INIT;
  4695.   return \"bset %1,%0\";
  4696. }")
  4697.  
  4698. ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
  4699. (define_insn ""
  4700.   [(set (match_operand:QI 0 "memory_operand" "+m")
  4701.     (ior:QI (subreg:QI (ashift:SI (const_int 1)
  4702.         (match_operator:SI 2 "extend_operator"
  4703.         [(match_operand 1 "general_operand" "d")])) 0)
  4704.     (match_dup 0)))]
  4705.   ""
  4706.   "*
  4707. {
  4708.   CC_STATUS_INIT;
  4709.   return \"bset %1,%0\";
  4710. }")
  4711.  
  4712. ;; clear bit, bit number is int
  4713. (define_insn "bclrmemqi"
  4714.   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
  4715.     (const_int 1)
  4716.     (minus:SI (const_int 7)
  4717.         (match_operand:SI 1 "general_operand" "d")))
  4718.     (const_int 0))]
  4719.   ""
  4720.   "*
  4721. {
  4722.   CC_STATUS_INIT;
  4723.   return \"bclr %1,%0\";
  4724. }")
  4725.  
  4726. ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
  4727. (define_insn ""
  4728.   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
  4729.     (const_int 1)
  4730.     (minus:SI (const_int 7)
  4731.         (match_operator:SI 2 "extend_operator"
  4732.         [(match_operand 1 "general_operand" "d")])))
  4733.     (const_int 0))]
  4734.   ""
  4735.   "*
  4736. {
  4737.   CC_STATUS_INIT;
  4738.   return \"bclr %1,%0\";
  4739. }")
  4740.  
  4741. ;; Special cases of bit-field insns which we should
  4742. ;; recognize in preference to the general case.
  4743. ;; These handle aligned 8-bit and 16-bit fields,
  4744. ;; which can usually be done with move instructions.
  4745.  
  4746. ;
  4747. ; Special case for 32-bit field in memory.  This only occurs when 32-bit
  4748. ; alignment of structure members is specified.
  4749. ;
  4750. ; The move is allowed to be odd byte aligned, because that's still faster
  4751. ; than an odd byte aligned bit field instruction.
  4752. ;
  4753. (define_insn ""
  4754.   [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o")
  4755.              (const_int 32)
  4756.              (match_operand:SI 2 "const_int_operand" "n"))
  4757.     (match_operand:SI 3 "general_operand" "rmi"))]
  4758.   "TARGET_68020 && TARGET_BITFIELD
  4759.    && (INTVAL (operands[2]) % 8) == 0
  4760.    && ! mode_dependent_address_p (XEXP (operands[0], 0))"
  4761.   "*
  4762. {
  4763.   operands[0]
  4764.     = adj_offsettable_operand (operands[0], INTVAL (operands[2]) / 8);
  4765.  
  4766.   return \"move%.l %3,%0\";
  4767. }")
  4768.  
  4769. (define_insn ""
  4770.   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+do")
  4771.              (match_operand:SI 1 "const_int_operand" "n")
  4772.              (match_operand:SI 2 "const_int_operand" "n"))
  4773.     (match_operand:SI 3 "register_operand" "d"))]
  4774.   "TARGET_68020 && TARGET_BITFIELD
  4775.    && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
  4776.    && INTVAL (operands[2]) % INTVAL (operands[1]) == 0
  4777.    && (GET_CODE (operands[0]) == REG
  4778.        || ! mode_dependent_address_p (XEXP (operands[0], 0)))"
  4779.   "*
  4780. {
  4781.   if (REG_P (operands[0]))
  4782.     {
  4783.       if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
  4784.         return \"bfins %3,%0{%b2:%b1}\";
  4785.     }
  4786.   else
  4787.     operands[0]
  4788.       = adj_offsettable_operand (operands[0], INTVAL (operands[2]) / 8);
  4789.  
  4790.   if (GET_CODE (operands[3]) == MEM)
  4791.     operands[3] = adj_offsettable_operand (operands[3],
  4792.                        (32 - INTVAL (operands[1])) / 8);
  4793.   if (INTVAL (operands[1]) == 8)
  4794.     return \"move%.b %3,%0\";
  4795.   return \"move%.w %3,%0\";
  4796. }")
  4797.  
  4798.  
  4799. ;
  4800. ; Special case for 32-bit field in memory.  This only occurs when 32-bit
  4801. ; alignment of structure members is specified.
  4802. ;
  4803. ; The move is allowed to be odd byte aligned, because that's still faster
  4804. ; than an odd byte aligned bit field instruction.
  4805. ;
  4806. (define_insn ""
  4807.   [(set (match_operand:SI 0 "general_operand" "=rm")
  4808.     (zero_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o")
  4809.              (const_int 32)
  4810.              (match_operand:SI 3 "const_int_operand" "n")))]
  4811.   "TARGET_68020 && TARGET_BITFIELD
  4812.    && (INTVAL (operands[3]) % 8) == 0
  4813.    && ! mode_dependent_address_p (XEXP (operands[1], 0))"
  4814.   "*
  4815. {
  4816.   operands[1]
  4817.     = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8);
  4818.  
  4819.   return \"move%.l %1,%0\";
  4820. }")
  4821.  
  4822. (define_insn ""
  4823.   [(set (match_operand:SI 0 "general_operand" "=&d")
  4824.     (zero_extract:SI (match_operand:SI 1 "nonimmediate_operand" "do")
  4825.              (match_operand:SI 2 "const_int_operand" "n")
  4826.              (match_operand:SI 3 "const_int_operand" "n")))]
  4827.   "TARGET_68020 && TARGET_BITFIELD
  4828.    && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
  4829.    && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
  4830.    && (GET_CODE (operands[1]) == REG
  4831.        || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
  4832.   "*
  4833. {
  4834.   cc_status.flags |= CC_NOT_NEGATIVE;
  4835.   if (REG_P (operands[1]))
  4836.     {
  4837.       if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
  4838.     return \"bfextu %1{%b3:%b2},%0\";
  4839.     }
  4840.   else
  4841.     operands[1]
  4842.       = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8);
  4843.  
  4844.   output_asm_insn (\"clr%.l %0\", operands);
  4845.   if (GET_CODE (operands[0]) == MEM)
  4846.     operands[0] = adj_offsettable_operand (operands[0],
  4847.                        (32 - INTVAL (operands[1])) / 8);
  4848.   if (INTVAL (operands[2]) == 8)
  4849.     return \"move%.b %1,%0\";
  4850.   return \"move%.w %1,%0\";
  4851. }")
  4852.  
  4853. ;
  4854. ; Special case for 32-bit field in memory.  This only occurs when 32-bit
  4855. ; alignment of structure members is specified.
  4856. ;
  4857. ; The move is allowed to be odd byte aligned, because that's still faster
  4858. ; than an odd byte aligned bit field instruction.
  4859. ;
  4860. (define_insn ""
  4861.   [(set (match_operand:SI 0 "general_operand" "=rm")
  4862.     (sign_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o")
  4863.              (const_int 32)
  4864.              (match_operand:SI 3 "const_int_operand" "n")))]
  4865.   "TARGET_68020 && TARGET_BITFIELD
  4866.    && (INTVAL (operands[3]) % 8) == 0
  4867.    && ! mode_dependent_address_p (XEXP (operands[1], 0))"
  4868.   "*
  4869. {
  4870.   operands[1]
  4871.     = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8);
  4872.  
  4873.   return \"move%.l %1,%0\";
  4874. }")
  4875.  
  4876. (define_insn ""
  4877.   [(set (match_operand:SI 0 "general_operand" "=d")
  4878.     (sign_extract:SI (match_operand:SI 1 "nonimmediate_operand" "do")
  4879.              (match_operand:SI 2 "const_int_operand" "n")
  4880.              (match_operand:SI 3 "const_int_operand" "n")))]
  4881.   "TARGET_68020 && TARGET_BITFIELD
  4882.    && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
  4883.    && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
  4884.    && (GET_CODE (operands[1]) == REG
  4885.        || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
  4886.   "*
  4887. {
  4888.   if (REG_P (operands[1]))
  4889.     {
  4890.       if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
  4891.     return \"bfexts %1{%b3:%b2},%0\";
  4892.     }
  4893.   else
  4894.     operands[1]
  4895.       = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8);
  4896.  
  4897.   if (INTVAL (operands[2]) == 8)
  4898.     return \"move%.b %1,%0\;extb%.l %0\";
  4899.   return \"move%.w %1,%0\;ext%.l %0\";
  4900. }")
  4901.  
  4902. ;; Bit field instructions, general cases.
  4903. ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
  4904. ;; so that its address is reloaded.
  4905.  
  4906. (define_insn "extv"
  4907.   [(set (match_operand:SI 0 "general_operand" "=d,d")
  4908.     (sign_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o,d")
  4909.              (match_operand:SI 2 "general_operand" "di,di")
  4910.              (match_operand:SI 3 "general_operand" "di,di")))]
  4911.   "TARGET_68020 && TARGET_BITFIELD"
  4912.   "bfexts %1{%b3:%b2},%0")
  4913.  
  4914. (define_insn "extzv"
  4915.   [(set (match_operand:SI 0 "general_operand" "=d,d")
  4916.     (zero_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o,d")
  4917.              (match_operand:SI 2 "general_operand" "di,di")
  4918.              (match_operand:SI 3 "general_operand" "di,di")))]
  4919.   "TARGET_68020 && TARGET_BITFIELD"
  4920.   "*
  4921. {
  4922.   if (GET_CODE (operands[2]) == CONST_INT)
  4923.     {
  4924.       if (INTVAL (operands[2]) != 32)
  4925.     cc_status.flags |= CC_NOT_NEGATIVE;
  4926.     }
  4927.   else
  4928.     {
  4929.       CC_STATUS_INIT;
  4930.     }
  4931.   return \"bfextu %1{%b3:%b2},%0\";
  4932. }")
  4933.  
  4934. (define_insn ""
  4935.   [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d")
  4936.              (match_operand:SI 1 "general_operand" "di,di")
  4937.              (match_operand:SI 2 "general_operand" "di,di"))
  4938.         (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
  4939.         (match_operand 3 "const_int_operand" "n,n")))]
  4940.   "TARGET_68020 && TARGET_BITFIELD
  4941.    && (INTVAL (operands[3]) == -1
  4942.        || (GET_CODE (operands[1]) == CONST_INT
  4943.            && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
  4944.   "*
  4945. {
  4946.   CC_STATUS_INIT;
  4947.   return \"bfchg %0{%b2:%b1}\";
  4948. }")
  4949.  
  4950. (define_insn ""
  4951.   [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d")
  4952.              (match_operand:SI 1 "general_operand" "di,di")
  4953.              (match_operand:SI 2 "general_operand" "di,di"))
  4954.     (const_int 0))]
  4955.   "TARGET_68020 && TARGET_BITFIELD"
  4956.   "*
  4957. {
  4958.   CC_STATUS_INIT;
  4959.   return \"bfclr %0{%b2:%b1}\";
  4960. }")
  4961.  
  4962. (define_insn ""
  4963.   [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d")
  4964.              (match_operand:SI 1 "general_operand" "di,di")
  4965.              (match_operand:SI 2 "general_operand" "di,di"))
  4966.     (const_int -1))]
  4967.   "TARGET_68020 && TARGET_BITFIELD"
  4968.   "*
  4969. {
  4970.   CC_STATUS_INIT;
  4971.   return \"bfset %0{%b2:%b1}\";
  4972. }")
  4973.  
  4974. (define_insn "insv"
  4975.   [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d")
  4976.              (match_operand:SI 1 "general_operand" "di,di")
  4977.              (match_operand:SI 2 "general_operand" "di,di"))
  4978.     (match_operand:SI 3 "register_operand" "d,d"))]
  4979.   "TARGET_68020 && TARGET_BITFIELD"
  4980.   "bfins %3,%0{%b2:%b1}")
  4981.  
  4982. ;; Now recognize bit field insns that operate on registers
  4983. ;; (or at least were intended to do so).
  4984.  
  4985. (define_insn ""
  4986.   [(set (match_operand:SI 0 "general_operand" "=d")
  4987.     (sign_extract:SI (match_operand:SI 1 "nonimmediate_operand" "d")
  4988.              (match_operand:SI 2 "general_operand" "di")
  4989.              (match_operand:SI 3 "general_operand" "di")))]
  4990.   "TARGET_68020 && TARGET_BITFIELD"
  4991.   "bfexts %1{%b3:%b2},%0")
  4992.  
  4993. (define_insn ""
  4994.   [(set (match_operand:SI 0 "general_operand" "=d")
  4995.     (zero_extract:SI (match_operand:SI 1 "nonimmediate_operand" "d")
  4996.              (match_operand:SI 2 "general_operand" "di")
  4997.              (match_operand:SI 3 "general_operand" "di")))]
  4998.   "TARGET_68020 && TARGET_BITFIELD"
  4999.   "*
  5000. {
  5001.   if (GET_CODE (operands[2]) == CONST_INT)
  5002.     {
  5003.       if (INTVAL (operands[2]) != 32)
  5004.     cc_status.flags |= CC_NOT_NEGATIVE;
  5005.     }
  5006.   else
  5007.     {
  5008.       CC_STATUS_INIT;
  5009.     }
  5010.   return \"bfextu %1{%b3:%b2},%0\";
  5011. }")
  5012.  
  5013. (define_insn ""
  5014.   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d")
  5015.              (match_operand:SI 1 "general_operand" "di")
  5016.              (match_operand:SI 2 "general_operand" "di"))
  5017.     (const_int 0))]
  5018.   "TARGET_68020 && TARGET_BITFIELD"
  5019.   "*
  5020. {
  5021.   CC_STATUS_INIT;
  5022.   return \"bfclr %0{%b2:%b1}\";
  5023. }")
  5024.  
  5025. (define_insn ""
  5026.   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d")
  5027.              (match_operand:SI 1 "general_operand" "di")
  5028.              (match_operand:SI 2 "general_operand" "di"))
  5029.     (const_int -1))]
  5030.   "TARGET_68020 && TARGET_BITFIELD"
  5031.   "*
  5032. {
  5033.   CC_STATUS_INIT;
  5034.   return \"bfset %0{%b2:%b1}\";
  5035. }")
  5036.  
  5037. (define_insn ""
  5038.   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d")
  5039.              (match_operand:SI 1 "general_operand" "di")
  5040.              (match_operand:SI 2 "general_operand" "di"))
  5041.     (match_operand:SI 3 "register_operand" "d"))]
  5042.   "TARGET_68020 && TARGET_BITFIELD"
  5043.   "*
  5044. {
  5045. #if 0
  5046.   /* These special cases are now recognized by a specific pattern.  */
  5047.   if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
  5048.       && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
  5049.     return \"move%.w %3,%0\";
  5050.   if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
  5051.       && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
  5052.     return \"move%.b %3,%0\";
  5053. #endif
  5054.   return \"bfins %3,%0{%b2:%b1}\";
  5055. }")
  5056.  
  5057. ;; Special patterns for optimizing bit-field instructions.
  5058.  
  5059. (define_insn ""
  5060.   [(set (cc0)
  5061.     (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
  5062.              (match_operand:SI 1 "const_int_operand" "n")
  5063.              (match_operand:SI 2 "general_operand" "di")))]
  5064.   "TARGET_68020 && TARGET_BITFIELD"
  5065.   "*
  5066. {
  5067.   if (operands[1] == const1_rtx
  5068.       && GET_CODE (operands[2]) == CONST_INT)
  5069.     {    
  5070.       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
  5071.       return output_btst (operands,
  5072.               gen_rtx (CONST_INT, VOIDmode,
  5073.                    width - INTVAL (operands[2])),
  5074.               operands[0],
  5075.               insn, 1000);
  5076.       /* Pass 1000 as SIGNPOS argument so that btst will
  5077.          not think we are testing the sign bit for an `and'
  5078.      and assume that nonzero implies a negative result.  */
  5079.     }
  5080.   if (INTVAL (operands[1]) != 32)
  5081.     cc_status.flags = CC_NOT_NEGATIVE;
  5082.   return \"bftst %0{%b2:%b1}\";
  5083. }")
  5084.  
  5085.   
  5086. ;;; now handle the register cases
  5087. (define_insn ""
  5088.   [(set (cc0)
  5089.     (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "d")
  5090.              (match_operand:SI 1 "const_int_operand" "n")
  5091.              (match_operand:SI 2 "general_operand" "di")))]
  5092.   "TARGET_68020 && TARGET_BITFIELD"
  5093.   "*
  5094. {
  5095.   if (operands[1] == const1_rtx
  5096.       && GET_CODE (operands[2]) == CONST_INT)
  5097.     {    
  5098.       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
  5099.       return output_btst (operands,
  5100.               gen_rtx (CONST_INT, VOIDmode,
  5101.                    width - INTVAL (operands[2])),
  5102.               operands[0],
  5103.               insn, 1000);
  5104.       /* Pass 1000 as SIGNPOS argument so that btst will
  5105.          not think we are testing the sign bit for an `and'
  5106.      and assume that nonzero implies a negative result.  */
  5107.     }
  5108.   if (INTVAL (operands[1]) != 32)
  5109.     cc_status.flags = CC_NOT_NEGATIVE;
  5110.   return \"bftst %0{%b2:%b1}\";
  5111. }")
  5112.  
  5113. (define_insn "scc0_di"
  5114.   [(set (match_operand:QI 0 "general_operand" "=dm")
  5115.     (match_operator 1 "valid_dbcc_comparison_p"
  5116.       [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
  5117.   ""
  5118.   "*
  5119. {
  5120.   return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
  5121. } ")
  5122.  
  5123. (define_insn "scc_di"
  5124.   [(set (match_operand:QI 0 "general_operand" "=dm,dm")
  5125.     (match_operator 1 "valid_dbcc_comparison_p"
  5126.       [(match_operand:DI 2 "general_operand" "ro,r")
  5127.        (match_operand:DI 3 "general_operand" "r,ro")]))]
  5128.   ""
  5129.   "*
  5130. {
  5131.   return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
  5132. } ")
  5133.  
  5134. (define_insn "seq"
  5135.   [(set (match_operand:QI 0 "general_operand" "=d")
  5136.     (eq:QI (cc0) (const_int 0)))]
  5137.   ""
  5138.   "*
  5139.   cc_status = cc_prev_status;
  5140.   OUTPUT_JUMP (\"seq %0\", \"fseq %0\", \"seq %0\");
  5141. ")
  5142.  
  5143. (define_insn "sne"
  5144.   [(set (match_operand:QI 0 "general_operand" "=d")
  5145.     (ne:QI (cc0) (const_int 0)))]
  5146.   ""
  5147.   "*
  5148.   cc_status = cc_prev_status;
  5149.   OUTPUT_JUMP (\"sne %0\", \"fsne %0\", \"sne %0\");
  5150. ")
  5151.  
  5152. (define_insn "sgt"
  5153.   [(set (match_operand:QI 0 "general_operand" "=d")
  5154.     (gt:QI (cc0) (const_int 0)))]
  5155.   ""
  5156.   "*
  5157.   cc_status = cc_prev_status;
  5158.   OUTPUT_JUMP (\"sgt %0\", \"fsgt %0\", 0);
  5159. ")
  5160.  
  5161. (define_insn "sgtu"
  5162.   [(set (match_operand:QI 0 "general_operand" "=d")
  5163.     (gtu:QI (cc0) (const_int 0)))]
  5164.   ""
  5165.   "* cc_status = cc_prev_status;
  5166.      return \"shi %0\"; ")
  5167.  
  5168. (define_insn "slt"
  5169.   [(set (match_operand:QI 0 "general_operand" "=d")
  5170.     (lt:QI (cc0) (const_int 0)))]
  5171.   ""
  5172.   "* cc_status = cc_prev_status;
  5173.      OUTPUT_JUMP (\"slt %0\", \"fslt %0\", \"smi %0\"); ")
  5174.  
  5175. (define_insn "sltu"
  5176.   [(set (match_operand:QI 0 "general_operand" "=d")
  5177.     (ltu:QI (cc0) (const_int 0)))]
  5178.   ""
  5179.   "* cc_status = cc_prev_status;
  5180.      return \"scs %0\"; ")
  5181.  
  5182. (define_insn "sge"
  5183.   [(set (match_operand:QI 0 "general_operand" "=d")
  5184.     (ge:QI (cc0) (const_int 0)))]
  5185.   ""
  5186.   "* cc_status = cc_prev_status;
  5187.      OUTPUT_JUMP (\"sge %0\", \"fsge %0\", \"spl %0\"); ")
  5188.  
  5189. (define_insn "sgeu"
  5190.   [(set (match_operand:QI 0 "general_operand" "=d")
  5191.     (geu:QI (cc0) (const_int 0)))]
  5192.   ""
  5193.   "* cc_status = cc_prev_status;
  5194.      return \"scc %0\"; ")
  5195.  
  5196. (define_insn "sle"
  5197.   [(set (match_operand:QI 0 "general_operand" "=d")
  5198.     (le:QI (cc0) (const_int 0)))]
  5199.   ""
  5200.   "*
  5201.   cc_status = cc_prev_status;
  5202.   OUTPUT_JUMP (\"sle %0\", \"fsle %0\", 0);
  5203. ")
  5204.  
  5205. (define_insn "sleu"
  5206.   [(set (match_operand:QI 0 "general_operand" "=d")
  5207.     (leu:QI (cc0) (const_int 0)))]
  5208.   ""
  5209.   "* cc_status = cc_prev_status;
  5210.      return \"sls %0\"; ")
  5211.  
  5212. ;; Basic conditional jump instructions.
  5213.  
  5214. (define_insn "beq0_di"
  5215.   [(set (pc)
  5216.     (if_then_else (eq (match_operand:DI 0 "general_operand" "d*ao,<>")
  5217.             (const_int 0))
  5218.         (label_ref (match_operand 1 "" ","))
  5219.         (pc)))
  5220.    (clobber (match_scratch:SI 2 "=d,d"))]
  5221.   ""
  5222.   "*
  5223. {
  5224.   if (which_alternative == 1)
  5225. #ifdef MOTOROLA
  5226.     return \"move%.l %0,%2\;or%.l %0,%2\;jbeq %l1\";
  5227. #else
  5228.     return \"move%.l %0,%2\;or%.l %0,%2\;jeq %l1\";
  5229. #endif
  5230.   if (GET_CODE (operands[0]) == REG)
  5231.     operands[3] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  5232.   else
  5233.     operands[3] = adj_offsettable_operand (operands[0], 4);
  5234.   if (! ADDRESS_REG_P (operands[0]))
  5235. #ifdef MOTOROLA
  5236.     return \"move%.l %0,%2\;or%.l %3,%2\;jbeq %l1\";
  5237. #else
  5238.     return \"move%.l %0,%2\;or%.l %3,%2\;jeq %l1\";
  5239. #endif
  5240.   operands[4] = gen_label_rtx();
  5241. #ifdef MOTOROLA
  5242.   output_asm_insn (\"tst%.l %0\;jbne %l4\;tst%.l %3\;jbeq %l1\", operands);
  5243. #else
  5244.   output_asm_insn (\"tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1\", operands);
  5245. #endif
  5246.   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
  5247.                 CODE_LABEL_NUMBER (operands[4]));
  5248.   return \"\";
  5249. } ")
  5250.  
  5251. (define_insn "bne0_di"
  5252.   [(set (pc)
  5253.     (if_then_else (ne (match_operand:DI 0 "general_operand" "do,*a")
  5254.             (const_int 0))
  5255.         (label_ref (match_operand 1 "" ","))
  5256.         (pc)))
  5257.    (clobber (match_scratch:SI 2 "=d,"))]
  5258.   ""
  5259.   "*
  5260. {
  5261.   if (GET_CODE (operands[0]) == REG)
  5262.     operands[3] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  5263.   else
  5264.     operands[3] = adj_offsettable_operand (operands[0], 4);
  5265.   if (ADDRESS_REG_P (operands[0]))
  5266. #ifdef MOTOROLA
  5267.     return \"tst%.l %0\;jbne %l1\;tst%.l %3\;jbne %l1\";
  5268. #else
  5269.     return \"tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1\";
  5270. #endif
  5271.   else
  5272. #ifdef MOTOROLA
  5273.     return \"move%.l %0,%2\;or%.l %3,%2\;jbne %l1\";
  5274. #else
  5275.     return \"move%.l %0,%2\;or%.l %3,%2\;jne %l1\";
  5276. #endif
  5277. } ")
  5278.  
  5279. (define_insn "bge0_di"
  5280.   [(set (pc)
  5281.     (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
  5282.             (const_int 0))
  5283.         (label_ref (match_operand 1 "" ""))
  5284.         (pc)))]
  5285.   ""
  5286.   "*
  5287. {
  5288. #ifdef MOTOROLA
  5289.   return \"tst%.l %0\;jbge %l1\";
  5290. #else
  5291.   return \"tst%.l %0\;jge %l1\";
  5292. #endif
  5293. } ")
  5294.  
  5295. (define_insn "blt0_di"
  5296.   [(set (pc)
  5297.     (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
  5298.             (const_int 0))
  5299.         (label_ref (match_operand 1 "" ""))
  5300.         (pc)))]
  5301.   ""
  5302.   "*
  5303. {
  5304. #ifdef MOTOROLA
  5305.   return \"tst%.l %0\;jbmi %l1\";
  5306. #else
  5307.   return \"tst%.l %0\;jmi %l1\";
  5308. #endif
  5309. } ")
  5310.  
  5311. (define_insn "beq"
  5312.   [(set (pc)
  5313.     (if_then_else (eq (cc0)
  5314.               (const_int 0))
  5315.               (label_ref (match_operand 0 "" ""))
  5316.               (pc)))]
  5317.   ""
  5318.   "*
  5319. {
  5320. #ifdef MOTOROLA
  5321.   OUTPUT_JUMP (\"jbeq %l0\", \"fbeq %l0\", \"jbeq %l0\");
  5322. #else
  5323.   OUTPUT_JUMP (\"jeq %l0\", \"fjeq %l0\", \"jeq %l0\");
  5324. #endif
  5325. }")
  5326.  
  5327. (define_insn "bne"
  5328.   [(set (pc)
  5329.     (if_then_else (ne (cc0)
  5330.               (const_int 0))
  5331.               (label_ref (match_operand 0 "" ""))
  5332.               (pc)))]
  5333.   ""
  5334.   "*
  5335. {
  5336. #ifdef MOTOROLA
  5337.   OUTPUT_JUMP (\"jbne %l0\", \"fbne %l0\", \"jbne %l0\");
  5338. #else
  5339.   OUTPUT_JUMP (\"jne %l0\", \"fjne %l0\", \"jne %l0\");
  5340. #endif
  5341. }")
  5342.  
  5343. (define_insn "bgt"
  5344.   [(set (pc)
  5345.     (if_then_else (gt (cc0)
  5346.               (const_int 0))
  5347.               (label_ref (match_operand 0 "" ""))
  5348.               (pc)))]
  5349.   ""
  5350.   "*
  5351. #ifdef MOTOROLA
  5352.   OUTPUT_JUMP (\"jbgt %l0\", \"fbgt %l0\", 0);
  5353. #else
  5354.   OUTPUT_JUMP (\"jgt %l0\", \"fjgt %l0\", 0);
  5355. #endif
  5356. ")
  5357.  
  5358. (define_insn "bgtu"
  5359.   [(set (pc)
  5360.     (if_then_else (gtu (cc0)
  5361.                (const_int 0))
  5362.               (label_ref (match_operand 0 "" ""))
  5363.               (pc)))]
  5364.   ""
  5365.   "*
  5366. #ifdef MOTOROLA
  5367.   return \"jbhi %l0\";
  5368. #else
  5369.   return \"jhi %l0\";
  5370. #endif
  5371. ")
  5372.  
  5373. (define_insn "blt"
  5374.   [(set (pc)
  5375.     (if_then_else (lt (cc0)
  5376.               (const_int 0))
  5377.               (label_ref (match_operand 0 "" ""))
  5378.               (pc)))]
  5379.   ""
  5380.   "*
  5381. #ifdef MOTOROLA
  5382.   OUTPUT_JUMP (\"jblt %l0\", \"fblt %l0\", \"jbmi %l0\");
  5383. #else
  5384.   OUTPUT_JUMP (\"jlt %l0\", \"fjlt %l0\", \"jmi %l0\");
  5385. #endif
  5386. ")
  5387.  
  5388. (define_insn "bltu"
  5389.   [(set (pc)
  5390.     (if_then_else (ltu (cc0)
  5391.                (const_int 0))
  5392.               (label_ref (match_operand 0 "" ""))
  5393.               (pc)))]
  5394.   ""
  5395.   "*
  5396. #ifdef MOTOROLA
  5397.   return \"jbcs %l0\";
  5398. #else
  5399.   return \"jcs %l0\";
  5400. #endif
  5401. ")
  5402.  
  5403. (define_insn "bge"
  5404.   [(set (pc)
  5405.     (if_then_else (ge (cc0)
  5406.               (const_int 0))
  5407.               (label_ref (match_operand 0 "" ""))
  5408.               (pc)))]
  5409.   ""
  5410.   "*
  5411. #ifdef MOTOROLA
  5412.   OUTPUT_JUMP (\"jbge %l0\", \"fbge %l0\", \"jbpl %l0\");
  5413. #else
  5414.   OUTPUT_JUMP (\"jge %l0\", \"fjge %l0\", \"jpl %l0\");
  5415. #endif
  5416. ")
  5417.  
  5418. (define_insn "bgeu"
  5419.   [(set (pc)
  5420.     (if_then_else (geu (cc0)
  5421.                (const_int 0))
  5422.               (label_ref (match_operand 0 "" ""))
  5423.               (pc)))]
  5424.   ""
  5425.   "*
  5426. #ifdef MOTOROLA
  5427.   return \"jbcc %l0\";
  5428. #else
  5429.   return \"jcc %l0\";
  5430. #endif
  5431. ")
  5432.  
  5433. (define_insn "ble"
  5434.   [(set (pc)
  5435.     (if_then_else (le (cc0)
  5436.               (const_int 0))
  5437.               (label_ref (match_operand 0 "" ""))
  5438.               (pc)))]
  5439.   ""
  5440.   "*
  5441. #ifdef MOTOROLA
  5442.   OUTPUT_JUMP (\"jble %l0\", \"fble %l0\", 0);
  5443. #else
  5444.   OUTPUT_JUMP (\"jle %l0\", \"fjle %l0\", 0);
  5445. #endif
  5446. ")
  5447.  
  5448. (define_insn "bleu"
  5449.   [(set (pc)
  5450.     (if_then_else (leu (cc0)
  5451.                (const_int 0))
  5452.               (label_ref (match_operand 0 "" ""))
  5453.               (pc)))]
  5454.   ""
  5455.   "*
  5456. #ifdef MOTOROLA
  5457.   return \"jbls %l0\";
  5458. #else
  5459.   return \"jls %l0\";
  5460. #endif
  5461. ")
  5462.  
  5463. ;; Negated conditional jump instructions.
  5464.  
  5465. (define_insn ""
  5466.   [(set (pc)
  5467.     (if_then_else (eq (cc0)
  5468.               (const_int 0))
  5469.               (pc)
  5470.               (label_ref (match_operand 0 "" ""))))]
  5471.   ""
  5472.   "*
  5473. {
  5474. #ifdef MOTOROLA
  5475.   OUTPUT_JUMP (\"jbne %l0\", \"fbne %l0\", \"jbne %l0\");
  5476. #else
  5477.   OUTPUT_JUMP (\"jne %l0\", \"fjne %l0\", \"jne %l0\");
  5478. #endif
  5479. }")
  5480.  
  5481. (define_insn ""
  5482.   [(set (pc)
  5483.     (if_then_else (ne (cc0)
  5484.               (const_int 0))
  5485.               (pc)
  5486.               (label_ref (match_operand 0 "" ""))))]
  5487.   ""
  5488.   "*
  5489. {
  5490. #ifdef MOTOROLA
  5491.   OUTPUT_JUMP (\"jbeq %l0\", \"fbeq %l0\", \"jbeq %l0\");
  5492. #else
  5493.   OUTPUT_JUMP (\"jeq %l0\", \"fjeq %l0\", \"jeq %l0\");
  5494. #endif
  5495. }")
  5496.  
  5497. (define_insn ""
  5498.   [(set (pc)
  5499.     (if_then_else (gt (cc0)
  5500.               (const_int 0))
  5501.               (pc)
  5502.               (label_ref (match_operand 0 "" ""))))]
  5503.   ""
  5504.   "*
  5505. #ifdef MOTOROLA
  5506.   OUTPUT_JUMP (\"jble %l0\", \"fbngt %l0\", 0);
  5507. #else
  5508.   OUTPUT_JUMP (\"jle %l0\", \"fjngt %l0\", 0);
  5509. #endif
  5510. ")
  5511.  
  5512. (define_insn ""
  5513.   [(set (pc)
  5514.     (if_then_else (gtu (cc0)
  5515.                (const_int 0))
  5516.               (pc)
  5517.               (label_ref (match_operand 0 "" ""))))]
  5518.   ""
  5519.   "*
  5520. #ifdef MOTOROLA
  5521.   return \"jbls %l0\";
  5522. #else
  5523.   return \"jls %l0\";
  5524. #endif
  5525. ")
  5526.  
  5527. (define_insn ""
  5528.   [(set (pc)
  5529.     (if_then_else (lt (cc0)
  5530.               (const_int 0))
  5531.               (pc)
  5532.               (label_ref (match_operand 0 "" ""))))]
  5533.   ""
  5534.   "*
  5535. #ifdef MOTOROLA
  5536.   OUTPUT_JUMP (\"jbge %l0\", \"fbnlt %l0\", \"jbpl %l0\");
  5537. #else
  5538.   OUTPUT_JUMP (\"jge %l0\", \"fjnlt %l0\", \"jpl %l0\");
  5539. #endif
  5540. ")
  5541.  
  5542. (define_insn ""
  5543.   [(set (pc)
  5544.     (if_then_else (ltu (cc0)
  5545.                (const_int 0))
  5546.               (pc)
  5547.               (label_ref (match_operand 0 "" ""))))]
  5548.   ""
  5549.   "*
  5550. #ifdef MOTOROLA
  5551.   return \"jbcc %l0\";
  5552. #else
  5553.   return \"jcc %l0\";
  5554. #endif
  5555. ")
  5556.  
  5557. (define_insn ""
  5558.   [(set (pc)
  5559.     (if_then_else (ge (cc0)
  5560.               (const_int 0))
  5561.               (pc)
  5562.               (label_ref (match_operand 0 "" ""))))]
  5563.   ""
  5564.   "*
  5565. #ifdef MOTOROLA
  5566.   OUTPUT_JUMP (\"jblt %l0\", \"fbnge %l0\", \"jbmi %l0\");
  5567. #else
  5568.   OUTPUT_JUMP (\"jlt %l0\", \"fjnge %l0\", \"jmi %l0\");
  5569. #endif
  5570. ")
  5571.  
  5572. (define_insn ""
  5573.   [(set (pc)
  5574.     (if_then_else (geu (cc0)
  5575.                (const_int 0))
  5576.               (pc)
  5577.               (label_ref (match_operand 0 "" ""))))]
  5578.   ""
  5579.   "*
  5580. #ifdef MOTOROLA
  5581.   return \"jbcs %l0\";
  5582. #else
  5583.   return \"jcs %l0\";
  5584. #endif
  5585. ")
  5586.  
  5587. (define_insn ""
  5588.   [(set (pc)
  5589.     (if_then_else (le (cc0)
  5590.               (const_int 0))
  5591.               (pc)
  5592.               (label_ref (match_operand 0 "" ""))))]
  5593.   ""
  5594.   "*
  5595. #ifdef MOTOROLA
  5596.   OUTPUT_JUMP (\"jbgt %l0\", \"fbnle %l0\", 0);
  5597. #else
  5598.   OUTPUT_JUMP (\"jgt %l0\", \"fjnle %l0\", 0);
  5599. #endif
  5600. ")
  5601.  
  5602. (define_insn ""
  5603.   [(set (pc)
  5604.     (if_then_else (leu (cc0)
  5605.                (const_int 0))
  5606.               (pc)
  5607.               (label_ref (match_operand 0 "" ""))))]
  5608.   ""
  5609.   "*
  5610. #ifdef MOTOROLA
  5611.   return \"jbhi %l0\";
  5612. #else
  5613.   return \"jhi %l0\";
  5614. #endif
  5615. ")
  5616.  
  5617. ;; Unconditional and other jump instructions
  5618. (define_insn "jump"
  5619.   [(set (pc)
  5620.     (label_ref (match_operand 0 "" "")))]
  5621.   ""
  5622.   "*
  5623. #ifdef MOTOROLA
  5624.   return \"jbra %l0\";
  5625. #else
  5626.   return \"jra %l0\";
  5627. #endif
  5628. ")
  5629.  
  5630. ;; We support two different ways of handling dispatch tables.
  5631. ;; The NeXT uses absolute tables, and other machines use relative.
  5632. ;; This define_expand can generate either kind.
  5633. (define_expand "tablejump"
  5634.   [(parallel [(set (pc) (match_operand 0 "" ""))
  5635.           (use (label_ref (match_operand 1 "" "")))])]
  5636.   ""
  5637.   "
  5638. {
  5639. #ifdef MACHOPIC_PURE
  5640.   if (MACHOPIC_PURE)
  5641.     {
  5642.       current_function_uses_pic_offset_table = 1;
  5643. #endif
  5644. #if defined (CASE_VECTOR_PC_RELATIVE) || defined (MACHOPIC_PURE)
  5645.     operands[0] = gen_rtx (PLUS, SImode, pc_rtx,
  5646. #ifndef MACHOPIC_PURE
  5647.                gen_rtx (SIGN_EXTEND, SImode, operands[0]));
  5648. #else
  5649.                operands[0]);
  5650.     }
  5651. #endif /* MACHOPIC_PURE */
  5652. #endif
  5653. }")
  5654.  
  5655. ;; Jump to variable address from dispatch table of absolute addresses.
  5656. (define_insn ""
  5657.   [(set (pc) (match_operand:SI 0 "register_operand" "a"))
  5658.    (use (label_ref (match_operand 1 "" "")))]
  5659.   ""
  5660.   "*
  5661. #ifdef MOTOROLA
  5662.   return \"jmp (%0)\";
  5663. #else
  5664.   return \"jmp %0@\";
  5665. #endif
  5666. ")
  5667.  
  5668. ;; Jump to variable address from dispatch table of relative addresses.
  5669. (define_insn ""
  5670.   [(set (pc)
  5671.     (plus:SI (pc)
  5672.          (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
  5673.    (use (label_ref (match_operand 1 "" "")))]
  5674.   ""
  5675.   "*
  5676. #ifdef ASM_RETURN_CASE_JUMP
  5677.  ASM_RETURN_CASE_JUMP;
  5678. #else
  5679. #ifdef SGS
  5680. #ifdef ASM_OUTPUT_CASE_LABEL
  5681.   return \"jmp 6(%%pc,%0.w)\";
  5682. #else
  5683. #ifdef CRDS
  5684.   return \"jmp 2(pc,%0.w)\";
  5685. #else
  5686.   return \"jmp 2(%%pc,%0.w)\";
  5687. #endif  /* end !CRDS */
  5688. #endif
  5689. #else /* not SGS */
  5690. #ifdef MOTOROLA
  5691.   return \"jmp (2,pc,%0.w)\";
  5692. #else
  5693.   return \"jmp pc@(2,%0:w)\";
  5694. #endif
  5695. #endif
  5696. #endif
  5697. ")
  5698.  
  5699. ;; Jump to variable address from dispatch table of relative addresses.
  5700. (define_insn ""
  5701.   [(set (pc)
  5702.     (plus:SI (pc) (match_operand:SI 0 "register_operand" "r")))
  5703.    (use (label_ref (match_operand 1 "" "")))]
  5704.   ""
  5705.   "*
  5706. #ifdef ASM_RETURN_CASE_JUMP
  5707.  ASM_RETURN_CASE_JUMP;
  5708. #else
  5709. #ifdef SGS
  5710. #ifdef ASM_OUTPUT_CASE_LABEL
  5711.   return \"jmp 6(%%pc,%0.l)\";
  5712. #else
  5713. #ifdef CRDS
  5714.   return \"jmp 2(pc,%0.l)\";
  5715. #else
  5716.   return \"jmp 2(%%pc,%0.l)\";
  5717. #endif  /* end !CRDS */
  5718. #endif
  5719. #else /* not SGS */
  5720. #ifdef MOTOROLA
  5721.   return \"jmp (2,pc,%0.l)\";
  5722. #else
  5723. #ifdef MACHO_PIC
  5724.   return \"jmp a5@(0,%0:l)\;\";
  5725. #else
  5726.   return \"jmp pc@(2,%0:l)\";
  5727. #endif
  5728. #endif
  5729. #endif
  5730. #endif
  5731. ")
  5732.  
  5733. ;; Decrement-and-branch insns.
  5734. (define_insn ""
  5735.   [(set (pc)
  5736.     (if_then_else
  5737.      (ne (match_operand:HI 0 "general_operand" "+d*g")
  5738.          (const_int 0))
  5739.      (label_ref (match_operand 1 "" ""))
  5740.      (pc)))
  5741.    (set (match_dup 0)
  5742.     (plus:HI (match_dup 0)
  5743.          (const_int -1)))]
  5744.   ""
  5745.   "*
  5746. {
  5747.   CC_STATUS_INIT;
  5748.   if (DATA_REG_P (operands[0]))
  5749.     return \"dbra %0,%l1\";
  5750.   if (GET_CODE (operands[0]) == MEM)
  5751.     {
  5752. #ifdef MOTOROLA
  5753. #ifdef NO_ADDSUB_Q
  5754.       return \"sub%.w %#1,%0\;jbcc %l1\";
  5755. #else
  5756.       return \"subq%.w %#1,%0\;jbcc %l1\";
  5757. #endif
  5758. #else /* not MOTOROLA */
  5759.       return \"subqw %#1,%0\;jcc %l1\";
  5760. #endif
  5761.     }
  5762. #ifdef MOTOROLA
  5763. #ifdef SGS_CMP_ORDER
  5764. #ifdef NO_ADDSUB_Q
  5765.   return \"sub%.w %#1,%0\;cmp%.w %0,%#-1\;jbne %l1\";
  5766. #else
  5767.   return \"subq%.w %#1,%0\;cmp%.w %0,%#-1\;jbne %l1\";
  5768. #endif
  5769. #else /* not SGS_CMP_ORDER */
  5770.   return \"subq%.w %#1,%0\;cmp%.w %#-1,%0\;jbne %l1\";
  5771. #endif
  5772. #else /* not MOTOROLA */
  5773.   return \"subqw %#1,%0\;cmpw %#-1,%0\;jne %l1\";
  5774. #endif
  5775. }")
  5776.  
  5777. (define_insn ""
  5778.   [(set (pc)
  5779.     (if_then_else
  5780.      (ne (match_operand:SI 0 "general_operand" "+d*g")
  5781.          (const_int 0))
  5782.      (label_ref (match_operand 1 "" ""))
  5783.      (pc)))
  5784.    (set (match_dup 0)
  5785.     (plus:SI (match_dup 0)
  5786.          (const_int -1)))]
  5787.   ""
  5788.   "*
  5789. {
  5790.   CC_STATUS_INIT;
  5791. #ifdef MOTOROLA
  5792. #ifdef NO_ADDSUB_Q
  5793.   if (DATA_REG_P (operands[0]))
  5794.     return \"dbra %0,%l1\;clr%.w %0\;sub%.l %#1,%0\;jbcc %l1\";
  5795.   if (GET_CODE (operands[0]) == MEM)
  5796.     return \"sub%.l %#1,%0\;jbcc %l1\";
  5797. #else
  5798.   if (DATA_REG_P (operands[0]))
  5799.     return \"dbra %0,%l1\;clr%.w %0\;subq%.l %#1,%0\;jbcc %l1\";
  5800.   if (GET_CODE (operands[0]) == MEM)
  5801.     return \"subq%.l %#1,%0\;jbcc %l1\";
  5802. #endif /* NO_ADDSUB_Q */
  5803. #ifdef SGS_CMP_ORDER
  5804. #ifdef NO_ADDSUB_Q
  5805.   return \"sub.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\";
  5806. #else
  5807.   return \"subq.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\";
  5808. #endif
  5809. #else /* not SGS_CMP_ORDER */
  5810.   return \"subq.l %#1,%0\;cmp.l %#-1,%0\;jbne %l1\";
  5811. #endif /* not SGS_CMP_ORDER */
  5812. #else /* not MOTOROLA */
  5813.   if (DATA_REG_P (operands[0]))
  5814.     return \"dbra %0,%l1\;clr%.w %0\;subql %#1,%0\;jcc %l1\";
  5815.   if (GET_CODE (operands[0]) == MEM)
  5816.     return \"subql %#1,%0\;jcc %l1\";
  5817.   return \"subql %#1,%0\;cmpl %#-1,%0\;jne %l1\";
  5818. #endif /* not MOTOROLA */
  5819. }")
  5820.  
  5821. ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
  5822.  
  5823. (define_insn ""
  5824.   [(set (pc)
  5825.     (if_then_else
  5826.       (ge (plus:HI (match_operand:HI 0 "general_operand" "+d*am")
  5827.                (const_int -1))
  5828.           (const_int 0))
  5829.       (label_ref (match_operand 1 "" ""))
  5830.       (pc)))
  5831.    (set (match_dup 0)
  5832.     (plus:HI (match_dup 0)
  5833.          (const_int -1)))]
  5834.   "find_reg_note (insn, REG_NONNEG, 0)"
  5835.   "*
  5836. {
  5837.   CC_STATUS_INIT;
  5838. #ifdef MOTOROLA
  5839. #ifdef NO_ADDSUB_Q
  5840.   if (DATA_REG_P (operands[0]))
  5841.     return \"dbra %0,%l1\";
  5842.   if (GET_CODE (operands[0]) == MEM)
  5843.     return \"sub%.w %#1,%0\;jbcc %l1\";
  5844. #else
  5845.   if (DATA_REG_P (operands[0]))
  5846.     return \"dbra %0,%l1\";
  5847.   if (GET_CODE (operands[0]) == MEM)
  5848.     return \"subq%.w %#1,%0\;jbcc %l1\";
  5849. #endif
  5850. #ifdef SGS_CMP_ORDER
  5851. #ifdef NO_ADDSUB_Q
  5852.   return \"sub.w %#1,%0\;cmp.w %0,%#-1\;jbne %l1\";
  5853. #else
  5854.   return \"subq.w %#1,%0\;cmp.w %0,%#-1\;jbne %l1\";
  5855. #endif
  5856. #else /* not SGS_CMP_ORDER */
  5857.   return \"subq.w %#1,%0\;cmp.w %#-1,%0\;jbne %l1\";
  5858. #endif /* not SGS_CMP_ORDER */
  5859. #else /* not MOTOROLA */
  5860.   if (DATA_REG_P (operands[0]))
  5861.     return \"dbra %0,%l1\";
  5862.   if (GET_CODE (operands[0]) == MEM)
  5863.     return \"subqw %#1,%0\;jcc %l1\";
  5864.   return \"subqw %#1,%0\;cmpw %#-1,%0\;jne %l1\";
  5865. #endif /* not MOTOROLA */
  5866. }")
  5867.  
  5868. (define_insn "decrement_and_branch_until_zero"
  5869.   [(set (pc)
  5870.     (if_then_else
  5871.       (ge (plus:SI (match_operand:SI 0 "general_operand" "+d*am")
  5872.                (const_int -1))
  5873.           (const_int 0))
  5874.       (label_ref (match_operand 1 "" ""))
  5875.       (pc)))
  5876.    (set (match_dup 0)
  5877.     (plus:SI (match_dup 0)
  5878.          (const_int -1)))]
  5879.   "find_reg_note (insn, REG_NONNEG, 0)"
  5880.   "*
  5881. {
  5882.   CC_STATUS_INIT;
  5883. #ifdef MOTOROLA
  5884. #ifdef NO_ADDSUB_Q
  5885.   if (DATA_REG_P (operands[0]))
  5886.     return \"dbra %0,%l1\;clr%.w %0\;sub%.l %#1,%0\;jbcc %l1\";
  5887.   if (GET_CODE (operands[0]) == MEM)
  5888.     return \"sub%.l %#1,%0\;jbcc %l1\";
  5889. #else
  5890.   if (DATA_REG_P (operands[0]))
  5891.     return \"dbra %0,%l1\;clr%.w %0\;subq%.l %#1,%0\;jbcc %l1\";
  5892.   if (GET_CODE (operands[0]) == MEM)
  5893.     return \"subq%.l %#1,%0\;jbcc %l1\";
  5894. #endif
  5895. #ifdef SGS_CMP_ORDER
  5896. #ifdef NO_ADDSUB_Q
  5897.   return \"sub.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\";
  5898. #else
  5899.   return \"subq.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\";
  5900. #endif
  5901. #else /* not SGS_CMP_ORDER */
  5902.   return \"subq.l %#1,%0\;cmp.l %#-1,%0\;jbne %l1\";
  5903. #endif /* not SGS_CMP_ORDER */
  5904. #else /* not MOTOROLA */
  5905.   if (DATA_REG_P (operands[0]))
  5906.     return \"dbra %0,%l1\;clr%.w %0\;subql %#1,%0\;jcc %l1\";
  5907.   if (GET_CODE (operands[0]) == MEM)
  5908.     return \"subql %#1,%0\;jcc %l1\";
  5909.   return \"subql %#1,%0\;cmpl %#-1,%0\;jne %l1\";
  5910. #endif /* not MOTOROLA */
  5911. }")
  5912.  
  5913.  
  5914. ;; For PIC calls, in order to be able to support
  5915. ;; dynamic linker LAZY BINDING, all the procedure calls need to go 
  5916. ;; through the PLT (Procedure Linkage Table) section in PIC mode.
  5917. ;;
  5918. ;; PIC calls are handled by loading the address of the function into a 
  5919. ;; register (via movsi), then emitting a register indirect call using
  5920. ;; the "jsr" function call syntax.
  5921. ;;
  5922. ;; When outputting MIT syntax (e.g. on Suns), we add a bogus extra
  5923. ;; operand to the jbsr statement to indicate that this call should
  5924. ;; go through the PLT (why? because this is the way that Sun does it).
  5925. ;;
  5926. ;; We have different patterns for PIC calls and non-PIC calls.  The
  5927. ;; different patterns are only used to choose the right syntax.
  5928. ;;
  5929. ;; The svr4 m68k assembler recognizes this syntax: `bsr FUNC@PLTPC' and it 
  5930. ;; will create the correct relocation entry (R_68K_PLT32) for `FUNC', 
  5931. ;; that tells the linker editor to create an entry for `FUNC' in PLT
  5932. ;; section at link time. However, all global objects reference are still
  5933. ;; done by using `OBJ@GOT'. So, the goal here is to output the function 
  5934. ;; call operand as `FUNC@PLTPC', but output object operand as `OBJ@GOT'. 
  5935. ;; We need to have a way to differentiate these two different operands.
  5936. ;;
  5937. ;; The strategy I use here is to use SYMBOL_REF_FLAG to differentiate 
  5938. ;; these two different operands. The macro LEGITIMATE_PIC_OPERAND_P needs
  5939. ;; to be changed to recognize function calls symbol_ref operand as a valid 
  5940. ;; PIC operand (by checking whether SYMBOL_REF_FLAG is set). This will 
  5941. ;; avoid the compiler to load this symbol_ref operand into a register. 
  5942. ;; Remember, the operand "foo@PLTPC" cannot be called via jsr directly 
  5943. ;; since the value is a PC relative offset, not a real address.
  5944. ;;
  5945. ;; All global objects are treated in the similar way as in SUN3. The only 
  5946. ;; difference is: on m68k svr4, the reference of such global object needs 
  5947. ;; to end with a suffix "@GOT" so the assembler and linker know to create
  5948. ;; an entry for it in GOT (Global Offset Table) section. This is done in 
  5949. ;; m68k.c.
  5950.  
  5951. ;; Call subroutine with no return value.
  5952. (define_expand "call"
  5953.   [(call (match_operand:QI 0 "memory_operand" "")
  5954.      (match_operand:SI 1 "general_operand" ""))]
  5955.   ;; Operand 1 not really used on the m68000.
  5956.  
  5957.   ""
  5958.   "
  5959. {
  5960.   if (flag_pic && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
  5961. #ifdef MACHO_PIC
  5962.   { 
  5963.     extern rtx machopic_indirect_call_target();
  5964. #endif
  5965.     SYMBOL_REF_FLAG (XEXP (operands[0], 0)) = 1;
  5966. #ifdef MACHO_PIC
  5967.     operands[0] = machopic_indirect_call_target (operands[0]);
  5968.     SYMBOL_REF_FLAG (XEXP (operands[0], 0)) = 1;
  5969.   }
  5970. #endif
  5971. }")
  5972.  
  5973. ;; This is a normal call sequence.
  5974. (define_insn ""
  5975.   [(call (match_operand:QI 0 "memory_operand" "o")
  5976.      (match_operand:SI 1 "general_operand" "g"))]
  5977.   ;; Operand 1 not really used on the m68000.
  5978.  
  5979.   "! flag_pic"
  5980.   "*
  5981. #if defined (MOTOROLA) && !defined (USE_GAS)
  5982. #ifdef MOTOROLA_BSR
  5983.   if (GET_CODE (operands[0]) == MEM 
  5984.       && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
  5985.     return \"bsr %0\";
  5986. #endif
  5987.   return \"jsr %0\";
  5988. #else
  5989.   return \"jbsr %0\";
  5990. #endif
  5991. ")
  5992.  
  5993. ;; This is a PIC call sequence.
  5994. (define_insn ""
  5995.   [(call (match_operand:QI 0 "memory_operand" "o")
  5996.      (match_operand:SI 1 "general_operand" "g"))]
  5997.   ;; Operand 1 not really used on the m68000.
  5998.  
  5999.   "flag_pic"
  6000.   "*
  6001. #ifdef MACHO_PIC
  6002.   return \"jbsr %0\";
  6003. #else
  6004.   if (GET_CODE (operands[0]) == MEM 
  6005.       && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
  6006. #ifdef MOTOROLA
  6007. #ifdef HPUX_ASM
  6008.     return \"bsr.l %0\";
  6009. #else
  6010. #ifdef USE_GAS
  6011.     return \"bsr.l %0@PLTPC\";
  6012. #else
  6013.     return \"bsr %0@PLTPC\";
  6014. #endif
  6015. #endif
  6016. #else
  6017.     /* The ',a1' is a dummy argument telling the Sun assembler we want PIC,
  6018.        GAS just plain ignores it.  */
  6019.     return \"jbsr %0,a1\";
  6020. #endif
  6021.   return \"jsr %0\";
  6022. #endif
  6023. ")
  6024.  
  6025. ;; Call subroutine, returning value in operand 0
  6026. ;; (which must be a hard register).
  6027. ;; See comments before "call" regarding PIC calls.
  6028. (define_expand "call_value"
  6029.   [(set (match_operand 0 "" "")
  6030.     (call (match_operand:QI 1 "memory_operand" "")
  6031.      (match_operand:SI 2 "general_operand" "")))]
  6032.   ;; Operand 2 not really used on the m68000.
  6033.   ""
  6034.   "
  6035. {
  6036.   if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
  6037. #ifdef MACHO_PIC
  6038.   {
  6039.     extern rtx machopic_indirect_call_target();
  6040. #endif
  6041.     SYMBOL_REF_FLAG (XEXP (operands[1], 0)) = 1;
  6042. #ifdef MACHO_PIC
  6043.     operands[1] = (rtx)machopic_indirect_call_target (operands[1]);
  6044.     SYMBOL_REF_FLAG (XEXP (operands[1], 0)) = 1;
  6045.   }
  6046. #endif
  6047. }")
  6048.  
  6049. ;; This is a normal call_value
  6050. (define_insn ""
  6051.   [(set (match_operand 0 "" "=rf")
  6052.     (call (match_operand:QI 1 "memory_operand" "o")
  6053.           (match_operand:SI 2 "general_operand" "g")))]
  6054.   ;; Operand 2 not really used on the m68000.
  6055.   "! flag_pic"
  6056.   "*
  6057. #if defined (MOTOROLA) && !defined (USE_GAS)
  6058. #ifdef MOTOROLA_BSR
  6059.   if (GET_CODE (operands[1]) == MEM 
  6060.       && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
  6061.     return \"bsr %1\";
  6062. #endif
  6063.   return \"jsr %1\";
  6064. #else
  6065.   return \"jbsr %1\";
  6066. #endif
  6067. ")
  6068.  
  6069. ;; This is a PIC call_value
  6070. (define_insn ""
  6071.   [(set (match_operand 0 "" "=rf")
  6072.     (call (match_operand:QI 1 "memory_operand" "o")
  6073.           (match_operand:SI 2 "general_operand" "g")))]
  6074.   ;; Operand 2 not really used on the m68000.
  6075.   "flag_pic"
  6076.   "*
  6077. #ifdef MACHO_PIC
  6078.   return \"jbsr %1\";
  6079. #else
  6080.   if (GET_CODE (operands[1]) == MEM 
  6081.       && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
  6082. #ifdef MOTOROLA
  6083. #ifdef HPUX_ASM
  6084.     return \"bsr.l %1\";
  6085. #else
  6086. #ifdef USE_GAS
  6087.     return \"bsr.l %1@PLTPC\";
  6088. #else
  6089.     return \"bsr %1@PLTPC\";
  6090. #endif
  6091. #endif
  6092. #else
  6093.     /* The ',a1' is a dummy argument telling the Sun assembler we want PIC
  6094.        GAS just plain ignores it.  */
  6095.     return \"jbsr %1,a1\";
  6096. #endif
  6097.   return \"jsr %1\";
  6098. #endif
  6099. ")
  6100.  
  6101. ;; Call subroutine returning any type.
  6102.  
  6103. (define_expand "untyped_call"
  6104.   [(parallel [(call (match_operand 0 "" "")
  6105.             (const_int 0))
  6106.           (match_operand 1 "" "")
  6107.           (match_operand 2 "" "")])]
  6108.   "NEEDS_UNTYPED_CALL"
  6109.   "
  6110. {
  6111.   int i;
  6112.  
  6113.   emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx));
  6114.  
  6115.   for (i = 0; i < XVECLEN (operands[2], 0); i++)
  6116.     {
  6117.       rtx set = XVECEXP (operands[2], 0, i);
  6118.       emit_move_insn (SET_DEST (set), SET_SRC (set));
  6119.     }
  6120.  
  6121.   /* The optimizer does not know that the call sets the function value
  6122.      registers we stored in the result block.  We avoid problems by
  6123.      claiming that all hard registers are used and clobbered at this
  6124.      point.  */
  6125.   emit_insn (gen_blockage ());
  6126.  
  6127.   DONE;
  6128. }")
  6129.  
  6130. ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
  6131. ;; all of memory.  This blocks insns from being moved across this point.
  6132.  
  6133. (define_insn "blockage"
  6134.   [(unspec_volatile [(const_int 0)] 0)]
  6135.   ""
  6136.   "")
  6137.  
  6138. (define_insn "nop"
  6139.   [(const_int 0)]
  6140.   ""
  6141.   "nop")
  6142.  
  6143. (define_insn "probe"
  6144.  [(reg:SI 15)]
  6145.  "NEED_PROBE"
  6146.  "*
  6147. {
  6148.   operands[0] = gen_rtx (PLUS, SImode, stack_pointer_rtx,
  6149.              gen_rtx (CONST_INT, VOIDmode, NEED_PROBE));
  6150.   return \"tstl %a0\";
  6151. }")
  6152.  
  6153. ;; Used for frameless functions which save no regs and allocate no locals.
  6154. (define_insn "return"
  6155.   [(return)]
  6156.   "USE_RETURN_INSN"
  6157.   "*
  6158. {
  6159.   if (current_function_pops_args == 0)
  6160.     return \"rts\";
  6161.   operands[0] = gen_rtx (CONST_INT, VOIDmode, current_function_pops_args);
  6162.   return \"rtd %0\";
  6163. }")
  6164.  
  6165. (define_insn "indirect_jump"
  6166.   [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
  6167.   ""
  6168.   "jmp %a0")
  6169.  
  6170. ;; This should not be used unless the add/sub insns can't be.
  6171.  
  6172. (define_insn ""
  6173.   [(set (match_operand:SI 0 "general_operand" "=a")
  6174.     (match_operand:QI 1 "address_operand" "p"))]
  6175.   ""
  6176.   "*
  6177. {
  6178. #ifndef SGS_NO_LI
  6179.   /* Recognize an insn that refers to a table of offsets.  Such an insn will
  6180.      need to refer to a label on the insn.  So output one.  Use the
  6181.      label-number of the table of offsets to generate this label.  This code,
  6182.      and similar code above, assumes that there will be at most one reference
  6183.      to each table.  */
  6184.   if (GET_CODE (operands[1]) == PLUS
  6185.       && GET_CODE (XEXP (operands[1], 1)) == LABEL_REF
  6186.       && GET_CODE (XEXP (operands[1], 0)) != PLUS)
  6187.     {
  6188.       rtx labelref = XEXP (operands[1], 1);
  6189. #if defined (MOTOROLA) && !defined (SGS_SWITCH_TABLES)
  6190. #ifdef SGS
  6191.       asm_fprintf (asm_out_file, \"\\tset %LLI%d,.+2\\n\",
  6192.            CODE_LABEL_NUMBER (XEXP (labelref, 0)));
  6193. #else /* not SGS */
  6194.       asm_fprintf (asm_out_file, \"\\t.set %LLI%d,.+2\\n\",
  6195.                CODE_LABEL_NUMBER (XEXP (labelref, 0)));
  6196. #endif /* not SGS */
  6197. #else /* SGS_SWITCH_TABLES or not MOTOROLA */
  6198.       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"LI\",
  6199.                  CODE_LABEL_NUMBER (XEXP (labelref, 0)));
  6200. #ifdef SGS_SWITCH_TABLES
  6201.       /* Set flag saying we need to define the symbol
  6202.      LD%n (with value L%n-LI%n) at the end of the switch table.  */
  6203.       switch_table_difference_label_flag = 1;
  6204. #endif /* SGS_SWITCH_TABLES */
  6205. #endif /* SGS_SWITCH_TABLES or not MOTOROLA */
  6206.     }
  6207. #endif /* SGS_NO_LI */
  6208.  
  6209.   return \"lea %a1,%0\";
  6210. }")
  6211.  
  6212. ;; This is the first machine-dependent peephole optimization.
  6213. ;; It is useful when a floating value is returned from a function call
  6214. ;; and then is moved into an FP register.
  6215. ;; But it is mainly intended to test the support for these optimizations.
  6216.  
  6217. (define_peephole
  6218.   [(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int 4)))
  6219.    (set (match_operand:DF 0 "register_operand" "=f")
  6220.     (match_operand:DF 1 "register_operand" "ad"))]
  6221.   "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
  6222.   "*
  6223. {
  6224.   rtx xoperands[2];
  6225.   xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  6226.   output_asm_insn (\"move%.l %1,%@\", xoperands);
  6227.   output_asm_insn (\"move%.l %1,%-\", operands);
  6228.   return \"fmove%.d %+,%0\";
  6229. }
  6230. ")
  6231.  
  6232. ;; Optimize a stack-adjust followed by a push of an argument.
  6233. ;; This is said to happen frequently with -msoft-float
  6234. ;; when there are consecutive library calls.
  6235.  
  6236. (define_peephole
  6237.   [(set (reg:SI 15) (plus:SI (reg:SI 15)
  6238.                  (match_operand:SI 0 "const_int_operand" "n")))
  6239.    (set (match_operand:SF 1 "push_operand" "=m")
  6240.     (match_operand:SF 2 "general_operand" "rmfF"))]
  6241.   "INTVAL (operands[0]) >= 4
  6242.    && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
  6243.   "*
  6244. {
  6245.   if (INTVAL (operands[0]) > 4)
  6246.     {
  6247.       rtx xoperands[2];
  6248.       xoperands[0] = stack_pointer_rtx;
  6249.       xoperands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[0]) - 4);
  6250. #ifndef NO_ADDSUB_Q
  6251.       if (INTVAL (xoperands[1]) <= 8)
  6252.         output_asm_insn (\"addq%.w %1,%0\", xoperands);
  6253.       else if (INTVAL (xoperands[1]) <= 16 && TARGET_68020)
  6254.     {
  6255.       xoperands[1] = gen_rtx (CONST_INT, VOIDmode, 
  6256.                   INTVAL (xoperands[1]) - 8);
  6257.       output_asm_insn (\"addq%.w %#8,%0\;addq%.w %1,%0\", xoperands);
  6258.     }
  6259.       else
  6260. #endif
  6261.         if (INTVAL (xoperands[1]) <= 0x7FFF)
  6262.           output_asm_insn (\"add%.w %1,%0\", xoperands);
  6263.       else
  6264.         output_asm_insn (\"add%.l %1,%0\", xoperands);
  6265.     }
  6266.   if (FP_REG_P (operands[2]))
  6267.     return \"fmove%.s %2,%@\";
  6268.   return \"move%.l %2,%@\";
  6269. }")
  6270.  
  6271. ;; Speed up stack adjust followed by a fullword fixedpoint push.
  6272.  
  6273. (define_peephole
  6274.   [(set (reg:SI 15) (plus:SI (reg:SI 15)
  6275.                  (match_operand:SI 0 "const_int_operand" "n")))
  6276.    (set (match_operand:SI 1 "push_operand" "=m")
  6277.     (match_operand:SI 2 "general_operand" "g"))]
  6278.   "INTVAL (operands[0]) >= 4
  6279.    && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
  6280.   "*
  6281. {
  6282.   if (INTVAL (operands[0]) > 4)
  6283.     {
  6284.       rtx xoperands[2];
  6285.       xoperands[0] = stack_pointer_rtx;
  6286.       xoperands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[0]) - 4);
  6287. #ifndef NO_ADDSUB_Q
  6288.       if (INTVAL (xoperands[1]) <= 8)
  6289.         output_asm_insn (\"addq%.w %1,%0\", xoperands);
  6290.       else if (INTVAL (xoperands[1]) <= 16 && TARGET_68020)
  6291.     {
  6292.       xoperands[1] = gen_rtx (CONST_INT, VOIDmode, 
  6293.                   INTVAL (xoperands[1]) - 8);
  6294.       output_asm_insn (\"addq%.w %#8,%0\;addq%.w %1,%0\", xoperands);
  6295.     }
  6296.       else
  6297. #endif
  6298.         if (INTVAL (xoperands[1]) <= 0x7FFF)
  6299.           output_asm_insn (\"add%.w %1,%0\", xoperands);
  6300.       else
  6301.         output_asm_insn (\"add%.l %1,%0\", xoperands);
  6302.     }
  6303.   if (operands[2] == const0_rtx)
  6304.     return \"clr%.l %@\";
  6305.   return \"move%.l %2,%@\";
  6306. }")
  6307.  
  6308. ;; Speed up pushing a single byte but leaving four bytes of space.
  6309.  
  6310. (define_peephole
  6311.   [(set (mem:QI (pre_dec:SI (reg:SI 15)))
  6312.     (match_operand:QI 1 "general_operand" "dami"))
  6313.    (set (reg:SI 15) (minus:SI (reg:SI 15) (const_int 2)))]
  6314.   "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
  6315.   "*
  6316. {
  6317.   rtx xoperands[4];
  6318.  
  6319.   if (GET_CODE (operands[1]) == REG)
  6320.     return \"move%.l %1,%-\";
  6321.  
  6322.   xoperands[1] = operands[1];
  6323.   xoperands[2]
  6324.     = gen_rtx (MEM, QImode,
  6325.            gen_rtx (PLUS, VOIDmode, stack_pointer_rtx,
  6326.             gen_rtx (CONST_INT, VOIDmode, 3)));
  6327.   xoperands[3] = stack_pointer_rtx;
  6328.   output_asm_insn (\"subq%.w %#4,%3\;move%.b %1,%2\", xoperands);
  6329.   return \"\";
  6330. }")
  6331.  
  6332. (define_peephole
  6333.   [(set (match_operand:SI 0 "register_operand" "=d")
  6334.     (const_int 0))
  6335.    (set (strict_low_part (subreg:HI (match_dup 0) 0))
  6336.     (match_operand:HI 1 "general_operand" "rmn"))]
  6337.   "strict_low_part_peephole_ok (HImode, prev_nonnote_insn (insn), operands[0])"
  6338.   "*
  6339. {
  6340.   if (GET_CODE (operands[1]) == CONST_INT)
  6341.     {
  6342.       if (operands[1] == const0_rtx
  6343.       && (DATA_REG_P (operands[0])
  6344.           || GET_CODE (operands[0]) == MEM)
  6345.       /* clr insns on 68000 read before writing.
  6346.          This isn't so on the 68010, but we have no alternative for it.  */
  6347.       && (TARGET_68020
  6348.           || !(GET_CODE (operands[0]) == MEM
  6349.            && MEM_VOLATILE_P (operands[0]))))
  6350.     return \"clr%.w %0\";
  6351.     }
  6352.   return \"move%.w %1,%0\";
  6353. }")
  6354.  
  6355. ;; dbCC peepholes
  6356. ;;
  6357. ;; Turns
  6358. ;;   loop:
  6359. ;;           [ ... ]
  6360. ;;           jCC label        ; abnormal loop termination
  6361. ;;           dbra dN, loop    ; normal loop termination
  6362. ;;
  6363. ;; Into
  6364. ;;   loop:
  6365. ;;           [ ... ]
  6366. ;;           dbCC dN, loop
  6367. ;;           jCC label
  6368. ;;
  6369. ;; Which moves the jCC condition outside the inner loop for free.
  6370. ;;
  6371. (define_peephole
  6372.   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
  6373.                              [(cc0) (const_int 0)])
  6374.                            (label_ref (match_operand 2 "" ""))
  6375.                            (pc)))
  6376.    (parallel
  6377.     [(set (pc)
  6378.       (if_then_else
  6379.         (ge (plus:HI (match_operand:HI 0 "register_operand" "+d")
  6380.                  (const_int -1))
  6381.             (const_int 0))
  6382.         (label_ref (match_operand 1 "" ""))
  6383.         (pc)))
  6384.      (set (match_dup 0)
  6385.       (plus:HI (match_dup 0)
  6386.            (const_int -1)))])]
  6387.   "DATA_REG_P (operands[0])"
  6388.   "*
  6389. {
  6390.   CC_STATUS_INIT;
  6391.   output_dbcc_and_branch (operands);
  6392.   return \"\";
  6393. }")
  6394.  
  6395. (define_peephole
  6396.   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
  6397.                              [(cc0) (const_int 0)])
  6398.                            (label_ref (match_operand 2 "" ""))
  6399.                            (pc)))
  6400.    (parallel
  6401.     [(set (pc)
  6402.       (if_then_else
  6403.         (ge (plus:SI (match_operand:SI 0 "register_operand" "+d")
  6404.                  (const_int -1))
  6405.             (const_int 0))
  6406.         (label_ref (match_operand 1 "" ""))
  6407.         (pc)))
  6408.      (set (match_dup 0)
  6409.       (plus:SI (match_dup 0)
  6410.            (const_int -1)))])]
  6411.   "DATA_REG_P (operands[0])"
  6412.   "*
  6413. {
  6414.   CC_STATUS_INIT;
  6415.   output_dbcc_and_branch (operands);
  6416.   return \"\";
  6417. }")
  6418.  
  6419.  
  6420. ;; FPA multiply and add.
  6421. (define_insn ""
  6422.   [(set (match_operand:DF 0 "register_operand" "=x,y,y")
  6423.     (plus:DF (mult:DF (match_operand:DF 1 "general_operand" "%x,dmF,y")
  6424.               (match_operand:DF 2 "general_operand" "xH,y,y"))
  6425.          (match_operand:DF 3 "general_operand" "xH,y,dmF")))]
  6426.    "TARGET_FPA"
  6427.    "@
  6428.     fpma%.d %1,%w2,%w3,%0
  6429.     fpma%.d %x1,%x2,%x3,%0
  6430.     fpma%.d %x1,%x2,%x3,%0")
  6431.  
  6432. (define_insn ""
  6433.   [(set (match_operand:SF 0 "register_operand" "=x,y,y")
  6434.     (plus:SF (mult:SF (match_operand:SF 1 "general_operand" "%x,ydmF,y")
  6435.               (match_operand:SF 2 "general_operand" "xH,y,ydmF"))
  6436.          (match_operand:SF 3 "general_operand" "xH,ydmF,ydmF")))]
  6437.    "TARGET_FPA"
  6438.    "@
  6439.     fpma%.s %1,%w2,%w3,%0
  6440.     fpma%.s %1,%2,%3,%0
  6441.     fpma%.s %1,%2,%3,%0")
  6442.  
  6443. ;; FPA Multiply and subtract
  6444. (define_insn ""
  6445.   [(set (match_operand:DF 0 "register_operand" "=x,y,y")
  6446.     (minus:DF (match_operand:DF 1 "general_operand" "xH,rmF,y")
  6447.           (mult:DF (match_operand:DF 2 "general_operand" "%xH,y,y")
  6448.                (match_operand:DF 3 "general_operand" "x,y,rmF"))))]
  6449.   "TARGET_FPA"
  6450.   "@
  6451.    fpms%.d %3,%w2,%w1,%0
  6452.    fpms%.d %x3,%2,%x1,%0
  6453.    fpms%.d %x3,%2,%x1,%0")
  6454.  
  6455. (define_insn ""
  6456.   [(set (match_operand:SF 0 "register_operand" "=x,y,y")
  6457.     (minus:SF (match_operand:SF 1 "general_operand" "xH,rmF,yrmF")
  6458.           (mult:SF (match_operand:SF 2 "general_operand" "%xH,rmF,y")
  6459.                (match_operand:SF 3 "general_operand" "x,y,yrmF"))))]
  6460.   "TARGET_FPA"
  6461.   "@
  6462.    fpms%.s %3,%w2,%w1,%0
  6463.    fpms%.s %3,%2,%1,%0
  6464.    fpms%.s %3,%2,%1,%0")
  6465.  
  6466. (define_insn ""
  6467.   [(set (match_operand:DF 0 "register_operand" "=x,y,y")
  6468.     (minus:DF (mult:DF (match_operand:DF 1 "general_operand" "%xH,y,y")
  6469.                (match_operand:DF 2 "general_operand" "x,y,rmF"))
  6470.           (match_operand:DF 3 "general_operand" "xH,rmF,y")))]
  6471.   "TARGET_FPA"
  6472.   "@
  6473.    fpmr%.d %2,%w1,%w3,%0
  6474.    fpmr%.d %x2,%1,%x3,%0
  6475.    fpmr%.d %x2,%1,%x3,%0")
  6476.  
  6477. (define_insn ""
  6478.   [(set (match_operand:SF 0 "register_operand" "=x,y,y")
  6479.     (minus:SF (mult:SF (match_operand:SF 1 "general_operand" "%xH,rmF,y")
  6480.                (match_operand:SF 2 "general_operand" "x,y,yrmF"))
  6481.           (match_operand:SF 3 "general_operand" "xH,rmF,yrmF")))]
  6482.   "TARGET_FPA"
  6483.   "@
  6484.    fpmr%.s %2,%w1,%w3,%0
  6485.    fpmr%.s %x2,%1,%x3,%0
  6486.    fpmr%.s %x2,%1,%x3,%0")
  6487.  
  6488. ;; FPA Add and multiply
  6489. (define_insn ""
  6490.   [(set (match_operand:DF 0 "register_operand" "=x,y,y")
  6491.     (mult:DF (plus:DF (match_operand:DF 1 "general_operand" "%xH,y,y")
  6492.               (match_operand:DF 2 "general_operand" "x,y,rmF"))
  6493.          (match_operand:DF 3 "general_operand" "xH,rmF,y")))]
  6494.   "TARGET_FPA"
  6495.   "@
  6496.    fpam%.d %2,%w1,%w3,%0
  6497.    fpam%.d %x2,%1,%x3,%0
  6498.    fpam%.d %x2,%1,%x3,%0")
  6499.  
  6500. (define_insn ""
  6501.   [(set (match_operand:SF 0 "register_operand" "=x,y,y")
  6502.     (mult:SF (plus:SF (match_operand:SF 1 "general_operand" "%xH,rmF,y")
  6503.               (match_operand:SF 2 "general_operand" "x,y,yrmF"))
  6504.          (match_operand:SF 3 "general_operand" "xH,rmF,yrmF")))]
  6505.   "TARGET_FPA"
  6506.   "@
  6507.    fpam%.s %2,%w1,%w3,%0
  6508.    fpam%.s %x2,%1,%x3,%0
  6509.    fpam%.s %x2,%1,%x3,%0")
  6510.  
  6511. ;;FPA Subtract and multiply
  6512. (define_insn ""
  6513.   [(set (match_operand:DF 0 "register_operand" "=x,y,y")
  6514.     (mult:DF (minus:DF (match_operand:DF 1 "general_operand" "xH,y,y")
  6515.                (match_operand:DF 2 "general_operand" "x,y,rmF"))
  6516.          (match_operand:DF 3 "general_operand" "xH,rmF,y")))]
  6517.   "TARGET_FPA"
  6518.   "@
  6519.    fpsm%.d %2,%w1,%w3,%0
  6520.    fpsm%.d %x2,%1,%x3,%0
  6521.    fpsm%.d %x2,%1,%x3,%0")
  6522.  
  6523. (define_insn ""
  6524.   [(set (match_operand:DF 0 "register_operand" "=x,y,y")
  6525.     (mult:DF (match_operand:DF 1 "general_operand" "xH,rmF,y")
  6526.          (minus:DF (match_operand:DF 2 "general_operand" "xH,y,y")
  6527.                (match_operand:DF 3 "general_operand" "x,y,rmF"))))]
  6528.   "TARGET_FPA"
  6529.   "@
  6530.    fpsm%.d %3,%w2,%w1,%0
  6531.    fpsm%.d %x3,%2,%x1,%0
  6532.    fpsm%.d %x3,%2,%x1,%0")
  6533.  
  6534. (define_insn ""
  6535.   [(set (match_operand:SF 0 "register_operand" "=x,y,y")
  6536.     (mult:SF (minus:SF (match_operand:SF 1 "general_operand" "xH,rmF,y")
  6537.                (match_operand:SF 2 "general_operand" "x,y,yrmF"))
  6538.          (match_operand:SF 3 "general_operand" "xH,rmF,yrmF")))]
  6539.   "TARGET_FPA"
  6540.   "@
  6541.    fpsm%.s %2,%w1,%w3,%0
  6542.    fpsm%.s %x2,%1,%x3,%0
  6543.    fpsm%.s %x2,%1,%x3,%0")
  6544.  
  6545. (define_insn ""
  6546.   [(set (match_operand:SF 0 "register_operand" "=x,y,y")
  6547.     (mult:SF (match_operand:SF 1 "general_operand" "xH,rmF,yrmF")
  6548.          (minus:SF (match_operand:SF 2 "general_operand" "xH,rmF,y")
  6549.                (match_operand:SF 3 "general_operand" "x,y,yrmF"))))]
  6550.   "TARGET_FPA"
  6551.   "@
  6552.    fpsm%.s %3,%w2,%w1,%0
  6553.    fpsm%.s %x3,%2,%x1,%0
  6554.    fpsm%.s %x3,%2,%x1,%0")
  6555.  
  6556. (define_insn "tstxf"
  6557.   [(set (cc0)
  6558.     (match_operand:XF 0 "nonimmediate_operand" "fm"))]
  6559.   "TARGET_68881"
  6560.   "*
  6561. {
  6562.   cc_status.flags = CC_IN_68881;
  6563.   return \"ftst%.x %0\";
  6564. }")
  6565.  
  6566.  
  6567. (define_expand "cmpxf"
  6568.   [(set (cc0)
  6569.     (compare (match_operand:XF 0 "general_operand" "f,m")
  6570.          (match_operand:XF 1 "general_operand" "fm,f")))]
  6571.   "TARGET_68881"
  6572.   "
  6573. {
  6574. #ifdef MACHO_PIC
  6575.   extern rtx machopic_indirect_data_reference();
  6576.   rtx reg = reload_in_progress ? 0 : gen_reg_rtx (Pmode);
  6577. #endif
  6578.  
  6579.   if (CONSTANT_P (operands[0]))
  6580.     {
  6581.       operands[0] = force_const_mem (XFmode, operands[0]);
  6582. #ifdef MACHO_PIC
  6583.       operands[0] = machopic_indirect_data_reference (operands[0], reg);
  6584. #endif
  6585.     }
  6586.   if (CONSTANT_P (operands[1]))
  6587.     {
  6588.       operands[1] = force_const_mem (XFmode, operands[1]);
  6589. #ifdef MACHO_PIC
  6590.       operands[1] = machopic_indirect_data_reference (operands[1], reg);
  6591. #endif
  6592.     }
  6593. }")
  6594.  
  6595. (define_insn ""
  6596.   [(set (cc0)
  6597.     (compare (match_operand:XF 0 "nonimmediate_operand" "f,m")
  6598.          (match_operand:XF 1 "nonimmediate_operand" "fm,f")))]
  6599.   "TARGET_68881"
  6600.   "*
  6601. {
  6602.   cc_status.flags = CC_IN_68881;
  6603. #ifdef SGS_CMP_ORDER
  6604.   if (REG_P (operands[0]))
  6605.     {
  6606.       if (REG_P (operands[1]))
  6607.     return \"fcmp%.x %0,%1\";
  6608.       else
  6609.         return \"fcmp%.x %0,%f1\";
  6610.     }
  6611.   cc_status.flags |= CC_REVERSED;
  6612.   return \"fcmp%.x %1,%f0\";
  6613. #else
  6614.   if (REG_P (operands[0]))
  6615.     {
  6616.       if (REG_P (operands[1]))
  6617.     return \"fcmp%.x %1,%0\";
  6618.       else
  6619.         return \"fcmp%.x %f1,%0\";
  6620.     }
  6621.   cc_status.flags |= CC_REVERSED;
  6622.   return \"fcmp%.x %f0,%1\";
  6623. #endif
  6624. }")
  6625.  
  6626. (define_insn "extendsfxf2"
  6627.   [(set (match_operand:XF 0 "general_operand" "=fm,f")
  6628.     (float_extend:XF (match_operand:SF 1 "general_operand" "f,m")))]
  6629.   "TARGET_68881"
  6630.   "*
  6631. {
  6632.   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
  6633.     {
  6634.       if (REGNO (operands[0]) == REGNO (operands[1]))
  6635.     {
  6636.       /* Extending float to double in an fp-reg is a no-op.
  6637.          NOTICE_UPDATE_CC has already assumed that the
  6638.          cc will be set.  So cancel what it did.  */
  6639.       cc_status = cc_prev_status;
  6640.       return \"\";
  6641.     }
  6642.       return \"f%$move%.x %1,%0\";
  6643.     }
  6644.   if (FP_REG_P (operands[0]))
  6645.     return \"f%$move%.s %f1,%0\";
  6646.   return \"fmove%.x %f1,%0\";
  6647. }")
  6648.  
  6649.  
  6650. (define_insn "extenddfxf2"
  6651.   [(set (match_operand:XF 0 "general_operand" "=fm,f")
  6652.     (float_extend:XF
  6653.           (match_operand:DF 1 "general_operand" "f,m")))]
  6654.   "TARGET_68881"
  6655.   "*
  6656. {
  6657.   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
  6658.     {
  6659.       if (REGNO (operands[0]) == REGNO (operands[1]))
  6660.     {
  6661.       /* Extending float to double in an fp-reg is a no-op.
  6662.          NOTICE_UPDATE_CC has already assumed that the
  6663.          cc will be set.  So cancel what it did.  */
  6664.       cc_status = cc_prev_status;
  6665.       return \"\";
  6666.     }
  6667.       return \"fmove%.x %1,%0\";
  6668.     }
  6669.   if (FP_REG_P (operands[0]))
  6670.     return \"f%&move%.d %f1,%0\";
  6671.   return \"fmove%.x %f1,%0\";
  6672. }")
  6673.  
  6674. (define_insn "truncxfdf2"
  6675.   [(set (match_operand:DF 0 "general_operand" "=m,!r")
  6676.     (float_truncate:DF
  6677.           (match_operand:XF 1 "general_operand" "f,f")))]
  6678.   "TARGET_68881"
  6679.   "*
  6680. {
  6681.   if (REG_P (operands[0]))
  6682.     {
  6683.       output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands);
  6684.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  6685.       return \"move%.l %+,%0\";
  6686.     }
  6687.   return \"fmove%.d %f1,%0\";
  6688. }")
  6689.  
  6690. (define_insn "truncxfsf2"
  6691.   [(set (match_operand:SF 0 "general_operand" "=dm")
  6692.     (float_truncate:SF
  6693.       (match_operand:XF 1 "general_operand" "f")))]
  6694.   "TARGET_68881"
  6695.   "fmove%.s %f1,%0")
  6696.  
  6697. (define_insn "floatsixf2"
  6698.   [(set (match_operand:XF 0 "general_operand" "=f")
  6699.     (float:XF (match_operand:SI 1 "general_operand" "dmi")))]
  6700.   "TARGET_68881"
  6701.   "fmove%.l %1,%0")
  6702.  
  6703. (define_insn "floathixf2"
  6704.   [(set (match_operand:XF 0 "general_operand" "=f")
  6705.     (float:XF (match_operand:HI 1 "general_operand" "dmn")))]
  6706.   "TARGET_68881"
  6707.   "fmove%.w %1,%0")
  6708.  
  6709. (define_insn "floatqixf2"
  6710.   [(set (match_operand:XF 0 "general_operand" "=f")
  6711.     (float:XF (match_operand:QI 1 "general_operand" "dmn")))]
  6712.   "TARGET_68881"
  6713.   "fmove%.b %1,%0")
  6714.  
  6715. (define_insn "ftruncxf2"
  6716.   [(set (match_operand:XF 0 "general_operand" "=f")
  6717.     (fix:XF (match_operand:XF 1 "general_operand" "fFm")))]
  6718.   "TARGET_68881"
  6719.   "*
  6720. {
  6721.   if (FP_REG_P (operands[1]))
  6722.     return \"fintrz%.x %f1,%0\";
  6723.   return \"fintrz%.x %f1,%0\";
  6724. }")
  6725.  
  6726. (define_insn "fixxfqi2"
  6727.   [(set (match_operand:QI 0 "general_operand" "=dm")
  6728.     (fix:QI (match_operand:XF 1 "general_operand" "f")))]
  6729.   "TARGET_68881"
  6730.   "fmove%.b %1,%0")
  6731.  
  6732. (define_insn "fixxfhi2"
  6733.   [(set (match_operand:HI 0 "general_operand" "=dm")
  6734.     (fix:HI (match_operand:XF 1 "general_operand" "f")))]
  6735.   "TARGET_68881"
  6736.   "fmove%.w %1,%0")
  6737.  
  6738. (define_insn "fixxfsi2"
  6739.   [(set (match_operand:SI 0 "general_operand" "=dm")
  6740.     (fix:SI (match_operand:XF 1 "general_operand" "f")))]
  6741.   "TARGET_68881"
  6742.   "fmove%.l %1,%0")
  6743.  
  6744. (define_expand "addxf3"
  6745.   [(set (match_operand:XF 0 "general_operand" "")
  6746.     (plus:XF (match_operand:XF 1 "general_operand" "")
  6747.          (match_operand:XF 2 "general_operand" "")))]
  6748.   "TARGET_68881"
  6749.   "
  6750. {
  6751. #ifdef MACHO_PIC
  6752.   extern rtx machopic_indirect_data_reference();
  6753.   rtx reg = reload_in_progress ? 0 : gen_reg_rtx (Pmode);
  6754. #endif
  6755.  
  6756.   if (CONSTANT_P (operands[1]))
  6757.     {
  6758.       operands[1] = force_const_mem (XFmode, operands[1]);
  6759. #ifdef MACHO_PIC
  6760.       operands[1] = machopic_indirect_data_reference (operands[1], reg);
  6761. #endif
  6762.     }
  6763.   if (CONSTANT_P (operands[2]))
  6764.     {
  6765.       operands[2] = force_const_mem (XFmode, operands[2]);
  6766. #ifdef MACHO_PIC
  6767.       operands[2] = machopic_indirect_data_reference (operands[2], reg);
  6768. #endif
  6769.     }
  6770. }")
  6771.  
  6772. (define_insn ""
  6773.   [(set (match_operand:XF 0 "general_operand" "=f")
  6774.     (plus:XF (float:XF (match_operand:SI 2 "general_operand" "dmi"))
  6775.          (match_operand:XF 1 "nonimmediate_operand" "0")))]
  6776.   "TARGET_68881"
  6777.   "fadd%.l %2,%0")
  6778.  
  6779. (define_insn ""
  6780.   [(set (match_operand:XF 0 "general_operand" "=f")
  6781.     (plus:XF (float:XF (match_operand:HI 2 "general_operand" "dmn"))
  6782.          (match_operand:XF 1 "nonimmediate_operand" "0")))]
  6783.   "TARGET_68881"
  6784.   "fadd%.w %2,%0")
  6785.  
  6786. (define_insn ""
  6787.   [(set (match_operand:XF 0 "general_operand" "=f")
  6788.     (plus:XF (float:XF (match_operand:QI 2 "general_operand" "dmn"))
  6789.          (match_operand:XF 1 "general_operand" "0")))]
  6790.   "TARGET_68881"
  6791.   "fadd%.b %2,%0")
  6792.  
  6793. (define_insn ""
  6794.   [(set (match_operand:XF 0 "general_operand" "=f")
  6795.     (plus:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
  6796.          (match_operand:XF 2 "nonimmediate_operand" "fm")))]
  6797.   "TARGET_68881"
  6798.   "*
  6799. {
  6800.   if (REG_P (operands[2]))
  6801.     return \"fadd%.x %2,%0\";
  6802.   return \"fadd%.x %f2,%0\";
  6803. }")
  6804.  
  6805. (define_expand "subxf3"
  6806.   [(set (match_operand:XF 0 "general_operand" "")
  6807.     (minus:XF (match_operand:XF 1 "general_operand" "")
  6808.          (match_operand:XF 2 "general_operand" "")))]
  6809.   "TARGET_68881"
  6810.   "
  6811. {
  6812. #ifdef MACHO_PIC
  6813.   extern rtx machopic_indirect_data_reference();
  6814.   rtx reg = reload_in_progress ? 0 : gen_reg_rtx (Pmode);
  6815. #endif
  6816.  
  6817.   if (CONSTANT_P (operands[1]))
  6818.     {
  6819.       operands[1] = force_const_mem (XFmode, operands[1]);
  6820. #ifdef MACHO_PIC
  6821.       operands[1] = machopic_indirect_data_reference (operands[1], reg);
  6822. #endif
  6823.     }
  6824.   if (CONSTANT_P (operands[2]))
  6825.     {
  6826.       operands[2] = force_const_mem (XFmode, operands[2]);
  6827. #ifdef MACHO_PIC
  6828.       operands[2] = machopic_indirect_data_reference (operands[2], reg);
  6829. #endif
  6830.     }
  6831. }")
  6832.  
  6833. (define_insn ""
  6834.   [(set (match_operand:XF 0 "general_operand" "=f")
  6835.     (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
  6836.           (float:XF (match_operand:SI 2 "general_operand" "dmi"))))]
  6837.   "TARGET_68881"
  6838.   "fsub%.l %2,%0")
  6839.  
  6840. (define_insn ""
  6841.   [(set (match_operand:XF 0 "general_operand" "=f")
  6842.     (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
  6843.           (float:XF (match_operand:HI 2 "general_operand" "dmn"))))]
  6844.   "TARGET_68881"
  6845.   "fsub%.w %2,%0")
  6846.  
  6847. (define_insn ""
  6848.   [(set (match_operand:XF 0 "general_operand" "=f")
  6849.     (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
  6850.           (float:XF (match_operand:QI 2 "general_operand" "dmn"))))]
  6851.   "TARGET_68881"
  6852.   "fsub%.b %2,%0")
  6853.  
  6854. (define_insn ""
  6855.   [(set (match_operand:XF 0 "general_operand" "=f")
  6856.     (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
  6857.           (match_operand:XF 2 "nonimmediate_operand" "fm")))]
  6858.   "TARGET_68881"
  6859.   "*
  6860. {
  6861.   if (REG_P (operands[2]))
  6862.     return \"fsub%.x %2,%0\";
  6863.   return \"fsub%.x %f2,%0\";
  6864. }")
  6865.  
  6866. (define_expand "mulxf3"
  6867.   [(set (match_operand:XF 0 "general_operand" "")
  6868.     (mult:XF (match_operand:XF 1 "general_operand" "")
  6869.         (match_operand:XF 2 "general_operand" "")))]
  6870.   "TARGET_68881"
  6871.   "
  6872. {
  6873. #ifdef MACHO_PIC
  6874.   extern rtx machopic_indirect_data_reference();
  6875.   rtx reg = reload_in_progress ? 0 : gen_reg_rtx (Pmode);
  6876. #endif
  6877.  
  6878.   if (CONSTANT_P (operands[1]))
  6879.     {    
  6880.       operands[1] = force_const_mem (XFmode, operands[1]);
  6881. #ifdef MACHO_PIC
  6882.       operands[1] = machopic_indirect_data_reference (operands[1], reg);
  6883. #endif
  6884.     }
  6885.   if (CONSTANT_P (operands[2]))
  6886.     {
  6887.       operands[2] = force_const_mem (XFmode, operands[2]);
  6888. #ifdef MACHO_PIC
  6889.       operands[2] = machopic_indirect_data_reference (operands[2], reg);
  6890. #endif
  6891.     }
  6892. }")
  6893.  
  6894. (define_insn ""
  6895.   [(set (match_operand:XF 0 "general_operand" "=f")
  6896.     (mult:XF (float:XF (match_operand:SI 2 "general_operand" "dmi"))
  6897.          (match_operand:XF 1 "nonimmediate_operand" "0")))]
  6898.   "TARGET_68881"
  6899.   "fmul%.l %2,%0")
  6900.  
  6901. (define_insn ""
  6902.   [(set (match_operand:XF 0 "general_operand" "=f")
  6903.     (mult:XF (float:XF (match_operand:HI 2 "general_operand" "dmn"))
  6904.          (match_operand:XF 1 "nonimmediate_operand" "0")))]
  6905.   "TARGET_68881"
  6906.   "fmul%.w %2,%0")
  6907.  
  6908. (define_insn ""
  6909.   [(set (match_operand:XF 0 "general_operand" "=f")
  6910.     (mult:XF (float:XF (match_operand:QI 2 "general_operand" "dmn"))
  6911.          (match_operand:XF 1 "nonimmediate_operand" "0")))]
  6912.   "TARGET_68881"
  6913.   "fmul%.b %2,%0")
  6914.  
  6915. (define_insn ""
  6916.   [(set (match_operand:XF 0 "general_operand" "=f")
  6917.     (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
  6918.          (match_operand:XF 2 "nonimmediate_operand" "fm")))]
  6919.   "TARGET_68881"
  6920.   "*
  6921. {
  6922.   if (REG_P (operands[2]))
  6923.     return \"fmul%.x %2,%0\";
  6924.   return \"fmul%.x %f2,%0\";
  6925. }")
  6926.  
  6927. (define_expand "divxf3"
  6928.   [(set (match_operand:XF 0 "general_operand" "")
  6929.     (div:XF (match_operand:XF 1 "general_operand" "")
  6930.         (match_operand:XF 2 "general_operand" "")))]
  6931.   "TARGET_68881"
  6932.   "
  6933. {
  6934. #ifdef MACHO_PIC
  6935.   extern rtx machopic_indirect_data_reference();
  6936.   rtx reg = reload_in_progress ? 0 : gen_reg_rtx (Pmode);
  6937. #endif
  6938.  
  6939.   if (CONSTANT_P (operands[1]))
  6940.     {    
  6941.       operands[1] = force_const_mem (XFmode, operands[1]);
  6942. #ifdef MACHO_PIC
  6943.       operands[1] = machopic_indirect_data_reference (operands[1], reg);
  6944. #endif
  6945.     }
  6946.   if (CONSTANT_P (operands[2]))
  6947.     {
  6948.       operands[2] = force_const_mem (XFmode, operands[2]);
  6949. #ifdef MACHO_PIC
  6950.       operands[2] = machopic_indirect_data_reference (operands[2], reg);
  6951. #endif
  6952.     }
  6953. }")
  6954.  
  6955. (define_insn ""
  6956.   [(set (match_operand:XF 0 "general_operand" "=f")
  6957.     (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
  6958.         (float:XF (match_operand:SI 2 "general_operand" "dmi"))))]
  6959.   "TARGET_68881"
  6960.   "fdiv%.l %2,%0")
  6961.  
  6962. (define_insn ""
  6963.   [(set (match_operand:XF 0 "general_operand" "=f")
  6964.     (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
  6965.         (float:XF (match_operand:HI 2 "general_operand" "dmn"))))]
  6966.   "TARGET_68881"
  6967.   "fdiv%.w %2,%0")
  6968.  
  6969. (define_insn ""
  6970.   [(set (match_operand:XF 0 "general_operand" "=f")
  6971.     (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
  6972.         (float:XF (match_operand:QI 2 "general_operand" "dmn"))))]
  6973.   "TARGET_68881"
  6974.   "fdiv%.b %2,%0")
  6975.  
  6976. (define_insn ""
  6977.   [(set (match_operand:XF 0 "general_operand" "=f")
  6978.     (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
  6979.         (match_operand:XF 2 "nonimmediate_operand" "fm")))]
  6980.   "TARGET_68881"
  6981.   "*
  6982. {
  6983.   if (REG_P (operands[2]))
  6984.     return \"fdiv%.x %2,%0\";
  6985.   return \"fdiv%.x %f2,%0\";
  6986. }")
  6987.  
  6988. (define_expand "negxf2"
  6989.   [(set (match_operand:XF 0 "general_operand" "")
  6990.     (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
  6991.   ""
  6992.   "
  6993. {
  6994.   /* ??? There isn't an FPA define_insn so we could handle it here too.
  6995.      For now we don't (paranoia).  */
  6996.   if (!TARGET_68881)
  6997.     {
  6998.       rtx result;
  6999.       rtx target;
  7000.       rtx insns;
  7001.  
  7002.       start_sequence ();
  7003.       target = operand_subword (operands[0], 0, 1, XFmode);
  7004.       result = expand_binop (SImode, xor_optab,
  7005.                  operand_subword_force (operands[1], 0, XFmode),
  7006.                  GEN_INT(0x80000000), target, 0, OPTAB_WIDEN);
  7007.       if (result == 0)
  7008.     abort ();
  7009.  
  7010.       if (result != target)
  7011.     emit_move_insn (result, target);
  7012.   
  7013.       emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
  7014.               operand_subword_force (operands[1], 1, XFmode));
  7015.       emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
  7016.               operand_subword_force (operands[1], 2, XFmode));
  7017.  
  7018.       insns = get_insns ();
  7019.       end_sequence ();
  7020.  
  7021.       emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
  7022.       DONE;
  7023.     }
  7024. }")
  7025.  
  7026. (define_insn "negxf2_68881"
  7027.   [(set (match_operand:XF 0 "general_operand" "=f")
  7028.     (neg:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
  7029.   "TARGET_68881"
  7030.   "*
  7031. {
  7032.   if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
  7033.     return \"fneg%.x %1,%0\";
  7034.   return \"fneg%.x %f1,%0\";
  7035. }")
  7036.  
  7037. (define_expand "absxf2"
  7038.   [(set (match_operand:XF 0 "general_operand" "")
  7039.     (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
  7040.   ""
  7041.   "
  7042. {
  7043.   /* ??? There isn't an FPA define_insn so we could handle it here too.
  7044.      For now we don't (paranoia).  */
  7045.   if (!TARGET_68881)
  7046.     {
  7047.       rtx result;
  7048.       rtx target;
  7049.       rtx insns;
  7050.  
  7051.       start_sequence ();
  7052.       target = operand_subword (operands[0], 0, 1, XFmode);
  7053.       result = expand_binop (SImode, and_optab,
  7054.                  operand_subword_force (operands[1], 0, XFmode),
  7055.                  GEN_INT(0x7fffffff), target, 0, OPTAB_WIDEN);
  7056.       if (result == 0)
  7057.     abort ();
  7058.  
  7059.       if (result != target)
  7060.     emit_move_insn (result, target);
  7061.   
  7062.       emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
  7063.               operand_subword_force (operands[1], 1, XFmode));
  7064.       emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
  7065.               operand_subword_force (operands[1], 2, XFmode));
  7066.  
  7067.       insns = get_insns ();
  7068.       end_sequence ();
  7069.  
  7070.       emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
  7071.       DONE;
  7072.     }
  7073. }")
  7074.  
  7075. (define_insn "absxf2_68881"
  7076.   [(set (match_operand:XF 0 "general_operand" "=f")
  7077.     (abs:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
  7078.   "TARGET_68881"
  7079.   "*
  7080. {
  7081.   if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
  7082.     return \"fabs%.x %1,%0\";
  7083.   return \"fabs%.x %f1,%0\";
  7084. }")
  7085.  
  7086. (define_insn "sqrtxf2"
  7087.   [(set (match_operand:XF 0 "general_operand" "=f")
  7088.     (sqrt:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
  7089.   "TARGET_68881"
  7090.   "fsqrt%.x %1,%0")
  7091.  
  7092. (define_insn "sinsf2"
  7093.   [(set (match_operand:SF 0 "general_operand" "=f")
  7094.     (unspec:SF [(match_operand:SF 1 "general_operand" "fm")] 1))]
  7095.   "TARGET_68881 && flag_fast_math"
  7096.   "*
  7097. {
  7098.   if (FP_REG_P (operands[1]))
  7099.     return \"fsin%.x %1,%0\";
  7100.   else
  7101.     return \"fsin%.s %1,%0\";
  7102. }")
  7103.  
  7104. (define_insn "sindf2"
  7105.   [(set (match_operand:DF 0 "general_operand" "=f")
  7106.     (unspec:DF [(match_operand:DF 1 "general_operand" "fm")] 1))]
  7107.   "TARGET_68881 && flag_fast_math"
  7108.   "*
  7109. {
  7110.   if (FP_REG_P (operands[1]))
  7111.     return \"fsin%.x %1,%0\";
  7112.   else
  7113.     return \"fsin%.d %1,%0\";
  7114. }")
  7115.  
  7116. (define_insn "sinxf2"
  7117.   [(set (match_operand:XF 0 "general_operand" "=f")
  7118.     (unspec:XF [(match_operand:XF 1 "nonimmediate_operand" "fm")] 1))]
  7119.   "TARGET_68881 && flag_fast_math"
  7120.   "fsin%.x %1,%0")
  7121.  
  7122. (define_insn "cossf2"
  7123.   [(set (match_operand:SF 0 "general_operand" "=f")
  7124.     (unspec:SF [(match_operand:SF 1 "general_operand" "fm")] 2))]
  7125.   "TARGET_68881 && flag_fast_math"
  7126.   "*
  7127. {
  7128.   if (FP_REG_P (operands[1]))
  7129.     return \"fcos%.x %1,%0\";
  7130.   else
  7131.     return \"fcos%.s %1,%0\";
  7132. }")
  7133.  
  7134. (define_insn "cosdf2"
  7135.   [(set (match_operand:DF 0 "general_operand" "=f")
  7136.     (unspec:DF [(match_operand:DF 1 "general_operand" "fm")] 2))]
  7137.   "TARGET_68881 && flag_fast_math"
  7138.   "*
  7139. {
  7140.   if (FP_REG_P (operands[1]))
  7141.     return \"fcos%.x %1,%0\";
  7142.   else
  7143.     return \"fcos%.d %1,%0\";
  7144. }")
  7145.  
  7146. (define_insn "cosxf2"
  7147.   [(set (match_operand:XF 0 "general_operand" "=f")
  7148.     (unspec:XF [(match_operand:XF 1 "nonimmediate_operand" "fm")] 2))]
  7149.   "TARGET_68881 && flag_fast_math"
  7150.   "fcos%.x %1,%0")
  7151.  
  7152. /* Switch the floating-point precision control between single and double.
  7153.    This doesn't work if the precision control is set to extended.  */
  7154.  
  7155. (define_insn "fppc_switch"
  7156.   [(unspec [(const_int 0)] 0)
  7157.    (clobber (match_scratch:SI 0 "=d"))]
  7158.   ""
  7159.   "fmovem%.l %!,%0\;eor%.l %#192,%0\;fmovem%.l %0,%!")
  7160.