home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / GNUSRC.Z / m68k.md < prev    next >
Encoding:
Text File  |  1995-10-17  |  203.7 KB  |  7,182 lines

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