1 ;; Machine description of the Mitsubishi M32R cpu for GNU C compiler
2 ;; Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
4 ;; This file is part of GNU CC.
6 ;; GNU CC is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 2, or (at your option)
11 ;; GNU CC is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GNU CC; see the file COPYING. If not, write to
18 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
19 ;; Boston, MA 02111-1307, USA.
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)")))
75 ;; ::::::::::::::::::::
79 ;; ::::::::::::::::::::
81 ;; On most RISC machines, there are instructions whose results are not
82 ;; available for a specific number of cycles. Common cases are instructions
83 ;; that load data from memory. On many machines, a pipeline stall will result
84 ;; if the data is referenced too soon after the load instruction.
86 ;; In addition, many newer microprocessors have multiple function units,
87 ;; usually one for integer and one for floating point, and often will incur
88 ;; pipeline stalls when a result that is needed is not yet ready.
90 ;; The descriptions in this section allow the specification of how much time
91 ;; must elapse between the execution of an instruction and the time when its
92 ;; result is used. It also allows specification of when the execution of an
93 ;; instruction will delay execution of similar instructions due to function
96 ;; For the purposes of the specifications in this section, a machine is divided
97 ;; into "function units", each of which execute a specific class of
98 ;; instructions in first-in-first-out order. Function units that accept one
99 ;; instruction each cycle and allow a result to be used in the succeeding
100 ;; instruction (usually via forwarding) need not be specified. Classic RISC
101 ;; microprocessors will normally have a single function unit, which we can call
102 ;; `memory'. The newer "superscalar" processors will often have function units
103 ;; for floating point operations, usually at least a floating point adder and
106 ;; Each usage of a function units by a class of insns is specified with a
107 ;; `define_function_unit' expression, which looks like this:
109 ;; (define_function_unit NAME MULTIPLICITY SIMULTANEITY TEST READY-DELAY
110 ;; ISSUE-DELAY [CONFLICT-LIST])
112 ;; NAME is a string giving the name of the function unit.
114 ;; MULTIPLICITY is an integer specifying the number of identical units in the
115 ;; processor. If more than one unit is specified, they will be scheduled
116 ;; independently. Only truly independent units should be counted; a pipelined
117 ;; unit should be specified as a single unit. (The only common example of a
118 ;; machine that has multiple function units for a single instruction class that
119 ;; are truly independent and not pipelined are the two multiply and two
120 ;; increment units of the CDC 6600.)
122 ;; SIMULTANEITY specifies the maximum number of insns that can be executing in
123 ;; each instance of the function unit simultaneously or zero if the unit is
124 ;; pipelined and has no limit.
126 ;; All `define_function_unit' definitions referring to function unit NAME must
127 ;; have the same name and values for MULTIPLICITY and SIMULTANEITY.
129 ;; TEST is an attribute test that selects the insns we are describing in this
130 ;; definition. Note that an insn may use more than one function unit and a
131 ;; function unit may be specified in more than one `define_function_unit'.
133 ;; READY-DELAY is an integer that specifies the number of cycles after which
134 ;; the result of the instruction can be used without introducing any stalls.
136 ;; ISSUE-DELAY is an integer that specifies the number of cycles after the
137 ;; instruction matching the TEST expression begins using this unit until a
138 ;; subsequent instruction can begin. A cost of N indicates an N-1 cycle delay.
139 ;; A subsequent instruction may also be delayed if an earlier instruction has a
140 ;; longer READY-DELAY value. This blocking effect is computed using the
141 ;; SIMULTANEITY, READY-DELAY, ISSUE-DELAY, and CONFLICT-LIST terms. For a
142 ;; normal non-pipelined function unit, SIMULTANEITY is one, the unit is taken
143 ;; to block for the READY-DELAY cycles of the executing insn, and smaller
144 ;; values of ISSUE-DELAY are ignored.
146 ;; CONFLICT-LIST is an optional list giving detailed conflict costs for this
147 ;; unit. If specified, it is a list of condition test expressions to be
148 ;; applied to insns chosen to execute in NAME following the particular insn
149 ;; matching TEST that is already executing in NAME. For each insn in the list,
150 ;; ISSUE-DELAY specifies the conflict cost; for insns not in the list, the cost
151 ;; is zero. If not specified, CONFLICT-LIST defaults to all instructions that
152 ;; use the function unit.
154 ;; Typical uses of this vector are where a floating point function unit can
155 ;; pipeline either single- or double-precision operations, but not both, or
156 ;; where a memory unit can pipeline loads, but not stores, etc.
158 ;; As an example, consider a classic RISC machine where the result of a load
159 ;; instruction is not available for two cycles (a single "delay" instruction is
160 ;; required) and where only one load instruction can be executed
161 ;; simultaneously. This would be specified as:
163 ;; (define_function_unit "memory" 1 1 (eq_attr "type" "load") 2 0)
165 ;; For the case of a floating point function unit that can pipeline
166 ;; either single or double precision, but not both, the following could be
169 ;; (define_function_unit "fp" 1 0
170 ;; (eq_attr "type" "sp_fp") 4 4
171 ;; [(eq_attr "type" "dp_fp")])
173 ;; (define_function_unit "fp" 1 0
174 ;; (eq_attr "type" "dp_fp") 4 4
175 ;; [(eq_attr "type" "sp_fp")])
177 ;; Note: The scheduler attempts to avoid function unit conflicts and uses all
178 ;; the specifications in the `define_function_unit' expression. It has
179 ;; recently come to our attention that these specifications may not allow
180 ;; modeling of some of the newer "superscalar" processors that have insns using
181 ;; multiple pipelined units. These insns will cause a potential conflict for
182 ;; the second unit used during their execution and there is no way of
183 ;; representing that conflict. We welcome any examples of how function unit
184 ;; conflicts work in such processors and suggestions for their representation.
186 ;; Function units of the M32R
187 ;; Units that take one cycle do not need to be specified.
189 ;; (define_function_unit {name} {multiplicity} {simulataneity} {test}
190 ;; {ready-delay} {issue-delay} [{conflict-list}])
192 ;; Hack to get GCC to better pack the instructions.
193 ;; We pretend there is a separate long function unit that conflicts with
194 ;; both the left and right 16 bit insn slots.
196 (define_function_unit "short" 2 2
197 (and (eq_attr "m32r" "yes")
198 (and (eq_attr "insn_size" "short")
199 (eq_attr "type" "!load2")))
201 [(eq_attr "insn_size" "long")])
203 (define_function_unit "short" 2 2 ;; load delay of 1 clock for mem execution + 1 clock for WB
204 (and (eq_attr "m32r" "yes")
205 (eq_attr "type" "load2"))
207 [(eq_attr "insn_size" "long")])
209 (define_function_unit "long" 1 1
210 (and (eq_attr "m32r" "yes")
211 (and (eq_attr "insn_size" "long")
212 (eq_attr "type" "!load4,load8")))
214 [(eq_attr "insn_size" "short")])
216 (define_function_unit "long" 1 1 ;; load delay of 1 clock for mem execution + 1 clock for WB
217 (and (eq_attr "m32r" "yes")
218 (and (eq_attr "insn_size" "long")
219 (eq_attr "type" "load4,load8")))
221 [(eq_attr "insn_size" "short")])
225 ;; Instruction grouping
228 ;; Expand prologue as RTL
229 (define_expand "prologue"
234 m32r_expand_prologue ();
239 ;; Move instructions.
241 ;; For QI and HI moves, the register must contain the full properly
242 ;; sign-extended value. nonzero_bits assumes this [otherwise
243 ;; SHORT_IMMEDIATES_SIGN_EXTEND must be used, but the comment for it
244 ;; says it's a kludge and the .md files should be fixed instead].
246 (define_expand "movqi"
247 [(set (match_operand:QI 0 "general_operand" "")
248 (match_operand:QI 1 "general_operand" ""))]
252 /* Everything except mem = const or mem = mem can be done easily.
253 Objects in the small data area are handled too. */
255 if (GET_CODE (operands[0]) == MEM)
256 operands[1] = force_reg (QImode, operands[1]);
259 (define_insn "*movqi_insn"
260 [(set (match_operand:QI 0 "move_dest_operand" "=r,r,r,r,r,T,m")
261 (match_operand:QI 1 "move_src_operand" "r,I,JQR,T,m,r,r"))]
262 "register_operand (operands[0], QImode) || register_operand (operands[1], QImode)"
271 [(set_attr "type" "int2,int2,int4,load2,load4,store2,store4")
272 (set_attr "length" "2,2,4,2,4,2,4")])
274 (define_expand "movhi"
275 [(set (match_operand:HI 0 "general_operand" "")
276 (match_operand:HI 1 "general_operand" ""))]
280 /* Everything except mem = const or mem = mem can be done easily. */
282 if (GET_CODE (operands[0]) == MEM)
283 operands[1] = force_reg (HImode, operands[1]);
286 (define_insn "*movhi_insn"
287 [(set (match_operand:HI 0 "move_dest_operand" "=r,r,r,r,r,r,T,m")
288 (match_operand:HI 1 "move_src_operand" "r,I,JQR,K,T,m,r,r"))]
289 "register_operand (operands[0], HImode) || register_operand (operands[1], HImode)"
299 [(set_attr "type" "int2,int2,int4,int4,load2,load4,store2,store4")
300 (set_attr "length" "2,2,4,4,2,4,2,4")])
302 (define_expand "movsi_push"
303 [(set (mem:SI (pre_dec:SI (match_operand:SI 0 "register_operand" "")))
304 (match_operand:SI 1 "register_operand" ""))]
308 (define_expand "movsi_pop"
309 [(set (match_operand:SI 0 "register_operand" "")
310 (mem:SI (post_inc:SI (match_operand:SI 1 "register_operand" ""))))]
314 (define_expand "movsi"
315 [(set (match_operand:SI 0 "general_operand" "")
316 (match_operand:SI 1 "general_operand" ""))]
320 /* Everything except mem = const or mem = mem can be done easily. */
322 if (GET_CODE (operands[0]) == MEM)
323 operands[1] = force_reg (SImode, operands[1]);
325 /* Small Data Area reference? */
326 if (small_data_operand (operands[1], SImode))
328 emit_insn (gen_movsi_sda (operands[0], operands[1]));
332 /* If medium or large code model, symbols have to be loaded with
334 if (addr32_operand (operands[1], SImode))
336 emit_insn (gen_movsi_addr32 (operands[0], operands[1]));
341 ;; ??? Do we need a const_double constraint here for large unsigned values?
342 (define_insn "*movsi_insn"
343 [(set (match_operand:SI 0 "move_dest_operand" "=r,r,r,r,r,r,r,r,r,T,U,m")
344 (match_operand:SI 1 "move_src_operand" "r,I,J,MQ,L,n,T,U,m,r,r,r"))]
345 "register_operand (operands[0], SImode) || register_operand (operands[1], SImode)"
348 if (GET_CODE (operands[0]) == REG || GET_CODE (operands[1]) == SUBREG)
350 switch (GET_CODE (operands[1]))
365 value = INTVAL (operands[1]);
367 return \"ldi %0,%#%1\\t; %X1\";
369 if (UINT24_P (value))
370 return \"ld24 %0,%#%1\\t; %X1\";
372 if (UPPER16_P (value))
373 return \"seth %0,%#%T1\\t; %X1\";
381 return \"ld24 %0,%#%1\";
387 else if (GET_CODE (operands[0]) == MEM
388 && (GET_CODE (operands[1]) == REG || GET_CODE (operands[1]) == SUBREG))
391 fatal_insn (\"bad movsi insn\", insn);
393 [(set_attr "type" "int2,int2,int4,int4,int4,multi,load2,load2,load4,store2,store2,store4")
394 (set_attr "length" "2,2,4,4,4,8,2,2,4,2,2,4")])
396 ; Try to use a four byte / two byte pair for constants not loadable with
400 [(set (match_operand:SI 0 "register_operand" "")
401 (match_operand:SI 1 "two_insn_const_operand" ""))]
403 [(set (match_dup 0) (match_dup 2))
404 (set (match_dup 0) (ior:SI (match_dup 0) (match_dup 3)))]
407 unsigned HOST_WIDE_INT val = INTVAL (operands[1]);
408 unsigned HOST_WIDE_INT tmp;
411 /* In all cases we will emit two instructions. However we try to
412 use 2 byte instructions wherever possible. We can assume the
413 constant isn't loadable with any of ldi, ld24, or seth. */
415 /* See if we can load a 24 bit unsigned value and invert it. */
416 if (UINT24_P (~ val))
418 emit_insn (gen_movsi (operands[0], GEN_INT (~ val)));
419 emit_insn (gen_one_cmplsi2 (operands[0], operands[0]));
423 /* See if we can load a 24 bit unsigned value and shift it into place.
424 0x01fffffe is just beyond ld24's range. */
425 for (shift = 1, tmp = 0x01fffffe;
429 if ((val & ~tmp) == 0)
431 emit_insn (gen_movsi (operands[0], GEN_INT (val >> shift)));
432 emit_insn (gen_ashlsi3 (operands[0], operands[0], GEN_INT (shift)));
437 /* Can't use any two byte insn, fall back to seth/or3. Use ~0xffff instead
438 of 0xffff0000, since the later fails on a 64-bit host. */
439 operands[2] = GEN_INT ((val) & ~0xffff);
440 operands[3] = GEN_INT ((val) & 0xffff);
444 [(set (match_operand:SI 0 "register_operand" "")
445 (match_operand:SI 1 "seth_add3_operand" "i"))]
448 (high:SI (match_dup 1)))
450 (lo_sum:SI (match_dup 0)
454 ;; Small data area support.
455 ;; The address of _SDA_BASE_ is loaded into a register and all objects in
456 ;; the small data area are indexed off that. This is done for each reference
457 ;; but cse will clean things up for us. We let the compiler choose the
458 ;; register to use so we needn't allocate (and maybe even fix) a special
459 ;; register to use. Since the load and store insns have a 16 bit offset the
460 ;; total size of the data area can be 64K. However, if the data area lives
461 ;; above 16M (24 bits), _SDA_BASE_ will have to be loaded with seth/add3 which
462 ;; would then yield 3 instructions to reference an object [though there would
463 ;; be no net loss if two or more objects were referenced]. The 3 insns can be
464 ;; reduced back to 2 if the size of the small data area were reduced to 32K
465 ;; [then seth + ld/st would work for any object in the area]. Doing this
466 ;; would require special handling of _SDA_BASE_ (its value would be
467 ;; (.sdata + 32K) & 0xffff0000) and reloc computations would be different
468 ;; [I think]. What to do about this is deferred until later and for now we
469 ;; require .sdata to be in the first 16M.
471 (define_expand "movsi_sda"
473 (unspec [(const_int 0)] 2))
474 (set (match_operand:SI 0 "register_operand" "")
475 (lo_sum:SI (match_dup 2)
476 (match_operand:SI 1 "small_data_operand" "")))]
480 if (reload_in_progress || reload_completed)
481 operands[2] = operands[0];
483 operands[2] = gen_reg_rtx (SImode);
486 (define_insn "*load_sda_base"
487 [(set (match_operand:SI 0 "register_operand" "=r")
488 (unspec [(const_int 0)] 2))]
490 "ld24 %0,#_SDA_BASE_"
491 [(set_attr "type" "int4")
492 (set_attr "length" "4")])
494 ;; 32 bit address support.
496 (define_expand "movsi_addr32"
498 ; addr32_operand isn't used because it's too restrictive,
499 ; seth_add3_operand is more general and thus safer.
500 (high:SI (match_operand:SI 1 "seth_add3_operand" "")))
501 (set (match_operand:SI 0 "register_operand" "")
502 (lo_sum:SI (match_dup 2) (match_dup 1)))]
506 if (reload_in_progress || reload_completed)
507 operands[2] = operands[0];
509 operands[2] = gen_reg_rtx (SImode);
512 (define_insn "set_hi_si"
513 [(set (match_operand:SI 0 "register_operand" "=r")
514 (high:SI (match_operand 1 "symbolic_operand" "")))]
516 "seth %0,%#shigh(%1)"
517 [(set_attr "type" "int4")
518 (set_attr "length" "4")])
520 (define_insn "lo_sum_si"
521 [(set (match_operand:SI 0 "register_operand" "=r")
522 (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
523 (match_operand:SI 2 "immediate_operand" "in")))]
526 [(set_attr "type" "int4")
527 (set_attr "length" "4")])
529 (define_expand "movdi"
530 [(set (match_operand:DI 0 "general_operand" "")
531 (match_operand:DI 1 "general_operand" ""))]
535 /* Everything except mem = const or mem = mem can be done easily. */
537 if (GET_CODE (operands[0]) == MEM)
538 operands[1] = force_reg (DImode, operands[1]);
541 (define_insn "*movdi_insn"
542 [(set (match_operand:DI 0 "move_dest_operand" "=r,r,r,r,m")
543 (match_operand:DI 1 "move_double_src_operand" "r,nG,F,m,r"))]
544 "register_operand (operands[0], DImode) || register_operand (operands[1], DImode)"
546 [(set_attr "type" "multi,multi,multi,load8,store8")
547 (set_attr "length" "4,4,16,6,6")])
550 [(set (match_operand:DI 0 "move_dest_operand" "")
551 (match_operand:DI 1 "move_double_src_operand" ""))]
554 "operands[2] = gen_split_move_double (operands);")
556 ;; Floating point move insns.
558 (define_expand "movsf"
559 [(set (match_operand:SF 0 "general_operand" "")
560 (match_operand:SF 1 "general_operand" ""))]
564 /* Everything except mem = const or mem = mem can be done easily. */
566 if (GET_CODE (operands[0]) == MEM)
567 operands[1] = force_reg (SFmode, operands[1]);
570 (define_insn "*movsf_insn"
571 [(set (match_operand:SF 0 "move_dest_operand" "=r,r,r,r,T,m")
572 (match_operand:SF 1 "move_src_operand" "r,F,T,m,r,r"))]
573 "register_operand (operands[0], SFmode) || register_operand (operands[1], SFmode)"
581 ;; ??? Length of alternative 1 is either 2, 4 or 8.
582 [(set_attr "type" "int2,multi,load2,load4,store2,store4")
583 (set_attr "length" "2,8,2,4,2,4")])
586 [(set (match_operand:SF 0 "register_operand" "")
587 (match_operand:SF 1 "const_double_operand" ""))]
589 [(set (match_dup 2) (match_dup 3))]
595 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
596 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
598 operands[2] = operand_subword (operands[0], 0, 0, SFmode);
599 operands[3] = GEN_INT (l);
602 (define_expand "movdf"
603 [(set (match_operand:DF 0 "general_operand" "")
604 (match_operand:DF 1 "general_operand" ""))]
608 /* Everything except mem = const or mem = mem can be done easily. */
610 if (GET_CODE (operands[0]) == MEM)
611 operands[1] = force_reg (DFmode, operands[1]);
614 (define_insn "*movdf_insn"
615 [(set (match_operand:DF 0 "move_dest_operand" "=r,r,r,m")
616 (match_operand:DF 1 "move_double_src_operand" "r,F,m,r"))]
617 "register_operand (operands[0], DFmode) || register_operand (operands[1], DFmode)"
619 [(set_attr "type" "multi,multi,load8,store8")
620 (set_attr "length" "4,16,6,6")])
623 [(set (match_operand:DF 0 "move_dest_operand" "")
624 (match_operand:DF 1 "move_double_src_operand" ""))]
627 "operands[2] = gen_split_move_double (operands);")
629 ;; Zero extension instructions.
631 (define_insn "zero_extendqihi2"
632 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
633 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "r,T,m")))]
639 [(set_attr "type" "int4,load2,load4")
640 (set_attr "length" "4,2,4")])
642 (define_insn "zero_extendqisi2"
643 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
644 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,T,m")))]
650 [(set_attr "type" "int4,load2,load4")
651 (set_attr "length" "4,2,4")])
653 (define_insn "zero_extendhisi2"
654 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
655 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,T,m")))]
661 [(set_attr "type" "int4,load2,load4")
662 (set_attr "length" "4,2,4")])
664 ;; Sign extension instructions.
667 ;; These patterns originally accepted general_operands, however, slightly
668 ;; better code is generated by only accepting register_operands, and then
669 ;; letting combine generate the lds[hb] insns.
670 ;; [This comment copied from sparc.md, I think.]
672 (define_expand "extendqihi2"
673 [(set (match_operand:HI 0 "register_operand" "")
674 (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
678 rtx temp = gen_reg_rtx (SImode);
679 rtx shift_24 = GEN_INT (24);
683 if (GET_CODE (operand1) == SUBREG)
685 op1_subword = SUBREG_WORD (operand1);
686 operand1 = XEXP (operand1, 0);
688 if (GET_CODE (operand0) == SUBREG)
690 op0_subword = SUBREG_WORD (operand0);
691 operand0 = XEXP (operand0, 0);
693 emit_insn (gen_ashlsi3 (temp, gen_rtx (SUBREG, SImode, operand1,
696 if (GET_MODE (operand0) != SImode)
697 operand0 = gen_rtx (SUBREG, SImode, operand0, op0_subword);
698 emit_insn (gen_ashrsi3 (operand0, temp, shift_24));
702 (define_insn "*sign_extendqihi2_insn"
703 [(set (match_operand:HI 0 "register_operand" "=r,r")
704 (sign_extend:HI (match_operand:QI 1 "memory_operand" "T,m")))]
707 [(set_attr "type" "load2,load4")
708 (set_attr "length" "2,4")])
710 (define_expand "extendqisi2"
711 [(set (match_operand:SI 0 "register_operand" "")
712 (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
716 rtx temp = gen_reg_rtx (SImode);
717 rtx shift_24 = GEN_INT (24);
720 if (GET_CODE (operand1) == SUBREG)
722 op1_subword = SUBREG_WORD (operand1);
723 operand1 = XEXP (operand1, 0);
726 emit_insn (gen_ashlsi3 (temp, gen_rtx (SUBREG, SImode, operand1,
729 emit_insn (gen_ashrsi3 (operand0, temp, shift_24));
733 (define_insn "*sign_extendqisi2_insn"
734 [(set (match_operand:SI 0 "register_operand" "=r,r")
735 (sign_extend:SI (match_operand:QI 1 "memory_operand" "T,m")))]
738 [(set_attr "type" "load2,load4")
739 (set_attr "length" "2,4")])
741 (define_expand "extendhisi2"
742 [(set (match_operand:SI 0 "register_operand" "")
743 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
747 rtx temp = gen_reg_rtx (SImode);
748 rtx shift_16 = GEN_INT (16);
751 if (GET_CODE (operand1) == SUBREG)
753 op1_subword = SUBREG_WORD (operand1);
754 operand1 = XEXP (operand1, 0);
757 emit_insn (gen_ashlsi3 (temp, gen_rtx (SUBREG, SImode, operand1,
760 emit_insn (gen_ashrsi3 (operand0, temp, shift_16));
764 (define_insn "*sign_extendhisi2_insn"
765 [(set (match_operand:SI 0 "register_operand" "=r,r")
766 (sign_extend:SI (match_operand:HI 1 "memory_operand" "T,m")))]
769 [(set_attr "type" "load2,load4")
770 (set_attr "length" "2,4")])
772 ;; Arithmetic instructions.
774 ; ??? Adding an alternative to split add3 of small constants into two
775 ; insns yields better instruction packing but slower code. Adds of small
776 ; values is done a lot.
778 (define_insn "addsi3"
779 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
780 (plus:SI (match_operand:SI 1 "register_operand" "%0,0,r")
781 (match_operand:SI 2 "nonmemory_operand" "r,I,J")))]
787 [(set_attr "type" "int2,int2,int4")
788 (set_attr "length" "2,2,4")])
791 ; [(set (match_operand:SI 0 "register_operand" "")
792 ; (plus:SI (match_operand:SI 1 "register_operand" "")
793 ; (match_operand:SI 2 "int8_operand" "")))]
795 ; && REGNO (operands[0]) != REGNO (operands[1])
796 ; && INT8_P (INTVAL (operands[2]))
797 ; && INTVAL (operands[2]) != 0"
798 ; [(set (match_dup 0) (match_dup 1))
799 ; (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
802 (define_insn "adddi3"
803 [(set (match_operand:DI 0 "register_operand" "=r")
804 (plus:DI (match_operand:DI 1 "register_operand" "%0")
805 (match_operand:DI 2 "register_operand" "r")))
806 (clobber (reg:SI 17))]
809 [(set_attr "type" "multi")
810 (set_attr "length" "6")])
812 ;; ??? The cmp clears the condition bit. Can we speed up somehow?
814 [(set (match_operand:DI 0 "register_operand" "")
815 (plus:DI (match_operand:DI 1 "register_operand" "")
816 (match_operand:DI 2 "register_operand" "")))
817 (clobber (match_operand 3 "" ""))]
819 [(parallel [(set (match_dup 3)
821 (use (match_dup 4))])
822 (parallel [(set (match_dup 4)
823 (plus:SI (match_dup 4)
824 (plus:SI (match_dup 5)
827 (unspec [(const_int 0)] 3))])
828 (parallel [(set (match_dup 6)
829 (plus:SI (match_dup 6)
830 (plus:SI (match_dup 7)
833 (unspec [(const_int 0)] 3))])]
836 operands[4] = operand_subword (operands[0], (WORDS_BIG_ENDIAN != 0), 0, DImode);
837 operands[5] = operand_subword (operands[2], (WORDS_BIG_ENDIAN != 0), 0, DImode);
838 operands[6] = operand_subword (operands[0], (WORDS_BIG_ENDIAN == 0), 0, DImode);
839 operands[7] = operand_subword (operands[2], (WORDS_BIG_ENDIAN == 0), 0, DImode);
842 (define_insn "*clear_c"
845 (use (match_operand:SI 0 "register_operand" "r"))]
848 [(set_attr "type" "int2")
849 (set_attr "length" "2")])
851 (define_insn "*add_carry"
852 [(set (match_operand:SI 0 "register_operand" "=r")
853 (plus:SI (match_operand:SI 1 "register_operand" "%0")
854 (plus:SI (match_operand:SI 2 "register_operand" "r")
857 (unspec [(const_int 0)] 3))]
860 [(set_attr "type" "int2")
861 (set_attr "length" "2")])
863 (define_insn "subsi3"
864 [(set (match_operand:SI 0 "register_operand" "=r")
865 (minus:SI (match_operand:SI 1 "register_operand" "0")
866 (match_operand:SI 2 "register_operand" "r")))]
869 [(set_attr "type" "int2")
870 (set_attr "length" "2")])
872 (define_insn "subdi3"
873 [(set (match_operand:DI 0 "register_operand" "=r")
874 (minus:DI (match_operand:DI 1 "register_operand" "0")
875 (match_operand:DI 2 "register_operand" "r")))
876 (clobber (reg:SI 17))]
879 [(set_attr "type" "multi")
880 (set_attr "length" "6")])
882 ;; ??? The cmp clears the condition bit. Can we speed up somehow?
884 [(set (match_operand:DI 0 "register_operand" "")
885 (minus:DI (match_operand:DI 1 "register_operand" "")
886 (match_operand:DI 2 "register_operand" "")))
887 (clobber (match_operand 3 "" ""))]
889 [(parallel [(set (match_dup 3)
891 (use (match_dup 4))])
892 (parallel [(set (match_dup 4)
893 (minus:SI (match_dup 4)
894 (minus:SI (match_dup 5)
897 (unspec [(const_int 0)] 3))])
898 (parallel [(set (match_dup 6)
899 (minus:SI (match_dup 6)
900 (minus:SI (match_dup 7)
903 (unspec [(const_int 0)] 3))])]
906 operands[4] = operand_subword (operands[0], (WORDS_BIG_ENDIAN != 0), 0, DImode);
907 operands[5] = operand_subword (operands[2], (WORDS_BIG_ENDIAN != 0), 0, DImode);
908 operands[6] = operand_subword (operands[0], (WORDS_BIG_ENDIAN == 0), 0, DImode);
909 operands[7] = operand_subword (operands[2], (WORDS_BIG_ENDIAN == 0), 0, DImode);
912 (define_insn "*sub_carry"
913 [(set (match_operand:SI 0 "register_operand" "=r")
914 (minus:SI (match_operand:SI 1 "register_operand" "%0")
915 (minus:SI (match_operand:SI 2 "register_operand" "r")
918 (unspec [(const_int 0)] 3))]
921 [(set_attr "type" "int2")
922 (set_attr "length" "2")])
924 ; Multiply/Divide instructions.
926 (define_insn "mulhisi3"
927 [(set (match_operand:SI 0 "register_operand" "=r")
928 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "r"))
929 (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
931 "mullo %1,%2\;mvfacmi %0"
932 [(set_attr "type" "multi")
933 (set_attr "length" "4")])
935 (define_insn "mulsi3"
936 [(set (match_operand:SI 0 "register_operand" "=r")
937 (mult:SI (match_operand:SI 1 "register_operand" "%0")
938 (match_operand:SI 2 "register_operand" "r")))]
941 [(set_attr "type" "mul2")
942 (set_attr "length" "2")])
944 (define_insn "divsi3"
945 [(set (match_operand:SI 0 "register_operand" "=r")
946 (div:SI (match_operand:SI 1 "register_operand" "0")
947 (match_operand:SI 2 "register_operand" "r")))]
950 [(set_attr "type" "div4")
951 (set_attr "length" "4")])
953 (define_insn "udivsi3"
954 [(set (match_operand:SI 0 "register_operand" "=r")
955 (udiv:SI (match_operand:SI 1 "register_operand" "0")
956 (match_operand:SI 2 "register_operand" "r")))]
959 [(set_attr "type" "div4")
960 (set_attr "length" "4")])
962 (define_insn "modsi3"
963 [(set (match_operand:SI 0 "register_operand" "=r")
964 (mod:SI (match_operand:SI 1 "register_operand" "0")
965 (match_operand:SI 2 "register_operand" "r")))]
968 [(set_attr "type" "div4")
969 (set_attr "length" "4")])
971 (define_insn "umodsi3"
972 [(set (match_operand:SI 0 "register_operand" "=r")
973 (umod:SI (match_operand:SI 1 "register_operand" "0")
974 (match_operand:SI 2 "register_operand" "r")))]
977 [(set_attr "type" "div4")
978 (set_attr "length" "4")])
980 ;; Boolean instructions.
982 ;; We don't define the DImode versions as expand_binop does a good enough job.
983 ;; And if it doesn't it should be fixed.
985 (define_insn "andsi3"
986 [(set (match_operand:SI 0 "register_operand" "=r,r")
987 (and:SI (match_operand:SI 1 "register_operand" "%0,r")
988 (match_operand:SI 2 "nonmemory_operand" "r,K")))]
992 and3 %0,%1,%#%2\\t; %X2"
993 [(set_attr "type" "int2,int4")
994 (set_attr "length" "2,4")])
996 (define_insn "iorsi3"
997 [(set (match_operand:SI 0 "register_operand" "=r,r")
998 (ior:SI (match_operand:SI 1 "register_operand" "%0,r")
999 (match_operand:SI 2 "nonmemory_operand" "r,K")))]
1003 or3 %0,%1,%#%2\\t; %X2"
1004 [(set_attr "type" "int2,int4")
1005 (set_attr "length" "2,4")])
1007 (define_insn "xorsi3"
1008 [(set (match_operand:SI 0 "register_operand" "=r,r")
1009 (xor:SI (match_operand:SI 1 "register_operand" "%0,r")
1010 (match_operand:SI 2 "nonmemory_operand" "r,K")))]
1014 xor3 %0,%1,%#%2\\t; %X2"
1015 [(set_attr "type" "int2,int4")
1016 (set_attr "length" "2,4")])
1018 (define_insn "negsi2"
1019 [(set (match_operand:SI 0 "register_operand" "=r")
1020 (neg:SI (match_operand:SI 1 "register_operand" "r")))]
1023 [(set_attr "type" "int2")
1024 (set_attr "length" "2")])
1026 (define_insn "one_cmplsi2"
1027 [(set (match_operand:SI 0 "register_operand" "=r")
1028 (not:SI (match_operand:SI 1 "register_operand" "r")))]
1031 [(set_attr "type" "int2")
1032 (set_attr "length" "2")])
1034 ;; Shift instructions.
1036 (define_insn "ashlsi3"
1037 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1038 (ashift:SI (match_operand:SI 1 "register_operand" "0,0,r")
1039 (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))]
1045 [(set_attr "type" "shift2,shift2,shift4")
1046 (set_attr "length" "2,2,4")])
1048 (define_insn "ashrsi3"
1049 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1050 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r")
1051 (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))]
1057 [(set_attr "type" "shift2,shift2,shift4")
1058 (set_attr "length" "2,2,4")])
1060 (define_insn "lshrsi3"
1061 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1062 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r")
1063 (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))]
1069 [(set_attr "type" "shift2,shift2,shift4")
1070 (set_attr "length" "2,2,4")])
1072 ;; Compare instructions.
1073 ;; This controls RTL generation and register allocation.
1075 ;; We generate RTL for comparisons and branches by having the cmpxx
1076 ;; patterns store away the operands. Then the bcc patterns
1077 ;; emit RTL for both the compare and the branch.
1079 ;; On the m32r it is more efficient to use the bxxz instructions and
1080 ;; thus merge the compare and branch into one instruction, so they are
1083 (define_expand "cmpsi"
1085 (compare:SI (match_operand:SI 0 "register_operand" "")
1086 (match_operand:SI 1 "nonmemory_operand" "")))]
1090 m32r_compare_op0 = operands[0];
1091 m32r_compare_op1 = operands[1];
1096 ;; The cmp_xxx_insn patterns set the condition bit to the result of the
1097 ;; comparison. There isn't a "compare equal" instruction so cmp_eqsi_insn
1098 ;; is quite inefficient. However, it is rarely used.
1100 (define_insn "cmp_eqsi_insn"
1102 (eq:SI (match_operand:SI 0 "register_operand" "r,r")
1103 (match_operand:SI 1 "reg_or_cmp_int16_operand" "r,P")))
1104 (clobber (match_scratch:SI 2 "=&r,&r"))]
1108 if (which_alternative == 0)
1110 return \"mv %2,%0\;sub %2,%1\;cmpui %2,#1\";
1114 if (INTVAL (operands [1]) == 0)
1115 return \"cmpui %0, #1\";
1116 else if (REGNO (operands [2]) == REGNO (operands [0]))
1117 return \"addi %0,%#%N1\;cmpui %2,#1\";
1119 return \"add3 %2,%0,%#%N1\;cmpui %2,#1\";
1122 [(set_attr "type" "multi,multi")
1123 (set_attr "length" "8,8")])
1125 (define_insn "cmp_ltsi_insn"
1127 (lt:SI (match_operand:SI 0 "register_operand" "r,r")
1128 (match_operand:SI 1 "reg_or_int16_operand" "r,J")))]
1133 [(set_attr "type" "int2,int4")
1134 (set_attr "length" "2,4")])
1136 (define_insn "cmp_ltusi_insn"
1138 (ltu:SI (match_operand:SI 0 "register_operand" "r,r")
1139 (match_operand:SI 1 "reg_or_uint16_operand" "r,K")))]
1144 [(set_attr "type" "int2,int4")
1145 (set_attr "length" "2,4")])
1147 ;; reg == small constant comparisons are best handled by putting the result
1148 ;; of the comparison in a tmp reg and then using beqz/bnez.
1149 ;; ??? The result register doesn't contain 0/STORE_FLAG_VALUE,
1150 ;; it contains 0/non-zero.
1152 (define_insn "cmp_ne_small_const_insn"
1153 [(set (match_operand:SI 0 "register_operand" "=r,r")
1154 (ne:SI (match_operand:SI 1 "register_operand" "0,r")
1155 (match_operand:SI 2 "cmp_int16_operand" "N,P")))]
1160 [(set_attr "type" "int2,int4")
1161 (set_attr "length" "2,4")])
1163 ;; These control RTL generation for conditional jump insns.
1165 (define_expand "beq"
1167 (if_then_else (match_dup 1)
1168 (label_ref (match_operand 0 "" ""))
1173 operands[1] = gen_compare ((int)EQ, m32r_compare_op0, m32r_compare_op1, FALSE);
1176 (define_expand "bne"
1178 (if_then_else (match_dup 1)
1179 (label_ref (match_operand 0 "" ""))
1184 operands[1] = gen_compare ((int)NE, m32r_compare_op0, m32r_compare_op1, FALSE);
1187 (define_expand "bgt"
1189 (if_then_else (match_dup 1)
1190 (label_ref (match_operand 0 "" ""))
1195 operands[1] = gen_compare ((int)GT, m32r_compare_op0, m32r_compare_op1, FALSE);
1198 (define_expand "ble"
1200 (if_then_else (match_dup 1)
1201 (label_ref (match_operand 0 "" ""))
1206 operands[1] = gen_compare ((int)LE, m32r_compare_op0, m32r_compare_op1, FALSE);
1209 (define_expand "bge"
1211 (if_then_else (match_dup 1)
1212 (label_ref (match_operand 0 "" ""))
1217 operands[1] = gen_compare ((int)GE, m32r_compare_op0, m32r_compare_op1, FALSE);
1220 (define_expand "blt"
1222 (if_then_else (match_dup 1)
1223 (label_ref (match_operand 0 "" ""))
1228 operands[1] = gen_compare ((int)LT, m32r_compare_op0, m32r_compare_op1, FALSE);
1231 (define_expand "bgtu"
1233 (if_then_else (match_dup 1)
1234 (label_ref (match_operand 0 "" ""))
1239 operands[1] = gen_compare ((int)GTU, m32r_compare_op0, m32r_compare_op1, FALSE);
1242 (define_expand "bleu"
1244 (if_then_else (match_dup 1)
1245 (label_ref (match_operand 0 "" ""))
1250 operands[1] = gen_compare ((int)LEU, m32r_compare_op0, m32r_compare_op1, FALSE);
1253 (define_expand "bgeu"
1255 (if_then_else (match_dup 1)
1256 (label_ref (match_operand 0 "" ""))
1261 operands[1] = gen_compare ((int)GEU, m32r_compare_op0, m32r_compare_op1, FALSE);
1264 (define_expand "bltu"
1266 (if_then_else (match_dup 1)
1267 (label_ref (match_operand 0 "" ""))
1272 operands[1] = gen_compare ((int)LTU, m32r_compare_op0, m32r_compare_op1, FALSE);
1275 ;; Now match both normal and inverted jump.
1277 (define_insn "*branch_insn"
1279 (if_then_else (match_operator 1 "eqne_comparison_operator"
1280 [(reg 17) (const_int 0)])
1281 (label_ref (match_operand 0 "" ""))
1286 static char instruction[40];
1287 sprintf (instruction, \"%s%s %%l0\",
1288 (GET_CODE (operands[1]) == NE) ? \"bc\" : \"bnc\",
1289 (get_attr_length (insn) == 2) ? \".s\" : \"\");
1292 [(set_attr "type" "branch")
1293 ; We use 400/800 instead of 512,1024 to account for inaccurate insn
1294 ; lengths and insn alignments that are complex to track.
1295 ; It's not important that we be hyper-precise here. It may be more
1296 ; important blah blah blah when the chip supports parallel execution
1297 ; blah blah blah but until then blah blah blah this is simple and
1299 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1305 (define_insn "*rev_branch_insn"
1307 (if_then_else (match_operator 1 "eqne_comparison_operator"
1308 [(reg 17) (const_int 0)])
1310 (label_ref (match_operand 0 "" ""))))]
1311 ;"REVERSIBLE_CC_MODE (GET_MODE (XEXP (operands[1], 0)))"
1315 static char instruction[40];
1316 sprintf (instruction, \"%s%s %%l0\",
1317 (GET_CODE (operands[1]) == EQ) ? \"bc\" : \"bnc\",
1318 (get_attr_length (insn) == 2) ? \".s\" : \"\");
1321 [(set_attr "type" "branch")
1322 ; We use 400/800 instead of 512,1024 to account for inaccurate insn
1323 ; lengths and insn alignments that are complex to track.
1324 ; It's not important that we be hyper-precise here. It may be more
1325 ; important blah blah blah when the chip supports parallel execution
1326 ; blah blah blah but until then blah blah blah this is simple and
1328 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1334 ; reg/reg compare and branch insns
1336 (define_insn "*reg_branch_insn"
1338 (if_then_else (match_operator 1 "eqne_comparison_operator"
1339 [(match_operand:SI 2 "register_operand" "r")
1340 (match_operand:SI 3 "register_operand" "r")])
1341 (label_ref (match_operand 0 "" ""))
1346 /* Is branch target reachable with beq/bne? */
1347 if (get_attr_length (insn) == 4)
1349 if (GET_CODE (operands[1]) == EQ)
1350 return \"beq %2,%3,%l0\";
1352 return \"bne %2,%3,%l0\";
1356 if (GET_CODE (operands[1]) == EQ)
1357 return \"bne %2,%3,1f\;bra %l0\;1:\";
1359 return \"beq %2,%3,1f\;bra %l0\;1:\";
1362 [(set_attr "type" "branch")
1363 ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1364 ; which is complex to track and inaccurate length specs.
1365 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1371 (define_insn "*rev_reg_branch_insn"
1373 (if_then_else (match_operator 1 "eqne_comparison_operator"
1374 [(match_operand:SI 2 "register_operand" "r")
1375 (match_operand:SI 3 "register_operand" "r")])
1377 (label_ref (match_operand 0 "" ""))))]
1381 /* Is branch target reachable with beq/bne? */
1382 if (get_attr_length (insn) == 4)
1384 if (GET_CODE (operands[1]) == NE)
1385 return \"beq %2,%3,%l0\";
1387 return \"bne %2,%3,%l0\";
1391 if (GET_CODE (operands[1]) == NE)
1392 return \"bne %2,%3,1f\;bra %l0\;1:\";
1394 return \"beq %2,%3,1f\;bra %l0\;1:\";
1397 [(set_attr "type" "branch")
1398 ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1399 ; which is complex to track and inaccurate length specs.
1400 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1406 ; reg/zero compare and branch insns
1408 (define_insn "*zero_branch_insn"
1410 (if_then_else (match_operator 1 "signed_comparison_operator"
1411 [(match_operand:SI 2 "register_operand" "r")
1413 (label_ref (match_operand 0 "" ""))
1421 switch (GET_CODE (operands[1]))
1423 case EQ : br = \"eq\"; invbr = \"ne\"; break;
1424 case NE : br = \"ne\"; invbr = \"eq\"; break;
1425 case LE : br = \"le\"; invbr = \"gt\"; break;
1426 case GT : br = \"gt\"; invbr = \"le\"; break;
1427 case LT : br = \"lt\"; invbr = \"ge\"; break;
1428 case GE : br = \"ge\"; invbr = \"lt\"; break;
1431 /* Is branch target reachable with bxxz? */
1432 if (get_attr_length (insn) == 4)
1434 sprintf (asmtext, \"b%sz %%2,%%l0\", br);
1435 output_asm_insn (asmtext, operands);
1439 sprintf (asmtext, \"b%sz %%2,1f\;bra %%l0\;1:\", invbr);
1440 output_asm_insn (asmtext, operands);
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_zero_branch_insn"
1455 (if_then_else (match_operator 1 "eqne_comparison_operator"
1456 [(match_operand:SI 2 "register_operand" "r")
1459 (label_ref (match_operand 0 "" ""))))]
1466 switch (GET_CODE (operands[1]))
1468 case EQ : br = \"eq\"; invbr = \"ne\"; break;
1469 case NE : br = \"ne\"; invbr = \"eq\"; break;
1470 case LE : br = \"le\"; invbr = \"gt\"; break;
1471 case GT : br = \"gt\"; invbr = \"le\"; break;
1472 case LT : br = \"lt\"; invbr = \"ge\"; break;
1473 case GE : br = \"ge\"; invbr = \"lt\"; break;
1476 /* Is branch target reachable with bxxz? */
1477 if (get_attr_length (insn) == 4)
1479 sprintf (asmtext, \"b%sz %%2,%%l0\", invbr);
1480 output_asm_insn (asmtext, operands);
1484 sprintf (asmtext, \"b%sz %%2,1f\;bra %%l0\;1:\", br);
1485 output_asm_insn (asmtext, operands);
1489 [(set_attr "type" "branch")
1490 ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1491 ; which is complex to track and inaccurate length specs.
1492 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1498 ;; Unconditional and other jump instructions.
1501 [(set (pc) (label_ref (match_operand 0 "" "")))]
1504 [(set_attr "type" "uncond_branch")
1505 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1511 (define_insn "indirect_jump"
1512 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
1515 [(set_attr "type" "uncond_branch")
1516 (set_attr "length" "2")])
1518 (define_insn "tablejump"
1519 [(set (pc) (match_operand:SI 0 "address_operand" "p"))
1520 (use (label_ref (match_operand 1 "" "")))]
1523 [(set_attr "type" "uncond_branch")
1524 (set_attr "length" "2")])
1526 (define_expand "call"
1527 ;; operands[1] is stack_size_rtx
1528 ;; operands[2] is next_arg_register
1529 [(parallel [(call (match_operand:SI 0 "call_operand" "")
1530 (match_operand 1 "" ""))
1531 (clobber (reg:SI 14))])]
1535 (define_insn "*call_via_reg"
1536 [(call (mem:SI (match_operand:SI 0 "register_operand" "r"))
1537 (match_operand 1 "" ""))
1538 (clobber (reg:SI 14))]
1541 [(set_attr "type" "call")
1542 (set_attr "length" "2")])
1544 (define_insn "*call_via_label"
1545 [(call (mem:SI (match_operand:SI 0 "call_address_operand" ""))
1546 (match_operand 1 "" ""))
1547 (clobber (reg:SI 14))]
1551 int call26_p = call26_operand (operands[0], FUNCTION_MODE);
1555 /* We may not be able to reach with a `bl' insn so punt and leave it to
1557 We do this here, rather than doing a force_reg in the define_expand
1558 so these insns won't be separated, say by scheduling, thus simplifying
1560 return \"seth r14,%T0\;add3 r14,r14,%B0\;jl r14\";
1565 [(set_attr "type" "call")
1566 (set (attr "length")
1567 (if_then_else (eq (symbol_ref "call26_operand (operands[0], FUNCTION_MODE)")
1569 (const_int 12) ; 10 + 2 for nop filler
1570 ; The return address must be on a 4 byte boundary so
1571 ; there's no point in using a value of 2 here. A 2 byte
1572 ; insn may go in the left slot but we currently can't
1573 ; use such knowledge.
1576 (define_expand "call_value"
1577 ;; operand 2 is stack_size_rtx
1578 ;; operand 3 is next_arg_register
1579 [(parallel [(set (match_operand 0 "register_operand" "=r")
1580 (call (match_operand:SI 1 "call_operand" "")
1581 (match_operand 2 "" "")))
1582 (clobber (reg:SI 14))])]
1586 (define_insn "*call_value_via_reg"
1587 [(set (match_operand 0 "register_operand" "=r")
1588 (call (mem:SI (match_operand:SI 1 "register_operand" "r"))
1589 (match_operand 2 "" "")))
1590 (clobber (reg:SI 14))]
1593 [(set_attr "type" "call")
1594 (set_attr "length" "2")])
1596 (define_insn "*call_value_via_label"
1597 [(set (match_operand 0 "register_operand" "=r")
1598 (call (mem:SI (match_operand:SI 1 "call_address_operand" ""))
1599 (match_operand 2 "" "")))
1600 (clobber (reg:SI 14))]
1604 int call26_p = call26_operand (operands[1], FUNCTION_MODE);
1608 /* We may not be able to reach with a `bl' insn so punt and leave it to
1610 We do this here, rather than doing a force_reg in the define_expand
1611 so these insns won't be separated, say by scheduling, thus simplifying
1613 return \"seth r14,%T1\;add3 r14,r14,%B1\;jl r14\";
1618 [(set_attr "type" "call")
1619 (set (attr "length")
1620 (if_then_else (eq (symbol_ref "call26_operand (operands[1], FUNCTION_MODE)")
1622 (const_int 12) ; 10 + 2 for nop filler
1623 ; The return address must be on a 4 byte boundary so
1624 ; there's no point in using a value of 2 here. A 2 byte
1625 ; insn may go in the left slot but we currently can't
1626 ; use such knowledge.
1633 [(set_attr "type" "int2")
1634 (set_attr "length" "2")])
1636 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
1637 ;; all of memory. This blocks insns from being moved across this point.
1639 (define_insn "blockage"
1640 [(unspec_volatile [(const_int 0)] 0)]
1644 ;; Special pattern to flush the icache.
1646 (define_insn "flush_icache"
1647 [(unspec_volatile [(match_operand 0 "memory_operand" "m")] 0)]
1649 "* return \"nop ; flush-icache\";"
1650 [(set_attr "type" "int2")
1651 (set_attr "length" "2")])
1653 ;; Conditional move instructions
1654 ;; Based on those done for the d10v
1657 (define_expand "movsicc"
1659 (set (match_operand:SI 0 "register_operand" "r")
1660 (if_then_else:SI (match_operand 1 "" "")
1661 (match_operand:SI 2 "conditional_move_operand" "O")
1662 (match_operand:SI 3 "conditional_move_operand" "O")
1669 if (! zero_and_one (operands [2], operands [3]))
1672 /* Generate the comparision that will set the carry flag. */
1673 operands[1] = gen_compare ((int)GET_CODE (operands[1]), m32r_compare_op0,
1674 m32r_compare_op1, TRUE);
1676 /* See other movsicc pattern below for reason why. */
1677 emit_insn (gen_blockage());
1680 ;; Generate the conditional instructions based on how the carry flag is examined.
1681 (define_insn "*movsicc_internal"
1682 [(set (match_operand:SI 0 "register_operand" "r")
1683 (if_then_else:SI (match_operand 1 "carry_compare_operand" "")
1684 (match_operand:SI 2 "conditional_move_operand" "O")
1685 (match_operand:SI 3 "conditional_move_operand" "O")
1688 "zero_and_one (operands [2], operands[3])"
1689 "* return emit_cond_move (operands, insn);"
1690 [(set_attr "type" "multi")
1691 (set_attr "length" "8")
1695 (define_insn "movcc_insn"
1696 [(set (match_operand:SI 0 "register_operand" "=r")
1700 [(set_attr "type" "misc")
1701 (set_attr "length" "2")]
1705 ;; Split up troublesome insns for better scheduling.
1707 ;; Peepholes go at the end.
1709 ;; ??? Setting the type attribute may not be useful, but for completeness
1713 [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "r")
1715 (match_operand:SI 1 "register_operand" "r"))]
1716 "0 && dead_or_set_p (insn, operands[0])"
1718 [(set_attr "type" "store2")
1719 (set_attr "length" "2")])
1721 ;; This case is triggered by compiling this code:
1723 ;; extern void sub(int *);
1727 ;; while (i < j) sub(&k);
1734 ;; Without the peephole the following assembler is generated for the
1735 ;; divide and subtract expressions:
1742 ;; Simialr code is produced for the subtract expression. With this
1743 ;; peephole the redundant move is eliminated.
1745 ;; This optimisation onbly works if PRESERVE_DEATH_INFO_REGNO_P is
1746 ;; defined in m32r.h
1749 [(set (match_operand:SI 0 "register_operand" "r")
1750 (match_operand:SI 1 "register_operand" "r")
1752 (set (mem:SI (plus: SI (match_operand:SI 2 "register_operand" "r")
1753 (match_operand:SI 3 "immediate_operand" "J")))
1757 "0 && dead_or_set_p (insn, operands [0])"
1759 [(set_attr "type" "store4")
1760 (set_attr "length" "4")
1764 ;; Block moves, see m32r.c for more details.
1765 ;; Argument 0 is the destination
1766 ;; Argument 1 is the source
1767 ;; Argument 2 is the length
1768 ;; Argument 3 is the alignment
1770 (define_expand "movstrsi"
1771 [(parallel [(set (match_operand:BLK 0 "general_operand" "")
1772 (match_operand:BLK 1 "general_operand" ""))
1773 (use (match_operand:SI 2 "immediate_operand" ""))
1774 (use (match_operand:SI 3 "immediate_operand" ""))])]
1778 if (operands[0]) /* avoid unused code messages */
1780 m32r_expand_block_move (operands);
1785 ;; Insn generated by block moves
1787 (define_insn "movstrsi_internal"
1788 [(set (mem:BLK (match_operand:SI 0 "register_operand" "r")) ;; destination
1789 (mem:BLK (match_operand:SI 1 "register_operand" "r"))) ;; source
1790 (use (match_operand:SI 2 "m32r_block_immediate_operand" "J"));; # bytes to move
1791 (set (match_dup 0) (plus:SI (match_dup 0) (minus:SI (match_dup 2) (const_int 4))))
1792 (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))
1793 (clobber (match_scratch:SI 3 "=&r")) ;; temp 1
1794 (clobber (match_scratch:SI 4 "=&r"))] ;; temp 2
1796 "* return m32r_output_block_move (insn, operands);"
1797 [(set_attr "type" "store8")
1798 (set_attr "length" "72")]) ;; Maximum