1 ;; Machine description of the Renesas M32R cpu for GNU C compiler
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
4 ;; This file is part of GCC.
6 ;; GCC is free software; you can redistribute it and/or modify it
7 ;; under the terms of the GNU General Public License as published
8 ;; by the Free Software Foundation; either version 2, or (at your
9 ;; option) any later version.
11 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
12 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 ;; License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING. If not, write to
18 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
19 ;; Boston, MA 02111-1307, USA.
21 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
27 ;; 3 - setting carry in addx/subx instructions.
29 ;; Insn type. Used to default other attribute values.
31 "int2,int4,load2,load4,load8,store2,store4,store8,shift2,shift4,mul2,div4,uncond_branch,branch,call,multi,misc"
32 (const_string "misc"))
35 (define_attr "length" ""
36 (cond [(eq_attr "type" "int2,load2,store2,shift2,mul2")
39 (eq_attr "type" "int4,load4,store4,shift4,div4")
42 (eq_attr "type" "multi")
45 (eq_attr "type" "uncond_branch,branch,call")
50 ;; The length here is the length of a single asm. Unfortunately it might be
51 ;; 2 or 4 so we must allow for 4. That's ok though.
52 (define_asm_attributes
53 [(set_attr "length" "4")
54 (set_attr "type" "multi")])
57 ;; Whether an instruction is 16-bit or 32-bit
58 (define_attr "insn_size" "short,long"
59 (if_then_else (eq_attr "type" "int2,load2,store2,shift2,mul2")
60 (const_string "short")
61 (const_string "long")))
63 (define_attr "debug" "no,yes"
64 (const (symbol_ref "(TARGET_DEBUG != 0)")))
66 (define_attr "opt_size" "no,yes"
67 (const (symbol_ref "(optimize_size != 0)")))
69 (define_attr "m32r" "no,yes"
70 (const (symbol_ref "(TARGET_M32R != 0)")))
72 (define_attr "m32rx" "no,yes"
73 (const (symbol_ref "(TARGET_M32RX != 0)")))
75 (define_attr "m32r2" "no,yes"
76 (const (symbol_ref "(TARGET_M32R2 != 0)")))
78 (define_attr "m32rx_pipeline" "either,s,o,long,m32r"
79 (cond [(and (eq_attr "m32rx" "no")
80 (eq_attr "m32r2" "no"))
83 (eq_attr "insn_size" "!short")
84 (const_string "long")]
86 (cond [(eq_attr "type" "int2")
87 (const_string "either")
89 (eq_attr "type" "load2,store2,shift2,uncond_branch,branch,call")
92 (eq_attr "type" "mul2")
95 (const_string "long"))))
97 ;; ::::::::::::::::::::
101 ;; ::::::::::::::::::::
103 ;; On most RISC machines, there are instructions whose results are not
104 ;; available for a specific number of cycles. Common cases are instructions
105 ;; that load data from memory. On many machines, a pipeline stall will result
106 ;; if the data is referenced too soon after the load instruction.
108 ;; In addition, many newer microprocessors have multiple function units,
109 ;; usually one for integer and one for floating point, and often will incur
110 ;; pipeline stalls when a result that is needed is not yet ready.
112 ;; The descriptions in this section allow the specification of how much time
113 ;; must elapse between the execution of an instruction and the time when its
114 ;; result is used. It also allows specification of when the execution of an
115 ;; instruction will delay execution of similar instructions due to function
118 ;; For the purposes of the specifications in this section, a machine is divided
119 ;; into "function units", each of which execute a specific class of
120 ;; instructions in first-in-first-out order. Function units that accept one
121 ;; instruction each cycle and allow a result to be used in the succeeding
122 ;; instruction (usually via forwarding) need not be specified. Classic RISC
123 ;; microprocessors will normally have a single function unit, which we can call
124 ;; `memory'. The newer "superscalar" processors will often have function units
125 ;; for floating point operations, usually at least a floating point adder and
128 ;; Each usage of a function units by a class of insns is specified with a
129 ;; `define_function_unit' expression, which looks like this:
131 ;; (define_function_unit NAME MULTIPLICITY SIMULTANEITY TEST READY-DELAY
132 ;; ISSUE-DELAY [CONFLICT-LIST])
134 ;; NAME is a string giving the name of the function unit.
136 ;; MULTIPLICITY is an integer specifying the number of identical units in the
137 ;; processor. If more than one unit is specified, they will be scheduled
138 ;; independently. Only truly independent units should be counted; a pipelined
139 ;; unit should be specified as a single unit. (The only common example of a
140 ;; machine that has multiple function units for a single instruction class that
141 ;; are truly independent and not pipelined are the two multiply and two
142 ;; increment units of the CDC 6600.)
144 ;; SIMULTANEITY specifies the maximum number of insns that can be executing in
145 ;; each instance of the function unit simultaneously or zero if the unit is
146 ;; pipelined and has no limit.
148 ;; All `define_function_unit' definitions referring to function unit NAME must
149 ;; have the same name and values for MULTIPLICITY and SIMULTANEITY.
151 ;; TEST is an attribute test that selects the insns we are describing in this
152 ;; definition. Note that an insn may use more than one function unit and a
153 ;; function unit may be specified in more than one `define_function_unit'.
155 ;; READY-DELAY is an integer that specifies the number of cycles after which
156 ;; the result of the instruction can be used without introducing any stalls.
158 ;; ISSUE-DELAY is an integer that specifies the number of cycles after the
159 ;; instruction matching the TEST expression begins using this unit until a
160 ;; subsequent instruction can begin. A cost of N indicates an N-1 cycle delay.
161 ;; A subsequent instruction may also be delayed if an earlier instruction has a
162 ;; longer READY-DELAY value. This blocking effect is computed using the
163 ;; SIMULTANEITY, READY-DELAY, ISSUE-DELAY, and CONFLICT-LIST terms. For a
164 ;; normal non-pipelined function unit, SIMULTANEITY is one, the unit is taken
165 ;; to block for the READY-DELAY cycles of the executing insn, and smaller
166 ;; values of ISSUE-DELAY are ignored.
168 ;; CONFLICT-LIST is an optional list giving detailed conflict costs for this
169 ;; unit. If specified, it is a list of condition test expressions to be
170 ;; applied to insns chosen to execute in NAME following the particular insn
171 ;; matching TEST that is already executing in NAME. For each insn in the list,
172 ;; ISSUE-DELAY specifies the conflict cost; for insns not in the list, the cost
173 ;; is zero. If not specified, CONFLICT-LIST defaults to all instructions that
174 ;; use the function unit.
176 ;; Typical uses of this vector are where a floating point function unit can
177 ;; pipeline either single- or double-precision operations, but not both, or
178 ;; where a memory unit can pipeline loads, but not stores, etc.
180 ;; As an example, consider a classic RISC machine where the result of a load
181 ;; instruction is not available for two cycles (a single "delay" instruction is
182 ;; required) and where only one load instruction can be executed
183 ;; simultaneously. This would be specified as:
185 ;; (define_function_unit "memory" 1 1 (eq_attr "type" "load") 2 0)
187 ;; For the case of a floating point function unit that can pipeline
188 ;; either single or double precision, but not both, the following could be
191 ;; (define_function_unit "fp" 1 0
192 ;; (eq_attr "type" "sp_fp") 4 4
193 ;; [(eq_attr "type" "dp_fp")])
195 ;; (define_function_unit "fp" 1 0
196 ;; (eq_attr "type" "dp_fp") 4 4
197 ;; [(eq_attr "type" "sp_fp")])
199 ;; Note: The scheduler attempts to avoid function unit conflicts and uses all
200 ;; the specifications in the `define_function_unit' expression. It has
201 ;; recently come to our attention that these specifications may not allow
202 ;; modeling of some of the newer "superscalar" processors that have insns using
203 ;; multiple pipelined units. These insns will cause a potential conflict for
204 ;; the second unit used during their execution and there is no way of
205 ;; representing that conflict. We welcome any examples of how function unit
206 ;; conflicts work in such processors and suggestions for their representation.
208 ;; Function units of the M32R
209 ;; Units that take one cycle do not need to be specified.
211 ;; (define_function_unit {name} {multiplicity} {simultaneity} {test}
212 ;; {ready-delay} {issue-delay} [{conflict-list}])
214 ;; Hack to get GCC to better pack the instructions.
215 ;; We pretend there is a separate long function unit that conflicts with
216 ;; both the left and right 16 bit insn slots.
218 (define_function_unit "short" 2 2
219 (and (eq_attr "m32r" "yes")
220 (and (eq_attr "insn_size" "short")
221 (eq_attr "type" "!load2")))
223 [(eq_attr "insn_size" "long")])
225 (define_function_unit "short" 2 2 ;; load delay of 1 clock for mem execution + 1 clock for WB
226 (and (eq_attr "m32r" "yes")
227 (eq_attr "type" "load2"))
229 [(eq_attr "insn_size" "long")])
231 (define_function_unit "long" 1 1
232 (and (eq_attr "m32r" "yes")
233 (and (eq_attr "insn_size" "long")
234 (eq_attr "type" "!load4,load8")))
236 [(eq_attr "insn_size" "short")])
238 (define_function_unit "long" 1 1 ;; load delay of 1 clock for mem execution + 1 clock for WB
239 (and (eq_attr "m32r" "yes")
240 (and (eq_attr "insn_size" "long")
241 (eq_attr "type" "load4,load8")))
243 [(eq_attr "insn_size" "short")])
245 (define_function_unit "left" 1 1
246 (and (eq_attr "m32rx_pipeline" "o,either")
247 (eq_attr "type" "!load2"))
249 [(eq_attr "insn_size" "long")])
251 (define_function_unit "left" 1 1 ;; load delay of 1 clock for mem execution + 1 clock for WB
252 (and (eq_attr "m32rx_pipeline" "o,either")
253 (eq_attr "type" "load2"))
255 [(eq_attr "insn_size" "long")])
257 (define_function_unit "right" 1 1
258 (eq_attr "m32rx_pipeline" "s,either")
260 [(eq_attr "insn_size" "long")])
262 (define_function_unit "long" 1 1
263 (and (eq_attr "m32rx" "yes")
264 (and (eq_attr "insn_size" "long")
265 (eq_attr "type" "!load4,load8")))
267 [(eq_attr "insn_size" "short")])
269 (define_function_unit "long" 1 1 ;; load delay of 1 clock for mem execution + 1 clock for WB
270 (and (eq_attr "m32rx" "yes")
271 (and (eq_attr "insn_size" "long")
272 (eq_attr "type" "load4,load8")))
274 [(eq_attr "insn_size" "short")])
276 ;; Expand prologue as RTL
277 (define_expand "prologue"
282 m32r_expand_prologue ();
287 ;; Move instructions.
289 ;; For QI and HI moves, the register must contain the full properly
290 ;; sign-extended value. nonzero_bits assumes this [otherwise
291 ;; SHORT_IMMEDIATES_SIGN_EXTEND must be used, but the comment for it
292 ;; says it's a kludge and the .md files should be fixed instead].
294 (define_expand "movqi"
295 [(set (match_operand:QI 0 "general_operand" "")
296 (match_operand:QI 1 "general_operand" ""))]
300 /* Everything except mem = const or mem = mem can be done easily.
301 Objects in the small data area are handled too. */
303 if (GET_CODE (operands[0]) == MEM)
304 operands[1] = force_reg (QImode, operands[1]);
307 (define_insn "*movqi_insn"
308 [(set (match_operand:QI 0 "move_dest_operand" "=r,r,r,r,r,T,m")
309 (match_operand:QI 1 "move_src_operand" "r,I,JQR,T,m,r,r"))]
310 "register_operand (operands[0], QImode) || register_operand (operands[1], QImode)"
319 [(set_attr "type" "int2,int2,int4,load2,load4,store2,store4")
320 (set_attr "length" "2,2,4,2,4,2,4")])
322 (define_expand "movhi"
323 [(set (match_operand:HI 0 "general_operand" "")
324 (match_operand:HI 1 "general_operand" ""))]
328 /* Everything except mem = const or mem = mem can be done easily. */
330 if (GET_CODE (operands[0]) == MEM)
331 operands[1] = force_reg (HImode, operands[1]);
334 (define_insn "*movhi_insn"
335 [(set (match_operand:HI 0 "move_dest_operand" "=r,r,r,r,r,r,T,m")
336 (match_operand:HI 1 "move_src_operand" "r,I,JQR,K,T,m,r,r"))]
337 "register_operand (operands[0], HImode) || register_operand (operands[1], HImode)"
347 [(set_attr "type" "int2,int2,int4,int4,load2,load4,store2,store4")
348 (set_attr "length" "2,2,4,4,2,4,2,4")])
350 (define_expand "movsi_push"
351 [(set (mem:SI (pre_dec:SI (match_operand:SI 0 "register_operand" "")))
352 (match_operand:SI 1 "register_operand" ""))]
356 (define_expand "movsi_pop"
357 [(set (match_operand:SI 0 "register_operand" "")
358 (mem:SI (post_inc:SI (match_operand:SI 1 "register_operand" ""))))]
362 (define_expand "movsi"
363 [(set (match_operand:SI 0 "general_operand" "")
364 (match_operand:SI 1 "general_operand" ""))]
368 /* Everything except mem = const or mem = mem can be done easily. */
370 if (GET_CODE (operands[0]) == MEM)
371 operands[1] = force_reg (SImode, operands[1]);
373 /* Small Data Area reference? */
374 if (small_data_operand (operands[1], SImode))
376 emit_insn (gen_movsi_sda (operands[0], operands[1]));
380 /* If medium or large code model, symbols have to be loaded with
382 if (addr32_operand (operands[1], SImode))
384 emit_insn (gen_movsi_addr32 (operands[0], operands[1]));
389 ;; ??? Do we need a const_double constraint here for large unsigned values?
390 (define_insn "*movsi_insn"
391 [(set (match_operand:SI 0 "move_dest_operand" "=r,r,r,r,r,r,r,r,r,T,S,m")
392 (match_operand:SI 1 "move_src_operand" "r,I,J,MQ,L,n,T,U,m,r,r,r"))]
393 "register_operand (operands[0], SImode) || register_operand (operands[1], SImode)"
396 if (GET_CODE (operands[0]) == REG || GET_CODE (operands[1]) == SUBREG)
398 switch (GET_CODE (operands[1]))
410 if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
411 && XEXP (XEXP (operands[1], 0), 0) == stack_pointer_rtx)
417 value = INTVAL (operands[1]);
419 return \"ldi %0,%#%1\\t; %X1\";
421 if (UINT24_P (value))
422 return \"ld24 %0,%#%1\\t; %X1\";
424 if (UPPER16_P (value))
425 return \"seth %0,%#%T1\\t; %X1\";
433 return \"ld24 %0,%#%1\";
439 else if (GET_CODE (operands[0]) == MEM
440 && (GET_CODE (operands[1]) == REG || GET_CODE (operands[1]) == SUBREG))
442 if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
443 && XEXP (XEXP (operands[0], 0), 0) == stack_pointer_rtx)
451 [(set_attr "type" "int2,int2,int4,int4,int4,multi,load2,load2,load4,store2,store2,store4")
452 (set_attr "length" "2,2,4,4,4,8,2,2,4,2,2,4")])
454 ; Try to use a four byte / two byte pair for constants not loadable with
458 [(set (match_operand:SI 0 "register_operand" "")
459 (match_operand:SI 1 "two_insn_const_operand" ""))]
461 [(set (match_dup 0) (match_dup 2))
462 (set (match_dup 0) (ior:SI (match_dup 0) (match_dup 3)))]
465 unsigned HOST_WIDE_INT val = INTVAL (operands[1]);
466 unsigned HOST_WIDE_INT tmp;
469 /* In all cases we will emit two instructions. However we try to
470 use 2 byte instructions wherever possible. We can assume the
471 constant isn't loadable with any of ldi, ld24, or seth. */
473 /* See if we can load a 24 bit unsigned value and invert it. */
474 if (UINT24_P (~ val))
476 emit_insn (gen_movsi (operands[0], GEN_INT (~ val)));
477 emit_insn (gen_one_cmplsi2 (operands[0], operands[0]));
481 /* See if we can load a 24 bit unsigned value and shift it into place.
482 0x01fffffe is just beyond ld24's range. */
483 for (shift = 1, tmp = 0x01fffffe;
487 if ((val & ~tmp) == 0)
489 emit_insn (gen_movsi (operands[0], GEN_INT (val >> shift)));
490 emit_insn (gen_ashlsi3 (operands[0], operands[0], GEN_INT (shift)));
495 /* Can't use any two byte insn, fall back to seth/or3. Use ~0xffff instead
496 of 0xffff0000, since the later fails on a 64-bit host. */
497 operands[2] = GEN_INT ((val) & ~0xffff);
498 operands[3] = GEN_INT ((val) & 0xffff);
502 [(set (match_operand:SI 0 "register_operand" "")
503 (match_operand:SI 1 "seth_add3_operand" ""))]
506 (high:SI (match_dup 1)))
508 (lo_sum:SI (match_dup 0)
512 ;; Small data area support.
513 ;; The address of _SDA_BASE_ is loaded into a register and all objects in
514 ;; the small data area are indexed off that. This is done for each reference
515 ;; but cse will clean things up for us. We let the compiler choose the
516 ;; register to use so we needn't allocate (and maybe even fix) a special
517 ;; register to use. Since the load and store insns have a 16 bit offset the
518 ;; total size of the data area can be 64K. However, if the data area lives
519 ;; above 16M (24 bits), _SDA_BASE_ will have to be loaded with seth/add3 which
520 ;; would then yield 3 instructions to reference an object [though there would
521 ;; be no net loss if two or more objects were referenced]. The 3 insns can be
522 ;; reduced back to 2 if the size of the small data area were reduced to 32K
523 ;; [then seth + ld/st would work for any object in the area]. Doing this
524 ;; would require special handling of _SDA_BASE_ (its value would be
525 ;; (.sdata + 32K) & 0xffff0000) and reloc computations would be different
526 ;; [I think]. What to do about this is deferred until later and for now we
527 ;; require .sdata to be in the first 16M.
529 (define_expand "movsi_sda"
531 (unspec [(const_int 0)] 2))
532 (set (match_operand:SI 0 "register_operand" "")
533 (lo_sum:SI (match_dup 2)
534 (match_operand:SI 1 "small_data_operand" "")))]
538 if (reload_in_progress || reload_completed)
539 operands[2] = operands[0];
541 operands[2] = gen_reg_rtx (SImode);
544 (define_insn "*load_sda_base"
545 [(set (match_operand:SI 0 "register_operand" "=r")
546 (unspec [(const_int 0)] 2))]
548 "ld24 %0,#_SDA_BASE_"
549 [(set_attr "type" "int4")
550 (set_attr "length" "4")])
552 ;; 32 bit address support.
554 (define_expand "movsi_addr32"
556 ; addr32_operand isn't used because it's too restrictive,
557 ; seth_add3_operand is more general and thus safer.
558 (high:SI (match_operand:SI 1 "seth_add3_operand" "")))
559 (set (match_operand:SI 0 "register_operand" "")
560 (lo_sum:SI (match_dup 2) (match_dup 1)))]
564 if (reload_in_progress || reload_completed)
565 operands[2] = operands[0];
567 operands[2] = gen_reg_rtx (SImode);
570 (define_insn "set_hi_si"
571 [(set (match_operand:SI 0 "register_operand" "=r")
572 (high:SI (match_operand 1 "symbolic_operand" "")))]
574 "seth %0,%#shigh(%1)"
575 [(set_attr "type" "int4")
576 (set_attr "length" "4")])
578 (define_insn "lo_sum_si"
579 [(set (match_operand:SI 0 "register_operand" "=r")
580 (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
581 (match_operand:SI 2 "immediate_operand" "in")))]
584 [(set_attr "type" "int4")
585 (set_attr "length" "4")])
587 (define_expand "movdi"
588 [(set (match_operand:DI 0 "general_operand" "")
589 (match_operand:DI 1 "general_operand" ""))]
593 /* Everything except mem = const or mem = mem can be done easily. */
595 if (GET_CODE (operands[0]) == MEM)
596 operands[1] = force_reg (DImode, operands[1]);
599 (define_insn "*movdi_insn"
600 [(set (match_operand:DI 0 "move_dest_operand" "=r,r,r,r,m")
601 (match_operand:DI 1 "move_double_src_operand" "r,nG,F,m,r"))]
602 "register_operand (operands[0], DImode) || register_operand (operands[1], DImode)"
604 [(set_attr "type" "multi,multi,multi,load8,store8")
605 (set_attr "length" "4,4,16,6,6")])
608 [(set (match_operand:DI 0 "move_dest_operand" "")
609 (match_operand:DI 1 "move_double_src_operand" ""))]
612 "operands[2] = gen_split_move_double (operands);")
614 ;; Floating point move insns.
616 (define_expand "movsf"
617 [(set (match_operand:SF 0 "general_operand" "")
618 (match_operand:SF 1 "general_operand" ""))]
622 /* Everything except mem = const or mem = mem can be done easily. */
624 if (GET_CODE (operands[0]) == MEM)
625 operands[1] = force_reg (SFmode, operands[1]);
628 (define_insn "*movsf_insn"
629 [(set (match_operand:SF 0 "move_dest_operand" "=r,r,r,r,r,T,S,m")
630 (match_operand:SF 1 "move_src_operand" "r,F,U,S,m,r,r,r"))]
631 "register_operand (operands[0], SFmode) || register_operand (operands[1], SFmode)"
641 ;; ??? Length of alternative 1 is either 2, 4 or 8.
642 [(set_attr "type" "int2,multi,load2,load2,load4,store2,store2,store4")
643 (set_attr "length" "2,8,2,2,4,2,2,4")])
646 [(set (match_operand:SF 0 "register_operand" "")
647 (match_operand:SF 1 "const_double_operand" ""))]
649 [(set (match_dup 2) (match_dup 3))]
652 operands[2] = operand_subword (operands[0], 0, 0, SFmode);
653 operands[3] = operand_subword (operands[1], 0, 0, SFmode);
656 (define_expand "movdf"
657 [(set (match_operand:DF 0 "general_operand" "")
658 (match_operand:DF 1 "general_operand" ""))]
662 /* Everything except mem = const or mem = mem can be done easily. */
664 if (GET_CODE (operands[0]) == MEM)
665 operands[1] = force_reg (DFmode, operands[1]);
668 (define_insn "*movdf_insn"
669 [(set (match_operand:DF 0 "move_dest_operand" "=r,r,r,m")
670 (match_operand:DF 1 "move_double_src_operand" "r,F,m,r"))]
671 "register_operand (operands[0], DFmode) || register_operand (operands[1], DFmode)"
673 [(set_attr "type" "multi,multi,load8,store8")
674 (set_attr "length" "4,16,6,6")])
677 [(set (match_operand:DF 0 "move_dest_operand" "")
678 (match_operand:DF 1 "move_double_src_operand" ""))]
681 "operands[2] = gen_split_move_double (operands);")
683 ;; Zero extension instructions.
685 (define_insn "zero_extendqihi2"
686 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
687 (zero_extend:HI (match_operand:QI 1 "extend_operand" "r,T,m")))]
693 [(set_attr "type" "int4,load2,load4")
694 (set_attr "length" "4,2,4")])
696 (define_insn "zero_extendqisi2"
697 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
698 (zero_extend:SI (match_operand:QI 1 "extend_operand" "r,T,m")))]
704 [(set_attr "type" "int4,load2,load4")
705 (set_attr "length" "4,2,4")])
707 (define_insn "zero_extendhisi2"
708 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
709 (zero_extend:SI (match_operand:HI 1 "extend_operand" "r,T,m")))]
715 [(set_attr "type" "int4,load2,load4")
716 (set_attr "length" "4,2,4")])
718 ;; Signed conversions from a smaller integer to a larger integer
719 (define_insn "extendqihi2"
720 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
721 (sign_extend:HI (match_operand:QI 1 "extend_operand" "0,T,m")))]
727 [(set_attr "type" "multi,load2,load4")
728 (set_attr "length" "2,2,4")])
731 [(set (match_operand:HI 0 "register_operand" "")
732 (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
738 rtx op0 = gen_lowpart (SImode, operands[0]);
739 rtx shift = gen_rtx (CONST_INT, VOIDmode, 24);
741 operands[2] = gen_ashlsi3 (op0, op0, shift);
742 operands[3] = gen_ashrsi3 (op0, op0, shift);
745 (define_insn "extendqisi2"
746 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
747 (sign_extend:SI (match_operand:QI 1 "extend_operand" "0,T,m")))]
753 [(set_attr "type" "multi,load2,load4")
754 (set_attr "length" "4,2,4")])
757 [(set (match_operand:SI 0 "register_operand" "")
758 (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
764 rtx op0 = gen_lowpart (SImode, operands[0]);
765 rtx shift = gen_rtx (CONST_INT, VOIDmode, 24);
767 operands[2] = gen_ashlsi3 (op0, op0, shift);
768 operands[3] = gen_ashrsi3 (op0, op0, shift);
771 (define_insn "extendhisi2"
772 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
773 (sign_extend:SI (match_operand:HI 1 "extend_operand" "0,T,m")))]
779 [(set_attr "type" "multi,load2,load4")
780 (set_attr "length" "4,2,4")])
783 [(set (match_operand:SI 0 "register_operand" "")
784 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
790 rtx op0 = gen_lowpart (SImode, operands[0]);
791 rtx shift = gen_rtx (CONST_INT, VOIDmode, 16);
793 operands[2] = gen_ashlsi3 (op0, op0, shift);
794 operands[3] = gen_ashrsi3 (op0, op0, shift);
797 ;; Arithmetic instructions.
799 ; ??? Adding an alternative to split add3 of small constants into two
800 ; insns yields better instruction packing but slower code. Adds of small
801 ; values is done a lot.
803 (define_insn "addsi3"
804 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
805 (plus:SI (match_operand:SI 1 "register_operand" "%0,0,r")
806 (match_operand:SI 2 "nonmemory_operand" "r,I,J")))]
812 [(set_attr "type" "int2,int2,int4")
813 (set_attr "length" "2,2,4")])
816 ; [(set (match_operand:SI 0 "register_operand" "")
817 ; (plus:SI (match_operand:SI 1 "register_operand" "")
818 ; (match_operand:SI 2 "int8_operand" "")))]
820 ; && REGNO (operands[0]) != REGNO (operands[1])
821 ; && INT8_P (INTVAL (operands[2]))
822 ; && INTVAL (operands[2]) != 0"
823 ; [(set (match_dup 0) (match_dup 1))
824 ; (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
827 (define_insn "adddi3"
828 [(set (match_operand:DI 0 "register_operand" "=r")
829 (plus:DI (match_operand:DI 1 "register_operand" "%0")
830 (match_operand:DI 2 "register_operand" "r")))
831 (clobber (reg:SI 17))]
834 [(set_attr "type" "multi")
835 (set_attr "length" "6")])
837 ;; ??? The cmp clears the condition bit. Can we speed up somehow?
839 [(set (match_operand:DI 0 "register_operand" "")
840 (plus:DI (match_operand:DI 1 "register_operand" "")
841 (match_operand:DI 2 "register_operand" "")))
842 (clobber (match_operand 3 "" ""))]
844 [(parallel [(set (match_dup 3)
846 (use (match_dup 4))])
847 (parallel [(set (match_dup 4)
848 (plus:SI (match_dup 4)
849 (plus:SI (match_dup 5)
852 (unspec [(const_int 0)] 3))])
853 (parallel [(set (match_dup 6)
854 (plus:SI (match_dup 6)
855 (plus:SI (match_dup 7)
858 (unspec [(const_int 0)] 3))])]
861 operands[4] = operand_subword (operands[0], (WORDS_BIG_ENDIAN != 0), 0, DImode);
862 operands[5] = operand_subword (operands[2], (WORDS_BIG_ENDIAN != 0), 0, DImode);
863 operands[6] = operand_subword (operands[0], (WORDS_BIG_ENDIAN == 0), 0, DImode);
864 operands[7] = operand_subword (operands[2], (WORDS_BIG_ENDIAN == 0), 0, DImode);
867 (define_insn "*clear_c"
870 (use (match_operand:SI 0 "register_operand" "r"))]
873 [(set_attr "type" "int2")
874 (set_attr "length" "2")])
876 (define_insn "*add_carry"
877 [(set (match_operand:SI 0 "register_operand" "=r")
878 (plus:SI (match_operand:SI 1 "register_operand" "%0")
879 (plus:SI (match_operand:SI 2 "register_operand" "r")
882 (unspec [(const_int 0)] 3))]
885 [(set_attr "type" "int2")
886 (set_attr "length" "2")])
888 (define_insn "subsi3"
889 [(set (match_operand:SI 0 "register_operand" "=r")
890 (minus:SI (match_operand:SI 1 "register_operand" "0")
891 (match_operand:SI 2 "register_operand" "r")))]
894 [(set_attr "type" "int2")
895 (set_attr "length" "2")])
897 (define_insn "subdi3"
898 [(set (match_operand:DI 0 "register_operand" "=r")
899 (minus:DI (match_operand:DI 1 "register_operand" "0")
900 (match_operand:DI 2 "register_operand" "r")))
901 (clobber (reg:SI 17))]
904 [(set_attr "type" "multi")
905 (set_attr "length" "6")])
907 ;; ??? The cmp clears the condition bit. Can we speed up somehow?
909 [(set (match_operand:DI 0 "register_operand" "")
910 (minus:DI (match_operand:DI 1 "register_operand" "")
911 (match_operand:DI 2 "register_operand" "")))
912 (clobber (match_operand 3 "" ""))]
914 [(parallel [(set (match_dup 3)
916 (use (match_dup 4))])
917 (parallel [(set (match_dup 4)
918 (minus:SI (match_dup 4)
919 (minus:SI (match_dup 5)
922 (unspec [(const_int 0)] 3))])
923 (parallel [(set (match_dup 6)
924 (minus:SI (match_dup 6)
925 (minus:SI (match_dup 7)
928 (unspec [(const_int 0)] 3))])]
931 operands[4] = operand_subword (operands[0], (WORDS_BIG_ENDIAN != 0), 0, DImode);
932 operands[5] = operand_subword (operands[2], (WORDS_BIG_ENDIAN != 0), 0, DImode);
933 operands[6] = operand_subword (operands[0], (WORDS_BIG_ENDIAN == 0), 0, DImode);
934 operands[7] = operand_subword (operands[2], (WORDS_BIG_ENDIAN == 0), 0, DImode);
937 (define_insn "*sub_carry"
938 [(set (match_operand:SI 0 "register_operand" "=r")
939 (minus:SI (match_operand:SI 1 "register_operand" "%0")
940 (minus:SI (match_operand:SI 2 "register_operand" "r")
943 (unspec [(const_int 0)] 3))]
946 [(set_attr "type" "int2")
947 (set_attr "length" "2")])
949 ; Multiply/Divide instructions.
951 (define_insn "mulhisi3"
952 [(set (match_operand:SI 0 "register_operand" "=r")
953 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "r"))
954 (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
956 "mullo %1,%2\;mvfacmi %0"
957 [(set_attr "type" "multi")
958 (set_attr "length" "4")])
960 (define_insn "mulsi3"
961 [(set (match_operand:SI 0 "register_operand" "=r")
962 (mult:SI (match_operand:SI 1 "register_operand" "%0")
963 (match_operand:SI 2 "register_operand" "r")))]
966 [(set_attr "type" "mul2")
967 (set_attr "length" "2")])
969 (define_insn "divsi3"
970 [(set (match_operand:SI 0 "register_operand" "=r")
971 (div:SI (match_operand:SI 1 "register_operand" "0")
972 (match_operand:SI 2 "register_operand" "r")))]
975 [(set_attr "type" "div4")
976 (set_attr "length" "4")])
978 (define_insn "udivsi3"
979 [(set (match_operand:SI 0 "register_operand" "=r")
980 (udiv:SI (match_operand:SI 1 "register_operand" "0")
981 (match_operand:SI 2 "register_operand" "r")))]
984 [(set_attr "type" "div4")
985 (set_attr "length" "4")])
987 (define_insn "modsi3"
988 [(set (match_operand:SI 0 "register_operand" "=r")
989 (mod:SI (match_operand:SI 1 "register_operand" "0")
990 (match_operand:SI 2 "register_operand" "r")))]
993 [(set_attr "type" "div4")
994 (set_attr "length" "4")])
996 (define_insn "umodsi3"
997 [(set (match_operand:SI 0 "register_operand" "=r")
998 (umod:SI (match_operand:SI 1 "register_operand" "0")
999 (match_operand:SI 2 "register_operand" "r")))]
1002 [(set_attr "type" "div4")
1003 (set_attr "length" "4")])
1005 ;; Boolean instructions.
1007 ;; We don't define the DImode versions as expand_binop does a good enough job.
1008 ;; And if it doesn't it should be fixed.
1010 (define_insn "andsi3"
1011 [(set (match_operand:SI 0 "register_operand" "=r,r")
1012 (and:SI (match_operand:SI 1 "register_operand" "%0,r")
1013 (match_operand:SI 2 "reg_or_uint16_operand" "r,K")))]
1017 /* If we are worried about space, see if we can break this up into two
1018 short instructions, which might eliminate a NOP being inserted. */
1020 && m32r_not_same_reg (operands[0], operands[1])
1021 && GET_CODE (operands[2]) == CONST_INT
1022 && INT8_P (INTVAL (operands[2])))
1025 else if (GET_CODE (operands[2]) == CONST_INT)
1026 return \"and3 %0,%1,%#%X2\";
1028 return \"and %0,%2\";
1030 [(set_attr "type" "int2,int4")
1031 (set_attr "length" "2,4")])
1034 [(set (match_operand:SI 0 "register_operand" "")
1035 (and:SI (match_operand:SI 1 "register_operand" "")
1036 (match_operand:SI 2 "int8_operand" "")))]
1037 "optimize_size && m32r_not_same_reg (operands[0], operands[1])"
1038 [(set (match_dup 0) (match_dup 2))
1039 (set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))]
1042 (define_insn "iorsi3"
1043 [(set (match_operand:SI 0 "register_operand" "=r,r")
1044 (ior:SI (match_operand:SI 1 "register_operand" "%0,r")
1045 (match_operand:SI 2 "reg_or_uint16_operand" "r,K")))]
1049 /* If we are worried about space, see if we can break this up into two
1050 short instructions, which might eliminate a NOP being inserted. */
1052 && m32r_not_same_reg (operands[0], operands[1])
1053 && GET_CODE (operands[2]) == CONST_INT
1054 && INT8_P (INTVAL (operands[2])))
1057 else if (GET_CODE (operands[2]) == CONST_INT)
1058 return \"or3 %0,%1,%#%X2\";
1060 return \"or %0,%2\";
1062 [(set_attr "type" "int2,int4")
1063 (set_attr "length" "2,4")])
1066 [(set (match_operand:SI 0 "register_operand" "")
1067 (ior:SI (match_operand:SI 1 "register_operand" "")
1068 (match_operand:SI 2 "int8_operand" "")))]
1069 "optimize_size && m32r_not_same_reg (operands[0], operands[1])"
1070 [(set (match_dup 0) (match_dup 2))
1071 (set (match_dup 0) (ior:SI (match_dup 0) (match_dup 1)))]
1074 (define_insn "xorsi3"
1075 [(set (match_operand:SI 0 "register_operand" "=r,r")
1076 (xor:SI (match_operand:SI 1 "register_operand" "%0,r")
1077 (match_operand:SI 2 "reg_or_uint16_operand" "r,K")))]
1081 /* If we are worried about space, see if we can break this up into two
1082 short instructions, which might eliminate a NOP being inserted. */
1084 && m32r_not_same_reg (operands[0], operands[1])
1085 && GET_CODE (operands[2]) == CONST_INT
1086 && INT8_P (INTVAL (operands[2])))
1089 else if (GET_CODE (operands[2]) == CONST_INT)
1090 return \"xor3 %0,%1,%#%X2\";
1092 return \"xor %0,%2\";
1094 [(set_attr "type" "int2,int4")
1095 (set_attr "length" "2,4")])
1098 [(set (match_operand:SI 0 "register_operand" "")
1099 (xor:SI (match_operand:SI 1 "register_operand" "")
1100 (match_operand:SI 2 "int8_operand" "")))]
1101 "optimize_size && m32r_not_same_reg (operands[0], operands[1])"
1102 [(set (match_dup 0) (match_dup 2))
1103 (set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))]
1106 (define_insn "negsi2"
1107 [(set (match_operand:SI 0 "register_operand" "=r")
1108 (neg:SI (match_operand:SI 1 "register_operand" "r")))]
1111 [(set_attr "type" "int2")
1112 (set_attr "length" "2")])
1114 (define_insn "one_cmplsi2"
1115 [(set (match_operand:SI 0 "register_operand" "=r")
1116 (not:SI (match_operand:SI 1 "register_operand" "r")))]
1119 [(set_attr "type" "int2")
1120 (set_attr "length" "2")])
1122 ;; Shift instructions.
1124 (define_insn "ashlsi3"
1125 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1126 (ashift:SI (match_operand:SI 1 "register_operand" "0,0,r")
1127 (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))]
1133 [(set_attr "type" "shift2,shift2,shift4")
1134 (set_attr "length" "2,2,4")])
1136 (define_insn "ashrsi3"
1137 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1138 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r")
1139 (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))]
1145 [(set_attr "type" "shift2,shift2,shift4")
1146 (set_attr "length" "2,2,4")])
1148 (define_insn "lshrsi3"
1149 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1150 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r")
1151 (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))]
1157 [(set_attr "type" "shift2,shift2,shift4")
1158 (set_attr "length" "2,2,4")])
1160 ;; Compare instructions.
1161 ;; This controls RTL generation and register allocation.
1163 ;; We generate RTL for comparisons and branches by having the cmpxx
1164 ;; patterns store away the operands. Then the bcc patterns
1165 ;; emit RTL for both the compare and the branch.
1167 ;; On the m32r it is more efficient to use the bxxz instructions and
1168 ;; thus merge the compare and branch into one instruction, so they are
1171 (define_expand "cmpsi"
1173 (compare:CC (match_operand:SI 0 "register_operand" "")
1174 (match_operand:SI 1 "reg_or_cmp_int16_operand" "")))]
1178 m32r_compare_op0 = operands[0];
1179 m32r_compare_op1 = operands[1];
1183 (define_insn "cmp_eqsi_zero_insn"
1185 (eq:SI (match_operand:SI 0 "register_operand" "r,r")
1186 (match_operand:SI 1 "reg_or_zero_operand" "r,P")))]
1187 "TARGET_M32RX || TARGET_M32R2"
1191 [(set_attr "type" "int4")
1192 (set_attr "length" "4")])
1194 ;; The cmp_xxx_insn patterns set the condition bit to the result of the
1195 ;; comparison. There isn't a "compare equal" instruction so cmp_eqsi_insn
1196 ;; is quite inefficient. However, it is rarely used.
1198 (define_insn "cmp_eqsi_insn"
1200 (eq:SI (match_operand:SI 0 "register_operand" "r,r")
1201 (match_operand:SI 1 "reg_or_cmp_int16_operand" "r,P")))
1202 (clobber (match_scratch:SI 2 "=&r,&r"))]
1206 if (which_alternative == 0)
1208 return \"mv %2,%0\;sub %2,%1\;cmpui %2,#1\";
1212 if (INTVAL (operands [1]) == 0)
1213 return \"cmpui %0, #1\";
1214 else if (REGNO (operands [2]) == REGNO (operands [0]))
1215 return \"addi %0,%#%N1\;cmpui %2,#1\";
1217 return \"add3 %2,%0,%#%N1\;cmpui %2,#1\";
1220 [(set_attr "type" "multi,multi")
1221 (set_attr "length" "8,8")])
1223 (define_insn "cmp_ltsi_insn"
1225 (lt:SI (match_operand:SI 0 "register_operand" "r,r")
1226 (match_operand:SI 1 "reg_or_int16_operand" "r,J")))]
1231 [(set_attr "type" "int2,int4")
1232 (set_attr "length" "2,4")])
1234 (define_insn "cmp_ltusi_insn"
1236 (ltu:SI (match_operand:SI 0 "register_operand" "r,r")
1237 (match_operand:SI 1 "reg_or_int16_operand" "r,J")))]
1242 [(set_attr "type" "int2,int4")
1243 (set_attr "length" "2,4")])
1245 ;; These control RTL generation for conditional jump insns.
1247 (define_expand "beq"
1249 (if_then_else (match_dup 1)
1250 (label_ref (match_operand 0 "" ""))
1255 operands[1] = gen_compare (EQ, m32r_compare_op0, m32r_compare_op1, FALSE);
1258 (define_expand "bne"
1260 (if_then_else (match_dup 1)
1261 (label_ref (match_operand 0 "" ""))
1266 operands[1] = gen_compare (NE, m32r_compare_op0, m32r_compare_op1, FALSE);
1269 (define_expand "bgt"
1271 (if_then_else (match_dup 1)
1272 (label_ref (match_operand 0 "" ""))
1277 operands[1] = gen_compare (GT, m32r_compare_op0, m32r_compare_op1, FALSE);
1280 (define_expand "ble"
1282 (if_then_else (match_dup 1)
1283 (label_ref (match_operand 0 "" ""))
1288 operands[1] = gen_compare (LE, m32r_compare_op0, m32r_compare_op1, FALSE);
1291 (define_expand "bge"
1293 (if_then_else (match_dup 1)
1294 (label_ref (match_operand 0 "" ""))
1299 operands[1] = gen_compare (GE, m32r_compare_op0, m32r_compare_op1, FALSE);
1302 (define_expand "blt"
1304 (if_then_else (match_dup 1)
1305 (label_ref (match_operand 0 "" ""))
1310 operands[1] = gen_compare (LT, m32r_compare_op0, m32r_compare_op1, FALSE);
1313 (define_expand "bgtu"
1315 (if_then_else (match_dup 1)
1316 (label_ref (match_operand 0 "" ""))
1321 operands[1] = gen_compare (GTU, m32r_compare_op0, m32r_compare_op1, FALSE);
1324 (define_expand "bleu"
1326 (if_then_else (match_dup 1)
1327 (label_ref (match_operand 0 "" ""))
1332 operands[1] = gen_compare (LEU, m32r_compare_op0, m32r_compare_op1, FALSE);
1335 (define_expand "bgeu"
1337 (if_then_else (match_dup 1)
1338 (label_ref (match_operand 0 "" ""))
1343 operands[1] = gen_compare (GEU, m32r_compare_op0, m32r_compare_op1, FALSE);
1346 (define_expand "bltu"
1348 (if_then_else (match_dup 1)
1349 (label_ref (match_operand 0 "" ""))
1354 operands[1] = gen_compare (LTU, m32r_compare_op0, m32r_compare_op1, FALSE);
1357 ;; Now match both normal and inverted jump.
1359 (define_insn "*branch_insn"
1361 (if_then_else (match_operator 1 "eqne_comparison_operator"
1362 [(reg 17) (const_int 0)])
1363 (label_ref (match_operand 0 "" ""))
1368 static char instruction[40];
1369 sprintf (instruction, \"%s%s %%l0\",
1370 (GET_CODE (operands[1]) == NE) ? \"bc\" : \"bnc\",
1371 (get_attr_length (insn) == 2) ? \".s\" : \"\");
1374 [(set_attr "type" "branch")
1375 ; We use 400/800 instead of 512,1024 to account for inaccurate insn
1376 ; lengths and insn alignments that are complex to track.
1377 ; It's not important that we be hyper-precise here. It may be more
1378 ; important blah blah blah when the chip supports parallel execution
1379 ; blah blah blah but until then blah blah blah this is simple and
1381 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1387 (define_insn "*rev_branch_insn"
1389 (if_then_else (match_operator 1 "eqne_comparison_operator"
1390 [(reg 17) (const_int 0)])
1392 (label_ref (match_operand 0 "" ""))))]
1393 ;"REVERSIBLE_CC_MODE (GET_MODE (XEXP (operands[1], 0)))"
1397 static char instruction[40];
1398 sprintf (instruction, \"%s%s %%l0\",
1399 (GET_CODE (operands[1]) == EQ) ? \"bc\" : \"bnc\",
1400 (get_attr_length (insn) == 2) ? \".s\" : \"\");
1403 [(set_attr "type" "branch")
1404 ; We use 400/800 instead of 512,1024 to account for inaccurate insn
1405 ; lengths and insn alignments that are complex to track.
1406 ; It's not important that we be hyper-precise here. It may be more
1407 ; important blah blah blah when the chip supports parallel execution
1408 ; blah blah blah but until then blah blah blah this is simple and
1410 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1416 ; reg/reg compare and branch insns
1418 (define_insn "*reg_branch_insn"
1420 (if_then_else (match_operator 1 "eqne_comparison_operator"
1421 [(match_operand:SI 2 "register_operand" "r")
1422 (match_operand:SI 3 "register_operand" "r")])
1423 (label_ref (match_operand 0 "" ""))
1428 /* Is branch target reachable with beq/bne? */
1429 if (get_attr_length (insn) == 4)
1431 if (GET_CODE (operands[1]) == EQ)
1432 return \"beq %2,%3,%l0\";
1434 return \"bne %2,%3,%l0\";
1438 if (GET_CODE (operands[1]) == EQ)
1439 return \"bne %2,%3,1f\;bra %l0\;1:\";
1441 return \"beq %2,%3,1f\;bra %l0\;1:\";
1444 [(set_attr "type" "branch")
1445 ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1446 ; which is complex to track and inaccurate length specs.
1447 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1453 (define_insn "*rev_reg_branch_insn"
1455 (if_then_else (match_operator 1 "eqne_comparison_operator"
1456 [(match_operand:SI 2 "register_operand" "r")
1457 (match_operand:SI 3 "register_operand" "r")])
1459 (label_ref (match_operand 0 "" ""))))]
1463 /* Is branch target reachable with beq/bne? */
1464 if (get_attr_length (insn) == 4)
1466 if (GET_CODE (operands[1]) == NE)
1467 return \"beq %2,%3,%l0\";
1469 return \"bne %2,%3,%l0\";
1473 if (GET_CODE (operands[1]) == NE)
1474 return \"bne %2,%3,1f\;bra %l0\;1:\";
1476 return \"beq %2,%3,1f\;bra %l0\;1:\";
1479 [(set_attr "type" "branch")
1480 ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1481 ; which is complex to track and inaccurate length specs.
1482 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1488 ; reg/zero compare and branch insns
1490 (define_insn "*zero_branch_insn"
1492 (if_then_else (match_operator 1 "signed_comparison_operator"
1493 [(match_operand:SI 2 "register_operand" "r")
1495 (label_ref (match_operand 0 "" ""))
1500 const char *br,*invbr;
1503 switch (GET_CODE (operands[1]))
1505 case EQ : br = \"eq\"; invbr = \"ne\"; break;
1506 case NE : br = \"ne\"; invbr = \"eq\"; break;
1507 case LE : br = \"le\"; invbr = \"gt\"; break;
1508 case GT : br = \"gt\"; invbr = \"le\"; break;
1509 case LT : br = \"lt\"; invbr = \"ge\"; break;
1510 case GE : br = \"ge\"; invbr = \"lt\"; break;
1515 /* Is branch target reachable with bxxz? */
1516 if (get_attr_length (insn) == 4)
1518 sprintf (asmtext, \"b%sz %%2,%%l0\", br);
1519 output_asm_insn (asmtext, operands);
1523 sprintf (asmtext, \"b%sz %%2,1f\;bra %%l0\;1:\", invbr);
1524 output_asm_insn (asmtext, operands);
1528 [(set_attr "type" "branch")
1529 ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1530 ; which is complex to track and inaccurate length specs.
1531 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1537 (define_insn "*rev_zero_branch_insn"
1539 (if_then_else (match_operator 1 "eqne_comparison_operator"
1540 [(match_operand:SI 2 "register_operand" "r")
1543 (label_ref (match_operand 0 "" ""))))]
1547 const char *br,*invbr;
1550 switch (GET_CODE (operands[1]))
1552 case EQ : br = \"eq\"; invbr = \"ne\"; break;
1553 case NE : br = \"ne\"; invbr = \"eq\"; break;
1554 case LE : br = \"le\"; invbr = \"gt\"; break;
1555 case GT : br = \"gt\"; invbr = \"le\"; break;
1556 case LT : br = \"lt\"; invbr = \"ge\"; break;
1557 case GE : br = \"ge\"; invbr = \"lt\"; break;
1562 /* Is branch target reachable with bxxz? */
1563 if (get_attr_length (insn) == 4)
1565 sprintf (asmtext, \"b%sz %%2,%%l0\", invbr);
1566 output_asm_insn (asmtext, operands);
1570 sprintf (asmtext, \"b%sz %%2,1f\;bra %%l0\;1:\", br);
1571 output_asm_insn (asmtext, operands);
1575 [(set_attr "type" "branch")
1576 ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1577 ; which is complex to track and inaccurate length specs.
1578 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1584 ;; S<cc> operations to set a register to 1/0 based on a comparison
1586 (define_expand "seq"
1587 [(match_operand:SI 0 "register_operand" "")]
1591 rtx op0 = operands[0];
1592 rtx op1 = m32r_compare_op0;
1593 rtx op2 = m32r_compare_op1;
1594 enum machine_mode mode = GET_MODE (op0);
1599 if (! register_operand (op1, mode))
1600 op1 = force_reg (mode, op1);
1602 if (TARGET_M32RX || TARGET_M32R2)
1604 if (! reg_or_zero_operand (op2, mode))
1605 op2 = force_reg (mode, op2);
1607 emit_insn (gen_seq_insn_m32rx (op0, op1, op2));
1610 if (GET_CODE (op2) == CONST_INT && INTVAL (op2) == 0)
1612 emit_insn (gen_seq_zero_insn (op0, op1));
1616 if (! reg_or_eq_int16_operand (op2, mode))
1617 op2 = force_reg (mode, op2);
1619 emit_insn (gen_seq_insn (op0, op1, op2));
1623 (define_insn "seq_insn_m32rx"
1624 [(set (match_operand:SI 0 "register_operand" "=r")
1625 (eq:SI (match_operand:SI 1 "register_operand" "%r")
1626 (match_operand:SI 2 "reg_or_zero_operand" "rP")))
1627 (clobber (reg:SI 17))]
1628 "TARGET_M32RX || TARGET_M32R2"
1630 [(set_attr "type" "multi")
1631 (set_attr "length" "6")])
1634 [(set (match_operand:SI 0 "register_operand" "")
1635 (eq:SI (match_operand:SI 1 "register_operand" "")
1636 (match_operand:SI 2 "reg_or_zero_operand" "")))
1637 (clobber (reg:SI 17))]
1638 "TARGET_M32RX || TARGET_M32R2"
1640 (eq:SI (match_dup 1)
1646 (define_insn "seq_zero_insn"
1647 [(set (match_operand:SI 0 "register_operand" "=r")
1648 (eq:SI (match_operand:SI 1 "register_operand" "r")
1650 (clobber (reg:SI 17))]
1653 [(set_attr "type" "multi")
1654 (set_attr "length" "6")])
1657 [(set (match_operand:SI 0 "register_operand" "")
1658 (eq:SI (match_operand:SI 1 "register_operand" "")
1660 (clobber (reg:SI 17))]
1665 rtx op0 = operands[0];
1666 rtx op1 = operands[1];
1669 emit_insn (gen_cmp_ltusi_insn (op1, GEN_INT (1)));
1670 emit_insn (gen_movcc_insn (op0));
1671 operands[3] = get_insns ();
1675 (define_insn "seq_insn"
1676 [(set (match_operand:SI 0 "register_operand" "=r,r,??r,r")
1677 (eq:SI (match_operand:SI 1 "register_operand" "r,r,r,r")
1678 (match_operand:SI 2 "reg_or_eq_int16_operand" "r,r,r,PK")))
1679 (clobber (reg:SI 17))
1680 (clobber (match_scratch:SI 3 "=1,2,&r,r"))]
1683 [(set_attr "type" "multi")
1684 (set_attr "length" "8,8,10,10")])
1687 [(set (match_operand:SI 0 "register_operand" "")
1688 (eq:SI (match_operand:SI 1 "register_operand" "")
1689 (match_operand:SI 2 "reg_or_eq_int16_operand" "")))
1690 (clobber (reg:SI 17))
1691 (clobber (match_scratch:SI 3 ""))]
1692 "TARGET_M32R && reload_completed"
1696 rtx op0 = operands[0];
1697 rtx op1 = operands[1];
1698 rtx op2 = operands[2];
1699 rtx op3 = operands[3];
1700 HOST_WIDE_INT value;
1702 if (GET_CODE (op2) == REG && GET_CODE (op3) == REG
1703 && REGNO (op2) == REGNO (op3))
1710 if (GET_CODE (op1) == REG && GET_CODE (op3) == REG
1711 && REGNO (op1) != REGNO (op3))
1713 emit_move_insn (op3, op1);
1717 if (GET_CODE (op2) == CONST_INT && (value = INTVAL (op2)) != 0
1718 && CMP_INT16_P (value))
1719 emit_insn (gen_addsi3 (op3, op1, GEN_INT (-value)));
1721 emit_insn (gen_xorsi3 (op3, op1, op2));
1723 emit_insn (gen_cmp_ltusi_insn (op3, GEN_INT (1)));
1724 emit_insn (gen_movcc_insn (op0));
1725 operands[4] = get_insns ();
1729 (define_expand "sne"
1730 [(match_operand:SI 0 "register_operand" "")]
1734 rtx op0 = operands[0];
1735 rtx op1 = m32r_compare_op0;
1736 rtx op2 = m32r_compare_op1;
1737 enum machine_mode mode = GET_MODE (op0);
1742 if (GET_CODE (op2) != CONST_INT
1743 || (INTVAL (op2) != 0 && UINT16_P (INTVAL (op2))))
1747 if (reload_completed || reload_in_progress)
1750 reg = gen_reg_rtx (SImode);
1751 emit_insn (gen_xorsi3 (reg, op1, op2));
1754 if (! register_operand (op1, mode))
1755 op1 = force_reg (mode, op1);
1757 emit_insn (gen_sne_zero_insn (op0, op1));
1764 (define_insn "sne_zero_insn"
1765 [(set (match_operand:SI 0 "register_operand" "=r")
1766 (ne:SI (match_operand:SI 1 "register_operand" "r")
1768 (clobber (reg:SI 17))
1769 (clobber (match_scratch:SI 2 "=&r"))]
1772 [(set_attr "type" "multi")
1773 (set_attr "length" "6")])
1776 [(set (match_operand:SI 0 "register_operand" "")
1777 (ne:SI (match_operand:SI 1 "register_operand" "")
1779 (clobber (reg:SI 17))
1780 (clobber (match_scratch:SI 2 ""))]
1785 (ltu:SI (match_dup 2)
1791 (define_expand "slt"
1792 [(match_operand:SI 0 "register_operand" "")]
1796 rtx op0 = operands[0];
1797 rtx op1 = m32r_compare_op0;
1798 rtx op2 = m32r_compare_op1;
1799 enum machine_mode mode = GET_MODE (op0);
1804 if (! register_operand (op1, mode))
1805 op1 = force_reg (mode, op1);
1807 if (! reg_or_int16_operand (op2, mode))
1808 op2 = force_reg (mode, op2);
1810 emit_insn (gen_slt_insn (op0, op1, op2));
1814 (define_insn "slt_insn"
1815 [(set (match_operand:SI 0 "register_operand" "=r,r")
1816 (lt:SI (match_operand:SI 1 "register_operand" "r,r")
1817 (match_operand:SI 2 "reg_or_int16_operand" "r,J")))
1818 (clobber (reg:SI 17))]
1821 [(set_attr "type" "multi")
1822 (set_attr "length" "4,6")])
1825 [(set (match_operand:SI 0 "register_operand" "")
1826 (lt:SI (match_operand:SI 1 "register_operand" "")
1827 (match_operand:SI 2 "reg_or_int16_operand" "")))
1828 (clobber (reg:SI 17))]
1831 (lt:SI (match_dup 1)
1837 (define_expand "sle"
1838 [(match_operand:SI 0 "register_operand" "")]
1842 rtx op0 = operands[0];
1843 rtx op1 = m32r_compare_op0;
1844 rtx op2 = m32r_compare_op1;
1845 enum machine_mode mode = GET_MODE (op0);
1850 if (! register_operand (op1, mode))
1851 op1 = force_reg (mode, op1);
1853 if (GET_CODE (op2) == CONST_INT)
1855 HOST_WIDE_INT value = INTVAL (op2);
1856 if (value >= 2147483647)
1858 emit_move_insn (op0, GEN_INT (1));
1862 op2 = GEN_INT (value+1);
1863 if (value < -32768 || value >= 32767)
1864 op2 = force_reg (mode, op2);
1866 emit_insn (gen_slt_insn (op0, op1, op2));
1870 if (! register_operand (op2, mode))
1871 op2 = force_reg (mode, op2);
1873 emit_insn (gen_sle_insn (op0, op1, op2));
1877 (define_insn "sle_insn"
1878 [(set (match_operand:SI 0 "register_operand" "=r")
1879 (le:SI (match_operand:SI 1 "register_operand" "r")
1880 (match_operand:SI 2 "register_operand" "r")))
1881 (clobber (reg:SI 17))]
1884 [(set_attr "type" "multi")
1885 (set_attr "length" "8")])
1888 [(set (match_operand:SI 0 "register_operand" "")
1889 (le:SI (match_operand:SI 1 "register_operand" "")
1890 (match_operand:SI 2 "register_operand" "")))
1891 (clobber (reg:SI 17))]
1894 (lt:SI (match_dup 2)
1899 (xor:SI (match_dup 0)
1903 ;; If optimizing for space, use -(reg - 1) to invert the comparison rather than
1904 ;; xor reg,reg,1 which might eliminate a NOP being inserted.
1906 [(set (match_operand:SI 0 "register_operand" "")
1907 (le:SI (match_operand:SI 1 "register_operand" "")
1908 (match_operand:SI 2 "register_operand" "")))
1909 (clobber (reg:SI 17))]
1912 (lt:SI (match_dup 2)
1917 (plus:SI (match_dup 0)
1920 (neg:SI (match_dup 0)))]
1923 (define_expand "sgt"
1924 [(match_operand:SI 0 "register_operand" "")]
1928 rtx op0 = operands[0];
1929 rtx op1 = m32r_compare_op0;
1930 rtx op2 = m32r_compare_op1;
1931 enum machine_mode mode = GET_MODE (op0);
1936 if (! register_operand (op1, mode))
1937 op1 = force_reg (mode, op1);
1939 if (! register_operand (op2, mode))
1940 op2 = force_reg (mode, op2);
1942 emit_insn (gen_slt_insn (op0, op2, op1));
1946 (define_expand "sge"
1947 [(match_operand:SI 0 "register_operand" "")]
1951 rtx op0 = operands[0];
1952 rtx op1 = m32r_compare_op0;
1953 rtx op2 = m32r_compare_op1;
1954 enum machine_mode mode = GET_MODE (op0);
1959 if (! register_operand (op1, mode))
1960 op1 = force_reg (mode, op1);
1962 if (! reg_or_int16_operand (op2, mode))
1963 op2 = force_reg (mode, op2);
1965 emit_insn (gen_sge_insn (op0, op1, op2));
1969 (define_insn "sge_insn"
1970 [(set (match_operand:SI 0 "register_operand" "=r,r")
1971 (ge:SI (match_operand:SI 1 "register_operand" "r,r")
1972 (match_operand:SI 2 "reg_or_int16_operand" "r,J")))
1973 (clobber (reg:SI 17))]
1976 [(set_attr "type" "multi")
1977 (set_attr "length" "8,10")])
1980 [(set (match_operand:SI 0 "register_operand" "")
1981 (ge:SI (match_operand:SI 1 "register_operand" "")
1982 (match_operand:SI 2 "reg_or_int16_operand" "")))
1983 (clobber (reg:SI 17))]
1986 (lt:SI (match_dup 1)
1991 (xor:SI (match_dup 0)
1995 ;; If optimizing for space, use -(reg - 1) to invert the comparison rather than
1996 ;; xor reg,reg,1 which might eliminate a NOP being inserted.
1998 [(set (match_operand:SI 0 "register_operand" "")
1999 (ge:SI (match_operand:SI 1 "register_operand" "")
2000 (match_operand:SI 2 "reg_or_int16_operand" "")))
2001 (clobber (reg:SI 17))]
2004 (lt:SI (match_dup 1)
2009 (plus:SI (match_dup 0)
2012 (neg:SI (match_dup 0)))]
2015 (define_expand "sltu"
2016 [(match_operand:SI 0 "register_operand" "")]
2020 rtx op0 = operands[0];
2021 rtx op1 = m32r_compare_op0;
2022 rtx op2 = m32r_compare_op1;
2023 enum machine_mode mode = GET_MODE (op0);
2028 if (! register_operand (op1, mode))
2029 op1 = force_reg (mode, op1);
2031 if (! reg_or_int16_operand (op2, mode))
2032 op2 = force_reg (mode, op2);
2034 emit_insn (gen_sltu_insn (op0, op1, op2));
2038 (define_insn "sltu_insn"
2039 [(set (match_operand:SI 0 "register_operand" "=r,r")
2040 (ltu:SI (match_operand:SI 1 "register_operand" "r,r")
2041 (match_operand:SI 2 "reg_or_int16_operand" "r,J")))
2042 (clobber (reg:SI 17))]
2045 [(set_attr "type" "multi")
2046 (set_attr "length" "6,8")])
2049 [(set (match_operand:SI 0 "register_operand" "")
2050 (ltu:SI (match_operand:SI 1 "register_operand" "")
2051 (match_operand:SI 2 "reg_or_int16_operand" "")))
2052 (clobber (reg:SI 17))]
2055 (ltu:SI (match_dup 1)
2061 (define_expand "sleu"
2062 [(match_operand:SI 0 "register_operand" "")]
2066 rtx op0 = operands[0];
2067 rtx op1 = m32r_compare_op0;
2068 rtx op2 = m32r_compare_op1;
2069 enum machine_mode mode = GET_MODE (op0);
2074 if (GET_CODE (op2) == CONST_INT)
2076 HOST_WIDE_INT value = INTVAL (op2);
2077 if (value >= 2147483647)
2079 emit_move_insn (op0, GEN_INT (1));
2083 op2 = GEN_INT (value+1);
2084 if (value < 0 || value >= 32767)
2085 op2 = force_reg (mode, op2);
2087 emit_insn (gen_sltu_insn (op0, op1, op2));
2091 if (! register_operand (op2, mode))
2092 op2 = force_reg (mode, op2);
2094 emit_insn (gen_sleu_insn (op0, op1, op2));
2098 (define_insn "sleu_insn"
2099 [(set (match_operand:SI 0 "register_operand" "=r")
2100 (leu:SI (match_operand:SI 1 "register_operand" "r")
2101 (match_operand:SI 2 "register_operand" "r")))
2102 (clobber (reg:SI 17))]
2105 [(set_attr "type" "multi")
2106 (set_attr "length" "8")])
2109 [(set (match_operand:SI 0 "register_operand" "")
2110 (leu:SI (match_operand:SI 1 "register_operand" "")
2111 (match_operand:SI 2 "register_operand" "")))
2112 (clobber (reg:SI 17))]
2115 (ltu:SI (match_dup 2)
2120 (xor:SI (match_dup 0)
2124 ;; If optimizing for space, use -(reg - 1) to invert the comparison rather than
2125 ;; xor reg,reg,1 which might eliminate a NOP being inserted.
2127 [(set (match_operand:SI 0 "register_operand" "")
2128 (leu:SI (match_operand:SI 1 "register_operand" "")
2129 (match_operand:SI 2 "register_operand" "")))
2130 (clobber (reg:SI 17))]
2133 (ltu:SI (match_dup 2)
2138 (plus:SI (match_dup 0)
2141 (neg:SI (match_dup 0)))]
2144 (define_expand "sgtu"
2145 [(match_operand:SI 0 "register_operand" "")]
2149 rtx op0 = operands[0];
2150 rtx op1 = m32r_compare_op0;
2151 rtx op2 = m32r_compare_op1;
2152 enum machine_mode mode = GET_MODE (op0);
2157 if (! register_operand (op1, mode))
2158 op1 = force_reg (mode, op1);
2160 if (! register_operand (op2, mode))
2161 op2 = force_reg (mode, op2);
2163 emit_insn (gen_sltu_insn (op0, op2, op1));
2167 (define_expand "sgeu"
2168 [(match_operand:SI 0 "register_operand" "")]
2172 rtx op0 = operands[0];
2173 rtx op1 = m32r_compare_op0;
2174 rtx op2 = m32r_compare_op1;
2175 enum machine_mode mode = GET_MODE (op0);
2180 if (! register_operand (op1, mode))
2181 op1 = force_reg (mode, op1);
2183 if (! reg_or_int16_operand (op2, mode))
2184 op2 = force_reg (mode, op2);
2186 emit_insn (gen_sgeu_insn (op0, op1, op2));
2190 (define_insn "sgeu_insn"
2191 [(set (match_operand:SI 0 "register_operand" "=r,r")
2192 (geu:SI (match_operand:SI 1 "register_operand" "r,r")
2193 (match_operand:SI 2 "reg_or_int16_operand" "r,J")))
2194 (clobber (reg:SI 17))]
2197 [(set_attr "type" "multi")
2198 (set_attr "length" "8,10")])
2201 [(set (match_operand:SI 0 "register_operand" "")
2202 (geu:SI (match_operand:SI 1 "register_operand" "")
2203 (match_operand:SI 2 "reg_or_int16_operand" "")))
2204 (clobber (reg:SI 17))]
2207 (ltu:SI (match_dup 1)
2212 (xor:SI (match_dup 0)
2216 ;; If optimizing for space, use -(reg - 1) to invert the comparison rather than
2217 ;; xor reg,reg,1 which might eliminate a NOP being inserted.
2219 [(set (match_operand:SI 0 "register_operand" "")
2220 (geu:SI (match_operand:SI 1 "register_operand" "")
2221 (match_operand:SI 2 "reg_or_int16_operand" "")))
2222 (clobber (reg:SI 17))]
2225 (ltu:SI (match_dup 1)
2230 (plus:SI (match_dup 0)
2233 (neg:SI (match_dup 0)))]
2236 (define_insn "movcc_insn"
2237 [(set (match_operand:SI 0 "register_operand" "=r")
2241 [(set_attr "type" "misc")
2242 (set_attr "length" "2")])
2245 ;; Unconditional and other jump instructions.
2248 [(set (pc) (label_ref (match_operand 0 "" "")))]
2251 [(set_attr "type" "uncond_branch")
2252 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
2258 (define_insn "indirect_jump"
2259 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
2262 [(set_attr "type" "uncond_branch")
2263 (set_attr "length" "2")])
2265 (define_insn "return"
2269 [(set_attr "type" "uncond_branch")
2270 (set_attr "length" "2")])
2272 (define_insn "tablejump"
2273 [(set (pc) (match_operand:SI 0 "address_operand" "p"))
2274 (use (label_ref (match_operand 1 "" "")))]
2277 [(set_attr "type" "uncond_branch")
2278 (set_attr "length" "2")])
2280 (define_expand "call"
2281 ;; operands[1] is stack_size_rtx
2282 ;; operands[2] is next_arg_register
2283 [(parallel [(call (match_operand:SI 0 "call_operand" "")
2284 (match_operand 1 "" ""))
2285 (clobber (reg:SI 14))])]
2289 (define_insn "*call_via_reg"
2290 [(call (mem:SI (match_operand:SI 0 "register_operand" "r"))
2291 (match_operand 1 "" ""))
2292 (clobber (reg:SI 14))]
2295 [(set_attr "type" "call")
2296 (set_attr "length" "2")])
2298 (define_insn "*call_via_label"
2299 [(call (mem:SI (match_operand:SI 0 "call_address_operand" ""))
2300 (match_operand 1 "" ""))
2301 (clobber (reg:SI 14))]
2305 int call26_p = call26_operand (operands[0], FUNCTION_MODE);
2309 /* We may not be able to reach with a `bl' insn so punt and leave it to
2311 We do this here, rather than doing a force_reg in the define_expand
2312 so these insns won't be separated, say by scheduling, thus simplifying
2314 return \"seth r14,%T0\;add3 r14,r14,%B0\;jl r14\";
2319 [(set_attr "type" "call")
2320 (set (attr "length")
2321 (if_then_else (eq (symbol_ref "call26_operand (operands[0], FUNCTION_MODE)")
2323 (const_int 12) ; 10 + 2 for nop filler
2324 ; The return address must be on a 4 byte boundary so
2325 ; there's no point in using a value of 2 here. A 2 byte
2326 ; insn may go in the left slot but we currently can't
2327 ; use such knowledge.
2330 (define_expand "call_value"
2331 ;; operand 2 is stack_size_rtx
2332 ;; operand 3 is next_arg_register
2333 [(parallel [(set (match_operand 0 "register_operand" "=r")
2334 (call (match_operand:SI 1 "call_operand" "")
2335 (match_operand 2 "" "")))
2336 (clobber (reg:SI 14))])]
2340 (define_insn "*call_value_via_reg"
2341 [(set (match_operand 0 "register_operand" "=r")
2342 (call (mem:SI (match_operand:SI 1 "register_operand" "r"))
2343 (match_operand 2 "" "")))
2344 (clobber (reg:SI 14))]
2347 [(set_attr "type" "call")
2348 (set_attr "length" "2")])
2350 (define_insn "*call_value_via_label"
2351 [(set (match_operand 0 "register_operand" "=r")
2352 (call (mem:SI (match_operand:SI 1 "call_address_operand" ""))
2353 (match_operand 2 "" "")))
2354 (clobber (reg:SI 14))]
2358 int call26_p = call26_operand (operands[1], FUNCTION_MODE);
2362 /* We may not be able to reach with a `bl' insn so punt and leave it to
2364 We do this here, rather than doing a force_reg in the define_expand
2365 so these insns won't be separated, say by scheduling, thus simplifying
2367 return \"seth r14,%T1\;add3 r14,r14,%B1\;jl r14\";
2372 [(set_attr "type" "call")
2373 (set (attr "length")
2374 (if_then_else (eq (symbol_ref "call26_operand (operands[1], FUNCTION_MODE)")
2376 (const_int 12) ; 10 + 2 for nop filler
2377 ; The return address must be on a 4 byte boundary so
2378 ; there's no point in using a value of 2 here. A 2 byte
2379 ; insn may go in the left slot but we currently can't
2380 ; use such knowledge.
2387 [(set_attr "type" "int2")
2388 (set_attr "length" "2")])
2390 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
2391 ;; all of memory. This blocks insns from being moved across this point.
2393 (define_insn "blockage"
2394 [(unspec_volatile [(const_int 0)] 0)]
2398 ;; Special pattern to flush the icache.
2400 (define_insn "flush_icache"
2401 [(unspec_volatile [(match_operand 0 "memory_operand" "m")] 0)]
2403 "* return \"nop ; flush-icache\";"
2404 [(set_attr "type" "int2")
2405 (set_attr "length" "2")])
2407 ;; Speed up fabs and provide correct sign handling for -0
2409 (define_insn "absdf2"
2410 [(set (match_operand:DF 0 "register_operand" "=r")
2411 (abs:DF (match_operand:DF 1 "register_operand" "0")))]
2414 [(set_attr "type" "multi")
2415 (set_attr "length" "4")])
2418 [(set (match_operand:DF 0 "register_operand" "")
2419 (abs:DF (match_operand:DF 1 "register_operand" "")))]
2422 (ashift:SI (match_dup 2)
2425 (lshiftrt:SI (match_dup 2)
2427 "operands[2] = gen_highpart (SImode, operands[0]);")
2429 (define_insn "abssf2"
2430 [(set (match_operand:SF 0 "register_operand" "=r")
2431 (abs:SF (match_operand:SF 1 "register_operand" "0")))]
2434 [(set_attr "type" "multi")
2435 (set_attr "length" "4")])
2438 [(set (match_operand:SF 0 "register_operand" "")
2439 (abs:SF (match_operand:SF 1 "register_operand" "")))]
2442 (ashift:SI (match_dup 2)
2445 (lshiftrt:SI (match_dup 2)
2447 "operands[2] = gen_highpart (SImode, operands[0]);")
2449 ;; Conditional move instructions
2450 ;; Based on those done for the d10v
2452 (define_expand "movsicc"
2454 (set (match_operand:SI 0 "register_operand" "r")
2455 (if_then_else:SI (match_operand 1 "" "")
2456 (match_operand:SI 2 "conditional_move_operand" "O")
2457 (match_operand:SI 3 "conditional_move_operand" "O")
2464 if (! zero_and_one (operands [2], operands [3]))
2467 /* Generate the comparison that will set the carry flag. */
2468 operands[1] = gen_compare (GET_CODE (operands[1]), m32r_compare_op0,
2469 m32r_compare_op1, TRUE);
2471 /* See other movsicc pattern below for reason why. */
2472 emit_insn (gen_blockage ());
2475 ;; Generate the conditional instructions based on how the carry flag is examined.
2476 (define_insn "*movsicc_internal"
2477 [(set (match_operand:SI 0 "register_operand" "=r")
2478 (if_then_else:SI (match_operand 1 "carry_compare_operand" "")
2479 (match_operand:SI 2 "conditional_move_operand" "O")
2480 (match_operand:SI 3 "conditional_move_operand" "O")
2483 "zero_and_one (operands [2], operands[3])"
2484 "* return emit_cond_move (operands, insn);"
2485 [(set_attr "type" "multi")
2486 (set_attr "length" "8")
2491 ;; Split up troublesome insns for better scheduling.
2492 ;; FIXME: Peepholes go at the end.
2494 ;; ??? Setting the type attribute may not be useful, but for completeness
2498 [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "r")
2500 (match_operand:SI 1 "register_operand" "r"))]
2501 "0 && dead_or_set_p (insn, operands[0])"
2503 [(set_attr "type" "store2")
2504 (set_attr "length" "2")])
2506 ;; This case is triggered by compiling this code:
2508 ;; extern void sub(int *);
2512 ;; while (i < j) sub(&k);
2519 ;; Without the peephole the following assembler is generated for the
2520 ;; divide and subtract expressions:
2527 ;; Similar code is produced for the subtract expression. With this
2528 ;; peephole the redundant move is eliminated.
2530 ;; This optimization only works if PRESERVE_DEATH_INFO_REGNO_P is
2531 ;; defined in m32r.h
2534 [(set (match_operand:SI 0 "register_operand" "r")
2535 (match_operand:SI 1 "register_operand" "r")
2537 (set (mem:SI (plus: SI (match_operand:SI 2 "register_operand" "r")
2538 (match_operand:SI 3 "immediate_operand" "J")))
2542 "0 && dead_or_set_p (insn, operands [0])"
2544 [(set_attr "type" "store4")
2545 (set_attr "length" "4")
2549 ;; Block moves, see m32r.c for more details.
2550 ;; Argument 0 is the destination
2551 ;; Argument 1 is the source
2552 ;; Argument 2 is the length
2553 ;; Argument 3 is the alignment
2555 (define_expand "movstrsi"
2556 [(parallel [(set (match_operand:BLK 0 "general_operand" "")
2557 (match_operand:BLK 1 "general_operand" ""))
2558 (use (match_operand:SI 2 "immediate_operand" ""))
2559 (use (match_operand:SI 3 "immediate_operand" ""))])]
2563 if (operands[0]) /* avoid unused code messages */
2565 m32r_expand_block_move (operands);
2570 ;; Insn generated by block moves
2572 (define_insn "movstrsi_internal"
2573 [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r")) ;; destination
2574 (mem:BLK (match_operand:SI 1 "register_operand" "+r"))) ;; source
2575 (use (match_operand:SI 2 "m32r_block_immediate_operand" "J"));; # bytes to move
2576 (set (match_dup 0) (plus:SI (match_dup 0) (minus:SI (match_dup 2) (const_int 4))))
2577 (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))
2578 (clobber (match_scratch:SI 3 "=&r")) ;; temp 1
2579 (clobber (match_scratch:SI 4 "=&r"))] ;; temp 2
2581 "* m32r_output_block_move (insn, operands); return \"\"; "
2582 [(set_attr "type" "store8")
2583 (set_attr "length" "72")]) ;; Maximum