1 ;; Machine description of the Renesas M32R cpu for GNU C compiler
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2001, 2003, 2004, 2005,
3 ; 2007 Free Software Foundation, Inc.
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published
9 ;; by the Free Software Foundation; either version 2, or (at your
10 ;; option) any later version.
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 ;; License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 ;; Boston, MA 02110-1301, USA.
22 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
24 ;; UNSPEC_VOLATILE usage
27 (UNSPECV_FLUSH_ICACHE 1)])
31 [(UNSPEC_LOAD_SDA_BASE 2)
33 (UNSPEC_PIC_LOAD_ADDR 4)
38 ;; Insn type. Used to default other attribute values.
40 "int2,int4,load2,load4,load8,store2,store4,store8,shift2,shift4,mul2,div4,uncond_branch,branch,call,multi,misc"
41 (const_string "misc"))
44 (define_attr "length" ""
45 (cond [(eq_attr "type" "int2,load2,store2,shift2,mul2")
48 (eq_attr "type" "int4,load4,store4,shift4,div4")
51 (eq_attr "type" "multi")
54 (eq_attr "type" "uncond_branch,branch,call")
59 ;; The length here is the length of a single asm. Unfortunately it might be
60 ;; 2 or 4 so we must allow for 4. That's ok though.
61 (define_asm_attributes
62 [(set_attr "length" "4")
63 (set_attr "type" "multi")])
65 ;; Whether an instruction is short (16-bit) or long (32-bit).
66 (define_attr "insn_size" "short,long"
67 (if_then_else (eq_attr "type" "int2,load2,store2,shift2,mul2")
68 (const_string "short")
69 (const_string "long")))
71 ;; The target CPU we're compiling for.
72 (define_attr "cpu" "m32r,m32r2,m32rx"
73 (cond [(ne (symbol_ref "TARGET_M32RX") (const_int 0))
74 (const_string "m32rx")
75 (ne (symbol_ref "TARGET_M32R2") (const_int 0))
76 (const_string "m32r2")]
77 (const_string "m32r")))
79 ;; Defines the pipeline where an instruction can be executed on.
80 ;; For the M32R, a short instruction can execute one of the two pipes.
81 ;; For the M32Rx, the restrictions are modelled in the second
82 ;; condition of this attribute definition.
83 (define_attr "m32r_pipeline" "either,s,o,long"
84 (cond [(and (eq_attr "cpu" "m32r")
85 (eq_attr "insn_size" "short"))
86 (const_string "either")
87 (eq_attr "insn_size" "!short")
88 (const_string "long")]
89 (cond [(eq_attr "type" "int2")
90 (const_string "either")
91 (eq_attr "type" "load2,store2,shift2,uncond_branch,branch,call")
93 (eq_attr "type" "mul2")
95 (const_string "long"))))
97 ;; ::::::::::::::::::::
99 ;; :: Pipeline description
101 ;; ::::::::::::::::::::
103 ;; This model is based on Chapter 2, Appendix 3 and Appendix 4 of the
104 ;; "M32R-FPU Software Manual", Revision 1.01, plus additional information
105 ;; obtained by our best friend and mine, Google.
107 ;; The pipeline is modelled as a fetch unit, and a core with a memory unit,
108 ;; two execution units, where "fetch" models IF and D, "memory" for MEM1
109 ;; and MEM2, and "EXEC" for E, E1, E2, EM, and EA. Writeback and
110 ;; bypasses are not modelled.
111 (define_automaton "m32r")
113 ;; We pretend there are two short (16 bits) instruction fetchers. The
114 ;; "s" short fetcher cannot be reserved until the "o" short fetcher is
115 ;; reserved. Some instructions reserve both the left and right fetchers.
116 ;; These fetch units are a hack to get GCC to better pack the instructions
117 ;; for the M32Rx processor, which has two execution pipes.
119 ;; In reality there is only one decoder, which can decode either two 16-bit
120 ;; instructions, or a single 32-bit instruction.
122 ;; Note, "fetch" models both the IF and the D pipeline stages.
124 ;; The m32rx core has two execution pipes. We name them o_E and s_E.
125 ;; In addition, there's a memory unit.
127 (define_cpu_unit "o_IF,s_IF,o_E,s_E,memory" "m32r")
129 ;; Prevent the s pipe from being reserved before the o pipe.
130 (absence_set "s_IF" "o_IF")
131 (absence_set "s_E" "o_E")
133 ;; On the M32Rx, long instructions execute on both pipes, so reserve
134 ;; both fetch slots and both pipes.
135 (define_reservation "long_IF" "o_IF+s_IF")
136 (define_reservation "long_E" "o_E+s_E")
138 ;; ::::::::::::::::::::
140 ;; Simple instructions do 4 stages: IF D E WB. WB is not modelled.
141 ;; Hence, ready latency is 1.
142 (define_insn_reservation "short_left" 1
143 (and (eq_attr "m32r_pipeline" "o")
144 (and (eq_attr "insn_size" "short")
145 (eq_attr "type" "!load2")))
148 (define_insn_reservation "short_right" 1
149 (and (eq_attr "m32r_pipeline" "s")
150 (and (eq_attr "insn_size" "short")
151 (eq_attr "type" "!load2")))
154 (define_insn_reservation "short_either" 1
155 (and (eq_attr "m32r_pipeline" "either")
156 (and (eq_attr "insn_size" "short")
157 (eq_attr "type" "!load2")))
160 (define_insn_reservation "long_m32r" 1
161 (and (eq_attr "cpu" "m32r")
162 (and (eq_attr "insn_size" "long")
163 (eq_attr "type" "!load4,load8")))
166 (define_insn_reservation "long_m32rx" 2
167 (and (eq_attr "m32r_pipeline" "long")
168 (and (eq_attr "insn_size" "long")
169 (eq_attr "type" "!load4,load8")))
172 ;; Load/store instructions do 6 stages: IF D E MEM1 MEM2 WB.
173 ;; MEM1 may require more than one cycle depending on locality. We
174 ;; optimistically assume all memory is nearby, i.e. MEM1 takes only
175 ;; one cycle. Hence, ready latency is 3.
177 ;; The M32Rx can do short load/store only on the left pipe.
178 (define_insn_reservation "short_load_left" 3
179 (and (eq_attr "m32r_pipeline" "o")
180 (and (eq_attr "insn_size" "short")
181 (eq_attr "type" "load2")))
184 (define_insn_reservation "short_load" 3
185 (and (eq_attr "m32r_pipeline" "either")
186 (and (eq_attr "insn_size" "short")
187 (eq_attr "type" "load2")))
188 "s_IF|o_IF,s_E|o_E,memory*2")
190 (define_insn_reservation "long_load" 3
191 (and (eq_attr "cpu" "m32r")
192 (and (eq_attr "insn_size" "long")
193 (eq_attr "type" "load4,load8")))
194 "long_IF,long_E,memory*2")
196 (define_insn_reservation "long_load_m32rx" 3
197 (and (eq_attr "m32r_pipeline" "long")
198 (eq_attr "type" "load4,load8"))
199 "long_IF,long_E,memory*2")
202 (include "predicates.md")
204 ;; Expand prologue as RTL
205 (define_expand "prologue"
210 m32r_expand_prologue ();
214 ;; Expand epilogue as RTL
215 (define_expand "epilogue"
220 m32r_expand_epilogue ();
221 emit_jump_insn (gen_return_normal ());
225 ;; Move instructions.
227 ;; For QI and HI moves, the register must contain the full properly
228 ;; sign-extended value. nonzero_bits assumes this [otherwise
229 ;; SHORT_IMMEDIATES_SIGN_EXTEND must be used, but the comment for it
230 ;; says it's a kludge and the .md files should be fixed instead].
232 (define_expand "movqi"
233 [(set (match_operand:QI 0 "general_operand" "")
234 (match_operand:QI 1 "general_operand" ""))]
238 /* Fixup PIC cases. */
241 if (symbolic_operand (operands[1], QImode))
243 if (reload_in_progress || reload_completed)
244 operands[1] = m32r_legitimize_pic_address (operands[1], operands[0]);
246 operands[1] = m32r_legitimize_pic_address (operands[1], NULL_RTX);
250 /* Everything except mem = const or mem = mem can be done easily.
251 Objects in the small data area are handled too. */
253 if (GET_CODE (operands[0]) == MEM)
254 operands[1] = force_reg (QImode, operands[1]);
257 (define_insn "*movqi_insn"
258 [(set (match_operand:QI 0 "move_dest_operand" "=r,r,r,r,r,T,m")
259 (match_operand:QI 1 "move_src_operand" "r,I,JQR,T,m,r,r"))]
260 "register_operand (operands[0], QImode) || register_operand (operands[1], QImode)"
269 [(set_attr "type" "int2,int2,int4,load2,load4,store2,store4")
270 (set_attr "length" "2,2,4,2,4,2,4")])
272 (define_expand "movhi"
273 [(set (match_operand:HI 0 "general_operand" "")
274 (match_operand:HI 1 "general_operand" ""))]
278 /* Fixup PIC cases. */
281 if (symbolic_operand (operands[1], HImode))
283 if (reload_in_progress || reload_completed)
284 operands[1] = m32r_legitimize_pic_address (operands[1], operands[0]);
286 operands[1] = m32r_legitimize_pic_address (operands[1], NULL_RTX);
290 /* Everything except mem = const or mem = mem can be done easily. */
292 if (GET_CODE (operands[0]) == MEM)
293 operands[1] = force_reg (HImode, operands[1]);
296 (define_insn "*movhi_insn"
297 [(set (match_operand:HI 0 "move_dest_operand" "=r,r,r,r,r,r,T,m")
298 (match_operand:HI 1 "move_src_operand" "r,I,JQR,K,T,m,r,r"))]
299 "register_operand (operands[0], HImode) || register_operand (operands[1], HImode)"
309 [(set_attr "type" "int2,int2,int4,int4,load2,load4,store2,store4")
310 (set_attr "length" "2,2,4,4,2,4,2,4")])
312 (define_expand "movsi_push"
313 [(set (mem:SI (pre_dec:SI (match_operand:SI 0 "register_operand" "")))
314 (match_operand:SI 1 "register_operand" ""))]
318 (define_expand "movsi_pop"
319 [(set (match_operand:SI 0 "register_operand" "")
320 (mem:SI (post_inc:SI (match_operand:SI 1 "register_operand" ""))))]
324 (define_expand "movsi"
325 [(set (match_operand:SI 0 "general_operand" "")
326 (match_operand:SI 1 "general_operand" ""))]
330 /* Fixup PIC cases. */
333 if (symbolic_operand (operands[1], SImode))
335 if (reload_in_progress || reload_completed)
336 operands[1] = m32r_legitimize_pic_address (operands[1], operands[0]);
338 operands[1] = m32r_legitimize_pic_address (operands[1], NULL_RTX);
342 /* Everything except mem = const or mem = mem can be done easily. */
344 if (GET_CODE (operands[0]) == MEM)
345 operands[1] = force_reg (SImode, operands[1]);
347 /* Small Data Area reference? */
348 if (small_data_operand (operands[1], SImode))
350 emit_insn (gen_movsi_sda (operands[0], operands[1]));
354 /* If medium or large code model, symbols have to be loaded with
356 if (addr32_operand (operands[1], SImode))
358 emit_insn (gen_movsi_addr32 (operands[0], operands[1]));
363 ;; ??? Do we need a const_double constraint here for large unsigned values?
364 (define_insn "*movsi_insn"
365 [(set (match_operand:SI 0 "move_dest_operand" "=r,r,r,r,r,r,r,r,r,T,S,m")
366 (match_operand:SI 1 "move_src_operand" "r,I,J,MQ,L,n,T,U,m,r,r,r"))]
367 "register_operand (operands[0], SImode) || register_operand (operands[1], SImode)"
370 if (GET_CODE (operands[0]) == REG || GET_CODE (operands[1]) == SUBREG)
372 switch (GET_CODE (operands[1]))
384 if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
385 && XEXP (XEXP (operands[1], 0), 0) == stack_pointer_rtx)
391 value = INTVAL (operands[1]);
393 return \"ldi %0,%#%1\\t; %X1\";
395 if (UINT24_P (value))
396 return \"ld24 %0,%#%1\\t; %X1\";
398 if (UPPER16_P (value))
399 return \"seth %0,%#%T1\\t; %X1\";
407 return \"ld24 %0,%#%1\";
413 else if (GET_CODE (operands[0]) == MEM
414 && (GET_CODE (operands[1]) == REG || GET_CODE (operands[1]) == SUBREG))
416 if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
417 && XEXP (XEXP (operands[0], 0), 0) == stack_pointer_rtx)
425 [(set_attr "type" "int2,int2,int4,int4,int4,multi,load2,load2,load4,store2,store2,store4")
426 (set_attr "length" "2,2,4,4,4,8,2,2,4,2,2,4")])
428 ; Try to use a four byte / two byte pair for constants not loadable with
432 [(set (match_operand:SI 0 "register_operand" "")
433 (match_operand:SI 1 "two_insn_const_operand" ""))]
435 [(set (match_dup 0) (match_dup 2))
436 (set (match_dup 0) (ior:SI (match_dup 0) (match_dup 3)))]
439 unsigned HOST_WIDE_INT val = INTVAL (operands[1]);
440 unsigned HOST_WIDE_INT tmp;
443 /* In all cases we will emit two instructions. However we try to
444 use 2 byte instructions wherever possible. We can assume the
445 constant isn't loadable with any of ldi, ld24, or seth. */
447 /* See if we can load a 24-bit unsigned value and invert it. */
448 if (UINT24_P (~ val))
450 emit_insn (gen_movsi (operands[0], GEN_INT (~ val)));
451 emit_insn (gen_one_cmplsi2 (operands[0], operands[0]));
455 /* See if we can load a 24-bit unsigned value and shift it into place.
456 0x01fffffe is just beyond ld24's range. */
457 for (shift = 1, tmp = 0x01fffffe;
461 if ((val & ~tmp) == 0)
463 emit_insn (gen_movsi (operands[0], GEN_INT (val >> shift)));
464 emit_insn (gen_ashlsi3 (operands[0], operands[0], GEN_INT (shift)));
469 /* Can't use any two byte insn, fall back to seth/or3. Use ~0xffff instead
470 of 0xffff0000, since the later fails on a 64-bit host. */
471 operands[2] = GEN_INT ((val) & ~0xffff);
472 operands[3] = GEN_INT ((val) & 0xffff);
476 [(set (match_operand:SI 0 "register_operand" "")
477 (match_operand:SI 1 "seth_add3_operand" ""))]
480 (high:SI (match_dup 1)))
482 (lo_sum:SI (match_dup 0)
486 ;; Small data area support.
487 ;; The address of _SDA_BASE_ is loaded into a register and all objects in
488 ;; the small data area are indexed off that. This is done for each reference
489 ;; but cse will clean things up for us. We let the compiler choose the
490 ;; register to use so we needn't allocate (and maybe even fix) a special
491 ;; register to use. Since the load and store insns have a 16-bit offset the
492 ;; total size of the data area can be 64K. However, if the data area lives
493 ;; above 16M (24 bits), _SDA_BASE_ will have to be loaded with seth/add3 which
494 ;; would then yield 3 instructions to reference an object [though there would
495 ;; be no net loss if two or more objects were referenced]. The 3 insns can be
496 ;; reduced back to 2 if the size of the small data area were reduced to 32K
497 ;; [then seth + ld/st would work for any object in the area]. Doing this
498 ;; would require special handling of _SDA_BASE_ (its value would be
499 ;; (.sdata + 32K) & 0xffff0000) and reloc computations would be different
500 ;; [I think]. What to do about this is deferred until later and for now we
501 ;; require .sdata to be in the first 16M.
503 (define_expand "movsi_sda"
505 (unspec:SI [(const_int 0)] UNSPEC_LOAD_SDA_BASE))
506 (set (match_operand:SI 0 "register_operand" "")
507 (lo_sum:SI (match_dup 2)
508 (match_operand:SI 1 "small_data_operand" "")))]
512 if (reload_in_progress || reload_completed)
513 operands[2] = operands[0];
515 operands[2] = gen_reg_rtx (SImode);
518 (define_insn "*load_sda_base_32"
519 [(set (match_operand:SI 0 "register_operand" "=r")
520 (unspec:SI [(const_int 0)] UNSPEC_LOAD_SDA_BASE))]
522 "seth %0,%#shigh(_SDA_BASE_)\;add3 %0,%0,%#low(_SDA_BASE_)"
523 [(set_attr "type" "multi")
524 (set_attr "length" "8")])
526 (define_insn "*load_sda_base"
527 [(set (match_operand:SI 0 "register_operand" "=r")
528 (unspec:SI [(const_int 0)] UNSPEC_LOAD_SDA_BASE))]
530 "ld24 %0,#_SDA_BASE_"
531 [(set_attr "type" "int4")
532 (set_attr "length" "4")])
534 ;; 32-bit address support.
536 (define_expand "movsi_addr32"
538 ; addr32_operand isn't used because it's too restrictive,
539 ; seth_add3_operand is more general and thus safer.
540 (high:SI (match_operand:SI 1 "seth_add3_operand" "")))
541 (set (match_operand:SI 0 "register_operand" "")
542 (lo_sum:SI (match_dup 2) (match_dup 1)))]
546 if (reload_in_progress || reload_completed)
547 operands[2] = operands[0];
549 operands[2] = gen_reg_rtx (SImode);
552 (define_insn "set_hi_si"
553 [(set (match_operand:SI 0 "register_operand" "=r")
554 (high:SI (match_operand 1 "symbolic_operand" "")))]
556 "seth %0,%#shigh(%1)"
557 [(set_attr "type" "int4")
558 (set_attr "length" "4")])
560 (define_insn "lo_sum_si"
561 [(set (match_operand:SI 0 "register_operand" "=r")
562 (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
563 (match_operand:SI 2 "immediate_operand" "in")))]
566 [(set_attr "type" "int4")
567 (set_attr "length" "4")])
569 (define_expand "movdi"
570 [(set (match_operand:DI 0 "general_operand" "")
571 (match_operand:DI 1 "general_operand" ""))]
575 /* Fixup PIC cases. */
578 if (symbolic_operand (operands[1], DImode))
580 if (reload_in_progress || reload_completed)
581 operands[1] = m32r_legitimize_pic_address (operands[1], operands[0]);
583 operands[1] = m32r_legitimize_pic_address (operands[1], NULL_RTX);
587 /* Everything except mem = const or mem = mem can be done easily. */
589 if (GET_CODE (operands[0]) == MEM)
590 operands[1] = force_reg (DImode, operands[1]);
593 (define_insn "*movdi_insn"
594 [(set (match_operand:DI 0 "move_dest_operand" "=r,r,r,r,m")
595 (match_operand:DI 1 "move_double_src_operand" "r,nG,F,m,r"))]
596 "register_operand (operands[0], DImode) || register_operand (operands[1], DImode)"
598 [(set_attr "type" "multi,multi,multi,load8,store8")
599 (set_attr "length" "4,4,16,6,6")])
602 [(set (match_operand:DI 0 "move_dest_operand" "")
603 (match_operand:DI 1 "move_double_src_operand" ""))]
606 "operands[2] = gen_split_move_double (operands);")
608 ;; Floating point move insns.
610 (define_expand "movsf"
611 [(set (match_operand:SF 0 "general_operand" "")
612 (match_operand:SF 1 "general_operand" ""))]
616 /* Fixup PIC cases. */
619 if (symbolic_operand (operands[1], SFmode))
621 if (reload_in_progress || reload_completed)
622 operands[1] = m32r_legitimize_pic_address (operands[1], operands[0]);
624 operands[1] = m32r_legitimize_pic_address (operands[1], NULL_RTX);
628 /* Everything except mem = const or mem = mem can be done easily. */
630 if (GET_CODE (operands[0]) == MEM)
631 operands[1] = force_reg (SFmode, operands[1]);
634 (define_insn "*movsf_insn"
635 [(set (match_operand:SF 0 "move_dest_operand" "=r,r,r,r,r,T,S,m")
636 (match_operand:SF 1 "move_src_operand" "r,F,U,S,m,r,r,r"))]
637 "register_operand (operands[0], SFmode) || register_operand (operands[1], SFmode)"
647 ;; ??? Length of alternative 1 is either 2, 4 or 8.
648 [(set_attr "type" "int2,multi,load2,load2,load4,store2,store2,store4")
649 (set_attr "length" "2,8,2,2,4,2,2,4")])
652 [(set (match_operand:SF 0 "register_operand" "")
653 (match_operand:SF 1 "const_double_operand" ""))]
655 [(set (match_dup 2) (match_dup 3))]
658 operands[2] = operand_subword (operands[0], 0, 0, SFmode);
659 operands[3] = operand_subword (operands[1], 0, 0, SFmode);
662 (define_expand "movdf"
663 [(set (match_operand:DF 0 "general_operand" "")
664 (match_operand:DF 1 "general_operand" ""))]
668 /* Fixup PIC cases. */
671 if (symbolic_operand (operands[1], DFmode))
673 if (reload_in_progress || reload_completed)
674 operands[1] = m32r_legitimize_pic_address (operands[1], operands[0]);
676 operands[1] = m32r_legitimize_pic_address (operands[1], NULL_RTX);
680 /* Everything except mem = const or mem = mem can be done easily. */
682 if (GET_CODE (operands[0]) == MEM)
683 operands[1] = force_reg (DFmode, operands[1]);
686 (define_insn "*movdf_insn"
687 [(set (match_operand:DF 0 "move_dest_operand" "=r,r,r,m")
688 (match_operand:DF 1 "move_double_src_operand" "r,F,m,r"))]
689 "register_operand (operands[0], DFmode) || register_operand (operands[1], DFmode)"
691 [(set_attr "type" "multi,multi,load8,store8")
692 (set_attr "length" "4,16,6,6")])
695 [(set (match_operand:DF 0 "move_dest_operand" "")
696 (match_operand:DF 1 "move_double_src_operand" ""))]
699 "operands[2] = gen_split_move_double (operands);")
701 ;; Zero extension instructions.
703 (define_insn "zero_extendqihi2"
704 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
705 (zero_extend:HI (match_operand:QI 1 "extend_operand" "r,T,m")))]
711 [(set_attr "type" "int4,load2,load4")
712 (set_attr "length" "4,2,4")])
714 (define_insn "zero_extendqisi2"
715 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
716 (zero_extend:SI (match_operand:QI 1 "extend_operand" "r,T,m")))]
722 [(set_attr "type" "int4,load2,load4")
723 (set_attr "length" "4,2,4")])
725 (define_insn "zero_extendhisi2"
726 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
727 (zero_extend:SI (match_operand:HI 1 "extend_operand" "r,T,m")))]
733 [(set_attr "type" "int4,load2,load4")
734 (set_attr "length" "4,2,4")])
736 ;; Signed conversions from a smaller integer to a larger integer
737 (define_insn "extendqihi2"
738 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
739 (sign_extend:HI (match_operand:QI 1 "extend_operand" "0,T,m")))]
745 [(set_attr "type" "multi,load2,load4")
746 (set_attr "length" "2,2,4")])
749 [(set (match_operand:HI 0 "register_operand" "")
750 (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
756 rtx op0 = gen_lowpart (SImode, operands[0]);
757 rtx shift = GEN_INT (24);
759 operands[2] = gen_ashlsi3 (op0, op0, shift);
760 operands[3] = gen_ashrsi3 (op0, op0, shift);
763 (define_insn "extendqisi2"
764 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
765 (sign_extend:SI (match_operand:QI 1 "extend_operand" "0,T,m")))]
771 [(set_attr "type" "multi,load2,load4")
772 (set_attr "length" "4,2,4")])
775 [(set (match_operand:SI 0 "register_operand" "")
776 (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
782 rtx shift = GEN_INT (24);
784 operands[2] = gen_ashlsi3 (operands[0], operands[0], shift);
785 operands[3] = gen_ashrsi3 (operands[0], operands[0], shift);
788 (define_insn "extendhisi2"
789 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
790 (sign_extend:SI (match_operand:HI 1 "extend_operand" "0,T,m")))]
796 [(set_attr "type" "multi,load2,load4")
797 (set_attr "length" "4,2,4")])
800 [(set (match_operand:SI 0 "register_operand" "")
801 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
807 rtx shift = GEN_INT (16);
809 operands[2] = gen_ashlsi3 (operands[0], operands[0], shift);
810 operands[3] = gen_ashrsi3 (operands[0], operands[0], shift);
813 ;; Arithmetic instructions.
815 ; ??? Adding an alternative to split add3 of small constants into two
816 ; insns yields better instruction packing but slower code. Adds of small
817 ; values is done a lot.
819 (define_insn "addsi3"
820 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
821 (plus:SI (match_operand:SI 1 "register_operand" "%0,0,r")
822 (match_operand:SI 2 "nonmemory_operand" "r,I,J")))]
828 [(set_attr "type" "int2,int2,int4")
829 (set_attr "length" "2,2,4")])
832 ; [(set (match_operand:SI 0 "register_operand" "")
833 ; (plus:SI (match_operand:SI 1 "register_operand" "")
834 ; (match_operand:SI 2 "int8_operand" "")))]
836 ; && REGNO (operands[0]) != REGNO (operands[1])
837 ; && INT8_P (INTVAL (operands[2]))
838 ; && INTVAL (operands[2]) != 0"
839 ; [(set (match_dup 0) (match_dup 1))
840 ; (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
843 (define_insn "adddi3"
844 [(set (match_operand:DI 0 "register_operand" "=r")
845 (plus:DI (match_operand:DI 1 "register_operand" "%0")
846 (match_operand:DI 2 "register_operand" "r")))
847 (clobber (reg:CC 17))]
850 [(set_attr "type" "multi")
851 (set_attr "length" "6")])
853 ;; ??? The cmp clears the condition bit. Can we speed up somehow?
855 [(set (match_operand:DI 0 "register_operand" "")
856 (plus:DI (match_operand:DI 1 "register_operand" "")
857 (match_operand:DI 2 "register_operand" "")))
858 (clobber (reg:CC 17))]
860 [(parallel [(set (reg:CC 17)
862 (use (match_dup 4))])
863 (parallel [(set (match_dup 4)
864 (plus:SI (match_dup 4)
865 (plus:SI (match_dup 5)
866 (ne:SI (reg:CC 17) (const_int 0)))))
868 (unspec:CC [(const_int 0)] UNSPEC_SET_CBIT))])
869 (parallel [(set (match_dup 6)
870 (plus:SI (match_dup 6)
871 (plus:SI (match_dup 7)
872 (ne:SI (reg:CC 17) (const_int 0)))))
874 (unspec:CC [(const_int 0)] UNSPEC_SET_CBIT))])]
877 operands[4] = operand_subword (operands[0], (WORDS_BIG_ENDIAN != 0), 0, DImode);
878 operands[5] = operand_subword (operands[2], (WORDS_BIG_ENDIAN != 0), 0, DImode);
879 operands[6] = operand_subword (operands[0], (WORDS_BIG_ENDIAN == 0), 0, DImode);
880 operands[7] = operand_subword (operands[2], (WORDS_BIG_ENDIAN == 0), 0, DImode);
883 (define_insn "*clear_c"
886 (use (match_operand:SI 0 "register_operand" "r"))]
889 [(set_attr "type" "int2")
890 (set_attr "length" "2")])
892 (define_insn "*add_carry"
893 [(set (match_operand:SI 0 "register_operand" "=r")
894 (plus:SI (match_operand:SI 1 "register_operand" "%0")
895 (plus:SI (match_operand:SI 2 "register_operand" "r")
896 (ne:SI (reg:CC 17) (const_int 0)))))
898 (unspec:CC [(const_int 0)] UNSPEC_SET_CBIT))]
901 [(set_attr "type" "int2")
902 (set_attr "length" "2")])
904 (define_insn "subsi3"
905 [(set (match_operand:SI 0 "register_operand" "=r")
906 (minus:SI (match_operand:SI 1 "register_operand" "0")
907 (match_operand:SI 2 "register_operand" "r")))]
910 [(set_attr "type" "int2")
911 (set_attr "length" "2")])
913 (define_insn "subdi3"
914 [(set (match_operand:DI 0 "register_operand" "=r")
915 (minus:DI (match_operand:DI 1 "register_operand" "0")
916 (match_operand:DI 2 "register_operand" "r")))
917 (clobber (reg:CC 17))]
920 [(set_attr "type" "multi")
921 (set_attr "length" "6")])
923 ;; ??? The cmp clears the condition bit. Can we speed up somehow?
925 [(set (match_operand:DI 0 "register_operand" "")
926 (minus:DI (match_operand:DI 1 "register_operand" "")
927 (match_operand:DI 2 "register_operand" "")))
928 (clobber (reg:CC 17))]
930 [(parallel [(set (reg:CC 17)
932 (use (match_dup 4))])
933 (parallel [(set (match_dup 4)
934 (minus:SI (match_dup 4)
935 (minus:SI (match_dup 5)
936 (ne:SI (reg:CC 17) (const_int 0)))))
938 (unspec:CC [(const_int 0)] UNSPEC_SET_CBIT))])
939 (parallel [(set (match_dup 6)
940 (minus:SI (match_dup 6)
941 (minus:SI (match_dup 7)
942 (ne:SI (reg:CC 17) (const_int 0)))))
944 (unspec:CC [(const_int 0)] UNSPEC_SET_CBIT))])]
947 operands[4] = operand_subword (operands[0], (WORDS_BIG_ENDIAN != 0), 0, DImode);
948 operands[5] = operand_subword (operands[2], (WORDS_BIG_ENDIAN != 0), 0, DImode);
949 operands[6] = operand_subword (operands[0], (WORDS_BIG_ENDIAN == 0), 0, DImode);
950 operands[7] = operand_subword (operands[2], (WORDS_BIG_ENDIAN == 0), 0, DImode);
953 (define_insn "*sub_carry"
954 [(set (match_operand:SI 0 "register_operand" "=r")
955 (minus:SI (match_operand:SI 1 "register_operand" "%0")
956 (minus:SI (match_operand:SI 2 "register_operand" "r")
957 (ne:SI (reg:CC 17) (const_int 0)))))
959 (unspec:CC [(const_int 0)] UNSPEC_SET_CBIT))]
962 [(set_attr "type" "int2")
963 (set_attr "length" "2")])
965 ; Multiply/Divide instructions.
967 (define_insn "mulhisi3"
968 [(set (match_operand:SI 0 "register_operand" "=r")
969 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "r"))
970 (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
972 "mullo %1,%2\;mvfacmi %0"
973 [(set_attr "type" "multi")
974 (set_attr "length" "4")])
976 (define_insn "mulsi3"
977 [(set (match_operand:SI 0 "register_operand" "=r")
978 (mult:SI (match_operand:SI 1 "register_operand" "%0")
979 (match_operand:SI 2 "register_operand" "r")))]
982 [(set_attr "type" "mul2")
983 (set_attr "length" "2")])
985 (define_insn "divsi3"
986 [(set (match_operand:SI 0 "register_operand" "=r")
987 (div:SI (match_operand:SI 1 "register_operand" "0")
988 (match_operand:SI 2 "register_operand" "r")))]
991 [(set_attr "type" "div4")
992 (set_attr "length" "4")])
994 (define_insn "udivsi3"
995 [(set (match_operand:SI 0 "register_operand" "=r")
996 (udiv:SI (match_operand:SI 1 "register_operand" "0")
997 (match_operand:SI 2 "register_operand" "r")))]
1000 [(set_attr "type" "div4")
1001 (set_attr "length" "4")])
1003 (define_insn "modsi3"
1004 [(set (match_operand:SI 0 "register_operand" "=r")
1005 (mod:SI (match_operand:SI 1 "register_operand" "0")
1006 (match_operand:SI 2 "register_operand" "r")))]
1009 [(set_attr "type" "div4")
1010 (set_attr "length" "4")])
1012 (define_insn "umodsi3"
1013 [(set (match_operand:SI 0 "register_operand" "=r")
1014 (umod:SI (match_operand:SI 1 "register_operand" "0")
1015 (match_operand:SI 2 "register_operand" "r")))]
1018 [(set_attr "type" "div4")
1019 (set_attr "length" "4")])
1021 ;; Boolean instructions.
1023 ;; We don't define the DImode versions as expand_binop does a good enough job.
1024 ;; And if it doesn't it should be fixed.
1026 (define_insn "andsi3"
1027 [(set (match_operand:SI 0 "register_operand" "=r,r")
1028 (and:SI (match_operand:SI 1 "register_operand" "%0,r")
1029 (match_operand:SI 2 "reg_or_uint16_operand" "r,K")))]
1033 /* If we are worried about space, see if we can break this up into two
1034 short instructions, which might eliminate a NOP being inserted. */
1036 && m32r_not_same_reg (operands[0], operands[1])
1037 && GET_CODE (operands[2]) == CONST_INT
1038 && INT8_P (INTVAL (operands[2])))
1041 else if (GET_CODE (operands[2]) == CONST_INT)
1042 return \"and3 %0,%1,%#%X2\";
1044 return \"and %0,%2\";
1046 [(set_attr "type" "int2,int4")
1047 (set_attr "length" "2,4")])
1050 [(set (match_operand:SI 0 "register_operand" "")
1051 (and:SI (match_operand:SI 1 "register_operand" "")
1052 (match_operand:SI 2 "int8_operand" "")))]
1053 "optimize_size && m32r_not_same_reg (operands[0], operands[1])"
1054 [(set (match_dup 0) (match_dup 2))
1055 (set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))]
1058 (define_insn "iorsi3"
1059 [(set (match_operand:SI 0 "register_operand" "=r,r")
1060 (ior:SI (match_operand:SI 1 "register_operand" "%0,r")
1061 (match_operand:SI 2 "reg_or_uint16_operand" "r,K")))]
1065 /* If we are worried about space, see if we can break this up into two
1066 short instructions, which might eliminate a NOP being inserted. */
1068 && m32r_not_same_reg (operands[0], operands[1])
1069 && GET_CODE (operands[2]) == CONST_INT
1070 && INT8_P (INTVAL (operands[2])))
1073 else if (GET_CODE (operands[2]) == CONST_INT)
1074 return \"or3 %0,%1,%#%X2\";
1076 return \"or %0,%2\";
1078 [(set_attr "type" "int2,int4")
1079 (set_attr "length" "2,4")])
1082 [(set (match_operand:SI 0 "register_operand" "")
1083 (ior:SI (match_operand:SI 1 "register_operand" "")
1084 (match_operand:SI 2 "int8_operand" "")))]
1085 "optimize_size && m32r_not_same_reg (operands[0], operands[1])"
1086 [(set (match_dup 0) (match_dup 2))
1087 (set (match_dup 0) (ior:SI (match_dup 0) (match_dup 1)))]
1090 (define_insn "xorsi3"
1091 [(set (match_operand:SI 0 "register_operand" "=r,r")
1092 (xor:SI (match_operand:SI 1 "register_operand" "%0,r")
1093 (match_operand:SI 2 "reg_or_uint16_operand" "r,K")))]
1097 /* If we are worried about space, see if we can break this up into two
1098 short instructions, which might eliminate a NOP being inserted. */
1100 && m32r_not_same_reg (operands[0], operands[1])
1101 && GET_CODE (operands[2]) == CONST_INT
1102 && INT8_P (INTVAL (operands[2])))
1105 else if (GET_CODE (operands[2]) == CONST_INT)
1106 return \"xor3 %0,%1,%#%X2\";
1108 return \"xor %0,%2\";
1110 [(set_attr "type" "int2,int4")
1111 (set_attr "length" "2,4")])
1114 [(set (match_operand:SI 0 "register_operand" "")
1115 (xor:SI (match_operand:SI 1 "register_operand" "")
1116 (match_operand:SI 2 "int8_operand" "")))]
1117 "optimize_size && m32r_not_same_reg (operands[0], operands[1])"
1118 [(set (match_dup 0) (match_dup 2))
1119 (set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))]
1122 (define_insn "negsi2"
1123 [(set (match_operand:SI 0 "register_operand" "=r")
1124 (neg:SI (match_operand:SI 1 "register_operand" "r")))]
1127 [(set_attr "type" "int2")
1128 (set_attr "length" "2")])
1130 (define_insn "one_cmplsi2"
1131 [(set (match_operand:SI 0 "register_operand" "=r")
1132 (not:SI (match_operand:SI 1 "register_operand" "r")))]
1135 [(set_attr "type" "int2")
1136 (set_attr "length" "2")])
1138 ;; Shift instructions.
1140 (define_insn "ashlsi3"
1141 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1142 (ashift:SI (match_operand:SI 1 "register_operand" "0,0,r")
1143 (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))]
1149 [(set_attr "type" "shift2,shift2,shift4")
1150 (set_attr "length" "2,2,4")])
1152 (define_insn "ashrsi3"
1153 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1154 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r")
1155 (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))]
1161 [(set_attr "type" "shift2,shift2,shift4")
1162 (set_attr "length" "2,2,4")])
1164 (define_insn "lshrsi3"
1165 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1166 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r")
1167 (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))]
1173 [(set_attr "type" "shift2,shift2,shift4")
1174 (set_attr "length" "2,2,4")])
1176 ;; Compare instructions.
1177 ;; This controls RTL generation and register allocation.
1179 ;; We generate RTL for comparisons and branches by having the cmpxx
1180 ;; patterns store away the operands. Then the bcc patterns
1181 ;; emit RTL for both the compare and the branch.
1183 ;; On the m32r it is more efficient to use the bxxz instructions and
1184 ;; thus merge the compare and branch into one instruction, so they are
1187 (define_expand "cmpsi"
1189 (compare:CC (match_operand:SI 0 "register_operand" "")
1190 (match_operand:SI 1 "reg_or_cmp_int16_operand" "")))]
1194 m32r_compare_op0 = operands[0];
1195 m32r_compare_op1 = operands[1];
1199 (define_insn "cmp_eqsi_zero_insn"
1201 (eq:CC (match_operand:SI 0 "register_operand" "r,r")
1202 (match_operand:SI 1 "reg_or_zero_operand" "r,P")))]
1203 "TARGET_M32RX || TARGET_M32R2"
1207 [(set_attr "type" "int4")
1208 (set_attr "length" "4")])
1210 ;; The cmp_xxx_insn patterns set the condition bit to the result of the
1211 ;; comparison. There isn't a "compare equal" instruction so cmp_eqsi_insn
1212 ;; is quite inefficient. However, it is rarely used.
1214 (define_insn "cmp_eqsi_insn"
1216 (eq:CC (match_operand:SI 0 "register_operand" "r,r")
1217 (match_operand:SI 1 "reg_or_cmp_int16_operand" "r,P")))
1218 (clobber (match_scratch:SI 2 "=&r,&r"))]
1222 if (which_alternative == 0)
1224 return \"mv %2,%0\;sub %2,%1\;cmpui %2,#1\";
1228 if (INTVAL (operands [1]) == 0)
1229 return \"cmpui %0, #1\";
1230 else if (REGNO (operands [2]) == REGNO (operands [0]))
1231 return \"addi %0,%#%N1\;cmpui %2,#1\";
1233 return \"add3 %2,%0,%#%N1\;cmpui %2,#1\";
1236 [(set_attr "type" "multi,multi")
1237 (set_attr "length" "8,8")])
1239 (define_insn "cmp_ltsi_insn"
1241 (lt:CC (match_operand:SI 0 "register_operand" "r,r")
1242 (match_operand:SI 1 "reg_or_int16_operand" "r,J")))]
1247 [(set_attr "type" "int2,int4")
1248 (set_attr "length" "2,4")])
1250 (define_insn "cmp_ltusi_insn"
1252 (ltu:CC (match_operand:SI 0 "register_operand" "r,r")
1253 (match_operand:SI 1 "reg_or_int16_operand" "r,J")))]
1258 [(set_attr "type" "int2,int4")
1259 (set_attr "length" "2,4")])
1261 ;; These control RTL generation for conditional jump insns.
1263 (define_expand "beq"
1265 (if_then_else (match_dup 1)
1266 (label_ref (match_operand 0 "" ""))
1271 operands[1] = gen_compare (EQ, m32r_compare_op0, m32r_compare_op1, FALSE);
1274 (define_expand "bne"
1276 (if_then_else (match_dup 1)
1277 (label_ref (match_operand 0 "" ""))
1282 operands[1] = gen_compare (NE, m32r_compare_op0, m32r_compare_op1, FALSE);
1285 (define_expand "bgt"
1287 (if_then_else (match_dup 1)
1288 (label_ref (match_operand 0 "" ""))
1293 operands[1] = gen_compare (GT, m32r_compare_op0, m32r_compare_op1, FALSE);
1296 (define_expand "ble"
1298 (if_then_else (match_dup 1)
1299 (label_ref (match_operand 0 "" ""))
1304 operands[1] = gen_compare (LE, m32r_compare_op0, m32r_compare_op1, FALSE);
1307 (define_expand "bge"
1309 (if_then_else (match_dup 1)
1310 (label_ref (match_operand 0 "" ""))
1315 operands[1] = gen_compare (GE, m32r_compare_op0, m32r_compare_op1, FALSE);
1318 (define_expand "blt"
1320 (if_then_else (match_dup 1)
1321 (label_ref (match_operand 0 "" ""))
1326 operands[1] = gen_compare (LT, m32r_compare_op0, m32r_compare_op1, FALSE);
1329 (define_expand "bgtu"
1331 (if_then_else (match_dup 1)
1332 (label_ref (match_operand 0 "" ""))
1337 operands[1] = gen_compare (GTU, m32r_compare_op0, m32r_compare_op1, FALSE);
1340 (define_expand "bleu"
1342 (if_then_else (match_dup 1)
1343 (label_ref (match_operand 0 "" ""))
1348 operands[1] = gen_compare (LEU, m32r_compare_op0, m32r_compare_op1, FALSE);
1351 (define_expand "bgeu"
1353 (if_then_else (match_dup 1)
1354 (label_ref (match_operand 0 "" ""))
1359 operands[1] = gen_compare (GEU, m32r_compare_op0, m32r_compare_op1, FALSE);
1362 (define_expand "bltu"
1364 (if_then_else (match_dup 1)
1365 (label_ref (match_operand 0 "" ""))
1370 operands[1] = gen_compare (LTU, m32r_compare_op0, m32r_compare_op1, FALSE);
1373 ;; Now match both normal and inverted jump.
1375 (define_insn "*branch_insn"
1377 (if_then_else (match_operator 1 "eqne_comparison_operator"
1378 [(reg 17) (const_int 0)])
1379 (label_ref (match_operand 0 "" ""))
1384 static char instruction[40];
1385 sprintf (instruction, \"%s%s %%l0\",
1386 (GET_CODE (operands[1]) == NE) ? \"bc\" : \"bnc\",
1387 (get_attr_length (insn) == 2) ? \".s\" : \"\");
1390 [(set_attr "type" "branch")
1392 ; We use 300/600 instead of 512,1024 to account for inaccurate insn
1393 ; lengths and insn alignments that are complex to track.
1394 ; It's not important that we be hyper-precise here. It may be more
1395 ; important blah blah blah when the chip supports parallel execution
1396 ; blah blah blah but until then blah blah blah this is simple and
1398 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1404 (define_insn "*rev_branch_insn"
1406 (if_then_else (match_operator 1 "eqne_comparison_operator"
1407 [(reg 17) (const_int 0)])
1409 (label_ref (match_operand 0 "" ""))))]
1410 ;"REVERSIBLE_CC_MODE (GET_MODE (XEXP (operands[1], 0)))"
1414 static char instruction[40];
1415 sprintf (instruction, \"%s%s %%l0\",
1416 (GET_CODE (operands[1]) == EQ) ? \"bc\" : \"bnc\",
1417 (get_attr_length (insn) == 2) ? \".s\" : \"\");
1420 [(set_attr "type" "branch")
1422 ; We use 300/600 instead of 512,1024 to account for inaccurate insn
1423 ; lengths and insn alignments that are complex to track.
1424 ; It's not important that we be hyper-precise here. It may be more
1425 ; important blah blah blah when the chip supports parallel execution
1426 ; blah blah blah but until then blah blah blah this is simple and
1428 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1434 ; reg/reg compare and branch insns
1436 (define_insn "*reg_branch_insn"
1438 (if_then_else (match_operator 1 "eqne_comparison_operator"
1439 [(match_operand:SI 2 "register_operand" "r")
1440 (match_operand:SI 3 "register_operand" "r")])
1441 (label_ref (match_operand 0 "" ""))
1446 /* Is branch target reachable with beq/bne? */
1447 if (get_attr_length (insn) == 4)
1449 if (GET_CODE (operands[1]) == EQ)
1450 return \"beq %2,%3,%l0\";
1452 return \"bne %2,%3,%l0\";
1456 if (GET_CODE (operands[1]) == EQ)
1457 return \"bne %2,%3,1f\;bra %l0\;1:\";
1459 return \"beq %2,%3,1f\;bra %l0\;1:\";
1462 [(set_attr "type" "branch")
1463 ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1464 ; which is complex to track and inaccurate length specs.
1465 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1471 (define_insn "*rev_reg_branch_insn"
1473 (if_then_else (match_operator 1 "eqne_comparison_operator"
1474 [(match_operand:SI 2 "register_operand" "r")
1475 (match_operand:SI 3 "register_operand" "r")])
1477 (label_ref (match_operand 0 "" ""))))]
1481 /* Is branch target reachable with beq/bne? */
1482 if (get_attr_length (insn) == 4)
1484 if (GET_CODE (operands[1]) == NE)
1485 return \"beq %2,%3,%l0\";
1487 return \"bne %2,%3,%l0\";
1491 if (GET_CODE (operands[1]) == NE)
1492 return \"bne %2,%3,1f\;bra %l0\;1:\";
1494 return \"beq %2,%3,1f\;bra %l0\;1:\";
1497 [(set_attr "type" "branch")
1498 ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1499 ; which is complex to track and inaccurate length specs.
1500 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1506 ; reg/zero compare and branch insns
1508 (define_insn "*zero_branch_insn"
1510 (if_then_else (match_operator 1 "signed_comparison_operator"
1511 [(match_operand:SI 2 "register_operand" "r")
1513 (label_ref (match_operand 0 "" ""))
1518 const char *br,*invbr;
1521 switch (GET_CODE (operands[1]))
1523 case EQ : br = \"eq\"; invbr = \"ne\"; break;
1524 case NE : br = \"ne\"; invbr = \"eq\"; break;
1525 case LE : br = \"le\"; invbr = \"gt\"; break;
1526 case GT : br = \"gt\"; invbr = \"le\"; break;
1527 case LT : br = \"lt\"; invbr = \"ge\"; break;
1528 case GE : br = \"ge\"; invbr = \"lt\"; break;
1530 default: gcc_unreachable ();
1533 /* Is branch target reachable with bxxz? */
1534 if (get_attr_length (insn) == 4)
1536 sprintf (asmtext, \"b%sz %%2,%%l0\", br);
1537 output_asm_insn (asmtext, operands);
1541 sprintf (asmtext, \"b%sz %%2,1f\;bra %%l0\;1:\", invbr);
1542 output_asm_insn (asmtext, operands);
1546 [(set_attr "type" "branch")
1547 ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1548 ; which is complex to track and inaccurate length specs.
1549 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1555 (define_insn "*rev_zero_branch_insn"
1557 (if_then_else (match_operator 1 "eqne_comparison_operator"
1558 [(match_operand:SI 2 "register_operand" "r")
1561 (label_ref (match_operand 0 "" ""))))]
1565 const char *br,*invbr;
1568 switch (GET_CODE (operands[1]))
1570 case EQ : br = \"eq\"; invbr = \"ne\"; break;
1571 case NE : br = \"ne\"; invbr = \"eq\"; break;
1572 case LE : br = \"le\"; invbr = \"gt\"; break;
1573 case GT : br = \"gt\"; invbr = \"le\"; break;
1574 case LT : br = \"lt\"; invbr = \"ge\"; break;
1575 case GE : br = \"ge\"; invbr = \"lt\"; break;
1577 default: gcc_unreachable ();
1580 /* Is branch target reachable with bxxz? */
1581 if (get_attr_length (insn) == 4)
1583 sprintf (asmtext, \"b%sz %%2,%%l0\", invbr);
1584 output_asm_insn (asmtext, operands);
1588 sprintf (asmtext, \"b%sz %%2,1f\;bra %%l0\;1:\", br);
1589 output_asm_insn (asmtext, operands);
1593 [(set_attr "type" "branch")
1594 ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1595 ; which is complex to track and inaccurate length specs.
1596 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1602 ;; S<cc> operations to set a register to 1/0 based on a comparison
1604 (define_expand "seq"
1605 [(match_operand:SI 0 "register_operand" "")]
1609 rtx op0 = operands[0];
1610 rtx op1 = m32r_compare_op0;
1611 rtx op2 = m32r_compare_op1;
1612 enum machine_mode mode = GET_MODE (op0);
1617 if (! register_operand (op1, mode))
1618 op1 = force_reg (mode, op1);
1620 if (TARGET_M32RX || TARGET_M32R2)
1622 if (! reg_or_zero_operand (op2, mode))
1623 op2 = force_reg (mode, op2);
1625 emit_insn (gen_seq_insn_m32rx (op0, op1, op2));
1628 if (GET_CODE (op2) == CONST_INT && INTVAL (op2) == 0)
1630 emit_insn (gen_seq_zero_insn (op0, op1));
1634 if (! reg_or_eq_int16_operand (op2, mode))
1635 op2 = force_reg (mode, op2);
1637 emit_insn (gen_seq_insn (op0, op1, op2));
1641 (define_insn "seq_insn_m32rx"
1642 [(set (match_operand:SI 0 "register_operand" "=r")
1643 (eq:SI (match_operand:SI 1 "register_operand" "%r")
1644 (match_operand:SI 2 "reg_or_zero_operand" "rP")))
1645 (clobber (reg:CC 17))]
1646 "TARGET_M32RX || TARGET_M32R2"
1648 [(set_attr "type" "multi")
1649 (set_attr "length" "6")])
1652 [(set (match_operand:SI 0 "register_operand" "")
1653 (eq:SI (match_operand:SI 1 "register_operand" "")
1654 (match_operand:SI 2 "reg_or_zero_operand" "")))
1655 (clobber (reg:CC 17))]
1656 "TARGET_M32RX || TARGET_M32R2"
1658 (eq:CC (match_dup 1)
1661 (ne:SI (reg:CC 17) (const_int 0)))]
1664 (define_insn "seq_zero_insn"
1665 [(set (match_operand:SI 0 "register_operand" "=r")
1666 (eq:SI (match_operand:SI 1 "register_operand" "r")
1668 (clobber (reg:CC 17))]
1671 [(set_attr "type" "multi")
1672 (set_attr "length" "6")])
1675 [(set (match_operand:SI 0 "register_operand" "")
1676 (eq:SI (match_operand:SI 1 "register_operand" "")
1678 (clobber (reg:CC 17))]
1683 rtx op0 = operands[0];
1684 rtx op1 = operands[1];
1687 emit_insn (gen_cmp_ltusi_insn (op1, const1_rtx));
1688 emit_insn (gen_movcc_insn (op0));
1689 operands[3] = get_insns ();
1693 (define_insn "seq_insn"
1694 [(set (match_operand:SI 0 "register_operand" "=r,r,??r,r")
1695 (eq:SI (match_operand:SI 1 "register_operand" "r,r,r,r")
1696 (match_operand:SI 2 "reg_or_eq_int16_operand" "r,r,r,PK")))
1697 (clobber (reg:CC 17))
1698 (clobber (match_scratch:SI 3 "=1,2,&r,r"))]
1701 [(set_attr "type" "multi")
1702 (set_attr "length" "8,8,10,10")])
1705 [(set (match_operand:SI 0 "register_operand" "")
1706 (eq:SI (match_operand:SI 1 "register_operand" "")
1707 (match_operand:SI 2 "reg_or_eq_int16_operand" "")))
1708 (clobber (reg:CC 17))
1709 (clobber (match_scratch:SI 3 ""))]
1710 "TARGET_M32R && reload_completed"
1714 rtx op0 = operands[0];
1715 rtx op1 = operands[1];
1716 rtx op2 = operands[2];
1717 rtx op3 = operands[3];
1718 HOST_WIDE_INT value;
1720 if (GET_CODE (op2) == REG && GET_CODE (op3) == REG
1721 && REGNO (op2) == REGNO (op3))
1728 if (GET_CODE (op1) == REG && GET_CODE (op3) == REG
1729 && REGNO (op1) != REGNO (op3))
1731 emit_move_insn (op3, op1);
1735 if (GET_CODE (op2) == CONST_INT && (value = INTVAL (op2)) != 0
1736 && CMP_INT16_P (value))
1737 emit_insn (gen_addsi3 (op3, op1, GEN_INT (-value)));
1739 emit_insn (gen_xorsi3 (op3, op1, op2));
1741 emit_insn (gen_cmp_ltusi_insn (op3, const1_rtx));
1742 emit_insn (gen_movcc_insn (op0));
1743 operands[4] = get_insns ();
1747 (define_expand "sne"
1748 [(match_operand:SI 0 "register_operand" "")]
1752 rtx op0 = operands[0];
1753 rtx op1 = m32r_compare_op0;
1754 rtx op2 = m32r_compare_op1;
1755 enum machine_mode mode = GET_MODE (op0);
1760 if (GET_CODE (op2) != CONST_INT
1761 || (INTVAL (op2) != 0 && UINT16_P (INTVAL (op2))))
1765 if (reload_completed || reload_in_progress)
1768 reg = gen_reg_rtx (SImode);
1769 emit_insn (gen_xorsi3 (reg, op1, op2));
1772 if (! register_operand (op1, mode))
1773 op1 = force_reg (mode, op1);
1775 emit_insn (gen_sne_zero_insn (op0, op1));
1782 (define_insn "sne_zero_insn"
1783 [(set (match_operand:SI 0 "register_operand" "=r")
1784 (ne:SI (match_operand:SI 1 "register_operand" "r")
1786 (clobber (reg:CC 17))
1787 (clobber (match_scratch:SI 2 "=&r"))]
1790 [(set_attr "type" "multi")
1791 (set_attr "length" "6")])
1794 [(set (match_operand:SI 0 "register_operand" "")
1795 (ne:SI (match_operand:SI 1 "register_operand" "")
1797 (clobber (reg:CC 17))
1798 (clobber (match_scratch:SI 2 ""))]
1803 (ltu:CC (match_dup 2)
1806 (ne:SI (reg:CC 17) (const_int 0)))]
1809 (define_expand "slt"
1810 [(match_operand:SI 0 "register_operand" "")]
1814 rtx op0 = operands[0];
1815 rtx op1 = m32r_compare_op0;
1816 rtx op2 = m32r_compare_op1;
1817 enum machine_mode mode = GET_MODE (op0);
1822 if (! register_operand (op1, mode))
1823 op1 = force_reg (mode, op1);
1825 if (! reg_or_int16_operand (op2, mode))
1826 op2 = force_reg (mode, op2);
1828 emit_insn (gen_slt_insn (op0, op1, op2));
1832 (define_insn "slt_insn"
1833 [(set (match_operand:SI 0 "register_operand" "=r,r")
1834 (lt:SI (match_operand:SI 1 "register_operand" "r,r")
1835 (match_operand:SI 2 "reg_or_int16_operand" "r,J")))
1836 (clobber (reg:CC 17))]
1839 [(set_attr "type" "multi")
1840 (set_attr "length" "4,6")])
1843 [(set (match_operand:SI 0 "register_operand" "")
1844 (lt:SI (match_operand:SI 1 "register_operand" "")
1845 (match_operand:SI 2 "reg_or_int16_operand" "")))
1846 (clobber (reg:CC 17))]
1849 (lt:CC (match_dup 1)
1852 (ne:SI (reg:CC 17) (const_int 0)))]
1855 (define_expand "sle"
1856 [(match_operand:SI 0 "register_operand" "")]
1860 rtx op0 = operands[0];
1861 rtx op1 = m32r_compare_op0;
1862 rtx op2 = m32r_compare_op1;
1863 enum machine_mode mode = GET_MODE (op0);
1868 if (! register_operand (op1, mode))
1869 op1 = force_reg (mode, op1);
1871 if (GET_CODE (op2) == CONST_INT)
1873 HOST_WIDE_INT value = INTVAL (op2);
1874 if (value >= 2147483647)
1876 emit_move_insn (op0, const1_rtx);
1880 op2 = GEN_INT (value+1);
1881 if (value < -32768 || value >= 32767)
1882 op2 = force_reg (mode, op2);
1884 emit_insn (gen_slt_insn (op0, op1, op2));
1888 if (! register_operand (op2, mode))
1889 op2 = force_reg (mode, op2);
1891 emit_insn (gen_sle_insn (op0, op1, op2));
1895 (define_insn "sle_insn"
1896 [(set (match_operand:SI 0 "register_operand" "=r")
1897 (le:SI (match_operand:SI 1 "register_operand" "r")
1898 (match_operand:SI 2 "register_operand" "r")))
1899 (clobber (reg:CC 17))]
1902 [(set_attr "type" "multi")
1903 (set_attr "length" "8")])
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:CC 17))]
1912 (lt:CC (match_dup 2)
1915 (ne:SI (reg:CC 17) (const_int 0)))
1917 (xor:SI (match_dup 0)
1921 ;; If optimizing for space, use -(reg - 1) to invert the comparison rather than
1922 ;; xor reg,reg,1 which might eliminate a NOP being inserted.
1924 [(set (match_operand:SI 0 "register_operand" "")
1925 (le:SI (match_operand:SI 1 "register_operand" "")
1926 (match_operand:SI 2 "register_operand" "")))
1927 (clobber (reg:CC 17))]
1930 (lt:CC (match_dup 2)
1933 (ne:SI (reg:CC 17) (const_int 0)))
1935 (plus:SI (match_dup 0)
1938 (neg:SI (match_dup 0)))]
1941 (define_expand "sgt"
1942 [(match_operand:SI 0 "register_operand" "")]
1946 rtx op0 = operands[0];
1947 rtx op1 = m32r_compare_op0;
1948 rtx op2 = m32r_compare_op1;
1949 enum machine_mode mode = GET_MODE (op0);
1954 if (! register_operand (op1, mode))
1955 op1 = force_reg (mode, op1);
1957 if (! register_operand (op2, mode))
1958 op2 = force_reg (mode, op2);
1960 emit_insn (gen_slt_insn (op0, op2, op1));
1964 (define_expand "sge"
1965 [(match_operand:SI 0 "register_operand" "")]
1969 rtx op0 = operands[0];
1970 rtx op1 = m32r_compare_op0;
1971 rtx op2 = m32r_compare_op1;
1972 enum machine_mode mode = GET_MODE (op0);
1977 if (! register_operand (op1, mode))
1978 op1 = force_reg (mode, op1);
1980 if (! reg_or_int16_operand (op2, mode))
1981 op2 = force_reg (mode, op2);
1983 emit_insn (gen_sge_insn (op0, op1, op2));
1987 (define_insn "sge_insn"
1988 [(set (match_operand:SI 0 "register_operand" "=r,r")
1989 (ge:SI (match_operand:SI 1 "register_operand" "r,r")
1990 (match_operand:SI 2 "reg_or_int16_operand" "r,J")))
1991 (clobber (reg:CC 17))]
1994 [(set_attr "type" "multi")
1995 (set_attr "length" "8,10")])
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:CC 17))]
2004 (lt:CC (match_dup 1)
2007 (ne:SI (reg:CC 17) (const_int 0)))
2009 (xor:SI (match_dup 0)
2013 ;; If optimizing for space, use -(reg - 1) to invert the comparison rather than
2014 ;; xor reg,reg,1 which might eliminate a NOP being inserted.
2016 [(set (match_operand:SI 0 "register_operand" "")
2017 (ge:SI (match_operand:SI 1 "register_operand" "")
2018 (match_operand:SI 2 "reg_or_int16_operand" "")))
2019 (clobber (reg:CC 17))]
2022 (lt:CC (match_dup 1)
2025 (ne:SI (reg:CC 17) (const_int 0)))
2027 (plus:SI (match_dup 0)
2030 (neg:SI (match_dup 0)))]
2033 (define_expand "sltu"
2034 [(match_operand:SI 0 "register_operand" "")]
2038 rtx op0 = operands[0];
2039 rtx op1 = m32r_compare_op0;
2040 rtx op2 = m32r_compare_op1;
2041 enum machine_mode mode = GET_MODE (op0);
2046 if (! register_operand (op1, mode))
2047 op1 = force_reg (mode, op1);
2049 if (! reg_or_int16_operand (op2, mode))
2050 op2 = force_reg (mode, op2);
2052 emit_insn (gen_sltu_insn (op0, op1, op2));
2056 (define_insn "sltu_insn"
2057 [(set (match_operand:SI 0 "register_operand" "=r,r")
2058 (ltu:SI (match_operand:SI 1 "register_operand" "r,r")
2059 (match_operand:SI 2 "reg_or_int16_operand" "r,J")))
2060 (clobber (reg:CC 17))]
2063 [(set_attr "type" "multi")
2064 (set_attr "length" "6,8")])
2067 [(set (match_operand:SI 0 "register_operand" "")
2068 (ltu:SI (match_operand:SI 1 "register_operand" "")
2069 (match_operand:SI 2 "reg_or_int16_operand" "")))
2070 (clobber (reg:CC 17))]
2073 (ltu:CC (match_dup 1)
2076 (ne:SI (reg:CC 17) (const_int 0)))]
2079 (define_expand "sleu"
2080 [(match_operand:SI 0 "register_operand" "")]
2084 rtx op0 = operands[0];
2085 rtx op1 = m32r_compare_op0;
2086 rtx op2 = m32r_compare_op1;
2087 enum machine_mode mode = GET_MODE (op0);
2092 if (GET_CODE (op2) == CONST_INT)
2094 HOST_WIDE_INT value = INTVAL (op2);
2095 if (value >= 2147483647)
2097 emit_move_insn (op0, const1_rtx);
2101 op2 = GEN_INT (value+1);
2102 if (value < 0 || value >= 32767)
2103 op2 = force_reg (mode, op2);
2105 emit_insn (gen_sltu_insn (op0, op1, op2));
2109 if (! register_operand (op2, mode))
2110 op2 = force_reg (mode, op2);
2112 emit_insn (gen_sleu_insn (op0, op1, op2));
2116 (define_insn "sleu_insn"
2117 [(set (match_operand:SI 0 "register_operand" "=r")
2118 (leu:SI (match_operand:SI 1 "register_operand" "r")
2119 (match_operand:SI 2 "register_operand" "r")))
2120 (clobber (reg:CC 17))]
2123 [(set_attr "type" "multi")
2124 (set_attr "length" "8")])
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:CC 17))]
2133 (ltu:CC (match_dup 2)
2136 (ne:SI (reg:CC 17) (const_int 0)))
2138 (xor:SI (match_dup 0)
2142 ;; If optimizing for space, use -(reg - 1) to invert the comparison rather than
2143 ;; xor reg,reg,1 which might eliminate a NOP being inserted.
2145 [(set (match_operand:SI 0 "register_operand" "")
2146 (leu:SI (match_operand:SI 1 "register_operand" "")
2147 (match_operand:SI 2 "register_operand" "")))
2148 (clobber (reg:CC 17))]
2151 (ltu:CC (match_dup 2)
2154 (ne:SI (reg:CC 17) (const_int 0)))
2156 (plus:SI (match_dup 0)
2159 (neg:SI (match_dup 0)))]
2162 (define_expand "sgtu"
2163 [(match_operand:SI 0 "register_operand" "")]
2167 rtx op0 = operands[0];
2168 rtx op1 = m32r_compare_op0;
2169 rtx op2 = m32r_compare_op1;
2170 enum machine_mode mode = GET_MODE (op0);
2175 if (! register_operand (op1, mode))
2176 op1 = force_reg (mode, op1);
2178 if (! register_operand (op2, mode))
2179 op2 = force_reg (mode, op2);
2181 emit_insn (gen_sltu_insn (op0, op2, op1));
2185 (define_expand "sgeu"
2186 [(match_operand:SI 0 "register_operand" "")]
2190 rtx op0 = operands[0];
2191 rtx op1 = m32r_compare_op0;
2192 rtx op2 = m32r_compare_op1;
2193 enum machine_mode mode = GET_MODE (op0);
2198 if (! register_operand (op1, mode))
2199 op1 = force_reg (mode, op1);
2201 if (! reg_or_int16_operand (op2, mode))
2202 op2 = force_reg (mode, op2);
2204 emit_insn (gen_sgeu_insn (op0, op1, op2));
2208 (define_insn "sgeu_insn"
2209 [(set (match_operand:SI 0 "register_operand" "=r,r")
2210 (geu:SI (match_operand:SI 1 "register_operand" "r,r")
2211 (match_operand:SI 2 "reg_or_int16_operand" "r,J")))
2212 (clobber (reg:CC 17))]
2215 [(set_attr "type" "multi")
2216 (set_attr "length" "8,10")])
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:CC 17))]
2225 (ltu:CC (match_dup 1)
2228 (ne:SI (reg:CC 17) (const_int 0)))
2230 (xor:SI (match_dup 0)
2234 ;; If optimizing for space, use -(reg - 1) to invert the comparison rather than
2235 ;; xor reg,reg,1 which might eliminate a NOP being inserted.
2237 [(set (match_operand:SI 0 "register_operand" "")
2238 (geu:SI (match_operand:SI 1 "register_operand" "")
2239 (match_operand:SI 2 "reg_or_int16_operand" "")))
2240 (clobber (reg:CC 17))]
2243 (ltu:CC (match_dup 1)
2246 (ne:SI (reg:CC 17) (const_int 0)))
2248 (plus:SI (match_dup 0)
2251 (neg:SI (match_dup 0)))]
2254 (define_insn "movcc_insn"
2255 [(set (match_operand:SI 0 "register_operand" "=r")
2256 (ne:SI (reg:CC 17) (const_int 0)))]
2259 [(set_attr "type" "misc")
2260 (set_attr "length" "2")])
2263 ;; Unconditional and other jump instructions.
2266 [(set (pc) (label_ref (match_operand 0 "" "")))]
2269 [(set_attr "type" "uncond_branch")
2270 (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
2276 (define_insn "indirect_jump"
2277 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
2280 [(set_attr "type" "uncond_branch")
2281 (set_attr "length" "2")])
2283 (define_insn "return_lr"
2284 [(parallel [(return) (use (reg:SI 14))])]
2287 [(set_attr "type" "uncond_branch")
2288 (set_attr "length" "2")])
2290 (define_insn "return_rte"
2294 [(set_attr "type" "uncond_branch")
2295 (set_attr "length" "2")])
2297 (define_expand "return"
2302 emit_jump_insn (gen_return_lr ());
2306 (define_expand "return_normal"
2311 enum m32r_function_type fn_type;
2313 fn_type = m32r_compute_function_type (current_function_decl);
2314 if (M32R_INTERRUPT_P (fn_type))
2316 emit_jump_insn (gen_return_rte ());
2320 emit_jump_insn (gen_return_lr ());
2324 (define_expand "tablejump"
2325 [(parallel [(set (pc) (match_operand 0 "register_operand" "r"))
2326 (use (label_ref (match_operand 1 "" "")))])]
2330 /* In pic mode, our address differences are against the base of the
2331 table. Add that base value back in; CSE ought to be able to combine
2332 the two address loads. */
2337 tmp = gen_rtx_LABEL_REF (Pmode, operands[1]);
2339 tmp = gen_rtx_PLUS (Pmode, tmp2, tmp);
2340 operands[0] = memory_address (Pmode, tmp);
2344 (define_insn "*tablejump_insn"
2345 [(set (pc) (match_operand:SI 0 "address_operand" "p"))
2346 (use (label_ref (match_operand 1 "" "")))]
2349 [(set_attr "type" "uncond_branch")
2350 (set_attr "length" "2")])
2352 (define_expand "call"
2353 ;; operands[1] is stack_size_rtx
2354 ;; operands[2] is next_arg_register
2355 [(parallel [(call (match_operand:SI 0 "call_operand" "")
2356 (match_operand 1 "" ""))
2357 (clobber (reg:SI 14))])]
2362 current_function_uses_pic_offset_table = 1;
2365 (define_insn "*call_via_reg"
2366 [(call (mem:SI (match_operand:SI 0 "register_operand" "r"))
2367 (match_operand 1 "" ""))
2368 (clobber (reg:SI 14))]
2371 [(set_attr "type" "call")
2372 (set_attr "length" "2")])
2374 (define_insn "*call_via_label"
2375 [(call (mem:SI (match_operand:SI 0 "call_address_operand" ""))
2376 (match_operand 1 "" ""))
2377 (clobber (reg:SI 14))]
2381 int call26_p = call26_operand (operands[0], FUNCTION_MODE);
2385 /* We may not be able to reach with a `bl' insn so punt and leave it to
2387 We do this here, rather than doing a force_reg in the define_expand
2388 so these insns won't be separated, say by scheduling, thus simplifying
2390 return \"seth r14,%T0\;add3 r14,r14,%B0\;jl r14\";
2395 [(set_attr "type" "call")
2396 (set (attr "length")
2397 (if_then_else (eq (symbol_ref "call26_operand (operands[0], FUNCTION_MODE)")
2399 (const_int 12) ; 10 + 2 for nop filler
2400 ; The return address must be on a 4 byte boundary so
2401 ; there's no point in using a value of 2 here. A 2 byte
2402 ; insn may go in the left slot but we currently can't
2403 ; use such knowledge.
2406 (define_expand "call_value"
2407 ;; operand 2 is stack_size_rtx
2408 ;; operand 3 is next_arg_register
2409 [(parallel [(set (match_operand 0 "register_operand" "=r")
2410 (call (match_operand:SI 1 "call_operand" "")
2411 (match_operand 2 "" "")))
2412 (clobber (reg:SI 14))])]
2417 current_function_uses_pic_offset_table = 1;
2420 (define_insn "*call_value_via_reg"
2421 [(set (match_operand 0 "register_operand" "=r")
2422 (call (mem:SI (match_operand:SI 1 "register_operand" "r"))
2423 (match_operand 2 "" "")))
2424 (clobber (reg:SI 14))]
2427 [(set_attr "type" "call")
2428 (set_attr "length" "2")])
2430 (define_insn "*call_value_via_label"
2431 [(set (match_operand 0 "register_operand" "=r")
2432 (call (mem:SI (match_operand:SI 1 "call_address_operand" ""))
2433 (match_operand 2 "" "")))
2434 (clobber (reg:SI 14))]
2438 int call26_p = call26_operand (operands[1], FUNCTION_MODE);
2441 current_function_uses_pic_offset_table = 1;
2445 /* We may not be able to reach with a `bl' insn so punt and leave it to
2447 We do this here, rather than doing a force_reg in the define_expand
2448 so these insns won't be separated, say by scheduling, thus simplifying
2450 return \"seth r14,%T1\;add3 r14,r14,%B1\;jl r14\";
2455 [(set_attr "type" "call")
2456 (set (attr "length")
2457 (if_then_else (eq (symbol_ref "call26_operand (operands[1], FUNCTION_MODE)")
2459 (const_int 12) ; 10 + 2 for nop filler
2460 ; The return address must be on a 4 byte boundary so
2461 ; there's no point in using a value of 2 here. A 2 byte
2462 ; insn may go in the left slot but we currently can't
2463 ; use such knowledge.
2470 [(set_attr "type" "int2")
2471 (set_attr "length" "2")])
2473 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
2474 ;; all of memory. This blocks insns from being moved across this point.
2476 (define_insn "blockage"
2477 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
2481 ;; Special pattern to flush the icache.
2483 (define_insn "flush_icache"
2484 [(unspec_volatile [(match_operand 0 "memory_operand" "m")]
2485 UNSPECV_FLUSH_ICACHE)
2486 (match_operand 1 "" "")
2487 (clobber (reg:SI 17))]
2489 "* return \"trap %#%1 ; flush-icache\";"
2490 [(set_attr "type" "int4")
2491 (set_attr "length" "4")])
2493 ;; Speed up fabs and provide correct sign handling for -0
2495 (define_insn "absdf2"
2496 [(set (match_operand:DF 0 "register_operand" "=r")
2497 (abs:DF (match_operand:DF 1 "register_operand" "0")))]
2500 [(set_attr "type" "multi")
2501 (set_attr "length" "4")])
2504 [(set (match_operand:DF 0 "register_operand" "")
2505 (abs:DF (match_operand:DF 1 "register_operand" "")))]
2508 (ashift:SI (match_dup 2)
2511 (lshiftrt:SI (match_dup 2)
2513 "operands[2] = gen_highpart (SImode, operands[0]);")
2515 (define_insn "abssf2"
2516 [(set (match_operand:SF 0 "register_operand" "=r")
2517 (abs:SF (match_operand:SF 1 "register_operand" "0")))]
2520 [(set_attr "type" "multi")
2521 (set_attr "length" "4")])
2524 [(set (match_operand:SF 0 "register_operand" "")
2525 (abs:SF (match_operand:SF 1 "register_operand" "")))]
2528 (ashift:SI (match_dup 2)
2531 (lshiftrt:SI (match_dup 2)
2533 "operands[2] = gen_highpart (SImode, operands[0]);")
2535 ;; Conditional move instructions
2536 ;; Based on those done for the d10v
2538 (define_expand "movsicc"
2540 (set (match_operand:SI 0 "register_operand" "r")
2541 (if_then_else:SI (match_operand 1 "" "")
2542 (match_operand:SI 2 "conditional_move_operand" "O")
2543 (match_operand:SI 3 "conditional_move_operand" "O")
2550 if (! zero_and_one (operands [2], operands [3]))
2553 /* Generate the comparison that will set the carry flag. */
2554 operands[1] = gen_compare (GET_CODE (operands[1]), m32r_compare_op0,
2555 m32r_compare_op1, TRUE);
2557 /* See other movsicc pattern below for reason why. */
2558 emit_insn (gen_blockage ());
2561 ;; Generate the conditional instructions based on how the carry flag is examined.
2562 (define_insn "*movsicc_internal"
2563 [(set (match_operand:SI 0 "register_operand" "=r")
2564 (if_then_else:SI (match_operand 1 "carry_compare_operand" "")
2565 (match_operand:SI 2 "conditional_move_operand" "O")
2566 (match_operand:SI 3 "conditional_move_operand" "O")
2569 "zero_and_one (operands [2], operands[3])"
2570 "* return emit_cond_move (operands, insn);"
2571 [(set_attr "type" "multi")
2572 (set_attr "length" "8")
2577 ;; Block moves, see m32r.c for more details.
2578 ;; Argument 0 is the destination
2579 ;; Argument 1 is the source
2580 ;; Argument 2 is the length
2581 ;; Argument 3 is the alignment
2583 (define_expand "movmemsi"
2584 [(parallel [(set (match_operand:BLK 0 "general_operand" "")
2585 (match_operand:BLK 1 "general_operand" ""))
2586 (use (match_operand:SI 2 "immediate_operand" ""))
2587 (use (match_operand:SI 3 "immediate_operand" ""))])]
2591 if (operands[0]) /* Avoid unused code messages. */
2593 if (m32r_expand_block_move (operands))
2600 ;; Insn generated by block moves
2602 (define_insn "movmemsi_internal"
2603 [(set (mem:BLK (match_operand:SI 0 "register_operand" "r")) ;; destination
2604 (mem:BLK (match_operand:SI 1 "register_operand" "r"))) ;; source
2605 (use (match_operand:SI 2 "m32r_block_immediate_operand" "J"));; # bytes to move
2606 (set (match_operand:SI 3 "register_operand" "=0")
2607 (plus:SI (minus (match_dup 2) (const_int 4))
2609 (set (match_operand:SI 4 "register_operand" "=1")
2610 (plus:SI (match_dup 1)
2612 (clobber (match_scratch:SI 5 "=&r")) ;; temp1
2613 (clobber (match_scratch:SI 6 "=&r"))] ;; temp2
2615 "* m32r_output_block_move (insn, operands); return \"\"; "
2616 [(set_attr "type" "store8")
2617 (set_attr "length" "72")]) ;; Maximum
2621 /* When generating pic, we need to load the symbol offset into a register.
2622 So that the optimizer does not confuse this with a normal symbol load
2623 we use an unspec. The offset will be loaded from a constant pool entry,
2624 since that is the only type of relocation we can use. */
2626 (define_insn "pic_load_addr"
2627 [(set (match_operand:SI 0 "register_operand" "=r")
2628 (unspec:SI [(match_operand 1 "" "")] UNSPEC_PIC_LOAD_ADDR))]
2631 [(set_attr "type" "int4")])
2633 (define_insn "gotoff_load_addr"
2634 [(set (match_operand:SI 0 "register_operand" "=r")
2635 (unspec:SI [(match_operand 1 "" "")] UNSPEC_GOTOFF))]
2637 "seth %0, %#shigh(%1@GOTOFF)\;add3 %0, %0, low(%1@GOTOFF)"
2638 [(set_attr "type" "int4")
2639 (set_attr "length" "8")])
2641 ;; Load program counter insns.
2643 (define_insn "get_pc"
2644 [(clobber (reg:SI 14))
2645 (set (match_operand 0 "register_operand" "=r")
2646 (unspec [(match_operand 1 "" "")] UNSPEC_GET_PC))
2647 (use (match_operand:SI 2 "immediate_operand" ""))]
2651 if (INTVAL(operands[2]))
2652 return \"bl.s .+4\;ld24 %0,%#%1\;add %0,lr\";
2654 return \"bl.s .+4\;seth %0,%#shigh(%1)\;add3 %0,%0,%#low(%1+4)\;add %0,lr\";}"
2655 [(set (attr "length") (if_then_else (ne (match_dup 2) (const_int 0))
2659 (define_expand "builtin_setjmp_receiver"
2660 [(label_ref (match_operand 0 "" ""))]
2664 m32r_load_pic_register ();