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

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