home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / bbs / gnu / gcc-2.5.8-src.lha / src / amiga / gcc-2.5.8 / config / m68k / m68k.md < prev    next >
Encoding:
Text File  |  1994-02-22  |  162.1 KB  |  5,690 lines

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