home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / gnu / gcc-2.3.3-src.lha / GNU / src / amiga / gcc-2.3.3 / config / m68k.md < prev    next >
Text File  |  1994-02-06  |  148KB  |  5,104 lines

  1. ;;- Machine description for GNU compiler
  2. ;;- Motorola 68000 Version
  3. ;;   Copyright (C) 1987, 1988 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.     return \"cmpm%.l %1,%0\";
  391.   if (REG_P (operands[1])
  392.       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
  393.     { cc_status.flags |= CC_REVERSED;
  394. #ifdef SGS_CMP_ORDER
  395.       return \"cmp%.l %d1,%d0\";
  396. #else
  397.       return \"cmp%.l %d0,%d1\";
  398. #endif
  399.     }
  400. #ifdef SGS_CMP_ORDER
  401.   return \"cmp%.l %d0,%d1\";
  402. #else
  403.   return \"cmp%.l %d1,%d0\";
  404. #endif
  405. }")
  406.  
  407. (define_insn "cmphi"
  408.   [(set (cc0)
  409.     (compare (match_operand:HI 0 "nonimmediate_operand" "rnm,d,n,m")
  410.          (match_operand:HI 1 "general_operand" "d,rnm,m,n")))]
  411.   ""
  412.   "*
  413. {
  414.   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
  415.     return \"cmpm%.w %1,%0\";
  416.   if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
  417.       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
  418.     { cc_status.flags |= CC_REVERSED;
  419. #ifdef SGS_CMP_ORDER
  420.       return \"cmp%.w %d1,%d0\";
  421. #else
  422.       return \"cmp%.w %d0,%d1\";
  423. #endif
  424.     }
  425. #ifdef SGS_CMP_ORDER
  426.   return \"cmp%.w %d0,%d1\";
  427. #else
  428.   return \"cmp%.w %d1,%d0\";
  429. #endif
  430. }")
  431.  
  432. (define_insn "cmpqi"
  433.   [(set (cc0)
  434.     (compare (match_operand:QI 0 "nonimmediate_operand" "dn,md,>")
  435.          (match_operand:QI 1 "general_operand" "dm,nd,>")))]
  436.   ""
  437.   "*
  438. {
  439.   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
  440.     return \"cmpm%.b %1,%0\";
  441.   if (REG_P (operands[1])
  442.       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
  443.     { cc_status.flags |= CC_REVERSED;
  444. #ifdef SGS_CMP_ORDER
  445.       return \"cmp%.b %d1,%d0\";
  446. #else
  447.       return \"cmp%.b %d0,%d1\";
  448. #endif
  449.     }
  450. #ifdef SGS_CMP_ORDER
  451.   return \"cmp%.b %d0,%d1\";
  452. #else
  453.   return \"cmp%.b %d1,%d0\";
  454. #endif
  455. }")
  456.  
  457. (define_expand "cmpdf"
  458.   [(set (cc0)
  459.     (compare (match_operand:DF 0 "general_operand" "")
  460.          (match_operand:DF 1 "general_operand" "")))]
  461.   "TARGET_68881 || TARGET_FPA"
  462.   "
  463. {
  464.   if (TARGET_FPA)
  465.     {
  466.       emit_insn (gen_cmpdf_fpa (operands[0], operands[1]));
  467.       DONE;
  468.     }
  469. }")
  470.  
  471. (define_insn "cmpdf_fpa"
  472.   [(set (cc0)
  473.     (compare (match_operand:DF 0 "general_operand" "x,y")
  474.          (match_operand:DF 1 "general_operand" "xH,rmF")))
  475.    (clobber (match_scratch:SI 2 "=d,d"))]
  476.   "TARGET_FPA"
  477.   "fpcmp%.d %y1,%0\;fpmove fpastatus,%2\;movw %2,cc")
  478.  
  479. (define_insn ""
  480.   [(set (cc0)
  481.     (compare (match_operand:DF 0 "general_operand" "f,mG")
  482.          (match_operand:DF 1 "general_operand" "fmG,f")))]
  483.   "TARGET_68881"
  484.   "*
  485. {
  486.   cc_status.flags = CC_IN_68881;
  487. #ifdef SGS_CMP_ORDER
  488.   if (REG_P (operands[0]))
  489.     {
  490.       if (REG_P (operands[1]))
  491.     return \"fcmp%.x %0,%1\";
  492.       else
  493.         return \"fcmp%.d %0,%f1\";
  494.     }
  495.   cc_status.flags |= CC_REVERSED;
  496.   return \"fcmp%.d %1,%f0\";
  497. #else
  498.   if (REG_P (operands[0]))
  499.     {
  500.       if (REG_P (operands[1]))
  501.     return \"fcmp%.x %1,%0\";
  502.       else
  503.         return \"fcmp%.d %f1,%0\";
  504.     }
  505.   cc_status.flags |= CC_REVERSED;
  506.   return \"fcmp%.d %f0,%1\";
  507. #endif
  508. }")
  509.  
  510. (define_expand "cmpsf"
  511.  [(set (cc0)
  512.        (compare (match_operand:SF 0 "general_operand" "")
  513.         (match_operand:SF 1 "general_operand" "")))]
  514.  "TARGET_68881 || TARGET_FPA"
  515.  "
  516. {
  517.   if (TARGET_FPA)
  518.     {
  519.       emit_insn (gen_cmpsf_fpa (operands[0], operands[1]));
  520.       DONE;
  521.     }
  522. }")
  523.  
  524. (define_insn "cmpsf_fpa"
  525.   [(set (cc0)
  526.     (compare (match_operand:SF 0 "general_operand" "x,y")
  527.          (match_operand:SF 1 "general_operand" "xH,rmF")))
  528.    (clobber (match_scratch:SI 2 "=d,d"))]
  529.   "TARGET_FPA"
  530.   "fpcmp%.s %w1,%x0\;fpmove fpastatus,%2\;movw %2,cc")
  531.  
  532. (define_insn ""
  533.   [(set (cc0)
  534.     (compare (match_operand:SF 0 "general_operand" "f,mdG")
  535.          (match_operand:SF 1 "general_operand" "fmdG,f")))]
  536.   "TARGET_68881"
  537.   "*
  538. {
  539.   cc_status.flags = CC_IN_68881;
  540. #ifdef SGS_CMP_ORDER
  541.   if (FP_REG_P (operands[0]))
  542.     {
  543.       if (FP_REG_P (operands[1]))
  544.     return \"fcmp%.x %0,%1\";
  545.       else
  546.         return \"fcmp%.s %0,%f1\";
  547.     }
  548.   cc_status.flags |= CC_REVERSED;
  549.   return \"fcmp%.s %1,%f0\";
  550. #else
  551.   if (FP_REG_P (operands[0]))
  552.     {
  553.       if (FP_REG_P (operands[1]))
  554.     return \"fcmp%.x %1,%0\";
  555.       else
  556.         return \"fcmp%.s %f1,%0\";
  557.     }
  558.   cc_status.flags |= CC_REVERSED;
  559.   return \"fcmp%.s %f0,%1\";
  560. #endif
  561. }")
  562.  
  563. ;; Recognizers for btst instructions.
  564.  
  565. (define_insn ""
  566.   [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "do")
  567.                 (const_int 1)
  568.                 (minus:SI (const_int 7)
  569.                       (match_operand:SI 1 "general_operand" "di"))))]
  570.   ""
  571.   "* { return output_btst (operands, operands[1], operands[0], insn, 7); }")
  572.  
  573. (define_insn ""
  574.   [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "d")
  575.                 (const_int 1)
  576.                 (minus:SI (const_int 31)
  577.                       (match_operand:SI 1 "general_operand" "di"))))]
  578.   ""
  579.   "* { return output_btst (operands, operands[1], operands[0], insn, 31); }")
  580.  
  581. ;; The following two patterns are like the previous two
  582. ;; except that they use the fact that bit-number operands
  583. ;; are automatically masked to 3 or 5 bits.
  584.  
  585. (define_insn ""
  586.   [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "do")
  587.                 (const_int 1)
  588.                 (minus:SI (const_int 7)
  589.                       (and:SI
  590.                        (match_operand:SI 1 "general_operand" "d")
  591.                        (const_int 7)))))]
  592.   ""
  593.   "* { return output_btst (operands, operands[1], operands[0], insn, 7); }")
  594.  
  595. (define_insn ""
  596.   [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "d")
  597.                 (const_int 1)
  598.                 (minus:SI (const_int 31)
  599.                       (and:SI
  600.                        (match_operand:SI 1 "general_operand" "d")
  601.                        (const_int 31)))))]
  602.   ""
  603.   "* { return output_btst (operands, operands[1], operands[0], insn, 31); }")
  604.  
  605. ;; Nonoffsettable mem refs are ok in this one pattern
  606. ;; since we don't try to adjust them.
  607. (define_insn ""
  608.   [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "md")
  609.                 (const_int 1)
  610.                 (match_operand:SI 1 "general_operand" "i")))]
  611.   "GET_CODE (operands[1]) == CONST_INT
  612.    && (unsigned) INTVAL (operands[1]) < 8"
  613.   "*
  614. {
  615.   operands[1] = gen_rtx (CONST_INT, VOIDmode, 7 - INTVAL (operands[1]));
  616.   return output_btst (operands, operands[1], operands[0], insn, 7);
  617. }")
  618.  
  619. (define_insn ""
  620.   [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "do")
  621.                 (const_int 1)
  622.                 (match_operand:SI 1 "general_operand" "i")))]
  623.   "GET_CODE (operands[1]) == CONST_INT"
  624.   "*
  625. {
  626.   if (GET_CODE (operands[0]) == MEM)
  627.     {
  628.       operands[0] = adj_offsettable_operand (operands[0],
  629.                          INTVAL (operands[1]) / 8);
  630.       operands[1] = gen_rtx (CONST_INT, VOIDmode, 
  631.                  7 - INTVAL (operands[1]) % 8);
  632.       return output_btst (operands, operands[1], operands[0], insn, 7);
  633.     }
  634.   operands[1] = gen_rtx (CONST_INT, VOIDmode,
  635.              31 - INTVAL (operands[1]));
  636.   return output_btst (operands, operands[1], operands[0], insn, 31);
  637. }")
  638.  
  639.  
  640. ;; move instructions
  641.  
  642. ;; A special case in which it is not desirable
  643. ;; to reload the constant into a data register.
  644. (define_insn ""
  645.   [(set (match_operand:SI 0 "push_operand" "=m")
  646.     (match_operand:SI 1 "general_operand" "J"))]
  647.   "GET_CODE (operands[1]) == CONST_INT
  648.    && INTVAL (operands[1]) >= -0x8000
  649.    && INTVAL (operands[1]) < 0x8000"
  650.   "*
  651. {
  652.   if (operands[1] == const0_rtx)
  653.     return \"clr%.l %0\";
  654.   return \"pea %a1\";
  655. }")
  656.  
  657. ;This is never used.
  658. ;(define_insn "swapsi"
  659. ;  [(set (match_operand:SI 0 "general_operand" "+r")
  660. ;    (match_operand:SI 1 "general_operand" "+r"))
  661. ;   (set (match_dup 1) (match_dup 0))]
  662. ;  ""
  663. ;  "exg %1,%0")
  664.  
  665. ;; Special case of fullword move when source is zero.
  666. ;; The reason this is special is to avoid loading a zero
  667. ;; into a data reg with moveq in order to store it elsewhere.
  668.    
  669. (define_insn ""
  670.   [(set (match_operand:SI 0 "general_operand" "=g")
  671.     (const_int 0))]
  672.   ;; clr insns on 68000 read before writing.
  673.   ;; This isn't so on the 68010, but we have no alternative for it.
  674.   "(TARGET_68020
  675.     || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))"
  676.   "*
  677. {
  678.   if (ADDRESS_REG_P (operands[0]))
  679.     return \"sub%.l %0,%0\";
  680.   /* moveq is faster on the 68000.  */
  681.   if (DATA_REG_P (operands[0]) && !TARGET_68020)
  682. #if defined(MOTOROLA) && !defined(CRDS)
  683.     return \"moveq%.l %#0,%0\";
  684. #else
  685.     return \"moveq %#0,%0\";
  686. #endif
  687.   return \"clr%.l %0\";
  688. }")
  689.  
  690. ;; General case of fullword move. 
  691. ;;
  692. ;; This is the main "hook" for PIC code.  When generating
  693. ;; PIC, movsi is responsible for determining when the source address
  694. ;; needs PIC relocation and appropriately calling legitimize_pic_address
  695. ;; to perform the actual relocation.
  696. ;;
  697. ;; In both the PIC and non-PIC cases the patterns generated will
  698. ;; matched by the next define_insn. 
  699. (define_expand "movsi"
  700.   [(set (match_operand:SI 0 "general_operand" "")
  701.     (match_operand:SI 1 "general_operand" ""))]
  702.   ""
  703.   "
  704. {
  705.   if (flag_pic && symbolic_operand (operands[1], SImode)) 
  706.     {
  707. #ifdef LEGITIMATE_BASEREL_OPERAND_P
  708.       if (flag_pic < 3 || !LEGITIMATE_BASEREL_OPERAND_P (operands[1]))
  709. #endif
  710.       {
  711.         /* The source is an address which requires PIC relocation.  
  712.            Call legitimize_pic_address with the source, mode, and a relocation
  713.            register (a new pseudo, or the final destination if reload_in_progress
  714.            is set).   Then fall through normally */
  715.         extern rtx legitimize_pic_address();
  716.         rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
  717.         operands[1] = legitimize_pic_address (operands[1], SImode, temp);
  718.       }
  719.     }
  720. }")
  721.  
  722. ;; General case of fullword move.  The register constraints
  723. ;; force integer constants in range for a moveq to be reloaded
  724. ;; if they are headed for memory.
  725. (define_insn ""
  726.   ;; Notes: make sure no alternative allows g vs g.
  727.   ;; We don't allow f-regs since fixed point cannot go in them.
  728.   ;; We do allow y and x regs since fixed point is allowed in them.
  729.   [(set (match_operand:SI 0 "general_operand" "=g,da,y,!*x*r*m")
  730.     (match_operand:SI 1 "general_operand" "daymKs,i,g,*x*r*m"))]
  731.   ""
  732.   "*
  733. {
  734.   if (which_alternative == 3)
  735.     return \"fpmove%.l %x1,fpa0\;fpmove%.l fpa0,%x0\";    
  736.   if (FPA_REG_P (operands[1]) || FPA_REG_P (operands[0]))
  737.     return \"fpmove%.l %x1,%x0\";
  738.   if (GET_CODE (operands[1]) == CONST_INT)
  739.     {
  740.       if (operands[1] == const0_rtx
  741.       && (DATA_REG_P (operands[0])
  742.           || GET_CODE (operands[0]) == MEM)
  743.       /* clr insns on 68000 read before writing.
  744.          This isn't so on the 68010, but we have no alternative for it.  */
  745.       && (TARGET_68020
  746.           || !(GET_CODE (operands[0]) == MEM
  747.            && MEM_VOLATILE_P (operands[0]))))
  748.     return \"clr%.l %0\";
  749.       else if (DATA_REG_P (operands[0])
  750.            && INTVAL (operands[1]) < 128
  751.            && INTVAL (operands[1]) >= -128)
  752.         {
  753. #if defined(MOTOROLA) && !defined(CRDS)
  754.           return \"moveq%.l %1,%0\";
  755. #else
  756.       return \"moveq %1,%0\";
  757. #endif
  758.     }
  759. #ifndef NO_ADDSUB_Q
  760.       else if (DATA_REG_P (operands[0])
  761.            /* Do this with a moveq #N-8, dreg; addq #8,dreg */
  762.            && INTVAL (operands[1]) < 136
  763.            && INTVAL (operands[1]) >= 128)
  764.         {
  765.       operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8);
  766. #if defined(MOTOROLA) && !defined(CRDS)
  767.           return \"moveq%.l %1,%0\;addq%.w %#8,%0\";
  768. #else
  769.       return \"moveq %1,%0\;addq%.w %#8,%0\";
  770. #endif
  771.     }
  772.       else if (DATA_REG_P (operands[0])
  773.            /* Do this with a moveq #N+8, dreg; subq #8,dreg */
  774.            && INTVAL (operands[1]) < -128
  775.            && INTVAL (operands[1]) >= -136)
  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;subq%.w %#8,%0\";
  780. #else
  781.       return \"moveq %1,%0;subq%.w %#8,%0\";
  782. #endif
  783.     }
  784. #endif
  785.       else if (DATA_REG_P (operands[0])
  786.            /* If N is in the right range and is even, then use
  787.               moveq #N/2, dreg; addl dreg,dreg */
  788.            && INTVAL (operands[1]) > 127
  789.            && INTVAL (operands[1]) <= 254
  790.            && INTVAL (operands[1]) % 2 == 0)
  791.         {
  792.       operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) / 2);
  793. #if defined(MOTOROLA) && !defined(CRDS)
  794.           return \"moveq%.l %1,%0\;add%.w %0,%0\";
  795. #else
  796.       return \"moveq %1,%0\;add%.w %0,%0\";
  797. #endif
  798.     }
  799.       else if (ADDRESS_REG_P (operands[0])
  800.            && INTVAL (operands[1]) < 0x8000
  801.            && INTVAL (operands[1]) >= -0x8000)
  802.     return \"move%.w %1,%0\";
  803.       else if (push_operand (operands[0], SImode)
  804.            && INTVAL (operands[1]) < 0x8000
  805.            && INTVAL (operands[1]) >= -0x8000)
  806.         return \"pea %a1\";
  807.     }
  808.   else if ((GET_CODE (operands[1]) == SYMBOL_REF
  809.         || GET_CODE (operands[1]) == CONST)
  810.        && push_operand (operands[0], SImode))
  811.     return \"pea %a1\";
  812.   else if ((GET_CODE (operands[1]) == SYMBOL_REF
  813.         || GET_CODE (operands[1]) == CONST)
  814.        && ADDRESS_REG_P (operands[0]))
  815.     return \"lea %a1,%0\";
  816.   return \"move%.l %1,%0\";
  817. }")
  818.  
  819. (define_insn "movhi"
  820.   [(set (match_operand:HI 0 "general_operand" "=g")
  821.     (match_operand:HI 1 "general_operand" "g"))]
  822.   ""
  823.   "*
  824. {
  825.   if (GET_CODE (operands[1]) == CONST_INT)
  826.     {
  827.       if (operands[1] == const0_rtx
  828.       && (DATA_REG_P (operands[0])
  829.           || GET_CODE (operands[0]) == MEM)
  830.       /* clr insns on 68000 read before writing.
  831.          This isn't so on the 68010, but we have no alternative for it.  */
  832.       && (TARGET_68020
  833.           || !(GET_CODE (operands[0]) == MEM
  834.            && MEM_VOLATILE_P (operands[0]))))
  835.     return \"clr%.w %0\";
  836.       else if (DATA_REG_P (operands[0])
  837.            && INTVAL (operands[1]) < 128
  838.            && INTVAL (operands[1]) >= -128)
  839.         {
  840. #if defined(MOTOROLA) && !defined(CRDS)
  841.           return \"moveq%.l %1,%0\";
  842. #else
  843.       return \"moveq %1,%0\";
  844. #endif
  845.     }
  846.       else if (INTVAL (operands[1]) < 0x8000
  847.            && INTVAL (operands[1]) >= -0x8000)
  848.     return \"move%.w %1,%0\";
  849.     }
  850.   else if (CONSTANT_P (operands[1]))
  851.     return \"move%.l %1,%0\";
  852. #ifndef SGS_NO_LI
  853.   /* Recognize the insn before a tablejump, one that refers
  854.      to a table of offsets.  Such an insn will need to refer
  855.      to a label on the insn.  So output one.  Use the label-number
  856.      of the table of offsets to generate this label.  */
  857.   if (GET_CODE (operands[1]) == MEM
  858.       && GET_CODE (XEXP (operands[1], 0)) == PLUS
  859.       && (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF
  860.       || GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == LABEL_REF)
  861.       && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) != PLUS
  862.       && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) != PLUS)
  863.     {
  864.       rtx labelref;
  865.       if (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF)
  866.     labelref = XEXP (XEXP (operands[1], 0), 0);
  867.       else
  868.     labelref = XEXP (XEXP (operands[1], 0), 1);
  869. #if defined (MOTOROLA) && !defined (SGS_SWITCH_TABLES)
  870. #ifdef SGS
  871.       asm_fprintf (asm_out_file, \"\\tset %LLI%d,.+2\\n\",
  872.            CODE_LABEL_NUMBER (XEXP (labelref, 0)));
  873. #else /* not SGS */
  874.       asm_fprintf (asm_out_file, \"\\t.set %LLI%d,.+2\\n\",
  875.                CODE_LABEL_NUMBER (XEXP (labelref, 0)));
  876. #endif /* not SGS */
  877. #else /* SGS_SWITCH_TABLES or not MOTOROLA */
  878.       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"LI\",
  879.                  CODE_LABEL_NUMBER (XEXP (labelref, 0)));
  880. #ifdef SGS_SWITCH_TABLES
  881.       /* Set flag saying we need to define the symbol
  882.      LD%n (with value L%n-LI%n) at the end of the switch table.  */
  883.       switch_table_difference_label_flag = 1;
  884. #endif /* SGS_SWITCH_TABLES */
  885. #endif /* SGS_SWITCH_TABLES or not MOTOROLA */
  886.     }
  887. #endif /* SGS_NO_LI */
  888.   return \"move%.w %1,%0\";
  889. }")
  890.  
  891. (define_insn "movstricthi"
  892.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm"))
  893.     (match_operand:HI 1 "general_operand" "rmn"))]
  894.   ""
  895.   "*
  896. {
  897.   if (GET_CODE (operands[1]) == CONST_INT)
  898.     {
  899.       if (operands[1] == const0_rtx
  900.       && (DATA_REG_P (operands[0])
  901.           || GET_CODE (operands[0]) == MEM)
  902.       /* clr insns on 68000 read before writing.
  903.          This isn't so on the 68010, but we have no alternative for it.  */
  904.       && (TARGET_68020
  905.           || !(GET_CODE (operands[0]) == MEM
  906.            && MEM_VOLATILE_P (operands[0]))))
  907.     return \"clr%.w %0\";
  908.     }
  909.   return \"move%.w %1,%0\";
  910. }")
  911.  
  912. (define_insn "movqi"
  913.   [(set (match_operand:QI 0 "general_operand" "=d,*a,m,m,?*a")
  914.     (match_operand:QI 1 "general_operand" "dmi*a,d*a,dmi,?*a,m"))]
  915.   ""
  916.   "*
  917. {
  918.   rtx xoperands[4];
  919.  
  920.   /* This is probably useless, since it loses for pushing a struct
  921.      of several bytes a byte at a time.  */
  922.   if (GET_CODE (operands[0]) == MEM
  923.       && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
  924.       && XEXP (XEXP (operands[0], 0), 0) == stack_pointer_rtx)
  925.     {
  926.       xoperands[1] = operands[1];
  927.       xoperands[2]
  928.         = gen_rtx (MEM, QImode,
  929.            gen_rtx (PLUS, VOIDmode, stack_pointer_rtx, const1_rtx));
  930.       xoperands[3] = stack_pointer_rtx;
  931.       /* Just pushing a byte puts it in the high byte of the halfword.  */
  932.       /* We must put it in the low-order, high-numbered byte.  */
  933.       output_asm_insn (\"subq%.w %#2,%3\;move%.b %1,%2\", xoperands);
  934.       return \"\";
  935.     }
  936.  
  937.   if (ADDRESS_REG_P (operands[0]) && GET_CODE (operands[1]) == MEM)
  938.     {
  939.       xoperands[1] = operands[1];
  940.       xoperands[2]
  941.         = gen_rtx (MEM, QImode,
  942.            gen_rtx (PLUS, VOIDmode, stack_pointer_rtx, const1_rtx));
  943.       xoperands[3] = stack_pointer_rtx;
  944.       /* Just pushing a byte puts it in the high byte of the halfword.  */
  945.       /* We must put it in the low half, the second byte.  */
  946.       output_asm_insn (\"subq%.w %#2,%3\;move%.b %1,%2\", xoperands);
  947.       return \"move%.w %+,%0\";
  948.     }
  949.   if (ADDRESS_REG_P (operands[1]) && GET_CODE (operands[0]) == MEM)
  950.     {
  951.       xoperands[0] = operands[0];
  952.       xoperands[1] = operands[1];
  953.       xoperands[2]
  954.         = gen_rtx (MEM, QImode,
  955.            gen_rtx (PLUS, VOIDmode, stack_pointer_rtx, const1_rtx));
  956.       xoperands[3] = stack_pointer_rtx;
  957.       output_asm_insn (\"move%.w %1,%-\;move%.b %2,%0\;addq%.w %#2,%3\", xoperands);
  958.       return \"\";
  959.     }
  960.   /* clr and st insns on 68000 read before writing.
  961.      This isn't so on the 68010, but we have no alternative for it.  */
  962.   if (TARGET_68020
  963.       || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))
  964.     {
  965.       if (operands[1] == const0_rtx)
  966.     return \"clr%.b %0\";
  967.       if (GET_CODE (operands[1]) == CONST_INT
  968.       && INTVAL (operands[1]) == -1)
  969.     {
  970.       CC_STATUS_INIT;
  971.       return \"st %0\";
  972.     }
  973.     }
  974.   if (GET_CODE (operands[1]) != CONST_INT && CONSTANT_P (operands[1]))
  975.     return \"move%.l %1,%0\";
  976.   if (ADDRESS_REG_P (operands[0]) || ADDRESS_REG_P (operands[1]))
  977.     return \"move%.w %1,%0\";
  978.   return \"move%.b %1,%0\";
  979. }")
  980.  
  981. (define_insn "movstrictqi"
  982.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm"))
  983.     (match_operand:QI 1 "general_operand" "dmn"))]
  984.   ""
  985.   "*
  986. {
  987.   if (operands[1] == const0_rtx
  988.       /* clr insns on 68000 read before writing.
  989.          This isn't so on the 68010, but we have no alternative for it.  */
  990.       && (TARGET_68020
  991.           || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
  992.     return \"clr%.b %0\";
  993.   return \"move%.b %1,%0\";
  994. }")
  995.  
  996. (define_insn "movsf"
  997.   [(set (match_operand:SF 0 "general_operand" "=rmf,x,y,rm,!x,!rm")
  998.     (match_operand:SF 1 "general_operand" "rmfF,xH,rmF,y,rm,x"))]
  999. ;  [(set (match_operand:SF 0 "general_operand" "=rmf")
  1000. ;    (match_operand:SF 1 "general_operand" "rmfF"))]
  1001.   ""
  1002.   "*
  1003. {
  1004.   if (which_alternative >= 4)
  1005.     return \"fpmove%.s %1,fpa0\;fpmove%.s fpa0,%0\";
  1006.   if (FPA_REG_P (operands[0]))
  1007.     {
  1008.       if (FPA_REG_P (operands[1]))
  1009.     return \"fpmove%.s %x1,%x0\";
  1010.       else if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1011.     return output_move_const_single (operands);
  1012.       else if (FP_REG_P (operands[1]))
  1013.         return \"fmove%.s %1,sp@-\;fpmove%.d sp@+, %0\";
  1014.       return \"fpmove%.s %x1,%x0\";
  1015.     }
  1016.   if (FPA_REG_P (operands[1]))
  1017.     {
  1018.       if (FP_REG_P (operands[0]))
  1019.     return \"fpmove%.s %x1,sp@-\;fmove%.s sp@+,%0\";
  1020.       else
  1021.     return \"fpmove%.s %x1,%x0\";
  1022.     }
  1023.   if (FP_REG_P (operands[0]))
  1024.     {
  1025.       if (FP_REG_P (operands[1]))
  1026.     return \"f%$move%.x %1,%0\";
  1027.       else if (ADDRESS_REG_P (operands[1]))
  1028.     return \"move%.l %1,%-\;f%$move%.s %+,%0\";
  1029.       else if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1030.     return output_move_const_single (operands);
  1031.       return \"f%$move%.s %f1,%0\";
  1032.     }
  1033.   if (FP_REG_P (operands[1]))
  1034.     {
  1035.       if (ADDRESS_REG_P (operands[0]))
  1036.     return \"fmove%.s %1,%-\;move%.l %+,%0\";
  1037.       return \"fmove%.s %f1,%0\";
  1038.     }
  1039.   return \"move%.l %1,%0\";
  1040. }")
  1041.  
  1042. (define_insn "movdf"
  1043.   [(set (match_operand:DF 0 "general_operand" "=rm,&rf,&rof<>,y,rm,x,!x,!rm")
  1044.     (match_operand:DF 1 "general_operand" "rf,m,rofE<>,rmE,y,xH,rm,x"))]
  1045. ;  [(set (match_operand:DF 0 "general_operand" "=rm,&rf,&rof<>")
  1046. ;    (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
  1047.   ""
  1048.   "*
  1049. {
  1050.   if (which_alternative == 6)
  1051.     return \"fpmove%.d %x1,fpa0\;fpmove%.d fpa0,%x0\";
  1052.   if (FPA_REG_P (operands[0]))
  1053.     {
  1054.       if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1055.     return output_move_const_double (operands);
  1056.       if (FP_REG_P (operands[1]))
  1057.         return \"fmove%.d %1,sp@-\;fpmove%.d sp@+,%x0\";
  1058.       return \"fpmove%.d %x1,%x0\";
  1059.     }
  1060.   else if (FPA_REG_P (operands[1]))
  1061.     {
  1062.       if (FP_REG_P(operands[0]))
  1063.         return \"fpmove%.d %x1,sp@-\;fmoved sp@+,%0\";
  1064.       else
  1065.         return \"fpmove%.d %x1,%x0\";
  1066.     }
  1067.   if (FP_REG_P (operands[0]))
  1068.     {
  1069.       if (FP_REG_P (operands[1]))
  1070.     return \"f%&move%.x %1,%0\";
  1071.       if (REG_P (operands[1]))
  1072.     {
  1073.       rtx xoperands[2];
  1074.       xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  1075.       output_asm_insn (\"move%.l %1,%-\", xoperands);
  1076.       output_asm_insn (\"move%.l %1,%-\", operands);
  1077.       return \"f%&move%.d %+,%0\";
  1078.     }
  1079.       if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1080.     return output_move_const_double (operands);
  1081.       return \"f%&move%.d %f1,%0\";
  1082.     }
  1083.   else if (FP_REG_P (operands[1]))
  1084.     {
  1085.       if (REG_P (operands[0]))
  1086.     {
  1087.       output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands);
  1088.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1089.       return \"move%.l %+,%0\";
  1090.     }
  1091.       else
  1092.         return \"fmove%.d %f1,%0\";
  1093.     }
  1094.   return output_move_double (operands);
  1095. }
  1096. ")
  1097.  
  1098. ;; movdi can apply to fp regs in some cases
  1099. (define_insn "movdi"
  1100.   ;; Let's see if it really still needs to handle fp regs, and, if so, why.
  1101.   [(set (match_operand:DI 0 "general_operand" "=rm,&r,&ro<>,y,rm,!*x,!rm")
  1102.     (match_operand:DI 1 "general_operand" "rF,m,roi<>F,rmiF,y,rmF,*x"))]
  1103. ;  [(set (match_operand:DI 0 "general_operand" "=rm,&r,&ro<>,!&rm,!&f,y,rm,x,!x,!rm")
  1104. ;    (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfmF,rmi,y,rm,x"))]
  1105. ;  [(set (match_operand:DI 0 "general_operand" "=rm,&rf,&ro<>,!&rm,!&f")
  1106. ;    (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
  1107.   ""
  1108.   "*
  1109. {
  1110.   if (which_alternative == 8)
  1111.     return \"fpmove%.d %x1,fpa0\;fpmove%.d fpa0,%x0\";
  1112.   if (FPA_REG_P (operands[0]) || FPA_REG_P (operands[1]))
  1113.     return \"fpmove%.d %x1,%x0\";
  1114.   if (FP_REG_P (operands[0]))
  1115.     {
  1116.       if (FP_REG_P (operands[1]))
  1117.     return \"fmove%.x %1,%0\";
  1118.       if (REG_P (operands[1]))
  1119.     {
  1120.       rtx xoperands[2];
  1121.       xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  1122.       output_asm_insn (\"move%.l %1,%-\", xoperands);
  1123.       output_asm_insn (\"move%.l %1,%-\", operands);
  1124.       return \"fmove%.d %+,%0\";
  1125.     }
  1126.       if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1127.     return output_move_const_double (operands);
  1128.       return \"fmove%.d %f1,%0\";
  1129.     }
  1130.   else if (FP_REG_P (operands[1]))
  1131.     {
  1132.       if (REG_P (operands[0]))
  1133.     {
  1134.       output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands);
  1135.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1136.       return \"move%.l %+,%0\";
  1137.     }
  1138.       else
  1139.         return \"fmove%.d %f1,%0\";
  1140.     }
  1141.   return output_move_double (operands);
  1142. }
  1143. ")
  1144.  
  1145. ;; Thus goes after the move instructions
  1146. ;; because the move instructions are better (require no spilling)
  1147. ;; when they can apply.  It goes before the add/sub insns
  1148. ;; so we will prefer it to them.
  1149.  
  1150. (define_insn "pushasi"
  1151.   [(set (match_operand:SI 0 "push_operand" "=m")
  1152.     (match_operand:SI 1 "address_operand" "p"))]
  1153.   ""
  1154.   "pea %a1")
  1155.  
  1156. ;; truncation instructions
  1157. (define_insn "truncsiqi2"
  1158.   [(set (match_operand:QI 0 "general_operand" "=dm,d")
  1159.     (truncate:QI
  1160.      (match_operand:SI 1 "general_operand" "doJ,i")))]
  1161.   ""
  1162.   "*
  1163. {
  1164.   if (GET_CODE (operands[0]) == REG)
  1165.     {
  1166.       /* Must clear condition codes, since the move.l bases them on
  1167.      the entire 32 bits, not just the desired 8 bits.  */
  1168.       CC_STATUS_INIT;
  1169.       return \"move%.l %1,%0\";
  1170.     }
  1171.   if (GET_CODE (operands[1]) == MEM)
  1172.     operands[1] = adj_offsettable_operand (operands[1], 3);
  1173.   return \"move%.b %1,%0\";
  1174. }")
  1175.  
  1176. (define_insn "trunchiqi2"
  1177.   [(set (match_operand:QI 0 "general_operand" "=dm,d")
  1178.     (truncate:QI
  1179.      (match_operand:HI 1 "general_operand" "doJ,i")))]
  1180.   ""
  1181.   "*
  1182. {
  1183.   if (GET_CODE (operands[0]) == REG
  1184.       && (GET_CODE (operands[1]) == MEM
  1185.       || GET_CODE (operands[1]) == CONST_INT))
  1186.     {
  1187.       /* Must clear condition codes, since the move.w bases them on
  1188.      the entire 16 bits, not just the desired 8 bits.  */
  1189.       CC_STATUS_INIT;
  1190.       return \"move%.w %1,%0\";
  1191.     }
  1192.   if (GET_CODE (operands[0]) == REG)
  1193.     {
  1194.       /* Must clear condition codes, since the move.l bases them on
  1195.      the entire 32 bits, not just the desired 8 bits.  */
  1196.       CC_STATUS_INIT;
  1197.       return \"move%.l %1,%0\";
  1198.     }
  1199.   if (GET_CODE (operands[1]) == MEM)
  1200.     operands[1] = adj_offsettable_operand (operands[1], 1);
  1201.   return \"move%.b %1,%0\";
  1202. }")
  1203.  
  1204. (define_insn "truncsihi2"
  1205.   [(set (match_operand:HI 0 "general_operand" "=dm,d")
  1206.     (truncate:HI
  1207.      (match_operand:SI 1 "general_operand" "roJ,i")))]
  1208.   ""
  1209.   "*
  1210. {
  1211.   if (GET_CODE (operands[0]) == REG)
  1212.     {
  1213.       /* Must clear condition codes, since the move.l bases them on
  1214.      the entire 32 bits, not just the desired 8 bits.  */
  1215.       CC_STATUS_INIT;
  1216.       return \"move%.l %1,%0\";
  1217.     }
  1218.   if (GET_CODE (operands[1]) == MEM)
  1219.     operands[1] = adj_offsettable_operand (operands[1], 2);
  1220.   return \"move%.w %1,%0\";
  1221. }")
  1222.  
  1223. ;; zero extension instructions
  1224.  
  1225. (define_expand "zero_extendhisi2"
  1226.   [(set (match_operand:SI 0 "register_operand" "")
  1227.     (const_int 0))
  1228.    (set (strict_low_part (match_dup 2))
  1229.     (match_operand:HI 1 "general_operand" ""))]
  1230.   ""
  1231.   "
  1232. {
  1233.   operands[1] = make_safe_from (operands[1], operands[0]);
  1234.   if (GET_CODE (operands[0]) == SUBREG)
  1235.     operands[2] = gen_rtx (SUBREG, HImode, SUBREG_REG (operands[0]),
  1236.                SUBREG_WORD (operands[0]));
  1237.   else
  1238.     operands[2] = gen_rtx (SUBREG, HImode, operands[0], 0);
  1239. }")
  1240.  
  1241. (define_expand "zero_extendqihi2"
  1242.   [(set (match_operand:HI 0 "register_operand" "")
  1243.     (const_int 0))
  1244.    (set (strict_low_part (match_dup 2))
  1245.     (match_operand:QI 1 "general_operand" ""))]
  1246.   ""
  1247.   "
  1248. {
  1249.   operands[1] = make_safe_from (operands[1], operands[0]);
  1250.   if (GET_CODE (operands[0]) == SUBREG)
  1251.     operands[2] = gen_rtx (SUBREG, QImode, SUBREG_REG (operands[0]),
  1252.                SUBREG_WORD (operands[0]));
  1253.   else
  1254.     operands[2] = gen_rtx (SUBREG, QImode, operands[0], 0);
  1255. }")
  1256.  
  1257. (define_expand "zero_extendqisi2"
  1258.   [(set (match_operand:SI 0 "register_operand" "")
  1259.     (const_int 0))
  1260.    (set (strict_low_part (match_dup 2))
  1261.     (match_operand:QI 1 "general_operand" ""))]
  1262.   ""
  1263.   "
  1264. {
  1265.   operands[1] = make_safe_from (operands[1], operands[0]);
  1266.   if (GET_CODE (operands[0]) == SUBREG)
  1267.     operands[2] = gen_rtx (SUBREG, QImode, SUBREG_REG (operands[0]),
  1268.                SUBREG_WORD (operands[0]));
  1269.   else
  1270.     operands[2] = gen_rtx (SUBREG, QImode, operands[0], 0);
  1271. }")
  1272.  
  1273. ;; Patterns to recognize zero-extend insns produced by the combiner.
  1274. ;; We don't allow both operands in memory, because of aliasing problems.
  1275. ;; Explicitly disallow two memory operands via the condition since reloading
  1276. ;; of this case will result in worse code than the uncombined patterns.
  1277.  
  1278. (define_insn ""
  1279.   [(set (match_operand:SI 0 "general_operand" "=do<>,d<")
  1280.     (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
  1281.   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
  1282.   "*
  1283. {
  1284.   if (DATA_REG_P (operands[0]))
  1285.     {
  1286.       if (GET_CODE (operands[1]) == REG
  1287.       && REGNO (operands[0]) == REGNO (operands[1]))
  1288.     return \"and%.l %#0xFFFF,%0\";
  1289.       if (reg_mentioned_p (operands[0], operands[1]))
  1290.         return \"move%.w %1,%0\;and%.l %#0xFFFF,%0\";
  1291.       return \"clr%.l %0\;move%.w %1,%0\";
  1292.     }
  1293.   else if (GET_CODE (operands[0]) == MEM
  1294.        && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  1295.     return \"move%.w %1,%0\;clr%.w %0\";
  1296.   else if (GET_CODE (operands[0]) == MEM
  1297.        && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  1298.     return \"clr%.w %0\;move%.w %1,%0\";
  1299.   else
  1300.     {
  1301.       output_asm_insn (\"clr%.w %0\", operands);
  1302.       operands[0] = adj_offsettable_operand (operands[0], 2);
  1303.       return \"move%.w %1,%0\";
  1304.     }
  1305. }")
  1306.  
  1307. (define_insn ""
  1308.   [(set (match_operand:HI 0 "general_operand" "=do<>,d")
  1309.     (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
  1310.   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
  1311.   "*
  1312. {
  1313.   if (DATA_REG_P (operands[0]))
  1314.     {
  1315.       if (GET_CODE (operands[1]) == REG
  1316.       && REGNO (operands[0]) == REGNO (operands[1]))
  1317.     return \"and%.w %#0xFF,%0\";
  1318.       if (reg_mentioned_p (operands[0], operands[1]))
  1319.         return \"move%.b %1,%0\;and%.w %#0xFF,%0\";
  1320.       return \"clr%.w %0\;move%.b %1,%0\";
  1321.     }
  1322.   else if (GET_CODE (operands[0]) == MEM
  1323.        && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  1324.     {
  1325.       if (REGNO (XEXP (XEXP (operands[0], 0), 0))
  1326.       == STACK_POINTER_REGNUM)
  1327.     {
  1328.       output_asm_insn (\"clr%.w %-\", operands);
  1329.       operands[0] = gen_rtx (MEM, GET_MODE (operands[0]),
  1330.                  plus_constant (stack_pointer_rtx, 1));
  1331.       return \"move%.b %1,%0\";
  1332.     }
  1333.       else
  1334.     return \"move%.b %1,%0\;clr%.b %0\";
  1335.     }
  1336.   else if (GET_CODE (operands[0]) == MEM
  1337.        && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  1338.     return \"clr%.b %0\;move%.b %1,%0\";
  1339.   else
  1340.     {
  1341.       output_asm_insn (\"clr%.b %0\", operands);
  1342.       operands[0] = adj_offsettable_operand (operands[0], 1);
  1343.       return \"move%.b %1,%0\";
  1344.     }
  1345. }")
  1346.  
  1347. (define_insn ""
  1348.   [(set (match_operand:SI 0 "general_operand" "=do<>,d")
  1349.     (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
  1350.   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
  1351.   "*
  1352. {
  1353.   if (DATA_REG_P (operands[0]))
  1354.     {
  1355.       if (GET_CODE (operands[1]) == REG
  1356.       && REGNO (operands[0]) == REGNO (operands[1]))
  1357.     return \"and%.l %#0xFF,%0\";
  1358.       if (reg_mentioned_p (operands[0], operands[1]))
  1359.         return \"move%.b %1,%0\;and%.l %#0xFF,%0\";
  1360.       return \"clr%.l %0\;move%.b %1,%0\";
  1361.     }
  1362.   else if (GET_CODE (operands[0]) == MEM
  1363.        && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  1364.     {
  1365.       operands[0] = XEXP (XEXP (operands[0], 0), 0);
  1366. #ifdef MOTOROLA
  1367. #ifdef SGS
  1368.       return \"clr%.l -(%0)\;move%.b %1,3(%0)\";
  1369. #else
  1370.       return \"clr%.l -(%0)\;move%.b %1,(3,%0)\";
  1371. #endif
  1372. #else
  1373.       return \"clrl %0@-\;moveb %1,%0@(3)\";
  1374. #endif
  1375.     }
  1376.   else if (GET_CODE (operands[0]) == MEM
  1377.        && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  1378.     {
  1379.       operands[0] = XEXP (XEXP (operands[0], 0), 0);
  1380. #ifdef MOTOROLA
  1381. #ifdef SGS
  1382.       return \"clr%.l (%0)+\;move%.b %1,-1(%0)\";
  1383. #else
  1384.       return \"clr%.l (%0)+\;move%.b %1,(-1,%0)\";
  1385. #endif
  1386. #else
  1387.       return \"clrl %0@+\;moveb %1,%0@(-1)\";
  1388. #endif
  1389.     }
  1390.   else
  1391.     {
  1392.       output_asm_insn (\"clr%.l %0\", operands);
  1393.       operands[0] = adj_offsettable_operand (operands[0], 3);
  1394.       return \"move%.b %1,%0\";
  1395.     }
  1396. }")
  1397.  
  1398. ;; sign extension instructions
  1399.  
  1400. (define_insn "extendhisi2"
  1401.   [(set (match_operand:SI 0 "general_operand" "=*d,a")
  1402.     (sign_extend:SI
  1403.      (match_operand:HI 1 "nonimmediate_operand" "0,rm")))]
  1404.   ""
  1405.   "*
  1406. {
  1407.   if (ADDRESS_REG_P (operands[0]))
  1408.     return \"move%.w %1,%0\";
  1409.   return \"ext%.l %0\";
  1410. }")
  1411.  
  1412. (define_insn "extendqihi2"
  1413.   [(set (match_operand:HI 0 "general_operand" "=d")
  1414.     (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
  1415.   ""
  1416.   "ext%.w %0")
  1417.  
  1418. (define_insn "extendqisi2"
  1419.   [(set (match_operand:SI 0 "general_operand" "=d")
  1420.     (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
  1421.   "TARGET_68020"
  1422.   "extb%.l %0")
  1423.  
  1424. ;; Conversions between float and double.
  1425.  
  1426. (define_expand "extendsfdf2"
  1427.   [(set (match_operand:DF 0 "general_operand" "")
  1428.     (float_extend:DF
  1429.      (match_operand:SF 1 "general_operand" "")))]
  1430.   "TARGET_68881 || TARGET_FPA"
  1431.   "")
  1432.  
  1433. (define_insn ""
  1434.   [(set (match_operand:DF 0 "general_operand" "=x,y")
  1435.     (float_extend:DF
  1436.      (match_operand:SF 1 "general_operand" "xH,rmF")))]
  1437.   "TARGET_FPA"
  1438.   "fpstod %w1,%0")
  1439.  
  1440. (define_insn ""
  1441.   [(set (match_operand:DF 0 "general_operand" "=*fdm,f")
  1442.     (float_extend:DF
  1443.       (match_operand:SF 1 "general_operand" "f,dmF")))]
  1444.   "TARGET_68881"
  1445.   "*
  1446. {
  1447.   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
  1448.     {
  1449.       if (REGNO (operands[0]) == REGNO (operands[1]))
  1450.     {
  1451.       /* Extending float to double in an fp-reg is a no-op.
  1452.          NOTICE_UPDATE_CC has already assumed that the
  1453.          cc will be set.  So cancel what it did.  */
  1454.       cc_status = cc_prev_status;
  1455.       return \"\";
  1456.     }
  1457.       return \"f%&move%.x %1,%0\";
  1458.     }
  1459.   if (FP_REG_P (operands[0]))
  1460.     return \"f%&move%.s %f1,%0\";
  1461.   if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
  1462.     {
  1463.       output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands);
  1464.       operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1465.       return \"move%.l %+,%0\";
  1466.     }
  1467.   return \"fmove%.d %f1,%0\";
  1468. }")
  1469.  
  1470. ;; This cannot output into an f-reg because there is no way to be
  1471. ;; sure of truncating in that case.
  1472. ;; But on the Sun FPA, we can be sure.
  1473. (define_expand "truncdfsf2"
  1474.   [(set (match_operand:SF 0 "general_operand" "")
  1475.     (float_truncate:SF
  1476.       (match_operand:DF 1 "general_operand" "")))]
  1477.   "TARGET_68881 || TARGET_FPA"
  1478.   "")
  1479.  
  1480. (define_insn ""
  1481.   [(set (match_operand:SF 0 "general_operand" "=x,y")
  1482.     (float_truncate:SF
  1483.       (match_operand:DF 1 "general_operand" "xH,rmF")))]
  1484.   "TARGET_FPA"
  1485.   "fpdtos %y1,%0")
  1486.  
  1487. ;; On the '040 we can truncate in a register accurately and easily.
  1488. (define_insn ""
  1489.   [(set (match_operand:SF 0 "general_operand" "=f")
  1490.     (float_truncate:SF
  1491.       (match_operand:DF 1 "general_operand" "fmG")))]
  1492.   "TARGET_68040_ONLY"
  1493.   "*
  1494. {
  1495.   if (FP_REG_P (operands[1]))
  1496.     return \"fsmove%.x %1,%0\";
  1497.   return \"fsmove%.d %f1,%0\";
  1498. }")
  1499.  
  1500. (define_insn ""
  1501.   [(set (match_operand:SF 0 "general_operand" "=dm")
  1502.     (float_truncate:SF
  1503.       (match_operand:DF 1 "general_operand" "f")))]
  1504.   "TARGET_68881"
  1505.   "fmove%.s %f1,%0")
  1506.  
  1507. ;; Conversion between fixed point and floating point.
  1508. ;; Note that among the fix-to-float insns
  1509. ;; the ones that start with SImode come first.
  1510. ;; That is so that an operand that is a CONST_INT
  1511. ;; (and therefore lacks a specific machine mode).
  1512. ;; will be recognized as SImode (which is always valid)
  1513. ;; rather than as QImode or HImode.
  1514.  
  1515. (define_expand "floatsisf2"
  1516.   [(set (match_operand:SF 0 "general_operand" "")
  1517.     (float:SF (match_operand:SI 1 "general_operand" "")))]
  1518.   "TARGET_68881 || TARGET_FPA"
  1519.   "")
  1520.  
  1521. (define_insn ""
  1522.   [(set (match_operand:SF 0 "general_operand" "=y,x")
  1523.     (float:SF (match_operand:SI 1 "general_operand" "rmi,x")))]
  1524.   "TARGET_FPA"
  1525.   "fpltos %1,%0")
  1526.  
  1527. (define_insn ""
  1528.   [(set (match_operand:SF 0 "general_operand" "=f")
  1529.     (float:SF (match_operand:SI 1 "general_operand" "dmi")))]
  1530.   "TARGET_68881"
  1531.   "f%$move%.l %1,%0")
  1532.  
  1533. (define_expand "floatsidf2"
  1534.   [(set (match_operand:DF 0 "general_operand" "")
  1535.     (float:DF (match_operand:SI 1 "general_operand" "")))]
  1536.   "TARGET_68881 || TARGET_FPA"
  1537.   "")
  1538.  
  1539. (define_insn ""
  1540.   [(set (match_operand:DF 0 "general_operand" "=y,x")
  1541.     (float:DF (match_operand:SI 1 "general_operand" "rmi,x")))]
  1542.   "TARGET_FPA"
  1543.   "fpltod %1,%0")
  1544.  
  1545. (define_insn ""
  1546.   [(set (match_operand:DF 0 "general_operand" "=f")
  1547.     (float:DF (match_operand:SI 1 "general_operand" "dmi")))]
  1548.   "TARGET_68881"
  1549.   "f%&move%.l %1,%0")
  1550.  
  1551. (define_insn "floathisf2"
  1552.   [(set (match_operand:SF 0 "general_operand" "=f")
  1553.     (float:SF (match_operand:HI 1 "general_operand" "dmn")))]
  1554.   "TARGET_68881"
  1555.   "f%$move%.w %1,%0")
  1556.  
  1557. (define_insn "floathidf2"
  1558.   [(set (match_operand:DF 0 "general_operand" "=f")
  1559.     (float:DF (match_operand:HI 1 "general_operand" "dmn")))]
  1560.   "TARGET_68881"
  1561.   "fmove%.w %1,%0")
  1562.  
  1563. (define_insn "floatqisf2"
  1564.   [(set (match_operand:SF 0 "general_operand" "=f")
  1565.     (float:SF (match_operand:QI 1 "general_operand" "dmn")))]
  1566.   "TARGET_68881"
  1567.   "fmove%.b %1,%0")
  1568.  
  1569. (define_insn "floatqidf2"
  1570.   [(set (match_operand:DF 0 "general_operand" "=f")
  1571.     (float:DF (match_operand:QI 1 "general_operand" "dmn")))]
  1572.   "TARGET_68881"
  1573.   "f%&move%.b %1,%0")
  1574.  
  1575. ;; New routines to convert floating-point values to integers
  1576. ;; to be used on the '040.  These should be faster than trapping
  1577. ;; into the kernel to emulate fintrz.  They should also be faster
  1578. ;; than calling the subroutines fixsfsi() or fixdfsi().
  1579.  
  1580. (define_insn "fix_truncdfsi2"
  1581.   [(set (match_operand:SI 0 "general_operand" "=dm")
  1582.     (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
  1583.    (clobber (match_scratch:SI 2 "=d"))
  1584.    (clobber (match_scratch:SI 3 "=d"))]
  1585.   "TARGET_68040"
  1586.   "*
  1587. {
  1588.   CC_STATUS_INIT;
  1589.   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,%!\";
  1590. }")
  1591.  
  1592. (define_insn "fix_truncdfhi2"
  1593.   [(set (match_operand:HI 0 "general_operand" "=dm")
  1594.     (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
  1595.    (clobber (match_scratch:SI 2 "=d"))
  1596.    (clobber (match_scratch:SI 3 "=d"))]
  1597.   "TARGET_68040"
  1598.   "*
  1599. {
  1600.   CC_STATUS_INIT;
  1601.   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,%!\";
  1602. }")
  1603.  
  1604. (define_insn "fix_truncdfqi2"
  1605.   [(set (match_operand:QI 0 "general_operand" "=dm")
  1606.     (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
  1607.    (clobber (match_scratch:SI 2 "=d"))
  1608.    (clobber (match_scratch:SI 3 "=d"))]
  1609.   "TARGET_68040"
  1610.   "*
  1611. {
  1612.   CC_STATUS_INIT;
  1613.   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,%!\";
  1614. }")
  1615.  
  1616. ;; Convert a float to a float whose value is an integer.
  1617. ;; This is the first stage of converting it to an integer type.
  1618.  
  1619. (define_insn "ftruncdf2"
  1620.   [(set (match_operand:DF 0 "general_operand" "=f")
  1621.     (fix:DF (match_operand:DF 1 "general_operand" "fFm")))]
  1622.   "TARGET_68881 && !TARGET_68040"
  1623.   "*
  1624. {
  1625.   if (FP_REG_P (operands[1]))
  1626.     return \"fintrz%.x %f1,%0\";
  1627.   return \"fintrz%.d %f1,%0\";
  1628. }")
  1629.  
  1630. (define_insn "ftruncsf2"
  1631.   [(set (match_operand:SF 0 "general_operand" "=f")
  1632.     (fix:SF (match_operand:SF 1 "general_operand" "dfFm")))]
  1633.   "TARGET_68881 && !TARGET_68040"
  1634.   "*
  1635. {
  1636.   if (FP_REG_P (operands[1]))
  1637.     return \"fintrz%.x %f1,%0\";
  1638.   return \"fintrz%.s %f1,%0\";
  1639. }")
  1640.  
  1641. ;; Convert a float whose value is an integer
  1642. ;; to an actual integer.  Second stage of converting float to integer type.
  1643. (define_insn "fixsfqi2"
  1644.   [(set (match_operand:QI 0 "general_operand" "=dm")
  1645.     (fix:QI (match_operand:SF 1 "general_operand" "f")))]
  1646.   "TARGET_68881"
  1647.   "fmove%.b %1,%0")
  1648.  
  1649. (define_insn "fixsfhi2"
  1650.   [(set (match_operand:HI 0 "general_operand" "=dm")
  1651.     (fix:HI (match_operand:SF 1 "general_operand" "f")))]
  1652.   "TARGET_68881"
  1653.   "fmove%.w %1,%0")
  1654.  
  1655. (define_insn "fixsfsi2"
  1656.   [(set (match_operand:SI 0 "general_operand" "=dm")
  1657.     (fix:SI (match_operand:SF 1 "general_operand" "f")))]
  1658.   "TARGET_68881"
  1659.   "fmove%.l %1,%0")
  1660.  
  1661. (define_insn "fixdfqi2"
  1662.   [(set (match_operand:QI 0 "general_operand" "=dm")
  1663.     (fix:QI (match_operand:DF 1 "general_operand" "f")))]
  1664.   "TARGET_68881"
  1665.   "fmove%.b %1,%0")
  1666.  
  1667. (define_insn "fixdfhi2"
  1668.   [(set (match_operand:HI 0 "general_operand" "=dm")
  1669.     (fix:HI (match_operand:DF 1 "general_operand" "f")))]
  1670.   "TARGET_68881"
  1671.   "fmove%.w %1,%0")
  1672.  
  1673. (define_insn "fixdfsi2"
  1674.   [(set (match_operand:SI 0 "general_operand" "=dm")
  1675.     (fix:SI (match_operand:DF 1 "general_operand" "f")))]
  1676.   "TARGET_68881"
  1677.   "fmove%.l %1,%0")
  1678.  
  1679. ;; Convert a float to an integer.
  1680. ;; On the Sun FPA, this is done in one step.
  1681.  
  1682. (define_insn ""
  1683.   [(set (match_operand:SI 0 "general_operand" "=x,y")
  1684.     (fix:SI (fix:SF (match_operand:SF 1 "general_operand" "xH,rmF"))))]
  1685.   "TARGET_FPA"
  1686.   "fpstol %w1,%0")
  1687.  
  1688. (define_insn ""
  1689.   [(set (match_operand:SI 0 "general_operand" "=x,y")
  1690.     (fix:SI (fix:DF (match_operand:DF 1 "general_operand" "xH,rmF"))))]
  1691.   "TARGET_FPA"
  1692.   "fpdtol %y1,%0")
  1693.  
  1694. ;; add instructions
  1695.  
  1696. ;; Note that the middle two alternatives are near-duplicates
  1697. ;; in order to handle insns generated by reload.
  1698. ;; This is needed since they are not themselves reloaded,
  1699. ;; so commutativity won't apply to them.
  1700. (define_insn "addsi3"
  1701.   [(set (match_operand:SI 0 "general_operand" "=m,?a,?a,r")
  1702.     (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0")
  1703.          (match_operand:SI 2 "general_operand" "dIKLs,rJK,a,mrIKLs")))]
  1704.   ""
  1705.   "*
  1706. {
  1707.   if (! operands_match_p (operands[0], operands[1]))
  1708.     {
  1709.       if (!ADDRESS_REG_P (operands[1]))
  1710.     {
  1711.       rtx tmp = operands[1];
  1712.  
  1713.       operands[1] = operands[2];
  1714.       operands[2] = tmp;
  1715.     }
  1716.  
  1717.       /* These insns can result from reloads to access
  1718.      stack slots over 64k from the frame pointer.  */
  1719.       if (((GET_CODE (operands[2]) == CONST_INT
  1720.        && INTVAL (operands[2]) + 0x8000 >= (unsigned) 0x10000))
  1721.       || (flag_pic == 4 && operands[1] == pic_offset_table_rtx))
  1722.         return \"move%.l %2,%0\;add%.l %1,%0\";
  1723. #ifdef SGS
  1724.       if (GET_CODE (operands[2]) == REG)
  1725.     return \"lea 0(%1,%2.l),%0\";
  1726.       else
  1727.     return \"lea %c2(%1),%0\";
  1728. #else /* not SGS */
  1729. #ifdef MOTOROLA
  1730.       if (GET_CODE (operands[2]) == REG)
  1731.     return \"lea (%1,%2.l),%0\";
  1732.       else
  1733.     return \"lea (%c2,%1),%0\";
  1734. #else /* not MOTOROLA (MIT syntax) */
  1735.       if (GET_CODE (operands[2]) == REG)
  1736.     return \"lea %1@(0,%2:l),%0\";
  1737.       else
  1738.     return \"lea %1@(%c2),%0\";
  1739. #endif /* not MOTOROLA */
  1740. #endif /* not SGS */
  1741.     }
  1742.   if (GET_CODE (operands[2]) == CONST_INT)
  1743.     {
  1744. #ifndef NO_ADDSUB_Q
  1745.       if (INTVAL (operands[2]) > 0
  1746.       && INTVAL (operands[2]) <= 8)
  1747.     return (ADDRESS_REG_P (operands[0])
  1748.         ? \"addq%.w %2,%0\"
  1749.         : \"addq%.l %2,%0\");
  1750.       if (INTVAL (operands[2]) < 0
  1751.       && INTVAL (operands[2]) >= -8)
  1752.         {
  1753.       operands[2] = gen_rtx (CONST_INT, VOIDmode,
  1754.                      - INTVAL (operands[2]));
  1755.       return (ADDRESS_REG_P (operands[0])
  1756.           ? \"subq%.w %2,%0\"
  1757.           : \"subq%.l %2,%0\");
  1758.     }
  1759.       /* On everything except the 68000 it is faster to use two
  1760.      addqw instructions to add a small integer (8 < N <= 16)
  1761.      to an address register.  Likewise for subqw.*/
  1762.       if (INTVAL (operands[2]) > 8
  1763.       && INTVAL (operands[2]) <= 16
  1764.       && ADDRESS_REG_P (operands[0])
  1765.       && TARGET_68020) 
  1766.     {
  1767.       operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8);
  1768.       return \"addq%.w %#8,%0\;addq%.w %2,%0\";
  1769.     }
  1770.       if (INTVAL (operands[2]) < -8
  1771.       && INTVAL (operands[2]) >= -16
  1772.       && ADDRESS_REG_P (operands[0])
  1773.       && TARGET_68020) 
  1774.     {
  1775.       operands[2] = gen_rtx (CONST_INT, VOIDmode, 
  1776.                   - INTVAL (operands[2]) - 8);
  1777.       return \"subq%.w %#8,%0\;subq%.w %2,%0\";
  1778.     }
  1779. #endif
  1780.       if (ADDRESS_REG_P (operands[0])
  1781.       && INTVAL (operands[2]) >= -0x8000
  1782.       && INTVAL (operands[2]) < 0x8000)
  1783.     return \"add%.w %2,%0\";
  1784.     }
  1785.   return \"add%.l %2,%0\";
  1786. }")
  1787.  
  1788. (define_insn ""
  1789.   [(set (match_operand:SI 0 "general_operand" "=a")
  1790.     (plus:SI (match_operand:SI 1 "general_operand" "0")
  1791.          (sign_extend:SI
  1792.           (match_operand:HI 2 "nonimmediate_operand" "rm"))))]
  1793.   ""
  1794.   "add%.w %2,%0")
  1795.  
  1796. (define_insn "addhi3"
  1797.   [(set (match_operand:HI 0 "general_operand" "=m,r")
  1798.     (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
  1799.          (match_operand:HI 2 "general_operand" "dn,rmn")))]
  1800.   ""
  1801.   "*
  1802. {
  1803. #ifndef NO_ADDSUB_Q
  1804.   if (GET_CODE (operands[2]) == CONST_INT)
  1805.     {
  1806.       /* If the constant would be a negative number when interpreted as
  1807.      HImode, make it negative.  This is usually, but not always, done
  1808.      elsewhere in the compiler.  First check for constants out of range,
  1809.      which could confuse us.  */
  1810.  
  1811.       if (INTVAL (operands[2]) >= 32768)
  1812.     operands[2] = gen_rtx (CONST_INT, VOIDmode,
  1813.                    INTVAL (operands[2]) - 65536);
  1814.  
  1815.       if (INTVAL (operands[2]) > 0
  1816.       && INTVAL (operands[2]) <= 8)
  1817.     return \"addq%.w %2,%0\";
  1818.       if (INTVAL (operands[2]) < 0
  1819.       && INTVAL (operands[2]) >= -8)
  1820.     {
  1821.       operands[2] = gen_rtx (CONST_INT, VOIDmode,
  1822.                      - INTVAL (operands[2]));
  1823.       return \"subq%.w %2,%0\";
  1824.     }
  1825.       /* On everything except the 68000 it is faster to use two
  1826.      addqw instructions to add a small integer (8 < N <= 16)
  1827.      to an address register.  Likewise for subqw. */
  1828.       if (INTVAL (operands[2]) > 8
  1829.       && INTVAL (operands[2]) <= 16
  1830.       && ADDRESS_REG_P (operands[0])
  1831.       && TARGET_68020) 
  1832.     {
  1833.       operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8);
  1834.       return \"addq%.w %#8,%0\;addq%.w %2,%0\";
  1835.     }
  1836.       if (INTVAL (operands[2]) < -8
  1837.       && INTVAL (operands[2]) >= -16
  1838.       && ADDRESS_REG_P (operands[0])
  1839.       && TARGET_68020) 
  1840.     {
  1841.       operands[2] = gen_rtx (CONST_INT, VOIDmode, 
  1842.                  - INTVAL (operands[2]) - 8);
  1843.       return \"subq%.w %#8,%0\;subq%.w %2,%0\";
  1844.     }
  1845.     }
  1846. #endif
  1847.   return \"add%.w %2,%0\";
  1848. }")
  1849.  
  1850. ;; These insns must use MATCH_DUP instead of the more expected
  1851. ;; use of a matching constraint because the "output" here is also
  1852. ;; an input, so you can't use the matching constraint.  That also means
  1853. ;; that you can't use the "%", so you need patterns with the matched
  1854. ;; operand in both positions.
  1855.  
  1856. (define_insn ""
  1857.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  1858.     (plus:HI (match_dup 0)
  1859.          (match_operand:HI 1 "general_operand" "dn,rmn")))]
  1860.   ""
  1861.   "*
  1862. {
  1863. #ifndef NO_ADDSUB_Q
  1864.   if (GET_CODE (operands[1]) == CONST_INT)
  1865.     {
  1866.       /* If the constant would be a negative number when interpreted as
  1867.      HImode, make it negative.  This is usually, but not always, done
  1868.      elsewhere in the compiler.  First check for constants out of range,
  1869.      which could confuse us.  */
  1870.  
  1871.       if (INTVAL (operands[1]) >= 32768)
  1872.     operands[1] = gen_rtx (CONST_INT, VOIDmode,
  1873.                    INTVAL (operands[1]) - 65536);
  1874.  
  1875.       if (INTVAL (operands[1]) > 0
  1876.       && INTVAL (operands[1]) <= 8)
  1877.     return \"addq%.w %1,%0\";
  1878.       if (INTVAL (operands[1]) < 0
  1879.       && INTVAL (operands[1]) >= -8)
  1880.     {
  1881.       operands[1] = gen_rtx (CONST_INT, VOIDmode,
  1882.                      - INTVAL (operands[1]));
  1883.       return \"subq%.w %1,%0\";
  1884.     }
  1885.       /* On everything except the 68000 it is faster to use two
  1886.      addqw instructions to add a small integer (8 < N <= 16)
  1887.      to an address register.  Likewise for subqw. */
  1888.       if (INTVAL (operands[1]) > 8
  1889.       && INTVAL (operands[1]) <= 16
  1890.       && ADDRESS_REG_P (operands[0])
  1891.       && TARGET_68020) 
  1892.     {
  1893.       operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8);
  1894.       return \"addq%.w %#8,%0\;addq%.w %1,%0\";
  1895.     }
  1896.       if (INTVAL (operands[1]) < -8
  1897.       && INTVAL (operands[1]) >= -16
  1898.       && ADDRESS_REG_P (operands[0])
  1899.       && TARGET_68020) 
  1900.     {
  1901.       operands[1] = gen_rtx (CONST_INT, VOIDmode, 
  1902.                  - INTVAL (operands[1]) - 8);
  1903.       return \"subq%.w %#8,%0\;subq%.w %1,%0\";
  1904.     }
  1905.     }
  1906. #endif
  1907.   return \"add%.w %1,%0\";
  1908. }")
  1909.  
  1910. (define_insn ""
  1911.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  1912.     (plus:HI (match_operand:HI 1 "general_operand" "dn,rmn")
  1913.          (match_dup 0)))]
  1914.   ""
  1915.   "*
  1916. {
  1917. #ifndef NO_ADDSUB_Q
  1918.   if (GET_CODE (operands[1]) == CONST_INT)
  1919.     {
  1920.       /* If the constant would be a negative number when interpreted as
  1921.      HImode, make it negative.  This is usually, but not always, done
  1922.      elsewhere in the compiler.  First check for constants out of range,
  1923.      which could confuse us.  */
  1924.  
  1925.       if (INTVAL (operands[1]) >= 32768)
  1926.     operands[1] = gen_rtx (CONST_INT, VOIDmode,
  1927.                    INTVAL (operands[1]) - 65536);
  1928.  
  1929.       if (INTVAL (operands[1]) > 0
  1930.       && INTVAL (operands[1]) <= 8)
  1931.     return \"addq%.w %1,%0\";
  1932.       if (INTVAL (operands[1]) < 0
  1933.       && INTVAL (operands[1]) >= -8)
  1934.     {
  1935.       operands[1] = gen_rtx (CONST_INT, VOIDmode,
  1936.                      - INTVAL (operands[1]));
  1937.       return \"subq%.w %1,%0\";
  1938.     }
  1939.       /* On everything except the 68000 it is faster to use two
  1940.      addqw instructions to add a small integer (8 < N <= 16)
  1941.      to an address register.  Likewise for subqw. */
  1942.       if (INTVAL (operands[1]) > 8
  1943.       && INTVAL (operands[1]) <= 16
  1944.       && ADDRESS_REG_P (operands[0])
  1945.       && TARGET_68020) 
  1946.     {
  1947.       operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8);
  1948.       return \"addq%.w %#8,%0\;addq%.w %1,%0\";
  1949.     }
  1950.       if (INTVAL (operands[1]) < -8
  1951.       && INTVAL (operands[1]) >= -16
  1952.       && ADDRESS_REG_P (operands[0])
  1953.       && TARGET_68020) 
  1954.     {
  1955.       operands[1] = gen_rtx (CONST_INT, VOIDmode, 
  1956.                  - INTVAL (operands[1]) - 8);
  1957.       return \"subq%.w %#8,%0\;subq%.w %1,%0\";
  1958.     }
  1959.     }
  1960. #endif
  1961.   return \"add%.w %1,%0\";
  1962. }")
  1963.  
  1964. (define_insn "addqi3"
  1965.   [(set (match_operand:QI 0 "general_operand" "=m,d")
  1966.     (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
  1967.          (match_operand:QI 2 "general_operand" "dn,dmn")))]
  1968.   ""
  1969.   "*
  1970. {
  1971. #ifndef NO_ADDSUB_Q
  1972.   if (GET_CODE (operands[2]) == CONST_INT)
  1973.     {
  1974.       if (INTVAL (operands[2]) >= 128)
  1975.     operands[2] = gen_rtx (CONST_INT, VOIDmode,
  1976.                    INTVAL (operands[2]) - 256);
  1977.  
  1978.       if (INTVAL (operands[2]) > 0
  1979.       && INTVAL (operands[2]) <= 8)
  1980.     return \"addq%.b %2,%0\";
  1981.       if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
  1982.        {
  1983.      operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]));
  1984.      return \"subq%.b %2,%0\";
  1985.        }
  1986.     }
  1987. #endif
  1988.   return \"add%.b %2,%0\";
  1989. }")
  1990.  
  1991. (define_insn ""
  1992.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  1993.     (plus:QI (match_dup 0)
  1994.          (match_operand:QI 1 "general_operand" "dn,dmn")))]
  1995.   ""
  1996.   "*
  1997. {
  1998. #ifndef NO_ADDSUB_Q
  1999.   if (GET_CODE (operands[1]) == CONST_INT)
  2000.     {
  2001.       if (INTVAL (operands[1]) >= 128)
  2002.     operands[1] = gen_rtx (CONST_INT, VOIDmode,
  2003.                    INTVAL (operands[1]) - 256);
  2004.  
  2005.       if (INTVAL (operands[1]) > 0
  2006.       && INTVAL (operands[1]) <= 8)
  2007.     return \"addq%.b %1,%0\";
  2008.       if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
  2009.        {
  2010.      operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]));
  2011.      return \"subq%.b %1,%0\";
  2012.        }
  2013.     }
  2014. #endif
  2015.   return \"add%.b %1,%0\";
  2016. }")
  2017.  
  2018. (define_insn ""
  2019.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  2020.     (plus:QI (match_operand:QI 1 "general_operand" "dn,dmn")
  2021.          (match_dup 0)))]
  2022.   ""
  2023.   "*
  2024. {
  2025. #ifndef NO_ADDSUB_Q
  2026.   if (GET_CODE (operands[1]) == CONST_INT)
  2027.     {
  2028.       if (INTVAL (operands[1]) >= 128)
  2029.     operands[1] = gen_rtx (CONST_INT, VOIDmode,
  2030.                    INTVAL (operands[1]) - 256);
  2031.  
  2032.       if (INTVAL (operands[1]) > 0
  2033.       && INTVAL (operands[1]) <= 8)
  2034.     return \"addq%.b %1,%0\";
  2035.       if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
  2036.        {
  2037.      operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]));
  2038.      return \"subq%.b %1,%0\";
  2039.        }
  2040.     }
  2041. #endif
  2042.   return \"add%.b %1,%0\";
  2043. }")
  2044.  
  2045. (define_expand "adddf3"
  2046.   [(set (match_operand:DF 0 "general_operand" "")
  2047.     (plus:DF (match_operand:DF 1 "general_operand" "")
  2048.          (match_operand:DF 2 "general_operand" "")))]
  2049.   "TARGET_68881 || TARGET_FPA"
  2050.   "")
  2051.  
  2052. (define_insn ""
  2053.   [(set (match_operand:DF 0 "general_operand" "=x,y")
  2054.     (plus:DF (match_operand:DF 1 "general_operand" "%xH,y")
  2055.          (match_operand:DF 2 "general_operand" "xH,dmF")))]
  2056.   "TARGET_FPA"
  2057.   "*
  2058. {
  2059.   if (rtx_equal_p (operands[0], operands[1]))
  2060.     return \"fpadd%.d %y2,%0\";
  2061.   if (rtx_equal_p (operands[0], operands[2]))
  2062.     return \"fpadd%.d %y1,%0\";
  2063.   if (which_alternative == 0)
  2064.     return \"fpadd3%.d %w2,%w1,%0\";
  2065.   return \"fpadd3%.d %x2,%x1,%0\";
  2066. }")
  2067.  
  2068. (define_insn ""
  2069.   [(set (match_operand:DF 0 "general_operand" "=f")
  2070.     (plus:DF (match_operand:DF 1 "general_operand" "%0")
  2071.          (match_operand:DF 2 "general_operand" "fmG")))]
  2072.   "TARGET_68881"
  2073.   "*
  2074. {
  2075.   if (REG_P (operands[2]))
  2076.     return \"f%&add%.x %2,%0\";
  2077.   return \"f%&add%.d %f2,%0\";
  2078. }")
  2079.  
  2080. (define_expand "addsf3"
  2081.   [(set (match_operand:SF 0 "general_operand" "")
  2082.     (plus:SF (match_operand:SF 1 "general_operand" "")
  2083.          (match_operand:SF 2 "general_operand" "")))]
  2084.   "TARGET_68881 || TARGET_FPA"
  2085.   "")
  2086.  
  2087. (define_insn ""
  2088.   [(set (match_operand:SF 0 "general_operand" "=x,y")
  2089.     (plus:SF (match_operand:SF 1 "general_operand" "%xH,y")
  2090.          (match_operand:SF 2 "general_operand" "xH,rmF")))]
  2091.   "TARGET_FPA"
  2092.   "*
  2093. {
  2094.   if (rtx_equal_p (operands[0], operands[1]))
  2095.     return \"fpadd%.s %w2,%0\";
  2096.   if (rtx_equal_p (operands[0], operands[2]))
  2097.     return \"fpadd%.s %w1,%0\";
  2098.   if (which_alternative == 0)
  2099.     return \"fpadd3%.s %w2,%w1,%0\";
  2100.   return \"fpadd3%.s %2,%1,%0\";
  2101. }")
  2102.  
  2103. (define_insn ""
  2104.   [(set (match_operand:SF 0 "general_operand" "=f")
  2105.     (plus:SF (match_operand:SF 1 "general_operand" "%0")
  2106.          (match_operand:SF 2 "general_operand" "fdmF")))]
  2107.   "TARGET_68881"
  2108.   "*
  2109. {
  2110.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  2111.     return \"f%$add%.x %2,%0\";
  2112.   return \"f%$add%.s %f2,%0\";
  2113. }")
  2114.  
  2115. ;; subtract instructions
  2116.  
  2117. (define_insn "subsi3"
  2118.   [(set (match_operand:SI 0 "general_operand" "=m,r,!a,?d")
  2119.     (minus:SI (match_operand:SI 1 "general_operand" "0,0,a,mrIKs")
  2120.           (match_operand:SI 2 "general_operand" "dIKs,mrIKs,J,0")))]
  2121.   ""
  2122.   "*
  2123. {
  2124.   if (! operands_match_p (operands[0], operands[1]))
  2125.     {
  2126.       if (operands_match_p (operands[0], operands[2]))
  2127.     {
  2128. #ifndef NO_ADDSUB_Q
  2129.       if (GET_CODE (operands[1]) == CONST_INT)
  2130.         {
  2131.           if (INTVAL (operands[1]) > 0
  2132.           && INTVAL (operands[1]) <= 8)
  2133.         return \"subq%.l %1,%0\;neg%.l %0\";
  2134.         }
  2135. #endif
  2136.       return \"sub%.l %1,%0\;neg%.l %0\";
  2137.     }
  2138.       /* This case is matched by J, but negating -0x8000
  2139.          in an lea would give an invalid displacement.
  2140.      So do this specially.  */
  2141.       if (INTVAL (operands[2]) == -0x8000)
  2142.     return \"move%.l %1,%0\;sub%.l %2,%0\";
  2143. #ifdef SGS
  2144.       return \"lea %n2(%1),%0\";
  2145. #else
  2146. #ifdef MOTOROLA
  2147.       return \"lea (%n2,%1),%0\";
  2148. #else /* not MOTOROLA (MIT syntax) */
  2149.       return \"lea %1@(%n2),%0\";
  2150. #endif /* not MOTOROLA */
  2151. #endif /* not SGS */
  2152.     }
  2153.   if (GET_CODE (operands[2]) == CONST_INT)
  2154.     {
  2155. #ifndef NO_ADDSUB_Q
  2156.       if (INTVAL (operands[2]) > 0
  2157.       && INTVAL (operands[2]) <= 8)
  2158.     return \"subq%.l %2,%0\";
  2159.       /* Using two subqw for 8 < N <= 16 being subtracted from an
  2160.      address register is faster on all but 68000 */
  2161.       if (INTVAL (operands[2]) > 8
  2162.       && INTVAL (operands[2]) <= 16
  2163.       && ADDRESS_REG_P (operands[0])
  2164.       && TARGET_68020)
  2165.     {
  2166.       operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8);
  2167.       return \"subq%.w %#8,%0\;subq%.w %2,%0\";
  2168.     }
  2169. #endif
  2170.       if (ADDRESS_REG_P (operands[0])
  2171.       && INTVAL (operands[2]) >= -0x8000
  2172.       && INTVAL (operands[2]) < 0x8000)
  2173.     return \"sub%.w %2,%0\";
  2174.     }
  2175.   return \"sub%.l %2,%0\";
  2176. }")
  2177.  
  2178. (define_insn ""
  2179.   [(set (match_operand:SI 0 "general_operand" "=a")
  2180.     (minus:SI (match_operand:SI 1 "general_operand" "0")
  2181.           (sign_extend:SI
  2182.            (match_operand:HI 2 "nonimmediate_operand" "rm"))))]
  2183.   ""
  2184.   "sub%.w %2,%0")
  2185.  
  2186. (define_insn "subhi3"
  2187.   [(set (match_operand:HI 0 "general_operand" "=m,r")
  2188.     (minus:HI (match_operand:HI 1 "general_operand" "0,0")
  2189.           (match_operand:HI 2 "general_operand" "dn,rmn")))]
  2190.   ""
  2191.   "sub%.w %2,%0")
  2192.  
  2193. (define_insn ""
  2194.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  2195.     (minus:HI (match_dup 0)
  2196.           (match_operand:HI 1 "general_operand" "dn,rmn")))]
  2197.   ""
  2198.   "sub%.w %1,%0")
  2199.  
  2200. (define_insn "subqi3"
  2201.   [(set (match_operand:QI 0 "general_operand" "=m,d")
  2202.     (minus:QI (match_operand:QI 1 "general_operand" "0,0")
  2203.           (match_operand:QI 2 "general_operand" "dn,dmn")))]
  2204.   ""
  2205.   "sub%.b %2,%0")
  2206.  
  2207. (define_insn ""
  2208.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  2209.     (minus:QI (match_dup 0)
  2210.           (match_operand:QI 1 "general_operand" "dn,dmn")))]
  2211.   ""
  2212.   "sub%.b %1,%0")
  2213.  
  2214. (define_expand "subdf3"
  2215.   [(set (match_operand:DF 0 "general_operand" "")
  2216.     (minus:DF (match_operand:DF 1 "general_operand" "")
  2217.           (match_operand:DF 2 "general_operand" "")))]
  2218.   "TARGET_68881 || TARGET_FPA"
  2219.   "")
  2220.  
  2221. (define_insn ""
  2222.   [(set (match_operand:DF 0 "general_operand" "=x,y,y")
  2223.     (minus:DF (match_operand:DF 1 "general_operand" "xH,y,dmF")
  2224.           (match_operand:DF 2 "general_operand" "xH,dmF,0")))]
  2225.   "TARGET_FPA"
  2226.   "*
  2227. {
  2228.   if (rtx_equal_p (operands[0], operands[2]))
  2229.     return \"fprsub%.d %y1,%0\";
  2230.   if (rtx_equal_p (operands[0], operands[1]))
  2231.     return \"fpsub%.d %y2,%0\";
  2232.   if (which_alternative == 0)
  2233.     return \"fpsub3%.d %w2,%w1,%0\";
  2234.   return \"fpsub3%.d %x2,%x1,%0\";
  2235. }")
  2236.  
  2237. (define_insn ""
  2238.   [(set (match_operand:DF 0 "general_operand" "=f")
  2239.     (minus:DF (match_operand:DF 1 "general_operand" "0")
  2240.           (match_operand:DF 2 "general_operand" "fmG")))]
  2241.   "TARGET_68881"
  2242.   "*
  2243. {
  2244.   if (REG_P (operands[2]))
  2245.     return \"f%&sub%.x %2,%0\";
  2246.   return \"f%&sub%.d %f2,%0\";
  2247. }")
  2248.  
  2249. (define_expand "subsf3"
  2250.   [(set (match_operand:SF 0 "general_operand" "")
  2251.     (minus:SF (match_operand:SF 1 "general_operand" "")
  2252.           (match_operand:SF 2 "general_operand" "")))]
  2253.   "TARGET_68881 || TARGET_FPA"
  2254.   "")
  2255.  
  2256. (define_insn ""
  2257.   [(set (match_operand:SF 0 "general_operand" "=x,y,y")
  2258.     (minus:SF (match_operand:SF 1 "general_operand" "xH,y,rmF")
  2259.           (match_operand:SF 2 "general_operand" "xH,rmF,0")))]
  2260.   "TARGET_FPA"
  2261.   "*
  2262. {
  2263.   if (rtx_equal_p (operands[0], operands[2]))
  2264.     return \"fprsub%.s %w1,%0\";
  2265.   if (rtx_equal_p (operands[0], operands[1]))
  2266.     return \"fpsub%.s %w2,%0\";
  2267.   if (which_alternative == 0)
  2268.     return \"fpsub3%.s %w2,%w1,%0\";
  2269.   return \"fpsub3%.s %2,%1,%0\";
  2270. }")
  2271.  
  2272. (define_insn ""
  2273.   [(set (match_operand:SF 0 "general_operand" "=f")
  2274.     (minus:SF (match_operand:SF 1 "general_operand" "0")
  2275.           (match_operand:SF 2 "general_operand" "fdmF")))]
  2276.   "TARGET_68881"
  2277.   "*
  2278. {
  2279.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  2280.     return \"f%$sub%.x %2,%0\";
  2281.   return \"f%$sub%.s %f2,%0\";
  2282. }")
  2283.  
  2284. ;; multiply instructions
  2285.  
  2286. (define_insn "mulhi3"
  2287.   [(set (match_operand:HI 0 "general_operand" "=d")
  2288.     (mult:HI (match_operand:HI 1 "general_operand" "%0")
  2289.          (match_operand:HI 2 "general_operand" "dmn")))]
  2290.   ""
  2291.   "*
  2292. {
  2293. #if defined(MOTOROLA) && !defined(CRDS)
  2294.   return \"muls%.w %2,%0\";
  2295. #else
  2296.   return \"muls %2,%0\";
  2297. #endif
  2298. }")
  2299.  
  2300. (define_insn "mulhisi3"
  2301.   [(set (match_operand:SI 0 "general_operand" "=d")
  2302.     (mult:SI (sign_extend:SI
  2303.           (match_operand:HI 1 "nonimmediate_operand" "%0"))
  2304.          (sign_extend:SI
  2305.           (match_operand:HI 2 "nonimmediate_operand" "dm"))))]
  2306.   ""
  2307.   "*
  2308. {
  2309. #if defined(MOTOROLA) && !defined(CRDS)
  2310.   return \"muls%.w %2,%0\";
  2311. #else
  2312.   return \"muls %2,%0\";
  2313. #endif
  2314. }")
  2315.  
  2316. (define_insn ""
  2317.   [(set (match_operand:SI 0 "general_operand" "=d")
  2318.     (mult:SI (sign_extend:SI
  2319.           (match_operand:HI 1 "nonimmediate_operand" "%0"))
  2320.          (match_operand:SI 2 "const_int_operand" "n")))]
  2321.   ""
  2322.   "*
  2323. {
  2324. #if defined(MOTOROLA) && !defined(CRDS)
  2325.   return \"muls%.w %2,%0\";
  2326. #else
  2327.   return \"muls %2,%0\";
  2328. #endif
  2329. }")
  2330.  
  2331. (define_insn "mulsi3"
  2332.   [(set (match_operand:SI 0 "general_operand" "=d")
  2333.     (mult:SI (match_operand:SI 1 "general_operand" "%0")
  2334.          (match_operand:SI 2 "general_operand" "dmsK")))]
  2335.   "TARGET_68020"
  2336.   "muls%.l %2,%0")
  2337.  
  2338. (define_insn "umulhisi3"
  2339.   [(set (match_operand:SI 0 "general_operand" "=d")
  2340.     (mult:SI (zero_extend:SI
  2341.           (match_operand:HI 1 "nonimmediate_operand" "%0"))
  2342.          (zero_extend:SI
  2343.           (match_operand:HI 2 "nonimmediate_operand" "dm"))))]
  2344.   ""
  2345.   "*
  2346. {
  2347. #if defined(MOTOROLA) && !defined(CRDS)
  2348.   return \"mulu%.w %2,%0\";
  2349. #else
  2350.   return \"mulu %2,%0\";
  2351. #endif
  2352. }")
  2353.  
  2354. (define_insn ""
  2355.   [(set (match_operand:SI 0 "general_operand" "=d")
  2356.     (mult:SI (zero_extend:SI
  2357.           (match_operand:HI 1 "nonimmediate_operand" "%0"))
  2358.          (match_operand:SI 2 "const_int_operand" "n")))]
  2359.   ""
  2360.   "*
  2361. {
  2362. #if defined(MOTOROLA) && !defined(CRDS)
  2363.   return \"mulu%.w %2,%0\";
  2364. #else
  2365.   return \"mulu %2,%0\";
  2366. #endif
  2367. }")
  2368.  
  2369. ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
  2370. ;; proper matching constraint.  This is because the matching is between
  2371. ;; the high-numbered word of the DImode operand[0] and operand[1].
  2372. (define_expand "umulsidi3"
  2373.   [(parallel
  2374.     [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 1)
  2375.       (subreg:SI
  2376.        (mult:DI (zero_extend:DI
  2377.              (match_operand:SI 1 "register_operand" ""))
  2378.             (zero_extend:DI
  2379.              (match_operand:SI 2 "nonimmediate_operand" ""))) 1))
  2380.      (set (subreg:SI (match_dup 0) 0)
  2381.       (subreg:SI
  2382.        (mult:DI (zero_extend:DI
  2383.              (match_dup 1))
  2384.             (zero_extend:DI
  2385.              (match_dup 2))) 0))])]
  2386.   "TARGET_68020"
  2387.   "")
  2388.  
  2389. (define_insn ""
  2390.   [(set (match_operand:SI 0 "register_operand" "=d")
  2391.     (subreg:SI
  2392.      (mult:DI (zero_extend:DI
  2393.            (match_operand:SI 1 "register_operand" "%0"))
  2394.           (zero_extend:DI
  2395.            (match_operand:SI 2 "nonimmediate_operand" "dm"))) 1))
  2396.    (set (match_operand:SI 3 "register_operand" "=d")
  2397.     (subreg:SI
  2398.      (mult:DI (zero_extend:DI
  2399.            (match_dup 1))
  2400.           (zero_extend:DI
  2401.            (match_dup 2))) 0))]
  2402.   "TARGET_68020"
  2403.   "mulu%.l %2,%3:%0")
  2404.  
  2405. (define_insn ""
  2406.   [(set (match_operand:SI 0 "register_operand" "=d")
  2407.     (subreg:SI
  2408.      (mult:DI (zero_extend:DI
  2409.            (match_operand:SI 1 "register_operand" "%0"))
  2410.           (match_operand:SI 2 "immediate_operand" "sK")) 1))
  2411.    (set (match_operand:SI 3 "register_operand" "=d")
  2412.     (subreg:SI
  2413.      (mult:DI (zero_extend:DI
  2414.            (match_dup 1))
  2415.           (match_dup 2)) 0))]
  2416.   "TARGET_68020
  2417.    && (GET_CODE (operands[2]) != CONST_INT
  2418.        || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K'))"
  2419.   "mulu%.l %2,%3:%0")
  2420.  
  2421. (define_expand "mulsidi3"
  2422.   [(parallel
  2423.     [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 1)
  2424.       (subreg:SI
  2425.        (mult:DI (sign_extend:DI
  2426.              (match_operand:SI 1 "register_operand" ""))
  2427.             (sign_extend:DI
  2428.              (match_operand:SI 2 "nonimmediate_operand" ""))) 1))
  2429.      (set (subreg:SI (match_dup 0) 0)
  2430.       (subreg:SI
  2431.        (mult:DI (sign_extend:DI
  2432.              (match_dup 1))
  2433.             (sign_extend:DI
  2434.              (match_dup 2))) 0))])]
  2435.   "TARGET_68020"
  2436.   "")
  2437.  
  2438. (define_insn ""
  2439.   [(set (match_operand:SI 0 "register_operand" "=d")
  2440.     (subreg:SI
  2441.      (mult:DI (sign_extend:DI
  2442.            (match_operand:SI 1 "register_operand" "%0"))
  2443.           (sign_extend:DI
  2444.            (match_operand:SI 2 "nonimmediate_operand" "dm"))) 1))
  2445.    (set (match_operand:SI 3 "register_operand" "=d")
  2446.     (subreg:SI
  2447.      (mult:DI (sign_extend:DI
  2448.            (match_dup 1))
  2449.           (sign_extend:DI
  2450.            (match_dup 2))) 0))]
  2451.   "TARGET_68020"
  2452.   "muls%.l %2,%3:%0")
  2453.  
  2454. (define_insn ""
  2455.   [(set (match_operand:SI 0 "register_operand" "=d")
  2456.     (subreg:SI
  2457.      (mult:DI (sign_extend:DI
  2458.            (match_operand:SI 1 "register_operand" "%0"))
  2459.           (match_operand:SI 2 "immediate_operand" "sK")) 1))
  2460.    (set (match_operand:SI 3 "register_operand" "=d")
  2461.     (subreg:SI
  2462.      (mult:DI (sign_extend:DI
  2463.            (match_dup 1))
  2464.            (match_dup 2)) 0))]
  2465.   "TARGET_68020
  2466.    && (GET_CODE (operands[2]) != CONST_INT
  2467.        || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K'))"
  2468.   "muls%.l %2,%3:%0")
  2469.  
  2470. (define_expand "muldf3"
  2471.   [(set (match_operand:DF 0 "general_operand" "")
  2472.     (mult:DF (match_operand:DF 1 "general_operand" "")
  2473.          (match_operand:DF 2 "general_operand" "")))]
  2474.   "TARGET_68881 || TARGET_FPA"
  2475.   "")
  2476.  
  2477. (define_insn ""
  2478.   [(set (match_operand:DF 0 "general_operand" "=x,y")
  2479.     (mult:DF (match_operand:DF 1 "general_operand" "%xH,y")
  2480.          (match_operand:DF 2 "general_operand" "xH,rmF")))]
  2481.   "TARGET_FPA"
  2482.   "*
  2483. {
  2484.   if (rtx_equal_p (operands[1], operands[2]))
  2485.     return \"fpsqr%.d %y1,%0\";
  2486.   if (rtx_equal_p (operands[0], operands[1]))
  2487.     return \"fpmul%.d %y2,%0\";
  2488.   if (rtx_equal_p (operands[0], operands[2]))
  2489.     return \"fpmul%.d %y1,%0\";
  2490.   if (which_alternative == 0)
  2491.     return \"fpmul3%.d %w2,%w1,%0\";
  2492.   return \"fpmul3%.d %x2,%x1,%0\";
  2493. }")
  2494.  
  2495. (define_insn ""
  2496.   [(set (match_operand:DF 0 "general_operand" "=f")
  2497.     (mult:DF (match_operand:DF 1 "general_operand" "%0")
  2498.          (match_operand:DF 2 "general_operand" "fmG")))]
  2499.   "TARGET_68881"
  2500.   "*
  2501. {
  2502.   if (GET_CODE (operands[2]) == CONST_DOUBLE
  2503.       && floating_exact_log2 (operands[2]) && !TARGET_68040)
  2504.     {
  2505.       int i = floating_exact_log2 (operands[2]);
  2506.       operands[2] = gen_rtx (CONST_INT, VOIDmode, i);
  2507.       return \"fscale%.l %2,%0\";
  2508.     }
  2509.   if (REG_P (operands[2]))
  2510.     return \"f%&mul%.x %2,%0\";
  2511.   return \"f%&mul%.d %f2,%0\";
  2512. }")
  2513.  
  2514. (define_expand "mulsf3"
  2515.   [(set (match_operand:SF 0 "general_operand" "")
  2516.     (mult:SF (match_operand:SF 1 "general_operand" "")
  2517.          (match_operand:SF 2 "general_operand" "")))]
  2518.   "TARGET_68881 || TARGET_FPA"
  2519.   "")
  2520.  
  2521. (define_insn ""
  2522.   [(set (match_operand:SF 0 "general_operand" "=x,y")
  2523.     (mult:SF (match_operand:SF 1 "general_operand" "%xH,y")
  2524.          (match_operand:SF 2 "general_operand" "xH,rmF")))]
  2525.   "TARGET_FPA"
  2526.   "*
  2527. {
  2528.   if (rtx_equal_p (operands[1], operands[2]))
  2529.     return \"fpsqr%.s %w1,%0\";
  2530.   if (rtx_equal_p (operands[0], operands[1]))
  2531.     return \"fpmul%.s %w2,%0\";
  2532.   if (rtx_equal_p (operands[0], operands[2]))
  2533.     return \"fpmul%.s %w1,%0\";
  2534.   if (which_alternative == 0)
  2535.     return \"fpmul3%.s %w2,%w1,%0\";
  2536.   return \"fpmul3%.s %2,%1,%0\";
  2537. }")
  2538.  
  2539. (define_insn ""
  2540.   [(set (match_operand:SF 0 "general_operand" "=f")
  2541.     (mult:SF (match_operand:SF 1 "general_operand" "%0")
  2542.          (match_operand:SF 2 "general_operand" "fdmF")))]
  2543.   "TARGET_68881"
  2544.   "*
  2545. {
  2546. #ifdef FSGLMUL_USE_S
  2547.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  2548.     return (TARGET_68040_ONLY
  2549.         ? \"fsmul%.s %2,%0\"
  2550.         : \"fsglmul%.s %2,%0\");
  2551. #else
  2552.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  2553.     return (TARGET_68040_ONLY
  2554.         ? \"fsmul%.x %2,%0\"
  2555.         : \"fsglmul%.x %2,%0\");
  2556. #endif
  2557.   return (TARGET_68040_ONLY
  2558.       ? \"fsmul%.s %f2,%0\"
  2559.       : \"fsglmul%.s %f2,%0\");
  2560. }")
  2561.  
  2562. ;; divide instructions
  2563.  
  2564. (define_insn "divhi3"
  2565.   [(set (match_operand:HI 0 "general_operand" "=d")
  2566.     (div:HI (match_operand:HI 1 "general_operand" "0")
  2567.         (match_operand:HI 2 "general_operand" "dmn")))]
  2568.   ""
  2569.   "*
  2570. {
  2571. #ifdef MOTOROLA
  2572.   return \"ext%.l %0\;divs%.w %2,%0\";
  2573. #else
  2574.   return \"extl %0\;divs %2,%0\";
  2575. #endif
  2576. }")
  2577.  
  2578. (define_insn "divhisi3"
  2579.   [(set (match_operand:HI 0 "general_operand" "=d")
  2580.     (truncate:HI
  2581.      (div:SI
  2582.       (match_operand:SI 1 "general_operand" "0")
  2583.       (sign_extend:SI (match_operand:HI 2 "nonimmediate_operand" "dm")))))]
  2584.   ""
  2585.   "*
  2586. {
  2587. #ifdef MOTOROLA
  2588.   return \"divs%.w %2,%0\";
  2589. #else
  2590.   return \"divs %2,%0\";
  2591. #endif
  2592. }")
  2593.  
  2594. (define_insn ""
  2595.   [(set (match_operand:HI 0 "general_operand" "=d")
  2596.     (truncate:HI (div:SI (match_operand:SI 1 "general_operand" "0")
  2597.                  (match_operand:SI 2 "const_int_operand" "n"))))]
  2598.   ""
  2599.   "*
  2600. {
  2601. #ifdef MOTOROLA
  2602.   return \"divs%.w %2,%0\";
  2603. #else
  2604.   return \"divs %2,%0\";
  2605. #endif
  2606. }")
  2607.  
  2608. (define_insn "udivhi3"
  2609.   [(set (match_operand:HI 0 "general_operand" "=d")
  2610.     (udiv:HI (match_operand:HI 1 "general_operand" "0")
  2611.          (match_operand:HI 2 "general_operand" "dmn")))]
  2612.   ""
  2613.   "*
  2614. {
  2615. #ifdef MOTOROLA
  2616.   return \"and%.l %#0xFFFF,%0\;divu%.w %2,%0\";
  2617. #else
  2618.   return \"andl %#0xFFFF,%0\;divu %2,%0\";
  2619. #endif
  2620. }")
  2621.  
  2622. (define_insn "udivhisi3"
  2623.   [(set (match_operand:HI 0 "general_operand" "=d")
  2624.     (truncate:HI
  2625.      (udiv:SI
  2626.       (match_operand:SI 1 "general_operand" "0")
  2627.       (zero_extend:SI (match_operand:HI 2 "nonimmediate_operand" "dm")))))]
  2628.   ""
  2629.   "*
  2630. {
  2631. #ifdef MOTOROLA
  2632.   return \"divu%.w %2,%0\";
  2633. #else
  2634.   return \"divu %2,%0\";
  2635. #endif
  2636. }")
  2637.  
  2638. (define_insn ""
  2639.   [(set (match_operand:HI 0 "general_operand" "=d")
  2640.     (truncate:HI (udiv:SI (match_operand:SI 1 "general_operand" "0")
  2641.                   (match_operand:SI 2 "const_int_operand" "n"))))]
  2642.   ""
  2643.   "*
  2644. {
  2645. #ifdef MOTOROLA
  2646.   return \"divu%.w %2,%0\";
  2647. #else
  2648.   return \"divu %2,%0\";
  2649. #endif
  2650. }")
  2651.  
  2652. (define_expand "divdf3"
  2653.   [(set (match_operand:DF 0 "general_operand" "")
  2654.     (div:DF (match_operand:DF 1 "general_operand" "")
  2655.         (match_operand:DF 2 "general_operand" "")))]
  2656.   "TARGET_68881 || TARGET_FPA"
  2657.   "")
  2658.  
  2659. (define_insn ""
  2660.   [(set (match_operand:DF 0 "general_operand" "=x,y,y")
  2661.     (div:DF (match_operand:DF 1 "general_operand" "xH,y,rmF")
  2662.         (match_operand:DF 2 "general_operand" "xH,rmF,0")))]
  2663.   "TARGET_FPA"
  2664.   "*
  2665. {
  2666.   if (rtx_equal_p (operands[0], operands[2]))
  2667.     return \"fprdiv%.d %y1,%0\";
  2668.   if (rtx_equal_p (operands[0], operands[1]))
  2669.     return \"fpdiv%.d %y2,%0\";
  2670.   if (which_alternative == 0)
  2671.     return \"fpdiv3%.d %w2,%w1,%0\";
  2672.   return \"fpdiv3%.d %x2,%x1,%x0\";
  2673. }")
  2674.  
  2675. (define_insn ""
  2676.   [(set (match_operand:DF 0 "general_operand" "=f")
  2677.     (div:DF (match_operand:DF 1 "general_operand" "0")
  2678.         (match_operand:DF 2 "general_operand" "fmG")))]
  2679.   "TARGET_68881"
  2680.   "*
  2681. {
  2682.   if (REG_P (operands[2]))
  2683.     return \"f%&div%.x %2,%0\";
  2684.   return \"f%&div%.d %f2,%0\";
  2685. }")
  2686.  
  2687. (define_expand "divsf3"
  2688.   [(set (match_operand:SF 0 "general_operand" "")
  2689.     (div:SF (match_operand:SF 1 "general_operand" "")
  2690.         (match_operand:SF 2 "general_operand" "")))]
  2691.   "TARGET_68881 || TARGET_FPA"
  2692.   "")
  2693.  
  2694. (define_insn ""
  2695.   [(set (match_operand:SF 0 "general_operand" "=x,y,y")
  2696.     (div:SF (match_operand:SF 1 "general_operand" "xH,y,rmF")
  2697.         (match_operand:SF 2 "general_operand" "xH,rmF,0")))]
  2698.   "TARGET_FPA"
  2699.   "*
  2700. {
  2701.   if (rtx_equal_p (operands[0], operands[1]))
  2702.     return \"fpdiv%.s %w2,%0\";
  2703.   if (rtx_equal_p (operands[0], operands[2]))
  2704.     return \"fprdiv%.s %w1,%0\";
  2705.   if (which_alternative == 0)
  2706.     return \"fpdiv3%.s %w2,%w1,%0\";
  2707.   return \"fpdiv3%.s %2,%1,%0\";
  2708. }")
  2709.  
  2710. (define_insn ""
  2711.   [(set (match_operand:SF 0 "general_operand" "=f")
  2712.     (div:SF (match_operand:SF 1 "general_operand" "0")
  2713.         (match_operand:SF 2 "general_operand" "fdmF")))]
  2714.   "TARGET_68881"
  2715.   "*
  2716. {
  2717. #ifdef FSGLDIV_USE_S
  2718.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  2719.     return (TARGET_68040_ONLY
  2720.         ? \"fsdiv%.s %2,%0\"
  2721.         : \"fsgldiv%.s %2,%0\");
  2722. #else
  2723.   if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
  2724.     return (TARGET_68040_ONLY
  2725.         ? \"fsdiv%.x %2,%0\"
  2726.         : \"fsgldiv%.x %2,%0\");
  2727. #endif
  2728.   return (TARGET_68040_ONLY
  2729.       ? \"fsdiv%.s %f2,%0\"
  2730.       : \"fsgldiv%.s %f2,%0\");
  2731. }")
  2732.  
  2733. ;; Remainder instructions.
  2734.  
  2735. (define_insn "modhi3"
  2736.   [(set (match_operand:HI 0 "general_operand" "=d")
  2737.     (mod:HI (match_operand:HI 1 "general_operand" "0")
  2738.         (match_operand:HI 2 "general_operand" "dmn")))]
  2739.   ""
  2740.   "*
  2741. {
  2742.   /* The swap insn produces cc's that don't correspond to the result.  */
  2743.   CC_STATUS_INIT;
  2744. #ifdef MOTOROLA
  2745.   return \"ext%.l %0\;divs%.w %2,%0\;swap %0\";
  2746. #else
  2747.   return \"extl %0\;divs %2,%0\;swap %0\";
  2748. #endif
  2749. }")
  2750.  
  2751. (define_insn "modhisi3"
  2752.   [(set (match_operand:HI 0 "general_operand" "=d")
  2753.     (truncate:HI
  2754.      (mod:SI
  2755.       (match_operand:SI 1 "general_operand" "0")
  2756.       (sign_extend:SI (match_operand:HI 2 "nonimmediate_operand" "dm")))))]
  2757.   ""
  2758.   "*
  2759. {
  2760.   /* The swap insn produces cc's that don't correspond to the result.  */
  2761.   CC_STATUS_INIT;
  2762. #ifdef MOTOROLA
  2763.   return \"divs%.w %2,%0\;swap %0\";
  2764. #else
  2765.   return \"divs %2,%0\;swap %0\";
  2766. #endif
  2767. }")
  2768.  
  2769. (define_insn ""
  2770.   [(set (match_operand:HI 0 "general_operand" "=d")
  2771.     (truncate:HI (mod:SI (match_operand:SI 1 "general_operand" "0")
  2772.                  (match_operand:SI 2 "const_int_operand" "n"))))]
  2773.   ""
  2774.   "*
  2775. {
  2776.   /* The swap insn produces cc's that don't correspond to the result.  */
  2777.   CC_STATUS_INIT;
  2778. #ifdef MOTOROLA
  2779.   return \"divs%.w %2,%0\;swap %0\";
  2780. #else
  2781.   return \"divs %2,%0\;swap %0\";
  2782. #endif
  2783. }")
  2784.  
  2785. (define_insn "umodhi3"
  2786.   [(set (match_operand:HI 0 "general_operand" "=d")
  2787.     (umod:HI (match_operand:HI 1 "general_operand" "0")
  2788.          (match_operand:HI 2 "general_operand" "dmn")))]
  2789.   ""
  2790.   "*
  2791. {
  2792.   /* The swap insn produces cc's that don't correspond to the result.  */
  2793.   CC_STATUS_INIT;
  2794. #ifdef MOTOROLA
  2795.   return \"and%.l %#0xFFFF,%0\;divu%.w %2,%0\;swap %0\";
  2796. #else
  2797.   return \"andl %#0xFFFF,%0\;divu %2,%0\;swap %0\";
  2798. #endif
  2799. }")
  2800.  
  2801. (define_insn "umodhisi3"
  2802.   [(set (match_operand:HI 0 "general_operand" "=d")
  2803.     (truncate:HI
  2804.      (umod:SI
  2805.       (match_operand:SI 1 "general_operand" "0")
  2806.       (zero_extend:SI (match_operand:HI 2 "nonimmediate_operand" "dm")))))]
  2807.   ""
  2808.   "*
  2809. {
  2810.   /* The swap insn produces cc's that don't correspond to the result.  */
  2811.   CC_STATUS_INIT;
  2812. #ifdef MOTOROLA
  2813.   return \"divu%.w %2,%0\;swap %0\";
  2814. #else
  2815.   return \"divu %2,%0\;swap %0\";
  2816. #endif
  2817. }")
  2818.  
  2819. (define_insn ""
  2820.   [(set (match_operand:HI 0 "general_operand" "=d")
  2821.     (truncate:HI (umod:SI (match_operand:SI 1 "general_operand" "0")
  2822.                   (match_operand:SI 2 "const_int_operand" "n"))))]
  2823.   ""
  2824.   "*
  2825. {
  2826.   /* The swap insn produces cc's that don't correspond to the result.  */
  2827.   CC_STATUS_INIT;
  2828. #ifdef MOTOROLA
  2829.   return \"divu%.w %2,%0\;swap %0\";
  2830. #else
  2831.   return \"divu %2,%0\;swap %0\";
  2832. #endif
  2833. }")
  2834.  
  2835. (define_insn "divmodsi4"
  2836.   [(set (match_operand:SI 0 "general_operand" "=d")
  2837.     (div:SI (match_operand:SI 1 "general_operand" "0")
  2838.         (match_operand:SI 2 "general_operand" "dmsK")))
  2839.    (set (match_operand:SI 3 "general_operand" "=d")
  2840.     (mod:SI (match_dup 1) (match_dup 2)))]
  2841.   "TARGET_68020"
  2842.   "*
  2843. {
  2844.   if (find_reg_note (insn, REG_UNUSED, operands[3]))
  2845.     return \"divs%.l %2,%0\";
  2846.   else
  2847.     return \"divsl%.l %2,%3:%0\";
  2848. }")
  2849.  
  2850. (define_insn "udivmodsi4"
  2851.   [(set (match_operand:SI 0 "general_operand" "=d")
  2852.     (udiv:SI (match_operand:SI 1 "general_operand" "0")
  2853.          (match_operand:SI 2 "general_operand" "dmsK")))
  2854.    (set (match_operand:SI 3 "general_operand" "=d")
  2855.     (umod:SI (match_dup 1) (match_dup 2)))]
  2856.   "TARGET_68020"
  2857.   "*
  2858. {
  2859.   if (find_reg_note (insn, REG_UNUSED, operands[3]))
  2860.     return \"divu%.l %2,%0\";
  2861.   else
  2862.     return \"divul%.l %2,%3:%0\";
  2863. }")
  2864.  
  2865. ;; logical-and instructions
  2866.  
  2867. ;; Prevent AND from being made with sp.  This doesn't exist in the machine
  2868. ;; and reload will cause inefficient code.  Since sp is a FIXED_REG, we
  2869. ;; can't allocate pseudos into it.
  2870. (define_insn "andsi3"
  2871.   [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
  2872.     (and:SI (match_operand:SI 1 "general_operand" "%0,0")
  2873.         (match_operand:SI 2 "general_operand" "dKs,dmKs")))]
  2874.   ""
  2875.   "*
  2876. {
  2877.   int logval;
  2878.   if (GET_CODE (operands[2]) == CONST_INT
  2879.       && (INTVAL (operands[2]) | 0xffff) == 0xffffffff
  2880.       && (DATA_REG_P (operands[0])
  2881.       || offsettable_memref_p (operands[0])))
  2882.     { 
  2883.       if (GET_CODE (operands[0]) != REG)
  2884.         operands[0] = adj_offsettable_operand (operands[0], 2);
  2885.       operands[2] = gen_rtx (CONST_INT, VOIDmode,
  2886.                  INTVAL (operands[2]) & 0xffff);
  2887.       /* Do not delete a following tstl %0 insn; that would be incorrect.  */
  2888.       CC_STATUS_INIT;
  2889.       if (operands[2] == const0_rtx)
  2890.         return \"clr%.w %0\";
  2891.       return \"and%.w %2,%0\";
  2892.     }
  2893.   if (GET_CODE (operands[2]) == CONST_INT
  2894.       && (logval = exact_log2 (~ INTVAL (operands[2]))) >= 0
  2895.       && (DATA_REG_P (operands[0])
  2896.           || offsettable_memref_p (operands[0])))
  2897.     { 
  2898.       if (DATA_REG_P (operands[0]))
  2899.         {
  2900.           operands[1] = gen_rtx (CONST_INT, VOIDmode, logval);
  2901.         }
  2902.       else
  2903.         {
  2904.           operands[0] = adj_offsettable_operand (operands[0], 3 - (logval / 8));          operands[1] = gen_rtx (CONST_INT, VOIDmode, logval % 8);
  2905.         }
  2906.       /* This does not set condition codes in a standard way.  */
  2907.       CC_STATUS_INIT;
  2908.       return \"bclr %1,%0\";
  2909.     }
  2910.   return \"and%.l %2,%0\";
  2911. }")
  2912.  
  2913. (define_insn "andhi3"
  2914.   [(set (match_operand:HI 0 "general_operand" "=m,d")
  2915.     (and:HI (match_operand:HI 1 "general_operand" "%0,0")
  2916.         (match_operand:HI 2 "general_operand" "dn,dmn")))]
  2917.   ""
  2918.   "and%.w %2,%0")
  2919.  
  2920. (define_insn ""
  2921.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  2922.     (and:HI (match_dup 0)
  2923.         (match_operand:HI 1 "general_operand" "dn,dmn")))]
  2924.   ""
  2925.   "and%.w %1,%0")
  2926.  
  2927. (define_insn ""
  2928.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  2929.     (and:HI (match_operand:HI 1 "general_operand" "dn,dmn")
  2930.         (match_dup 0)))]
  2931.   ""
  2932.   "and%.w %1,%0")
  2933.  
  2934. (define_insn "andqi3"
  2935.   [(set (match_operand:QI 0 "general_operand" "=m,d")
  2936.     (and:QI (match_operand:QI 1 "general_operand" "%0,0")
  2937.         (match_operand:QI 2 "general_operand" "dn,dmn")))]
  2938.   ""
  2939.   "and%.b %2,%0")
  2940.  
  2941. (define_insn ""
  2942.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  2943.     (and:QI (match_dup 0)
  2944.         (match_operand:QI 1 "general_operand" "dn,dmn")))]
  2945.   ""
  2946.   "and%.b %1,%0")
  2947.  
  2948. (define_insn ""
  2949.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  2950.     (and:QI (match_operand:QI 1 "general_operand" "dn,dmn")
  2951.         (match_dup 0)))]
  2952.   ""
  2953.   "and%.b %1,%0")
  2954.  
  2955. ;; inclusive-or instructions
  2956.  
  2957. (define_insn "iorsi3"
  2958.   [(set (match_operand:SI 0 "general_operand" "=m,d")
  2959.     (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
  2960.         (match_operand:SI 2 "general_operand" "dKs,dmKs")))]
  2961.   ""
  2962.   "*
  2963. {
  2964.   register int logval;
  2965.   if (GET_CODE (operands[2]) == CONST_INT
  2966.       && INTVAL (operands[2]) >> 16 == 0
  2967.       && (DATA_REG_P (operands[0])
  2968.       || offsettable_memref_p (operands[0])))
  2969.     { 
  2970.       if (GET_CODE (operands[0]) != REG)
  2971.         operands[0] = adj_offsettable_operand (operands[0], 2);
  2972.       /* Do not delete a following tstl %0 insn; that would be incorrect.  */
  2973.       CC_STATUS_INIT;
  2974.       return \"or%.w %2,%0\";
  2975.     }
  2976.   if (GET_CODE (operands[2]) == CONST_INT
  2977.       && (logval = exact_log2 (INTVAL (operands[2]))) >= 0
  2978.       && (DATA_REG_P (operands[0])
  2979.       || offsettable_memref_p (operands[0])))
  2980.     { 
  2981.       if (DATA_REG_P (operands[0]))
  2982.     {
  2983.       operands[1] = gen_rtx (CONST_INT, VOIDmode, logval);
  2984.     }
  2985.       else
  2986.         {
  2987.       operands[0] = adj_offsettable_operand (operands[0], 3 - (logval / 8));
  2988.       operands[1] = gen_rtx (CONST_INT, VOIDmode, logval % 8);
  2989.     }
  2990.       return \"bset %1,%0\";
  2991.     }
  2992.   return \"or%.l %2,%0\";
  2993. }")
  2994.  
  2995. (define_insn "iorhi3"
  2996.   [(set (match_operand:HI 0 "general_operand" "=m,d")
  2997.     (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
  2998.         (match_operand:HI 2 "general_operand" "dn,dmn")))]
  2999.   ""
  3000.   "or%.w %2,%0")
  3001.  
  3002. (define_insn ""
  3003.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  3004.     (ior:HI (match_dup 0)
  3005.         (match_operand:HI 1 "general_operand" "dn,dmn")))]
  3006.   ""
  3007.   "or%.w %1,%0")
  3008.  
  3009. (define_insn ""
  3010.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d"))
  3011.     (ior:HI (match_operand:HI 1 "general_operand" "dn,dmn")
  3012.         (match_dup 0)))]
  3013.   ""
  3014.   "or%.w %1,%0")
  3015.  
  3016. (define_insn "iorqi3"
  3017.   [(set (match_operand:QI 0 "general_operand" "=m,d")
  3018.     (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
  3019.         (match_operand:QI 2 "general_operand" "dn,dmn")))]
  3020.   ""
  3021.   "or%.b %2,%0")
  3022.  
  3023. (define_insn ""
  3024.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  3025.     (ior:QI (match_dup 0)
  3026.         (match_operand:QI 1 "general_operand" "dn,dmn")))]
  3027.   ""
  3028.   "or%.b %1,%0")
  3029.  
  3030. (define_insn ""
  3031.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d"))
  3032.     (ior:QI (match_operand:QI 1 "general_operand" "dn,dmn")
  3033.         (match_dup 0)))]
  3034.   ""
  3035.   "or%.b %1,%0")
  3036.  
  3037. ;; xor instructions
  3038.  
  3039. (define_insn "xorsi3"
  3040.   [(set (match_operand:SI 0 "general_operand" "=do,m")
  3041.     (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
  3042.         (match_operand:SI 2 "general_operand" "di,dKs")))]
  3043.   ""
  3044.   "*
  3045. {
  3046.   if (GET_CODE (operands[2]) == CONST_INT
  3047.       && INTVAL (operands[2]) >> 16 == 0
  3048.       && (offsettable_memref_p (operands[0]) || DATA_REG_P (operands[0])))
  3049.     { 
  3050.       if (! DATA_REG_P (operands[0]))
  3051.     operands[0] = adj_offsettable_operand (operands[0], 2);
  3052.       /* Do not delete a following tstl %0 insn; that would be incorrect.  */
  3053.       CC_STATUS_INIT;
  3054.       return \"eor%.w %2,%0\";
  3055.     }
  3056.   return \"eor%.l %2,%0\";
  3057. }")
  3058.  
  3059. (define_insn "xorhi3"
  3060.   [(set (match_operand:HI 0 "general_operand" "=dm")
  3061.     (xor:HI (match_operand:HI 1 "general_operand" "%0")
  3062.         (match_operand:HI 2 "general_operand" "dn")))]
  3063.   ""
  3064.   "eor%.w %2,%0")
  3065.  
  3066. (define_insn ""
  3067.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm"))
  3068.     (xor:HI (match_dup 0)
  3069.         (match_operand:HI 1 "general_operand" "dn")))]
  3070.   ""
  3071.   "eor%.w %1,%0")
  3072.  
  3073.  
  3074. (define_insn ""
  3075.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm"))
  3076.     (xor:HI (match_operand:HI 1 "general_operand" "dn")
  3077.         (match_dup 0)))]
  3078.   ""
  3079.   "eor%.w %1,%0")
  3080.  
  3081. (define_insn "xorqi3"
  3082.   [(set (match_operand:QI 0 "general_operand" "=dm")
  3083.     (xor:QI (match_operand:QI 1 "general_operand" "%0")
  3084.         (match_operand:QI 2 "general_operand" "dn")))]
  3085.   ""
  3086.   "eor%.b %2,%0")
  3087.  
  3088. (define_insn ""
  3089.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm"))
  3090.     (xor:QI (match_dup 0)
  3091.         (match_operand:QI 1 "general_operand" "dn")))]
  3092.   ""
  3093.   "eor%.b %1,%0")
  3094.  
  3095. (define_insn ""
  3096.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm"))
  3097.     (xor:QI (match_operand:QI 1 "general_operand" "dn")
  3098.         (match_dup 0)))]
  3099.   ""
  3100.   "eor%.b %1,%0")
  3101.  
  3102. ;; negation instructions
  3103.  
  3104. (define_insn "negsi2"
  3105.   [(set (match_operand:SI 0 "general_operand" "=dm")
  3106.     (neg:SI (match_operand:SI 1 "general_operand" "0")))]
  3107.   ""
  3108.   "neg%.l %0")
  3109.  
  3110. (define_insn "neghi2"
  3111.   [(set (match_operand:HI 0 "general_operand" "=dm")
  3112.     (neg:HI (match_operand:HI 1 "general_operand" "0")))]
  3113.   ""
  3114.   "neg%.w %0")
  3115.  
  3116. (define_insn ""
  3117.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm"))
  3118.     (neg:HI (match_dup 0)))]
  3119.   ""
  3120.   "neg%.w %0")
  3121.  
  3122. (define_insn "negqi2"
  3123.   [(set (match_operand:QI 0 "general_operand" "=dm")
  3124.     (neg:QI (match_operand:QI 1 "general_operand" "0")))]
  3125.   ""
  3126.   "neg%.b %0")
  3127.  
  3128. (define_insn ""
  3129.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm"))
  3130.     (neg:QI (match_dup 0)))]
  3131.   ""
  3132.   "neg%.b %0")
  3133.  
  3134. (define_expand "negsf2"
  3135.   [(set (match_operand:SF 0 "general_operand" "")
  3136.     (neg:SF (match_operand:SF 1 "general_operand" "")))]
  3137.   "TARGET_68881 || TARGET_FPA"
  3138.   "")
  3139.  
  3140. (define_insn ""
  3141.   [(set (match_operand:SF 0 "general_operand" "=x,y")
  3142.     (neg:SF (match_operand:SF 1 "general_operand" "xH,rmF")))]
  3143.   "TARGET_FPA"
  3144.   "fpneg%.s %w1,%0")
  3145.  
  3146. (define_insn ""
  3147.   [(set (match_operand:SF 0 "general_operand" "=f,d")
  3148.     (neg:SF (match_operand:SF 1 "general_operand" "fdmF,0")))]
  3149.   "TARGET_68881"
  3150.   "*
  3151. {
  3152.   if (DATA_REG_P (operands[0]))
  3153.     {
  3154.       operands[1] = gen_rtx (CONST_INT, VOIDmode, 31);
  3155.       return \"bchg %1,%0\";
  3156.     }
  3157.   if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
  3158.     return \"f%$neg%.x %1,%0\";
  3159.   return \"f%$neg%.s %f1,%0\";
  3160. }")
  3161.  
  3162. (define_expand "negdf2"
  3163.   [(set (match_operand:DF 0 "general_operand" "")
  3164.     (neg:DF (match_operand:DF 1 "general_operand" "")))]
  3165.   "TARGET_68881 || TARGET_FPA"
  3166.   "")
  3167.  
  3168. (define_insn ""
  3169.   [(set (match_operand:DF 0 "general_operand" "=x,y")
  3170.     (neg:DF (match_operand:DF 1 "general_operand" "xH,rmF")))]
  3171.   "TARGET_FPA"
  3172.   "fpneg%.d %y1, %0")
  3173.  
  3174. (define_insn ""
  3175.   [(set (match_operand:DF 0 "general_operand" "=f,d")
  3176.     (neg:DF (match_operand:DF 1 "general_operand" "fmF,0")))]
  3177.   "TARGET_68881"
  3178.   "*
  3179. {
  3180.   if (DATA_REG_P (operands[0]))
  3181.     {
  3182.       operands[1] = gen_rtx (CONST_INT, VOIDmode, 31);
  3183.       return \"bchg %1,%0\";
  3184.     }
  3185.   if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
  3186.     return \"f%&neg%.x %1,%0\";
  3187.   return \"f%&neg%.d %f1,%0\";
  3188. }")
  3189.  
  3190. ;; Sqrt instruction for the 68881
  3191.  
  3192. (define_insn "sqrtdf2"
  3193.   [(set (match_operand:DF 0 "general_operand" "=f")
  3194.     (sqrt:DF (match_operand:DF 1 "general_operand" "fm")))]
  3195.   "TARGET_68881"
  3196.   "*
  3197. {
  3198.   if (FP_REG_P (operands[1]))
  3199.     return \"fsqrt%.x %1,%0\";
  3200.   else
  3201.     return \"fsqrt%.d %1,%0\";
  3202. }")
  3203.  
  3204. ;; Absolute value instructions
  3205.  
  3206. (define_expand "abssf2"
  3207.   [(set (match_operand:SF 0 "general_operand" "")
  3208.     (abs:SF (match_operand:SF 1 "general_operand" "")))]
  3209.   "TARGET_68881 || TARGET_FPA"
  3210.   "")
  3211.  
  3212. (define_insn ""
  3213.   [(set (match_operand:SF 0 "general_operand" "=x,y")
  3214.     (abs:SF (match_operand:SF 1 "general_operand" "xH,rmF")))]
  3215.   "TARGET_FPA"
  3216.   "fpabs%.s %y1,%0")
  3217.  
  3218. (define_insn ""
  3219.   [(set (match_operand:SF 0 "general_operand" "=f")
  3220.     (abs:SF (match_operand:SF 1 "general_operand" "fdmF")))]
  3221.   "TARGET_68881"
  3222.   "*
  3223. {
  3224.   if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
  3225.     return \"f%$abs%.x %1,%0\";
  3226.   return \"f%$abs%.s %f1,%0\";
  3227. }")
  3228.  
  3229. (define_expand "absdf2"
  3230.   [(set (match_operand:DF 0 "general_operand" "")
  3231.     (abs:DF (match_operand:DF 1 "general_operand" "")))]
  3232.   "TARGET_68881 || TARGET_FPA"
  3233.   "")
  3234.  
  3235. (define_insn ""
  3236.   [(set (match_operand:DF 0 "general_operand" "=x,y")
  3237.     (abs:DF (match_operand:DF 1 "general_operand" "xH,rmF")))]
  3238.   "TARGET_FPA"
  3239.   "fpabs%.d %y1,%0")
  3240.  
  3241. (define_insn ""
  3242.   [(set (match_operand:DF 0 "general_operand" "=f")
  3243.     (abs:DF (match_operand:DF 1 "general_operand" "fmF")))]
  3244.   "TARGET_68881"
  3245.   "*
  3246. {
  3247.   if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
  3248.     return \"f%&abs%.x %1,%0\";
  3249.   return \"f%&abs%.d %f1,%0\";
  3250. }")
  3251.  
  3252. ;; one complement instructions
  3253.  
  3254. (define_insn "one_cmplsi2"
  3255.   [(set (match_operand:SI 0 "general_operand" "=dm")
  3256.     (not:SI (match_operand:SI 1 "general_operand" "0")))]
  3257.   ""
  3258.   "not%.l %0")
  3259.  
  3260. (define_insn "one_cmplhi2"
  3261.   [(set (match_operand:HI 0 "general_operand" "=dm")
  3262.     (not:HI (match_operand:HI 1 "general_operand" "0")))]
  3263.   ""
  3264.   "not%.w %0")
  3265.  
  3266. (define_insn ""
  3267.   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm"))
  3268.     (not:HI (match_dup 0)))]
  3269.   ""
  3270.   "not%.w %0")
  3271.  
  3272. (define_insn "one_cmplqi2"
  3273.   [(set (match_operand:QI 0 "general_operand" "=dm")
  3274.     (not:QI (match_operand:QI 1 "general_operand" "0")))]
  3275.   ""
  3276.   "not%.b %0")
  3277.  
  3278. (define_insn ""
  3279.   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm"))
  3280.     (not:QI (match_dup 0)))]
  3281.   ""
  3282.   "not%.b %0")
  3283.  
  3284. ;; arithmetic shift instructions
  3285. ;; We don't need the shift memory by 1 bit instruction
  3286.  
  3287. ;; On all 68k models, this makes faster code in a special case.
  3288.  
  3289. (define_insn ""
  3290.   [(set (match_operand:SI 0 "register_operand" "=d")
  3291.     (ashift:SI (match_operand:SI 1 "register_operand" "0")
  3292.            (match_operand:SI 2 "immediate_operand" "i")))]
  3293.   "(GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)"
  3294.   "*
  3295. {
  3296.   CC_STATUS_INIT;
  3297.   return \"swap %0\;clr%.w %0\";
  3298. }")
  3299.  
  3300. ;; On the 68000, this makes faster code in a special case.
  3301.  
  3302. (define_insn ""
  3303.   [(set (match_operand:SI 0 "register_operand" "=d")
  3304.     (ashift:SI (match_operand:SI 1 "register_operand" "0")
  3305.            (match_operand:SI 2 "immediate_operand" "i")))]
  3306.   "(! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT
  3307.     && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
  3308.   "*
  3309. {
  3310.   CC_STATUS_INIT;
  3311.  
  3312.   operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16);
  3313.   return \"asl%.w %2,%0\;swap %0\;clr%.w %0\";
  3314. }")
  3315.  
  3316. (define_insn "ashlsi3"
  3317.   [(set (match_operand:SI 0 "register_operand" "=d")
  3318.     (ashift:SI (match_operand:SI 1 "register_operand" "0")
  3319.            (match_operand:SI 2 "general_operand" "dI")))]
  3320.   ""
  3321.   "*
  3322. {
  3323.   if (operands[2] == const1_rtx)
  3324.     return \"add%.l %0,%0\";
  3325.   return \"asl%.l %2,%0\";
  3326. }")
  3327.  
  3328. (define_insn "ashlhi3"
  3329.   [(set (match_operand:HI 0 "register_operand" "=d")
  3330.     (ashift:HI (match_operand:HI 1 "register_operand" "0")
  3331.            (match_operand:HI 2 "general_operand" "dI")))]
  3332.   ""
  3333.   "asl%.w %2,%0")
  3334.  
  3335. (define_insn ""
  3336.   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
  3337.     (ashift:HI (match_dup 0)
  3338.            (match_operand:HI 1 "general_operand" "dI")))]
  3339.   ""
  3340.   "asl%.w %1,%0")
  3341.  
  3342. (define_insn "ashlqi3"
  3343.   [(set (match_operand:QI 0 "register_operand" "=d")
  3344.     (ashift:QI (match_operand:QI 1 "register_operand" "0")
  3345.            (match_operand:QI 2 "general_operand" "dI")))]
  3346.   ""
  3347.   "asl%.b %2,%0")
  3348.  
  3349. (define_insn ""
  3350.   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
  3351.     (ashift:QI (match_dup 0)
  3352.            (match_operand:QI 1 "general_operand" "dI")))]
  3353.   ""
  3354.   "asl%.b %1,%0")
  3355.  
  3356. ;; On all 68k models, this makes faster code in a special case.
  3357.  
  3358. (define_insn ""
  3359.   [(set (match_operand:SI 0 "register_operand" "=d")
  3360.     (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
  3361.              (match_operand:SI 2 "immediate_operand" "i")))]
  3362.   "(GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)" 
  3363.   "swap %0\;ext%.l %0")
  3364.  
  3365. ;; On the 68000, this makes faster code in a special case.
  3366.  
  3367. (define_insn ""
  3368.   [(set (match_operand:SI 0 "register_operand" "=d")
  3369.     (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
  3370.              (match_operand:SI 2 "immediate_operand" "i")))]
  3371.   "(! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT
  3372.     && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
  3373.   "*
  3374. {
  3375.   operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16);
  3376.   return \"swap %0\;asr%.w %2,%0\;ext%.l %0\";
  3377. }")
  3378.  
  3379. (define_insn "ashrsi3"
  3380.   [(set (match_operand:SI 0 "register_operand" "=d")
  3381.     (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
  3382.              (match_operand:SI 2 "general_operand" "dI")))]
  3383.   ""
  3384.   "*
  3385. {
  3386.   return \"asr%.l %2,%0\";
  3387. }")
  3388.  
  3389. (define_insn "ashrhi3"
  3390.   [(set (match_operand:HI 0 "register_operand" "=d")
  3391.     (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
  3392.              (match_operand:HI 2 "general_operand" "dI")))]
  3393.   ""
  3394.   "asr%.w %2,%0")
  3395.  
  3396. (define_insn ""
  3397.   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
  3398.     (ashiftrt:HI (match_dup 0)
  3399.              (match_operand:HI 1 "general_operand" "dI")))]
  3400.   ""
  3401.   "asr%.w %1,%0")
  3402.  
  3403. (define_insn "ashrqi3"
  3404.   [(set (match_operand:QI 0 "register_operand" "=d")
  3405.     (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
  3406.              (match_operand:QI 2 "general_operand" "dI")))]
  3407.   ""
  3408.   "asr%.b %2,%0")
  3409.  
  3410. (define_insn ""
  3411.   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
  3412.     (ashiftrt:QI (match_dup 0)
  3413.              (match_operand:QI 1 "general_operand" "dI")))]
  3414.   ""
  3415.   "asr%.b %1,%0")
  3416.  
  3417. ;; logical shift instructions
  3418.  
  3419. ;; On all 68k models, this makes faster code in a special case.
  3420.  
  3421. (define_insn ""
  3422.   [(set (match_operand:SI 0 "register_operand" "=d")
  3423.     (lshift:SI (match_operand:SI 1 "register_operand" "0")
  3424.            (match_operand:SI 2 "immediate_operand" "i")))]
  3425.   "(GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)"
  3426.   "*
  3427. {
  3428.   CC_STATUS_INIT;
  3429.   return \"swap %0\;clr%.w %0\";
  3430. }")
  3431.  
  3432. ;; On the 68000, this makes faster code in a special case.
  3433.  
  3434. (define_insn ""
  3435.   [(set (match_operand:SI 0 "register_operand" "=d")
  3436.     (lshift:SI (match_operand:SI 1 "register_operand" "0")
  3437.            (match_operand:SI 2 "immediate_operand" "i")))]
  3438.   "(! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT
  3439.     && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
  3440.   "*
  3441. {
  3442.   CC_STATUS_INIT;
  3443.  
  3444.   operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16);
  3445.   return \"lsl%.w %2,%0\;swap %0\;clr%.w %0\";
  3446. }")
  3447.  
  3448. (define_insn "lshlsi3"
  3449.   [(set (match_operand:SI 0 "register_operand" "=d")
  3450.     (lshift:SI (match_operand:SI 1 "register_operand" "0")
  3451.            (match_operand:SI 2 "general_operand" "dI")))]
  3452.   ""
  3453.   "*
  3454. {
  3455.   if (operands[2] == const1_rtx)
  3456.     return \"add%.l %0,%0\";
  3457.   return \"lsl%.l %2,%0\";
  3458. }")
  3459.  
  3460. (define_insn "lshlhi3"
  3461.   [(set (match_operand:HI 0 "register_operand" "=d")
  3462.     (lshift:HI (match_operand:HI 1 "register_operand" "0")
  3463.            (match_operand:HI 2 "general_operand" "dI")))]
  3464.   ""
  3465.   "lsl%.w %2,%0")
  3466.  
  3467. (define_insn ""
  3468.   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
  3469.     (lshift:HI (match_dup 0)
  3470.            (match_operand:HI 1 "general_operand" "dI")))]
  3471.   ""
  3472.   "lsl%.w %1,%0")
  3473.  
  3474. (define_insn "lshlqi3"
  3475.   [(set (match_operand:QI 0 "register_operand" "=d")
  3476.     (lshift:QI (match_operand:QI 1 "register_operand" "0")
  3477.            (match_operand:QI 2 "general_operand" "dI")))]
  3478.   ""
  3479.   "lsl%.b %2,%0")
  3480.  
  3481. (define_insn ""
  3482.   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
  3483.     (lshift:QI (match_dup 0)
  3484.            (match_operand:QI 1 "general_operand" "dI")))]
  3485.   ""
  3486.   "lsl%.b %1,%0")
  3487.  
  3488. ;; On all 68k models, this makes faster code in a special case.
  3489.  
  3490. (define_insn ""
  3491.   [(set (match_operand:SI 0 "register_operand" "=d")
  3492.     (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
  3493.              (match_operand:SI 2 "immediate_operand" "i")))]
  3494.   "(GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)" 
  3495.   "*
  3496. {
  3497.   CC_STATUS_INIT;
  3498.   return \"clr%.w %0\;swap %0\";
  3499. }")
  3500.  
  3501. ;; On the 68000, this makes faster code in a special case.
  3502.  
  3503. (define_insn ""
  3504.   [(set (match_operand:SI 0 "register_operand" "=d")
  3505.     (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
  3506.              (match_operand:SI 2 "immediate_operand" "i")))]
  3507.   "(! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT
  3508.     && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
  3509.   "*
  3510. {
  3511.   /* I think lsr%.w sets the CC properly.  */
  3512.   operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16);
  3513.   return \"clr%.w %0\;swap %0\;lsr%.w %2,%0\";
  3514. }")
  3515.  
  3516. (define_insn "lshrsi3"
  3517.   [(set (match_operand:SI 0 "register_operand" "=d")
  3518.     (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
  3519.              (match_operand:SI 2 "general_operand" "dI")))]
  3520.   ""
  3521.   "*
  3522. {
  3523.   return \"lsr%.l %2,%0\";
  3524. }")
  3525.  
  3526. (define_insn "lshrhi3"
  3527.   [(set (match_operand:HI 0 "register_operand" "=d")
  3528.     (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
  3529.              (match_operand:HI 2 "general_operand" "dI")))]
  3530.   ""
  3531.   "lsr%.w %2,%0")
  3532.  
  3533. (define_insn ""
  3534.   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
  3535.     (lshiftrt:HI (match_dup 0)
  3536.              (match_operand:HI 1 "general_operand" "dI")))]
  3537.   ""
  3538.   "lsr%.w %1,%0")
  3539.  
  3540. (define_insn "lshrqi3"
  3541.   [(set (match_operand:QI 0 "register_operand" "=d")
  3542.     (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
  3543.              (match_operand:QI 2 "general_operand" "dI")))]
  3544.   ""
  3545.   "lsr%.b %2,%0")
  3546.  
  3547. (define_insn ""
  3548.   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
  3549.     (lshiftrt:QI (match_dup 0)
  3550.              (match_operand:QI 1 "general_operand" "dI")))]
  3551.   ""
  3552.   "lsr%.b %1,%0")
  3553.  
  3554. ;; rotate instructions
  3555.  
  3556. (define_insn "rotlsi3"
  3557.   [(set (match_operand:SI 0 "register_operand" "=d")
  3558.     (rotate:SI (match_operand:SI 1 "register_operand" "0")
  3559.            (match_operand:SI 2 "general_operand" "dI")))]
  3560.   ""
  3561.   "rol%.l %2,%0")
  3562.  
  3563. (define_insn "rotlhi3"
  3564.   [(set (match_operand:HI 0 "register_operand" "=d")
  3565.     (rotate:HI (match_operand:HI 1 "register_operand" "0")
  3566.            (match_operand:HI 2 "general_operand" "dI")))]
  3567.   ""
  3568.   "rol%.w %2,%0")
  3569.  
  3570.  
  3571. (define_insn ""
  3572.   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
  3573.     (rotate:HI (match_dup 0)
  3574.            (match_operand:HI 1 "general_operand" "dI")))]
  3575.   ""
  3576.   "rol%.w %1,%0")
  3577.  
  3578. (define_insn "rotlqi3"
  3579.   [(set (match_operand:QI 0 "register_operand" "=d")
  3580.     (rotate:QI (match_operand:QI 1 "register_operand" "0")
  3581.            (match_operand:QI 2 "general_operand" "dI")))]
  3582.   ""
  3583.   "rol%.b %2,%0")
  3584.  
  3585. (define_insn ""
  3586.   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
  3587.     (rotate:QI (match_dup 0)
  3588.            (match_operand:QI 1 "general_operand" "dI")))]
  3589.   ""
  3590.   "rol%.b %1,%0")
  3591.  
  3592. (define_insn "rotrsi3"
  3593.   [(set (match_operand:SI 0 "register_operand" "=d")
  3594.     (rotatert:SI (match_operand:SI 1 "register_operand" "0")
  3595.              (match_operand:SI 2 "general_operand" "dI")))]
  3596.   ""
  3597.   "ror%.l %2,%0")
  3598.  
  3599. (define_insn "rotrhi3"
  3600.   [(set (match_operand:HI 0 "register_operand" "=d")
  3601.     (rotatert:HI (match_operand:HI 1 "register_operand" "0")
  3602.              (match_operand:HI 2 "general_operand" "dI")))]
  3603.   ""
  3604.   "ror%.w %2,%0")
  3605.  
  3606. (define_insn ""
  3607.   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
  3608.     (rotatert:HI (match_dup 0)
  3609.              (match_operand:HI 1 "general_operand" "dI")))]
  3610.   ""
  3611.   "ror%.w %1,%0")
  3612.  
  3613. (define_insn "rotrqi3"
  3614.   [(set (match_operand:QI 0 "register_operand" "=d")
  3615.     (rotatert:QI (match_operand:QI 1 "register_operand" "0")
  3616.              (match_operand:QI 2 "general_operand" "dI")))]
  3617.   ""
  3618.   "ror%.b %2,%0")
  3619.  
  3620. (define_insn ""
  3621.   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
  3622.     (rotatert:QI (match_dup 0)
  3623.              (match_operand:QI 1 "general_operand" "dI")))]
  3624.   ""
  3625.   "ror%.b %1,%0")
  3626.  
  3627. ;; Special cases of bit-field insns which we should
  3628. ;; recognize in preference to the general case.
  3629. ;; These handle aligned 8-bit and 16-bit fields,
  3630. ;; which can usually be done with move instructions.
  3631.  
  3632. ;
  3633. ; Special case for 32-bit field in memory.  This only occurs when 32-bit
  3634. ; alignment of structure members is specified.
  3635. ;
  3636. ; The move is allowed to be odd byte aligned, because that's still faster
  3637. ; than an odd byte aligned bit field instruction.
  3638. ;
  3639. (define_insn ""
  3640.   [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o")
  3641.              (match_operand:SI 1 "immediate_operand" "i")
  3642.              (match_operand:SI 2 "immediate_operand" "i"))
  3643.     (match_operand:SI 3 "general_operand" "rmi"))]
  3644.   "TARGET_68020 && TARGET_BITFIELD
  3645.    && GET_CODE (operands[1]) == CONST_INT
  3646.    && (INTVAL (operands[1]) == 32)
  3647.    && GET_CODE (operands[2]) == CONST_INT
  3648.    && (INTVAL (operands[2]) % 8) == 0
  3649.    && ! mode_dependent_address_p (XEXP (operands[0], 0))"
  3650.   "*
  3651. {
  3652.   operands[0]
  3653.     = adj_offsettable_operand (operands[0], INTVAL (operands[2]) / 8);
  3654.  
  3655.   return \"move%.l %3,%0\";
  3656. }")
  3657.  
  3658. (define_insn ""
  3659.   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+do")
  3660.              (match_operand:SI 1 "immediate_operand" "i")
  3661.              (match_operand:SI 2 "immediate_operand" "i"))
  3662.     (match_operand:SI 3 "general_operand" "d"))]
  3663.   "TARGET_68020 && TARGET_BITFIELD
  3664.    && GET_CODE (operands[1]) == CONST_INT
  3665.    && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
  3666.    && GET_CODE (operands[2]) == CONST_INT
  3667.    && INTVAL (operands[2]) % INTVAL (operands[1]) == 0
  3668.    && (GET_CODE (operands[0]) == REG
  3669.        || ! mode_dependent_address_p (XEXP (operands[0], 0)))"
  3670.   "*
  3671. {
  3672.   if (REG_P (operands[0]))
  3673.     {
  3674.       if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
  3675.         return \"bfins %3,%0{%b2:%b1}\";
  3676.     }
  3677.   else
  3678.     operands[0]
  3679.       = adj_offsettable_operand (operands[0], INTVAL (operands[2]) / 8);
  3680.  
  3681.   if (GET_CODE (operands[3]) == MEM)
  3682.     operands[3] = adj_offsettable_operand (operands[3],
  3683.                        (32 - INTVAL (operands[1])) / 8);
  3684.   if (INTVAL (operands[1]) == 8)
  3685.     return \"move%.b %3,%0\";
  3686.   return \"move%.w %3,%0\";
  3687. }")
  3688.  
  3689.  
  3690. ;
  3691. ; Special case for 32-bit field in memory.  This only occurs when 32-bit
  3692. ; alignment of structure members is specified.
  3693. ;
  3694. ; The move is allowed to be odd byte aligned, because that's still faster
  3695. ; than an odd byte aligned bit field instruction.
  3696. ;
  3697. (define_insn ""
  3698.   [(set (match_operand:SI 0 "general_operand" "=rm")
  3699.     (zero_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o")
  3700.              (match_operand:SI 2 "immediate_operand" "i")
  3701.              (match_operand:SI 3 "immediate_operand" "i")))]
  3702.   "TARGET_68020 && TARGET_BITFIELD
  3703.    && GET_CODE (operands[2]) == CONST_INT
  3704.    && (INTVAL (operands[2]) == 32)
  3705.    && GET_CODE (operands[3]) == CONST_INT
  3706.    && (INTVAL (operands[3]) % 8) == 0
  3707.    && ! mode_dependent_address_p (XEXP (operands[1], 0))"
  3708.   "*
  3709. {
  3710.   operands[1]
  3711.     = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8);
  3712.  
  3713.   return \"move%.l %1,%0\";
  3714. }")
  3715.  
  3716. (define_insn ""
  3717.   [(set (match_operand:SI 0 "general_operand" "=&d")
  3718.     (zero_extract:SI (match_operand:SI 1 "nonimmediate_operand" "do")
  3719.              (match_operand:SI 2 "immediate_operand" "i")
  3720.              (match_operand:SI 3 "immediate_operand" "i")))]
  3721.   "TARGET_68020 && TARGET_BITFIELD
  3722.    && GET_CODE (operands[2]) == CONST_INT
  3723.    && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
  3724.    && GET_CODE (operands[3]) == CONST_INT
  3725.    && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
  3726.    && (GET_CODE (operands[1]) == REG
  3727.        || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
  3728.   "*
  3729. {
  3730.   cc_status.flags |= CC_NOT_NEGATIVE;
  3731.   if (REG_P (operands[1]))
  3732.     {
  3733.       if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
  3734.     return \"bfextu %1{%b3:%b2},%0\";
  3735.     }
  3736.   else
  3737.     operands[1]
  3738.       = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8);
  3739.  
  3740.   output_asm_insn (\"clr%.l %0\", operands);
  3741.   if (GET_CODE (operands[0]) == MEM)
  3742.     operands[0] = adj_offsettable_operand (operands[0],
  3743.                        (32 - INTVAL (operands[1])) / 8);
  3744.   if (INTVAL (operands[2]) == 8)
  3745.     return \"move%.b %1,%0\";
  3746.   return \"move%.w %1,%0\";
  3747. }")
  3748.  
  3749. ;
  3750. ; Special case for 32-bit field in memory.  This only occurs when 32-bit
  3751. ; alignment of structure members is specified.
  3752. ;
  3753. ; The move is allowed to be odd byte aligned, because that's still faster
  3754. ; than an odd byte aligned bit field instruction.
  3755. ;
  3756. (define_insn ""
  3757.   [(set (match_operand:SI 0 "general_operand" "=rm")
  3758.     (sign_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o")
  3759.              (match_operand:SI 2 "immediate_operand" "i")
  3760.              (match_operand:SI 3 "immediate_operand" "i")))]
  3761.   "TARGET_68020 && TARGET_BITFIELD
  3762.    && GET_CODE (operands[2]) == CONST_INT
  3763.    && (INTVAL (operands[2]) == 32)
  3764.    && GET_CODE (operands[3]) == CONST_INT
  3765.    && (INTVAL (operands[3]) % 8) == 0
  3766.    && ! mode_dependent_address_p (XEXP (operands[1], 0))"
  3767.   "*
  3768. {
  3769.   operands[1]
  3770.     = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8);
  3771.  
  3772.   return \"move%.l %1,%0\";
  3773. }")
  3774.  
  3775. (define_insn ""
  3776.   [(set (match_operand:SI 0 "general_operand" "=d")
  3777.     (sign_extract:SI (match_operand:SI 1 "nonimmediate_operand" "do")
  3778.              (match_operand:SI 2 "immediate_operand" "i")
  3779.              (match_operand:SI 3 "immediate_operand" "i")))]
  3780.   "TARGET_68020 && TARGET_BITFIELD
  3781.    && GET_CODE (operands[2]) == CONST_INT
  3782.    && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
  3783.    && GET_CODE (operands[3]) == CONST_INT
  3784.    && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
  3785.    && (GET_CODE (operands[1]) == REG
  3786.        || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
  3787.   "*
  3788. {
  3789.   if (REG_P (operands[1]))
  3790.     {
  3791.       if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
  3792.     return \"bfexts %1{%b3:%b2},%0\";
  3793.     }
  3794.   else
  3795.     operands[1]
  3796.       = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8);
  3797.  
  3798.   if (INTVAL (operands[2]) == 8)
  3799.     return \"move%.b %1,%0\;extb%.l %0\";
  3800.   return \"move%.w %1,%0\;ext%.l %0\";
  3801. }")
  3802.  
  3803. ;; Bit field instructions, general cases.
  3804. ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
  3805. ;; so that its address is reloaded.
  3806.  
  3807. (define_insn "extv"
  3808.   [(set (match_operand:SI 0 "general_operand" "=d,d")
  3809.     (sign_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o,d")
  3810.              (match_operand:SI 2 "general_operand" "di,di")
  3811.              (match_operand:SI 3 "general_operand" "di,di")))]
  3812.   "TARGET_68020 && TARGET_BITFIELD"
  3813.   "bfexts %1{%b3:%b2},%0")
  3814.  
  3815. (define_insn "extzv"
  3816.   [(set (match_operand:SI 0 "general_operand" "=d,d")
  3817.     (zero_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o,d")
  3818.              (match_operand:SI 2 "general_operand" "di,di")
  3819.              (match_operand:SI 3 "general_operand" "di,di")))]
  3820.   "TARGET_68020 && TARGET_BITFIELD"
  3821.   "*
  3822. {
  3823.   cc_status.flags |= CC_NOT_NEGATIVE;
  3824.   return \"bfextu %1{%b3:%b2},%0\";
  3825. }")
  3826.  
  3827. (define_insn ""
  3828.   [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d")
  3829.              (match_operand:SI 1 "general_operand" "di,di")
  3830.              (match_operand:SI 2 "general_operand" "di,di"))
  3831.         (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
  3832.         (match_operand 3 "immediate_operand" "i,i")))]
  3833.   "TARGET_68020 && TARGET_BITFIELD
  3834.    && GET_CODE (operands[3]) == CONST_INT
  3835.    && (INTVAL (operands[3]) == -1
  3836.        || (GET_CODE (operands[1]) == CONST_INT
  3837.            && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
  3838.   "*
  3839. {
  3840.   CC_STATUS_INIT;
  3841.   return \"bfchg %0{%b2:%b1}\";
  3842. }")
  3843.  
  3844. (define_insn ""
  3845.   [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d")
  3846.              (match_operand:SI 1 "general_operand" "di,di")
  3847.              (match_operand:SI 2 "general_operand" "di,di"))
  3848.     (const_int 0))]
  3849.   "TARGET_68020 && TARGET_BITFIELD"
  3850.   "*
  3851. {
  3852.   CC_STATUS_INIT;
  3853.   return \"bfclr %0{%b2:%b1}\";
  3854. }")
  3855.  
  3856. (define_insn ""
  3857.   [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d")
  3858.              (match_operand:SI 1 "general_operand" "di,di")
  3859.              (match_operand:SI 2 "general_operand" "di,di"))
  3860.     (const_int -1))]
  3861.   "TARGET_68020 && TARGET_BITFIELD"
  3862.   "*
  3863. {
  3864.   CC_STATUS_INIT;
  3865.   return \"bfset %0{%b2:%b1}\";
  3866. }")
  3867.  
  3868. (define_insn "insv"
  3869.   [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d")
  3870.              (match_operand:SI 1 "general_operand" "di,di")
  3871.              (match_operand:SI 2 "general_operand" "di,di"))
  3872.     (match_operand:SI 3 "general_operand" "d,d"))]
  3873.   "TARGET_68020 && TARGET_BITFIELD"
  3874.   "bfins %3,%0{%b2:%b1}")
  3875.  
  3876. ;; Now recognize bit field insns that operate on registers
  3877. ;; (or at least were intended to do so).
  3878.  
  3879. (define_insn ""
  3880.   [(set (match_operand:SI 0 "general_operand" "=d")
  3881.     (sign_extract:SI (match_operand:SI 1 "nonimmediate_operand" "d")
  3882.              (match_operand:SI 2 "general_operand" "di")
  3883.              (match_operand:SI 3 "general_operand" "di")))]
  3884.   "TARGET_68020 && TARGET_BITFIELD"
  3885.   "bfexts %1{%b3:%b2},%0")
  3886.  
  3887. (define_insn ""
  3888.   [(set (match_operand:SI 0 "general_operand" "=d")
  3889.     (zero_extract:SI (match_operand:SI 1 "nonimmediate_operand" "d")
  3890.              (match_operand:SI 2 "general_operand" "di")
  3891.              (match_operand:SI 3 "general_operand" "di")))]
  3892.   "TARGET_68020 && TARGET_BITFIELD"
  3893.   "*
  3894. {
  3895.   cc_status.flags |= CC_NOT_NEGATIVE;
  3896.   return \"bfextu %1{%b3:%b2},%0\";
  3897. }")
  3898.  
  3899. (define_insn ""
  3900.   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d")
  3901.              (match_operand:SI 1 "general_operand" "di")
  3902.              (match_operand:SI 2 "general_operand" "di"))
  3903.     (const_int 0))]
  3904.   "TARGET_68020 && TARGET_BITFIELD"
  3905.   "*
  3906. {
  3907.   CC_STATUS_INIT;
  3908.   return \"bfclr %0{%b2:%b1}\";
  3909. }")
  3910.  
  3911. (define_insn ""
  3912.   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d")
  3913.              (match_operand:SI 1 "general_operand" "di")
  3914.              (match_operand:SI 2 "general_operand" "di"))
  3915.     (const_int -1))]
  3916.   "TARGET_68020 && TARGET_BITFIELD"
  3917.   "*
  3918. {
  3919.   CC_STATUS_INIT;
  3920.   return \"bfset %0{%b2:%b1}\";
  3921. }")
  3922.  
  3923. (define_insn ""
  3924.   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d")
  3925.              (match_operand:SI 1 "general_operand" "di")
  3926.              (match_operand:SI 2 "general_operand" "di"))
  3927.     (match_operand:SI 3 "general_operand" "d"))]
  3928.   "TARGET_68020 && TARGET_BITFIELD"
  3929.   "*
  3930. {
  3931. #if 0
  3932.   /* These special cases are now recognized by a specific pattern.  */
  3933.   if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
  3934.       && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
  3935.     return \"move%.w %3,%0\";
  3936.   if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
  3937.       && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
  3938.     return \"move%.b %3,%0\";
  3939. #endif
  3940.   return \"bfins %3,%0{%b2:%b1}\";
  3941. }")
  3942.  
  3943. ;; Special patterns for optimizing bit-field instructions.
  3944.  
  3945. (define_insn ""
  3946.   [(set (cc0)
  3947.     (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
  3948.              (match_operand:SI 1 "general_operand" "di")
  3949.              (match_operand:SI 2 "general_operand" "di")))]
  3950.   "TARGET_68020 && TARGET_BITFIELD
  3951.    && GET_CODE (operands[1]) == CONST_INT"
  3952.   "*
  3953. {
  3954.   if (operands[1] == const1_rtx
  3955.       && GET_CODE (operands[2]) == CONST_INT)
  3956.     {    
  3957.       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
  3958.       return output_btst (operands,
  3959.               gen_rtx (CONST_INT, VOIDmode,
  3960.                    width - INTVAL (operands[2])),
  3961.               operands[0],
  3962.               insn, 1000);
  3963.       /* Pass 1000 as SIGNPOS argument so that btst will
  3964.          not think we are testing the sign bit for an `and'
  3965.      and assume that nonzero implies a negative result.  */
  3966.     }
  3967.   if (INTVAL (operands[1]) != 32)
  3968.     cc_status.flags = CC_NOT_NEGATIVE;
  3969.   return \"bftst %0{%b2:%b1}\";
  3970. }")
  3971.  
  3972.   
  3973. ;;; now handle the register cases
  3974. (define_insn ""
  3975.   [(set (cc0)
  3976.     (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "d")
  3977.              (match_operand:SI 1 "general_operand" "di")
  3978.              (match_operand:SI 2 "general_operand" "di")))]
  3979.   "TARGET_68020 && TARGET_BITFIELD
  3980.    && GET_CODE (operands[1]) == CONST_INT"
  3981.   "*
  3982. {
  3983.   if (operands[1] == const1_rtx
  3984.       && GET_CODE (operands[2]) == CONST_INT)
  3985.     {    
  3986.       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
  3987.       return output_btst (operands,
  3988.               gen_rtx (CONST_INT, VOIDmode,
  3989.                    width - INTVAL (operands[2])),
  3990.               operands[0],
  3991.               insn, 1000);
  3992.       /* Pass 1000 as SIGNPOS argument so that btst will
  3993.          not think we are testing the sign bit for an `and'
  3994.      and assume that nonzero implies a negative result.  */
  3995.     }
  3996.   if (INTVAL (operands[1]) != 32)
  3997.     cc_status.flags = CC_NOT_NEGATIVE;
  3998.   return \"bftst %0{%b2:%b1}\";
  3999. }")
  4000.  
  4001. (define_insn "seq"
  4002.   [(set (match_operand:QI 0 "general_operand" "=d")
  4003.     (eq:QI (cc0) (const_int 0)))]
  4004.   ""
  4005.   "*
  4006.   cc_status = cc_prev_status;
  4007.   OUTPUT_JUMP (\"seq %0\", \"fseq %0\", \"seq %0\");
  4008. ")
  4009.  
  4010. (define_insn "sne"
  4011.   [(set (match_operand:QI 0 "general_operand" "=d")
  4012.     (ne:QI (cc0) (const_int 0)))]
  4013.   ""
  4014.   "*
  4015.   cc_status = cc_prev_status;
  4016.   OUTPUT_JUMP (\"sne %0\", \"fsne %0\", \"sne %0\");
  4017. ")
  4018.  
  4019. (define_insn "sgt"
  4020.   [(set (match_operand:QI 0 "general_operand" "=d")
  4021.     (gt:QI (cc0) (const_int 0)))]
  4022.   ""
  4023.   "*
  4024.   cc_status = cc_prev_status;
  4025.   OUTPUT_JUMP (\"sgt %0\", \"fsgt %0\", 0);
  4026. ")
  4027.  
  4028. (define_insn "sgtu"
  4029.   [(set (match_operand:QI 0 "general_operand" "=d")
  4030.     (gtu:QI (cc0) (const_int 0)))]
  4031.   ""
  4032.   "* cc_status = cc_prev_status;
  4033.      return \"shi %0\"; ")
  4034.  
  4035. (define_insn "slt"
  4036.   [(set (match_operand:QI 0 "general_operand" "=d")
  4037.     (lt:QI (cc0) (const_int 0)))]
  4038.   ""
  4039.   "* cc_status = cc_prev_status;
  4040.      OUTPUT_JUMP (\"slt %0\", \"fslt %0\", \"smi %0\"); ")
  4041.  
  4042. (define_insn "sltu"
  4043.   [(set (match_operand:QI 0 "general_operand" "=d")
  4044.     (ltu:QI (cc0) (const_int 0)))]
  4045.   ""
  4046.   "* cc_status = cc_prev_status;
  4047.      return \"scs %0\"; ")
  4048.  
  4049. (define_insn "sge"
  4050.   [(set (match_operand:QI 0 "general_operand" "=d")
  4051.     (ge:QI (cc0) (const_int 0)))]
  4052.   ""
  4053.   "* cc_status = cc_prev_status;
  4054.      OUTPUT_JUMP (\"sge %0\", \"fsge %0\", \"spl %0\"); ")
  4055.  
  4056. (define_insn "sgeu"
  4057.   [(set (match_operand:QI 0 "general_operand" "=d")
  4058.     (geu:QI (cc0) (const_int 0)))]
  4059.   ""
  4060.   "* cc_status = cc_prev_status;
  4061.      return \"scc %0\"; ")
  4062.  
  4063. (define_insn "sle"
  4064.   [(set (match_operand:QI 0 "general_operand" "=d")
  4065.     (le:QI (cc0) (const_int 0)))]
  4066.   ""
  4067.   "*
  4068.   cc_status = cc_prev_status;
  4069.   OUTPUT_JUMP (\"sle %0\", \"fsle %0\", 0);
  4070. ")
  4071.  
  4072. (define_insn "sleu"
  4073.   [(set (match_operand:QI 0 "general_operand" "=d")
  4074.     (leu:QI (cc0) (const_int 0)))]
  4075.   ""
  4076.   "* cc_status = cc_prev_status;
  4077.      return \"sls %0\"; ")
  4078.  
  4079. ;; Basic conditional jump instructions.
  4080.  
  4081. (define_insn "beq"
  4082.   [(set (pc)
  4083.     (if_then_else (eq (cc0)
  4084.               (const_int 0))
  4085.               (label_ref (match_operand 0 "" ""))
  4086.               (pc)))]
  4087.   ""
  4088.   "*
  4089. {
  4090. #ifdef MOTOROLA
  4091.   OUTPUT_JUMP (\"jbeq %l0\", \"fbeq %l0\", \"jbeq %l0\");
  4092. #else
  4093.   OUTPUT_JUMP (\"jeq %l0\", \"fjeq %l0\", \"jeq %l0\");
  4094. #endif
  4095. }")
  4096.  
  4097. (define_insn "bne"
  4098.   [(set (pc)
  4099.     (if_then_else (ne (cc0)
  4100.               (const_int 0))
  4101.               (label_ref (match_operand 0 "" ""))
  4102.               (pc)))]
  4103.   ""
  4104.   "*
  4105. {
  4106. #ifdef MOTOROLA
  4107.   OUTPUT_JUMP (\"jbne %l0\", \"fbne %l0\", \"jbne %l0\");
  4108. #else
  4109.   OUTPUT_JUMP (\"jne %l0\", \"fjne %l0\", \"jne %l0\");
  4110. #endif
  4111. }")
  4112.  
  4113. (define_insn "bgt"
  4114.   [(set (pc)
  4115.     (if_then_else (gt (cc0)
  4116.               (const_int 0))
  4117.               (label_ref (match_operand 0 "" ""))
  4118.               (pc)))]
  4119.   ""
  4120.   "*
  4121. #ifdef MOTOROLA
  4122.   OUTPUT_JUMP (\"jbgt %l0\", \"fbgt %l0\", 0);
  4123. #else
  4124.   OUTPUT_JUMP (\"jgt %l0\", \"fjgt %l0\", 0);
  4125. #endif
  4126. ")
  4127.  
  4128. (define_insn "bgtu"
  4129.   [(set (pc)
  4130.     (if_then_else (gtu (cc0)
  4131.                (const_int 0))
  4132.               (label_ref (match_operand 0 "" ""))
  4133.               (pc)))]
  4134.   ""
  4135.   "*
  4136. #ifdef MOTOROLA
  4137.   return \"jbhi %l0\";
  4138. #else
  4139.   return \"jhi %l0\";
  4140. #endif
  4141. ")
  4142.  
  4143. (define_insn "blt"
  4144.   [(set (pc)
  4145.     (if_then_else (lt (cc0)
  4146.               (const_int 0))
  4147.               (label_ref (match_operand 0 "" ""))
  4148.               (pc)))]
  4149.   ""
  4150.   "*
  4151. #ifdef MOTOROLA
  4152.   OUTPUT_JUMP (\"jblt %l0\", \"fblt %l0\", \"jbmi %l0\");
  4153. #else
  4154.   OUTPUT_JUMP (\"jlt %l0\", \"fjlt %l0\", \"jmi %l0\");
  4155. #endif
  4156. ")
  4157.  
  4158. (define_insn "bltu"
  4159.   [(set (pc)
  4160.     (if_then_else (ltu (cc0)
  4161.                (const_int 0))
  4162.               (label_ref (match_operand 0 "" ""))
  4163.               (pc)))]
  4164.   ""
  4165.   "*
  4166. #ifdef MOTOROLA
  4167.   return \"jbcs %l0\";
  4168. #else
  4169.   return \"jcs %l0\";
  4170. #endif
  4171. ")
  4172.  
  4173. (define_insn "bge"
  4174.   [(set (pc)
  4175.     (if_then_else (ge (cc0)
  4176.               (const_int 0))
  4177.               (label_ref (match_operand 0 "" ""))
  4178.               (pc)))]
  4179.   ""
  4180.   "*
  4181. #ifdef MOTOROLA
  4182.   OUTPUT_JUMP (\"jbge %l0\", \"fbge %l0\", \"jbpl %l0\");
  4183. #else
  4184.   OUTPUT_JUMP (\"jge %l0\", \"fjge %l0\", \"jpl %l0\");
  4185. #endif
  4186. ")
  4187.  
  4188. (define_insn "bgeu"
  4189.   [(set (pc)
  4190.     (if_then_else (geu (cc0)
  4191.                (const_int 0))
  4192.               (label_ref (match_operand 0 "" ""))
  4193.               (pc)))]
  4194.   ""
  4195.   "*
  4196. #ifdef MOTOROLA
  4197.   return \"jbcc %l0\";
  4198. #else
  4199.   return \"jcc %l0\";
  4200. #endif
  4201. ")
  4202.  
  4203. (define_insn "ble"
  4204.   [(set (pc)
  4205.     (if_then_else (le (cc0)
  4206.               (const_int 0))
  4207.               (label_ref (match_operand 0 "" ""))
  4208.               (pc)))]
  4209.   ""
  4210.   "*
  4211. #ifdef MOTOROLA
  4212.   OUTPUT_JUMP (\"jble %l0\", \"fble %l0\", 0);
  4213. #else
  4214.   OUTPUT_JUMP (\"jle %l0\", \"fjle %l0\", 0);
  4215. #endif
  4216. ")
  4217.  
  4218. (define_insn "bleu"
  4219.   [(set (pc)
  4220.     (if_then_else (leu (cc0)
  4221.                (const_int 0))
  4222.               (label_ref (match_operand 0 "" ""))
  4223.               (pc)))]
  4224.   ""
  4225.   "*
  4226. #ifdef MOTOROLA
  4227.   return \"jbls %l0\";
  4228. #else
  4229.   return \"jls %l0\";
  4230. #endif
  4231. ")
  4232.  
  4233. ;; Negated conditional jump instructions.
  4234.  
  4235. (define_insn ""
  4236.   [(set (pc)
  4237.     (if_then_else (eq (cc0)
  4238.               (const_int 0))
  4239.               (pc)
  4240.               (label_ref (match_operand 0 "" ""))))]
  4241.   ""
  4242.   "*
  4243. {
  4244. #ifdef MOTOROLA
  4245.   OUTPUT_JUMP (\"jbne %l0\", \"fbne %l0\", \"jbne %l0\");
  4246. #else
  4247.   OUTPUT_JUMP (\"jne %l0\", \"fjne %l0\", \"jne %l0\");
  4248. #endif
  4249. }")
  4250.  
  4251. (define_insn ""
  4252.   [(set (pc)
  4253.     (if_then_else (ne (cc0)
  4254.               (const_int 0))
  4255.               (pc)
  4256.               (label_ref (match_operand 0 "" ""))))]
  4257.   ""
  4258.   "*
  4259. {
  4260. #ifdef MOTOROLA
  4261.   OUTPUT_JUMP (\"jbeq %l0\", \"fbeq %l0\", \"jbeq %l0\");
  4262. #else
  4263.   OUTPUT_JUMP (\"jeq %l0\", \"fjeq %l0\", \"jeq %l0\");
  4264. #endif
  4265. }")
  4266.  
  4267. (define_insn ""
  4268.   [(set (pc)
  4269.     (if_then_else (gt (cc0)
  4270.               (const_int 0))
  4271.               (pc)
  4272.               (label_ref (match_operand 0 "" ""))))]
  4273.   ""
  4274.   "*
  4275. #ifdef MOTOROLA
  4276.   OUTPUT_JUMP (\"jble %l0\", \"fbngt %l0\", 0);
  4277. #else
  4278.   OUTPUT_JUMP (\"jle %l0\", \"fjngt %l0\", 0);
  4279. #endif
  4280. ")
  4281.  
  4282. (define_insn ""
  4283.   [(set (pc)
  4284.     (if_then_else (gtu (cc0)
  4285.                (const_int 0))
  4286.               (pc)
  4287.               (label_ref (match_operand 0 "" ""))))]
  4288.   ""
  4289.   "*
  4290. #ifdef MOTOROLA
  4291.   return \"jbls %l0\";
  4292. #else
  4293.   return \"jls %l0\";
  4294. #endif
  4295. ")
  4296.  
  4297. (define_insn ""
  4298.   [(set (pc)
  4299.     (if_then_else (lt (cc0)
  4300.               (const_int 0))
  4301.               (pc)
  4302.               (label_ref (match_operand 0 "" ""))))]
  4303.   ""
  4304.   "*
  4305. #ifdef MOTOROLA
  4306.   OUTPUT_JUMP (\"jbge %l0\", \"fbnlt %l0\", \"jbpl %l0\");
  4307. #else
  4308.   OUTPUT_JUMP (\"jge %l0\", \"fjnlt %l0\", \"jpl %l0\");
  4309. #endif
  4310. ")
  4311.  
  4312. (define_insn ""
  4313.   [(set (pc)
  4314.     (if_then_else (ltu (cc0)
  4315.                (const_int 0))
  4316.               (pc)
  4317.               (label_ref (match_operand 0 "" ""))))]
  4318.   ""
  4319.   "*
  4320. #ifdef MOTOROLA
  4321.   return \"jbcc %l0\";
  4322. #else
  4323.   return \"jcc %l0\";
  4324. #endif
  4325. ")
  4326.  
  4327. (define_insn ""
  4328.   [(set (pc)
  4329.     (if_then_else (ge (cc0)
  4330.               (const_int 0))
  4331.               (pc)
  4332.               (label_ref (match_operand 0 "" ""))))]
  4333.   ""
  4334.   "*
  4335. #ifdef MOTOROLA
  4336.   OUTPUT_JUMP (\"jblt %l0\", \"fbnge %l0\", \"jbmi %l0\");
  4337. #else
  4338.   OUTPUT_JUMP (\"jlt %l0\", \"fjnge %l0\", \"jmi %l0\");
  4339. #endif
  4340. ")
  4341.  
  4342. (define_insn ""
  4343.   [(set (pc)
  4344.     (if_then_else (geu (cc0)
  4345.                (const_int 0))
  4346.               (pc)
  4347.               (label_ref (match_operand 0 "" ""))))]
  4348.   ""
  4349.   "*
  4350. #ifdef MOTOROLA
  4351.   return \"jbcs %l0\";
  4352. #else
  4353.   return \"jcs %l0\";
  4354. #endif
  4355. ")
  4356.  
  4357. (define_insn ""
  4358.   [(set (pc)
  4359.     (if_then_else (le (cc0)
  4360.               (const_int 0))
  4361.               (pc)
  4362.               (label_ref (match_operand 0 "" ""))))]
  4363.   ""
  4364.   "*
  4365. #ifdef MOTOROLA
  4366.   OUTPUT_JUMP (\"jbgt %l0\", \"fbnle %l0\", 0);
  4367. #else
  4368.   OUTPUT_JUMP (\"jgt %l0\", \"fjnle %l0\", 0);
  4369. #endif
  4370. ")
  4371.  
  4372. (define_insn ""
  4373.   [(set (pc)
  4374.     (if_then_else (leu (cc0)
  4375.                (const_int 0))
  4376.               (pc)
  4377.               (label_ref (match_operand 0 "" ""))))]
  4378.   ""
  4379.   "*
  4380. #ifdef MOTOROLA
  4381.   return \"jbhi %l0\";
  4382. #else
  4383.   return \"jhi %l0\";
  4384. #endif
  4385. ")
  4386.  
  4387. ;; Unconditional and other jump instructions
  4388. (define_insn "jump"
  4389.   [(set (pc)
  4390.     (label_ref (match_operand 0 "" "")))]
  4391.   ""
  4392.   "*
  4393. #ifdef MOTOROLA
  4394.   return \"jbra %l0\";
  4395. #else
  4396.   return \"jra %l0\";
  4397. #endif
  4398. ")
  4399.  
  4400. ;; We support two different ways of handling dispatch tables.
  4401. ;; The NeXT uses absolute tables, and other machines use relative.
  4402. ;; This define_expand can generate either kind.
  4403. (define_expand "tablejump"
  4404.   [(parallel [(set (pc) (match_operand 0 "" ""))
  4405.           (use (label_ref (match_operand 1 "" "")))])]
  4406.   ""
  4407.   "
  4408. {
  4409. #ifdef CASE_VECTOR_PC_RELATIVE
  4410.     operands[0] = gen_rtx (PLUS, SImode, pc_rtx, operands[0]);
  4411. #endif
  4412. }")
  4413.  
  4414. ;; Jump to variable address from dispatch table of absolute addresses.
  4415. (define_insn ""
  4416.   [(set (pc) (match_operand:SI 0 "register_operand" "a"))
  4417.    (use (label_ref (match_operand 1 "" "")))]
  4418.   ""
  4419.   "*
  4420. #ifdef MOTOROLA
  4421.   return \"jmp (%0)\";
  4422. #else
  4423.   return \"jmp %0@\";
  4424. #endif
  4425. ")
  4426.  
  4427. ;; Jump to variable address from dispatch table of relative addresses.
  4428. (define_insn ""
  4429.   [(set (pc)
  4430.     (plus:SI (pc) (match_operand:HI 0 "register_operand" "r")))
  4431.    (use (label_ref (match_operand 1 "" "")))]
  4432.   ""
  4433.   "*
  4434. #ifdef ASM_RETURN_CASE_JUMP
  4435.  ASM_RETURN_CASE_JUMP;
  4436. #else
  4437. #ifdef SGS
  4438. #ifdef ASM_OUTPUT_CASE_LABEL
  4439.   return \"jmp 6(%%pc,%0.w)\";
  4440. #else
  4441. #ifdef CRDS
  4442.   return \"jmp 2(pc,%0.w)\";
  4443. #else
  4444.   return \"jmp 2(%%pc,%0.w)\";
  4445. #endif  /* end !CRDS */
  4446. #endif
  4447. #else /* not SGS */
  4448. #ifdef MOTOROLA
  4449.   return \"jmp (2,pc,%0.w)\";
  4450. #else
  4451.   return \"jmp pc@(2,%0:w)\";
  4452. #endif
  4453. #endif
  4454. #endif
  4455. ")
  4456.  
  4457. ;; Decrement-and-branch insns.
  4458. (define_insn ""
  4459.   [(set (pc)
  4460.     (if_then_else
  4461.      (ne (match_operand:HI 0 "general_operand" "+g")
  4462.          (const_int 0))
  4463.      (label_ref (match_operand 1 "" ""))
  4464.      (pc)))
  4465.    (set (match_dup 0)
  4466.     (plus:HI (match_dup 0)
  4467.          (const_int -1)))]
  4468.   ""
  4469.   "*
  4470. {
  4471.   CC_STATUS_INIT;
  4472.   if (DATA_REG_P (operands[0]))
  4473.     return \"dbra %0,%l1\";
  4474.   if (GET_CODE (operands[0]) == MEM)
  4475.     {
  4476. #ifdef MOTOROLA
  4477. #ifdef NO_ADDSUB_Q
  4478.       return \"sub%.w %#1,%0\;jbcc %l1\";
  4479. #else
  4480.       return \"subq%.w %#1,%0\;jbcc %l1\";
  4481. #endif
  4482. #else /* not MOTOROLA */
  4483.       return \"subqw %#1,%0\;jcc %l1\";
  4484. #endif
  4485.     }
  4486. #ifdef MOTOROLA
  4487. #ifdef SGS_CMP_ORDER
  4488. #ifdef NO_ADDSUB_Q
  4489.   return \"sub%.w %#1,%0\;cmp%.w %0,%#-1\;jbne %l1\";
  4490. #else
  4491.   return \"subq%.w %#1,%0\;cmp%.w %0,%#-1\;jbne %l1\";
  4492. #endif
  4493. #else /* not SGS_CMP_ORDER */
  4494.   return \"subq%.w %#1,%0\;cmp%.w %#-1,%0\;jbne %l1\";
  4495. #endif
  4496. #else /* not MOTOROLA */
  4497.   return \"subqw %#1,%0\;cmpw %#-1,%0\;jne %l1\";
  4498. #endif
  4499. }")
  4500.  
  4501. (define_insn ""
  4502.   [(set (pc)
  4503.     (if_then_else
  4504.      (ne (match_operand:SI 0 "general_operand" "+g")
  4505.          (const_int 0))
  4506.      (label_ref (match_operand 1 "" ""))
  4507.      (pc)))
  4508.    (set (match_dup 0)
  4509.     (plus:SI (match_dup 0)
  4510.          (const_int -1)))]
  4511.   ""
  4512.   "*
  4513. {
  4514.   CC_STATUS_INIT;
  4515. #ifdef MOTOROLA
  4516. #ifdef NO_ADDSUB_Q
  4517.   if (DATA_REG_P (operands[0]))
  4518.     return \"dbra %0,%l1\;clr%.w %0\;sub%.l %#1,%0\;jbcc %l1\";
  4519.   if (GET_CODE (operands[0]) == MEM)
  4520.     return \"sub%.l %#1,%0\;jbcc %l1\";
  4521. #else
  4522.   if (DATA_REG_P (operands[0]))
  4523.     return \"dbra %0,%l1\;clr%.w %0\;subq%.l %#1,%0\;jbcc %l1\";
  4524.   if (GET_CODE (operands[0]) == MEM)
  4525.     return \"subq%.l %#1,%0\;jbcc %l1\";
  4526. #endif /* NO_ADDSUB_Q */
  4527. #ifdef SGS_CMP_ORDER
  4528. #ifdef NO_ADDSUB_Q
  4529.   return \"sub.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\";
  4530. #else
  4531.   return \"subq.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\";
  4532. #endif
  4533. #else /* not SGS_CMP_ORDER */
  4534.   return \"subq.l %#1,%0\;cmp.l %#-1,%0\;jbne %l1\";
  4535. #endif /* not SGS_CMP_ORDER */
  4536. #else /* not MOTOROLA */
  4537.   if (DATA_REG_P (operands[0]))
  4538.     return \"dbra %0,%l1\;clr%.w %0\;subql %#1,%0\;jcc %l1\";
  4539.   if (GET_CODE (operands[0]) == MEM)
  4540.     return \"subql %#1,%0\;jcc %l1\";
  4541.   return \"subql %#1,%0\;cmpl %#-1,%0\;jne %l1\";
  4542. #endif /* not MOTOROLA */
  4543. }")
  4544.  
  4545. ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
  4546.  
  4547. (define_insn ""
  4548.   [(set (pc)
  4549.     (if_then_else
  4550.       (ge (plus:HI (match_operand:HI 0 "general_operand" "+g")
  4551.                (const_int -1))
  4552.           (const_int 0))
  4553.       (label_ref (match_operand 1 "" ""))
  4554.       (pc)))
  4555.    (set (match_dup 0)
  4556.     (plus:HI (match_dup 0)
  4557.          (const_int -1)))]
  4558.   "find_reg_note (insn, REG_NONNEG, 0)"
  4559.   "*
  4560. {
  4561.   CC_STATUS_INIT;
  4562. #ifdef MOTOROLA
  4563. #ifdef NO_ADDSUB_Q
  4564.   if (DATA_REG_P (operands[0]))
  4565.     return \"dbra %0,%l1\";
  4566.   if (GET_CODE (operands[0]) == MEM)
  4567.     return \"sub%.w %#1,%0\;jbcc %l1\";
  4568. #else
  4569.   if (DATA_REG_P (operands[0]))
  4570.     return \"dbra %0,%l1\";
  4571.   if (GET_CODE (operands[0]) == MEM)
  4572.     return \"subq%.w %#1,%0\;jbcc %l1\";
  4573. #endif
  4574. #ifdef SGS_CMP_ORDER
  4575. #ifdef NO_ADDSUB_Q
  4576.   return \"sub.w %#1,%0\;cmp.w %0,%#-1\;jbne %l1\";
  4577. #else
  4578.   return \"subq.w %#1,%0\;cmp.w %0,%#-1\;jbne %l1\";
  4579. #endif
  4580. #else /* not SGS_CMP_ORDER */
  4581.   return \"subq.w %#1,%0\;cmp.w %#-1,%0\;jbne %l1\";
  4582. #endif /* not SGS_CMP_ORDER */
  4583. #else /* not MOTOROLA */
  4584.   if (DATA_REG_P (operands[0]))
  4585.     return \"dbra %0,%l1\";
  4586.   if (GET_CODE (operands[0]) == MEM)
  4587.     return \"subqw %#1,%0\;jcc %l1\";
  4588.   return \"subqw %#1,%0\;cmpw %#-1,%0\;jne %l1\";
  4589. #endif /* not MOTOROLA */
  4590. }")
  4591.  
  4592. (define_insn "decrement_and_branch_until_zero"
  4593.   [(set (pc)
  4594.     (if_then_else
  4595.       (ge (plus:SI (match_operand:SI 0 "general_operand" "+g")
  4596.                (const_int -1))
  4597.           (const_int 0))
  4598.       (label_ref (match_operand 1 "" ""))
  4599.       (pc)))
  4600.    (set (match_dup 0)
  4601.     (plus:SI (match_dup 0)
  4602.          (const_int -1)))]
  4603.   "find_reg_note (insn, REG_NONNEG, 0)"
  4604.   "*
  4605. {
  4606.   CC_STATUS_INIT;
  4607. #ifdef MOTOROLA
  4608. #ifdef NO_ADDSUB_Q
  4609.   if (DATA_REG_P (operands[0]))
  4610.     return \"dbra %0,%l1\;clr%.w %0\;sub%.l %#1,%0\;jbcc %l1\";
  4611.   if (GET_CODE (operands[0]) == MEM)
  4612.     return \"sub%.l %#1,%0\;jbcc %l1\";
  4613. #else
  4614.   if (DATA_REG_P (operands[0]))
  4615.     return \"dbra %0,%l1\;clr%.w %0\;subq%.l %#1,%0\;jbcc %l1\";
  4616.   if (GET_CODE (operands[0]) == MEM)
  4617.     return \"subq%.l %#1,%0\;jbcc %l1\";
  4618. #endif
  4619. #ifdef SGS_CMP_ORDER
  4620. #ifdef NO_ADDSUB_Q
  4621.   return \"sub.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\";
  4622. #else
  4623.   return \"subq.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\";
  4624. #endif
  4625. #else /* not SGS_CMP_ORDER */
  4626.   return \"subq.l %#1,%0\;cmp.l %#-1,%0\;jbne %l1\";
  4627. #endif /* not SGS_CMP_ORDER */
  4628. #else /* not MOTOROLA */
  4629.   if (DATA_REG_P (operands[0]))
  4630.     return \"dbra %0,%l1\;clr%.w %0\;subql %#1,%0\;jcc %l1\";
  4631.   if (GET_CODE (operands[0]) == MEM)
  4632.     return \"subql %#1,%0\;jcc %l1\";
  4633.   return \"subql %#1,%0\;cmpl %#-1,%0\;jne %l1\";
  4634. #endif /* not MOTOROLA */
  4635. }")
  4636.  
  4637.  
  4638. ;; PIC calls are handled by loading the address of the function into a 
  4639. ;; register (via movsi), then emitting a register indirect call using
  4640. ;; the "jsr" function call syntax.
  4641. ;;
  4642. ;; It is important to note that the "jsr" syntax is always used for 
  4643. ;; PIC calls, even on machines in which GCC normally uses the "jbsr"
  4644. ;; syntax for non-PIC calls.  This keeps at least 1 assembler (Sun)
  4645. ;; from emitting incorrect code for a PIC call.
  4646. ;;
  4647. ;; We have different patterns for PIC calls and non-PIC calls.  The
  4648. ;; different patterns are only used to choose the right syntax
  4649. ;; ("jsr" vs "jbsr").
  4650.  
  4651. ;; Call subroutine with no return value.
  4652. (define_expand "call"
  4653.   [(call (match_operand:QI 0 "memory_operand" "")
  4654.      (match_operand:SI 1 "general_operand" ""))]
  4655.   ;; Operand 1 not really used on the m68000.
  4656.  
  4657.   ""
  4658.   "
  4659. {
  4660.   if (flag_pic && flag_pic < 3 && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
  4661.     operands[0] = gen_rtx (MEM, GET_MODE (operands[0]),
  4662.                force_reg (Pmode, XEXP (operands[0], 0)));
  4663. }")
  4664.  
  4665. ;; This is a normal call sequence.
  4666. (define_insn ""
  4667.   [(call (match_operand:QI 0 "memory_operand" "o")
  4668.      (match_operand:SI 1 "general_operand" "g"))]
  4669.   ;; Operand 1 not really used on the m68000.
  4670.  
  4671.   "(! flag_pic || flag_pic >= 3)"
  4672.   "*
  4673. #ifdef MOTOROLA
  4674.   return \"jsr %0\";
  4675. #else
  4676.   return \"jbsr %0\";
  4677. #endif
  4678. ")
  4679.  
  4680. ;; This is a PIC call sequence.
  4681. (define_insn ""
  4682.   [(call (match_operand:QI 0 "memory_operand" "o")
  4683.      (match_operand:SI 1 "general_operand" "g"))]
  4684.   ;; Operand 1 not really used on the m68000.
  4685.  
  4686.   "(flag_pic && flag_pic < 3)"
  4687.   "*
  4688.   return \"jsr %0\";
  4689. ")
  4690.  
  4691. ;; Call subroutine, returning value in operand 0
  4692. ;; (which must be a hard register).
  4693. ;; See comments before "call" regarding PIC calls.
  4694. (define_expand "call_value"
  4695.   [(set (match_operand 0 "" "")
  4696.     (call (match_operand:QI 1 "memory_operand" "")
  4697.      (match_operand:SI 2 "general_operand" "")))]
  4698.   ;; Operand 2 not really used on the m68000.
  4699.   ""
  4700.   "
  4701. {
  4702.   if (flag_pic && flag_pic < 3 && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
  4703.     operands[1] = gen_rtx (MEM, GET_MODE (operands[1]),
  4704.                force_reg (Pmode, XEXP (operands[1], 0)));
  4705. }")
  4706.  
  4707. ;; This is a normal call_value
  4708. (define_insn ""
  4709.   [(set (match_operand 0 "" "=rf")
  4710.     (call (match_operand:QI 1 "memory_operand" "o")
  4711.           (match_operand:SI 2 "general_operand" "g")))]
  4712.   ;; Operand 2 not really used on the m68000.
  4713.   "(! flag_pic || flag_pic >= 3)"
  4714.   "*
  4715. #ifdef MOTOROLA
  4716.   return \"jsr %1\";
  4717. #else
  4718.   return \"jbsr %1\";
  4719. #endif
  4720. ")
  4721.  
  4722. ;; This is a PIC call_value
  4723. (define_insn ""
  4724.   [(set (match_operand 0 "" "=rf")
  4725.     (call (match_operand:QI 1 "memory_operand" "o")
  4726.           (match_operand:SI 2 "general_operand" "g")))]
  4727.   ;; Operand 2 not really used on the m68000.
  4728.   "(flag_pic && flag_pic < 3)"
  4729.   "*
  4730.   return \"jsr %1\";
  4731. ")
  4732.  
  4733. (define_insn "nop"
  4734.   [(const_int 0)]
  4735.   ""
  4736.   "nop")
  4737.  
  4738. (define_insn "probe"
  4739.  [(reg:SI 15)]
  4740.  "NEED_PROBE"
  4741.  "*
  4742. {
  4743.   operands[0] = gen_rtx (PLUS, SImode, stack_pointer_rtx,
  4744.              gen_rtx (CONST_INT, VOIDmode, NEED_PROBE));
  4745.   return \"tstl %a0\";
  4746. }")
  4747.  
  4748. ;; Used for frameless functions which save no regs and allocate no locals.
  4749. (define_insn "return"
  4750.   [(return)]
  4751.   "USE_RETURN_INSN"
  4752.   "*
  4753. {
  4754.   if (current_function_pops_args == 0)
  4755.     return \"rts\";
  4756.   operands[0] = gen_rtx (CONST_INT, VOIDmode, current_function_pops_args);
  4757.   return \"rtd %0\";
  4758. }")
  4759.  
  4760. (define_insn "indirect_jump"
  4761.   [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
  4762.   ""
  4763.   "jmp %a0")
  4764.  
  4765. ;; This should not be used unless the add/sub insns can't be.
  4766.  
  4767. (define_insn ""
  4768.   [(set (match_operand:SI 0 "general_operand" "=a")
  4769.     (match_operand:QI 1 "address_operand" "p"))]
  4770.   ""
  4771.   "lea %a1,%0")
  4772.  
  4773. ;; This is the first machine-dependent peephole optimization.
  4774. ;; It is useful when a floating value is returned from a function call
  4775. ;; and then is moved into an FP register.
  4776. ;; But it is mainly intended to test the support for these optimizations.
  4777.  
  4778. (define_peephole
  4779.   [(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int 4)))
  4780.    (set (match_operand:DF 0 "register_operand" "=f")
  4781.     (match_operand:DF 1 "register_operand" "ad"))]
  4782.   "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
  4783.   "*
  4784. {
  4785.   rtx xoperands[2];
  4786.   xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  4787.   output_asm_insn (\"move%.l %1,%@\", xoperands);
  4788.   output_asm_insn (\"move%.l %1,%-\", operands);
  4789.   return \"fmove%.d %+,%0\";
  4790. }
  4791. ")
  4792.  
  4793. ;; Optimize a stack-adjust followed by a push of an argument.
  4794. ;; This is said to happen frequently with -msoft-float
  4795. ;; when there are consecutive library calls.
  4796.  
  4797. (define_peephole
  4798.   [(set (reg:SI 15) (plus:SI (reg:SI 15)
  4799.                  (match_operand:SI 0 "immediate_operand" "n")))
  4800.    (set (match_operand:SF 1 "push_operand" "=m")
  4801.     (match_operand:SF 2 "general_operand" "rmfF"))]
  4802.   "GET_CODE (operands[0]) == CONST_INT && INTVAL (operands[0]) >= 4
  4803.    && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
  4804.   "*
  4805. {
  4806.   if (INTVAL (operands[0]) > 4)
  4807.     {
  4808.       rtx xoperands[2];
  4809.       xoperands[0] = stack_pointer_rtx;
  4810.       xoperands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[0]) - 4);
  4811. #ifndef NO_ADDSUB_Q
  4812.       if (INTVAL (xoperands[1]) <= 8)
  4813.         output_asm_insn (\"addq%.w %1,%0\", xoperands);
  4814.       else if (INTVAL (xoperands[1]) <= 16 && TARGET_68020)
  4815.     {
  4816.       xoperands[1] = gen_rtx (CONST_INT, VOIDmode, 
  4817.                   INTVAL (xoperands[1]) - 8);
  4818.       output_asm_insn (\"addq%.w %#8,%0\;addq%.w %1,%0\", xoperands);
  4819.     }
  4820.       else
  4821. #endif
  4822.         if (INTVAL (xoperands[1]) <= 0x7FFF)
  4823.           output_asm_insn (\"add%.w %1,%0\", xoperands);
  4824.       else
  4825.         output_asm_insn (\"add%.l %1,%0\", xoperands);
  4826.     }
  4827.   if (FP_REG_P (operands[2]))
  4828.     return \"fmove%.s %2,%@\";
  4829.   return \"move%.l %2,%@\";
  4830. }")
  4831.  
  4832. ;; Speed up stack adjust followed by a fullword fixedpoint push.
  4833.  
  4834. (define_peephole
  4835.   [(set (reg:SI 15) (plus:SI (reg:SI 15)
  4836.                  (match_operand:SI 0 "immediate_operand" "n")))
  4837.    (set (match_operand:SI 1 "push_operand" "=m")
  4838.     (match_operand:SI 2 "general_operand" "g"))]
  4839.   "GET_CODE (operands[0]) == CONST_INT && INTVAL (operands[0]) >= 4
  4840.    && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
  4841.   "*
  4842. {
  4843.   if (INTVAL (operands[0]) > 4)
  4844.     {
  4845.       rtx xoperands[2];
  4846.       xoperands[0] = stack_pointer_rtx;
  4847.       xoperands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[0]) - 4);
  4848. #ifndef NO_ADDSUB_Q
  4849.       if (INTVAL (xoperands[1]) <= 8)
  4850.         output_asm_insn (\"addq%.w %1,%0\", xoperands);
  4851.       else if (INTVAL (xoperands[1]) <= 16 && TARGET_68020)
  4852.     {
  4853.       xoperands[1] = gen_rtx (CONST_INT, VOIDmode, 
  4854.                   INTVAL (xoperands[1]) - 8);
  4855.       output_asm_insn (\"addq%.w %#8,%0\;addq%.w %1,%0\", xoperands);
  4856.     }
  4857.       else
  4858. #endif
  4859.         if (INTVAL (xoperands[1]) <= 0x7FFF)
  4860.           output_asm_insn (\"add%.w %1,%0\", xoperands);
  4861.       else
  4862.         output_asm_insn (\"add%.l %1,%0\", xoperands);
  4863.     }
  4864.   if (operands[2] == const0_rtx)
  4865.     return \"clr%.l %@\";
  4866.   return \"move%.l %2,%@\";
  4867. }")
  4868.  
  4869. ;; Speed up pushing a single byte but leaving four bytes of space.
  4870.  
  4871. (define_peephole
  4872.   [(set (mem:QI (pre_dec:SI (reg:SI 15)))
  4873.     (match_operand:QI 1 "general_operand" "dami"))
  4874.    (set (reg:SI 15) (minus:SI (reg:SI 15) (const_int 2)))]
  4875.   "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
  4876.   "*
  4877. {
  4878.   rtx xoperands[4];
  4879.  
  4880.   if (GET_CODE (operands[1]) == REG)
  4881.     return \"move%.l %1,%-\";
  4882.  
  4883.   xoperands[1] = operands[1];
  4884.   xoperands[2]
  4885.     = gen_rtx (MEM, QImode,
  4886.            gen_rtx (PLUS, VOIDmode, stack_pointer_rtx,
  4887.             gen_rtx (CONST_INT, VOIDmode, 3)));
  4888.   xoperands[3] = stack_pointer_rtx;
  4889.   output_asm_insn (\"subq%.w %#4,%3\;move%.b %1,%2\", xoperands);
  4890.   return \"\";
  4891. }")
  4892.  
  4893. ;; dbCC peepholes
  4894. ;;
  4895. ;; Turns
  4896. ;;   loop:
  4897. ;;           [ ... ]
  4898. ;;           jCC label        ; abnormal loop termination
  4899. ;;           dbra dN, loop    ; normal loop termination
  4900. ;;
  4901. ;; Into
  4902. ;;   loop:
  4903. ;;           [ ... ]
  4904. ;;           dbCC dN, loop
  4905. ;;           jCC label
  4906. ;;
  4907. ;; Which moves the jCC condition outside the inner loop for free.
  4908. ;;
  4909. (define_peephole
  4910.   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
  4911.                              [(cc0) (const_int 0)])
  4912.                            (label_ref (match_operand 2 "" ""))
  4913.                            (pc)))
  4914.    (parallel
  4915.     [(set (pc)
  4916.       (if_then_else
  4917.         (ge (plus:HI (match_operand:HI 0 "register_operand" "+d")
  4918.                  (const_int -1))
  4919.             (const_int 0))
  4920.         (label_ref (match_operand 1 "" ""))
  4921.         (pc)))
  4922.      (set (match_dup 0)
  4923.       (plus:HI (match_dup 0)
  4924.            (const_int -1)))])]
  4925.   "DATA_REG_P (operands[0])"
  4926.   "*
  4927. {
  4928.   CC_STATUS_INIT;
  4929.   output_dbcc_and_branch (operands);
  4930.   return \"\";
  4931. }")
  4932.  
  4933. (define_peephole
  4934.   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
  4935.                              [(cc0) (const_int 0)])
  4936.                            (label_ref (match_operand 2 "" ""))
  4937.                            (pc)))
  4938.    (parallel
  4939.     [(set (pc)
  4940.       (if_then_else
  4941.         (ge (plus:SI (match_operand:SI 0 "register_operand" "+d")
  4942.                  (const_int -1))
  4943.             (const_int 0))
  4944.         (label_ref (match_operand 1 "" ""))
  4945.         (pc)))
  4946.      (set (match_dup 0)
  4947.       (plus:SI (match_dup 0)
  4948.            (const_int -1)))])]
  4949.   "DATA_REG_P (operands[0])"
  4950.   "*
  4951. {
  4952.   CC_STATUS_INIT;
  4953.   output_dbcc_and_branch (operands);
  4954.   return \"\";
  4955. }")
  4956.  
  4957.  
  4958. ;; FPA multiply and add.
  4959. (define_insn ""
  4960.   [(set (match_operand:DF 0 "register_operand" "=x,y,y")
  4961.     (plus:DF (mult:DF (match_operand:DF 1 "general_operand" "%x,dmF,y")
  4962.               (match_operand:DF 2 "general_operand" "xH,y,y"))
  4963.          (match_operand:DF 3 "general_operand" "xH,y,dmF")))]
  4964.    "TARGET_FPA"
  4965.    "@
  4966.     fpma%.d %1,%w2,%w3,%0
  4967.     fpma%.d %x1,%x2,%x3,%0
  4968.     fpma%.d %x1,%x2,%x3,%0")
  4969.  
  4970. (define_insn ""
  4971.   [(set (match_operand:SF 0 "register_operand" "=x,y,y")
  4972.     (plus:SF (mult:SF (match_operand:SF 1 "general_operand" "%x,ydmF,y")
  4973.               (match_operand:SF 2 "general_operand" "xH,y,ydmF"))
  4974.          (match_operand:SF 3 "general_operand" "xH,ydmF,ydmF")))]
  4975.    "TARGET_FPA"
  4976.    "@
  4977.     fpma%.s %1,%w2,%w3,%0
  4978.     fpma%.s %1,%2,%3,%0
  4979.     fpma%.s %1,%2,%3,%0")
  4980.  
  4981. ;; FPA Multiply and subtract
  4982. (define_insn ""
  4983.   [(set (match_operand:DF 0 "register_operand" "=x,y,y")
  4984.     (minus:DF (match_operand:DF 1 "general_operand" "xH,rmF,y")
  4985.           (mult:DF (match_operand:DF 2 "general_operand" "%xH,y,y")
  4986.                (match_operand:DF 3 "general_operand" "x,y,rmF"))))]
  4987.   "TARGET_FPA"
  4988.   "@
  4989.    fpms%.d %3,%w2,%w1,%0
  4990.    fpms%.d %x3,%2,%x1,%0
  4991.    fpms%.d %x3,%2,%x1,%0")
  4992.  
  4993. (define_insn ""
  4994.   [(set (match_operand:SF 0 "register_operand" "=x,y,y")
  4995.     (minus:SF (match_operand:SF 1 "general_operand" "xH,rmF,yrmF")
  4996.           (mult:SF (match_operand:SF 2 "general_operand" "%xH,rmF,y")
  4997.                (match_operand:SF 3 "general_operand" "x,y,yrmF"))))]
  4998.   "TARGET_FPA"
  4999.   "@
  5000.    fpms%.s %3,%w2,%w1,%0
  5001.    fpms%.s %3,%2,%1,%0
  5002.    fpms%.s %3,%2,%1,%0")
  5003.  
  5004. (define_insn ""
  5005.   [(set (match_operand:DF 0 "register_operand" "=x,y,y")
  5006.     (minus:DF (mult:DF (match_operand:DF 1 "general_operand" "%xH,y,y")
  5007.                (match_operand:DF 2 "general_operand" "x,y,rmF"))
  5008.           (match_operand:DF 3 "general_operand" "xH,rmF,y")))]
  5009.   "TARGET_FPA"
  5010.   "@
  5011.    fpmr%.d %2,%w1,%w3,%0
  5012.    fpmr%.d %x2,%1,%x3,%0
  5013.    fpmr%.d %x2,%1,%x3,%0")
  5014.  
  5015. (define_insn ""
  5016.   [(set (match_operand:SF 0 "register_operand" "=x,y,y")
  5017.     (minus:SF (mult:SF (match_operand:SF 1 "general_operand" "%xH,rmF,y")
  5018.                (match_operand:SF 2 "general_operand" "x,y,yrmF"))
  5019.           (match_operand:SF 3 "general_operand" "xH,rmF,yrmF")))]
  5020.   "TARGET_FPA"
  5021.   "@
  5022.    fpmr%.s %2,%w1,%w3,%0
  5023.    fpmr%.s %x2,%1,%x3,%0
  5024.    fpmr%.s %x2,%1,%x3,%0")
  5025.  
  5026. ;; FPA Add and multiply
  5027. (define_insn ""
  5028.   [(set (match_operand:DF 0 "register_operand" "=x,y,y")
  5029.     (mult:DF (plus:DF (match_operand:DF 1 "general_operand" "%xH,y,y")
  5030.               (match_operand:DF 2 "general_operand" "x,y,rmF"))
  5031.          (match_operand:DF 3 "general_operand" "xH,rmF,y")))]
  5032.   "TARGET_FPA"
  5033.   "@
  5034.    fpam%.d %2,%w1,%w3,%0
  5035.    fpam%.d %x2,%1,%x3,%0
  5036.    fpam%.d %x2,%1,%x3,%0")
  5037.  
  5038. (define_insn ""
  5039.   [(set (match_operand:SF 0 "register_operand" "=x,y,y")
  5040.     (mult:SF (plus:SF (match_operand:SF 1 "general_operand" "%xH,rmF,y")
  5041.               (match_operand:SF 2 "general_operand" "x,y,yrmF"))
  5042.          (match_operand:SF 3 "general_operand" "xH,rmF,yrmF")))]
  5043.   "TARGET_FPA"
  5044.   "@
  5045.    fpam%.s %2,%w1,%w3,%0
  5046.    fpam%.s %x2,%1,%x3,%0
  5047.    fpam%.s %x2,%1,%x3,%0")
  5048.  
  5049. ;;FPA Subtract and multiply
  5050. (define_insn ""
  5051.   [(set (match_operand:DF 0 "register_operand" "=x,y,y")
  5052.     (mult:DF (minus:DF (match_operand:DF 1 "general_operand" "xH,y,y")
  5053.                (match_operand:DF 2 "general_operand" "x,y,rmF"))
  5054.          (match_operand:DF 3 "general_operand" "xH,rmF,y")))]
  5055.   "TARGET_FPA"
  5056.   "@
  5057.    fpsm%.d %2,%w1,%w3,%0
  5058.    fpsm%.d %x2,%1,%x3,%0
  5059.    fpsm%.d %x2,%1,%x3,%0")
  5060.  
  5061. (define_insn ""
  5062.   [(set (match_operand:DF 0 "register_operand" "=x,y,y")
  5063.     (mult:DF (match_operand:DF 1 "general_operand" "xH,rmF,y")
  5064.          (minus:DF (match_operand:DF 2 "general_operand" "xH,y,y")
  5065.                (match_operand:DF 3 "general_operand" "x,y,rmF"))))]
  5066.   "TARGET_FPA"
  5067.   "@
  5068.    fpsm%.d %3,%w2,%w1,%0
  5069.    fpsm%.d %x3,%2,%x1,%0
  5070.    fpsm%.d %x3,%2,%x1,%0")
  5071.  
  5072. (define_insn ""
  5073.   [(set (match_operand:SF 0 "register_operand" "=x,y,y")
  5074.     (mult:SF (minus:SF (match_operand:SF 1 "general_operand" "xH,rmF,y")
  5075.                (match_operand:SF 2 "general_operand" "x,y,yrmF"))
  5076.          (match_operand:SF 3 "general_operand" "xH,rmF,yrmF")))]
  5077.   "TARGET_FPA"
  5078.   "@
  5079.    fpsm%.s %2,%w1,%w3,%0
  5080.    fpsm%.s %x2,%1,%x3,%0
  5081.    fpsm%.s %x2,%1,%x3,%0")
  5082.  
  5083. (define_insn ""
  5084.   [(set (match_operand:SF 0 "register_operand" "=x,y,y")
  5085.     (mult:SF (match_operand:SF 1 "general_operand" "xH,rmF,yrmF")
  5086.          (minus:SF (match_operand:SF 2 "general_operand" "xH,rmF,y")
  5087.                (match_operand:SF 3 "general_operand" "x,y,yrmF"))))]
  5088.   "TARGET_FPA"
  5089.   "@
  5090.    fpsm%.s %3,%w2,%w1,%0
  5091.    fpsm%.s %x3,%2,%x1,%0
  5092.    fpsm%.s %x3,%2,%x1,%0")
  5093.  
  5094. ;;- Local variables:
  5095. ;;- mode:emacs-lisp
  5096. ;;- comment-start: ";;- "
  5097. ;;- comment-start-skip: ";+- *"
  5098. ;;- eval: (set-syntax-table (copy-sequence (syntax-table)))
  5099. ;;- eval: (modify-syntax-entry ?[ "(]")
  5100. ;;- eval: (modify-syntax-entry ?] ")[")
  5101. ;;- eval: (modify-syntax-entry ?{ "(}")
  5102. ;;- eval: (modify-syntax-entry ?} "){")
  5103. ;;- End:
  5104.