* config/cris/cris.md: Remove lingering EGCS reference.
[official-gcc.git] / gcc / config / cris / cris.md
blob2ec2502b1e5adaccc6223b22307f96522ad531c6
1 ;; GCC machine description for CRIS cpu cores.
2 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
3 ;; Contributed by Axis Communications.
5 ;; This file is part of GCC.
6 ;;
7 ;; GCC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; any later version.
12 ;; GCC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING.  If not, write to
19 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
22 ;; The original PO technology requires these to be ordered by speed,
23 ;; so that assigner will pick the fastest.
25 ;; See files "md.texi" and "rtl.def" for documentation on define_insn,
26 ;; match_*, et. al.
28 ;; The function cris_notice_update_cc in cris.c handles condition code
29 ;; updates for most instructions, helped by the "cc" attribute.
31 ;; There are several instructions that are orthogonal in size, and seems
32 ;; they could be matched by a single pattern without a specified size
33 ;; for the operand that is orthogonal.  However, this did not work on
34 ;; gcc-2.7.2 (and problably not on gcc-2.8.1), relating to that when a
35 ;; constant is substituted into an operand, the actual mode must be
36 ;; deduced from the pattern.  There is reasonable hope that that has been
37 ;; fixed, so FIXME: try again.
39 ;; You will notice that three-operand alternatives ("=r", "r", "!To")
40 ;; are marked with a "!" constraint modifier to avoid being reloaded
41 ;; into.  This is because gcc would otherwise prefer to use the constant
42 ;; pool and its offsettable address instead of reloading to an
43 ;; ("=r", "0", "i") alternative.  Also, the constant-pool support was not
44 ;; only suboptimal but also buggy in 2.7.2, ??? maybe only in 2.6.3.
46 ;; All insns that look like (set (...) (plus (...) (reg:SI 8)))
47 ;; get problems when reloading r8 (frame pointer) to r14 + offs (stack
48 ;; pointer).  Thus the instructions that get into trouble have specific
49 ;; checks against matching frame_pointer_rtx.
50 ;; ??? But it should be re-checked for gcc > 2.7.2
51 ;; FIXME: This changed some time ago (from 2000-03-16) for gcc-2.9x.
53 ;; FIXME: When PIC, all [rX=rY+S] could be enabled to match
54 ;; [rX=gotless_symbol].
55 ;; The movsi for a gotless symbol could be split (post reload).
57 ;; UNSPEC Usage:
58 ;; 0 PLT reference from call expansion: operand 0 is the address,
59 ;;   the mode is VOIDmode.  Always wrapped in CONST.
61 ;; We need an attribute to define whether an instruction can be put in
62 ;; a branch-delay slot or not, and whether it has a delay slot.
64 ;; Branches and return instructions have a delay slot, and cannot
65 ;; themselves be put in a delay slot.  This has changed *for short
66 ;; branches only* between architecture variants, but the possible win
67 ;; is presumed negligible compared to the added complexity of the machine
68 ;; description: one would have to add always-correct infrastructure to
69 ;; distinguish short branches.
71 ;; Whether an instruction can be put in a delay slot depends on the
72 ;; instruction (all short instructions except jumps and branches)
73 ;; and the addressing mode (must not be prefixed or referring to pc).
74 ;; In short, any "slottable" instruction must be 16 bit and not refer
75 ;; to pc, or alter it.
77 ;; The possible values are "yes", "no" and "has_slot".  Yes/no means if
78 ;; the insn is slottable or not.  Has_slot means that the insn is a
79 ;; return insn or branch insn (which are not considered slottable since
80 ;; that is generally true).  Having the semmingly illogical value
81 ;; "has_slot" means we do not have to add another attribute just to say
82 ;; that an insn has a delay-slot, since it also infers that it is not
83 ;; slottable.  Better names for the attribute were found to be longer and
84 ;; not add readability to the machine description.
86 ;; The default that is defined here for this attribute is "no", not
87 ;; slottable, not having a delay-slot, so there's no need to worry about
88 ;; it being wrong for non-branch and return instructions.
89 ;;  The default could depend on the kind of insn and the addressing
90 ;; mode, but that would need more attributes and hairier, more error
91 ;; prone code.
93 ;;  There is an extra constraint, 'Q', which recognizes indirect reg,
94 ;; except when the reg is pc.  The constraints 'Q' and '>' together match
95 ;; all possible memory operands that are slottable.
96 ;;  For other operands, you need to check if it has a valid "slottable"
97 ;; quick-immediate operand, where the particular signedness-variation
98 ;; may match the constraints 'I' or 'J'.), and include it in the
99 ;; constraint pattern for the slottable pattern.  An alternative using
100 ;; only "r" constraints is most often slottable.
102 (define_attr "slottable" "no,yes,has_slot" (const_string "no"))
104 ;; We also need attributes to sanely determine the condition code
105 ;; state.  See cris_notice_update_cc for how this is used.
107 (define_attr "cc" "none,clobber,normal" (const_string "normal"))
109 ;; A branch or return has one delay-slot.  The instruction in the
110 ;; delay-slot is always executed, independent of whether the branch is
111 ;; taken or not.  Note that besides setting "slottable" to "has_slot",
112 ;; there also has to be a "%#" at the end of a "delayed" instruction
113 ;; output pattern (for "jump" this means "ba %l0%#"), so print_operand can
114 ;; catch it and print a "nop" if necessary.  This method was stolen from
115 ;; sparc.md.
117 (define_delay (eq_attr "slottable" "has_slot")
118   [(eq_attr "slottable" "yes") (nil) (nil)])
120 ;; Test insns.
122 ;; DImode
124 ;; Allow register and offsettable mem operands only; post-increment is
125 ;; not worth the trouble.
127 (define_insn "tstdi"
128   [(set (cc0)
129         (match_operand:DI 0 "nonimmediate_operand" "r,o"))]
130   ""
131   "test.d %M0\;ax\;test.d %H0")
133 ;; No test insns with side-effect on the mem addressing.
135 ;; See note on cmp-insns with side-effects (or lack of them)
137 ;; Normal named test patterns from SI on.
138 ;; FIXME: Seems they should change to be in order smallest..largest.
140 (define_insn "tstsi"
141   [(set (cc0)
142         (match_operand:SI 0 "nonimmediate_operand" "r,Q>,m"))]
143   ""
144   "test.d %0"
145   [(set_attr "slottable" "yes,yes,no")])
147 (define_insn "tsthi"
148   [(set (cc0)
149         (match_operand:HI 0 "nonimmediate_operand" "r,Q>,m"))]
150   ""
151   "test.w %0"
152   [(set_attr "slottable" "yes,yes,no")])
154 (define_insn "tstqi"
155   [(set (cc0)
156         (match_operand:QI 0 "nonimmediate_operand" "r,Q>,m"))]
157   ""
158   "test.b %0"
159   [(set_attr "slottable" "yes,yes,no")])
161 ;; It seems that the position of the sign-bit and the fact that 0.0 is
162 ;; all 0-bits would make "tstsf" a straight-forward implementation;
163 ;; either "test.d" it for positive/negative or "btstq 30,r" it for
164 ;; zeroness.
166 ;; FIXME: Do that some time; check next_cc0_user to determine if
167 ;; zero or negative is tested for.
169 ;; Compare insns.
171 ;; We could optimize the sizes of the immediate operands for various
172 ;; cases, but that is not worth it because of the very little usage of
173 ;; DImode for anything else but a structure/block-mode.  Just do the
174 ;; obvious stuff for the straight-forward constraint letters.
176 (define_insn "cmpdi"
177   [(set (cc0)
178         (compare (match_operand:DI 0 "nonimmediate_operand" "r,r,r,r,r,r,o")
179                  (match_operand:DI 1 "general_operand" "K,I,P,n,r,o,r")))]
180   ""
181   "@
182    cmpq %1,%M0\;ax\;cmpq 0,%H0
183    cmpq %1,%M0\;ax\;cmpq -1,%H0
184    cmp%e1.%z1 %1,%M0\;ax\;cmpq %H1,%H0
185    cmp.d %M1,%M0\;ax\;cmp.d %H1,%H0
186    cmp.d %M1,%M0\;ax\;cmp.d %H1,%H0
187    cmp.d %M1,%M0\;ax\;cmp.d %H1,%H0
188    cmp.d %M0,%M1\;ax\;cmp.d %H0,%H1")
190 ;; Note that compare insns with side effect addressing mode (e.g.):
192 ;; cmp.S [rx=ry+i],rz;
193 ;; cmp.S [%3=%1+%2],%0
195 ;; are *not* usable for gcc since the reloader *does not accept*
196 ;; cc0-changing insns with side-effects other than setting the condition
197 ;; codes.  The reason is that the reload stage *may* cause another insn to
198 ;; be output after the main instruction, in turn invalidating cc0 for the
199 ;; insn using the test.  (This does not apply to the CRIS case, since a
200 ;; reload for output -- move to memory -- does not change the condition
201 ;; code.  Unfortunately we have no way to describe that at the moment.  I
202 ;; think code would improve being in the order of one percent faster.
204 ;; We have cmps and cmpu (compare reg w. sign/zero extended mem).
205 ;; These are mostly useful for compares in SImode, using 8 or 16-bit
206 ;; constants, but sometimes gcc will find its way to use it for other
207 ;; (memory) operands.  Avoid side-effect patterns, though (see above).
209 ;; FIXME: These could have an anonymous mode for operand 1.
211 ;; QImode
213 (define_insn "*cmp_extsi"
214   [(set (cc0)
215         (compare
216          (match_operand:SI 0 "register_operand" "r,r")
217          (match_operator:SI 2 "cris_extend_operator"
218                          [(match_operand:QI 1 "memory_operand" "Q>,m")])))]
219   ""
220   "cmp%e2.%s1 %1,%0"
221   [(set_attr "slottable" "yes,no")])
223 ;; HImode
224 (define_insn "*cmp_exthi"
225   [(set (cc0)
226         (compare
227          (match_operand:SI 0 "register_operand" "r,r")
228          (match_operator:SI 2 "cris_extend_operator"
229                          [(match_operand:HI 1 "memory_operand" "Q>,m")])))]
230   ""
231   "cmp%e2.%s1 %1,%0"
232   [(set_attr "slottable" "yes,no")])
234 ;; Swap operands; it seems the canonical look (if any) is not enforced.
236 ;; FIXME: Investigate that.
237 ;; FIXME: These could have an anonymous mode for operand 1.
239 ;; QImode
241 (define_insn "*cmp_swapextqi"
242   [(set (cc0)
243         (compare
244          (match_operator:SI 2 "cris_extend_operator"
245                             [(match_operand:QI 0 "memory_operand" "Q>,m")])
246          (match_operand:SI 1 "register_operand" "r,r")))]
247   ""
248   "cmp%e2.%s0 %0,%1" ; The function cris_notice_update_cc knows about
249                      ; swapped operands to compares.
250   [(set_attr "slottable" "yes,no")])
252 ;; HImode
254 (define_insn "*cmp_swapexthi"
255   [(set (cc0)
256         (compare
257          (match_operator:SI 2 "cris_extend_operator"
258                             [(match_operand:HI 0 "memory_operand" "Q>,m")])
259          (match_operand:SI 1 "register_operand" "r,r")))]
260   ""
261   "cmp%e2.%s0 %0,%1" ; The function cris_notice_update_cc knows about
262                      ; swapped operands to compares.
263   [(set_attr "slottable" "yes,no")])
265 ;; The "normal" compare patterns, from SI on.
267 (define_insn "cmpsi"
268   [(set (cc0)
269         (compare
270          (match_operand:SI 0 "nonimmediate_operand" "r,r,r,r,Q>,Q>,r,r,m,m")
271          (match_operand:SI 1 "general_operand" "I,r,Q>,M,M,r,P,g,M,r")))]
272   ""
273   "@
274    cmpq %1,%0
275    cmp.d %1,%0
276    cmp.d %1,%0
277    test.d %0
278    test.d %0
279    cmp.d %0,%1
280    cmp%e1.%z1 %1,%0
281    cmp.d %1,%0
282    test.d %0
283    cmp.d %0,%1"
284   [(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,no,no,no")])
286 (define_insn "cmphi"
287   [(set (cc0)
288         (compare (match_operand:HI 0 "nonimmediate_operand" "r,r,Q>,Q>,r,m,m")
289                  (match_operand:HI 1 "general_operand" "r,Q>,M,r,g,M,r")))]
290   ""
291   "@
292    cmp.w %1,%0
293    cmp.w %1,%0
294    test.w %0
295    cmp.w %0,%1
296    cmp.w %1,%0
297    test.w %0
298    cmp.w %0,%1"
299   [(set_attr "slottable" "yes,yes,yes,yes,no,no,no")])
301 (define_insn "cmpqi"
302   [(set (cc0)
303         (compare
304          (match_operand:QI 0 "nonimmediate_operand" "r,r,r,Q>,Q>,r,m,m")
305          (match_operand:QI 1 "general_operand" "r,Q>,M,M,r,g,M,r")))]
306   ""
307   "@
308    cmp.b %1,%0
309    cmp.b %1,%0
310    test.b %0
311    test.b %0
312    cmp.b %0,%1
313    cmp.b %1,%0
314    test.b %0
315    cmp.b %0,%1"
316   [(set_attr "slottable" "yes,yes,yes,yes,yes,no,no,no")])
318 ;; Pattern matching the BTST insn.
319 ;; It is useful for "if (i & val)" constructs, where val is an exact
320 ;; power of 2, or if val + 1 is a power of two, where we check for a bunch
321 ;; of zeros starting at bit 0).
323 ;; SImode.  This mode is the only one needed, since gcc automatically
324 ;; extends subregs for lower-size modes.  FIXME: Add test-case.
325 (define_insn "*btst"
326   [(set (cc0)
327         (zero_extract
328          (match_operand:SI 0 "nonmemory_operand" "r,r,r,r,r,r,n")
329          (match_operand:SI 1 "const_int_operand" "K,n,K,n,K,n,n")
330          (match_operand:SI 2 "nonmemory_operand" "M,M,K,n,r,r,r")))]
331   ;; Either it is a single bit, or consecutive ones starting at 0.
332   "GET_CODE (operands[1]) == CONST_INT
333    && (operands[1] == const1_rtx || operands[2] == const0_rtx)
334    && (REG_S_P (operands[0])
335        || (operands[1] == const1_rtx
336            && REG_S_P (operands[2])
337            && GET_CODE (operands[0]) == CONST_INT
338            && exact_log2 (INTVAL (operands[0])) >= 0))"
340 ;; The last "&&" condition above should be caught by some kind of
341 ;; canonicalization in gcc, but we can easily help with it here.
342 ;;  It results from expressions of the type
343 ;; "power_of_2_value & (1 << y)".
345 ;; Since there may be codes with tests in on bits (in constant position)
346 ;; beyond the size of a word, handle that by assuming those bits are 0.
347 ;; GCC should handle that, but it's a matter of easily-added belts while
348 ;; having suspenders.
350   "@
351    btstq (%1-1),%0
352    test.d %0
353    btstq %2,%0
354    clearf nz
355    btst %2,%0
356    clearf nz
357    cmpq %p0,%2"
358  [(set_attr "slottable" "yes")])
360 ;; Move insns.
362 ;; The whole mandatory movdi family is here; expander, "anonymous"
363 ;; recognizer and splitter.  We're forced to have a movdi pattern,
364 ;; although GCC should be able to split it up itself.  Normally it can,
365 ;; but if other insns have DI operands (as is the case here), reload
366 ;; must be able to generate or match a movdi.  many testcases fail at
367 ;; -O3 or -fssa if we don't have this.  FIXME: Fix GCC...  See
368 ;; <URL:http://gcc.gnu.org/ml/gcc-patches/2000-04/msg00104.html>.
369 ;; However, a patch from Richard Kenner (similar to the cause of
370 ;; discussion at the URL above), indicates otherwise.  See
371 ;; <URL:http://gcc.gnu.org/ml/gcc-patches/2000-04/msg00554.html>.
372 ;; The truth has IMO is not been decided yet, so check from time to
373 ;; time by disabling the movdi patterns.
375 (define_expand "movdi"
376   [(set (match_operand:DI 0 "nonimmediate_operand" "")
377         (match_operand:DI 1 "general_operand" ""))]
378   ""
379   "
381   if (GET_CODE (operands[0]) == MEM && operands[1] != const0_rtx)
382     operands[1] = copy_to_mode_reg (DImode, operands[1]);
384   /* Some other ports (as of 2001-09-10 for example mcore and romp) also
385      prefer to split up constants early, like this.  The testcase in
386      gcc.c-torture/execute/961213-1.c shows that CSE2 gets confused by the
387      resulting subreg sets when using the construct from mcore (as of FSF
388      CVS, version -r 1.5), and it believes that the high part (the last one
389      emitted) is the final value.  This construct from romp seems more
390      robust, especially considering the head comments from
391      emit_no_conflict_block.  */
392   if ((GET_CODE (operands[1]) == CONST_INT
393        || GET_CODE (operands[1]) == CONST_DOUBLE)
394       && ! reload_completed
395       && ! reload_in_progress)
396     {
397       rtx insns;
398       rtx op0 = operands[0];
399       rtx op1 = operands[1];
401       start_sequence ();
402       emit_move_insn (operand_subword (op0, 0, 1, DImode),
403                       operand_subword (op1, 0, 1, DImode));
404       emit_move_insn (operand_subword (op0, 1, 1, DImode),
405                       operand_subword (op1, 1, 1, DImode));
406       insns = get_insns ();
407       end_sequence ();
409       emit_no_conflict_block (insns, op0, op1, 0, op1);
410       DONE;
411     }
414 (define_insn "*movdi_insn"
415   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m")
416         (match_operand:DI 1 "general_operand" "r,g,rM"))]
417   "register_operand (operands[0], DImode)
418    || register_operand (operands[1], DImode)
419    || operands[1] == const0_rtx"
420   "#")
422 (define_split
423   [(set (match_operand:DI 0 "nonimmediate_operand" "")
424         (match_operand:DI 1 "general_operand" ""))]
425   "reload_completed"
426   [(match_dup 2)]
427   "operands[2] = cris_split_movdx (operands);")
429 ;; Side-effect patterns for move.S1 [rx=ry+rx.S2],rw
430 ;; and move.S1 [rx=ry+i],rz
431 ;;  Then movs.S1 and movu.S1 for both modes.
433 ;; move.S1 [rx=ry+rz.S],rw avoiding when rx is ry, or rw is rx
434 ;; FIXME: These could have anonymous mode for operand 0.
436 ;; QImode
438 (define_insn "*mov_sideqi_biap"
439   [(set (match_operand:QI 0 "register_operand" "=r,r")
440         (mem:QI (plus:SI
441                  (mult:SI (match_operand:SI 1 "register_operand" "r,r")
442                           (match_operand:SI 2 "const_int_operand" "n,n"))
443                  (match_operand:SI 3 "register_operand" "r,r"))))
444    (set (match_operand:SI 4 "register_operand" "=*3,r")
445         (plus:SI (mult:SI (match_dup 1)
446                           (match_dup 2))
447                  (match_dup 3)))]
448   "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
449   "@
450    #
451    move.%s0 [%4=%3+%1%T2],%0")
453 ;; HImode
455 (define_insn "*mov_sidehi_biap"
456   [(set (match_operand:HI 0 "register_operand" "=r,r")
457         (mem:HI (plus:SI
458                  (mult:SI (match_operand:SI 1 "register_operand" "r,r")
459                           (match_operand:SI 2 "const_int_operand" "n,n"))
460                  (match_operand:SI 3 "register_operand" "r,r"))))
461    (set (match_operand:SI 4 "register_operand" "=*3,r")
462         (plus:SI (mult:SI (match_dup 1)
463                           (match_dup 2))
464                  (match_dup 3)))]
465   "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
466   "@
467    #
468    move.%s0 [%4=%3+%1%T2],%0")
470 ;; SImode
472 (define_insn "*mov_sidesi_biap"
473   [(set (match_operand:SI 0 "register_operand" "=r,r")
474         (mem:SI (plus:SI
475                  (mult:SI (match_operand:SI 1 "register_operand" "r,r")
476                           (match_operand:SI 2 "const_int_operand" "n,n"))
477                  (match_operand:SI 3 "register_operand" "r,r"))))
478    (set (match_operand:SI 4 "register_operand" "=*3,r")
479         (plus:SI (mult:SI (match_dup 1)
480                           (match_dup 2))
481                  (match_dup 3)))]
482   "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
483   "@
484    #
485    move.%s0 [%4=%3+%1%T2],%0")
487 ;; move.S1 [rx=ry+i],rz
488 ;; avoiding move.S1 [ry=ry+i],rz
489 ;; and      move.S1 [rz=ry+i],rz
490 ;; Note that "i" is allowed to be a register.
491 ;; FIXME: These could have anonymous mode for operand 0.
493 ;; QImode
495 (define_insn "*mov_sideqi"
496   [(set (match_operand:QI 0 "register_operand" "=r,r,r")
497         (mem:QI
498          (plus:SI (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
499                   (match_operand:SI 2 "cris_bdap_operand" "r>Ri,r,>Ri"))))
500    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
501         (plus:SI (match_dup 1)
502                  (match_dup 2)))]
503   "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
504   "*
506   if (which_alternative == 0
507       && (GET_CODE (operands[2]) != CONST_INT
508           || INTVAL (operands[2]) > 127
509           || INTVAL (operands[2]) < -128
510           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
511           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
512     return \"#\";
513   return \"move.%s0 [%3=%1%S2],%0\";
516 ;; HImode
518 (define_insn "*mov_sidehi"
519   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
520         (mem:HI
521          (plus:SI (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
522                   (match_operand:SI 2 "cris_bdap_operand" "r>Ri,r,>Ri"))))
523    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
524         (plus:SI (match_dup 1)
525                  (match_dup 2)))]
526   "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
527   "*
529   if (which_alternative == 0
530       && (GET_CODE (operands[2]) != CONST_INT
531           || INTVAL (operands[2]) > 127
532           || INTVAL (operands[2]) < -128
533           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
534           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
535     return \"#\";
536   return \"move.%s0 [%3=%1%S2],%0\";
539 ;; SImode
541 (define_insn "*mov_sidesi"
542   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
543         (mem:SI
544          (plus:SI (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
545                   (match_operand:SI 2 "cris_bdap_operand" "r>Ri,r,>Ri"))))
546    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
547         (plus:SI (match_dup 1)
548                  (match_dup 2)))]
549   "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
550   "*
552   if (which_alternative == 0
553       && (GET_CODE (operands[2]) != CONST_INT
554           || INTVAL (operands[2]) > 127
555           || INTVAL (operands[2]) < -128
556           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
557           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
558     return \"#\";
559   return \"move.%s0 [%3=%1%S2],%0\";
562 ;; Other way around; move to memory.
564 ;; Note that the condition (which for side-effect patterns is usually a
565 ;; call to cris_side_effect_mode_ok), isn't consulted for register
566 ;; allocation preferences -- constraints is the method for that.  The
567 ;; drawback is that we can't exclude register allocation to cause
568 ;; "move.s rw,[rx=ry+rz.S]" when rw==rx without also excluding rx==ry or
569 ;; rx==rz if we use an earlyclobber modifier for the constraint for rx.
570 ;; Instead of that, we recognize and split the cases where dangerous
571 ;; register combinations are spotted: where a register is set in the
572 ;; side-effect, and used in the main insn.  We don't handle the case where
573 ;; the set in the main insn overlaps the set in the side-effect; that case
574 ;; must be handled in gcc.  We handle just the case where the set in the
575 ;; side-effect overlaps the input operand of the main insn (i.e. just
576 ;; moves to memory).
579 ;; move.s rz,[ry=rx+rw.S]
580 ;; FIXME: These could have anonymous mode for operand 3.
582 ;; QImode
584 (define_insn "*mov_sideqi_biap_mem"
585   [(set (mem:QI (plus:SI
586                  (mult:SI (match_operand:SI 0 "register_operand" "r,r,r")
587                           (match_operand:SI 1 "const_int_operand" "n,n,n"))
588                  (match_operand:SI 2 "register_operand" "r,r,r")))
589         (match_operand:QI 3 "register_operand" "r,r,r"))
590    (set (match_operand:SI 4 "register_operand" "=*2,!3,r")
591         (plus:SI (mult:SI (match_dup 0)
592                           (match_dup 1))
593                  (match_dup 2)))]
594   "cris_side_effect_mode_ok (MULT, operands, 4, 2, 0, 1, 3)"
595   "@
596    #
597    #
598    move.%s3 %3,[%4=%2+%0%T1]")
600 ;; HImode
602 (define_insn "*mov_sidehi_biap_mem"
603   [(set (mem:HI (plus:SI
604                  (mult:SI (match_operand:SI 0 "register_operand" "r,r,r")
605                           (match_operand:SI 1 "const_int_operand" "n,n,n"))
606                  (match_operand:SI 2 "register_operand" "r,r,r")))
607         (match_operand:HI 3 "register_operand" "r,r,r"))
608    (set (match_operand:SI 4 "register_operand" "=*2,!3,r")
609         (plus:SI (mult:SI (match_dup 0)
610                           (match_dup 1))
611                  (match_dup 2)))]
612   "cris_side_effect_mode_ok (MULT, operands, 4, 2, 0, 1, 3)"
613   "@
614    #
615    #
616    move.%s3 %3,[%4=%2+%0%T1]")
618 ;; SImode
620 (define_insn "*mov_sidesi_biap_mem"
621   [(set (mem:SI (plus:SI
622                  (mult:SI (match_operand:SI 0 "register_operand" "r,r,r")
623                           (match_operand:SI 1 "const_int_operand" "n,n,n"))
624                  (match_operand:SI 2 "register_operand" "r,r,r")))
625         (match_operand:SI 3 "register_operand" "r,r,r"))
626    (set (match_operand:SI 4 "register_operand" "=*2,!3,r")
627         (plus:SI (mult:SI (match_dup 0)
628                           (match_dup 1))
629                  (match_dup 2)))]
630   "cris_side_effect_mode_ok (MULT, operands, 4, 2, 0, 1, 3)"
631   "@
632    #
633    #
634    move.%s3 %3,[%4=%2+%0%T1]")
636 ;; Split for the case above where we're out of luck with register
637 ;; allocation (again, the condition isn't checked for that), and we end up
638 ;; with the set in the side-effect getting the same register as the input
639 ;; register.
641 (define_split
642   [(parallel
643     [(set (mem (plus:SI
644                 (mult:SI (match_operand:SI 0 "register_operand" "")
645                          (match_operand:SI 1 "const_int_operand" ""))
646                 (match_operand:SI 2 "register_operand" "")))
647           (match_operand 3 "register_operand" ""))
648      (set (match_operand:SI 4 "register_operand" "")
649           (plus:SI (mult:SI (match_dup 0)
650                             (match_dup 1))
651                    (match_dup 2)))])]
652   "reload_completed && reg_overlap_mentioned_p (operands[4], operands[3])"
653   [(set (match_dup 5) (match_dup 3))
654    (set (match_dup 4) (match_dup 2))
655    (set (match_dup 4)
656         (plus:SI (mult:SI (match_dup 0)
657                           (match_dup 1))
658                  (match_dup 4)))]
659   "operands[5]
660      = gen_rtx_MEM (GET_MODE (operands[3]),
661                     gen_rtx_PLUS (SImode,
662                                   gen_rtx_MULT (SImode,
663                                                 operands[0], operands[1]),
664                                   operands[2]));")
666 ;; move.s rx,[ry=rz+i]
667 ;; FIXME: These could have anonymous mode for operand 2.
669 ;; QImode
671 (define_insn "*mov_sideqi_mem"
672   [(set (mem:QI
673          (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r,r")
674                   (match_operand:SI 1 "cris_bdap_operand" "r>Ri,r>Ri,r,>Ri")))
675         (match_operand:QI 2 "register_operand" "r,r,r,r"))
676    (set (match_operand:SI 3 "register_operand" "=*0,!2,r,r")
677         (plus:SI (match_dup 0)
678                  (match_dup 1)))]
679   "cris_side_effect_mode_ok (PLUS, operands, 3, 0, 1, -1, 2)"
680   "*
682   if (which_alternative == 0
683       && (GET_CODE (operands[1]) != CONST_INT
684           || INTVAL (operands[1]) > 127
685           || INTVAL (operands[1]) < -128
686           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
687           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
688     return \"#\";
689   if (which_alternative == 1)
690     return \"#\";
691   return \"move.%s2 %2,[%3=%0%S1]\";
694 ;; HImode
696 (define_insn "*mov_sidehi_mem"
697   [(set (mem:HI
698          (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r,r")
699                   (match_operand:SI 1 "cris_bdap_operand" "r>Ri,r>Ri,r,>Ri")))
700         (match_operand:HI 2 "register_operand" "r,r,r,r"))
701    (set (match_operand:SI 3 "register_operand" "=*0,!2,r,r")
702         (plus:SI (match_dup 0)
703                  (match_dup 1)))]
704   "cris_side_effect_mode_ok (PLUS, operands, 3, 0, 1, -1, 2)"
705   "*
707   if (which_alternative == 0
708       && (GET_CODE (operands[1]) != CONST_INT
709           || INTVAL (operands[1]) > 127
710           || INTVAL (operands[1]) < -128
711           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
712           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
713     return \"#\";
714   if (which_alternative == 1)
715     return \"#\";
716   return \"move.%s2 %2,[%3=%0%S1]\";
719 ;; SImode
721 (define_insn "*mov_sidesi_mem"
722   [(set (mem:SI
723          (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r,r")
724                   (match_operand:SI 1 "cris_bdap_operand" "r>Ri,r>Ri,r,>Ri")))
725         (match_operand:SI 2 "register_operand" "r,r,r,r"))
726    (set (match_operand:SI 3 "register_operand" "=*0,!2,r,r")
727         (plus:SI (match_dup 0)
728                  (match_dup 1)))]
729   "cris_side_effect_mode_ok (PLUS, operands, 3, 0, 1, -1, 2)"
730   "*
732   if (which_alternative == 0
733       && (GET_CODE (operands[1]) != CONST_INT
734           || INTVAL (operands[1]) > 127
735           || INTVAL (operands[1]) < -128
736           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
737           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
738     return \"#\";
739   if (which_alternative == 1)
740     return \"#\";
741   return \"move.%s2 %2,[%3=%0%S1]\";
744 ;; Like the biap case, a split where the set in the side-effect gets the
745 ;; same register as the input register to the main insn, since the
746 ;; condition isn't checked at register allocation.
748 (define_split
749   [(parallel
750     [(set (mem (plus:SI
751                 (match_operand:SI 0 "cris_bdap_operand" "")
752                 (match_operand:SI 1 "cris_bdap_operand" "")))
753           (match_operand 2 "register_operand" ""))
754      (set (match_operand:SI 3 "register_operand" "")
755           (plus:SI (match_dup 0) (match_dup 1)))])]
756   "reload_completed && reg_overlap_mentioned_p (operands[3], operands[2])"
757   [(set (match_dup 4) (match_dup 2))
758    (set (match_dup 3) (match_dup 0))
759    (set (match_dup 3) (plus:SI (match_dup 3) (match_dup 1)))]
760   "operands[4]
761      = gen_rtx_MEM (GET_MODE (operands[2]),
762                     gen_rtx_PLUS (SImode, operands[0], operands[1]));")
764 ;; Clear memory side-effect patterns.  It is hard to get to the mode if
765 ;; the MEM was anonymous, so there will be one for each mode.
767 ;; clear.d [ry=rx+rw.s2]
769 (define_insn "*clear_sidesi_biap"
770   [(set (mem:SI (plus:SI
771                  (mult:SI (match_operand:SI 0 "register_operand" "r,r")
772                           (match_operand:SI 1 "const_int_operand" "n,n"))
773                  (match_operand:SI 2 "register_operand" "r,r")))
774         (const_int 0))
775    (set (match_operand:SI 3 "register_operand" "=*2,r")
776         (plus:SI (mult:SI (match_dup 0)
777                           (match_dup 1))
778                  (match_dup 2)))]
779   "cris_side_effect_mode_ok (MULT, operands, 3, 2, 0, 1, -1)"
780   "@
781    #
782    clear.d [%3=%2+%0%T1]")
784 ;; clear.d [ry=rz+i]
786 (define_insn "*clear_sidesi"
787   [(set (mem:SI
788          (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r")
789                   (match_operand:SI 1 "cris_bdap_operand" "r>Ri,r,>Ri")))
790         (const_int 0))
791    (set (match_operand:SI 2 "register_operand" "=*0,r,r")
792         (plus:SI (match_dup 0)
793                  (match_dup 1)))]
794   "cris_side_effect_mode_ok (PLUS, operands, 2, 0, 1, -1, -1)"
795   "*
797   if (which_alternative == 0
798       && (GET_CODE (operands[1]) != CONST_INT
799           || INTVAL (operands[1]) > 127
800           || INTVAL (operands[1]) < -128
801           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
802           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
803     return \"#\";
804   return \"clear.d [%2=%0%S1]\";
807 ;;  clear.w [ry=rx+rw.s2]
809 (define_insn "*clear_sidehi_biap"
810   [(set (mem:HI (plus:SI
811                  (mult:SI (match_operand:SI 0 "register_operand" "r,r")
812                           (match_operand:SI 1 "const_int_operand" "n,n"))
813                  (match_operand:SI 2 "register_operand" "r,r")))
814         (const_int 0))
815    (set (match_operand:SI 3 "register_operand" "=*2,r")
816         (plus:SI (mult:SI (match_dup 0)
817                           (match_dup 1))
818                  (match_dup 2)))]
819   "cris_side_effect_mode_ok (MULT, operands, 3, 2, 0, 1, -1)"
820   "@
821    #
822    clear.w [%3=%2+%0%T1]")
824 ;; clear.w [ry=rz+i]
826 (define_insn "*clear_sidehi"
827   [(set (mem:HI
828          (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r")
829                   (match_operand:SI 1 "cris_bdap_operand" "r>Ri,r,>Ri")))
830         (const_int 0))
831    (set (match_operand:SI 2 "register_operand" "=*0,r,r")
832         (plus:SI (match_dup 0)
833                  (match_dup 1)))]
834   "cris_side_effect_mode_ok (PLUS, operands, 2, 0, 1, -1, -1)"
835   "*
837   if (which_alternative == 0
838       && (GET_CODE (operands[1]) != CONST_INT
839           || INTVAL (operands[1]) > 127
840           || INTVAL (operands[1]) < -128
841           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
842           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
843     return \"#\";
844   return \"clear.w [%2=%0%S1]\";
847 ;;  clear.b [ry=rx+rw.s2]
849 (define_insn "*clear_sideqi_biap"
850   [(set (mem:QI (plus:SI
851                  (mult:SI (match_operand:SI 0 "register_operand" "r,r")
852                           (match_operand:SI 1 "const_int_operand" "n,n"))
853                  (match_operand:SI 2 "register_operand" "r,r")))
854         (const_int 0))
855    (set (match_operand:SI 3 "register_operand" "=*2,r")
856         (plus:SI (mult:SI (match_dup 0)
857                           (match_dup 1))
858                  (match_dup 2)))]
859   "cris_side_effect_mode_ok (MULT, operands, 3, 2, 0, 1, -1)"
860   "@
861    #
862    clear.b [%3=%2+%0%T1]")
864 ;; clear.b [ry=rz+i]
866 (define_insn "*clear_sideqi"
867   [(set (mem:QI
868          (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r")
869                   (match_operand:SI 1 "cris_bdap_operand" "r>Ri,r,>Ri")))
870         (const_int 0))
871    (set (match_operand:SI 2 "register_operand" "=*0,r,r")
872         (plus:SI (match_dup 0)
873                  (match_dup 1)))]
874   "cris_side_effect_mode_ok (PLUS, operands, 2, 0, 1, -1, -1)"
875   "*
877   if (which_alternative == 0
878       && (GET_CODE (operands[1]) != CONST_INT
879           || INTVAL (operands[1]) > 127
880           || INTVAL (operands[1]) < -128
881           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
882           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
883     return \"#\";
884   return \"clear.b [%2=%0%S1]\";
887 ;; To appease test-case gcc.c-torture/execute/920501-2.c (and others) at
888 ;; -O0, we need a movdi as a temporary measure.  Here's how things fail:
889 ;;  A cmpdi RTX needs reloading (global):
890 ;;    (insn 185 326 186 (set (cc0)
891 ;;          (compare (mem/f:DI (reg/v:SI 22) 0)
892 ;;              (const_int 1 [0x1]))) 4 {cmpdi} (nil)
893 ;;      (nil))
894 ;; Now, reg 22 is reloaded for input address, and the mem is also moved
895 ;; out of the instruction (into a register), since one of the operands
896 ;; must be a register.  Reg 22 is reloaded (into reg 10), and the mem is
897 ;; moved out and synthesized in SImode parts (reg 9, reg 10 - should be ok
898 ;; wrt. overlap).  The bad things happen with the synthesis in
899 ;; emit_move_insn_1; the location where to substitute reg 10 is lost into
900 ;; two new RTX:es, both still having reg 22.  Later on, the left-over reg
901 ;; 22 is recognized to have an equivalent in memory which is substituted
902 ;; straight in, and we end up with an unrecognizable insn:
903 ;;    (insn 325 324 326 (set (reg:SI 9 r9)
904 ;;            (mem/f:SI (mem:SI (plus:SI (reg:SI 8 r8)
905 ;;                        (const_int -84 [0xffffffac])) 0) 0)) -1 (nil)
906 ;;        (nil))
907 ;; which is the first part of the reloaded synthesized "movdi".
908 ;;  The right thing would be to add equivalent replacement locations for
909 ;; insn with pseudos that need more reloading.  The question is where.
911 ;; Normal move patterns from SI on.
913 (define_expand "movsi"
914   [(set
915     (match_operand:SI 0 "nonimmediate_operand" "")
916     (match_operand:SI 1 "cris_general_operand_or_symbol" ""))]
917   ""
918   "
920   /* If the output goes to a MEM, make sure we have zero or a register as
921      input.  */
922   if (GET_CODE (operands[0]) == MEM
923       && ! REG_S_P (operands[1])
924       && operands[1] != const0_rtx
925       && ! no_new_pseudos)
926     operands[1] = force_reg (SImode, operands[1]);
928   /* If we're generating PIC and have an incoming symbol, validize it to a
929      general operand or something that will match a special pattern.
931      FIXME: Do we *have* to recognize anything that would normally be a
932      valid symbol?  Can we exclude global PIC addresses with an added
933      offset?  */
934   if (flag_pic
935       && CONSTANT_ADDRESS_P (operands[1])
936       && cris_symbol (operands[1]))
937     {
938       /* We must have a register as destination for what we're about to
939          do, and for the patterns we generate.  */
940       if (! REG_S_P (operands[0]))
941         {
942           if (no_new_pseudos)
943             abort ();
944           operands[1] = force_reg (SImode, operands[1]);
945         }
946       else
947         {
948           /* Mark a needed PIC setup for a LABEL_REF:s coming in here:
949              they are so rare not-being-branch-targets that we don't mark
950              a function as needing PIC setup just because we have
951              inspected LABEL_REF:s as operands.  It is only in
952              __builtin_setjmp and such that we can get a LABEL_REF
953              assigned to a register.  */
954           if (GET_CODE (operands[1]) == LABEL_REF)
955             current_function_uses_pic_offset_table = 1;
957           /* We don't have to do anything for global PIC operands; they
958              look just like ``[rPIC+sym]''.  */
959           if (! cris_got_symbol (operands[1])
960               /* We don't do anything for local PIC operands; we match
961                  that with a special alternative.  */
962               && ! cris_gotless_symbol (operands[1]))
963             {
964               /* We get here when we have to change something that would
965                  be recognizable if it wasn't PIC.  A ``sym'' is ok for
966                  PIC symbols both with and without a GOT entry.  And ``sym
967                  + offset'' is ok for local symbols, so the only thing it
968                  could be, is a global symbol with an offset.  Check and
969                  abort if not.  */
970               rtx sym = get_related_value (operands[1]);
971               HOST_WIDE_INT offs = get_integer_term (operands[1]);
973               if (sym == NULL_RTX || offs == 0)
974                 abort ();
975               emit_move_insn (operands[0], sym);
976               if (expand_binop (SImode, add_optab, operands[0],
977                                 GEN_INT (offs), operands[0], 0,
978                                 OPTAB_LIB_WIDEN) != operands[0])
979                 abort ();
980               DONE;
981             }
982         }
983     }
986 (define_insn "*movsi_internal"
987   [(set
988     (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,Q>,r,Q>,g,r,r,r,g")
989     (match_operand:SI 1
990     ;; FIXME: We want to put S last, but apparently g matches S.
991     ;; It's a bug: an S is not a general_operand and shouldn't match g.
992      "cris_general_operand_or_gotless_symbol" "r,Q>,M,M,I,r,M,n,!S,g,r"))]
993   ""
994   "*
996   /* Better to have c-switch here; it is worth it to optimize the size of
997      move insns.  The alternative would be to try to find more constraint
998      letters.  FIXME: Check again.  It seems this could shrink a bit.  */
999   switch (which_alternative)
1000     {
1001     case 0:
1002     case 1:
1003     case 5:
1004     case 9:
1005     case 10:
1006       return \"move.d %1,%0\";
1008     case 2:
1009     case 3:
1010     case 6:
1011       return \"clear.d %0\";
1013       /* Constants -32..31 except 0.  */
1014     case 4:
1015       return \"moveq %1,%0\";
1017       /* We can win a little on constants -32768..-33, 32..65535.  */
1018     case 7:
1019       if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) < 65536)
1020         {
1021           if (INTVAL (operands[1]) < 256)
1022             return \"movu.b %1,%0\";
1023           return \"movu.w %1,%0\";
1024         }
1025       else if (INTVAL (operands[1]) >= -32768 && INTVAL (operands[1]) < 32768)
1026         {
1027           if (INTVAL (operands[1]) >= -128 && INTVAL (operands[1]) < 128)
1028             return \"movs.b %1,%0\";
1029           return \"movs.w %1,%0\";
1030         }
1031       return \"move.d %1,%0\";
1033       case 8:
1034         /* FIXME: Try and split this into pieces GCC makes better code of,
1035            than this multi-insn pattern.  Synopsis: wrap the GOT-relative
1036            symbol into an unspec, and when PIC, recognize the unspec
1037            everywhere a symbol is normally recognized.  (The PIC register
1038            should be recognized by GCC as pic_offset_table_rtx when needed
1039            and similar for PC.)  Each component can then be optimized with
1040            the rest of the code; it should be possible to have a constant
1041            term added on an unspec.  Don't forget to add a REG_EQUAL (or
1042            is it REG_EQUIV) note to the destination.  It might not be
1043            worth it.  Measure.
1045            Note that the 'v' modifier makes PLT references be output as
1046            sym:PLT rather than [rPIC+sym:GOTPLT].  */
1047         return \"move.d %v1,%0\;add.d %P1,%0\";
1049     default:
1050       return \"BOGUS: %1 to %0\";
1051     }
1053   [(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,no,no,no,no")])
1055 ;; Extend operations with side-effect from mem to register, using
1056 ;; MOVS/MOVU.  These are from mem to register only.
1058 ;; [rx=ry+rz.S]
1060 ;; QImode to HImode
1062 ;; FIXME: Can we omit extend to HImode, since GCC should truncate for
1063 ;; HImode by itself?  Perhaps use only anonymous modes?
1065 (define_insn "*ext_sideqihi_biap"
1066   [(set (match_operand:HI 0 "register_operand" "=r,r")
1067         (match_operator:HI
1068          5 "cris_extend_operator"
1069          [(mem:QI (plus:SI
1070                    (mult:SI (match_operand:SI 1 "register_operand" "r,r")
1071                             (match_operand:SI 2 "const_int_operand" "n,n"))
1072                    (match_operand:SI 3 "register_operand" "r,r")))]))
1073    (set (match_operand:SI 4 "register_operand" "=*3,r")
1074         (plus:SI (mult:SI (match_dup 1)
1075                           (match_dup 2))
1076                  (match_dup 3)))]
1077   "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
1078   "@
1079    #
1080    mov%e5.%m5 [%4=%3+%1%T2],%0")
1082 ;; QImode to SImode
1084 (define_insn "*ext_sideqisi_biap"
1085   [(set (match_operand:SI 0 "register_operand" "=r,r")
1086         (match_operator:SI
1087          5 "cris_extend_operator"
1088          [(mem:QI (plus:SI
1089                    (mult:SI (match_operand:SI 1 "register_operand" "r,r")
1090                             (match_operand:SI 2 "const_int_operand" "n,n"))
1091                    (match_operand:SI 3 "register_operand" "r,r")))]))
1092    (set (match_operand:SI 4 "register_operand" "=*3,r")
1093         (plus:SI (mult:SI (match_dup 1)
1094                           (match_dup 2))
1095                  (match_dup 3)))]
1096   "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
1097   "@
1098    #
1099    mov%e5.%m5 [%4=%3+%1%T2],%0")
1101 ;; HImode to SImode
1103 (define_insn "*ext_sidehisi_biap"
1104   [(set (match_operand:SI 0 "register_operand" "=r,r")
1105         (match_operator:SI
1106          5 "cris_extend_operator"
1107          [(mem:HI (plus:SI
1108                    (mult:SI (match_operand:SI 1 "register_operand" "r,r")
1109                             (match_operand:SI 2 "const_int_operand" "n,n"))
1110                    (match_operand:SI 3 "register_operand" "r,r")))]))
1111    (set (match_operand:SI 4 "register_operand" "=*3,r")
1112         (plus:SI (mult:SI (match_dup 1)
1113                           (match_dup 2))
1114                  (match_dup 3)))]
1115   "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
1116   "@
1117    #
1118    mov%e5.%m5 [%4=%3+%1%T2],%0")
1120 ;; Same but [rx=ry+i]
1122 ;; QImode to HImode
1124 (define_insn "*ext_sideqihi"
1125   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1126         (match_operator:HI
1127          4 "cris_extend_operator"
1128          [(mem:QI (plus:SI
1129                    (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
1130                    (match_operand:SI 2 "cris_bdap_operand" "r>Ri,r,>Ri")))]))
1131    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
1132         (plus:SI (match_dup 1)
1133                  (match_dup 2)))]
1134   "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
1135   "*
1137   if (which_alternative == 0
1138       && (GET_CODE (operands[2]) != CONST_INT
1139           || INTVAL (operands[2]) > 127
1140           || INTVAL (operands[2]) < -128
1141           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
1142           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
1143     return \"#\";
1144   return \"mov%e4.%m4 [%3=%1%S2],%0\";
1147 ;; QImode to SImode
1149 (define_insn "*ext_sideqisi"
1150   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1151         (match_operator:SI
1152          4 "cris_extend_operator"
1153          [(mem:QI (plus:SI
1154                    (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
1155                    (match_operand:SI 2 "cris_bdap_operand" "r>Ri,r,>Ri")))]))
1156    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
1157         (plus:SI (match_dup 1)
1158                  (match_dup 2)))]
1159   "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
1160   "*
1162   if (which_alternative == 0
1163       && (GET_CODE (operands[2]) != CONST_INT
1164           || INTVAL (operands[2]) > 127
1165           || INTVAL (operands[2]) < -128
1166           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
1167           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
1168     return \"#\";
1169   return \"mov%e4.%m4 [%3=%1%S2],%0\";
1172 ;; HImode to SImode
1174 (define_insn "*ext_sidehisi"
1175   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1176         (match_operator:SI
1177          4 "cris_extend_operator"
1178          [(mem:HI (plus:SI
1179                    (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
1180                    (match_operand:SI 2 "cris_bdap_operand" "r>Ri,r,>Ri")))]))
1181    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
1182         (plus:SI (match_dup 1)
1183                  (match_dup 2)))]
1184   "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
1185   "*
1187   if (which_alternative == 0
1188       && (GET_CODE (operands[2]) != CONST_INT
1189           || INTVAL (operands[2]) > 127
1190           || INTVAL (operands[2]) < -128
1191           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
1192           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
1193     return \"#\";
1194   return \"mov%e4.%m4 [%3=%1%S2],%0\";
1197 ;; FIXME: See movsi.
1199 (define_insn "movhi"
1200   [(set
1201     (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,Q>,r,Q>,r,r,r,g,g,r")
1202     (match_operand:HI 1 "general_operand" "r,Q>,M,M,I,r,L,O,n,M,r,g"))]
1203   ""
1204   "*
1206   switch (which_alternative)
1207     {
1208     case 0:
1209     case 1:
1210     case 5:
1211     case 10:
1212     case 11:
1213       return \"move.w %1,%0\";
1214     case 2:
1215     case 3:
1216     case 9:
1217       return \"clear.w %0\";
1218     case 4:
1219       return \"moveq %1,%0\";
1220     case 6:
1221     case 8:
1222       if (INTVAL (operands[1]) < 256 && INTVAL (operands[1]) >= -128)
1223         {
1224           if (INTVAL (operands[1]) > 0)
1225             return \"movu.b %1,%0\";
1226           return \"movs.b %1,%0\";
1227         }
1228       return \"move.w %1,%0\";
1229     case 7:
1230       return \"movEq %b1,%0\";
1231     default:
1232       return \"BOGUS: %1 to %0\";
1233   }
1235   [(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,yes,no,no,no,no")
1236    (set (attr "cc")
1237         (if_then_else (eq_attr "alternative" "7")
1238                       (const_string "clobber")
1239                       (const_string "normal")))])
1241 (define_insn "movstricthi"
1242   [(set
1243     (strict_low_part
1244      (match_operand:HI 0 "nonimmediate_operand" "+r,r,r,Q>,Q>,g,r,g"))
1245     (match_operand:HI 1 "general_operand" "r,Q>,M,M,r,M,g,r"))]
1246   ""
1247   "@
1248    move.w %1,%0
1249    move.w %1,%0
1250    clear.w %0
1251    clear.w %0
1252    move.w %1,%0
1253    clear.w %0
1254    move.w %1,%0
1255    move.w %1,%0"
1256   [(set_attr "slottable" "yes,yes,yes,yes,yes,no,no,no")])
1258 (define_insn "movqi"
1259   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,Q>,r,r,Q>,r,g,g,r,r")
1260         (match_operand:QI 1 "general_operand" "r,r,Q>,M,M,I,M,r,O,g"))]
1261   ""
1262   "@
1263    move.b %1,%0
1264    move.b %1,%0
1265    move.b %1,%0
1266    clear.b %0
1267    clear.b %0
1268    moveq %1,%0
1269    clear.b %0
1270    move.b %1,%0
1271    moveq %b1,%0
1272    move.b %1,%0"
1273   [(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,no,yes,no")
1274    (set (attr "cc")
1275         (if_then_else (eq_attr "alternative" "8")
1276                       (const_string "clobber")
1277                       (const_string "normal")))])
1279 (define_insn "movstrictqi"
1280   [(set (strict_low_part
1281          (match_operand:QI 0 "nonimmediate_operand" "+r,Q>,r,r,Q>,g,g,r"))
1282         (match_operand:QI 1 "general_operand" "r,r,Q>,M,M,M,r,g"))]
1283   ""
1284   "@
1285    move.b %1,%0
1286    move.b %1,%0
1287    move.b %1,%0
1288    clear.b %0
1289    clear.b %0
1290    clear.b %0
1291    move.b %1,%0
1292    move.b %1,%0"
1293   [(set_attr "slottable" "yes,yes,yes,yes,yes,no,no,no")])
1295 ;; The valid "quick" bit-patterns are, except for 0.0, denormalized
1296 ;; values REALLY close to 0, and some NaN:s (I think; their exponent is
1297 ;; all ones); the worthwhile one is "0.0".
1298 ;; It will use clear, so we know ALL types of immediate 0 never change cc.
1300 (define_insn "movsf"
1301   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,Q>,r,r,Q>,g,g,r")
1302         (match_operand:SF 1 "general_operand" "r,r,Q>,G,G,G,r,g"))]
1303   ""
1304   "@
1305    move.d %1,%0
1306    move.d %1,%0
1307    move.d %1,%0
1308    clear.d %0
1309    clear.d %0
1310    clear.d %0
1311    move.d %1,%0
1312    move.d %1,%0"
1313   [(set_attr "slottable" "yes,yes,yes,yes,yes,no,no,no")])
1316 ;; Sign- and zero-extend insns with standard names.
1317 ;;  Those for integer source operand are ordered with the widest source
1318 ;; type first.
1320 ;; Sign-extend.
1322 (define_insn "extendsidi2"
1323   [(set (match_operand:DI 0 "register_operand" "=r")
1324         (sign_extend:DI (match_operand:SI 1 "general_operand" "g")))]
1325   ""
1326   "move.d %1,%M0\;smi %H0\;neg.d %H0,%H0")
1328 (define_insn "extendhidi2"
1329   [(set (match_operand:DI 0 "register_operand" "=r")
1330         (sign_extend:DI (match_operand:HI 1 "general_operand" "g")))]
1331   ""
1332   "movs.w %1,%M0\;smi %H0\;neg.d %H0,%H0")
1334 (define_insn "extendhisi2"
1335   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1336         (sign_extend:SI (match_operand:HI 1 "general_operand" "r,Q>,g")))]
1337   ""
1338   "movs.w %1,%0"
1339   [(set_attr "slottable" "yes,yes,no")])
1341 (define_insn "extendqidi2"
1342   [(set (match_operand:DI 0 "register_operand" "=r")
1343         (sign_extend:DI (match_operand:QI 1 "general_operand" "g")))]
1344   ""
1345   "movs.b %1,%M0\;smi %H0\;neg.d %H0,%H0")
1347 (define_insn "extendqisi2"
1348   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1349         (sign_extend:SI (match_operand:QI 1 "general_operand" "r,Q>,g")))]
1350   ""
1351   "movs.b %1,%0"
1352   [(set_attr "slottable" "yes,yes,no")])
1354 ;; To do a byte->word exension, extend to dword, exept that the top half
1355 ;; of the register will be clobbered.  FIXME: Perhaps this is not needed.
1357 (define_insn "extendqihi2"
1358   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1359         (sign_extend:HI (match_operand:QI 1 "general_operand" "r,Q>,g")))]
1360   ""
1361   "movs.b %1,%0"
1362   [(set_attr "slottable" "yes,yes,no")])
1365 ;; Zero-extend.  The DImode ones are synthesized by gcc, so we don't
1366 ;; specify them here.
1368 (define_insn "zero_extendhisi2"
1369   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1370         (zero_extend:SI
1371          (match_operand:HI 1 "nonimmediate_operand" "r,Q>,m")))]
1372   ""
1373   "movu.w %1,%0"
1374   [(set_attr "slottable" "yes,yes,no")])
1376 (define_insn "zero_extendqisi2"
1377   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1378         (zero_extend:SI
1379          (match_operand:QI 1 "nonimmediate_operand" "r,Q>,m")))]
1380   ""
1381   "movu.b %1,%0"
1382   [(set_attr "slottable" "yes,yes,no")])
1384 ;; Same comment as sign-extend QImode to HImode above applies.
1386 (define_insn "zero_extendqihi2"
1387   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1388         (zero_extend:HI
1389          (match_operand:QI 1 "nonimmediate_operand" "r,Q>,m")))]
1390   ""
1391   "movu.b %1,%0"
1392   [(set_attr "slottable" "yes,yes,no")])
1394 ;; All kinds of arithmetic and logical instructions.
1396 ;; First, anonymous patterns to match addressing modes with
1397 ;; side-effects.
1399 ;; op.S [rx=ry+I],rz; (add, sub, or, and, bound).
1401 ;; [rx=ry+rz.S]
1402 ;; FIXME: These could have anonymous mode for operand 0.
1404 ;; QImode
1406 (define_insn "*op_sideqi_biap"
1407   [(set (match_operand:QI 0 "register_operand" "=r,r")
1408         (match_operator:QI
1409          6 "cris_orthogonal_operator"
1410          [(match_operand:QI 1 "register_operand" "0,0")
1411           (mem:QI (plus:SI
1412                    (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1413                             (match_operand:SI 3 "const_int_operand" "n,n"))
1414                    (match_operand:SI 4 "register_operand" "r,r")))]))
1415    (set (match_operand:SI 5 "register_operand" "=*4,r")
1416         (plus:SI (mult:SI (match_dup 2)
1417                           (match_dup 3))
1418                  (match_dup 4)))]
1419   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1420   "@
1421    #
1422    %x6.%s0 [%5=%4+%2%T3],%0")
1424 ;; HImode
1426 (define_insn "*op_sidehi_biap"
1427   [(set (match_operand:HI 0 "register_operand" "=r,r")
1428         (match_operator:HI
1429          6 "cris_orthogonal_operator"
1430          [(match_operand:HI 1 "register_operand" "0,0")
1431           (mem:HI (plus:SI
1432                    (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1433                             (match_operand:SI 3 "const_int_operand" "n,n"))
1434                    (match_operand:SI 4 "register_operand" "r,r")))]))
1435    (set (match_operand:SI 5 "register_operand" "=*4,r")
1436         (plus:SI (mult:SI (match_dup 2)
1437                           (match_dup 3))
1438                  (match_dup 4)))]
1439   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1440   "@
1441    #
1442    %x6.%s0 [%5=%4+%2%T3],%0")
1444 ;; SImode
1446 (define_insn "*op_sidesi_biap"
1447   [(set (match_operand:SI 0 "register_operand" "=r,r")
1448         (match_operator:SI
1449          6 "cris_orthogonal_operator"
1450          [(match_operand:SI 1 "register_operand" "0,0")
1451           (mem:SI (plus:SI
1452                    (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1453                             (match_operand:SI 3 "const_int_operand" "n,n"))
1454                    (match_operand:SI 4 "register_operand" "r,r")))]))
1455    (set (match_operand:SI 5 "register_operand" "=*4,r")
1456         (plus:SI (mult:SI (match_dup 2)
1457                           (match_dup 3))
1458                  (match_dup 4)))]
1459   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1460   "@
1461    #
1462    %x6.%s0 [%5=%4+%2%T3],%0")
1464 ;; [rx=ry+i] ([%4=%2+%3])
1465 ;; FIXME: These could have anonymous mode for operand 0.
1467 ;; QImode
1469 (define_insn "*op_sideqi"
1470   [(set (match_operand:QI 0 "register_operand" "=r,r,r")
1471         (match_operator:QI
1472          5 "cris_orthogonal_operator"
1473          [(match_operand:QI 1 "register_operand" "0,0,0")
1474           (mem:QI (plus:SI
1475                    (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1476                    (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))]))
1477    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1478         (plus:SI (match_dup 2)
1479                  (match_dup 3)))]
1480   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
1481   "*
1483   if (which_alternative == 0
1484       && (GET_CODE (operands[3]) != CONST_INT
1485           || INTVAL (operands[3]) > 127
1486           || INTVAL (operands[3]) < -128
1487           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
1488           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
1489     return \"#\";
1490   return \"%x5.%s0 [%4=%2%S3],%0\";
1493 ;; HImode
1495 (define_insn "*op_sidehi"
1496   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1497         (match_operator:HI
1498          5 "cris_orthogonal_operator"
1499          [(match_operand:HI 1 "register_operand" "0,0,0")
1500           (mem:HI (plus:SI
1501                    (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1502                    (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))]))
1503    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1504         (plus:SI (match_dup 2)
1505                  (match_dup 3)))]
1506   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
1507   "*
1509   if (which_alternative == 0
1510       && (GET_CODE (operands[3]) != CONST_INT
1511           || INTVAL (operands[3]) > 127
1512           || INTVAL (operands[3]) < -128
1513           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
1514           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
1515     return \"#\";
1516   return \"%x5.%s0 [%4=%2%S3],%0\";
1519 ;; SImode
1521 (define_insn "*op_sidesi"
1522   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1523         (match_operator:SI
1524          5 "cris_orthogonal_operator"
1525          [(match_operand:SI 1 "register_operand" "0,0,0")
1526           (mem:SI (plus:SI
1527                    (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1528                    (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))]))
1529    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1530         (plus:SI (match_dup 2)
1531                  (match_dup 3)))]
1532   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
1533   "*
1535   if (which_alternative == 0
1536       && (GET_CODE (operands[3]) != CONST_INT
1537           || INTVAL (operands[3]) > 127
1538           || INTVAL (operands[3]) < -128
1539           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
1540           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
1541     return \"#\";
1542   return \"%x5.%s0 [%4=%2%S3],%0\";
1545 ;; To match all cases for commutative operations we may have to have the
1546 ;; following pattern for add, or & and.  I do not know really, but it does
1547 ;; not break anything.
1549 ;; FIXME: This really ought to be checked.
1551 ;; op.S [rx=ry+I],rz;
1553 ;; [rx=ry+rz.S]
1554 ;; FIXME: These could have anonymous mode for operand 0.
1556 ;; QImode
1558 (define_insn "*op_swap_sideqi_biap"
1559   [(set (match_operand:QI 0 "register_operand" "=r,r")
1560         (match_operator:QI
1561          6 "cris_commutative_orth_op"
1562          [(mem:QI (plus:SI
1563                    (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1564                             (match_operand:SI 3 "const_int_operand" "n,n"))
1565                    (match_operand:SI 4 "register_operand" "r,r")))
1566           (match_operand:QI 1 "register_operand" "0,0")]))
1567    (set (match_operand:SI 5 "register_operand" "=*4,r")
1568         (plus:SI (mult:SI (match_dup 2)
1569                           (match_dup 3))
1570                  (match_dup 4)))]
1571   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1572   "@
1573    #
1574    %x6.%s0 [%5=%4+%2%T3],%0")
1576 ;; HImode
1578 (define_insn "*op_swap_sidehi_biap"
1579   [(set (match_operand:HI 0 "register_operand" "=r,r")
1580         (match_operator:HI
1581          6 "cris_commutative_orth_op"
1582          [(mem:HI (plus:SI
1583                    (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1584                             (match_operand:SI 3 "const_int_operand" "n,n"))
1585                    (match_operand:SI 4 "register_operand" "r,r")))
1586           (match_operand:HI 1 "register_operand" "0,0")]))
1587    (set (match_operand:SI 5 "register_operand" "=*4,r")
1588         (plus:SI (mult:SI (match_dup 2)
1589                           (match_dup 3))
1590                  (match_dup 4)))]
1591   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1592   "@
1593    #
1594    %x6.%s0 [%5=%4+%2%T3],%0")
1596 ;; SImode
1598 (define_insn "*op_swap_sidesi_biap"
1599   [(set (match_operand:SI 0 "register_operand" "=r,r")
1600         (match_operator:SI
1601          6 "cris_commutative_orth_op"
1602          [(mem:SI (plus:SI
1603                    (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1604                             (match_operand:SI 3 "const_int_operand" "n,n"))
1605                    (match_operand:SI 4 "register_operand" "r,r")))
1606           (match_operand:SI 1 "register_operand" "0,0")]))
1607    (set (match_operand:SI 5 "register_operand" "=*4,r")
1608         (plus:SI (mult:SI (match_dup 2)
1609                           (match_dup 3))
1610                  (match_dup 4)))]
1611   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1612   "@
1613    #
1614    %x6.%s0 [%5=%4+%2%T3],%0")
1616 ;; [rx=ry+i] ([%4=%2+%3])
1617 ;; FIXME: These could have anonymous mode for operand 0.
1619 ;; QImode
1621 (define_insn "*op_swap_sideqi"
1622   [(set (match_operand:QI 0 "register_operand" "=r,r,r")
1623         (match_operator:QI
1624          5 "cris_commutative_orth_op"
1625          [(mem:QI
1626            (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1627                     (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))
1628           (match_operand:QI 1 "register_operand" "0,0,0")]))
1629    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1630         (plus:SI (match_dup 2)
1631                  (match_dup 3)))]
1632   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
1633   "*
1635   if (which_alternative == 0
1636       && (GET_CODE (operands[3]) != CONST_INT
1637           || INTVAL (operands[3]) > 127
1638           || INTVAL (operands[3]) < -128
1639           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
1640           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
1641     return \"#\";
1642   return \"%x5.%s0 [%4=%2%S3],%0\";
1645 ;; HImode
1647 (define_insn "*op_swap_sidehi"
1648   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1649         (match_operator:HI
1650          5 "cris_commutative_orth_op"
1651          [(mem:HI
1652            (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1653                     (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))
1654           (match_operand:HI 1 "register_operand" "0,0,0")]))
1655    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1656         (plus:SI (match_dup 2)
1657                  (match_dup 3)))]
1658   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
1659   "*
1661   if (which_alternative == 0
1662       && (GET_CODE (operands[3]) != CONST_INT
1663           || INTVAL (operands[3]) > 127
1664           || INTVAL (operands[3]) < -128
1665           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
1666           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
1667     return \"#\";
1668   return \"%x5.%s0 [%4=%2%S3],%0\";
1671 ;; SImode
1673 (define_insn "*op_swap_sidesi"
1674   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1675         (match_operator:SI
1676          5 "cris_commutative_orth_op"
1677          [(mem:SI
1678            (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1679                     (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))
1680           (match_operand:SI 1 "register_operand" "0,0,0")]))
1681    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1682         (plus:SI (match_dup 2)
1683                  (match_dup 3)))]
1684   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
1685   "*
1687   if (which_alternative == 0
1688       && (GET_CODE (operands[3]) != CONST_INT
1689           || INTVAL (operands[3]) > 127
1690           || INTVAL (operands[3]) < -128
1691           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
1692           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
1693     return \"#\";
1694   return \"%x5.%s0 [%4=%2%S3],%0\";
1697 ;; Add operations, standard names.
1699 ;; Note that for the 'P' constraint, the high part can be -1 or 0.  We
1700 ;; output the insn through the 'A' output modifier as "adds.w" and "addq",
1701 ;; respectively.
1702 (define_insn "adddi3"
1703   [(set (match_operand:DI 0 "register_operand" "=r,r,r,&r,&r")
1704         (plus:DI (match_operand:DI 1 "register_operand" "%0,0,0,0,r")
1705                  (match_operand:DI 2 "general_operand" "J,N,P,g,!To")))]
1706   ""
1707   "@
1708    addq %2,%M0\;ax\;addq 0,%H0
1709    subq %n2,%M0\;ax\;subq 0,%H0
1710    add%e2.%z2 %2,%M0\;ax\;%A2 %H2,%H0
1711    add.d %M2,%M0\;ax\;add.d %H2,%H0
1712    add.d %M2,%M1,%M0\;ax\;add.d %H2,%H1,%H0")
1714 (define_insn "addsi3"
1715   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1716         (plus:SI
1717          (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0,r,r")
1718          (match_operand:SI 2 "general_operand" "r,Q>,J,N,n,g,!To,0")))]
1720 ;; The last constraint is due to that after reload, the '%' is not
1721 ;; honored, and canonicalization doesn't care about keeping the same
1722 ;; register as in destination.  This will happen after insn splitting.
1723 ;; gcc <= 2.7.2.  FIXME: Check for gcc-2.9x
1725  ""
1726  "*
1728   switch (which_alternative)
1729     {
1730     case 0:
1731     case 1:
1732       return \"add.d %2,%0\";
1733     case 2:
1734       return \"addq %2,%0\";
1735     case 3:
1736       return \"subq %n2,%0\";
1737     case 4:
1738       /* 'Known value', but not in -63..63.
1739          Check if addu/subu may be used.  */
1740       if (INTVAL (operands[2]) > 0)
1741         {
1742           if (INTVAL (operands[2]) < 256)
1743             return \"addu.b %2,%0\";
1744           if (INTVAL (operands[2]) < 65536)
1745             return \"addu.w %2,%0\";
1746         }
1747       else
1748         {
1749           if (INTVAL (operands[2]) >= -255)
1750             return \"subu.b %n2,%0\";
1751           if (INTVAL (operands[2]) >= -65535)
1752             return \"subu.w %n2,%0\";
1753         }
1754       return \"add.d %2,%0\";
1755     case 6:
1756       return \"add.d %2,%1,%0\";
1757     case 5:
1758       return \"add.d %2,%0\";
1759     case 7:
1760       return \"add.d %1,%0\";
1761     default:
1762       return \"BOGUS addsi %2+%1 to %0\";
1763     }
1765  [(set_attr "slottable" "yes,yes,yes,yes,no,no,no,yes")])
1767 (define_insn "addhi3"
1768   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r")
1769         (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0,r")
1770                  (match_operand:HI 2 "general_operand" "r,Q>,J,N,g,!To")))]
1771   ""
1772   "@
1773    add.w %2,%0
1774    add.w %2,%0
1775    addq %2,%0
1776    subq %n2,%0
1777    add.w %2,%0
1778    add.w %2,%1,%0"
1779   [(set_attr "slottable" "yes,yes,yes,yes,no,no")
1780    (set_attr "cc" "normal,normal,clobber,clobber,normal,normal")])
1782 (define_insn "addqi3"
1783   [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r,r,r")
1784         (plus:QI (match_operand:QI 1 "register_operand" "%0,0,0,0,0,0,r")
1785                  (match_operand:QI 2 "general_operand" "r,Q>,J,N,O,g,!To")))]
1786   ""
1787   "@
1788    add.b %2,%0
1789    add.b %2,%0
1790    addq %2,%0
1791    subq %n2,%0
1792    subQ -%b2,%0
1793    add.b %2,%0
1794    add.b %2,%1,%0"
1795   [(set_attr "slottable" "yes,yes,yes,yes,yes,no,no")
1796    (set_attr "cc" "normal,normal,clobber,clobber,clobber,normal,normal")])
1798 ;; Subtract.
1800 ;; Note that because of insn canonicalization these will *seldom* but
1801 ;; rarely be used with a known constant as an operand.
1803 ;; Note that for the 'P' constraint, the high part can be -1 or 0.  We
1804 ;; output the insn through the 'D' output modifier as "subs.w" and "subq",
1805 ;; respectively.
1806 (define_insn "subdi3"
1807   [(set (match_operand:DI 0 "register_operand" "=r,r,r,&r,&r")
1808         (minus:DI (match_operand:DI 1 "register_operand" "0,0,0,0,r")
1809                   (match_operand:DI 2 "general_operand" "J,N,P,g,!To")))]
1810   ""
1811   "@
1812    subq %2,%M0\;ax\;subq 0,%H0
1813    addq %n2,%M0\;ax\;addq 0,%H0
1814    sub%e2.%z2 %2,%M0\;ax\;%D2 %H2,%H0
1815    sub.d %M2,%M0\;ax\;sub.d %H2,%H0
1816    sub.d %M2,%M1,%M0\;ax\;sub.d %H2,%H1,%H0")
1818 (define_insn "subsi3"
1819   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1820         (minus:SI
1821          (match_operand:SI 1 "register_operand" "0,0,0,0,0,0,0,r")
1822          (match_operand:SI 2 "general_operand" "r,Q>,J,N,P,n,g,!To")))]
1823   ""
1825 ;; This does not do the optimal: "addu.w 65535,r0" when %2 is negative.
1826 ;; But then again, %2 should not be negative.
1828   "@
1829    sub.d %2,%0
1830    sub.d %2,%0
1831    subq %2,%0
1832    addq %n2,%0
1833    sub%e2.%z2 %2,%0
1834    sub.d %2,%0
1835    sub.d %2,%0
1836    sub.d %2,%1,%0"
1837   [(set_attr "slottable" "yes,yes,yes,yes,no,no,no,no")])
1839 (define_insn "subhi3"
1840   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r")
1841         (minus:HI (match_operand:HI 1 "register_operand" "0,0,0,0,0,r")
1842                   (match_operand:HI 2 "general_operand" "r,Q>,J,N,g,!To")))]
1843   ""
1844   "@
1845    sub.w %2,%0
1846    sub.w %2,%0
1847    subq %2,%0
1848    addq %n2,%0
1849    sub.w %2,%0
1850    sub.w %2,%1,%0"
1851   [(set_attr "slottable" "yes,yes,yes,yes,no,no")
1852    (set_attr "cc" "normal,normal,clobber,clobber,normal,normal")])
1854 (define_insn "subqi3"
1855   [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r,r")
1856         (minus:QI (match_operand:QI 1 "register_operand" "0,0,0,0,0,r")
1857                   (match_operand:QI 2 "general_operand" "r,Q>,J,N,g,!To")))]
1858   ""
1859   "@
1860    sub.b %2,%0
1861    sub.b %2,%0
1862    subq %2,%0
1863    addq %2,%0
1864    sub.b %2,%0
1865    sub.b %2,%1,%0"
1866   [(set_attr "slottable" "yes,yes,yes,yes,no,no")
1867    (set_attr "cc" "normal,normal,clobber,clobber,normal,normal")])
1869 ;; CRIS has some add/sub-with-sign/zero-extend instructions.
1870 ;;  Although these perform sign/zero-extension to SImode, they are
1871 ;; equally applicable for the HImode case.
1872 ;; FIXME: Check; GCC should handle the widening.
1873 ;;  Note that these must be located after the normal add/sub patterns,
1874 ;; so not to get constants into any less specific operands.
1876 ;; Extend with add/sub and side-effect.
1878 ;; ADDS/SUBS/ADDU/SUBU and BOUND, which needs a check for zero_extend
1880 ;; adds/subs/addu/subu bound [rx=ry+rz.S]
1881 ;; FIXME: These could have anonymous mode for operand 0.
1883 ;; QImode to HImode
1884 ;; FIXME: GCC should widen.
1886 (define_insn "*extopqihi_side_biap"
1887   [(set (match_operand:HI 0 "register_operand" "=r,r")
1888         (match_operator:HI
1889          6 "cris_additive_operand_extend_operator"
1890          [(match_operand:HI 1 "register_operand" "0,0")
1891           (match_operator:HI
1892            7 "cris_extend_operator"
1893            [(mem:QI (plus:SI
1894                      (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1895                               (match_operand:SI 3 "const_int_operand" "n,n"))
1896                      (match_operand:SI 4 "register_operand" "r,r")))])]))
1897    (set (match_operand:SI 5 "register_operand" "=*4,r")
1898         (plus:SI (mult:SI (match_dup 2)
1899                           (match_dup 3))
1900                  (match_dup 4)))]
1901   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1902   "@
1903    #
1904    %x6%e7.%m7 [%5=%4+%2%T3],%0")
1906 ;; QImode to SImode
1908 (define_insn "*extopqisi_side_biap"
1909   [(set (match_operand:SI 0 "register_operand" "=r,r")
1910         (match_operator:SI
1911          6 "cris_operand_extend_operator"
1912          [(match_operand:SI 1 "register_operand" "0,0")
1913           (match_operator:SI
1914            7 "cris_extend_operator"
1915            [(mem:QI (plus:SI
1916                      (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1917                               (match_operand:SI 3 "const_int_operand" "n,n"))
1918                      (match_operand:SI 4 "register_operand" "r,r")))])]))
1919    (set (match_operand:SI 5 "register_operand" "=*4,r")
1920         (plus:SI (mult:SI (match_dup 2)
1921                           (match_dup 3))
1922                  (match_dup 4)))]
1923   "(GET_CODE (operands[6]) != UMIN || GET_CODE (operands[7]) == ZERO_EXTEND)
1924    && cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1925   "@
1926    #
1927    %x6%e7.%m7 [%5=%4+%2%T3],%0")
1929 ;; HImode to SImode
1931 (define_insn "*extophisi_side_biap"
1932   [(set (match_operand:SI 0 "register_operand" "=r,r")
1933         (match_operator:SI
1934          6 "cris_operand_extend_operator"
1935          [(match_operand:SI 1 "register_operand" "0,0")
1936           (match_operator:SI
1937            7 "cris_extend_operator"
1938            [(mem:HI (plus:SI
1939                      (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1940                               (match_operand:SI 3 "const_int_operand" "n,n"))
1941                      (match_operand:SI 4 "register_operand" "r,r")))])]))
1942    (set (match_operand:SI 5 "register_operand" "=*4,r")
1943         (plus:SI (mult:SI (match_dup 2)
1944                           (match_dup 3))
1945                  (match_dup 4)))]
1946   "(GET_CODE (operands[6]) != UMIN || GET_CODE (operands[7]) == ZERO_EXTEND)
1947    && cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1948   "@
1949    #
1950    %x6%e7.%m7 [%5=%4+%2%T3],%0")
1953 ;; [rx=ry+i]
1954 ;; FIXME: These could have anonymous mode for operand 0.
1956 ;; QImode to HImode
1958 (define_insn "*extopqihi_side"
1959   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1960         (match_operator:HI
1961          5 "cris_additive_operand_extend_operator"
1962          [(match_operand:HI 1 "register_operand" "0,0,0")
1963           (match_operator:HI
1964            6 "cris_extend_operator"
1965            [(mem:QI
1966              (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1967                       (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")
1968                       ))])]))
1969    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1970         (plus:SI (match_dup 2)
1971                  (match_dup 3)))]
1972   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
1973   "*
1975   if (which_alternative == 0
1976       && (GET_CODE (operands[3]) != CONST_INT
1977           || INTVAL (operands[3]) > 127
1978           || INTVAL (operands[3]) < -128
1979           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
1980           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
1981     return \"#\";
1982   return \"%x5%e6.%m6 [%4=%2%S3],%0\";
1985 ;; QImode to SImode
1987 (define_insn "*extopqisi_side"
1988   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1989         (match_operator:SI
1990          5 "cris_operand_extend_operator"
1991          [(match_operand:SI 1 "register_operand" "0,0,0")
1992           (match_operator:SI
1993            6 "cris_extend_operator"
1994            [(mem:QI
1995              (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1996                       (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")
1997                       ))])]))
1998    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1999         (plus:SI (match_dup 2)
2000                  (match_dup 3)))]
2002   "(GET_CODE (operands[5]) != UMIN || GET_CODE (operands[6]) == ZERO_EXTEND)
2003    && cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
2004   "*
2006   if (which_alternative == 0
2007       && (GET_CODE (operands[3]) != CONST_INT
2008           || INTVAL (operands[3]) > 127
2009           || INTVAL (operands[3]) < -128
2010           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
2011           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
2012     return \"#\";
2013   return \"%x5%e6.%m6 [%4=%2%S3],%0\";
2016 ;; HImode to SImode
2018 (define_insn "*extophisi_side"
2019   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2020         (match_operator:SI
2021          5 "cris_operand_extend_operator"
2022          [(match_operand:SI 1 "register_operand" "0,0,0")
2023           (match_operator:SI
2024            6 "cris_extend_operator"
2025            [(mem:HI
2026              (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
2027                       (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")
2028                       ))])]))
2029    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
2030         (plus:SI (match_dup 2)
2031                  (match_dup 3)))]
2032   "(GET_CODE (operands[5]) != UMIN || GET_CODE (operands[6]) == ZERO_EXTEND)
2033    && cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
2034   "*
2036   if (which_alternative == 0
2037       && (GET_CODE (operands[3]) != CONST_INT
2038           || INTVAL (operands[3]) > 127
2039           || INTVAL (operands[3]) < -128
2040           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
2041           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
2042     return \"#\";
2043   return \"%x5%e6.%m6 [%4=%2%S3],%0\";
2047 ;; As with op.S we may have to add special pattern to match commuted
2048 ;; operands to adds/addu  and bound
2050 ;; adds/addu/bound [rx=ry+rz.S]
2052 ;; QImode to HImode
2053 ;; FIXME: GCC should widen.
2055 (define_insn "*extopqihi_swap_side_biap"
2056   [(set (match_operand:HI 0 "register_operand" "=r,r")
2057         (plus:HI
2058          (match_operator:HI
2059           6 "cris_extend_operator"
2060           [(mem:QI (plus:SI
2061                     (mult:SI (match_operand:SI 2 "register_operand" "r,r")
2062                              (match_operand:SI 3 "const_int_operand" "n,n"))
2063                     (match_operand:SI 4 "register_operand" "r,r")))])
2064          (match_operand:HI 1 "register_operand" "0,0")))
2065    (set (match_operand:SI 5 "register_operand" "=*4,r")
2066         (plus:SI (mult:SI (match_dup 2)
2067                           (match_dup 3))
2068                  (match_dup 4)))]
2069   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
2070   "@
2071    #
2072    add%e6.b [%5=%4+%2%T3],%0")
2074 ;; QImode to SImode
2076 (define_insn "*extopqisi_swap_side_biap"
2077   [(set (match_operand:SI 0 "register_operand" "=r,r")
2078         (match_operator:SI
2079          7 "cris_plus_or_bound_operator"
2080          [(match_operator:SI
2081            6 "cris_extend_operator"
2082            [(mem:QI (plus:SI
2083                      (mult:SI (match_operand:SI 2 "register_operand" "r,r")
2084                               (match_operand:SI 3 "const_int_operand" "n,n"))
2085                      (match_operand:SI 4 "register_operand" "r,r")))])
2086           (match_operand:SI 1 "register_operand" "0,0")]))
2087    (set (match_operand:SI 5 "register_operand" "=*4,r")
2088         (plus:SI (mult:SI (match_dup 2)
2089                           (match_dup 3))
2090                  (match_dup 4)))]
2091   "(GET_CODE (operands[7]) != UMIN || GET_CODE (operands[6]) == ZERO_EXTEND)
2092    && cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
2093   "@
2094    #
2095    %x7%e6.%m6 [%5=%4+%2%T3],%0")
2097 ;; HImode to SImode
2098 (define_insn "*extophisi_swap_side_biap"
2099   [(set (match_operand:SI 0 "register_operand" "=r,r")
2100         (match_operator:SI
2101          7 "cris_plus_or_bound_operator"
2102          [(match_operator:SI
2103            6 "cris_extend_operator"
2104            [(mem:HI (plus:SI
2105                      (mult:SI (match_operand:SI 2 "register_operand" "r,r")
2106                               (match_operand:SI 3 "const_int_operand" "n,n"))
2107                      (match_operand:SI 4 "register_operand" "r,r")))])
2108           (match_operand:SI 1 "register_operand" "0,0")]))
2109    (set (match_operand:SI 5 "register_operand" "=*4,r")
2110         (plus:SI (mult:SI (match_dup 2)
2111                           (match_dup 3))
2112                  (match_dup 4)))]
2113   "(GET_CODE (operands[7]) != UMIN || GET_CODE (operands[6]) == ZERO_EXTEND)
2114    && cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
2115   "@
2116    #
2117    %x7%e6.%m6 [%5=%4+%2%T3],%0")
2119 ;; [rx=ry+i]
2120 ;; FIXME: These could have anonymous mode for operand 0.
2121 ;; FIXME: GCC should widen.
2123 ;; QImode to HImode
2125 (define_insn "*extopqihi_swap_side"
2126   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
2127         (plus:HI
2128          (match_operator:HI
2129           5 "cris_extend_operator"
2130           [(mem:QI (plus:SI
2131                     (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
2132                     (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))])
2133          (match_operand:HI 1 "register_operand" "0,0,0")))
2134    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
2135         (plus:SI (match_dup 2)
2136                  (match_dup 3)))]
2137   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
2138   "*
2140   if (which_alternative == 0
2141       && (GET_CODE (operands[3]) != CONST_INT
2142           || INTVAL (operands[3]) > 127
2143           || INTVAL (operands[3]) < -128
2144           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
2145           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
2146     return \"#\";
2147   return \"add%e5.b [%4=%2%S3],%0\";
2150 ;; QImode to SImode
2152 (define_insn "*extopqisi_swap_side"
2153   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2154         (match_operator:SI
2155          6 "cris_plus_or_bound_operator"
2156          [(match_operator:SI
2157            5 "cris_extend_operator"
2158            [(mem:QI (plus:SI
2159                      (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
2160                      (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))])
2161           (match_operand:SI 1 "register_operand" "0,0,0")]))
2162    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
2163         (plus:SI (match_dup 2)
2164                  (match_dup 3)))]
2165   "(GET_CODE (operands[6]) != UMIN || GET_CODE (operands[5]) == ZERO_EXTEND)
2166    && cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
2167   "*
2169   if (which_alternative == 0
2170       && (GET_CODE (operands[3]) != CONST_INT
2171           || INTVAL (operands[3]) > 127
2172           || INTVAL (operands[3]) < -128
2173           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
2174           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
2175     return \"#\";
2176   return \"%x6%e5.%m5 [%4=%2%S3],%0\";
2179 ;; HImode to SImode
2181 (define_insn "*extophisi_swap_side"
2182   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2183         (match_operator:SI
2184          6 "cris_plus_or_bound_operator"
2185          [(match_operator:SI
2186            5 "cris_extend_operator"
2187            [(mem:HI (plus:SI
2188                      (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
2189                      (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))])
2190           (match_operand:SI 1 "register_operand" "0,0,0")]))
2191    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
2192         (plus:SI (match_dup 2)
2193                  (match_dup 3)))]
2194   "(GET_CODE (operands[6]) != UMIN || GET_CODE (operands[5]) == ZERO_EXTEND)
2195    && cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
2196   "*
2198   if (which_alternative == 0
2199       && (GET_CODE (operands[3]) != CONST_INT
2200           || INTVAL (operands[3]) > 127
2201           || INTVAL (operands[3]) < -128
2202           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
2203           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
2204     return \"#\";
2205   return \"%x6%e5.%m5 [%4=%2%S3],%0\";
2208 ;; Extend versions (zero/sign) of normal add/sub (no side-effects).
2209 ;; FIXME: These could have anonymous mode for operand 0.
2211 ;; QImode to HImode
2212 ;; FIXME: GCC should widen.
2214 (define_insn "*extopqihi"
2215   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
2216         (match_operator:HI
2217          3 "cris_additive_operand_extend_operator"
2218          [(match_operand:HI 1 "register_operand" "0,0,0,r")
2219           (match_operator:HI
2220            4 "cris_extend_operator"
2221            [(match_operand:QI 2 "nonimmediate_operand" "r,Q>,m,!To")])]))]
2222   "GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
2223    && (operands[1] != frame_pointer_rtx || GET_CODE (operands[3]) != PLUS)"
2224   "@
2225    %x3%e4.%m4 %2,%0
2226    %x3%e4.%m4 %2,%0
2227    %x3%e4.%m4 %2,%0
2228    %x3%e4.%m4 %2,%1,%0"
2229   [(set_attr "slottable" "yes,yes,no,no")
2230    (set_attr "cc" "clobber")])
2232 ;; QImode to SImode
2234 (define_insn "*extopqisi"
2235   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
2236         (match_operator:SI
2237          3 "cris_operand_extend_operator"
2238          [(match_operand:SI 1 "register_operand" "0,0,0,r")
2239           (match_operator:SI
2240            4 "cris_extend_operator"
2241            [(match_operand:QI 2 "nonimmediate_operand" "r,Q>,m,!To")])]))]
2242   "(GET_CODE (operands[3]) != UMIN || GET_CODE (operands[4]) == ZERO_EXTEND)
2243    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
2244    && (operands[1] != frame_pointer_rtx || GET_CODE (operands[3]) != PLUS)"
2245   "@
2246    %x3%e4.%m4 %2,%0
2247    %x3%e4.%m4 %2,%0
2248    %x3%e4.%m4 %2,%0
2249    %x3%e4.%m4 %2,%1,%0"
2250   [(set_attr "slottable" "yes,yes,no,no")])
2252 ;; HImode to SImode
2254 (define_insn "*extophisi"
2255   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
2256         (match_operator:SI
2257          3 "cris_operand_extend_operator"
2258          [(match_operand:SI 1 "register_operand" "0,0,0,r")
2259           (match_operator:SI
2260            4 "cris_extend_operator"
2261            [(match_operand:HI 2 "nonimmediate_operand" "r,Q>,m,!To")])]))]
2262   "(GET_CODE (operands[3]) != UMIN || GET_CODE (operands[4]) == ZERO_EXTEND)
2263    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
2264    && (operands[1] != frame_pointer_rtx || GET_CODE (operands[3]) != PLUS)"
2265   "@
2266    %x3%e4.%m4 %2,%0
2267    %x3%e4.%m4 %2,%0
2268    %x3%e4.%m4 %2,%0
2269    %x3%e4.%m4 %2,%1,%0"
2270   [(set_attr "slottable" "yes,yes,no,no")])
2273 ;; As with the side-effect patterns, may have to have swapped operands for add.
2274 ;; FIXME: *should* be redundant to gcc.
2276 ;; QImode to HImode
2278 (define_insn "*extopqihi_swap"
2279   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
2280         (plus:HI
2281          (match_operator:HI
2282           3 "cris_extend_operator"
2283           [(match_operand:QI 2 "nonimmediate_operand" "r,Q>,m,!To")])
2284          (match_operand:HI 1 "register_operand" "0,0,0,r")))]
2285   "operands[1] != frame_pointer_rtx"
2286   "@
2287    add%e3.b %2,%0
2288    add%e3.b %2,%0
2289    add%e3.b %2,%0
2290    add%e3.b %2,%1,%0"
2291   [(set_attr "slottable" "yes,yes,no,no")
2292    (set_attr "cc" "clobber")])
2294 ;; QImode to SImode
2296 (define_insn "*extopqisi_swap"
2297   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
2298         (match_operator:SI
2299          4 "cris_plus_or_bound_operator"
2300          [(match_operator:SI
2301            3 "cris_extend_operator"
2302            [(match_operand:QI 2 "nonimmediate_operand" "r,Q>,m,!To")])
2303           (match_operand:SI 1 "register_operand" "0,0,0,r")]))]
2304   "(GET_CODE (operands[4]) != UMIN || GET_CODE (operands[3]) == ZERO_EXTEND)
2305    && operands[1] != frame_pointer_rtx"
2306   "@
2307    %x4%e3.%m3 %2,%0
2308    %x4%e3.%m3 %2,%0
2309    %x4%e3.%m3 %2,%0
2310    %x4%e3.%m3 %2,%1,%0"
2311   [(set_attr "slottable" "yes,yes,no,no")])
2313 ;; HImode to SImode
2315 (define_insn "*extophisi_swap"
2316   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
2317         (match_operator:SI
2318          4 "cris_plus_or_bound_operator"
2319          [(match_operator:SI
2320            3 "cris_extend_operator"
2321            [(match_operand:HI 2 "nonimmediate_operand" "r,Q>,m,!To")])
2322           (match_operand:SI 1 "register_operand" "0,0,0,r")]))]
2323   "(GET_CODE (operands[4]) != UMIN || GET_CODE (operands[3]) == ZERO_EXTEND)
2324    && operands[1] != frame_pointer_rtx"
2325   "@
2326    %x4%e3.%m3 %2,%0
2327    %x4%e3.%m3 %2,%0
2328    %x4%e3.%m3 %2,%0
2329    %x4%e3.%m3 %2,%1,%0"
2330   [(set_attr "slottable" "yes,yes,no,no")])
2332 ;; This is the special case when we use what corresponds to the
2333 ;; instruction above in "casesi".  Do *not* change it to use the generic
2334 ;; pattern and "REG 15" as pc; I did that and it led to madness and
2335 ;; maintenance problems: Instead of (as imagined) recognizing and removing
2336 ;; or replacing this pattern with something simpler, other variant
2337 ;; patterns were recognized or combined, including some prefix variants
2338 ;; where the value in pc is not that of the next instruction (which means
2339 ;; this instruction actually *is* special and *should* be marked as such).
2340 ;; When switching from the "generic pattern match" approach to this simpler
2341 ;; approach, there were insignificant differences in gcc, ipps and
2342 ;; product code, somehow due to scratching reload behind the ear or
2343 ;; something.  Testcase "gcc" looked .01% slower and 4 bytes bigger;
2344 ;; product code became .001% smaller but "looked better".  The testcase
2345 ;; "ipps" was just different at register allocation).
2347 ;; Assumptions in the jump optimizer forces us to use IF_THEN_ELSE in this
2348 ;; pattern with the default-label as the else, with the "if" being
2349 ;; index-is-less-than the max number of cases plus one.  The default-label
2350 ;; is attached to the end of the case-table at time of output.
2352 (define_insn "*casesi_adds_w"
2353   [(set (pc)
2354         (if_then_else
2355          (ltu (match_operand:SI 0 "register_operand" "r")
2356               (match_operand:SI 1 "const_int_operand" "n"))
2357          (plus:SI (sign_extend:SI
2358                    (mem:HI
2359                     (plus:SI (mult:SI (match_dup 0) (const_int 2))
2360                              (pc))))
2361                   (pc))
2362          (label_ref (match_operand 2 "" ""))))
2363    (use (label_ref (match_operand 3 "" "")))]
2365   "operands[0] != frame_pointer_rtx"
2367   "adds.w [$pc+%0.w],$pc"
2368   [(set_attr "cc" "clobber")])
2370 ;; Multiply instructions.
2372 ;; Sometimes powers of 2 (which are normally canonicalized to a
2373 ;; left-shift) appear here, as a result of address reloading.
2374 ;; As a special, for values 3 and 5, we can match with an addi, so add those.
2376 ;; FIXME: This may be unnecessary now.
2377 ;; Explicitly named for convenience of having a gen_... function.
2379 (define_insn "addi_mul"
2380   [(set (match_operand:SI 0 "register_operand" "=r")
2381         (mult:SI
2382          (match_operand:SI 1 "register_operand" "%0")
2383          (match_operand:SI 2 "const_int_operand" "n")))]
2384   "operands[0] != frame_pointer_rtx
2385    && operands[1] != frame_pointer_rtx
2386    && GET_CODE (operands[2]) == CONST_INT
2387    && (INTVAL (operands[2]) == 2
2388        || INTVAL (operands[2]) == 4 || INTVAL (operands[2]) == 3
2389        || INTVAL (operands[2]) == 5)"
2390   "*
2392   if (INTVAL (operands[2]) == 2)
2393     return \"lslq 1,%0\";
2394   else if (INTVAL (operands[2]) == 4)
2395     return \"lslq 2,%0\";
2396   else if (INTVAL (operands[2]) == 3)
2397     return \"addi %0.w,%0\";
2398   else if (INTVAL (operands[2]) == 5)
2399     return \"addi %0.d,%0\";
2400   return \"BAD: adr_mulsi: %0=%1*%2\";
2402 [(set_attr "slottable" "yes")
2403  ;; No flags are changed if this insn is "addi", but it does not seem
2404  ;; worth the trouble to distinguish that to the lslq cases.
2405  (set_attr "cc" "clobber")])
2407 ;; The addi insn as it is normally used.
2409 (define_insn "*addi"
2410   [(set (match_operand:SI 0 "register_operand" "=r")
2411         (plus:SI
2412          (mult:SI (match_operand:SI 2 "register_operand" "r")
2413                   (match_operand:SI 3 "const_int_operand" "n"))
2414          (match_operand:SI 1 "register_operand" "0")))]
2415   "operands[0] != frame_pointer_rtx
2416    && operands[1] != frame_pointer_rtx
2417    && GET_CODE (operands[3]) == CONST_INT
2418    && (INTVAL (operands[3]) == 1
2419        || INTVAL (operands[3]) == 2 || INTVAL (operands[3]) == 4)"
2420   "addi %2%T3,%0"
2421   [(set_attr "slottable" "yes")
2422    (set_attr "cc" "none")])
2424 ;; The mstep instruction.  Probably not useful by itself; it's to
2425 ;; non-linear wrt. the other insns.  We used to expand to it, so at least
2426 ;; it's correct.
2428 (define_insn "mstep_shift"
2429   [(set (match_operand:SI 0 "register_operand" "=r")
2430         (if_then_else:SI
2431          (lt:SI (cc0) (const_int 0))
2432          (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
2433                              (const_int 1))
2434                   (match_operand:SI 2 "register_operand" "r"))
2435          (ashift:SI (match_operand:SI 3 "register_operand" "0")
2436                     (const_int 1))))]
2437   ""
2438   "mstep %2,%0"
2439   [(set_attr "slottable" "yes")])
2441 ;; When illegitimate addresses are legitimized, sometimes gcc forgets
2442 ;; to canonicalize the multiplications.
2444 ;; FIXME: Check gcc > 2.7.2, remove and possibly fix in gcc.
2446 (define_insn "mstep_mul"
2447   [(set (match_operand:SI 0 "register_operand" "=r")
2448         (if_then_else:SI
2449          (lt:SI (cc0) (const_int 0))
2450          (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "0")
2451                            (const_int 2))
2452                   (match_operand:SI 2 "register_operand" "r"))
2453          (mult:SI (match_operand:SI 3 "register_operand" "0")
2454                   (const_int 2))))]
2455   "operands[0] != frame_pointer_rtx
2456    && operands[1] != frame_pointer_rtx
2457    && operands[2] != frame_pointer_rtx
2458    && operands[3] != frame_pointer_rtx"
2459   "mstep %2,%0"
2460   [(set_attr "slottable" "yes")])
2462 (define_insn "umulhisi3"
2463   [(set (match_operand:SI 0 "register_operand" "=r")
2464         (mult:SI
2465          (zero_extend:SI (match_operand:HI 1 "register_operand" "0"))
2466          (zero_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
2467   "TARGET_HAS_MUL_INSNS"
2468   "mulu.w %2,%0"
2469   [(set_attr "slottable" "yes")
2470    ;; Just N unusable here, but let's be safe.
2471    (set_attr "cc" "clobber")])
2473 (define_insn "umulqihi3"
2474   [(set (match_operand:HI 0 "register_operand" "=r")
2475         (mult:HI
2476          (zero_extend:HI (match_operand:QI 1 "register_operand" "0"))
2477          (zero_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
2478   "TARGET_HAS_MUL_INSNS"
2479   "mulu.b %2,%0"
2480   [(set_attr "slottable" "yes")
2481    ;; Not exactly sure, but let's be safe.
2482    (set_attr "cc" "clobber")])
2484 ;; Note that gcc does not make use of such a thing as umulqisi3.  It gets
2485 ;; confused and will erroneously use it instead of umulhisi3, failing (at
2486 ;; least) gcc.c-torture/execute/arith-rand.c at all optimization levels.
2487 ;; Inspection of optab code shows that there must be only one widening
2488 ;; multiplication per mode widened to.
2490 (define_insn "mulsi3"
2491   [(set (match_operand:SI 0 "register_operand" "=r")
2492         (mult:SI (match_operand:SI 1 "register_operand" "0")
2493                  (match_operand:SI 2 "register_operand" "r")))]
2494   "TARGET_HAS_MUL_INSNS"
2495   "muls.d %2,%0"
2496   [(set_attr "slottable" "yes")
2497    ;; Just N unusable here, but let's be safe.
2498    (set_attr "cc" "clobber")])
2500 ;; A few multiply variations.
2502 ;; This really extends to SImode, so cc should be considered clobbered.
2504 (define_insn "mulqihi3"
2505   [(set (match_operand:HI 0 "register_operand" "=r")
2506         (mult:HI
2507          (sign_extend:HI (match_operand:QI 1 "register_operand" "0"))
2508          (sign_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
2509   "TARGET_HAS_MUL_INSNS"
2510   "muls.b %2,%0"
2511   [(set_attr "slottable" "yes")
2512    (set_attr "cc" "clobber")])
2514 (define_insn "mulhisi3"
2515   [(set (match_operand:SI 0 "register_operand" "=r")
2516         (mult:SI
2517          (sign_extend:SI (match_operand:HI 1 "register_operand" "0"))
2518          (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
2519   "TARGET_HAS_MUL_INSNS"
2520   "muls.w %2,%0"
2521   [(set_attr "slottable" "yes")
2522    ;; Just N unusable here, but let's be safe.
2523    (set_attr "cc" "clobber")])
2525 ;; When needed, we can get the high 32 bits from the overflow
2526 ;; register.  We don't care to split and optimize these.
2528 ;; Note that cc0 is still valid after the move-from-overflow-register
2529 ;; insn; no special precaution need to be taken in cris_notice_update_cc.
2531 (define_insn "mulsidi3"
2532   [(set (match_operand:DI 0 "register_operand" "=r")
2533         (mult:DI
2534          (sign_extend:DI (match_operand:SI 1 "register_operand" "0"))
2535          (sign_extend:DI (match_operand:SI 2 "register_operand" "r"))))]
2536   "TARGET_HAS_MUL_INSNS"
2537   "muls.d %2,%M0\;move $mof,%H0")
2539 (define_insn "umulsidi3"
2540   [(set (match_operand:DI 0 "register_operand" "=r")
2541         (mult:DI
2542          (zero_extend:DI (match_operand:SI 1 "register_operand" "0"))
2543          (zero_extend:DI (match_operand:SI 2 "register_operand" "r"))))]
2544   "TARGET_HAS_MUL_INSNS"
2545   "mulu.d %2,%M0\;move $mof,%H0")
2547 ;; This pattern would probably not be needed if we add "mof" in its own
2548 ;; register class (and open a can of worms about /not/ pairing it with a
2549 ;; "normal" register).  Having multiple register classes here, and
2550 ;; applicable to the v10 variant only, seems worse than having these two
2551 ;; patterns with multi-insn contents for now (may change; having a free
2552 ;; call-clobbered register is worth some trouble).
2554 (define_insn "smulsi3_highpart"
2555   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,m")
2556         (truncate:SI
2557          (lshiftrt:DI
2558           (mult:DI
2559            (sign_extend:DI (match_operand:SI 1 "register_operand" "%0,r,r"))
2560            (sign_extend:DI (match_operand:SI 2 "register_operand" "r,r,r")))
2561           (const_int 32))))
2562    (clobber (match_scratch:SI 3 "=X,1,1"))]
2563   "TARGET_HAS_MUL_INSNS"
2564   "muls.d %2,%1\;move $mof,%0"
2565   [(set_attr "cc" "clobber")])
2567 (define_insn "umulsi3_highpart"
2568   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,m")
2569         (truncate:SI
2570          (lshiftrt:DI
2571           (mult:DI
2572            (zero_extend:DI (match_operand:SI 1 "register_operand" "%0,r,r"))
2573            (zero_extend:DI (match_operand:SI 2 "register_operand" "r,r,r")))
2574           (const_int 32))))
2575    (clobber (match_scratch:SI 3 "=X,1,1"))]
2576   "TARGET_HAS_MUL_INSNS"
2577   "mulu.d %2,%1\;move $mof,%0"
2578   [(set_attr "cc" "clobber")])
2580 ;; Divide and modulus instructions.  CRIS only has a step instruction.
2582 (define_insn "dstep_shift"
2583   [(set (match_operand:SI 0 "register_operand" "=r")
2584         (if_then_else:SI
2585          (geu:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
2586                             (const_int 1))
2587               (match_operand:SI 2 "register_operand" "r"))
2588          (minus:SI (ashift:SI (match_operand:SI 3 "register_operand" "0")
2589                         (const_int 1))
2590                    (match_operand:SI 4 "register_operand" "2"))
2591          (ashift:SI (match_operand:SI 5 "register_operand" "0")
2592                         (const_int 1))))]
2593   ""
2594   "dstep %2,%0"
2595   [(set_attr "slottable" "yes")])
2597 ;; Here's a variant with mult instead of ashift.
2599 ;; FIXME: This should be investigated.  Which one matches through combination?
2601 (define_insn "dstep_mul"
2602   [(set (match_operand:SI 0 "register_operand" "=r")
2603         (if_then_else:SI
2604          (geu:SI (mult:SI (match_operand:SI 1 "register_operand" "0")
2605                           (const_int 2))
2606               (match_operand:SI 2 "register_operand" "r"))
2607          (minus:SI (mult:SI (match_operand:SI 3 "register_operand" "0")
2608                             (const_int 2))
2609                    (match_operand:SI 4 "register_operand" "2"))
2610          (mult:SI (match_operand:SI 5 "register_operand" "0")
2611                   (const_int 2))))]
2612   "operands[0] != frame_pointer_rtx
2613    && operands[1] != frame_pointer_rtx
2614    && operands[2] != frame_pointer_rtx
2615    && operands[3] != frame_pointer_rtx"
2616   "dstep %2,%0"
2617   [(set_attr "slottable" "yes")])
2619 ;; Logical operators.
2621 ;; Bitwise "and".
2623 ;; There is no use in defining "anddi3", because gcc can expand this by
2624 ;; itself, and make reasonable code without interference.
2626 ;; If the first operand is memory or a register and is the same as the
2627 ;; second operand, and the third operand is -256 or -65536, we can use
2628 ;; CLEAR instead.  Or, if the first operand is a register, and the third
2629 ;; operand is 255 or 65535, we can zero_extend.
2630 ;; GCC isn't smart enough to recognize these cases (yet), and they seem
2631 ;; to be common enough to be worthwhile.
2632 ;; FIXME: This should be made obsolete.
2634 (define_expand "andsi3"
2635   [(set (match_operand:SI 0 "nonimmediate_operand"         "")
2636         (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
2637                 (match_operand:SI 2 "general_operand"    "")))]
2638   ""
2639   "
2641   if (! (GET_CODE (operands[2]) == CONST_INT
2642          && (((INTVAL (operands[2]) == -256
2643                || INTVAL (operands[2]) == -65536)
2644               && rtx_equal_p (operands[1], operands[0]))
2645              || ((INTVAL (operands[2]) == 255
2646                   || INTVAL (operands[2]) == 65535)
2647                  && REG_P (operands[0])))))
2648     {
2649       /* Make intermediate steps if operand0 is not a register or
2650          operand1 is not a register, and hope that the reload pass will
2651          make something useful out of it.  Note that the operands are
2652          *not* canonicalized.  For the moment, I chicken out on this,
2653          because all or most ports do not describe 'and' with
2654          canonicalized operands, and I seem to remember magic in reload,
2655          checking that operand1 has constraint '%0', in which case
2656          operand0 and operand1 must have similar predicates.
2657          FIXME: Investigate.  */
2658       rtx reg0 = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode);
2659       rtx reg1 = operands[1];
2661       if (! REG_P (reg1))
2662         {
2663           emit_move_insn (reg0, reg1);
2664           reg1 = reg0;
2665         }
2667       emit_insn (gen_rtx_SET (SImode, reg0,
2668                           gen_rtx_AND (SImode, reg1, operands[2])));
2670       /* Make sure we get the right *final* destination.  */
2671       if (! REG_P (operands[0]))
2672         emit_move_insn (operands[0], reg0);
2674       DONE;
2675     }
2678 ;; Some special cases of andsi3.
2680 (define_insn "*andsi_movu"
2681   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2682         (and:SI (match_operand:SI 1 "nonimmediate_operand" "%r,Q>,m")
2683                 (match_operand:SI 2 "const_int_operand" "n,n,n")))]
2684   "INTVAL (operands[2]) == 255 || INTVAL (operands[2]) == 65535"
2685   "movu.%z2 %1,%0"
2686   [(set_attr "slottable" "yes,yes,no")])
2688 (define_insn "*andsi_clear"
2689   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,Q>,Q>,m,m")
2690         (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0,0")
2691                 (match_operand:SI 2 "const_int_operand" "P,n,P,n,P,n")))]
2692   "INTVAL (operands[2]) == -65536 || INTVAL (operands[2]) == -256"
2693   "@
2694    cLear.b %0
2695    cLear.w %0
2696    cLear.b %0
2697    cLear.w %0
2698    cLear.b %0
2699    cLear.w %0"
2700   [(set_attr "slottable" "yes,yes,yes,yes,no,no")
2701    (set_attr "cc" "none")])
2703 ;; This is a catch-all pattern, taking care of everything that was not
2704 ;; matched in the insns above.
2706 ;; Sidenote: the tightening from "nonimmediate_operand" to
2707 ;; "register_operand" for operand 1 actually increased the register
2708 ;; pressure (worse code).  That will hopefully change with an
2709 ;; improved reload pass.
2711 (define_insn "*expanded_andsi"
2712   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r")
2713         (and:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,r")
2714                 (match_operand:SI 2 "general_operand" "I,r,Q>,g,!To")))]
2715   ""
2716   "@
2717    andq %2,%0
2718    and.d %2,%0
2719    and.d %2,%0
2720    and.d %2,%0
2721    and.d %2,%1,%0"
2722   [(set_attr "slottable" "yes,yes,yes,no,no")])
2724 ;; For both QI and HI we may use the quick patterns.  This results in
2725 ;; useless condition codes, but that is used rarely enough for it to
2726 ;; normally be a win (could check ahead for use of cc0, but seems to be
2727 ;; more pain than win).
2729 ;; FIXME: See note for andsi3
2731 (define_expand "andhi3"
2732   [(set (match_operand:HI 0 "nonimmediate_operand" "")
2733         (and:HI (match_operand:HI 1 "nonimmediate_operand" "")
2734                 (match_operand:HI 2 "general_operand"  "")))]
2735   ""
2736   "
2738   if (! (GET_CODE (operands[2]) == CONST_INT
2739          && (((INTVAL (operands[2]) == -256
2740                || INTVAL (operands[2]) == 65280)
2741               && rtx_equal_p (operands[1], operands[0]))
2742              || (INTVAL (operands[2]) == 255
2743                  && REG_P (operands[0])))))
2744     {
2745       /* See comment for andsi3.  */
2746       rtx reg0 = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (HImode);
2747       rtx reg1 = operands[1];
2749       if (! REG_P (reg1))
2750         {
2751           emit_move_insn (reg0, reg1);
2752           reg1 = reg0;
2753         }
2755       emit_insn (gen_rtx_SET (HImode, reg0,
2756                           gen_rtx_AND (HImode, reg1, operands[2])));
2758       /* Make sure we get the right destination.  */
2759       if (! REG_P (operands[0]))
2760         emit_move_insn (operands[0], reg0);
2762       DONE;
2763     }
2766 ;; Some fast andhi3 special cases.
2768 (define_insn "*andhi_movu"
2769   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
2770         (and:HI (match_operand:HI 1 "nonimmediate_operand" "r,Q>,m")
2771                 (const_int 255)))]
2772   ""
2773   "mOvu.b %1,%0"
2774   [(set_attr "slottable" "yes,yes,no")])
2776 (define_insn "*andhi_clear_signed"
2777   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,Q>,m")
2778         (and:HI (match_operand:HI 1 "nonimmediate_operand" "0,0,0")
2779                 (const_int -256)))]
2780   ""
2781   "cLear.b %0"
2782   [(set_attr "slottable" "yes,yes,no")
2783    (set_attr "cc" "none")])
2785 ;; FIXME: Either this or the pattern above should be redundant.
2786 (define_insn "*andhi_clear_unsigned"
2787   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,Q>,m")
2788         (and:HI (match_operand:HI 1 "nonimmediate_operand" "0,0,0")
2789                 (const_int 65280)))]
2790   ""
2791   "cLear.b %0"
2792   [(set_attr "slottable" "yes,yes,no")
2793    (set_attr "cc" "none")])
2795 ;; Catch-all andhi3 pattern.
2797 (define_insn "*expanded_andhi"
2798   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r,r")
2799         (and:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0,0,r")
2800                 (match_operand:HI 2 "general_operand" "I,r,Q>,L,O,g,!To")))]
2802 ;; Sidenote: the tightening from "general_operand" to
2803 ;; "register_operand" for operand 1 actually increased the register
2804 ;; pressure (worse code).  That will hopefully change with an
2805 ;; improved reload pass.
2807   ""
2808   "@
2809    andq %2,%0
2810    and.w %2,%0
2811    and.w %2,%0
2812    and.w %2,%0
2813    anDq %b2,%0
2814    and.w %2,%0
2815    and.w %2,%1,%0"
2816   [(set_attr "slottable" "yes,yes,yes,no,yes,no,no")
2817    (set_attr "cc" "clobber,normal,normal,normal,clobber,normal,normal")])
2819 ;; A strict_low_part pattern.
2821 (define_insn "*andhi_lowpart"
2822   [(set (strict_low_part
2823          (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r"))
2824         (and:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0,r")
2825                 (match_operand:HI 2 "general_operand" "r,Q>,L,O,g,!To")))]
2826   ""
2827   "@
2828    and.w %2,%0
2829    and.w %2,%0
2830    and.w %2,%0
2831    anDq %b2,%0
2832    and.w %2,%0
2833    and.w %2,%1,%0"
2834   [(set_attr "slottable" "yes,yes,no,yes,no,no")
2835    (set_attr "cc" "normal,normal,normal,clobber,normal,normal")])
2837 (define_insn "andqi3"
2838   [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r,r")
2839         (and:QI (match_operand:QI 1 "register_operand" "%0,0,0,0,0,r")
2840                 (match_operand:QI 2 "general_operand" "I,r,Q>,O,g,!To")))]
2841   ""
2842   "@
2843    andq %2,%0
2844    and.b %2,%0
2845    and.b %2,%0
2846    andQ %b2,%0
2847    and.b %2,%0
2848    and.b %2,%1,%0"
2849   [(set_attr "slottable" "yes,yes,yes,yes,no,no")
2850    (set_attr "cc" "clobber,normal,normal,clobber,normal,normal")])
2852 (define_insn "*andqi_lowpart"
2853   [(set (strict_low_part
2854          (match_operand:QI 0 "register_operand" "=r,r,r,r,r"))
2855         (and:QI (match_operand:QI 1 "register_operand" "%0,0,0,0,r")
2856                 (match_operand:QI 2 "general_operand" "r,Q>,O,g,!To")))]
2857   ""
2858   "@
2859    and.b %2,%0
2860    and.b %2,%0
2861    andQ %b2,%0
2862    and.b %2,%0
2863    and.b %2,%1,%0"
2864   [(set_attr "slottable" "yes,yes,yes,no,no")
2865    (set_attr "cc" "normal,normal,clobber,normal,normal")])
2867 ;; Bitwise or.
2869 ;; Same comment as anddi3 applies here - no need for such a pattern.
2871 ;; It seems there's no need to jump through hoops to get good code such as
2872 ;; with andsi3.
2874 (define_insn "iorsi3"
2875   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
2876         (ior:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,r")
2877                 (match_operand:SI 2 "general_operand" "I,r,Q>,n,g,!To")))]
2878   ""
2879   "@
2880    orq %2,%0
2881    or.d %2,%0
2882    or.d %2,%0
2883    oR.%s2 %2,%0
2884    or.d %2,%0
2885    or.d %2,%1,%0"
2886   [(set_attr "slottable" "yes,yes,yes,no,no,no")
2887    (set_attr "cc" "normal,normal,normal,clobber,normal,normal")])
2889 (define_insn "iorhi3"
2890   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r,r")
2891         (ior:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0,0,r")
2892                 (match_operand:HI 2 "general_operand" "I,r,Q>,L,O,g,!To")))]
2893   ""
2894   "@
2895    orq %2,%0
2896    or.w %2,%0
2897    or.w %2,%0
2898    or.w %2,%0
2899    oRq %b2,%0
2900    or.w %2,%0
2901    or.w %2,%1,%0"
2902   [(set_attr "slottable" "yes,yes,yes,no,yes,no,no")
2903    (set_attr "cc" "clobber,normal,normal,normal,clobber,normal,normal")])
2905 (define_insn "iorqi3"
2906   [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r,r")
2907         (ior:QI (match_operand:QI 1 "register_operand" "%0,0,0,0,0,r")
2908                 (match_operand:QI 2 "general_operand" "I,r,Q>,O,g,!To")))]
2909   ""
2910   "@
2911    orq %2,%0
2912    or.b %2,%0
2913    or.b %2,%0
2914    orQ %b2,%0
2915    or.b %2,%0
2916    or.b %2,%1,%0"
2917   [(set_attr "slottable" "yes,yes,yes,yes,no,no")
2918    (set_attr "cc" "clobber,normal,normal,clobber,normal,normal")])
2920 ;; Exclusive-or
2922 ;; See comment about "anddi3" for xordi3 - no need for such a pattern.
2924 (define_insn "xorsi3"
2925   [(set (match_operand:SI 0 "register_operand" "=r")
2926         (xor:SI (match_operand:SI 1 "register_operand" "%0")
2927                 (match_operand:SI 2 "register_operand" "r")))]
2928   ""
2929   "xor %2,%0"
2930   [(set_attr "slottable" "yes")])
2932 (define_insn "xorhi3"
2933   [(set (match_operand:HI 0 "register_operand" "=r")
2934         (xor:HI (match_operand:HI 1 "register_operand" "%0")
2935                 (match_operand:HI 2 "register_operand" "r")))]
2936   ""
2937   "xor %2,%0"
2938   [(set_attr "slottable" "yes")
2939    (set_attr "cc" "clobber")])
2941 (define_insn "xorqi3"
2942   [(set (match_operand:QI 0 "register_operand" "=r")
2943         (xor:QI (match_operand:QI 1 "register_operand" "%0")
2944                 (match_operand:QI 2 "register_operand" "r")))]
2945   ""
2946   "xor %2,%0"
2947   [(set_attr "slottable" "yes")
2948    (set_attr "cc" "clobber")])
2950 ;; Negation insns.
2952 ;; Questionable use, here mostly as a (slightly usable) define_expand
2953 ;; example.
2955 (define_expand "negsf2"
2956   [(set (match_dup 2)
2957         (match_dup 3))
2958    (parallel [(set (match_operand:SF 0 "register_operand" "=r")
2959                    (neg:SF (match_operand:SF 1
2960                             "register_operand" "0")))
2961               (use (match_dup 2))])]
2962   ""
2963   "
2965   operands[2] = gen_reg_rtx (SImode);
2966   operands[3] = GEN_INT (1 << 31);
2969 (define_insn "*expanded_negsf2"
2970   [(set (match_operand:SF 0 "register_operand" "=r")
2971         (neg:SF (match_operand:SF 1 "register_operand" "0")))
2972    (use (match_operand:SI 2 "register_operand" "r"))]
2973   ""
2974   "xor %2,%0"
2975   [(set_attr "slottable" "yes")])
2977 ;; No "negdi2" although we could make one up that may be faster than
2978 ;; the one in libgcc.
2980 (define_insn "negsi2"
2981   [(set (match_operand:SI 0 "register_operand" "=r")
2982         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
2983   ""
2984   "neg.d %1,%0"
2985   [(set_attr "slottable" "yes")])
2987 (define_insn "neghi2"
2988   [(set (match_operand:HI 0 "register_operand" "=r")
2989         (neg:HI (match_operand:HI 1 "register_operand" "r")))]
2990   ""
2991   "neg.w %1,%0"
2992   [(set_attr "slottable" "yes")])
2994 (define_insn "negqi2"
2995   [(set (match_operand:QI 0 "register_operand" "=r")
2996         (neg:QI (match_operand:QI 1 "register_operand" "r")))]
2997   ""
2998   "neg.b %1,%0"
2999   [(set_attr "slottable" "yes")])
3001 ;; One-complements.
3003 ;; See comment on anddi3 - no need for a DImode pattern.
3005 (define_insn "one_cmplsi2"
3006   [(set (match_operand:SI 0 "register_operand" "=r")
3007         (not:SI (match_operand:SI 1 "register_operand" "0")))]
3008   ""
3009   "not %0"
3010   [(set_attr "slottable" "yes")])
3012 (define_insn "one_cmplhi2"
3013   [(set (match_operand:HI 0 "register_operand" "=r")
3014         (not:HI (match_operand:HI 1 "register_operand" "0")))]
3015   ""
3016   "not %0"
3017   [(set_attr "slottable" "yes")
3018    (set_attr "cc" "clobber")])
3020 (define_insn "one_cmplqi2"
3021   [(set (match_operand:QI 0 "register_operand" "=r")
3022         (not:QI (match_operand:QI 1 "register_operand" "0")))]
3023   ""
3024   "not %0"
3025   [(set_attr "slottable" "yes")
3026    (set_attr "cc" "clobber")])
3028 ;; Arithmetic shift right.
3030 (define_insn "ashrsi3"
3031   [(set (match_operand:SI 0 "register_operand" "=r")
3032         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
3033                      (match_operand:SI 2 "nonmemory_operand" "Kr")))]
3034   ""
3035   "*
3037   if (REG_S_P (operands[2]))
3038     return \"asr.d %2,%0\";
3040   return \"asrq %2,%0\";
3042   [(set_attr "slottable" "yes")])
3044 ;; Since gcc gets lost, and forgets to zero-extend the source (or mask
3045 ;; the destination) when it changes shifts of lower modes into SImode,
3046 ;; it is better to make these expands an anonymous patterns instead of
3047 ;; the more correct define_insns.  This occurs when gcc thinks that is
3048 ;; is better to widen to SImode and use immediate shift count.
3050 ;; FIXME: Is this legacy or still true for gcc >= 2.7.2?
3052 (define_expand "ashrhi3"
3053   [(set (match_dup 3)
3054         (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))
3055    (set (match_dup 4)
3056         (zero_extend:SI (match_operand:HI 2 "nonimmediate_operand" "rm")))
3057    (set (match_dup 5) (ashiftrt:SI (match_dup 3) (match_dup 4)))
3058    (set (match_operand:HI 0 "general_operand" "=g")
3059         (subreg:HI (match_dup 5) 0))]
3060   ""
3061   "
3063   int i;
3065   for (i = 3; i < 6; i++)
3066     operands[i] = gen_reg_rtx (SImode);
3069 (define_insn "*expanded_ashrhi"
3070   [(set (match_operand:HI 0 "register_operand" "=r")
3071         (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
3072                      (match_operand:HI 2 "register_operand" "r")))]
3073   ""
3074   "asr.w %2,%0"
3075   [(set_attr "slottable" "yes")])
3077 (define_insn "*ashrhi_lowpart"
3078   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
3079         (ashiftrt:HI (match_dup 0)
3080                      (match_operand:HI 1 "register_operand" "r")))]
3081   ""
3082   "asr.w %1,%0"
3083   [(set_attr "slottable" "yes")])
3085 ;; Same comment goes as for "ashrhi3".
3087 (define_expand "ashrqi3"
3088   [(set (match_dup 3)
3089         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "g")))
3090    (set (match_dup 4)
3091         (zero_extend:SI (match_operand:QI 2 "nonimmediate_operand" "g")))
3092    (set (match_dup 5) (ashiftrt:SI (match_dup 3) (match_dup 4)))
3093    (set (match_operand:QI 0 "general_operand" "=g")
3094         (subreg:QI (match_dup 5) 0))]
3095   ""
3096   "
3098   int i;
3100   for (i = 3; i < 6; i++)
3101     operands[i] = gen_reg_rtx (SImode);
3104 (define_insn "*expanded_ashrqi"
3105   [(set (match_operand:QI 0 "register_operand" "=r")
3106         (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
3107                      (match_operand:QI 2 "register_operand" "r")))]
3108   ""
3109   "asr.b %2,%0"
3110   [(set_attr "slottable" "yes")])
3112 ;; A strict_low_part matcher.
3114 (define_insn "*ashrqi_lowpart"
3115   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+r"))
3116         (ashiftrt:QI (match_dup 0)
3117                      (match_operand:QI 1 "register_operand" "r")))]
3118   ""
3119   "asr.b %1,%0"
3120   [(set_attr "slottable" "yes")])
3122 ;; Logical shift right.
3124 (define_insn "lshrsi3"
3125   [(set (match_operand:SI 0 "register_operand" "=r")
3126         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
3127                      (match_operand:SI 2 "nonmemory_operand" "Kr")))]
3128   ""
3129   "*
3131   if (REG_S_P (operands[2]))
3132     return \"lsr.d %2,%0\";
3134   return \"lsrq %2,%0\";
3136   [(set_attr "slottable" "yes")])
3138 ;; Same comments as for ashrhi3.
3140 (define_expand "lshrhi3"
3141   [(set (match_dup 3)
3142         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "g")))
3143    (set (match_dup 4)
3144         (zero_extend:SI (match_operand:HI 2 "nonimmediate_operand" "g")))
3145    (set (match_dup 5) (lshiftrt:SI (match_dup 3) (match_dup 4)))
3146    (set (match_operand:HI 0 "general_operand" "=g")
3147         (subreg:HI (match_dup 5) 0))]
3148   ""
3149   "
3151   int i;
3153   for (i = 3; i < 6; i++)
3154     operands[i] = gen_reg_rtx (SImode);
3157 (define_insn "*expanded_lshrhi"
3158   [(set (match_operand:HI 0 "register_operand" "=r")
3159         (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
3160                      (match_operand:HI 2 "register_operand" "r")))]
3161   ""
3162   "lsr.w %2,%0"
3163   [(set_attr "slottable" "yes")])
3165 ;; A strict_low_part matcher.
3167 (define_insn "*lshrhi_lowpart"
3168   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
3169         (lshiftrt:HI (match_dup 0)
3170                      (match_operand:HI 1 "register_operand" "r")))]
3171   ""
3172   "lsr.w %1,%0"
3173   [(set_attr "slottable" "yes")])
3175 ;; Same comments as for ashrhi3.
3177 (define_expand "lshrqi3"
3178   [(set (match_dup 3)
3179         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "g")))
3180    (set (match_dup 4)
3181         (zero_extend:SI (match_operand:QI 2 "nonimmediate_operand" "g")))
3182    (set (match_dup 5) (lshiftrt:SI (match_dup 3) (match_dup 4)))
3183    (set (match_operand:QI 0 "general_operand" "=g")
3184         (subreg:QI (match_dup 5) 0))]
3185   ""
3186   "
3188   int i;
3190   for (i = 3; i < 6; i++)
3191     operands[i] = gen_reg_rtx (SImode);
3194 (define_insn "*expanded_lshrqi"
3195   [(set (match_operand:QI 0 "register_operand" "=r")
3196         (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
3197                      (match_operand:QI 2 "register_operand" "r")))]
3198   ""
3199   "lsr.b %2,%0"
3200   [(set_attr "slottable" "yes")])
3202 ;; A strict_low_part matcher.
3204 (define_insn "*lshrqi_lowpart"
3205   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+r"))
3206         (lshiftrt:QI (match_dup 0)
3207                      (match_operand:QI 1 "register_operand" "r")))]
3208   ""
3209   "lsr.b %1,%0"
3210   [(set_attr "slottable" "yes")])
3212 ;; Arithmetic/logical shift left.
3214 (define_insn "ashlsi3"
3215   [(set (match_operand:SI 0 "register_operand" "=r")
3216         (ashift:SI (match_operand:SI 1 "register_operand" "0")
3217                    (match_operand:SI 2 "nonmemory_operand" "Kr")))]
3218   ""
3219   "*
3221   if (REG_S_P (operands[2]))
3222     return \"lsl.d %2,%0\";
3224   return \"lslq %2,%0\";
3226   [(set_attr "slottable" "yes")])
3228 ;; For narrower modes than SI, we can use lslq although it makes cc
3229 ;; unusable.  The win is that we do not have to reload the shift-count
3230 ;; into a register.
3232 (define_insn "ashlhi3"
3233   [(set (match_operand:HI 0 "register_operand" "=r,r")
3234         (ashift:HI (match_operand:HI 1 "register_operand" "0,0")
3235                    (match_operand:HI 2 "nonmemory_operand" "r,K")))]
3236   ""
3237   "*
3239   return
3240     (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) > 15)
3241     ? \"moveq 0,%0\"
3242     : (CONSTANT_P (operands[2])
3243        ? \"lslq %2,%0\" : \"lsl.w %2,%0\");
3245   [(set_attr "slottable" "yes")
3246    (set_attr "cc" "normal,clobber")])
3248 ;; A strict_low_part matcher.
3250 (define_insn "*ashlhi_lowpart"
3251   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
3252         (ashift:HI (match_dup 0)
3253                    (match_operand:HI 1 "register_operand" "r")))]
3254   ""
3255   "lsl.w %1,%0"
3256   [(set_attr "slottable" "yes")])
3258 (define_insn "ashlqi3"
3259   [(set (match_operand:QI 0 "register_operand" "=r,r")
3260         (ashift:QI (match_operand:QI 1 "register_operand" "0,0")
3261                    (match_operand:QI 2 "nonmemory_operand" "r,K")))]
3262   ""
3263   "*
3265   return
3266     (GET_CODE (operands[2]) == CONST_INT
3267      && INTVAL (operands[2]) > 7)
3268     ? \"moveq 0,%0\"
3269     : (CONSTANT_P (operands[2])
3270        ? \"lslq %2,%0\" : \"lsl.b %2,%0\");
3272   [(set_attr "slottable" "yes")
3273    (set_attr "cc" "normal,clobber")])
3275 ;; A strict_low_part matcher.
3277 (define_insn "*ashlqi_lowpart"
3278   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+r"))
3279         (ashift:QI (match_dup 0)
3280                    (match_operand:QI 1 "register_operand" "r")))]
3281   ""
3282   "lsl.b %1,%0"
3283   [(set_attr "slottable" "yes")])
3285 ;; Various strange insns that gcc likes.
3287 ;; Fortunately, it is simple to construct an abssf (although it may not
3288 ;; be very much used in practice).
3290 (define_insn "abssf2"
3291   [(set (match_operand:SF 0 "register_operand" "=r")
3292         (abs:SF (match_operand:SF 1 "register_operand" "0")))]
3293   ""
3294   "lslq 1,%0\;lsrq 1,%0")
3296 (define_insn "abssi2"
3297   [(set (match_operand:SI 0 "register_operand" "=r")
3298         (abs:SI (match_operand:SI 1 "register_operand" "r")))]
3299   ""
3300   "abs %1,%0"
3301   [(set_attr "slottable" "yes")])
3303 ;; FIXME: GCC should be able to do these expansions itself.
3305 (define_expand "abshi2"
3306   [(set (match_dup 2)
3307         (sign_extend:SI (match_operand:HI 1 "general_operand" "g")))
3308    (set (match_dup 3) (abs:SI (match_dup 2)))
3309    (set (match_operand:HI 0 "register_operand" "=r")
3310         (subreg:HI (match_dup 3) 0))]
3311   ""
3312   "operands[2] = gen_reg_rtx (SImode); operands[3] = gen_reg_rtx (SImode);")
3314 (define_expand "absqi2"
3315   [(set (match_dup 2)
3316         (sign_extend:SI (match_operand:QI 1 "general_operand" "g")))
3317    (set (match_dup 3) (abs:SI (match_dup 2)))
3318    (set (match_operand:QI 0 "register_operand" "=r")
3319         (subreg:QI (match_dup 3) 0))]
3320   ""
3321   "operands[2] = gen_reg_rtx (SImode); operands[3] = gen_reg_rtx (SImode);")
3323 ;; Bound-insn.  Defined to be the same as an unsigned minimum, which is an
3324 ;; operation supported by gcc.  Used in casesi, but used now and then in
3325 ;; normal code too.
3327 (define_insn "uminsi3"
3328   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
3329         (umin:SI  (match_operand:SI 1 "register_operand" "%0,0,0,r")
3330                   (match_operand:SI 2 "general_operand" "r,Q>,g,!STo")))]
3331   ""
3332   "*
3334   if (GET_CODE (operands[2]) == CONST_INT)
3335     {
3336       if (INTVAL (operands[2]) < 256)
3337         return \"bound.b %2,%0\";
3339       if (INTVAL (operands[2]) < 65536)
3340         return \"bound.w %2,%0\";
3341     }
3342   else if (which_alternative == 3)
3343     return \"bound.d %2,%1,%0\";
3345   return \"bound.d %2,%0\";
3347  [(set_attr "slottable" "yes,yes,no,no")])
3349 ;; Jump and branch insns.
3351 (define_insn "jump"
3352   [(set (pc)
3353         (label_ref (match_operand 0 "" "")))]
3354   ""
3355   "ba %l0%#"
3356   [(set_attr "slottable" "has_slot")])
3358 ;; Testcase gcc.c-torture/compile/991213-3.c fails if we allow a constant
3359 ;; here, since the insn is not recognized as an indirect jump by
3360 ;; jmp_uses_reg_or_mem used by computed_jump_p.  Perhaps it is a kludge to
3361 ;; change from general_operand to nonimmediate_operand (at least the docs
3362 ;; should be changed), but then again the pattern is called indirect_jump.
3363 (define_insn "indirect_jump"
3364   [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))]
3365   ""
3366   "jump %0")
3368 ;; Return insn.  Used whenever the epilogue is very simple; if it is only
3369 ;; a single ret or jump [sp+] or a contiguous sequence of movem:able saved
3370 ;; registers.  No allocated stack space is allowed.
3371 ;; Note that for this pattern, although named, it is ok to check the
3372 ;; context of the insn in the test, not only compiler switches.
3374 (define_insn "return"
3375   [(return)]
3376   "cris_simple_epilogue ()"
3377   "*
3379   int i;
3381   /* Just needs to hold a 'movem [sp+],rN'.  */
3382   char rd[sizeof (\"movem [$sp+],$r99\")];
3384   /* Try to avoid reorg.c surprises; avoid emitting invalid code, prefer
3385      crashing.  This test would have avoided invalid code for target/7042.  */
3386   if (current_function_epilogue_delay_list != NULL)
3387     abort ();
3389   *rd = 0;
3391   /* Start from the last call-saved register.  We know that we have a
3392      simple epilogue, so we just have to find the last register in the
3393      movem sequence.  */
3394   for (i = 8; i >= 0; i--)
3395     if (regs_ever_live[i]
3396         || (i == PIC_OFFSET_TABLE_REGNUM
3397             && current_function_uses_pic_offset_table))
3398       break;
3400   if (i >= 0)
3401     sprintf (rd, \"movem [$sp+],$%s\", reg_names [i]);
3403   if (regs_ever_live[CRIS_SRP_REGNUM])
3404     {
3405       if (*rd)
3406         output_asm_insn (rd, operands);
3407       return \"jump [$sp+]\";
3408     }
3410   if (*rd)
3411     {
3412       output_asm_insn (\"reT\", operands);
3413       output_asm_insn (rd, operands);
3414       return \"\";
3415     }
3417   return \"ret%#\";
3419   [(set (attr "slottable")
3420         (if_then_else
3421          (ne (symbol_ref "regs_ever_live[CRIS_SRP_REGNUM]") (const_int 0))
3422          (const_string "no")         ; If jump then not slottable.
3423          (if_then_else
3424           (ne (symbol_ref
3425                "(regs_ever_live[0]
3426                  || (flag_pic != 0 && regs_ever_live[1])
3427                  || (PIC_OFFSET_TABLE_REGNUM == 0
3428                      && cris_cfun_uses_pic_table ()))")
3429               (const_int 0))
3430           (const_string "no") ; ret+movem [sp+],rx: slot already filled.
3431           (const_string "has_slot")))) ; If ret then need to fill a slot.
3432    (set_attr "cc" "none")])
3434 ;; Conditional branches.
3436 ;; We suffer from the same overflow-bit-gets-in-the-way problem as
3437 ;; e.g. m68k, so we have to check if overflow bit is set on all "signed"
3438 ;; conditions.
3440 (define_insn "beq"
3441   [(set (pc)
3442         (if_then_else (eq (cc0)
3443                           (const_int 0))
3444                       (label_ref (match_operand 0 "" ""))
3445                       (pc)))]
3446   ""
3447   "beq %l0%#"
3448   [(set_attr "slottable" "has_slot")])
3450 (define_insn "bne"
3451   [(set (pc)
3452         (if_then_else (ne (cc0)
3453                           (const_int 0))
3454                       (label_ref (match_operand 0 "" ""))
3455                       (pc)))]
3456   ""
3457   "bne %l0%#"
3458   [(set_attr "slottable" "has_slot")])
3460 (define_insn "bgt"
3461   [(set (pc)
3462         (if_then_else (gt (cc0)
3463                           (const_int 0))
3464                       (label_ref (match_operand 0 "" ""))
3465                       (pc)))]
3466   ""
3467   "*
3469   return
3470     (cc_prev_status.flags & CC_NO_OVERFLOW)
3471     ? 0 : \"bgt %l0%#\";
3473   [(set_attr "slottable" "has_slot")])
3475 (define_insn "bgtu"
3476   [(set (pc)
3477         (if_then_else (gtu (cc0)
3478                            (const_int 0))
3479                       (label_ref (match_operand 0 "" ""))
3480                       (pc)))]
3481   ""
3482   "bhi %l0%#"
3483   [(set_attr "slottable" "has_slot")])
3485 (define_insn "blt"
3486   [(set (pc)
3487         (if_then_else (lt (cc0)
3488                           (const_int 0))
3489                       (label_ref (match_operand 0 "" ""))
3490                       (pc)))]
3491   ""
3492   "*
3494   return
3495     (cc_prev_status.flags & CC_NO_OVERFLOW)
3496     ? \"bmi %l0%#\" : \"blt %l0%#\";
3498   [(set_attr "slottable" "has_slot")])
3500 (define_insn "bltu"
3501   [(set (pc)
3502         (if_then_else (ltu (cc0)
3503                            (const_int 0))
3504                       (label_ref (match_operand 0 "" ""))
3505                       (pc)))]
3506   ""
3507   "blo %l0%#"
3508   [(set_attr "slottable" "has_slot")])
3510 (define_insn "bge"
3511   [(set (pc)
3512         (if_then_else (ge (cc0)
3513                           (const_int 0))
3514                       (label_ref (match_operand 0 "" ""))
3515                       (pc)))]
3516   ""
3517   "*
3519   return
3520     (cc_prev_status.flags & CC_NO_OVERFLOW)
3521     ? \"bpl %l0%#\" : \"bge %l0%#\";
3523   [(set_attr "slottable" "has_slot")])
3525 (define_insn "bgeu"
3526   [(set (pc)
3527         (if_then_else (geu (cc0)
3528                            (const_int 0))
3529                       (label_ref (match_operand 0 "" ""))
3530                       (pc)))]
3531   ""
3532   "bhs %l0%#"
3533   [(set_attr "slottable" "has_slot")])
3535 (define_insn "ble"
3536   [(set (pc)
3537         (if_then_else (le (cc0)
3538                           (const_int 0))
3539                       (label_ref (match_operand 0 "" ""))
3540                       (pc)))]
3541   ""
3542   "*
3544   return
3545     (cc_prev_status.flags & CC_NO_OVERFLOW)
3546     ? 0 : \"ble %l0%#\";
3548   [(set_attr "slottable" "has_slot")])
3550 (define_insn "bleu"
3551   [(set (pc)
3552         (if_then_else (leu (cc0)
3553                            (const_int 0))
3554                       (label_ref (match_operand 0 "" ""))
3555                       (pc)))]
3556   ""
3557   "bls %l0%#"
3558   [(set_attr "slottable" "has_slot")])
3560 ;; Reversed anonymous patterns to the ones above, as mandated.
3562 (define_insn "*beq_reversed"
3563   [(set (pc)
3564         (if_then_else (eq (cc0)
3565                           (const_int 0))
3566                       (pc)
3567                       (label_ref (match_operand 0 "" ""))))]
3568   ""
3569   "bne %l0%#"
3570   [(set_attr "slottable" "has_slot")])
3572 (define_insn "*bne_reversed"
3573   [(set (pc)
3574         (if_then_else (ne (cc0)
3575                           (const_int 0))
3576                       (pc)
3577                       (label_ref (match_operand 0 "" ""))))]
3578   ""
3579   "beq %l0%#"
3580   [(set_attr "slottable" "has_slot")])
3582 (define_insn "*bgt_reversed"
3583   [(set (pc)
3584         (if_then_else (gt (cc0)
3585                           (const_int 0))
3586                       (pc)
3587                       (label_ref (match_operand 0 "" ""))))]
3588   ""
3589   "*
3591   return
3592     (cc_prev_status.flags & CC_NO_OVERFLOW)
3593     ? 0 : \"ble %l0%#\";
3595   [(set_attr "slottable" "has_slot")])
3597 (define_insn "*bgtu_reversed"
3598   [(set (pc)
3599         (if_then_else (gtu (cc0)
3600                            (const_int 0))
3601                       (pc)
3602                       (label_ref (match_operand 0 "" ""))))]
3603   ""
3604   "bls %l0%#"
3605   [(set_attr "slottable" "has_slot")])
3607 (define_insn "*blt_reversed"
3608   [(set (pc)
3609         (if_then_else (lt (cc0)
3610                           (const_int 0))
3611                       (pc)
3612                       (label_ref (match_operand 0 "" ""))))]
3613   ""
3614   "*
3616   return
3617     (cc_prev_status.flags & CC_NO_OVERFLOW)
3618     ? \"bpl %l0%#\" : \"bge %l0%#\";
3620   [(set_attr "slottable" "has_slot")])
3622 (define_insn "*bltu_reversed"
3623   [(set (pc)
3624         (if_then_else (ltu (cc0)
3625                            (const_int 0))
3626                       (pc)
3627                       (label_ref (match_operand 0 "" ""))))]
3628   ""
3629   "bhs %l0%#"
3630   [(set_attr "slottable" "has_slot")])
3632 (define_insn "*bge_reversed"
3633   [(set (pc)
3634         (if_then_else (ge (cc0)
3635                           (const_int 0))
3636                       (pc)
3637                       (label_ref (match_operand 0 "" ""))))]
3638   ""
3639   "*
3641   return
3642     (cc_prev_status.flags & CC_NO_OVERFLOW)
3643     ? \"bmi %l0%#\" : \"blt %l0%#\";
3645   [(set_attr "slottable" "has_slot")])
3647 (define_insn "*bgeu_reversed"
3648   [(set (pc)
3649         (if_then_else (geu (cc0)
3650                            (const_int 0))
3651                       (pc)
3652                       (label_ref (match_operand 0 "" ""))))]
3653   ""
3654   "blo %l0%#"
3655   [(set_attr "slottable" "has_slot")])
3657 (define_insn "*ble_reversed"
3658   [(set (pc)
3659         (if_then_else (le (cc0)
3660                           (const_int 0))
3661                       (pc)
3662                       (label_ref (match_operand 0 "" ""))))]
3663   ""
3664   "*
3666   return
3667     (cc_prev_status.flags & CC_NO_OVERFLOW)
3668     ? 0 : \"bgt %l0%#\";
3670   [(set_attr "slottable" "has_slot")])
3672 (define_insn "*bleu_reversed"
3673   [(set (pc)
3674         (if_then_else (leu (cc0)
3675                            (const_int 0))
3676                       (pc)
3677                       (label_ref (match_operand 0 "" ""))))]
3678   ""
3679   "bhi %l0%#"
3680   [(set_attr "slottable" "has_slot")])
3682 ;; Set on condition: sCC.
3684 ;; Like bCC, we have to check the overflow bit for
3685 ;; signed conditions.
3687 (define_insn "sgeu"
3688   [(set (match_operand:SI 0 "register_operand" "=r")
3689         (geu:SI (cc0) (const_int 0)))]
3690   ""
3691   "shs %0"
3692   [(set_attr "slottable" "yes")
3693    (set_attr "cc" "none")])
3695 (define_insn "sltu"
3696   [(set (match_operand:SI 0 "register_operand" "=r")
3697         (ltu:SI (cc0) (const_int 0)))]
3698   ""
3699   "slo %0"
3700   [(set_attr "slottable" "yes")
3701    (set_attr "cc" "none")])
3703 (define_insn "seq"
3704   [(set (match_operand:SI 0 "register_operand" "=r")
3705         (eq:SI (cc0) (const_int 0)))]
3706   ""
3707   "seq %0"
3708   [(set_attr "slottable" "yes")
3709    (set_attr "cc" "none")])
3711 (define_insn "sge"
3712   [(set (match_operand:SI 0 "register_operand" "=r")
3713         (ge:SI (cc0) (const_int 0)))]
3714   ""
3715   "*
3717   return
3718     (cc_prev_status.flags & CC_NO_OVERFLOW)
3719     ? \"spl %0\" : \"sge %0\";
3721   [(set_attr "slottable" "yes")
3722    (set_attr "cc" "none")])
3724 (define_insn "sgt"
3725   [(set (match_operand:SI 0 "register_operand" "=r")
3726         (gt:SI (cc0) (const_int 0)))]
3727   ""
3728   "*
3730   return
3731     (cc_prev_status.flags & CC_NO_OVERFLOW)
3732     ? 0 : \"sgt %0\";
3734   [(set_attr "slottable" "yes")
3735    (set_attr "cc" "none")])
3737 (define_insn "sgtu"
3738   [(set (match_operand:SI 0 "register_operand" "=r")
3739         (gtu:SI (cc0) (const_int 0)))]
3740   ""
3741   "shi %0"
3742   [(set_attr "slottable" "yes")
3743    (set_attr "cc" "none")])
3745 (define_insn "sle"
3746   [(set (match_operand:SI 0 "register_operand" "=r")
3747         (le:SI (cc0) (const_int 0)))]
3748   ""
3749   "*
3751   return
3752     (cc_prev_status.flags & CC_NO_OVERFLOW)
3753     ? 0 : \"sle %0\";
3755   [(set_attr "slottable" "yes")
3756    (set_attr "cc" "none")])
3758 (define_insn "sleu"
3759   [(set (match_operand:SI 0 "register_operand" "=r")
3760         (leu:SI (cc0) (const_int 0)))]
3761   ""
3762   "sls %0"
3763   [(set_attr "slottable" "yes")
3764    (set_attr "cc" "none")])
3766 (define_insn "slt"
3767   [(set (match_operand:SI 0 "register_operand" "=r")
3768         (lt:SI (cc0) (const_int 0)))]
3769   ""
3770   "*
3772   return
3773     (cc_prev_status.flags & CC_NO_OVERFLOW)
3774     ? \"smi %0\" : \"slt %0\";
3776   [(set_attr "slottable" "yes")
3777    (set_attr "cc" "none")])
3779 (define_insn "sne"
3780   [(set (match_operand:SI 0 "register_operand" "=r")
3781         (ne:SI (cc0) (const_int 0)))]
3782   ""
3783   "sne %0"
3784   [(set_attr "slottable" "yes")
3785    (set_attr "cc" "none")])
3787 ;; Call insns.
3789 ;; We need to make these patterns "expand", since the real operand is
3790 ;; hidden in a (mem:QI ) inside operand[0] (call_value: operand[1]),
3791 ;; and cannot be checked if it were a "normal" pattern.
3792 ;;  Note that "call" and "call_value" are *always* called with a
3793 ;; mem-operand for operand 0 and 1 respective.  What happens for combined
3794 ;; instructions is a different issue.
3796 (define_expand "call"
3797   [(parallel [(call (match_operand:QI 0 "cris_mem_call_operand" "")
3798                     (match_operand 1 "general_operand" ""))
3799               ;; 16 is the srp (can't use the symbolic name here)
3800               (clobber (reg:SI 16))])]
3801   ""
3802   "
3804   rtx op0;
3806   if (GET_CODE (operands[0]) != MEM)
3807     abort ();
3809   if (flag_pic)
3810     {
3811       op0 = XEXP (operands[0], 0);
3813       /* It might be that code can be generated that jumps to 0 (or to a
3814          specific address).  Don't abort on that.  At least there's a
3815          test-case.  */
3816       if (CONSTANT_ADDRESS_P (op0) && GET_CODE (op0) != CONST_INT)
3817         {
3818           if (no_new_pseudos)
3819             abort ();
3821           /* For local symbols (non-PLT), get the plain symbol reference
3822              into a register.  For symbols that can be PLT, make them PLT.  */
3823           if (cris_gotless_symbol (op0) || GET_CODE (op0) != SYMBOL_REF)
3824             op0 = force_reg (Pmode, op0);
3825           else if (cris_symbol (op0))
3826             /* FIXME: Would hanging a REG_EQUIV/EQUAL on that register
3827                for the symbol cause bad recombinatorial effects?  */
3828             op0 = force_reg (Pmode,
3829                              gen_rtx_CONST
3830                              (VOIDmode,
3831                               gen_rtx_UNSPEC (VOIDmode,
3832                                               gen_rtvec (1, op0), 0)));
3833           else
3834             abort ();
3836           operands[0] = gen_rtx_MEM (GET_MODE (operands[0]), op0);
3837         }
3838     }
3841 ;; Accept *anything* as operand 1.  Accept operands for operand 0 in
3842 ;; order of preference (Q includes r, but r is shorter, faster)
3844 (define_insn "*expanded_call"
3845   [(call (mem:QI (match_operand:SI
3846                   0 "cris_general_operand_or_plt_symbol" "r,Q>,g,S"))
3847          (match_operand 1 "" ""))
3848    (clobber (reg:SI 16))] ;; 16 is the srp (can't use symbolic name)
3849   "! TARGET_AVOID_GOTPLT"
3850   "jsr %0")
3852 ;; Same as above, since can't afford wasting a constraint letter to mean
3853 ;; "S unless TARGET_AVOID_GOTPLT".
3854 (define_insn "*expanded_call_no_gotplt"
3855   [(call (mem:QI (match_operand:SI
3856                   0 "cris_general_operand_or_plt_symbol" "r,Q>,g"))
3857          (match_operand 1 "" ""))
3858    (clobber (reg:SI 16))] ;; 16 is the srp (can't use symbolic name)
3859   "TARGET_AVOID_GOTPLT"
3860   "jsr %0")
3862 (define_expand "call_value"
3863   [(parallel [(set (match_operand 0 "" "")
3864                    (call (match_operand:QI 1 "cris_mem_call_operand" "")
3865                          (match_operand 2 "" "")))
3866               ;; 16 is the srp (can't use symbolic name)
3867               (clobber (reg:SI 16))])]
3868   ""
3869   "
3871   rtx op1;
3873   if (GET_CODE (operands[1]) != MEM)
3874     abort ();
3876   if (flag_pic)
3877     {
3878       op1 = XEXP (operands[1], 0);
3880       /* It might be that code can be generated that jumps to 0 (or to a
3881          specific address).  Don't abort on that.  At least there's a
3882          test-case.  */
3883       if (CONSTANT_ADDRESS_P (op1) && GET_CODE (op1) != CONST_INT)
3884         {
3885           if (no_new_pseudos)
3886             abort ();
3888           if (cris_gotless_symbol (op1))
3889             op1 = force_reg (Pmode, op1);
3890           else if (cris_symbol (op1))
3891             /* FIXME: Would hanging a REG_EQUIV/EQUAL on that register
3892                for the symbol cause bad recombinatorial effects?  */
3893             op1 = force_reg (Pmode,
3894                              gen_rtx_CONST
3895                              (VOIDmode,
3896                               gen_rtx_UNSPEC (VOIDmode,
3897                                               gen_rtvec (1, op1), 0)));
3898           else
3899             abort ();
3901           operands[1] = gen_rtx_MEM (GET_MODE (operands[1]), op1);
3902         }
3903     }
3906 ;; Accept *anything* as operand 2.  The validity other than "general" of
3907 ;; operand 0 will be checked elsewhere.  Accept operands for operand 1 in
3908 ;; order of preference (Q includes r, but r is shorter, faster).
3909 ;;  We also accept a PLT symbol.  We output it as [rPIC+sym:GOTPLT] rather
3910 ;; than requiring getting rPIC + sym:PLT into a register.
3912 (define_insn "*expanded_call_value"
3913   [(set (match_operand 0 "nonimmediate_operand" "=g,g,g,g")
3914         (call (mem:QI (match_operand:SI
3915                        1 "cris_general_operand_or_plt_symbol" "r,Q>,g,S"))
3916               (match_operand 2 "" "")))
3917    (clobber (reg:SI 16))]
3918   "! TARGET_AVOID_GOTPLT"
3919   "Jsr %1"
3920   [(set_attr "cc" "clobber")])
3922 ;; Same as above, since can't afford wasting a constraint letter to mean
3923 ;; "S unless TARGET_AVOID_GOTPLT".
3924 (define_insn "*expanded_call_value_no_gotplt"
3925   [(set (match_operand 0 "nonimmediate_operand" "=g,g,g")
3926         (call (mem:QI (match_operand:SI
3927                        1 "cris_general_operand_or_plt_symbol" "r,Q>,g"))
3928               (match_operand 2 "" "")))
3929    (clobber (reg:SI 16))]
3930   "TARGET_AVOID_GOTPLT"
3931   "Jsr %1"
3932   [(set_attr "cc" "clobber")])
3934 ;; Used in debugging.  No use for the direct pattern; unfilled
3935 ;; delayed-branches are taken care of by other means.
3937 (define_insn "nop"
3938   [(const_int 0)]
3939   ""
3940   "nop"
3941   [(set_attr "cc" "none")])
3943 ;; We expand on casesi so we can use "bound" and "add offset fetched from
3944 ;; a table to pc" (adds.w [pc+%0.w],pc).
3946 ;; Note: if you change the "parallel" (or add anything after it) in
3947 ;; this expansion, you must change the macro ASM_OUTPUT_CASE_END
3948 ;; accordingly, to add the default case at the end of the jump-table.
3950 (define_expand "casesi"
3951   [(set (match_dup 5) (match_operand:SI 0 "general_operand" ""))
3952    (set (match_dup 6)
3953         (minus:SI (match_dup 5)
3954                   (match_operand:SI 1 "const_int_operand" "n")))
3955    (set (match_dup 7)
3956         (umin:SI (match_dup 6)
3957                  (match_operand:SI 2 "const_int_operand" "n")))
3958    (parallel
3959     [(set (pc)
3960           (if_then_else
3961            (ltu (match_dup 7) (match_dup 2))
3962            (plus:SI (sign_extend:SI
3963                      (mem:HI
3964                       (plus:SI (mult:SI (match_dup 7) (const_int 2))
3965                                (pc))))
3966                     (pc))
3967            (label_ref (match_operand 4 "" ""))))
3968      (use (label_ref (match_operand 3 "" "")))])]
3969   ""
3970   "
3972   operands[2] = plus_constant (operands[2], 1);
3973   operands[5] = gen_reg_rtx (SImode);
3974   operands[6] = gen_reg_rtx (SImode);
3975   operands[7] = gen_reg_rtx (SImode);
3978 ;; Split-patterns.  Some of them have modes unspecified.  This
3979 ;; should always be ok; if for no other reason sparc.md has it as
3980 ;; well.
3982 ;; When register_operand is specified for an operand, we can get a
3983 ;; subreg as well (Axis-990331), so don't just assume that REG_P is true
3984 ;; for a register_operand and that REGNO can be used as is.  It is best to
3985 ;; guard with REG_P, unless it is worth it to adjust for the subreg case.
3987 ;; op [rx + 0],ry,rz
3988 ;; The index to rx is optimized into zero, and gone.
3990 ;; First, recognize bound [rx],ry,rz; where [rx] is zero-extended,
3991 ;; and add/sub [rx],ry,rz, with zero or sign-extend on [rx].
3992 ;; Split this into:
3993 ;;  move ry,rz
3994 ;;  op [rx],rz
3995 ;; Lose if rz=ry or rx=rz.
3996 ;; Call this op-extend-split
3998 (define_split
3999   [(set (match_operand 0 "register_operand" "")
4000         (match_operator
4001          4 "cris_operand_extend_operator"
4002          [(match_operand 1 "register_operand" "")
4003           (match_operator
4004            3 "cris_extend_operator"
4005            [(match_operand 2 "memory_operand" "")])]))]
4006   "REG_P (operands[0])
4007    && REG_P (operands[1])
4008    && REGNO (operands[1]) != REGNO (operands[0])
4009    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4010    && REG_P (XEXP (operands[2], 0))
4011    && REGNO (XEXP (operands[2], 0)) != REGNO (operands[0])"
4012   [(set (match_dup 0)
4013         (match_dup 1))
4014    (set (match_dup 0)
4015         (match_op_dup
4016          4 [(match_dup 0)
4017             (match_op_dup 3 [(match_dup 2)])]))]
4018   "")
4020 ;; As op-extend-split, but recognize and split op [rz],ry,rz into
4021 ;;  ext [rz],rz
4022 ;;  op ry,rz
4023 ;; Do this for plus or bound only, being commutative operations, since we
4024 ;; have swapped the operands.
4025 ;; Call this op-extend-split-rx=rz
4027 (define_split
4028   [(set (match_operand 0 "register_operand" "")
4029         (match_operator
4030          4 "cris_plus_or_bound_operator"
4031          [(match_operand 1 "register_operand" "")
4032           (match_operator
4033            3 "cris_extend_operator"
4034            [(match_operand 2 "memory_operand" "")])]))]
4035   "REG_P (operands[0])
4036    && REG_P (operands[1])
4037    && REGNO (operands[1]) != REGNO (operands[0])
4038    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4039    && REG_P (XEXP (operands[2], 0))
4040    && REGNO (XEXP (operands[2], 0)) == REGNO (operands[0])"
4041   [(set (match_dup 0)
4042         (match_op_dup 3 [(match_dup 2)]))
4043    (set (match_dup 0)
4044         (match_op_dup
4045          4 [(match_dup 0)
4046             (match_dup 1)]))]
4047   "")
4049 ;; As the op-extend-split, but swapped operands, and only for
4050 ;; plus or bound, being the commutative extend-operators.  FIXME: Why is
4051 ;; this needed?  Is it?
4052 ;; Call this op-extend-split-swapped
4054 (define_split
4055   [(set (match_operand 0 "register_operand" "")
4056         (match_operator
4057          4 "cris_plus_or_bound_operator"
4058          [(match_operator
4059            3 "cris_extend_operator"
4060            [(match_operand 2 "memory_operand" "")])
4061           (match_operand 1 "register_operand" "")]))]
4062   "REG_P (operands[0])
4063    && REG_P (operands[1])
4064    && REGNO (operands[1]) != REGNO (operands[0])
4065    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4066    && REG_P (XEXP (operands[2], 0))
4067    && REGNO (XEXP (operands[2], 0)) != REGNO (operands[0])"
4068   [(set (match_dup 0)
4069         (match_dup 1))
4070    (set (match_dup 0)
4071         (match_op_dup
4072          4 [(match_dup 0)
4073             (match_op_dup 3 [(match_dup 2)])]))]
4074   "")
4076 ;; As op-extend-split-rx=rz, but swapped operands, only for plus or
4077 ;; bound.  Call this op-extend-split-swapped-rx=rz.
4079 (define_split
4080   [(set (match_operand 0 "register_operand" "")
4081         (match_operator
4082          4 "cris_plus_or_bound_operator"
4083          [(match_operator
4084            3 "cris_extend_operator"
4085            [(match_operand 2 "memory_operand" "")])
4086           (match_operand 1 "register_operand" "")]))]
4087   "REG_P (operands[0])
4088    && REG_P (operands[1])
4089    && REGNO (operands[1]) != REGNO (operands[0])
4090    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4091    && REG_P (XEXP (operands[2], 0))
4092    && REGNO (XEXP (operands[2], 0)) == REGNO (operands[0])"
4093   [(set (match_dup 0)
4094         (match_op_dup 3 [(match_dup 2)]))
4095    (set (match_dup 0)
4096         (match_op_dup
4097          4 [(match_dup 0)
4098             (match_dup 1)]))]
4099   "")
4101 ;; As op-extend-split, but the mem operand is not extended.
4103 ;; op [rx],ry,rz changed into
4104 ;;  move ry,rz
4105 ;;  op [rx],rz
4106 ;; lose if ry=rz or rx=rz
4107 ;; Call this op-extend.
4109 (define_split
4110   [(set (match_operand 0 "register_operand" "")
4111         (match_operator
4112          3 "cris_orthogonal_operator"
4113          [(match_operand 1 "register_operand" "")
4114           (match_operand 2 "memory_operand" "")]))]
4115   "REG_P (operands[0])
4116    && REG_P (operands[1])
4117    && REGNO (operands[1]) != REGNO (operands[0])
4118    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4119    && REG_P (XEXP (operands[2], 0))
4120    && REGNO (XEXP (operands[2], 0)) != REGNO (operands[0])"
4121   [(set (match_dup 0)
4122         (match_dup 1))
4123    (set (match_dup 0)
4124         (match_op_dup
4125          3 [(match_dup 0)
4126             (match_dup 2)]))]
4127   "")
4129 ;; As op-extend-split-rx=rz, non-extended.
4130 ;; Call this op-split-rx=rz
4132 (define_split
4133   [(set (match_operand 0 "register_operand" "")
4134         (match_operator
4135          3 "cris_commutative_orth_op"
4136          [(match_operand 2 "memory_operand" "")
4137           (match_operand 1 "register_operand" "")]))]
4138   "REG_P (operands[0])
4139    && REG_P (operands[1])
4140    && REGNO (operands[1]) != REGNO (operands[0])
4141    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4142    && REG_P (XEXP (operands[2], 0))
4143    && REGNO (XEXP (operands[2], 0)) != REGNO (operands[0])"
4144   [(set (match_dup 0)
4145         (match_dup 1))
4146    (set (match_dup 0)
4147         (match_op_dup
4148          3 [(match_dup 0)
4149             (match_dup 2)]))]
4150   "")
4152 ;; As op-extend-split-swapped, nonextended.
4153 ;; Call this op-split-swapped.
4155 (define_split
4156   [(set (match_operand 0 "register_operand" "")
4157         (match_operator
4158          3 "cris_commutative_orth_op"
4159          [(match_operand 1 "register_operand" "")
4160           (match_operand 2 "memory_operand" "")]))]
4161   "REG_P (operands[0]) && REG_P (operands[1])
4162    && REGNO (operands[1]) != REGNO (operands[0])
4163    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4164    && REG_P (XEXP (operands[2], 0))
4165    && REGNO (XEXP (operands[2], 0)) == REGNO (operands[0])"
4166   [(set (match_dup 0)
4167         (match_dup 2))
4168    (set (match_dup 0)
4169         (match_op_dup
4170          3 [(match_dup 0)
4171             (match_dup 1)]))]
4172   "")
4174 ;; As op-extend-split-swapped-rx=rz, non-extended.
4175 ;; Call this op-split-swapped-rx=rz.
4177 (define_split
4178   [(set (match_operand 0 "register_operand" "")
4179         (match_operator
4180          3 "cris_orthogonal_operator"
4181          [(match_operand 2 "memory_operand" "")
4182           (match_operand 1 "register_operand" "")]))]
4183   "REG_P (operands[0]) && REG_P (operands[1])
4184    && REGNO (operands[1]) != REGNO (operands[0])
4185    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4186    && REG_P (XEXP (operands[2], 0))
4187    && REGNO (XEXP (operands[2], 0)) == REGNO (operands[0])"
4188   [(set (match_dup 0)
4189         (match_dup 2))
4190    (set (match_dup 0)
4191         (match_op_dup
4192          3 [(match_dup 0)
4193             (match_dup 1)]))]
4194   "")
4196 ;; Splits for all cases in side-effect insns where (possibly after reload
4197 ;; and register allocation) rx and ry in [rx=ry+i] are equal.
4199 ;; move.S1 [rx=rx+rz.S2],ry
4201 (define_split
4202   [(parallel
4203     [(set (match_operand 0 "register_operand" "")
4204            (mem (plus:SI
4205                  (mult:SI (match_operand:SI 1 "register_operand" "")
4206                           (match_operand:SI 2 "const_int_operand" ""))
4207                  (match_operand:SI 3 "register_operand" ""))))
4208      (set (match_operand:SI 4 "register_operand" "")
4209            (plus:SI (mult:SI (match_dup 1)
4210                              (match_dup 2))
4211                     (match_dup 3)))])]
4212   "REG_P (operands[3]) && REG_P (operands[4])
4213    && REGNO (operands[3]) == REGNO (operands[4])"
4214   [(set (match_dup 4) (plus:SI (mult:SI (match_dup 1) (match_dup 2))
4215                                 (match_dup 3)))
4216    (set (match_dup 0) (match_dup 5))]
4217   "operands[5] = gen_rtx_MEM (GET_MODE (operands[0]), operands[3]);")
4219 ;; move.S1 [rx=rx+i],ry
4221 (define_split
4222   [(parallel
4223     [(set (match_operand 0 "register_operand" "")
4224            (mem
4225             (plus:SI (match_operand:SI 1 "cris_bdap_operand" "")
4226                      (match_operand:SI 2 "cris_bdap_operand" ""))))
4227      (set (match_operand:SI 3 "register_operand" "")
4228            (plus:SI (match_dup 1)
4229                     (match_dup 2)))])]
4230   "(rtx_equal_p (operands[3], operands[1])
4231     || rtx_equal_p (operands[3], operands[2]))"
4232   [(set (match_dup 3) (plus:SI (match_dup 1) (match_dup 2)))
4233    (set (match_dup 0) (match_dup 4))]
4234   "operands[4] = gen_rtx_MEM (GET_MODE (operands[0]), operands[3]);")
4236 ;; move.S1 ry,[rx=rx+rz.S2]
4238 (define_split
4239   [(parallel
4240     [(set (mem (plus:SI
4241                  (mult:SI (match_operand:SI 0 "register_operand" "")
4242                           (match_operand:SI 1 "const_int_operand" ""))
4243                  (match_operand:SI 2 "register_operand" "")))
4244            (match_operand 3 "register_operand" ""))
4245      (set (match_operand:SI 4 "register_operand" "")
4246            (plus:SI (mult:SI (match_dup 0)
4247                              (match_dup 1))
4248                     (match_dup 2)))])]
4249   "REG_P (operands[2]) && REG_P (operands[4])
4250    && REGNO (operands[4]) == REGNO (operands[2])"
4251   [(set (match_dup 4) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
4252                                 (match_dup 2)))
4253    (set (match_dup 5) (match_dup 3))]
4254   "operands[5] = gen_rtx_MEM (GET_MODE (operands[3]), operands[4]);")
4256 ;; move.S1 ry,[rx=rx+i]
4258 (define_split
4259   [(parallel
4260     [(set (mem
4261            (plus:SI (match_operand:SI 0 "cris_bdap_operand" "")
4262                     (match_operand:SI 1 "cris_bdap_operand" "")))
4263            (match_operand 2 "register_operand" ""))
4264      (set (match_operand:SI 3 "register_operand" "")
4265            (plus:SI (match_dup 0)
4266                    (match_dup 1)))])]
4267   "(rtx_equal_p (operands[3], operands[0])
4268     || rtx_equal_p (operands[3], operands[1]))"
4269   [(set (match_dup 3) (plus:SI (match_dup 0) (match_dup 1)))
4270    (set (match_dup 5) (match_dup 2))]
4271   "operands[5] = gen_rtx_MEM (GET_MODE (operands[2]), operands[3]);")
4273 ;; clear.d [rx=rx+rz.S2]
4275 (define_split
4276   [(parallel
4277     [(set (mem:SI (plus:SI
4278                     (mult:SI (match_operand:SI 0 "register_operand" "")
4279                              (match_operand:SI 1 "const_int_operand" ""))
4280                     (match_operand:SI 2 "register_operand" "")))
4281            (const_int 0))
4282      (set (match_operand:SI 3 "register_operand" "")
4283            (plus:SI (mult:SI (match_dup 0)
4284                              (match_dup 1))
4285                     (match_dup 2)))])]
4286   "REG_P (operands[2]) && REG_P (operands[3])
4287    && REGNO (operands[3]) == REGNO (operands[2])"
4288   [(set (match_dup 3) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
4289                                 (match_dup 2)))
4290    (set (mem:SI (match_dup 3)) (const_int 0))]
4291   "")
4293 ;; clear.w [rx=rx+rz.S2]
4295 (define_split
4296   [(parallel
4297     [(set (mem:HI (plus:SI
4298                     (mult:SI (match_operand:SI 0 "register_operand" "")
4299                              (match_operand:SI 1 "const_int_operand" ""))
4300                     (match_operand:SI 2 "register_operand" "")))
4301            (const_int 0))
4302      (set (match_operand:SI 3 "register_operand" "")
4303            (plus:SI (mult:SI (match_dup 0)
4304                              (match_dup 1))
4305                     (match_dup 2)))])]
4306   "REG_P (operands[2]) && REG_P (operands[3])
4307    && REGNO (operands[3]) == REGNO (operands[2])"
4308   [(set (match_dup 3) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
4309                                 (match_dup 2)))
4310    (set (mem:HI (match_dup 3)) (const_int 0))]
4311   "")
4313 ;; clear.b [rx=rx+rz.S2]
4315 (define_split
4316   [(parallel
4317     [(set (mem:QI (plus:SI
4318                     (mult:SI (match_operand:SI 0 "register_operand" "")
4319                              (match_operand:SI 1 "const_int_operand" ""))
4320                     (match_operand:SI 2 "register_operand" "")))
4321            (const_int 0))
4322      (set (match_operand:SI 3 "register_operand" "")
4323            (plus:SI (mult:SI (match_dup 0)
4324                              (match_dup 1))
4325                     (match_dup 2)))])]
4326   "REG_P (operands[2]) && REG_P (operands[3])
4327    && REGNO (operands[3]) == REGNO (operands[2])"
4328   [(set (match_dup 3) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
4329                                 (match_dup 2)))
4330    (set (mem:QI (match_dup 3)) (const_int 0))]
4331   "")
4333 ;; clear.d [rx=rx+i]
4335 (define_split
4336   [(parallel
4337     [(set (mem:SI
4338            (plus:SI (match_operand:SI 0 "cris_bdap_operand" "")
4339                     (match_operand:SI 1 "cris_bdap_operand" "")))
4340            (const_int 0))
4341      (set (match_operand:SI 2 "register_operand" "")
4342            (plus:SI (match_dup 0)
4343                     (match_dup 1)))])]
4344   "(rtx_equal_p (operands[0], operands[2])
4345     || rtx_equal_p (operands[2], operands[1]))"
4346   [(set (match_dup 2) (plus:SI (match_dup 0) (match_dup 1)))
4347    (set (mem:SI (match_dup 2)) (const_int 0))]
4348   "")
4350 ;; clear.w [rx=rx+i]
4352 (define_split
4353   [(parallel
4354     [(set (mem:HI
4355            (plus:SI (match_operand:SI 0 "cris_bdap_operand" "")
4356                     (match_operand:SI 1 "cris_bdap_operand" "")))
4357            (const_int 0))
4358      (set (match_operand:SI 2 "register_operand" "")
4359            (plus:SI (match_dup 0)
4360                     (match_dup 1)))])]
4361   "(rtx_equal_p (operands[0], operands[2])
4362     || rtx_equal_p (operands[2], operands[1]))"
4363   [(set (match_dup 2) (plus:SI (match_dup 0) (match_dup 1)))
4364    (set (mem:HI (match_dup 2)) (const_int 0))]
4365   "")
4367 ;; clear.b [rx=rx+i]
4369 (define_split
4370   [(parallel
4371     [(set (mem:QI
4372            (plus:SI (match_operand:SI 0 "cris_bdap_operand" "")
4373                     (match_operand:SI 1 "cris_bdap_operand" "")))
4374            (const_int 0))
4375      (set (match_operand:SI 2 "register_operand" "")
4376            (plus:SI (match_dup 0)
4377                     (match_dup 1)))])]
4378   "(rtx_equal_p (operands[0], operands[2])
4379     || rtx_equal_p (operands[2], operands[1]))"
4380   [(set (match_dup 2) (plus:SI (match_dup 0) (match_dup 1)))
4381    (set (mem:QI (match_dup 2)) (const_int 0))]
4382   "")
4384 ;; mov(s|u).S1 [rx=rx+rz.S2],ry
4386 (define_split
4387   [(parallel
4388     [(set (match_operand 0 "register_operand" "")
4389           (match_operator
4390             5 "cris_extend_operator"
4391             [(mem (plus:SI
4392                    (mult:SI (match_operand:SI 1 "register_operand" "")
4393                             (match_operand:SI 2 "const_int_operand" ""))
4394                    (match_operand:SI 3 "register_operand" "")))]))
4395      (set (match_operand:SI 4 "register_operand" "")
4396            (plus:SI (mult:SI (match_dup 1)
4397                              (match_dup 2))
4398                     (match_dup 3)))])]
4399   "REG_P (operands[3])
4400    && REG_P (operands[4])
4401    && REGNO (operands[3]) == REGNO (operands[4])"
4402   [(set (match_dup 4) (plus:SI (mult:SI (match_dup 1) (match_dup 2))
4403                                 (match_dup 3)))
4404    (set (match_dup 0) (match_op_dup 5 [(match_dup 6)]))]
4405   "operands[6] = gen_rtx_MEM (GET_MODE (XEXP (operands[5],0)),
4406                            operands[4]);")
4408 ;; mov(s|u).S1 [rx=rx+i],ry
4410 (define_split
4411   [(parallel
4412     [(set (match_operand 0 "register_operand" "")
4413           (match_operator
4414             4 "cris_extend_operator"
4415             [(mem (plus:SI
4416                    (match_operand:SI 1 "cris_bdap_operand" "")
4417                    (match_operand:SI 2 "cris_bdap_operand" "")))]))
4418      (set (match_operand:SI 3 "register_operand" "")
4419            (plus:SI (match_dup 1)
4420                     (match_dup 2)))])]
4421   "(rtx_equal_p (operands[1], operands[3])
4422     || rtx_equal_p (operands[2], operands[3]))"
4423   [(set (match_dup 3) (plus:SI (match_dup 1) (match_dup 2)))
4424    (set (match_dup 0) (match_op_dup 4 [(match_dup 5)]))]
4425   "operands[5] = gen_rtx_MEM (GET_MODE (XEXP (operands[4], 0)),
4426                           operands[3]);")
4428 ;; op.S1 [rx=rx+i],ry
4430 (define_split
4431   [(parallel
4432     [(set (match_operand 0 "register_operand" "")
4433           (match_operator
4434             5 "cris_orthogonal_operator"
4435             [(match_operand 1 "register_operand" "")
4436              (mem (plus:SI
4437                    (match_operand:SI 2 "cris_bdap_operand" "")
4438                    (match_operand:SI 3 "cris_bdap_operand" "")))]))
4439      (set (match_operand:SI 4 "register_operand" "")
4440            (plus:SI (match_dup 2)
4441                     (match_dup 3)))])]
4442   "(rtx_equal_p (operands[4], operands[2])
4443     || rtx_equal_p (operands[4], operands[3]))"
4444   [(set (match_dup 4) (plus:SI (match_dup 2) (match_dup 3)))
4445    (set (match_dup 0) (match_op_dup 5 [(match_dup 1) (match_dup 6)]))]
4446   "operands[6] = gen_rtx_MEM (GET_MODE (operands[0]), operands[4]);")
4448 ;; op.S1 [rx=rx+rz.S2],ry
4450 (define_split
4451   [(parallel
4452     [(set (match_operand 0 "register_operand" "")
4453           (match_operator
4454             6 "cris_orthogonal_operator"
4455             [(match_operand 1 "register_operand" "")
4456              (mem (plus:SI
4457                    (mult:SI (match_operand:SI 2 "register_operand" "")
4458                             (match_operand:SI 3 "const_int_operand" ""))
4459                    (match_operand:SI 4 "register_operand" "")))]))
4460      (set (match_operand:SI 5 "register_operand" "")
4461            (plus:SI (mult:SI (match_dup 2)
4462                              (match_dup 3))
4463                    (match_dup 4)))])]
4464   "REG_P (operands[4])
4465    && REG_P (operands[5])
4466    && REGNO (operands[5]) == REGNO (operands[4])"
4467   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 2) (match_dup 3))
4468                                 (match_dup 4)))
4469    (set (match_dup 0) (match_op_dup 6 [(match_dup 1) (match_dup 7)]))]
4470   "operands[7] = gen_rtx_MEM (GET_MODE (operands[0]), operands[5]);")
4472 ;; op.S1 [rx=rx+rz.S2],ry (swapped)
4474 (define_split
4475   [(parallel
4476     [(set (match_operand 0 "register_operand" "")
4477           (match_operator
4478             6 "cris_commutative_orth_op"
4479             [(mem (plus:SI
4480                    (mult:SI (match_operand:SI 2 "register_operand" "")
4481                             (match_operand:SI 3 "const_int_operand" ""))
4482                    (match_operand:SI 4 "register_operand" "")))
4483              (match_operand 1 "register_operand" "")]))
4484      (set (match_operand:SI 5 "register_operand" "")
4485            (plus:SI (mult:SI (match_dup 2)
4486                              (match_dup 3))
4487                     (match_dup 4)))])]
4488   "REG_P (operands[4])
4489    && REG_P (operands[5])
4490    && REGNO (operands[5]) == REGNO (operands[4])"
4491   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 2) (match_dup 3))
4492                                (match_dup 4)))
4493    (set (match_dup 0) (match_op_dup 6 [(match_dup 7) (match_dup 1)]))]
4494   "operands[7] = gen_rtx_MEM (GET_MODE (operands[0]), operands[5]);")
4496 ;; op.S1 [rx=rx+i],ry (swapped)
4498 (define_split
4499   [(parallel
4500     [(set (match_operand 0 "register_operand" "")
4501           (match_operator
4502             5 "cris_commutative_orth_op"
4503             [(mem
4504               (plus:SI (match_operand:SI 2 "cris_bdap_operand" "")
4505                        (match_operand:SI 3 "cris_bdap_operand" "")))
4506              (match_operand 1 "register_operand" "")]))
4507      (set (match_operand:SI 4 "register_operand" "")
4508           (plus:SI (match_dup 2)
4509                     (match_dup 3)))])]
4510   "(rtx_equal_p (operands[4], operands[2])
4511     || rtx_equal_p (operands[4], operands[3]))"
4512   [(set (match_dup 4) (plus:SI (match_dup 2) (match_dup 3)))
4513    (set (match_dup 0) (match_op_dup 5 [(match_dup 6) (match_dup 1)]))]
4514   "operands[6] = gen_rtx_MEM (GET_MODE (operands[0]), operands[4]);")
4516 ;; op(s|u).S1 [rx=rx+rz.S2],ry
4518 (define_split
4519   [(parallel
4520     [(set (match_operand 0 "register_operand" "")
4521           (match_operator
4522             6 "cris_operand_extend_operator"
4523             [(match_operand 1 "register_operand" "")
4524              (match_operator
4525               7 "cris_extend_operator"
4526               [(mem (plus:SI
4527                      (mult:SI (match_operand:SI 2 "register_operand" "")
4528                               (match_operand:SI 3 "const_int_operand" ""))
4529                      (match_operand:SI 4 "register_operand" "")))])]))
4530      (set (match_operand:SI 5 "register_operand" "")
4531            (plus:SI (mult:SI (match_dup 2)
4532                              (match_dup 3))
4533                     (match_dup 4)))])]
4534   "REG_P (operands[4])
4535    && REG_P (operands[5])
4536    && REGNO (operands[5]) == REGNO (operands[4])"
4537   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 2) (match_dup 3))
4538                                (match_dup 4)))
4539    (set (match_dup 0) (match_op_dup 6 [(match_dup 1) (match_dup 8)]))]
4540   "operands[8] = gen_rtx (GET_CODE (operands[7]), GET_MODE (operands[7]),
4541                           gen_rtx_MEM (GET_MODE (XEXP (operands[7], 0)),
4542                                    operands[5]));")
4544 ;; op(s|u).S1 [rx=rx+i],ry
4546 (define_split
4547   [(parallel
4548     [(set (match_operand 0 "register_operand" "")
4549           (match_operator
4550             5 "cris_operand_extend_operator"
4551             [(match_operand 1 "register_operand" "")
4552              (match_operator
4553               6 "cris_extend_operator"
4554               [(mem
4555                 (plus:SI (match_operand:SI 2 "cris_bdap_operand" "")
4556                          (match_operand:SI 3 "cris_bdap_operand" "")
4557                          ))])]))
4558      (set (match_operand:SI 4 "register_operand" "")
4559            (plus:SI (match_dup 2)
4560                     (match_dup 3)))])]
4561   "(rtx_equal_p (operands[4], operands[2])
4562     || rtx_equal_p (operands[4], operands[3]))"
4563   [(set (match_dup 4) (plus:SI (match_dup 2) (match_dup 3)))
4564    (set (match_dup 0) (match_op_dup 5 [(match_dup 1) (match_dup 7)]))]
4565   "operands[7] = gen_rtx (GET_CODE (operands[6]), GET_MODE (operands[6]),
4566                            gen_rtx_MEM (GET_MODE (XEXP (operands[6], 0)),
4567                                     operands[4]));")
4569 ;; op(s|u).S1 [rx=rx+rz.S2],ry (swapped, plus or bound)
4571 (define_split
4572   [(parallel
4573     [(set (match_operand 0 "register_operand" "")
4574           (match_operator
4575             7 "cris_plus_or_bound_operator"
4576             [(match_operator
4577               6 "cris_extend_operator"
4578               [(mem (plus:SI
4579                      (mult:SI (match_operand:SI 2 "register_operand" "")
4580                               (match_operand:SI 3 "const_int_operand" ""))
4581                      (match_operand:SI 4 "register_operand" "")))])
4582              (match_operand 1 "register_operand" "")]))
4583      (set (match_operand:SI 5 "register_operand" "")
4584            (plus:SI (mult:SI (match_dup 2)
4585                              (match_dup 3))
4586                     (match_dup 4)))])]
4587   "REG_P (operands[4]) && REG_P (operands[5])
4588    && REGNO (operands[5]) == REGNO (operands[4])"
4589   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 2) (match_dup 3))
4590                                (match_dup 4)))
4591    (set (match_dup 0) (match_op_dup 6 [(match_dup 8) (match_dup 1)]))]
4592   "operands[8] = gen_rtx (GET_CODE (operands[6]), GET_MODE (operands[6]),
4593                           gen_rtx_MEM (GET_MODE (XEXP (operands[6], 0)),
4594                                    operands[5]));")
4596 ;; op(s|u).S1 [rx=rx+i],ry (swapped, plus or bound)
4598 (define_split
4599   [(parallel
4600     [(set (match_operand 0 "register_operand" "")
4601           (match_operator
4602             6 "cris_plus_or_bound_operator"
4603             [(match_operator
4604               5 "cris_extend_operator"
4605              [(mem (plus:SI
4606                     (match_operand:SI 2 "cris_bdap_operand" "")
4607                     (match_operand:SI 3 "cris_bdap_operand" "")))])
4608              (match_operand 1 "register_operand" "")]))
4609      (set (match_operand:SI 4 "register_operand" "")
4610            (plus:SI (match_dup 2)
4611                     (match_dup 3)))])]
4612   "(rtx_equal_p (operands[4], operands[2])
4613     || rtx_equal_p (operands[4], operands[3]))"
4614   [(set (match_dup 4) (plus:SI (match_dup 2) (match_dup 3)))
4615    (set (match_dup 0) (match_op_dup 6 [(match_dup 7) (match_dup 1)]))]
4616   "operands[7] = gen_rtx (GET_CODE (operands[5]), GET_MODE (operands[5]),
4617                           gen_rtx_MEM (GET_MODE (XEXP (operands[5], 0)),
4618                                    operands[4]));")
4620 ;; Splits for addressing prefixes that have no side-effects, so we can
4621 ;; fill a delay slot.  Never split if we lose something, though.
4623 ;; If we have a
4624 ;;  move [indirect_ref],rx
4625 ;; where indirect ref = {const, [r+], [r]}, it costs as much as
4626 ;;  move indirect_ref,rx
4627 ;;  move [rx],rx
4628 ;; Take care not to allow indirect_ref = register.
4630 ;; We're not allowed to generate copies of registers with different mode
4631 ;; until after reload; copying pseudos upsets reload.  CVS as of
4632 ;; 2001-08-24, unwind-dw2-fde.c, _Unwind_Find_FDE ICE in
4633 ;; cselib_invalidate_regno.
4635 (define_split
4636   [(set (match_operand 0 "register_operand" "")
4637         (match_operand 1 "indirect_operand" ""))]
4638   "reload_completed
4639    && REG_P (operands[0])
4640    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4641    && (GET_CODE (XEXP (operands[1], 0)) == MEM
4642        || CONSTANT_P (XEXP (operands[1], 0)))"
4643   [(set (match_dup 2) (match_dup 4))
4644    (set (match_dup 0) (match_dup 3))]
4645   "operands[2] = gen_rtx_REG (Pmode, REGNO (operands[0]));
4646    operands[3] = gen_rtx_MEM (GET_MODE (operands[0]), operands[2]);
4647    operands[4] = XEXP (operands[1], 0);")
4649 ;; As the above, but MOVS and MOVU.
4651 (define_split
4652   [(set (match_operand 0 "register_operand" "")
4653         (match_operator
4654          4 "cris_extend_operator"
4655          [(match_operand 1 "indirect_operand" "")]))]
4656   "reload_completed
4657    && REG_P (operands[0])
4658    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4659    && (GET_CODE (XEXP (operands[1], 0)) == MEM
4660        || CONSTANT_P (XEXP (operands[1], 0)))"
4661   [(set (match_dup 2) (match_dup 5))
4662    (set (match_dup 0) (match_op_dup 4 [(match_dup 3)]))]
4663   "operands[2] = gen_rtx_REG (Pmode, REGNO (operands[0]));
4664    operands[3] = gen_rtx_MEM (GET_MODE (XEXP (operands[4], 0)), operands[2]);
4665    operands[5] = XEXP (operands[1], 0);")
4667 ;; Various peephole optimizations.
4669 ;; Watch out: when you exchange one set of instructions for another, the
4670 ;; condition codes setting must be the same, or you have to CC_INIT or
4671 ;; whatever is appropriate, in the pattern before you emit the
4672 ;; assembly text.  This is best done here, not in cris_notice_update_cc,
4673 ;; to keep changes local to their cause.
4675 ;; Do not add patterns that you do not know will be matched.
4676 ;; Please also add a self-contained test-case.
4678 ;; We have trouble with and:s and shifts.  Maybe something is broken in
4679 ;; gcc?  Or it could just be that bit-field insn expansion is a bit
4680 ;; suboptimal when not having extzv insns.
4682 (define_peephole
4683   [(set (match_operand 0 "register_operand" "=r")
4684         (ashiftrt:SI (match_dup 0)
4685                      (match_operand:SI 1 "const_int_operand" "n")))
4686    (set (match_dup 0)
4687         (and:SI (match_dup 0)
4688                 (match_operand 2 "const_int_operand" "n")))]
4689   "INTVAL (operands[2]) > 31
4690    && INTVAL (operands[2]) < 255
4691    && INTVAL (operands[1]) > 23"
4693 ;; The m flag should be ignored, because this will be a *byte* "and"
4694 ;; operation.
4696   "*
4698   cc_status.flags |= CC_NOT_NEGATIVE;
4700   return \"lsrq %1,%0\;and.b %2,%0\";
4703 (define_peephole
4704   [(set (match_operand 0 "register_operand" "=r")
4705         (ashiftrt:SI (match_dup 0)
4706                      (match_operand:SI 1 "const_int_operand" "n")))
4707    (set (match_dup 0)
4708         (and:SI (match_dup 0)
4709                 (match_operand 2 "const_int_operand" "n")))]
4710   "INTVAL (operands[2]) > 31
4711    && INTVAL (operands[2]) < 65535
4712    && INTVAL (operands[2]) != 255
4713    && INTVAL (operands[1]) > 15"
4715 ;; The m flag should be ignored, because this will be a *word* "and"
4716 ;; operation.
4718   "*
4720   cc_status.flags |= CC_NOT_NEGATIVE;
4722   return \"lsrq %1,%0\;and.w %2,%0\";
4725 (define_peephole
4726   [(set (match_operand 0 "register_operand" "=r")
4727         (lshiftrt:SI (match_dup 0)
4728                      (match_operand:SI 1 "const_int_operand" "n")))
4729    (set (match_dup 0)
4730         (and:SI (match_dup 0)
4731                 (match_operand 2 "const_int_operand" "n")))]
4732   "INTVAL (operands[2]) > 31
4733    && INTVAL (operands[2]) < 255
4734    && INTVAL (operands[1]) > 23"
4736 ;; The m flag should be ignored, because this will be a *byte* "and"
4737 ;; operation.
4739   "*
4741   cc_status.flags |= CC_NOT_NEGATIVE;
4743   return \"lsrq %1,%0\;and.b %2,%0\";
4746 (define_peephole
4747   [(set (match_operand 0 "register_operand" "=r")
4748         (lshiftrt:SI (match_dup 0)
4749                      (match_operand:SI 1 "const_int_operand" "n")))
4750    (set (match_dup 0)
4751         (and:SI (match_dup 0)
4752                 (match_operand 2 "const_int_operand" "n")))]
4753   "INTVAL (operands[2]) > 31 && INTVAL (operands[2]) < 65535
4754    && INTVAL (operands[2]) != 255
4755    && INTVAL (operands[1]) > 15"
4757 ;; The m flag should be ignored, because this will be a *word* "and"
4758 ;; operation.
4760   "*
4762   cc_status.flags |= CC_NOT_NEGATIVE;
4764   return \"lsrq %1,%0\;and.w %2,%0\";
4768 ;; Change
4769 ;;  add.d n,rx
4770 ;;  move [rx],ry
4771 ;; into
4772 ;;  move [rx=rx+n],ry
4773 ;; when -128 <= n <= 127.
4774 ;; This will reduce the size of the assembler code for n = [-128..127],
4775 ;; and speed up accordingly.
4777 (define_peephole
4778   [(set (match_operand:SI 0 "register_operand" "=r")
4779         (plus:SI (match_operand:SI 1 "register_operand" "0")
4780                  (match_operand:SI 2 "const_int_operand" "n")))
4781    (set (match_operand 3 "register_operand" "=r")
4782         (mem (match_dup 0)))]
4783   "GET_MODE (operands[3]) != DImode
4784     && REGNO (operands[3]) != REGNO (operands[0])
4785     && (BASE_P (operands[1]) || BASE_P (operands[2]))
4786     && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')
4787     && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
4788     && (INTVAL (operands[2]) >= -128 && INTVAL (operands[2]) < 128)"
4789   "move.%s3 [%0=%1%S2],%3")
4791 ;; Vice versa: move ry,[rx=rx+n]
4793 (define_peephole
4794   [(set (match_operand:SI 0 "register_operand" "=r")
4795         (plus:SI (match_operand:SI 1 "register_operand" "0")
4796                  (match_operand:SI 2 "const_int_operand" "n")))
4797    (set (mem (match_dup 0))
4798         (match_operand 3 "register_operand" "=r"))]
4799   "GET_MODE (operands[3]) != DImode
4800     && REGNO (operands[3]) != REGNO (operands[0])
4801     && (BASE_P (operands[1]) || BASE_P (operands[2]))
4802     && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')
4803     && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
4804     && (INTVAL (operands[2]) >= -128 && INTVAL (operands[2]) < 128)"
4805   "move.%s3 %3,[%0=%1%S2]"
4806   [(set_attr "cc" "none")])
4808 ;; As above, change:
4809 ;;  add.d n,rx
4810 ;;  op.d [rx],ry
4811 ;; into:
4812 ;;  op.d [rx=rx+n],ry
4813 ;; Saves when n = [-128..127].
4815 ;; Splitting and joining combinations for side-effect modes are slightly
4816 ;; out of hand.  They probably will not save the time they take typing in,
4817 ;; not to mention the bugs that creep in.  FIXME: Get rid of as many of
4818 ;; the splits and peepholes as possible.
4820 (define_peephole
4821   [(set (match_operand:SI 0 "register_operand" "=r")
4822         (plus:SI (match_operand:SI 1 "register_operand" "0")
4823                  (match_operand:SI 2 "const_int_operand" "n")))
4824    (set (match_operand 3 "register_operand" "=r")
4825         (match_operator 4 "cris_orthogonal_operator"
4826                            [(match_dup 3)
4827                             (mem (match_dup 0))]))]
4828   "GET_MODE (operands[3]) != DImode
4829     && REGNO (operands[0]) != REGNO (operands[3])
4830     && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')
4831     && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
4832     && INTVAL (operands[2]) >= -128
4833     && INTVAL (operands[2]) <= 127"
4834   "%x4.%s3 [%0=%1%S2],%3")
4836 ;; Sometimes, for some reason the pattern
4837 ;;  move x,rx
4838 ;;  add y,rx
4839 ;;  move [rx],rz
4840 ;; will occur.  Solve this, and likewise for to-memory.
4842 (define_peephole
4843   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
4844         (match_operand:SI 1 "cris_bdap_biap_operand" "r,>Ri,r,>Ri"))
4845    (set (match_dup 0)
4846         (plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Ri,r")
4847                  (match_operand:SI 3 "cris_bdap_biap_operand" "r>Ri,r,0,0")))
4848    (set (match_operand 4 "register_operand" "=r,r,r,r")
4849         (mem (match_dup 0)))]
4850   "(rtx_equal_p (operands[2], operands[0])
4851     || rtx_equal_p (operands[3], operands[0]))
4852    && cris_side_effect_mode_ok (PLUS, operands, 0,
4853                                 (REG_S_P (operands[1])
4854                                  ? 1
4855                                  : (rtx_equal_p (operands[2], operands[0])
4856                                     ? 3 : 2)),
4857                                 (! REG_S_P (operands[1])
4858                                  ? 1
4859                                  : (rtx_equal_p (operands[2], operands[0])
4860                                     ? 3 : 2)),
4861                                 -1, 4)"
4862   "@
4863    move.%s4 [%0=%1%S3],%4
4864    move.%s4 [%0=%3%S1],%4
4865    move.%s4 [%0=%1%S2],%4
4866    move.%s4 [%0=%2%S1],%4")
4868 ;; As above but to memory.
4870 (define_peephole
4871   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
4872         (match_operand:SI 1 "cris_bdap_biap_operand" "r,>Ri,r,>Ri"))
4873    (set (match_dup 0)
4874         (plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Ri,r")
4875                  (match_operand:SI 3 "cris_bdap_biap_operand" "r>Ri,r,0,0")))
4876    (set (mem (match_dup 0))
4877         (match_operand 4 "register_operand" "=r,r,r,r"))]
4878   "(rtx_equal_p (operands[2], operands[0])
4879     || rtx_equal_p (operands[3], operands[0]))
4880    && cris_side_effect_mode_ok (PLUS, operands, 0,
4881                                 (REG_S_P (operands[1])
4882                                  ? 1
4883                                  : (rtx_equal_p (operands[2], operands[0])
4884                                     ? 3 : 2)),
4885                                 (! REG_S_P (operands[1])
4886                                    ? 1
4887                                  : (rtx_equal_p (operands[2], operands[0])
4888                                     ? 3 : 2)),
4889                                 -1, 4)"
4890   "@
4891    move.%s4 %4,[%0=%1%S3]
4892    move.%s4 %4,[%0=%3%S1]
4893    move.%s4 %4,[%0=%1%S2]
4894    move.%s4 %4,[%0=%2%S1]"
4895   [(set_attr "cc" "none")])
4898 ;; As the move from-memory above, but with an operation.
4900 (define_peephole
4901   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
4902         (match_operand:SI 1 "cris_bdap_biap_operand" "r,>Ri,r,>Ri"))
4903    (set (match_dup 0)
4904         (plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Ri,r")
4905                  (match_operand:SI 3 "cris_bdap_biap_operand" "r>Ri,r,0,0")))
4906    (set (match_operand 4 "register_operand" "=r,r,r,r")
4907         (match_operator 5 "cris_orthogonal_operator"
4908                         [(match_dup 3)
4909                          (mem (match_dup 0))]))]
4910   "(rtx_equal_p (operands[2], operands[0])
4911     || rtx_equal_p (operands[3], operands[0]))
4912    && cris_side_effect_mode_ok (PLUS, operands, 0,
4913                                 (REG_S_P (operands[1])
4914                                  ? 1
4915                                  : (rtx_equal_p (operands[2], operands[0])
4916                                     ? 3 : 2)),
4917                                 (! REG_S_P (operands[1])
4918                                  ? 1
4919                                  : (rtx_equal_p (operands[2], operands[0])
4920                                     ? 3 : 2)),
4921                                 -1, 4)"
4922   "@
4923    %x5.%s4 [%0=%1%S3],%4
4924    %x5.%s4 [%0=%3%S1],%4
4925    %x5.%s4 [%0=%1%S2],%4
4926    %x5.%s4 [%0=%2%S1],%4")
4928 ;; Same, but with swapped operands (and commutative operation).
4930 (define_peephole
4931   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
4932         (match_operand:SI 1 "cris_bdap_biap_operand" "r,>Ri,r,>Ri"))
4933    (set (match_dup 0)
4934         (plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Ri,r")
4935                  (match_operand:SI 3 "cris_bdap_biap_operand" "r>Ri,r,0,0")))
4936    (set (match_operand 4 "register_operand" "=r,r,r,r")
4937         (match_operator 5 "cris_commutative_orth_op"
4938                         [(mem (match_dup 0))
4939                          (match_dup 3)]))]
4940   "(rtx_equal_p (operands[2], operands[0])
4941     || rtx_equal_p (operands[3], operands[0]))
4942    && cris_side_effect_mode_ok (PLUS, operands, 0,
4943                            (REG_S_P (operands[1])
4944                             ? 1
4945                             : (rtx_equal_p (operands[2], operands[0])
4946                                ? 3 : 2)),
4947                            (! REG_S_P (operands[1])
4948                             ? 1
4949                             : (rtx_equal_p (operands[2], operands[0])
4950                                ? 3 : 2)),
4951                            -1, 4)"
4952   "@
4953    %x5.%s4 [%0=%1%S3],%4
4954    %x5.%s4 [%0=%3%S1],%4
4955    %x5.%s4 [%0=%1%S2],%4
4956    %x5.%s4 [%0=%2%S1],%4")
4958 ;; Another spotted bad code:
4959 ;;   move rx,ry
4960 ;;   move [ry],ry
4962 (define_peephole
4963   [(set (match_operand:SI 0 "register_operand" "=r")
4964         (match_operand:SI 1 "register_operand" "r"))
4965    (set (match_operand 2 "register_operand" "=r")
4966         (mem (match_dup 0)))]
4967   "REGNO (operands[0]) == REGNO (operands[2])
4968    && GET_MODE_SIZE (GET_MODE (operands[2])) <= UNITS_PER_WORD"
4969   "move.%s2 [%1],%0"
4970   [(set_attr "slottable" "yes")])
4972 ;; And a simple variant with extended operand.
4974 (define_peephole
4975   [(set (match_operand:SI 0 "register_operand" "=r")
4976         (match_operand:SI 1 "register_operand" "r"))
4977    (set (match_operand 2 "register_operand" "=r")
4978         (match_operator 3 "cris_extend_operator" [(mem (match_dup 0))]))]
4979   "REGNO (operands[0]) == REGNO (operands[2])
4980    && GET_MODE_SIZE (GET_MODE (operands[2])) <= UNITS_PER_WORD"
4981   "mov%e3.%m3 [%1],%0"
4982   [(set_attr "slottable" "yes")])
4984 ;; Here are all peepholes that have a saved testcase.
4985 ;; Do not add new peepholes without testcases.
4987 ;; peep-1:
4988 ;;   move.d [r10+16],r9
4989 ;;   and.d r12,r9
4990 ;; change to
4991 ;;   and.d [r10+16],r12,r9
4992 ;; With generalization of the operation, the size and the addressing mode.
4993 ;;  This seems to be the result of a quirk in register allocation
4994 ;; missing the three-operand cases when having different predicates.
4995 ;; Maybe that it matters that it is a commutative operation.
4996 ;;  This pattern helps that situation, but there's still the increased
4997 ;; register pressure.
4998 ;;  Note that adding the noncommutative variant did not show any matches
4999 ;; in ipps and cc1, so it's not here.
5001 (define_peephole
5002   [(set (match_operand 0 "register_operand" "=r,r,r,r")
5003         (mem (plus:SI
5004               (match_operand:SI 1 "cris_bdap_biap_operand" "r,r>Ri,r,r>Ri")
5005               (match_operand:SI 2 "cris_bdap_biap_operand" "r>Ri,r,r>Ri,r"))))
5006    (set (match_dup 0)
5007         (match_operator 5 "cris_commutative_orth_op"
5008                         [(match_operand 3 "register_operand" "0,0,r,r")
5009                          (match_operand 4 "register_operand" "r,r,0,0")]))]
5010   "(rtx_equal_p (operands[3], operands[0])
5011     || rtx_equal_p (operands[4], operands[0]))
5012    && ! rtx_equal_p (operands[3], operands[4])
5013    && (REG_S_P (operands[1]) || REG_S_P (operands[2]))
5014    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD"
5015   "@
5016    %x5.%s0 [%1%S2],%4,%0
5017    %x5.%s0 [%2%S1],%4,%0
5018    %x5.%s0 [%1%S2],%3,%0
5019    %x5.%s0 [%2%S1],%3,%0")
5021 ;; peep-2:
5022 ;;  I cannot tell GCC (2.1, 2.7.2) how to correctly reload an instruction
5023 ;; that looks like
5024 ;;   and.b some_byte,const,reg_32
5025 ;; where reg_32 is the destination of the "three-address" code optimally.
5026 ;; It should be:
5027 ;;   movu.b some_byte,reg_32
5028 ;;   and.b const,reg_32
5029 ;; but is turns into:
5030 ;;   move.b some_byte,reg_32
5031 ;;   and.d const,reg_32
5032 ;; Fix it here.
5034 (define_peephole
5035   [(set (match_operand:SI 0 "register_operand" "=r")
5036         (match_operand:SI 1 "nonimmediate_operand" "rm"))
5037    (set (match_operand:SI 2 "register_operand" "=0")
5038         (and:SI (match_dup 0)
5039                 (match_operand:SI 3 "const_int_operand" "n")))]
5041    ;; Since the size of the memory access could be made different here,
5042    ;; don't do this for a mem-volatile access.
5044   "REGNO (operands[2]) == REGNO (operands[0])
5045    && INTVAL (operands[3]) <= 65535 && INTVAL (operands[3]) >= 0
5046    && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'I')
5047    && (GET_CODE (operands[1]) != MEM || ! MEM_VOLATILE_P (operands[1]))"
5048   "*
5050   if (CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'O'))
5051     return \"movu.%z3 %1,%0\;andq %b3,%0\";
5053   cc_status.flags |= CC_NOT_NEGATIVE;
5055   return \"movu.%z3 %1,%0\;and.%z3 %3,%0\";
5058 ;; peep-3
5060 (define_peephole
5061   [(set (match_operand 0 "register_operand" "=r")
5062         (match_operand 1 "nonimmediate_operand" "rm"))
5063    (set (match_operand:SI 2 "register_operand" "=r")
5064         (and:SI (subreg:SI (match_dup 0) 0)
5065                 (match_operand 3 "const_int_operand" "n")))]
5067    ;; Since the size of the memory access could be made different here,
5068    ;; don't do this for a mem-volatile access.
5070   "REGNO (operands[0]) == REGNO (operands[2])
5071    && INTVAL (operands[3]) > 0
5072    && INTVAL (operands[3]) <= 65535
5073    && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'I')
5074    && (GET_CODE (operands[1]) != MEM || ! MEM_VOLATILE_P (operands[1]))"
5075   "*
5077   if (CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'O'))
5078     return \"movu.%z3 %1,%0\;andq %b3,%0\";
5080   cc_status.flags |= CC_NOT_NEGATIVE;
5082   return \"movu.%z3 %1,%0\;and.%z3 %3,%0\";
5085 ;; Local variables:
5086 ;; mode:emacs-lisp
5087 ;; comment-start: ";; "
5088 ;; eval: (set-syntax-table (copy-sequence (syntax-table)))
5089 ;; eval: (modify-syntax-entry ?[ "(]")
5090 ;; eval: (modify-syntax-entry ?] ")[")
5091 ;; eval: (modify-syntax-entry ?{ "(}")
5092 ;; eval: (modify-syntax-entry ?} "){")
5093 ;; eval: (setq indent-tabs-mode t)
5094 ;; End: