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.
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)
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,
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).
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
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
117 (define_delay (eq_attr "slottable" "has_slot")
118 [(eq_attr "slottable" "yes") (nil) (nil)])
124 ;; Allow register and offsettable mem operands only; post-increment is
125 ;; not worth the trouble.
129 (match_operand:DI 0 "nonimmediate_operand" "r,o"))]
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.
142 (match_operand:SI 0 "nonimmediate_operand" "r,Q>,m"))]
145 [(set_attr "slottable" "yes,yes,no")])
149 (match_operand:HI 0 "nonimmediate_operand" "r,Q>,m"))]
152 [(set_attr "slottable" "yes,yes,no")])
156 (match_operand:QI 0 "nonimmediate_operand" "r,Q>,m"))]
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
166 ;; FIXME: Do that some time; check next_cc0_user to determine if
167 ;; zero or negative is tested for.
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.
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")))]
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.
213 (define_insn "*cmp_extsi"
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")])))]
221 [(set_attr "slottable" "yes,no")])
224 (define_insn "*cmp_exthi"
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")])))]
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.
241 (define_insn "*cmp_swapextqi"
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")))]
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")])
254 (define_insn "*cmp_swapexthi"
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")))]
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.
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")))]
284 [(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,no,no,no")])
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")))]
299 [(set_attr "slottable" "yes,yes,yes,yes,no,no,no")])
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")))]
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.
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.
358 [(set_attr "slottable" "yes")])
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" ""))]
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)
398 rtx op0 = operands[0];
399 rtx op1 = operands[1];
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 ();
409 emit_no_conflict_block (insns, op0, op1, 0, op1);
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"
423 [(set (match_operand:DI 0 "nonimmediate_operand" "")
424 (match_operand:DI 1 "general_operand" ""))]
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.
438 (define_insn "*mov_sideqi_biap"
439 [(set (match_operand:QI 0 "register_operand" "=r,r")
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)
448 "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
451 move.%s0 [%4=%3+%1%T2],%0")
455 (define_insn "*mov_sidehi_biap"
456 [(set (match_operand:HI 0 "register_operand" "=r,r")
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)
465 "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
468 move.%s0 [%4=%3+%1%T2],%0")
472 (define_insn "*mov_sidesi_biap"
473 [(set (match_operand:SI 0 "register_operand" "=r,r")
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)
482 "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
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.
495 (define_insn "*mov_sideqi"
496 [(set (match_operand:QI 0 "register_operand" "=r,r,r")
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)
503 "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
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')))
513 return \"move.%s0 [%3=%1%S2],%0\";
518 (define_insn "*mov_sidehi"
519 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
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)
526 "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
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')))
536 return \"move.%s0 [%3=%1%S2],%0\";
541 (define_insn "*mov_sidesi"
542 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
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)
549 "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
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')))
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
579 ;; move.s rz,[ry=rx+rw.S]
580 ;; FIXME: These could have anonymous mode for operand 3.
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)
594 "cris_side_effect_mode_ok (MULT, operands, 4, 2, 0, 1, 3)"
598 move.%s3 %3,[%4=%2+%0%T1]")
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)
612 "cris_side_effect_mode_ok (MULT, operands, 4, 2, 0, 1, 3)"
616 move.%s3 %3,[%4=%2+%0%T1]")
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)
630 "cris_side_effect_mode_ok (MULT, operands, 4, 2, 0, 1, 3)"
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
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)
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))
656 (plus:SI (mult:SI (match_dup 0)
660 = gen_rtx_MEM (GET_MODE (operands[3]),
661 gen_rtx_PLUS (SImode,
662 gen_rtx_MULT (SImode,
663 operands[0], operands[1]),
666 ;; move.s rx,[ry=rz+i]
667 ;; FIXME: These could have anonymous mode for operand 2.
671 (define_insn "*mov_sideqi_mem"
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)
679 "cris_side_effect_mode_ok (PLUS, operands, 3, 0, 1, -1, 2)"
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')))
689 if (which_alternative == 1)
691 return \"move.%s2 %2,[%3=%0%S1]\";
696 (define_insn "*mov_sidehi_mem"
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)
704 "cris_side_effect_mode_ok (PLUS, operands, 3, 0, 1, -1, 2)"
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')))
714 if (which_alternative == 1)
716 return \"move.%s2 %2,[%3=%0%S1]\";
721 (define_insn "*mov_sidesi_mem"
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)
729 "cris_side_effect_mode_ok (PLUS, operands, 3, 0, 1, -1, 2)"
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')))
739 if (which_alternative == 1)
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.
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)))]
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")))
775 (set (match_operand:SI 3 "register_operand" "=*2,r")
776 (plus:SI (mult:SI (match_dup 0)
779 "cris_side_effect_mode_ok (MULT, operands, 3, 2, 0, 1, -1)"
782 clear.d [%3=%2+%0%T1]")
786 (define_insn "*clear_sidesi"
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")))
791 (set (match_operand:SI 2 "register_operand" "=*0,r,r")
792 (plus:SI (match_dup 0)
794 "cris_side_effect_mode_ok (PLUS, operands, 2, 0, 1, -1, -1)"
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')))
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")))
815 (set (match_operand:SI 3 "register_operand" "=*2,r")
816 (plus:SI (mult:SI (match_dup 0)
819 "cris_side_effect_mode_ok (MULT, operands, 3, 2, 0, 1, -1)"
822 clear.w [%3=%2+%0%T1]")
826 (define_insn "*clear_sidehi"
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")))
831 (set (match_operand:SI 2 "register_operand" "=*0,r,r")
832 (plus:SI (match_dup 0)
834 "cris_side_effect_mode_ok (PLUS, operands, 2, 0, 1, -1, -1)"
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')))
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")))
855 (set (match_operand:SI 3 "register_operand" "=*2,r")
856 (plus:SI (mult:SI (match_dup 0)
859 "cris_side_effect_mode_ok (MULT, operands, 3, 2, 0, 1, -1)"
862 clear.b [%3=%2+%0%T1]")
866 (define_insn "*clear_sideqi"
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")))
871 (set (match_operand:SI 2 "register_operand" "=*0,r,r")
872 (plus:SI (match_dup 0)
874 "cris_side_effect_mode_ok (PLUS, operands, 2, 0, 1, -1, -1)"
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')))
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)
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)
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"
915 (match_operand:SI 0 "nonimmediate_operand" "")
916 (match_operand:SI 1 "cris_general_operand_or_symbol" ""))]
920 /* If the output goes to a MEM, make sure we have zero or a register as
922 if (GET_CODE (operands[0]) == MEM
923 && ! REG_S_P (operands[1])
924 && operands[1] != const0_rtx
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
935 && CONSTANT_ADDRESS_P (operands[1])
936 && cris_symbol (operands[1]))
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]))
944 operands[1] = force_reg (SImode, operands[1]);
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]))
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
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)
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])
986 (define_insn "*movsi_internal"
988 (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,Q>,r,Q>,g,r,r,r,g")
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"))]
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)
1006 return \"move.d %1,%0\";
1011 return \"clear.d %0\";
1013 /* Constants -32..31 except 0. */
1015 return \"moveq %1,%0\";
1017 /* We can win a little on constants -32768..-33, 32..65535. */
1019 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) < 65536)
1021 if (INTVAL (operands[1]) < 256)
1022 return \"movu.b %1,%0\";
1023 return \"movu.w %1,%0\";
1025 else if (INTVAL (operands[1]) >= -32768 && INTVAL (operands[1]) < 32768)
1027 if (INTVAL (operands[1]) >= -128 && INTVAL (operands[1]) < 128)
1028 return \"movs.b %1,%0\";
1029 return \"movs.w %1,%0\";
1031 return \"move.d %1,%0\";
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
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\";
1050 return \"BOGUS: %1 to %0\";
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.
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")
1068 5 "cris_extend_operator"
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)
1077 "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
1080 mov%e5.%m5 [%4=%3+%1%T2],%0")
1084 (define_insn "*ext_sideqisi_biap"
1085 [(set (match_operand:SI 0 "register_operand" "=r,r")
1087 5 "cris_extend_operator"
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)
1096 "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
1099 mov%e5.%m5 [%4=%3+%1%T2],%0")
1103 (define_insn "*ext_sidehisi_biap"
1104 [(set (match_operand:SI 0 "register_operand" "=r,r")
1106 5 "cris_extend_operator"
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)
1115 "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
1118 mov%e5.%m5 [%4=%3+%1%T2],%0")
1120 ;; Same but [rx=ry+i]
1124 (define_insn "*ext_sideqihi"
1125 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1127 4 "cris_extend_operator"
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)
1134 "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
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')))
1144 return \"mov%e4.%m4 [%3=%1%S2],%0\";
1149 (define_insn "*ext_sideqisi"
1150 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1152 4 "cris_extend_operator"
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)
1159 "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
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')))
1169 return \"mov%e4.%m4 [%3=%1%S2],%0\";
1174 (define_insn "*ext_sidehisi"
1175 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1177 4 "cris_extend_operator"
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)
1184 "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
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')))
1194 return \"mov%e4.%m4 [%3=%1%S2],%0\";
1197 ;; FIXME: See movsi.
1199 (define_insn "movhi"
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"))]
1206 switch (which_alternative)
1213 return \"move.w %1,%0\";
1217 return \"clear.w %0\";
1219 return \"moveq %1,%0\";
1222 if (INTVAL (operands[1]) < 256 && INTVAL (operands[1]) >= -128)
1224 if (INTVAL (operands[1]) > 0)
1225 return \"movu.b %1,%0\";
1226 return \"movs.b %1,%0\";
1228 return \"move.w %1,%0\";
1230 return \"movEq %b1,%0\";
1232 return \"BOGUS: %1 to %0\";
1235 [(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,yes,no,no,no,no")
1237 (if_then_else (eq_attr "alternative" "7")
1238 (const_string "clobber")
1239 (const_string "normal")))])
1241 (define_insn "movstricthi"
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"))]
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"))]
1273 [(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,no,yes,no")
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"))]
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"))]
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
1322 (define_insn "extendsidi2"
1323 [(set (match_operand:DI 0 "register_operand" "=r")
1324 (sign_extend:DI (match_operand:SI 1 "general_operand" "g")))]
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")))]
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")))]
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")))]
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")))]
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")))]
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")
1371 (match_operand:HI 1 "nonimmediate_operand" "r,Q>,m")))]
1374 [(set_attr "slottable" "yes,yes,no")])
1376 (define_insn "zero_extendqisi2"
1377 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1379 (match_operand:QI 1 "nonimmediate_operand" "r,Q>,m")))]
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")
1389 (match_operand:QI 1 "nonimmediate_operand" "r,Q>,m")))]
1392 [(set_attr "slottable" "yes,yes,no")])
1394 ;; All kinds of arithmetic and logical instructions.
1396 ;; First, anonymous patterns to match addressing modes with
1399 ;; op.S [rx=ry+I],rz; (add, sub, or, and, bound).
1402 ;; FIXME: These could have anonymous mode for operand 0.
1406 (define_insn "*op_sideqi_biap"
1407 [(set (match_operand:QI 0 "register_operand" "=r,r")
1409 6 "cris_orthogonal_operator"
1410 [(match_operand:QI 1 "register_operand" "0,0")
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)
1419 "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1422 %x6.%s0 [%5=%4+%2%T3],%0")
1426 (define_insn "*op_sidehi_biap"
1427 [(set (match_operand:HI 0 "register_operand" "=r,r")
1429 6 "cris_orthogonal_operator"
1430 [(match_operand:HI 1 "register_operand" "0,0")
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)
1439 "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1442 %x6.%s0 [%5=%4+%2%T3],%0")
1446 (define_insn "*op_sidesi_biap"
1447 [(set (match_operand:SI 0 "register_operand" "=r,r")
1449 6 "cris_orthogonal_operator"
1450 [(match_operand:SI 1 "register_operand" "0,0")
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)
1459 "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
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.
1469 (define_insn "*op_sideqi"
1470 [(set (match_operand:QI 0 "register_operand" "=r,r,r")
1472 5 "cris_orthogonal_operator"
1473 [(match_operand:QI 1 "register_operand" "0,0,0")
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)
1480 "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
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')))
1490 return \"%x5.%s0 [%4=%2%S3],%0\";
1495 (define_insn "*op_sidehi"
1496 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1498 5 "cris_orthogonal_operator"
1499 [(match_operand:HI 1 "register_operand" "0,0,0")
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)
1506 "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
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')))
1516 return \"%x5.%s0 [%4=%2%S3],%0\";
1521 (define_insn "*op_sidesi"
1522 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1524 5 "cris_orthogonal_operator"
1525 [(match_operand:SI 1 "register_operand" "0,0,0")
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)
1532 "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
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')))
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;
1554 ;; FIXME: These could have anonymous mode for operand 0.
1558 (define_insn "*op_swap_sideqi_biap"
1559 [(set (match_operand:QI 0 "register_operand" "=r,r")
1561 6 "cris_commutative_orth_op"
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)
1571 "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1574 %x6.%s0 [%5=%4+%2%T3],%0")
1578 (define_insn "*op_swap_sidehi_biap"
1579 [(set (match_operand:HI 0 "register_operand" "=r,r")
1581 6 "cris_commutative_orth_op"
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)
1591 "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1594 %x6.%s0 [%5=%4+%2%T3],%0")
1598 (define_insn "*op_swap_sidesi_biap"
1599 [(set (match_operand:SI 0 "register_operand" "=r,r")
1601 6 "cris_commutative_orth_op"
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)
1611 "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
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.
1621 (define_insn "*op_swap_sideqi"
1622 [(set (match_operand:QI 0 "register_operand" "=r,r,r")
1624 5 "cris_commutative_orth_op"
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)
1632 "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
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')))
1642 return \"%x5.%s0 [%4=%2%S3],%0\";
1647 (define_insn "*op_swap_sidehi"
1648 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1650 5 "cris_commutative_orth_op"
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)
1658 "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
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')))
1668 return \"%x5.%s0 [%4=%2%S3],%0\";
1673 (define_insn "*op_swap_sidesi"
1674 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1676 5 "cris_commutative_orth_op"
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)
1684 "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
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')))
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",
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")))]
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")
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
1728 switch (which_alternative)
1732 return \"add.d %2,%0\";
1734 return \"addq %2,%0\";
1736 return \"subq %n2,%0\";
1738 /* 'Known value', but not in -63..63.
1739 Check if addu/subu may be used. */
1740 if (INTVAL (operands[2]) > 0)
1742 if (INTVAL (operands[2]) < 256)
1743 return \"addu.b %2,%0\";
1744 if (INTVAL (operands[2]) < 65536)
1745 return \"addu.w %2,%0\";
1749 if (INTVAL (operands[2]) >= -255)
1750 return \"subu.b %n2,%0\";
1751 if (INTVAL (operands[2]) >= -65535)
1752 return \"subu.w %n2,%0\";
1754 return \"add.d %2,%0\";
1756 return \"add.d %2,%1,%0\";
1758 return \"add.d %2,%0\";
1760 return \"add.d %1,%0\";
1762 return \"BOGUS addsi %2+%1 to %0\";
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")))]
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")))]
1795 [(set_attr "slottable" "yes,yes,yes,yes,yes,no,no")
1796 (set_attr "cc" "normal,normal,clobber,clobber,clobber,normal,normal")])
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",
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")))]
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")
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")))]
1825 ;; This does not do the optimal: "addu.w 65535,r0" when %2 is negative.
1826 ;; But then again, %2 should not be negative.
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")))]
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")))]
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.
1884 ;; FIXME: GCC should widen.
1886 (define_insn "*extopqihi_side_biap"
1887 [(set (match_operand:HI 0 "register_operand" "=r,r")
1889 6 "cris_additive_operand_extend_operator"
1890 [(match_operand:HI 1 "register_operand" "0,0")
1892 7 "cris_extend_operator"
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)
1901 "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1904 %x6%e7.%m7 [%5=%4+%2%T3],%0")
1908 (define_insn "*extopqisi_side_biap"
1909 [(set (match_operand:SI 0 "register_operand" "=r,r")
1911 6 "cris_operand_extend_operator"
1912 [(match_operand:SI 1 "register_operand" "0,0")
1914 7 "cris_extend_operator"
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)
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)"
1927 %x6%e7.%m7 [%5=%4+%2%T3],%0")
1931 (define_insn "*extophisi_side_biap"
1932 [(set (match_operand:SI 0 "register_operand" "=r,r")
1934 6 "cris_operand_extend_operator"
1935 [(match_operand:SI 1 "register_operand" "0,0")
1937 7 "cris_extend_operator"
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)
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)"
1950 %x6%e7.%m7 [%5=%4+%2%T3],%0")
1954 ;; FIXME: These could have anonymous mode for operand 0.
1958 (define_insn "*extopqihi_side"
1959 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1961 5 "cris_additive_operand_extend_operator"
1962 [(match_operand:HI 1 "register_operand" "0,0,0")
1964 6 "cris_extend_operator"
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")
1969 (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1970 (plus:SI (match_dup 2)
1972 "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
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')))
1982 return \"%x5%e6.%m6 [%4=%2%S3],%0\";
1987 (define_insn "*extopqisi_side"
1988 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1990 5 "cris_operand_extend_operator"
1991 [(match_operand:SI 1 "register_operand" "0,0,0")
1993 6 "cris_extend_operator"
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")
1998 (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1999 (plus:SI (match_dup 2)
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)"
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')))
2013 return \"%x5%e6.%m6 [%4=%2%S3],%0\";
2018 (define_insn "*extophisi_side"
2019 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2021 5 "cris_operand_extend_operator"
2022 [(match_operand:SI 1 "register_operand" "0,0,0")
2024 6 "cris_extend_operator"
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")
2029 (set (match_operand:SI 4 "register_operand" "=*2,r,r")
2030 (plus:SI (match_dup 2)
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)"
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')))
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]
2053 ;; FIXME: GCC should widen.
2055 (define_insn "*extopqihi_swap_side_biap"
2056 [(set (match_operand:HI 0 "register_operand" "=r,r")
2059 6 "cris_extend_operator"
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)
2069 "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
2072 add%e6.b [%5=%4+%2%T3],%0")
2076 (define_insn "*extopqisi_swap_side_biap"
2077 [(set (match_operand:SI 0 "register_operand" "=r,r")
2079 7 "cris_plus_or_bound_operator"
2081 6 "cris_extend_operator"
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)
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)"
2095 %x7%e6.%m6 [%5=%4+%2%T3],%0")
2098 (define_insn "*extophisi_swap_side_biap"
2099 [(set (match_operand:SI 0 "register_operand" "=r,r")
2101 7 "cris_plus_or_bound_operator"
2103 6 "cris_extend_operator"
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)
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)"
2117 %x7%e6.%m6 [%5=%4+%2%T3],%0")
2120 ;; FIXME: These could have anonymous mode for operand 0.
2121 ;; FIXME: GCC should widen.
2125 (define_insn "*extopqihi_swap_side"
2126 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
2129 5 "cris_extend_operator"
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)
2137 "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
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')))
2147 return \"add%e5.b [%4=%2%S3],%0\";
2152 (define_insn "*extopqisi_swap_side"
2153 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2155 6 "cris_plus_or_bound_operator"
2157 5 "cris_extend_operator"
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)
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)"
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')))
2176 return \"%x6%e5.%m5 [%4=%2%S3],%0\";
2181 (define_insn "*extophisi_swap_side"
2182 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2184 6 "cris_plus_or_bound_operator"
2186 5 "cris_extend_operator"
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)
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)"
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')))
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.
2212 ;; FIXME: GCC should widen.
2214 (define_insn "*extopqihi"
2215 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
2217 3 "cris_additive_operand_extend_operator"
2218 [(match_operand:HI 1 "register_operand" "0,0,0,r")
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)"
2228 %x3%e4.%m4 %2,%1,%0"
2229 [(set_attr "slottable" "yes,yes,no,no")
2230 (set_attr "cc" "clobber")])
2234 (define_insn "*extopqisi"
2235 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
2237 3 "cris_operand_extend_operator"
2238 [(match_operand:SI 1 "register_operand" "0,0,0,r")
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)"
2249 %x3%e4.%m4 %2,%1,%0"
2250 [(set_attr "slottable" "yes,yes,no,no")])
2254 (define_insn "*extophisi"
2255 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
2257 3 "cris_operand_extend_operator"
2258 [(match_operand:SI 1 "register_operand" "0,0,0,r")
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)"
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.
2278 (define_insn "*extopqihi_swap"
2279 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
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"
2291 [(set_attr "slottable" "yes,yes,no,no")
2292 (set_attr "cc" "clobber")])
2296 (define_insn "*extopqisi_swap"
2297 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
2299 4 "cris_plus_or_bound_operator"
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"
2310 %x4%e3.%m3 %2,%1,%0"
2311 [(set_attr "slottable" "yes,yes,no,no")])
2315 (define_insn "*extophisi_swap"
2316 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
2318 4 "cris_plus_or_bound_operator"
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"
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"
2355 (ltu (match_operand:SI 0 "register_operand" "r")
2356 (match_operand:SI 1 "const_int_operand" "n"))
2357 (plus:SI (sign_extend:SI
2359 (plus:SI (mult:SI (match_dup 0) (const_int 2))
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")
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)"
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")
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)"
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
2428 (define_insn "mstep_shift"
2429 [(set (match_operand:SI 0 "register_operand" "=r")
2431 (lt:SI (cc0) (const_int 0))
2432 (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
2434 (match_operand:SI 2 "register_operand" "r"))
2435 (ashift:SI (match_operand:SI 3 "register_operand" "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")
2449 (lt:SI (cc0) (const_int 0))
2450 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "0")
2452 (match_operand:SI 2 "register_operand" "r"))
2453 (mult:SI (match_operand:SI 3 "register_operand" "0")
2455 "operands[0] != frame_pointer_rtx
2456 && operands[1] != frame_pointer_rtx
2457 && operands[2] != frame_pointer_rtx
2458 && operands[3] != frame_pointer_rtx"
2460 [(set_attr "slottable" "yes")])
2462 (define_insn "umulhisi3"
2463 [(set (match_operand:SI 0 "register_operand" "=r")
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"
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")
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"
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"
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")
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"
2511 [(set_attr "slottable" "yes")
2512 (set_attr "cc" "clobber")])
2514 (define_insn "mulhisi3"
2515 [(set (match_operand:SI 0 "register_operand" "=r")
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"
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")
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")
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")
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")))
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")
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")))
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")
2585 (geu:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
2587 (match_operand:SI 2 "register_operand" "r"))
2588 (minus:SI (ashift:SI (match_operand:SI 3 "register_operand" "0")
2590 (match_operand:SI 4 "register_operand" "2"))
2591 (ashift:SI (match_operand:SI 5 "register_operand" "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")
2604 (geu:SI (mult:SI (match_operand:SI 1 "register_operand" "0")
2606 (match_operand:SI 2 "register_operand" "r"))
2607 (minus:SI (mult:SI (match_operand:SI 3 "register_operand" "0")
2609 (match_operand:SI 4 "register_operand" "2"))
2610 (mult:SI (match_operand:SI 5 "register_operand" "0")
2612 "operands[0] != frame_pointer_rtx
2613 && operands[1] != frame_pointer_rtx
2614 && operands[2] != frame_pointer_rtx
2615 && operands[3] != frame_pointer_rtx"
2617 [(set_attr "slottable" "yes")])
2619 ;; Logical operators.
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" "")))]
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])))))
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];
2663 emit_move_insn (reg0, reg1);
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);
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"
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"
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")))]
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" "")))]
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])))))
2745 /* See comment for andsi3. */
2746 rtx reg0 = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (HImode);
2747 rtx reg1 = operands[1];
2751 emit_move_insn (reg0, reg1);
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);
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")
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")
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)))]
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.
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")))]
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")))]
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")))]
2864 [(set_attr "slottable" "yes,yes,yes,no,no")
2865 (set_attr "cc" "normal,normal,clobber,normal,normal")])
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
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")))]
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")))]
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")))]
2917 [(set_attr "slottable" "yes,yes,yes,yes,no,no")
2918 (set_attr "cc" "clobber,normal,normal,clobber,normal,normal")])
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")))]
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")))]
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")))]
2947 [(set_attr "slottable" "yes")
2948 (set_attr "cc" "clobber")])
2952 ;; Questionable use, here mostly as a (slightly usable) define_expand
2955 (define_expand "negsf2"
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))])]
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"))]
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")))]
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")))]
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")))]
2999 [(set_attr "slottable" "yes")])
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")))]
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")))]
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")))]
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")))]
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"
3054 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))
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))]
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")))]
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")))]
3083 [(set_attr "slottable" "yes")])
3085 ;; Same comment goes as for "ashrhi3".
3087 (define_expand "ashrqi3"
3089 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "g")))
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))]
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")))]
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")))]
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")))]
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"
3142 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "g")))
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))]
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")))]
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")))]
3173 [(set_attr "slottable" "yes")])
3175 ;; Same comments as for ashrhi3.
3177 (define_expand "lshrqi3"
3179 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "g")))
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))]
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")))]
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")))]
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")))]
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
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")))]
3240 (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) > 15)
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")))]
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")))]
3266 (GET_CODE (operands[2]) == CONST_INT
3267 && INTVAL (operands[2]) > 7)
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")))]
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")))]
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")))]
3301 [(set_attr "slottable" "yes")])
3303 ;; FIXME: GCC should be able to do these expansions itself.
3305 (define_expand "abshi2"
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))]
3312 "operands[2] = gen_reg_rtx (SImode); operands[3] = gen_reg_rtx (SImode);")
3314 (define_expand "absqi2"
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))]
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
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")))]
3334 if (GET_CODE (operands[2]) == CONST_INT)
3336 if (INTVAL (operands[2]) < 256)
3337 return \"bound.b %2,%0\";
3339 if (INTVAL (operands[2]) < 65536)
3340 return \"bound.w %2,%0\";
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.
3353 (label_ref (match_operand 0 "" "")))]
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"))]
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"
3376 "cris_simple_epilogue ()"
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)
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
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))
3401 sprintf (rd, \"movem [$sp+],$%s\", reg_names [i]);
3403 if (regs_ever_live[CRIS_SRP_REGNUM])
3406 output_asm_insn (rd, operands);
3407 return \"jump [$sp+]\";
3412 output_asm_insn (\"reT\", operands);
3413 output_asm_insn (rd, operands);
3419 [(set (attr "slottable")
3421 (ne (symbol_ref "regs_ever_live[CRIS_SRP_REGNUM]") (const_int 0))
3422 (const_string "no") ; If jump then not slottable.
3426 || (flag_pic != 0 && regs_ever_live[1])
3427 || (PIC_OFFSET_TABLE_REGNUM == 0
3428 && cris_cfun_uses_pic_table ()))")
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"
3442 (if_then_else (eq (cc0)
3444 (label_ref (match_operand 0 "" ""))
3448 [(set_attr "slottable" "has_slot")])
3452 (if_then_else (ne (cc0)
3454 (label_ref (match_operand 0 "" ""))
3458 [(set_attr "slottable" "has_slot")])
3462 (if_then_else (gt (cc0)
3464 (label_ref (match_operand 0 "" ""))
3470 (cc_prev_status.flags & CC_NO_OVERFLOW)
3471 ? 0 : \"bgt %l0%#\";
3473 [(set_attr "slottable" "has_slot")])
3477 (if_then_else (gtu (cc0)
3479 (label_ref (match_operand 0 "" ""))
3483 [(set_attr "slottable" "has_slot")])
3487 (if_then_else (lt (cc0)
3489 (label_ref (match_operand 0 "" ""))
3495 (cc_prev_status.flags & CC_NO_OVERFLOW)
3496 ? \"bmi %l0%#\" : \"blt %l0%#\";
3498 [(set_attr "slottable" "has_slot")])
3502 (if_then_else (ltu (cc0)
3504 (label_ref (match_operand 0 "" ""))
3508 [(set_attr "slottable" "has_slot")])
3512 (if_then_else (ge (cc0)
3514 (label_ref (match_operand 0 "" ""))
3520 (cc_prev_status.flags & CC_NO_OVERFLOW)
3521 ? \"bpl %l0%#\" : \"bge %l0%#\";
3523 [(set_attr "slottable" "has_slot")])
3527 (if_then_else (geu (cc0)
3529 (label_ref (match_operand 0 "" ""))
3533 [(set_attr "slottable" "has_slot")])
3537 (if_then_else (le (cc0)
3539 (label_ref (match_operand 0 "" ""))
3545 (cc_prev_status.flags & CC_NO_OVERFLOW)
3546 ? 0 : \"ble %l0%#\";
3548 [(set_attr "slottable" "has_slot")])
3552 (if_then_else (leu (cc0)
3554 (label_ref (match_operand 0 "" ""))
3558 [(set_attr "slottable" "has_slot")])
3560 ;; Reversed anonymous patterns to the ones above, as mandated.
3562 (define_insn "*beq_reversed"
3564 (if_then_else (eq (cc0)
3567 (label_ref (match_operand 0 "" ""))))]
3570 [(set_attr "slottable" "has_slot")])
3572 (define_insn "*bne_reversed"
3574 (if_then_else (ne (cc0)
3577 (label_ref (match_operand 0 "" ""))))]
3580 [(set_attr "slottable" "has_slot")])
3582 (define_insn "*bgt_reversed"
3584 (if_then_else (gt (cc0)
3587 (label_ref (match_operand 0 "" ""))))]
3592 (cc_prev_status.flags & CC_NO_OVERFLOW)
3593 ? 0 : \"ble %l0%#\";
3595 [(set_attr "slottable" "has_slot")])
3597 (define_insn "*bgtu_reversed"
3599 (if_then_else (gtu (cc0)
3602 (label_ref (match_operand 0 "" ""))))]
3605 [(set_attr "slottable" "has_slot")])
3607 (define_insn "*blt_reversed"
3609 (if_then_else (lt (cc0)
3612 (label_ref (match_operand 0 "" ""))))]
3617 (cc_prev_status.flags & CC_NO_OVERFLOW)
3618 ? \"bpl %l0%#\" : \"bge %l0%#\";
3620 [(set_attr "slottable" "has_slot")])
3622 (define_insn "*bltu_reversed"
3624 (if_then_else (ltu (cc0)
3627 (label_ref (match_operand 0 "" ""))))]
3630 [(set_attr "slottable" "has_slot")])
3632 (define_insn "*bge_reversed"
3634 (if_then_else (ge (cc0)
3637 (label_ref (match_operand 0 "" ""))))]
3642 (cc_prev_status.flags & CC_NO_OVERFLOW)
3643 ? \"bmi %l0%#\" : \"blt %l0%#\";
3645 [(set_attr "slottable" "has_slot")])
3647 (define_insn "*bgeu_reversed"
3649 (if_then_else (geu (cc0)
3652 (label_ref (match_operand 0 "" ""))))]
3655 [(set_attr "slottable" "has_slot")])
3657 (define_insn "*ble_reversed"
3659 (if_then_else (le (cc0)
3662 (label_ref (match_operand 0 "" ""))))]
3667 (cc_prev_status.flags & CC_NO_OVERFLOW)
3668 ? 0 : \"bgt %l0%#\";
3670 [(set_attr "slottable" "has_slot")])
3672 (define_insn "*bleu_reversed"
3674 (if_then_else (leu (cc0)
3677 (label_ref (match_operand 0 "" ""))))]
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.
3688 [(set (match_operand:SI 0 "register_operand" "=r")
3689 (geu:SI (cc0) (const_int 0)))]
3692 [(set_attr "slottable" "yes")
3693 (set_attr "cc" "none")])
3696 [(set (match_operand:SI 0 "register_operand" "=r")
3697 (ltu:SI (cc0) (const_int 0)))]
3700 [(set_attr "slottable" "yes")
3701 (set_attr "cc" "none")])
3704 [(set (match_operand:SI 0 "register_operand" "=r")
3705 (eq:SI (cc0) (const_int 0)))]
3708 [(set_attr "slottable" "yes")
3709 (set_attr "cc" "none")])
3712 [(set (match_operand:SI 0 "register_operand" "=r")
3713 (ge:SI (cc0) (const_int 0)))]
3718 (cc_prev_status.flags & CC_NO_OVERFLOW)
3719 ? \"spl %0\" : \"sge %0\";
3721 [(set_attr "slottable" "yes")
3722 (set_attr "cc" "none")])
3725 [(set (match_operand:SI 0 "register_operand" "=r")
3726 (gt:SI (cc0) (const_int 0)))]
3731 (cc_prev_status.flags & CC_NO_OVERFLOW)
3734 [(set_attr "slottable" "yes")
3735 (set_attr "cc" "none")])
3738 [(set (match_operand:SI 0 "register_operand" "=r")
3739 (gtu:SI (cc0) (const_int 0)))]
3742 [(set_attr "slottable" "yes")
3743 (set_attr "cc" "none")])
3746 [(set (match_operand:SI 0 "register_operand" "=r")
3747 (le:SI (cc0) (const_int 0)))]
3752 (cc_prev_status.flags & CC_NO_OVERFLOW)
3755 [(set_attr "slottable" "yes")
3756 (set_attr "cc" "none")])
3759 [(set (match_operand:SI 0 "register_operand" "=r")
3760 (leu:SI (cc0) (const_int 0)))]
3763 [(set_attr "slottable" "yes")
3764 (set_attr "cc" "none")])
3767 [(set (match_operand:SI 0 "register_operand" "=r")
3768 (lt:SI (cc0) (const_int 0)))]
3773 (cc_prev_status.flags & CC_NO_OVERFLOW)
3774 ? \"smi %0\" : \"slt %0\";
3776 [(set_attr "slottable" "yes")
3777 (set_attr "cc" "none")])
3780 [(set (match_operand:SI 0 "register_operand" "=r")
3781 (ne:SI (cc0) (const_int 0)))]
3784 [(set_attr "slottable" "yes")
3785 (set_attr "cc" "none")])
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))])]
3806 if (GET_CODE (operands[0]) != MEM)
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
3816 if (CONSTANT_ADDRESS_P (op0) && GET_CODE (op0) != CONST_INT)
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,
3831 gen_rtx_UNSPEC (VOIDmode,
3832 gen_rtvec (1, op0), 0)));
3836 operands[0] = gen_rtx_MEM (GET_MODE (operands[0]), op0);
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"
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"
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))])]
3873 if (GET_CODE (operands[1]) != MEM)
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
3883 if (CONSTANT_ADDRESS_P (op1) && GET_CODE (op1) != CONST_INT)
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,
3896 gen_rtx_UNSPEC (VOIDmode,
3897 gen_rtvec (1, op1), 0)));
3901 operands[1] = gen_rtx_MEM (GET_MODE (operands[1]), op1);
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"
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"
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.
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" ""))
3953 (minus:SI (match_dup 5)
3954 (match_operand:SI 1 "const_int_operand" "n")))
3956 (umin:SI (match_dup 6)
3957 (match_operand:SI 2 "const_int_operand" "n")))
3961 (ltu (match_dup 7) (match_dup 2))
3962 (plus:SI (sign_extend:SI
3964 (plus:SI (mult:SI (match_dup 7) (const_int 2))
3967 (label_ref (match_operand 4 "" ""))))
3968 (use (label_ref (match_operand 3 "" "")))])]
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
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].
3995 ;; Lose if rz=ry or rx=rz.
3996 ;; Call this op-extend-split
3999 [(set (match_operand 0 "register_operand" "")
4001 4 "cris_operand_extend_operator"
4002 [(match_operand 1 "register_operand" "")
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])"
4017 (match_op_dup 3 [(match_dup 2)])]))]
4020 ;; As op-extend-split, but recognize and split op [rz],ry,rz into
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
4028 [(set (match_operand 0 "register_operand" "")
4030 4 "cris_plus_or_bound_operator"
4031 [(match_operand 1 "register_operand" "")
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])"
4042 (match_op_dup 3 [(match_dup 2)]))
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
4055 [(set (match_operand 0 "register_operand" "")
4057 4 "cris_plus_or_bound_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])"
4073 (match_op_dup 3 [(match_dup 2)])]))]
4076 ;; As op-extend-split-rx=rz, but swapped operands, only for plus or
4077 ;; bound. Call this op-extend-split-swapped-rx=rz.
4080 [(set (match_operand 0 "register_operand" "")
4082 4 "cris_plus_or_bound_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])"
4094 (match_op_dup 3 [(match_dup 2)]))
4101 ;; As op-extend-split, but the mem operand is not extended.
4103 ;; op [rx],ry,rz changed into
4106 ;; lose if ry=rz or rx=rz
4107 ;; Call this op-extend.
4110 [(set (match_operand 0 "register_operand" "")
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])"
4129 ;; As op-extend-split-rx=rz, non-extended.
4130 ;; Call this op-split-rx=rz
4133 [(set (match_operand 0 "register_operand" "")
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])"
4152 ;; As op-extend-split-swapped, nonextended.
4153 ;; Call this op-split-swapped.
4156 [(set (match_operand 0 "register_operand" "")
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])"
4174 ;; As op-extend-split-swapped-rx=rz, non-extended.
4175 ;; Call this op-split-swapped-rx=rz.
4178 [(set (match_operand 0 "register_operand" "")
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])"
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
4203 [(set (match_operand 0 "register_operand" "")
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)
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))
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
4223 [(set (match_operand 0 "register_operand" "")
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)
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]
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)
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))
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]
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)
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]
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" "")))
4282 (set (match_operand:SI 3 "register_operand" "")
4283 (plus:SI (mult:SI (match_dup 0)
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))
4290 (set (mem:SI (match_dup 3)) (const_int 0))]
4293 ;; clear.w [rx=rx+rz.S2]
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" "")))
4302 (set (match_operand:SI 3 "register_operand" "")
4303 (plus:SI (mult:SI (match_dup 0)
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))
4310 (set (mem:HI (match_dup 3)) (const_int 0))]
4313 ;; clear.b [rx=rx+rz.S2]
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" "")))
4322 (set (match_operand:SI 3 "register_operand" "")
4323 (plus:SI (mult:SI (match_dup 0)
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))
4330 (set (mem:QI (match_dup 3)) (const_int 0))]
4333 ;; clear.d [rx=rx+i]
4338 (plus:SI (match_operand:SI 0 "cris_bdap_operand" "")
4339 (match_operand:SI 1 "cris_bdap_operand" "")))
4341 (set (match_operand:SI 2 "register_operand" "")
4342 (plus:SI (match_dup 0)
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))]
4350 ;; clear.w [rx=rx+i]
4355 (plus:SI (match_operand:SI 0 "cris_bdap_operand" "")
4356 (match_operand:SI 1 "cris_bdap_operand" "")))
4358 (set (match_operand:SI 2 "register_operand" "")
4359 (plus:SI (match_dup 0)
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))]
4367 ;; clear.b [rx=rx+i]
4372 (plus:SI (match_operand:SI 0 "cris_bdap_operand" "")
4373 (match_operand:SI 1 "cris_bdap_operand" "")))
4375 (set (match_operand:SI 2 "register_operand" "")
4376 (plus:SI (match_dup 0)
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))]
4384 ;; mov(s|u).S1 [rx=rx+rz.S2],ry
4388 [(set (match_operand 0 "register_operand" "")
4390 5 "cris_extend_operator"
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)
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))
4404 (set (match_dup 0) (match_op_dup 5 [(match_dup 6)]))]
4405 "operands[6] = gen_rtx_MEM (GET_MODE (XEXP (operands[5],0)),
4408 ;; mov(s|u).S1 [rx=rx+i],ry
4412 [(set (match_operand 0 "register_operand" "")
4414 4 "cris_extend_operator"
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)
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)),
4428 ;; op.S1 [rx=rx+i],ry
4432 [(set (match_operand 0 "register_operand" "")
4434 5 "cris_orthogonal_operator"
4435 [(match_operand 1 "register_operand" "")
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)
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
4452 [(set (match_operand 0 "register_operand" "")
4454 6 "cris_orthogonal_operator"
4455 [(match_operand 1 "register_operand" "")
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)
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))
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)
4476 [(set (match_operand 0 "register_operand" "")
4478 6 "cris_commutative_orth_op"
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)
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))
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)
4500 [(set (match_operand 0 "register_operand" "")
4502 5 "cris_commutative_orth_op"
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)
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
4520 [(set (match_operand 0 "register_operand" "")
4522 6 "cris_operand_extend_operator"
4523 [(match_operand 1 "register_operand" "")
4525 7 "cris_extend_operator"
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)
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))
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)),
4544 ;; op(s|u).S1 [rx=rx+i],ry
4548 [(set (match_operand 0 "register_operand" "")
4550 5 "cris_operand_extend_operator"
4551 [(match_operand 1 "register_operand" "")
4553 6 "cris_extend_operator"
4555 (plus:SI (match_operand:SI 2 "cris_bdap_operand" "")
4556 (match_operand:SI 3 "cris_bdap_operand" "")
4558 (set (match_operand:SI 4 "register_operand" "")
4559 (plus:SI (match_dup 2)
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)),
4569 ;; op(s|u).S1 [rx=rx+rz.S2],ry (swapped, plus or bound)
4573 [(set (match_operand 0 "register_operand" "")
4575 7 "cris_plus_or_bound_operator"
4577 6 "cris_extend_operator"
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)
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))
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)),
4596 ;; op(s|u).S1 [rx=rx+i],ry (swapped, plus or bound)
4600 [(set (match_operand 0 "register_operand" "")
4602 6 "cris_plus_or_bound_operator"
4604 5 "cris_extend_operator"
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)
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)),
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.
4624 ;; move [indirect_ref],rx
4625 ;; where indirect ref = {const, [r+], [r]}, it costs as much as
4626 ;; move indirect_ref,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.
4636 [(set (match_operand 0 "register_operand" "")
4637 (match_operand 1 "indirect_operand" ""))]
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.
4652 [(set (match_operand 0 "register_operand" "")
4654 4 "cris_extend_operator"
4655 [(match_operand 1 "indirect_operand" "")]))]
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.
4683 [(set (match_operand 0 "register_operand" "=r")
4684 (ashiftrt:SI (match_dup 0)
4685 (match_operand:SI 1 "const_int_operand" "n")))
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"
4698 cc_status.flags |= CC_NOT_NEGATIVE;
4700 return \"lsrq %1,%0\;and.b %2,%0\";
4704 [(set (match_operand 0 "register_operand" "=r")
4705 (ashiftrt:SI (match_dup 0)
4706 (match_operand:SI 1 "const_int_operand" "n")))
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"
4720 cc_status.flags |= CC_NOT_NEGATIVE;
4722 return \"lsrq %1,%0\;and.w %2,%0\";
4726 [(set (match_operand 0 "register_operand" "=r")
4727 (lshiftrt:SI (match_dup 0)
4728 (match_operand:SI 1 "const_int_operand" "n")))
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"
4741 cc_status.flags |= CC_NOT_NEGATIVE;
4743 return \"lsrq %1,%0\;and.b %2,%0\";
4747 [(set (match_operand 0 "register_operand" "=r")
4748 (lshiftrt:SI (match_dup 0)
4749 (match_operand:SI 1 "const_int_operand" "n")))
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"
4762 cc_status.flags |= CC_NOT_NEGATIVE;
4764 return \"lsrq %1,%0\;and.w %2,%0\";
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.
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]
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:
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.
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"
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
4840 ;; will occur. Solve this, and likewise for to-memory.
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"))
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])
4855 : (rtx_equal_p (operands[2], operands[0])
4857 (! REG_S_P (operands[1])
4859 : (rtx_equal_p (operands[2], operands[0])
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.
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"))
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])
4883 : (rtx_equal_p (operands[2], operands[0])
4885 (! REG_S_P (operands[1])
4887 : (rtx_equal_p (operands[2], operands[0])
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.
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"))
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"
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])
4915 : (rtx_equal_p (operands[2], operands[0])
4917 (! REG_S_P (operands[1])
4919 : (rtx_equal_p (operands[2], operands[0])
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).
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"))
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))
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])
4945 : (rtx_equal_p (operands[2], operands[0])
4947 (! REG_S_P (operands[1])
4949 : (rtx_equal_p (operands[2], operands[0])
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:
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"
4970 [(set_attr "slottable" "yes")])
4972 ;; And a simple variant with extended operand.
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.
4988 ;; move.d [r10+16],r9
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.
5002 [(set (match_operand 0 "register_operand" "=r,r,r,r")
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"))))
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"
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")
5022 ;; I cannot tell GCC (2.1, 2.7.2) how to correctly reload an instruction
5024 ;; and.b some_byte,const,reg_32
5025 ;; where reg_32 is the destination of the "three-address" code optimally.
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
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]))"
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\";
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]))"
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\";
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)