Merge reload-branch up to revision 101000
[official-gcc.git] / gcc / config / m32r / m32r.md
blob817c3c0287af01877ddbe5502341c227b0cc0036
1 ;; Machine description of the Renesas M32R cpu for GNU C compiler
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2001, 2003, 2004, 2005
3 ;  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, 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
22 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
24 ;; UNSPEC_VOLATILE usage
25 (define_constants
26   [(UNSPECV_BLOCKAGE            0)
27    (UNSPECV_FLUSH_ICACHE        1)])
29 ;; UNSPEC usage
30 (define_constants
31   [(UNSPEC_LOAD_SDA_BASE        2)
32    (UNSPEC_SET_CBIT             3)
33    (UNSPEC_PIC_LOAD_ADDR        4)
34    (UNSPEC_GET_PC               5)
35    (UNSPEC_GOTOFF               6)
36    ])
38 ;; Insn type.  Used to default other attribute values.
39 (define_attr "type"
40   "int2,int4,load2,load4,load8,store2,store4,store8,shift2,shift4,mul2,div4,uncond_branch,branch,call,multi,misc"
41   (const_string "misc"))
43 ;; Length in bytes.
44 (define_attr "length" ""
45   (cond [(eq_attr "type" "int2,load2,store2,shift2,mul2")
46          (const_int 2)
48          (eq_attr "type" "int4,load4,store4,shift4,div4")
49          (const_int 4)
51          (eq_attr "type" "multi")
52          (const_int 8)
54          (eq_attr "type" "uncond_branch,branch,call")
55          (const_int 4)]
57          (const_int 4)))
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")
92                    (const_string "o")
93                 (eq_attr "type" "mul2")
94                    (const_string "s")]
95          (const_string "long"))))
97 ;; ::::::::::::::::::::
98 ;; ::
99 ;; :: Pipeline description
100 ;; ::
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 bits
120 ;; instructions, or a single 32 bits 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")))
146   "o_IF,o_E")
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")))
152   "s_IF,s_E")
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")))
158   "o_IF|s_IF,o_E|s_E")
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")))
164   "long_IF,long_E")
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")))
170   "long_IF,long_E")
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")))
182   "o_IF,o_E,memory*2")
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")
203   
204 ;; Expand prologue as RTL
205 (define_expand "prologue"
206   [(const_int 1)]
207   ""
208   "
210   m32r_expand_prologue ();
211   DONE;
215 ;; Move instructions.
217 ;; For QI and HI moves, the register must contain the full properly
218 ;; sign-extended value.  nonzero_bits assumes this [otherwise
219 ;; SHORT_IMMEDIATES_SIGN_EXTEND must be used, but the comment for it
220 ;; says it's a kludge and the .md files should be fixed instead].
222 (define_expand "movqi"
223   [(set (match_operand:QI 0 "general_operand" "")
224         (match_operand:QI 1 "general_operand" ""))]
225   ""
226   "
228   /* Fixup PIC cases.  */
229   if (flag_pic)
230     {
231       if (symbolic_operand (operands[1], QImode))
232         {
233           if (reload_in_progress || reload_completed)
234             operands[1] = m32r_legitimize_pic_address (operands[1], operands[0]);
235           else
236             operands[1] = m32r_legitimize_pic_address (operands[1], NULL_RTX);
237         }
238     }
240   /* Everything except mem = const or mem = mem can be done easily.
241      Objects in the small data area are handled too.  */
243   if (GET_CODE (operands[0]) == MEM)
244     operands[1] = force_reg (QImode, operands[1]);
247 (define_insn "*movqi_insn"
248   [(set (match_operand:QI 0 "move_dest_operand" "=r,r,r,r,r,T,m")
249         (match_operand:QI 1 "move_src_operand" "r,I,JQR,T,m,r,r"))]
250   "register_operand (operands[0], QImode) || register_operand (operands[1], QImode)"
251   "@
252    mv %0,%1
253    ldi %0,%#%1
254    ldi %0,%#%1
255    ldub %0,%1
256    ldub %0,%1
257    stb %1,%0
258    stb %1,%0"
259   [(set_attr "type" "int2,int2,int4,load2,load4,store2,store4")
260    (set_attr "length" "2,2,4,2,4,2,4")])
262 (define_expand "movhi"
263   [(set (match_operand:HI 0 "general_operand" "")
264         (match_operand:HI 1 "general_operand" ""))]
265   ""
266   "
268   /* Fixup PIC cases.  */
269   if (flag_pic)
270     {
271       if (symbolic_operand (operands[1], HImode))
272         {
273           if (reload_in_progress || reload_completed)
274             operands[1] = m32r_legitimize_pic_address (operands[1], operands[0]);
275           else
276             operands[1] = m32r_legitimize_pic_address (operands[1], NULL_RTX);
277         }
278     }
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)"
290   "@
291    mv %0,%1
292    ldi %0,%#%1
293    ldi %0,%#%1
294    ld24 %0,%#%1
295    lduh %0,%1
296    lduh %0,%1
297    sth %1,%0
298    sth %1,%0"
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" ""))]
305   ""
306   "")
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" ""))))]
311   ""
312   "")
314 (define_expand "movsi"
315   [(set (match_operand:SI 0 "general_operand" "")
316         (match_operand:SI 1 "general_operand" ""))]
317   ""
318   "
320   /* Fixup PIC cases.  */
321   if (flag_pic)
322     {
323       if (symbolic_operand (operands[1], SImode))
324         {
325           if (reload_in_progress || reload_completed)
326             operands[1] = m32r_legitimize_pic_address (operands[1], operands[0]);
327           else
328             operands[1] = m32r_legitimize_pic_address (operands[1], NULL_RTX);
329         }
330     }
332   /* Everything except mem = const or mem = mem can be done easily.  */
334   if (GET_CODE (operands[0]) == MEM)
335     operands[1] = force_reg (SImode, operands[1]);
337   /* Small Data Area reference?  */
338   if (small_data_operand (operands[1], SImode))
339     {
340       emit_insn (gen_movsi_sda (operands[0], operands[1]));
341       DONE;
342     }
344   /* If medium or large code model, symbols have to be loaded with
345      seth/add3.  */
346   if (addr32_operand (operands[1], SImode))
347     {
348       emit_insn (gen_movsi_addr32 (operands[0], operands[1]));
349       DONE;
350     }
353 ;; ??? Do we need a const_double constraint here for large unsigned values?
354 (define_insn "*movsi_insn"
355   [(set (match_operand:SI 0 "move_dest_operand" "=r,r,r,r,r,r,r,r,r,T,S,m")
356         (match_operand:SI 1 "move_src_operand" "r,I,J,MQ,L,n,T,U,m,r,r,r"))]
357   "register_operand (operands[0], SImode) || register_operand (operands[1], SImode)"
358   "*
360   if (GET_CODE (operands[0]) == REG || GET_CODE (operands[1]) == SUBREG)
361     {
362       switch (GET_CODE (operands[1]))
363         {
364           HOST_WIDE_INT value;
366           default:
367             break;
369           case REG:
370           case SUBREG:
371             return \"mv %0,%1\";
373           case MEM:
374             if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
375                 && XEXP (XEXP (operands[1], 0), 0) == stack_pointer_rtx)
376               return \"pop %0\";
378             return \"ld %0,%1\";
380           case CONST_INT:
381             value = INTVAL (operands[1]);
382             if (INT16_P (value))
383               return \"ldi %0,%#%1\\t; %X1\";
385             if (UINT24_P (value))
386               return \"ld24 %0,%#%1\\t; %X1\";
388             if (UPPER16_P (value))
389               return \"seth %0,%#%T1\\t; %X1\";
391             return \"#\";
393           case CONST:
394           case SYMBOL_REF:
395           case LABEL_REF:
396             if (TARGET_ADDR24)
397               return \"ld24 %0,%#%1\";
399             return \"#\";
400         }
401     }
403   else if (GET_CODE (operands[0]) == MEM
404            && (GET_CODE (operands[1]) == REG || GET_CODE (operands[1]) == SUBREG))
405     {
406       if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
407           && XEXP (XEXP (operands[0], 0), 0) == stack_pointer_rtx)
408         return \"push %1\";
410       return \"st %1,%0\";
411     }
413   gcc_unreachable ();
415   [(set_attr "type" "int2,int2,int4,int4,int4,multi,load2,load2,load4,store2,store2,store4")
416    (set_attr "length" "2,2,4,4,4,8,2,2,4,2,2,4")])
418 ; Try to use a four byte / two byte pair for constants not loadable with
419 ; ldi, ld24, seth.
421 (define_split
422  [(set (match_operand:SI 0 "register_operand" "")
423        (match_operand:SI 1 "two_insn_const_operand" ""))]
424   ""
425   [(set (match_dup 0) (match_dup 2))
426    (set (match_dup 0) (ior:SI (match_dup 0) (match_dup 3)))]
427   "
429   unsigned HOST_WIDE_INT val = INTVAL (operands[1]);
430   unsigned HOST_WIDE_INT tmp;
431   int shift;
433   /* In all cases we will emit two instructions.  However we try to
434      use 2 byte instructions wherever possible.  We can assume the
435      constant isn't loadable with any of ldi, ld24, or seth.  */
437   /* See if we can load a 24 bit unsigned value and invert it.  */
438   if (UINT24_P (~ val))
439     {
440       emit_insn (gen_movsi (operands[0], GEN_INT (~ val)));
441       emit_insn (gen_one_cmplsi2 (operands[0], operands[0]));
442       DONE;
443     }
445   /* See if we can load a 24 bit unsigned value and shift it into place.
446      0x01fffffe is just beyond ld24's range.  */
447   for (shift = 1, tmp = 0x01fffffe;
448        shift < 8;
449        ++shift, tmp <<= 1)
450     {
451       if ((val & ~tmp) == 0)
452         {
453           emit_insn (gen_movsi (operands[0], GEN_INT (val >> shift)));
454           emit_insn (gen_ashlsi3 (operands[0], operands[0], GEN_INT (shift)));
455           DONE;
456         }
457     }
459   /* Can't use any two byte insn, fall back to seth/or3.  Use ~0xffff instead
460      of 0xffff0000, since the later fails on a 64-bit host.  */
461   operands[2] = GEN_INT ((val) & ~0xffff);
462   operands[3] = GEN_INT ((val) & 0xffff);
465 (define_split
466   [(set (match_operand:SI 0 "register_operand" "")
467         (match_operand:SI 1 "seth_add3_operand" ""))]
468   "TARGET_ADDR32"
469   [(set (match_dup 0)
470         (high:SI (match_dup 1)))
471    (set (match_dup 0)
472         (lo_sum:SI (match_dup 0)
473                    (match_dup 1)))]
474   "")
476 ;; Small data area support.
477 ;; The address of _SDA_BASE_ is loaded into a register and all objects in
478 ;; the small data area are indexed off that.  This is done for each reference
479 ;; but cse will clean things up for us.  We let the compiler choose the
480 ;; register to use so we needn't allocate (and maybe even fix) a special
481 ;; register to use.  Since the load and store insns have a 16 bit offset the
482 ;; total size of the data area can be 64K.  However, if the data area lives
483 ;; above 16M (24 bits), _SDA_BASE_ will have to be loaded with seth/add3 which
484 ;; would then yield 3 instructions to reference an object [though there would
485 ;; be no net loss if two or more objects were referenced].  The 3 insns can be
486 ;; reduced back to 2 if the size of the small data area were reduced to 32K
487 ;; [then seth + ld/st would work for any object in the area].  Doing this
488 ;; would require special handling of _SDA_BASE_ (its value would be
489 ;; (.sdata + 32K) & 0xffff0000) and reloc computations would be different
490 ;; [I think].  What to do about this is deferred until later and for now we
491 ;; require .sdata to be in the first 16M.
493 (define_expand "movsi_sda"
494   [(set (match_dup 2)
495         (unspec:SI [(const_int 0)] UNSPEC_LOAD_SDA_BASE))
496    (set (match_operand:SI 0 "register_operand" "")
497         (lo_sum:SI (match_dup 2)
498                    (match_operand:SI 1 "small_data_operand" "")))]
499   ""
500   "
502   if (reload_in_progress || reload_completed)
503     operands[2] = operands[0];
504   else
505     operands[2] = gen_reg_rtx (SImode);
508 (define_insn "*load_sda_base_32"
509   [(set (match_operand:SI 0 "register_operand" "=r")
510         (unspec:SI [(const_int 0)] UNSPEC_LOAD_SDA_BASE))]
511   "TARGET_ADDR32"
512   "seth %0,%#shigh(_SDA_BASE_)\;add3 %0,%0,%#low(_SDA_BASE_)"
513   [(set_attr "type" "multi")
514    (set_attr "length" "8")])
516 (define_insn "*load_sda_base"
517   [(set (match_operand:SI 0 "register_operand" "=r")
518         (unspec:SI [(const_int 0)] UNSPEC_LOAD_SDA_BASE))]
519   ""
520   "ld24 %0,#_SDA_BASE_"
521   [(set_attr "type" "int4")
522    (set_attr "length" "4")])
524 ;; 32 bit address support.
526 (define_expand "movsi_addr32"
527   [(set (match_dup 2)
528         ; addr32_operand isn't used because it's too restrictive,
529         ; seth_add3_operand is more general and thus safer.
530         (high:SI (match_operand:SI 1 "seth_add3_operand" "")))
531    (set (match_operand:SI 0 "register_operand" "")
532         (lo_sum:SI (match_dup 2) (match_dup 1)))]
533   ""
534   "
536   if (reload_in_progress || reload_completed)
537     operands[2] = operands[0];
538   else
539     operands[2] = gen_reg_rtx (SImode);
542 (define_insn "set_hi_si"
543   [(set (match_operand:SI 0 "register_operand" "=r")
544         (high:SI (match_operand 1 "symbolic_operand" "")))]
545   ""
546   "seth %0,%#shigh(%1)"
547   [(set_attr "type" "int4")
548    (set_attr "length" "4")])
550 (define_insn "lo_sum_si"
551   [(set (match_operand:SI 0 "register_operand" "=r")
552         (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
553                    (match_operand:SI 2 "immediate_operand" "in")))]
554   ""
555   "add3 %0,%1,%#%B2"
556   [(set_attr "type" "int4")
557    (set_attr "length" "4")])
559 (define_expand "movdi"
560   [(set (match_operand:DI 0 "general_operand" "")
561         (match_operand:DI 1 "general_operand" ""))]
562   ""
563   "
565   /* Fixup PIC cases.  */
566   if (flag_pic)
567     {
568       if (symbolic_operand (operands[1], DImode))
569         {
570           if (reload_in_progress || reload_completed)
571             operands[1] = m32r_legitimize_pic_address (operands[1], operands[0]);
572           else
573             operands[1] = m32r_legitimize_pic_address (operands[1], NULL_RTX);
574         }
575     }
577   /* Everything except mem = const or mem = mem can be done easily.  */
579   if (GET_CODE (operands[0]) == MEM)
580     operands[1] = force_reg (DImode, operands[1]);
583 (define_insn "*movdi_insn"
584   [(set (match_operand:DI 0 "move_dest_operand" "=r,r,r,r,m")
585         (match_operand:DI 1 "move_double_src_operand" "r,nG,F,m,r"))]
586   "register_operand (operands[0], DImode) || register_operand (operands[1], DImode)"
587   "#"
588   [(set_attr "type" "multi,multi,multi,load8,store8")
589    (set_attr "length" "4,4,16,6,6")])
591 (define_split
592   [(set (match_operand:DI 0 "move_dest_operand" "")
593         (match_operand:DI 1 "move_double_src_operand" ""))]
594   "reload_completed"
595   [(match_dup 2)]
596   "operands[2] = gen_split_move_double (operands);")
598 ;; Floating point move insns.
600 (define_expand "movsf"
601   [(set (match_operand:SF 0 "general_operand" "")
602         (match_operand:SF 1 "general_operand" ""))]
603   ""
604   "
606   /* Fixup PIC cases.  */
607   if (flag_pic)
608     {
609       if (symbolic_operand (operands[1], SFmode))
610         {
611           if (reload_in_progress || reload_completed)
612             operands[1] = m32r_legitimize_pic_address (operands[1], operands[0]);
613           else
614             operands[1] = m32r_legitimize_pic_address (operands[1], NULL_RTX);
615         }
616     }
618   /* Everything except mem = const or mem = mem can be done easily.  */
620   if (GET_CODE (operands[0]) == MEM)
621     operands[1] = force_reg (SFmode, operands[1]);
624 (define_insn "*movsf_insn"
625   [(set (match_operand:SF 0 "move_dest_operand" "=r,r,r,r,r,T,S,m")
626         (match_operand:SF 1 "move_src_operand" "r,F,U,S,m,r,r,r"))]
627   "register_operand (operands[0], SFmode) || register_operand (operands[1], SFmode)"
628   "@
629    mv %0,%1
630    #
631    ld %0,%1
632    ld %0,%1
633    ld %0,%1
634    st %1,%0
635    st %1,%0
636    st %1,%0"
637   ;; ??? Length of alternative 1 is either 2, 4 or 8.
638   [(set_attr "type" "int2,multi,load2,load2,load4,store2,store2,store4")
639    (set_attr "length" "2,8,2,2,4,2,2,4")])
641 (define_split
642   [(set (match_operand:SF 0 "register_operand" "")
643         (match_operand:SF 1 "const_double_operand" ""))]
644   "reload_completed"
645   [(set (match_dup 2) (match_dup 3))]
646   "
648   operands[2] = operand_subword (operands[0], 0, 0, SFmode);
649   operands[3] = operand_subword (operands[1], 0, 0, SFmode);
652 (define_expand "movdf"
653   [(set (match_operand:DF 0 "general_operand" "")
654         (match_operand:DF 1 "general_operand" ""))]
655   ""
656   "
658   /* Fixup PIC cases.  */
659   if (flag_pic)
660     {
661       if (symbolic_operand (operands[1], DFmode))
662         {
663           if (reload_in_progress || reload_completed)
664             operands[1] = m32r_legitimize_pic_address (operands[1], operands[0]);
665           else
666             operands[1] = m32r_legitimize_pic_address (operands[1], NULL_RTX);
667         }
668     }
670   /* Everything except mem = const or mem = mem can be done easily.  */
672   if (GET_CODE (operands[0]) == MEM)
673     operands[1] = force_reg (DFmode, operands[1]);
676 (define_insn "*movdf_insn"
677   [(set (match_operand:DF 0 "move_dest_operand" "=r,r,r,m")
678         (match_operand:DF 1 "move_double_src_operand" "r,F,m,r"))]
679   "register_operand (operands[0], DFmode) || register_operand (operands[1], DFmode)"
680   "#"
681   [(set_attr "type" "multi,multi,load8,store8")
682    (set_attr "length" "4,16,6,6")])
684 (define_split
685   [(set (match_operand:DF 0 "move_dest_operand" "")
686         (match_operand:DF 1 "move_double_src_operand" ""))]
687   "reload_completed"
688   [(match_dup 2)]
689   "operands[2] = gen_split_move_double (operands);")
691 ;; Zero extension instructions.
693 (define_insn "zero_extendqihi2"
694   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
695         (zero_extend:HI (match_operand:QI 1 "extend_operand" "r,T,m")))]
696   ""
697   "@
698    and3 %0,%1,%#255
699    ldub %0,%1
700    ldub %0,%1"
701   [(set_attr "type" "int4,load2,load4")
702    (set_attr "length" "4,2,4")])
704 (define_insn "zero_extendqisi2"
705   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
706         (zero_extend:SI (match_operand:QI 1 "extend_operand" "r,T,m")))]
707   ""
708   "@
709    and3 %0,%1,%#255
710    ldub %0,%1
711    ldub %0,%1"
712   [(set_attr "type" "int4,load2,load4")
713    (set_attr "length" "4,2,4")])
715 (define_insn "zero_extendhisi2"
716   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
717         (zero_extend:SI (match_operand:HI 1 "extend_operand" "r,T,m")))]
718   ""
719   "@
720    and3 %0,%1,%#65535
721    lduh %0,%1
722    lduh %0,%1"
723   [(set_attr "type" "int4,load2,load4")
724    (set_attr "length" "4,2,4")])
726 ;; Signed conversions from a smaller integer to a larger integer
727 (define_insn "extendqihi2"
728   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
729         (sign_extend:HI (match_operand:QI 1 "extend_operand" "0,T,m")))]
730   ""
731   "@
732     #
733     ldb %0,%1
734     ldb %0,%1"
735   [(set_attr "type" "multi,load2,load4")
736    (set_attr "length" "2,2,4")])
738 (define_split
739   [(set (match_operand:HI 0 "register_operand" "")
740         (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
741   "reload_completed"
742   [(match_dup 2)
743    (match_dup 3)]
744   "
746   rtx op0   = gen_lowpart (SImode, operands[0]);
747   rtx shift = GEN_INT (24);
749   operands[2] = gen_ashlsi3 (op0, op0, shift);
750   operands[3] = gen_ashrsi3 (op0, op0, shift);
753 (define_insn "extendqisi2"
754   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
755         (sign_extend:SI (match_operand:QI 1 "extend_operand" "0,T,m")))]
756   ""
757   "@
758     #
759     ldb %0,%1
760     ldb %0,%1"
761   [(set_attr "type" "multi,load2,load4")
762    (set_attr "length" "4,2,4")])
764 (define_split
765   [(set (match_operand:SI 0 "register_operand" "")
766         (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
767   "reload_completed"
768   [(match_dup 2)
769    (match_dup 3)]
770   "
772   rtx shift = GEN_INT (24);
774   operands[2] = gen_ashlsi3 (operands[0], operands[0], shift);
775   operands[3] = gen_ashrsi3 (operands[0], operands[0], shift);
778 (define_insn "extendhisi2"
779   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
780         (sign_extend:SI (match_operand:HI 1 "extend_operand" "0,T,m")))]
781   ""
782   "@
783     #
784     ldh %0,%1
785     ldh %0,%1"
786   [(set_attr "type" "multi,load2,load4")
787    (set_attr "length" "4,2,4")])
789 (define_split
790   [(set (match_operand:SI 0 "register_operand" "")
791         (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
792   "reload_completed"
793   [(match_dup 2)
794    (match_dup 3)]
795   "
797   rtx shift = GEN_INT (16);
799   operands[2] = gen_ashlsi3 (operands[0], operands[0], shift);
800   operands[3] = gen_ashrsi3 (operands[0], operands[0], shift);
803 ;; Arithmetic instructions.
805 ; ??? Adding an alternative to split add3 of small constants into two
806 ; insns yields better instruction packing but slower code.  Adds of small
807 ; values is done a lot.
809 (define_insn "addsi3"
810   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
811         (plus:SI (match_operand:SI 1 "register_operand" "%0,0,r")
812                  (match_operand:SI 2 "nonmemory_operand" "r,I,J")))]
813   ""
814   "@
815    add %0,%2
816    addi %0,%#%2
817    add3 %0,%1,%#%2"
818   [(set_attr "type" "int2,int2,int4")
819    (set_attr "length" "2,2,4")])
821 ;(define_split
822 ;  [(set (match_operand:SI 0 "register_operand" "")
823 ;       (plus:SI (match_operand:SI 1 "register_operand" "")
824 ;                (match_operand:SI 2 "int8_operand" "")))]
825 ;  "reload_completed
826 ;   && REGNO (operands[0]) != REGNO (operands[1])
827 ;   && INT8_P (INTVAL (operands[2]))
828 ;   && INTVAL (operands[2]) != 0"
829 ;  [(set (match_dup 0) (match_dup 1))
830 ;   (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
831 ;  "")
833 (define_insn "adddi3"
834   [(set (match_operand:DI 0 "register_operand" "=r")
835         (plus:DI (match_operand:DI 1 "register_operand" "%0")
836                  (match_operand:DI 2 "register_operand" "r")))
837    (clobber (reg:CC 17))]
838   ""
839   "#"
840   [(set_attr "type" "multi")
841    (set_attr "length" "6")])
843 ;; ??? The cmp clears the condition bit.  Can we speed up somehow?
844 (define_split
845   [(set (match_operand:DI 0 "register_operand" "")
846         (plus:DI (match_operand:DI 1 "register_operand" "")
847                  (match_operand:DI 2 "register_operand" "")))
848    (clobber (reg:CC 17))]
849   "reload_completed"
850   [(parallel [(set (reg:CC 17)
851                    (const_int 0))
852               (use (match_dup 4))])
853    (parallel [(set (match_dup 4)
854                    (plus:SI (match_dup 4)
855                             (plus:SI (match_dup 5)
856                                      (ne:SI (reg:CC 17) (const_int 0)))))
857               (set (reg:CC 17)
858                    (unspec:CC [(const_int 0)] UNSPEC_SET_CBIT))])
859    (parallel [(set (match_dup 6)
860                    (plus:SI (match_dup 6)
861                             (plus:SI (match_dup 7)
862                                      (ne:SI (reg:CC 17) (const_int 0)))))
863               (set (reg:CC 17)
864                    (unspec:CC [(const_int 0)] UNSPEC_SET_CBIT))])]
865   "
867   operands[4] = operand_subword (operands[0], (WORDS_BIG_ENDIAN != 0), 0, DImode);
868   operands[5] = operand_subword (operands[2], (WORDS_BIG_ENDIAN != 0), 0, DImode);
869   operands[6] = operand_subword (operands[0], (WORDS_BIG_ENDIAN == 0), 0, DImode);
870   operands[7] = operand_subword (operands[2], (WORDS_BIG_ENDIAN == 0), 0, DImode);
873 (define_insn "*clear_c"
874   [(set (reg:CC 17)
875         (const_int 0))
876    (use (match_operand:SI 0 "register_operand" "r"))]
877   ""
878   "cmp %0,%0"
879   [(set_attr "type" "int2")
880    (set_attr "length" "2")])
882 (define_insn "*add_carry"
883   [(set (match_operand:SI 0 "register_operand" "=r")
884         (plus:SI (match_operand:SI 1 "register_operand" "%0")
885                  (plus:SI (match_operand:SI 2 "register_operand" "r")
886                           (ne:SI (reg:CC 17) (const_int 0)))))
887    (set (reg:CC 17)
888         (unspec:CC [(const_int 0)] UNSPEC_SET_CBIT))]
889   ""
890   "addx %0,%2"
891   [(set_attr "type" "int2")
892    (set_attr "length" "2")])
894 (define_insn "subsi3"
895   [(set (match_operand:SI 0 "register_operand" "=r")
896         (minus:SI (match_operand:SI 1 "register_operand" "0")
897                   (match_operand:SI 2 "register_operand" "r")))]
898   ""
899   "sub %0,%2"
900   [(set_attr "type" "int2")
901    (set_attr "length" "2")])
903 (define_insn "subdi3"
904   [(set (match_operand:DI 0 "register_operand" "=r")
905         (minus:DI (match_operand:DI 1 "register_operand" "0")
906                   (match_operand:DI 2 "register_operand" "r")))
907    (clobber (reg:CC 17))]
908   ""
909   "#"
910   [(set_attr "type" "multi")
911    (set_attr "length" "6")])
913 ;; ??? The cmp clears the condition bit.  Can we speed up somehow?
914 (define_split
915   [(set (match_operand:DI 0 "register_operand" "")
916         (minus:DI (match_operand:DI 1 "register_operand" "")
917                   (match_operand:DI 2 "register_operand" "")))
918    (clobber (reg:CC 17))]
919   "reload_completed"
920   [(parallel [(set (reg:CC 17)
921                    (const_int 0))
922               (use (match_dup 4))])
923    (parallel [(set (match_dup 4)
924                    (minus:SI (match_dup 4)
925                              (minus:SI (match_dup 5)
926                                        (ne:SI (reg:CC 17) (const_int 0)))))
927               (set (reg:CC 17)
928                    (unspec:CC [(const_int 0)] UNSPEC_SET_CBIT))])
929    (parallel [(set (match_dup 6)
930                    (minus:SI (match_dup 6)
931                              (minus:SI (match_dup 7)
932                                        (ne:SI (reg:CC 17) (const_int 0)))))
933               (set (reg:CC 17)
934                    (unspec:CC [(const_int 0)] UNSPEC_SET_CBIT))])]
935   "
937   operands[4] = operand_subword (operands[0], (WORDS_BIG_ENDIAN != 0), 0, DImode);
938   operands[5] = operand_subword (operands[2], (WORDS_BIG_ENDIAN != 0), 0, DImode);
939   operands[6] = operand_subword (operands[0], (WORDS_BIG_ENDIAN == 0), 0, DImode);
940   operands[7] = operand_subword (operands[2], (WORDS_BIG_ENDIAN == 0), 0, DImode);
943 (define_insn "*sub_carry"
944   [(set (match_operand:SI 0 "register_operand" "=r")
945         (minus:SI (match_operand:SI 1 "register_operand" "%0")
946                   (minus:SI (match_operand:SI 2 "register_operand" "r")
947                             (ne:SI (reg:CC 17) (const_int 0)))))
948    (set (reg:CC 17)
949         (unspec:CC [(const_int 0)] UNSPEC_SET_CBIT))]
950   ""
951   "subx %0,%2"
952   [(set_attr "type" "int2")
953    (set_attr "length" "2")])
955 ; Multiply/Divide instructions.
957 (define_insn "mulhisi3"
958   [(set (match_operand:SI 0 "register_operand" "=r")
959         (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "r"))
960                  (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
961   ""
962   "mullo %1,%2\;mvfacmi %0"
963   [(set_attr "type" "multi")
964    (set_attr "length" "4")])
966 (define_insn "mulsi3"
967   [(set (match_operand:SI 0 "register_operand" "=r")
968         (mult:SI (match_operand:SI 1 "register_operand" "%0")
969                  (match_operand:SI 2 "register_operand" "r")))]
970   ""
971   "mul %0,%2"
972   [(set_attr "type" "mul2")
973    (set_attr "length" "2")])
975 (define_insn "divsi3"
976   [(set (match_operand:SI 0 "register_operand" "=r")
977         (div:SI (match_operand:SI 1 "register_operand" "0")
978                 (match_operand:SI 2 "register_operand" "r")))]
979   ""
980   "div %0,%2"
981   [(set_attr "type" "div4")
982    (set_attr "length" "4")])
984 (define_insn "udivsi3"
985   [(set (match_operand:SI 0 "register_operand" "=r")
986         (udiv:SI (match_operand:SI 1 "register_operand" "0")
987                  (match_operand:SI 2 "register_operand" "r")))]
988   ""
989   "divu %0,%2"
990   [(set_attr "type" "div4")
991    (set_attr "length" "4")])
993 (define_insn "modsi3"
994   [(set (match_operand:SI 0 "register_operand" "=r")
995         (mod:SI (match_operand:SI 1 "register_operand" "0")
996                 (match_operand:SI 2 "register_operand" "r")))]
997   ""
998   "rem %0,%2"
999   [(set_attr "type" "div4")
1000    (set_attr "length" "4")])
1002 (define_insn "umodsi3"
1003   [(set (match_operand:SI 0 "register_operand" "=r")
1004         (umod:SI (match_operand:SI 1 "register_operand" "0")
1005                  (match_operand:SI 2 "register_operand" "r")))]
1006   ""
1007   "remu %0,%2"
1008   [(set_attr "type" "div4")
1009    (set_attr "length" "4")])
1011 ;; Boolean instructions.
1013 ;; We don't define the DImode versions as expand_binop does a good enough job.
1014 ;; And if it doesn't it should be fixed.
1016 (define_insn "andsi3"
1017   [(set (match_operand:SI 0 "register_operand" "=r,r")
1018         (and:SI (match_operand:SI 1 "register_operand" "%0,r")
1019                 (match_operand:SI 2 "reg_or_uint16_operand" "r,K")))]
1020   ""
1021   "*
1023   /* If we are worried about space, see if we can break this up into two
1024      short instructions, which might eliminate a NOP being inserted.  */
1025   if (optimize_size
1026       && m32r_not_same_reg (operands[0], operands[1])
1027       && GET_CODE (operands[2]) == CONST_INT
1028       && INT8_P (INTVAL (operands[2])))
1029     return \"#\";
1031   else if (GET_CODE (operands[2]) == CONST_INT)
1032     return \"and3 %0,%1,%#%X2\";
1034   return \"and %0,%2\";
1036   [(set_attr "type" "int2,int4")
1037    (set_attr "length" "2,4")])
1039 (define_split
1040   [(set (match_operand:SI 0 "register_operand" "")
1041         (and:SI (match_operand:SI 1 "register_operand" "")
1042                 (match_operand:SI 2 "int8_operand" "")))]
1043   "optimize_size && m32r_not_same_reg (operands[0], operands[1])"
1044   [(set (match_dup 0) (match_dup 2))
1045    (set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))]
1046   "")
1048 (define_insn "iorsi3"
1049   [(set (match_operand:SI 0 "register_operand" "=r,r")
1050         (ior:SI (match_operand:SI 1 "register_operand" "%0,r")
1051                 (match_operand:SI 2 "reg_or_uint16_operand" "r,K")))]
1052   ""
1053   "*
1055   /* If we are worried about space, see if we can break this up into two
1056      short instructions, which might eliminate a NOP being inserted.  */
1057   if (optimize_size
1058       && m32r_not_same_reg (operands[0], operands[1])
1059       && GET_CODE (operands[2]) == CONST_INT
1060       && INT8_P (INTVAL (operands[2])))
1061     return \"#\";
1063   else if (GET_CODE (operands[2]) == CONST_INT)
1064     return \"or3 %0,%1,%#%X2\";
1066   return \"or %0,%2\";
1068   [(set_attr "type" "int2,int4")
1069    (set_attr "length" "2,4")])
1071 (define_split
1072   [(set (match_operand:SI 0 "register_operand" "")
1073         (ior:SI (match_operand:SI 1 "register_operand" "")
1074                 (match_operand:SI 2 "int8_operand" "")))]
1075   "optimize_size && m32r_not_same_reg (operands[0], operands[1])"
1076   [(set (match_dup 0) (match_dup 2))
1077    (set (match_dup 0) (ior:SI (match_dup 0) (match_dup 1)))]
1078   "")
1080 (define_insn "xorsi3"
1081   [(set (match_operand:SI 0 "register_operand" "=r,r")
1082         (xor:SI (match_operand:SI 1 "register_operand" "%0,r")
1083                 (match_operand:SI 2 "reg_or_uint16_operand" "r,K")))]
1084   ""
1085   "*
1087   /* If we are worried about space, see if we can break this up into two
1088      short instructions, which might eliminate a NOP being inserted.  */
1089   if (optimize_size
1090       && m32r_not_same_reg (operands[0], operands[1])
1091       && GET_CODE (operands[2]) == CONST_INT
1092       && INT8_P (INTVAL (operands[2])))
1093     return \"#\";
1095   else if (GET_CODE (operands[2]) == CONST_INT)
1096     return \"xor3 %0,%1,%#%X2\";
1098   return \"xor %0,%2\";
1100   [(set_attr "type" "int2,int4")
1101    (set_attr "length" "2,4")])
1103 (define_split
1104   [(set (match_operand:SI 0 "register_operand" "")
1105         (xor:SI (match_operand:SI 1 "register_operand" "")
1106                 (match_operand:SI 2 "int8_operand" "")))]
1107   "optimize_size && m32r_not_same_reg (operands[0], operands[1])"
1108   [(set (match_dup 0) (match_dup 2))
1109    (set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))]
1110   "")
1112 (define_insn "negsi2"
1113   [(set (match_operand:SI 0 "register_operand" "=r")
1114         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
1115   ""
1116   "neg %0,%1"
1117   [(set_attr "type" "int2")
1118    (set_attr "length" "2")])
1120 (define_insn "one_cmplsi2"
1121   [(set (match_operand:SI 0 "register_operand" "=r")
1122         (not:SI (match_operand:SI 1 "register_operand" "r")))]
1123   ""
1124   "not %0,%1"
1125   [(set_attr "type" "int2")
1126    (set_attr "length" "2")])
1128 ;; Shift instructions.
1130 (define_insn "ashlsi3"
1131   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1132         (ashift:SI (match_operand:SI 1 "register_operand" "0,0,r")
1133                    (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))]
1134   ""
1135   "@
1136    sll %0,%2
1137    slli %0,%#%2
1138    sll3 %0,%1,%#%2"
1139   [(set_attr "type" "shift2,shift2,shift4")
1140    (set_attr "length" "2,2,4")])
1142 (define_insn "ashrsi3"
1143   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1144         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r")
1145                      (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))]
1146   ""
1147   "@
1148    sra %0,%2
1149    srai %0,%#%2
1150    sra3 %0,%1,%#%2"
1151   [(set_attr "type" "shift2,shift2,shift4")
1152    (set_attr "length" "2,2,4")])
1154 (define_insn "lshrsi3"
1155   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1156         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r")
1157                      (match_operand:SI 2 "reg_or_uint16_operand" "r,O,K")))]
1158   ""
1159   "@
1160    srl %0,%2
1161    srli %0,%#%2
1162    srl3 %0,%1,%#%2"
1163   [(set_attr "type" "shift2,shift2,shift4")
1164    (set_attr "length" "2,2,4")])
1166 ;; Compare instructions.
1167 ;; This controls RTL generation and register allocation.
1169 ;; We generate RTL for comparisons and branches by having the cmpxx 
1170 ;; patterns store away the operands.  Then the bcc patterns
1171 ;; emit RTL for both the compare and the branch.
1173 ;; On the m32r it is more efficient to use the bxxz instructions and
1174 ;; thus merge the compare and branch into one instruction, so they are
1175 ;; preferred.
1177 (define_expand "cmpsi"
1178   [(set (reg:CC 17)
1179         (compare:CC (match_operand:SI 0 "register_operand" "")
1180                     (match_operand:SI 1 "reg_or_cmp_int16_operand" "")))]
1181   ""
1182   "
1184   m32r_compare_op0 = operands[0];
1185   m32r_compare_op1 = operands[1];
1186   DONE;
1189 (define_insn "cmp_eqsi_zero_insn"
1190   [(set (reg:CC 17)
1191         (eq:CC (match_operand:SI 0 "register_operand" "r,r")
1192                (match_operand:SI 1 "reg_or_zero_operand" "r,P")))]
1193   "TARGET_M32RX || TARGET_M32R2"
1194   "@
1195    cmpeq %0, %1
1196    cmpz  %0"
1197   [(set_attr "type" "int4")
1198    (set_attr "length" "4")])
1200 ;; The cmp_xxx_insn patterns set the condition bit to the result of the
1201 ;; comparison.  There isn't a "compare equal" instruction so cmp_eqsi_insn
1202 ;; is quite inefficient.  However, it is rarely used.
1204 (define_insn "cmp_eqsi_insn"
1205   [(set (reg:CC 17)
1206         (eq:CC (match_operand:SI 0 "register_operand" "r,r")
1207                (match_operand:SI 1 "reg_or_cmp_int16_operand" "r,P")))
1208    (clobber (match_scratch:SI 2 "=&r,&r"))]
1209   ""
1210   "*
1212   if (which_alternative == 0)
1213     {
1214          return \"mv %2,%0\;sub %2,%1\;cmpui %2,#1\";
1215     }
1216   else
1217     {
1218         if (INTVAL (operands [1]) == 0)
1219           return \"cmpui %0, #1\";
1220         else if (REGNO (operands [2]) == REGNO (operands [0]))
1221           return \"addi %0,%#%N1\;cmpui %2,#1\";
1222         else
1223           return \"add3 %2,%0,%#%N1\;cmpui %2,#1\";
1224     }
1226   [(set_attr "type" "multi,multi")
1227    (set_attr "length" "8,8")])
1229 (define_insn "cmp_ltsi_insn"
1230   [(set (reg:CC 17)
1231         (lt:CC (match_operand:SI 0 "register_operand" "r,r")
1232                (match_operand:SI 1 "reg_or_int16_operand" "r,J")))]
1233   ""
1234   "@
1235    cmp %0,%1
1236    cmpi %0,%#%1"
1237   [(set_attr "type" "int2,int4")
1238    (set_attr "length" "2,4")])
1240 (define_insn "cmp_ltusi_insn"
1241   [(set (reg:CC 17)
1242         (ltu:CC (match_operand:SI 0 "register_operand" "r,r")
1243                 (match_operand:SI 1 "reg_or_int16_operand" "r,J")))]
1244   ""
1245   "@
1246    cmpu %0,%1
1247    cmpui %0,%#%1"
1248   [(set_attr "type" "int2,int4")
1249    (set_attr "length" "2,4")])
1251 ;; These control RTL generation for conditional jump insns.
1253 (define_expand "beq"
1254   [(set (pc)
1255         (if_then_else (match_dup 1)
1256                       (label_ref (match_operand 0 "" ""))
1257                       (pc)))]
1258   ""
1259   "
1261   operands[1] = gen_compare (EQ, m32r_compare_op0, m32r_compare_op1, FALSE);
1264 (define_expand "bne"
1265   [(set (pc)
1266         (if_then_else (match_dup 1)
1267                       (label_ref (match_operand 0 "" ""))
1268                       (pc)))]
1269   ""
1270   "
1272   operands[1] = gen_compare (NE, m32r_compare_op0, m32r_compare_op1, FALSE);
1275 (define_expand "bgt"
1276   [(set (pc)
1277         (if_then_else (match_dup 1)
1278                       (label_ref (match_operand 0 "" ""))
1279                       (pc)))]
1280   ""
1281   "
1283   operands[1] = gen_compare (GT, m32r_compare_op0, m32r_compare_op1, FALSE);
1286 (define_expand "ble"
1287   [(set (pc)
1288         (if_then_else (match_dup 1)
1289                       (label_ref (match_operand 0 "" ""))
1290                       (pc)))]
1291   ""
1292   "
1294   operands[1] = gen_compare (LE, m32r_compare_op0, m32r_compare_op1, FALSE);
1297 (define_expand "bge"
1298   [(set (pc)
1299         (if_then_else (match_dup 1)
1300                       (label_ref (match_operand 0 "" ""))
1301                       (pc)))]
1302   ""
1303   "
1305   operands[1] = gen_compare (GE, m32r_compare_op0, m32r_compare_op1, FALSE);
1308 (define_expand "blt"
1309   [(set (pc)
1310         (if_then_else (match_dup 1)
1311                       (label_ref (match_operand 0 "" ""))
1312                       (pc)))]
1313   ""
1314   "
1316   operands[1] = gen_compare (LT, m32r_compare_op0, m32r_compare_op1, FALSE);
1319 (define_expand "bgtu"
1320   [(set (pc)
1321         (if_then_else (match_dup 1)
1322                       (label_ref (match_operand 0 "" ""))
1323                       (pc)))]
1324   ""
1325   "
1327   operands[1] = gen_compare (GTU, m32r_compare_op0, m32r_compare_op1, FALSE);
1330 (define_expand "bleu"
1331   [(set (pc)
1332         (if_then_else (match_dup 1)
1333                       (label_ref (match_operand 0 "" ""))
1334                       (pc)))]
1335   ""
1336   "
1338   operands[1] = gen_compare (LEU, m32r_compare_op0, m32r_compare_op1, FALSE);
1341 (define_expand "bgeu"
1342   [(set (pc)
1343         (if_then_else (match_dup 1)
1344                       (label_ref (match_operand 0 "" ""))
1345                       (pc)))]
1346   ""
1347   "
1349   operands[1] = gen_compare (GEU, m32r_compare_op0, m32r_compare_op1, FALSE);
1352 (define_expand "bltu"
1353   [(set (pc)
1354         (if_then_else (match_dup 1)
1355                       (label_ref (match_operand 0 "" ""))
1356                       (pc)))]
1357   ""
1358   "
1360   operands[1] = gen_compare (LTU, m32r_compare_op0, m32r_compare_op1, FALSE);
1363 ;; Now match both normal and inverted jump.
1365 (define_insn "*branch_insn"
1366   [(set (pc)
1367         (if_then_else (match_operator 1 "eqne_comparison_operator"
1368                                       [(reg 17) (const_int 0)])
1369                       (label_ref (match_operand 0 "" ""))
1370                       (pc)))]
1371   ""
1372   "*
1374   static char instruction[40];
1375   sprintf (instruction, \"%s%s %%l0\",
1376            (GET_CODE (operands[1]) == NE) ? \"bc\" : \"bnc\",
1377            (get_attr_length (insn) == 2) ? \".s\" : \"\");
1378   return instruction;
1380   [(set_attr "type" "branch")
1381    ; We use 400/800 instead of 512,1024 to account for inaccurate insn
1382    ; lengths and insn alignments that are complex to track.
1383    ; It's not important that we be hyper-precise here.  It may be more
1384    ; important blah blah blah when the chip supports parallel execution
1385    ; blah blah blah but until then blah blah blah this is simple and
1386    ; suffices.
1387    (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1388                                                  (const_int 400))
1389                                            (const_int 800))
1390                                       (const_int 2)
1391                                       (const_int 4)))])
1393 (define_insn "*rev_branch_insn"
1394   [(set (pc)
1395         (if_then_else (match_operator 1 "eqne_comparison_operator"
1396                                       [(reg 17) (const_int 0)])
1397                       (pc)
1398                       (label_ref (match_operand 0 "" ""))))]
1399   ;"REVERSIBLE_CC_MODE (GET_MODE (XEXP (operands[1], 0)))"
1400   ""
1401   "*
1403   static char instruction[40];
1404   sprintf (instruction, \"%s%s %%l0\",
1405            (GET_CODE (operands[1]) == EQ) ? \"bc\" : \"bnc\",
1406            (get_attr_length (insn) == 2) ? \".s\" : \"\");
1407   return instruction;
1409   [(set_attr "type" "branch")
1410    ; We use 400/800 instead of 512,1024 to account for inaccurate insn
1411    ; lengths and insn alignments that are complex to track.
1412    ; It's not important that we be hyper-precise here.  It may be more
1413    ; important blah blah blah when the chip supports parallel execution
1414    ; blah blah blah but until then blah blah blah this is simple and
1415    ; suffices.
1416    (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1417                                                  (const_int 400))
1418                                            (const_int 800))
1419                                       (const_int 2)
1420                                       (const_int 4)))])
1422 ; reg/reg compare and branch insns
1424 (define_insn "*reg_branch_insn"
1425   [(set (pc)
1426         (if_then_else (match_operator 1 "eqne_comparison_operator"
1427                                       [(match_operand:SI 2 "register_operand" "r")
1428                                        (match_operand:SI 3 "register_operand" "r")])
1429                       (label_ref (match_operand 0 "" ""))
1430                       (pc)))]
1431   ""
1432   "*
1434   /* Is branch target reachable with beq/bne?  */
1435   if (get_attr_length (insn) == 4)
1436     {
1437       if (GET_CODE (operands[1]) == EQ)
1438         return \"beq %2,%3,%l0\";
1439       else
1440         return \"bne %2,%3,%l0\";
1441     }
1442   else
1443     {
1444       if (GET_CODE (operands[1]) == EQ)
1445         return \"bne %2,%3,1f\;bra %l0\;1:\";
1446       else
1447         return \"beq %2,%3,1f\;bra %l0\;1:\";
1448     }
1450   [(set_attr "type" "branch")
1451   ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1452   ; which is complex to track and inaccurate length specs.
1453    (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1454                                                  (const_int 25000))
1455                                            (const_int 50000))
1456                                       (const_int 4)
1457                                       (const_int 8)))])
1459 (define_insn "*rev_reg_branch_insn"
1460   [(set (pc)
1461         (if_then_else (match_operator 1 "eqne_comparison_operator"
1462                                       [(match_operand:SI 2 "register_operand" "r")
1463                                        (match_operand:SI 3 "register_operand" "r")])
1464                       (pc)
1465                       (label_ref (match_operand 0 "" ""))))]
1466   ""
1467   "*
1469   /* Is branch target reachable with beq/bne?  */
1470   if (get_attr_length (insn) == 4)
1471     {
1472       if (GET_CODE (operands[1]) == NE)
1473         return \"beq %2,%3,%l0\";
1474       else
1475         return \"bne %2,%3,%l0\";
1476     }
1477   else
1478     {
1479       if (GET_CODE (operands[1]) == NE)
1480         return \"bne %2,%3,1f\;bra %l0\;1:\";
1481       else
1482         return \"beq %2,%3,1f\;bra %l0\;1:\";
1483     }
1485   [(set_attr "type" "branch")
1486   ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1487   ; which is complex to track and inaccurate length specs.
1488    (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1489                                                  (const_int 25000))
1490                                            (const_int 50000))
1491                                       (const_int 4)
1492                                       (const_int 8)))])
1494 ; reg/zero compare and branch insns
1496 (define_insn "*zero_branch_insn"
1497   [(set (pc)
1498         (if_then_else (match_operator 1 "signed_comparison_operator"
1499                                       [(match_operand:SI 2 "register_operand" "r")
1500                                        (const_int 0)])
1501                       (label_ref (match_operand 0 "" ""))
1502                       (pc)))]
1503   ""
1504   "*
1506   const char *br,*invbr;
1507   char asmtext[40];
1509   switch (GET_CODE (operands[1]))
1510     {
1511       case EQ : br = \"eq\"; invbr = \"ne\"; break;
1512       case NE : br = \"ne\"; invbr = \"eq\"; break;
1513       case LE : br = \"le\"; invbr = \"gt\"; break;
1514       case GT : br = \"gt\"; invbr = \"le\"; break;
1515       case LT : br = \"lt\"; invbr = \"ge\"; break;
1516       case GE : br = \"ge\"; invbr = \"lt\"; break;
1518       default: gcc_unreachable ();
1519     }
1521   /* Is branch target reachable with bxxz?  */
1522   if (get_attr_length (insn) == 4)
1523     {
1524       sprintf (asmtext, \"b%sz %%2,%%l0\", br);
1525       output_asm_insn (asmtext, operands);
1526     }
1527   else
1528     {
1529       sprintf (asmtext, \"b%sz %%2,1f\;bra %%l0\;1:\", invbr);
1530       output_asm_insn (asmtext, operands);
1531     }
1532   return \"\";
1534   [(set_attr "type" "branch")
1535   ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1536   ; which is complex to track and inaccurate length specs.
1537    (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1538                                                  (const_int 25000))
1539                                            (const_int 50000))
1540                                       (const_int 4)
1541                                       (const_int 8)))])
1543 (define_insn "*rev_zero_branch_insn"
1544   [(set (pc)
1545         (if_then_else (match_operator 1 "eqne_comparison_operator"
1546                                       [(match_operand:SI 2 "register_operand" "r")
1547                                        (const_int 0)])
1548                       (pc)
1549                       (label_ref (match_operand 0 "" ""))))]
1550   ""
1551   "*
1553   const char *br,*invbr;
1554   char asmtext[40];
1556   switch (GET_CODE (operands[1]))
1557     {
1558       case EQ : br = \"eq\"; invbr = \"ne\"; break;
1559       case NE : br = \"ne\"; invbr = \"eq\"; break;
1560       case LE : br = \"le\"; invbr = \"gt\"; break;
1561       case GT : br = \"gt\"; invbr = \"le\"; break;
1562       case LT : br = \"lt\"; invbr = \"ge\"; break;
1563       case GE : br = \"ge\"; invbr = \"lt\"; break;
1565       default: gcc_unreachable ();
1566     }
1568   /* Is branch target reachable with bxxz?  */
1569   if (get_attr_length (insn) == 4)
1570     {
1571       sprintf (asmtext, \"b%sz %%2,%%l0\", invbr);
1572       output_asm_insn (asmtext, operands);
1573     }
1574   else
1575     {
1576       sprintf (asmtext, \"b%sz %%2,1f\;bra %%l0\;1:\", br);
1577       output_asm_insn (asmtext, operands);
1578     }
1579   return \"\";
1581   [(set_attr "type" "branch")
1582   ; We use 25000/50000 instead of 32768/65536 to account for slot filling
1583   ; which is complex to track and inaccurate length specs.
1584    (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
1585                                                  (const_int 25000))
1586                                            (const_int 50000))
1587                                       (const_int 4)
1588                                       (const_int 8)))])
1590 ;; S<cc> operations to set a register to 1/0 based on a comparison
1592 (define_expand "seq"
1593   [(match_operand:SI 0 "register_operand" "")]
1594   ""
1595   "
1597   rtx op0 = operands[0];
1598   rtx op1 = m32r_compare_op0;
1599   rtx op2 = m32r_compare_op1;
1600   enum machine_mode mode = GET_MODE (op0);
1602   if (mode != SImode)
1603     FAIL;
1605   if (! register_operand (op1, mode))
1606     op1 = force_reg (mode, op1);
1608   if (TARGET_M32RX || TARGET_M32R2)
1609     {
1610       if (! reg_or_zero_operand (op2, mode))
1611         op2 = force_reg (mode, op2);
1613       emit_insn (gen_seq_insn_m32rx (op0, op1, op2));
1614       DONE;
1615     }
1616   if (GET_CODE (op2) == CONST_INT && INTVAL (op2) == 0)
1617     {
1618       emit_insn (gen_seq_zero_insn (op0, op1));
1619       DONE;
1620     }
1622   if (! reg_or_eq_int16_operand (op2, mode))
1623     op2 = force_reg (mode, op2);
1625   emit_insn (gen_seq_insn (op0, op1, op2));
1626   DONE;
1629 (define_insn "seq_insn_m32rx"
1630   [(set (match_operand:SI 0 "register_operand" "=r")
1631         (eq:SI (match_operand:SI 1 "register_operand" "%r")
1632                (match_operand:SI 2 "reg_or_zero_operand" "rP")))
1633    (clobber (reg:CC 17))]
1634   "TARGET_M32RX || TARGET_M32R2"
1635   "#"
1636   [(set_attr "type" "multi")
1637    (set_attr "length" "6")])
1639 (define_split
1640   [(set (match_operand:SI 0 "register_operand" "")
1641         (eq:SI (match_operand:SI 1 "register_operand" "")
1642                (match_operand:SI 2 "reg_or_zero_operand" "")))
1643    (clobber (reg:CC 17))]
1644   "TARGET_M32RX || TARGET_M32R2"
1645   [(set (reg:CC 17)
1646         (eq:CC (match_dup 1)
1647                (match_dup 2)))
1648    (set (match_dup 0)
1649         (ne:SI (reg:CC 17) (const_int 0)))]
1650   "")
1652 (define_insn "seq_zero_insn"
1653   [(set (match_operand:SI 0 "register_operand" "=r")
1654         (eq:SI (match_operand:SI 1 "register_operand" "r")
1655                (const_int 0)))
1656    (clobber (reg:CC 17))]
1657   "TARGET_M32R"
1658   "#"
1659   [(set_attr "type" "multi")
1660    (set_attr "length" "6")])
1662 (define_split
1663   [(set (match_operand:SI 0 "register_operand" "")
1664         (eq:SI (match_operand:SI 1 "register_operand" "")
1665                (const_int 0)))
1666    (clobber (reg:CC 17))]
1667   "TARGET_M32R"
1668   [(match_dup 3)]
1669   "
1671   rtx op0 = operands[0];
1672   rtx op1 = operands[1];
1674   start_sequence ();
1675   emit_insn (gen_cmp_ltusi_insn (op1, const1_rtx));
1676   emit_insn (gen_movcc_insn (op0));
1677   operands[3] = get_insns ();
1678   end_sequence ();
1681 (define_insn "seq_insn"
1682   [(set (match_operand:SI 0 "register_operand" "=r,r,??r,r")
1683         (eq:SI (match_operand:SI 1 "register_operand" "r,r,r,r")
1684                (match_operand:SI 2 "reg_or_eq_int16_operand" "r,r,r,PK")))
1685    (clobber (reg:CC 17))
1686    (clobber (match_scratch:SI 3 "=1,2,&r,r"))]
1687   "TARGET_M32R"
1688   "#"
1689   [(set_attr "type" "multi")
1690    (set_attr "length" "8,8,10,10")])
1692 (define_split
1693   [(set (match_operand:SI 0 "register_operand" "")
1694         (eq:SI (match_operand:SI 1 "register_operand" "")
1695                (match_operand:SI 2 "reg_or_eq_int16_operand" "")))
1696    (clobber (reg:CC 17))
1697    (clobber (match_scratch:SI 3 ""))]
1698   "TARGET_M32R && reload_completed"
1699   [(match_dup 4)]
1700   "
1702   rtx op0 = operands[0];
1703   rtx op1 = operands[1];
1704   rtx op2 = operands[2];
1705   rtx op3 = operands[3];
1706   HOST_WIDE_INT value;
1708   if (GET_CODE (op2) == REG && GET_CODE (op3) == REG
1709       && REGNO (op2) == REGNO (op3))
1710     {
1711       op1 = operands[2];
1712       op2 = operands[1];
1713     }
1715   start_sequence ();
1716   if (GET_CODE (op1) == REG && GET_CODE (op3) == REG
1717       && REGNO (op1) != REGNO (op3))
1718     {
1719       emit_move_insn (op3, op1);
1720       op1 = op3;
1721     }
1723   if (GET_CODE (op2) == CONST_INT && (value = INTVAL (op2)) != 0
1724       && CMP_INT16_P (value))
1725     emit_insn (gen_addsi3 (op3, op1, GEN_INT (-value)));
1726   else
1727     emit_insn (gen_xorsi3 (op3, op1, op2));
1729   emit_insn (gen_cmp_ltusi_insn (op3, const1_rtx));
1730   emit_insn (gen_movcc_insn (op0));
1731   operands[4] = get_insns ();
1732   end_sequence ();
1735 (define_expand "sne"
1736   [(match_operand:SI 0 "register_operand" "")]
1737   ""
1738   "
1740   rtx op0 = operands[0];
1741   rtx op1 = m32r_compare_op0;
1742   rtx op2 = m32r_compare_op1;
1743   enum machine_mode mode = GET_MODE (op0);
1745   if (mode != SImode)
1746     FAIL;
1748   if (GET_CODE (op2) != CONST_INT
1749       || (INTVAL (op2) != 0 && UINT16_P (INTVAL (op2))))
1750     {
1751       rtx reg;
1753       if (reload_completed || reload_in_progress)
1754         FAIL;
1756       reg = gen_reg_rtx (SImode);
1757       emit_insn (gen_xorsi3 (reg, op1, op2));
1758       op1 = reg;
1760       if (! register_operand (op1, mode))
1761         op1 = force_reg (mode, op1);
1763       emit_insn (gen_sne_zero_insn (op0, op1));
1764       DONE;
1765     }
1766   else
1767     FAIL;
1770 (define_insn "sne_zero_insn"
1771   [(set (match_operand:SI 0 "register_operand" "=r")
1772         (ne:SI (match_operand:SI 1 "register_operand" "r")
1773                (const_int 0)))
1774    (clobber (reg:CC 17))
1775    (clobber (match_scratch:SI 2 "=&r"))]
1776   ""
1777   "#"
1778   [(set_attr "type" "multi")
1779    (set_attr "length" "6")])
1781 (define_split
1782   [(set (match_operand:SI 0 "register_operand" "")
1783         (ne:SI (match_operand:SI 1 "register_operand" "")
1784                (const_int 0)))
1785    (clobber (reg:CC 17))
1786    (clobber (match_scratch:SI 2 ""))]
1787   "reload_completed"
1788   [(set (match_dup 2)
1789         (const_int 0))
1790    (set (reg:CC 17)
1791         (ltu:CC (match_dup 2)
1792                 (match_dup 1)))
1793    (set (match_dup 0)
1794         (ne:SI (reg:CC 17) (const_int 0)))]
1795   "")
1796         
1797 (define_expand "slt"
1798   [(match_operand:SI 0 "register_operand" "")]
1799   ""
1800   "
1802   rtx op0 = operands[0];
1803   rtx op1 = m32r_compare_op0;
1804   rtx op2 = m32r_compare_op1;
1805   enum machine_mode mode = GET_MODE (op0);
1807   if (mode != SImode)
1808     FAIL;
1810   if (! register_operand (op1, mode))
1811     op1 = force_reg (mode, op1);
1813   if (! reg_or_int16_operand (op2, mode))
1814     op2 = force_reg (mode, op2);
1816   emit_insn (gen_slt_insn (op0, op1, op2));
1817   DONE;
1820 (define_insn "slt_insn"
1821   [(set (match_operand:SI 0 "register_operand" "=r,r")
1822         (lt:SI (match_operand:SI 1 "register_operand" "r,r")
1823                (match_operand:SI 2 "reg_or_int16_operand" "r,J")))
1824    (clobber (reg:CC 17))]
1825   ""
1826   "#"
1827   [(set_attr "type" "multi")
1828    (set_attr "length" "4,6")])
1830 (define_split
1831   [(set (match_operand:SI 0 "register_operand" "")
1832         (lt:SI (match_operand:SI 1 "register_operand" "")
1833                (match_operand:SI 2 "reg_or_int16_operand" "")))
1834    (clobber (reg:CC 17))]
1835   ""
1836   [(set (reg:CC 17)
1837         (lt:CC (match_dup 1)
1838                (match_dup 2)))
1839    (set (match_dup 0)
1840         (ne:SI (reg:CC 17) (const_int 0)))]
1841   "")
1843 (define_expand "sle"
1844   [(match_operand:SI 0 "register_operand" "")]
1845   ""
1846   "
1848   rtx op0 = operands[0];
1849   rtx op1 = m32r_compare_op0;
1850   rtx op2 = m32r_compare_op1;
1851   enum machine_mode mode = GET_MODE (op0);
1853   if (mode != SImode)
1854     FAIL;
1856   if (! register_operand (op1, mode))
1857     op1 = force_reg (mode, op1);
1859   if (GET_CODE (op2) == CONST_INT)
1860     {
1861       HOST_WIDE_INT value = INTVAL (op2);
1862       if (value >= 2147483647)
1863         {
1864           emit_move_insn (op0, const1_rtx);
1865           DONE;
1866         }
1868       op2 = GEN_INT (value+1);
1869       if (value < -32768 || value >= 32767)
1870         op2 = force_reg (mode, op2);
1872       emit_insn (gen_slt_insn (op0, op1, op2));
1873       DONE;
1874     }
1876   if (! register_operand (op2, mode))
1877     op2 = force_reg (mode, op2);
1879   emit_insn (gen_sle_insn (op0, op1, op2));
1880   DONE;
1883 (define_insn "sle_insn"
1884   [(set (match_operand:SI 0 "register_operand" "=r")
1885         (le:SI (match_operand:SI 1 "register_operand" "r")
1886                (match_operand:SI 2 "register_operand" "r")))
1887    (clobber (reg:CC 17))]
1888   ""
1889   "#"
1890   [(set_attr "type" "multi")
1891    (set_attr "length" "8")])
1893 (define_split
1894   [(set (match_operand:SI 0 "register_operand" "")
1895         (le:SI (match_operand:SI 1 "register_operand" "")
1896                (match_operand:SI 2 "register_operand" "")))
1897    (clobber (reg:CC 17))]
1898   "!optimize_size"
1899   [(set (reg:CC 17)
1900         (lt:CC (match_dup 2)
1901                (match_dup 1)))
1902    (set (match_dup 0)
1903         (ne:SI (reg:CC 17) (const_int 0)))
1904    (set (match_dup 0)
1905         (xor:SI (match_dup 0)
1906                 (const_int 1)))]
1907   "")
1909 ;; If optimizing for space, use -(reg - 1) to invert the comparison rather than
1910 ;; xor reg,reg,1 which might eliminate a NOP being inserted.
1911 (define_split
1912   [(set (match_operand:SI 0 "register_operand" "")
1913         (le:SI (match_operand:SI 1 "register_operand" "")
1914                (match_operand:SI 2 "register_operand" "")))
1915    (clobber (reg:CC 17))]
1916   "optimize_size"
1917   [(set (reg:CC 17)
1918         (lt:CC (match_dup 2)
1919                (match_dup 1)))
1920    (set (match_dup 0)
1921         (ne:SI (reg:CC 17) (const_int 0)))
1922    (set (match_dup 0)
1923         (plus:SI (match_dup 0)
1924                  (const_int -1)))
1925    (set (match_dup 0)
1926         (neg:SI (match_dup 0)))]
1927   "")
1929 (define_expand "sgt"
1930   [(match_operand:SI 0 "register_operand" "")]
1931   ""
1932   "
1934   rtx op0 = operands[0];
1935   rtx op1 = m32r_compare_op0;
1936   rtx op2 = m32r_compare_op1;
1937   enum machine_mode mode = GET_MODE (op0);
1939   if (mode != SImode)
1940     FAIL;
1942   if (! register_operand (op1, mode))
1943     op1 = force_reg (mode, op1);
1945   if (! register_operand (op2, mode))
1946     op2 = force_reg (mode, op2);
1948   emit_insn (gen_slt_insn (op0, op2, op1));
1949   DONE;
1952 (define_expand "sge"
1953   [(match_operand:SI 0 "register_operand" "")]
1954   ""
1955   "
1957   rtx op0 = operands[0];
1958   rtx op1 = m32r_compare_op0;
1959   rtx op2 = m32r_compare_op1;
1960   enum machine_mode mode = GET_MODE (op0);
1962   if (mode != SImode)
1963     FAIL;
1965   if (! register_operand (op1, mode))
1966     op1 = force_reg (mode, op1);
1968   if (! reg_or_int16_operand (op2, mode))
1969     op2 = force_reg (mode, op2);
1971   emit_insn (gen_sge_insn (op0, op1, op2));
1972   DONE;
1975 (define_insn "sge_insn"
1976   [(set (match_operand:SI 0 "register_operand" "=r,r")
1977         (ge:SI (match_operand:SI 1 "register_operand" "r,r")
1978                (match_operand:SI 2 "reg_or_int16_operand" "r,J")))
1979    (clobber (reg:CC 17))]
1980   ""
1981   "#"
1982   [(set_attr "type" "multi")
1983    (set_attr "length" "8,10")])
1985 (define_split
1986   [(set (match_operand:SI 0 "register_operand" "")
1987         (ge:SI (match_operand:SI 1 "register_operand" "")
1988                (match_operand:SI 2 "reg_or_int16_operand" "")))
1989    (clobber (reg:CC 17))]
1990   "!optimize_size"
1991   [(set (reg:CC 17)
1992         (lt:CC (match_dup 1)
1993                (match_dup 2)))
1994    (set (match_dup 0)
1995         (ne:SI (reg:CC 17) (const_int 0)))
1996    (set (match_dup 0)
1997         (xor:SI (match_dup 0)
1998                 (const_int 1)))]
1999   "")
2001 ;; If optimizing for space, use -(reg - 1) to invert the comparison rather than
2002 ;; xor reg,reg,1 which might eliminate a NOP being inserted.
2003 (define_split
2004   [(set (match_operand:SI 0 "register_operand" "")
2005         (ge:SI (match_operand:SI 1 "register_operand" "")
2006                (match_operand:SI 2 "reg_or_int16_operand" "")))
2007    (clobber (reg:CC 17))]
2008   "optimize_size"
2009   [(set (reg:CC 17)
2010         (lt:CC (match_dup 1)
2011                (match_dup 2)))
2012    (set (match_dup 0)
2013         (ne:SI (reg:CC 17) (const_int 0)))
2014    (set (match_dup 0)
2015         (plus:SI (match_dup 0)
2016                  (const_int -1)))
2017    (set (match_dup 0)
2018         (neg:SI (match_dup 0)))]
2019   "")
2021 (define_expand "sltu"
2022   [(match_operand:SI 0 "register_operand" "")]
2023   ""
2024   "
2026   rtx op0 = operands[0];
2027   rtx op1 = m32r_compare_op0;
2028   rtx op2 = m32r_compare_op1;
2029   enum machine_mode mode = GET_MODE (op0);
2031   if (mode != SImode)
2032     FAIL;
2034   if (! register_operand (op1, mode))
2035     op1 = force_reg (mode, op1);
2037   if (! reg_or_int16_operand (op2, mode))
2038     op2 = force_reg (mode, op2);
2040   emit_insn (gen_sltu_insn (op0, op1, op2));
2041   DONE;
2044 (define_insn "sltu_insn"
2045   [(set (match_operand:SI 0 "register_operand" "=r,r")
2046         (ltu:SI (match_operand:SI 1 "register_operand" "r,r")
2047                 (match_operand:SI 2 "reg_or_int16_operand" "r,J")))
2048    (clobber (reg:CC 17))]
2049   ""
2050   "#"
2051   [(set_attr "type" "multi")
2052    (set_attr "length" "6,8")])
2054 (define_split
2055   [(set (match_operand:SI 0 "register_operand" "")
2056         (ltu:SI (match_operand:SI 1 "register_operand" "")
2057                 (match_operand:SI 2 "reg_or_int16_operand" "")))
2058    (clobber (reg:CC 17))]
2059   ""
2060   [(set (reg:CC 17)
2061         (ltu:CC (match_dup 1)
2062                 (match_dup 2)))
2063    (set (match_dup 0)
2064         (ne:SI (reg:CC 17) (const_int 0)))]
2065   "")
2067 (define_expand "sleu"
2068   [(match_operand:SI 0 "register_operand" "")]
2069   ""
2070   "
2072   rtx op0 = operands[0];
2073   rtx op1 = m32r_compare_op0;
2074   rtx op2 = m32r_compare_op1;
2075   enum machine_mode mode = GET_MODE (op0);
2077   if (mode != SImode)
2078     FAIL;
2080   if (GET_CODE (op2) == CONST_INT)
2081     {
2082       HOST_WIDE_INT value = INTVAL (op2);
2083       if (value >= 2147483647)
2084         {
2085           emit_move_insn (op0, const1_rtx);
2086           DONE;
2087         }
2089       op2 = GEN_INT (value+1);
2090       if (value < 0 || value >= 32767)
2091         op2 = force_reg (mode, op2);
2093       emit_insn (gen_sltu_insn (op0, op1, op2));
2094       DONE;
2095     }
2097   if (! register_operand (op2, mode))
2098     op2 = force_reg (mode, op2);
2100   emit_insn (gen_sleu_insn (op0, op1, op2));
2101   DONE;
2104 (define_insn "sleu_insn"
2105   [(set (match_operand:SI 0 "register_operand" "=r")
2106         (leu:SI (match_operand:SI 1 "register_operand" "r")
2107                 (match_operand:SI 2 "register_operand" "r")))
2108    (clobber (reg:CC 17))]
2109   ""
2110   "#"
2111   [(set_attr "type" "multi")
2112    (set_attr "length" "8")])
2114 (define_split
2115   [(set (match_operand:SI 0 "register_operand" "")
2116         (leu:SI (match_operand:SI 1 "register_operand" "")
2117                 (match_operand:SI 2 "register_operand" "")))
2118    (clobber (reg:CC 17))]
2119   "!optimize_size"
2120   [(set (reg:CC 17)
2121         (ltu:CC (match_dup 2)
2122                 (match_dup 1)))
2123    (set (match_dup 0)
2124         (ne:SI (reg:CC 17) (const_int 0)))
2125    (set (match_dup 0)
2126         (xor:SI (match_dup 0)
2127                 (const_int 1)))]
2128   "")
2130 ;; If optimizing for space, use -(reg - 1) to invert the comparison rather than
2131 ;; xor reg,reg,1 which might eliminate a NOP being inserted.
2132 (define_split
2133   [(set (match_operand:SI 0 "register_operand" "")
2134         (leu:SI (match_operand:SI 1 "register_operand" "")
2135                 (match_operand:SI 2 "register_operand" "")))
2136    (clobber (reg:CC 17))]
2137   "optimize_size"
2138   [(set (reg:CC 17)
2139         (ltu:CC (match_dup 2)
2140                 (match_dup 1)))
2141    (set (match_dup 0)
2142         (ne:SI (reg:CC 17) (const_int 0)))
2143    (set (match_dup 0)
2144         (plus:SI (match_dup 0)
2145                  (const_int -1)))
2146    (set (match_dup 0)
2147         (neg:SI (match_dup 0)))]
2148   "")
2150 (define_expand "sgtu"
2151   [(match_operand:SI 0 "register_operand" "")]
2152   ""
2153   "
2155   rtx op0 = operands[0];
2156   rtx op1 = m32r_compare_op0;
2157   rtx op2 = m32r_compare_op1;
2158   enum machine_mode mode = GET_MODE (op0);
2160   if (mode != SImode)
2161     FAIL;
2163   if (! register_operand (op1, mode))
2164     op1 = force_reg (mode, op1);
2166   if (! register_operand (op2, mode))
2167     op2 = force_reg (mode, op2);
2169   emit_insn (gen_sltu_insn (op0, op2, op1));
2170   DONE;
2173 (define_expand "sgeu"
2174   [(match_operand:SI 0 "register_operand" "")]
2175   ""
2176   "
2178   rtx op0 = operands[0];
2179   rtx op1 = m32r_compare_op0;
2180   rtx op2 = m32r_compare_op1;
2181   enum machine_mode mode = GET_MODE (op0);
2183   if (mode != SImode)
2184     FAIL;
2186   if (! register_operand (op1, mode))
2187     op1 = force_reg (mode, op1);
2189   if (! reg_or_int16_operand (op2, mode))
2190     op2 = force_reg (mode, op2);
2192   emit_insn (gen_sgeu_insn (op0, op1, op2));
2193   DONE;
2196 (define_insn "sgeu_insn"
2197   [(set (match_operand:SI 0 "register_operand" "=r,r")
2198         (geu:SI (match_operand:SI 1 "register_operand" "r,r")
2199                 (match_operand:SI 2 "reg_or_int16_operand" "r,J")))
2200    (clobber (reg:CC 17))]
2201   ""
2202   "#"
2203   [(set_attr "type" "multi")
2204    (set_attr "length" "8,10")])
2206 (define_split
2207   [(set (match_operand:SI 0 "register_operand" "")
2208         (geu:SI (match_operand:SI 1 "register_operand" "")
2209                 (match_operand:SI 2 "reg_or_int16_operand" "")))
2210    (clobber (reg:CC 17))]
2211   "!optimize_size"
2212   [(set (reg:CC 17)
2213         (ltu:CC (match_dup 1)
2214                 (match_dup 2)))
2215    (set (match_dup 0)
2216         (ne:SI (reg:CC 17) (const_int 0)))
2217    (set (match_dup 0)
2218         (xor:SI (match_dup 0)
2219                 (const_int 1)))]
2220   "")
2222 ;; If optimizing for space, use -(reg - 1) to invert the comparison rather than
2223 ;; xor reg,reg,1 which might eliminate a NOP being inserted.
2224 (define_split
2225   [(set (match_operand:SI 0 "register_operand" "")
2226         (geu:SI (match_operand:SI 1 "register_operand" "")
2227                 (match_operand:SI 2 "reg_or_int16_operand" "")))
2228    (clobber (reg:CC 17))]
2229   "optimize_size"
2230   [(set (reg:CC 17)
2231         (ltu:CC (match_dup 1)
2232                 (match_dup 2)))
2233    (set (match_dup 0)
2234         (ne:SI (reg:CC 17) (const_int 0)))
2235    (set (match_dup 0)
2236         (plus:SI (match_dup 0)
2237                  (const_int -1)))
2238    (set (match_dup 0)
2239         (neg:SI (match_dup 0)))]
2240   "")
2242 (define_insn "movcc_insn"
2243   [(set (match_operand:SI 0 "register_operand" "=r")
2244         (ne:SI (reg:CC 17) (const_int 0)))]
2245   ""
2246   "mvfc %0, cbr"
2247   [(set_attr "type" "misc")
2248    (set_attr "length" "2")])
2251 ;; Unconditional and other jump instructions.
2253 (define_insn "jump"
2254   [(set (pc) (label_ref (match_operand 0 "" "")))]
2255   ""
2256   "bra %l0"
2257   [(set_attr "type" "uncond_branch")
2258    (set (attr "length") (if_then_else (ltu (plus (minus (match_dup 0) (pc))
2259                                                  (const_int 400))
2260                                            (const_int 800))
2261                                       (const_int 2)
2262                                       (const_int 4)))])
2264 (define_insn "indirect_jump"
2265   [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
2266   ""
2267   "jmp %a0"
2268   [(set_attr "type" "uncond_branch")
2269    (set_attr "length" "2")])
2271 (define_insn "return"
2272   [(return)]
2273   "direct_return ()"
2274   "jmp lr"
2275   [(set_attr "type" "uncond_branch")
2276    (set_attr "length" "2")])
2278 (define_expand "tablejump"
2279   [(parallel [(set (pc) (match_operand 0 "register_operand" "r"))
2280               (use (label_ref (match_operand 1 "" "")))])]
2281   ""
2282   "
2284   /* In pic mode, our address differences are against the base of the
2285      table.  Add that base value back in; CSE ought to be able to combine
2286      the two address loads.  */
2287   if (flag_pic)
2288     {
2289       rtx tmp, tmp2;
2291       tmp = gen_rtx_LABEL_REF (Pmode, operands[1]);
2292       tmp2 = operands[0];
2293       tmp = gen_rtx_PLUS (Pmode, tmp2, tmp);
2294       operands[0] = memory_address (Pmode, tmp);
2295     }
2298 (define_insn "*tablejump_insn"
2299   [(set (pc) (match_operand:SI 0 "address_operand" "p"))
2300    (use (label_ref (match_operand 1 "" "")))]
2301   ""
2302   "jmp %a0"
2303   [(set_attr "type" "uncond_branch")
2304    (set_attr "length" "2")])
2306 (define_expand "call"
2307   ;; operands[1] is stack_size_rtx
2308   ;; operands[2] is next_arg_register
2309   [(parallel [(call (match_operand:SI 0 "call_operand" "")
2310                     (match_operand 1 "" ""))
2311              (clobber (reg:SI 14))])]
2312   ""
2313   "
2315   if (flag_pic)
2316     current_function_uses_pic_offset_table = 1;
2319 (define_insn "*call_via_reg"
2320   [(call (mem:SI (match_operand:SI 0 "register_operand" "r"))
2321          (match_operand 1 "" ""))
2322    (clobber (reg:SI 14))]
2323   ""
2324   "jl %0"
2325   [(set_attr "type" "call")
2326    (set_attr "length" "2")])
2328 (define_insn "*call_via_label"
2329   [(call (mem:SI (match_operand:SI 0 "call_address_operand" ""))
2330          (match_operand 1 "" ""))
2331    (clobber (reg:SI 14))]
2332   ""
2333   "*
2335   int call26_p = call26_operand (operands[0], FUNCTION_MODE);
2337   if (! call26_p)
2338     {
2339       /* We may not be able to reach with a `bl' insn so punt and leave it to
2340          the linker.
2341          We do this here, rather than doing a force_reg in the define_expand
2342          so these insns won't be separated, say by scheduling, thus simplifying
2343          the linker.  */
2344       return \"seth r14,%T0\;add3 r14,r14,%B0\;jl r14\";
2345     }
2346   else
2347     return \"bl %0\";
2349   [(set_attr "type" "call")
2350    (set (attr "length")
2351         (if_then_else (eq (symbol_ref "call26_operand (operands[0], FUNCTION_MODE)")
2352                           (const_int 0))
2353                       (const_int 12) ; 10 + 2 for nop filler
2354                       ; The return address must be on a 4 byte boundary so
2355                       ; there's no point in using a value of 2 here.  A 2 byte
2356                       ; insn may go in the left slot but we currently can't
2357                       ; use such knowledge.
2358                       (const_int 4)))])
2360 (define_expand "call_value"
2361   ;; operand 2 is stack_size_rtx
2362   ;; operand 3 is next_arg_register
2363   [(parallel [(set (match_operand 0 "register_operand" "=r")
2364                    (call (match_operand:SI 1 "call_operand" "")
2365                          (match_operand 2 "" "")))
2366              (clobber (reg:SI 14))])]
2367   ""
2368   "                                                                             
2370   if (flag_pic)
2371     current_function_uses_pic_offset_table = 1;
2374 (define_insn "*call_value_via_reg"
2375   [(set (match_operand 0 "register_operand" "=r")
2376         (call (mem:SI (match_operand:SI 1 "register_operand" "r"))
2377               (match_operand 2 "" "")))
2378    (clobber (reg:SI 14))]
2379   ""
2380   "jl %1"
2381   [(set_attr "type" "call")
2382    (set_attr "length" "2")])
2384 (define_insn "*call_value_via_label"
2385   [(set (match_operand 0 "register_operand" "=r")
2386         (call (mem:SI (match_operand:SI 1 "call_address_operand" ""))
2387               (match_operand 2 "" "")))
2388    (clobber (reg:SI 14))]
2389   ""
2390   "*
2392   int call26_p = call26_operand (operands[1], FUNCTION_MODE);
2394   if (flag_pic)
2395     current_function_uses_pic_offset_table = 1;
2397   if (! call26_p)
2398     {
2399       /* We may not be able to reach with a `bl' insn so punt and leave it to
2400          the linker.
2401          We do this here, rather than doing a force_reg in the define_expand
2402          so these insns won't be separated, say by scheduling, thus simplifying
2403          the linker.  */
2404       return \"seth r14,%T1\;add3 r14,r14,%B1\;jl r14\";
2405     }
2406   else
2407     return \"bl %1\";
2409   [(set_attr "type" "call")
2410    (set (attr "length")
2411         (if_then_else (eq (symbol_ref "call26_operand (operands[1], FUNCTION_MODE)")
2412                           (const_int 0))
2413                       (const_int 12) ; 10 + 2 for nop filler
2414                       ; The return address must be on a 4 byte boundary so
2415                       ; there's no point in using a value of 2 here.  A 2 byte
2416                       ; insn may go in the left slot but we currently can't
2417                       ; use such knowledge.
2418                       (const_int 4)))])
2420 (define_insn "nop"
2421   [(const_int 0)]
2422   ""
2423   "nop"
2424   [(set_attr "type" "int2")
2425    (set_attr "length" "2")])
2427 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
2428 ;; all of memory.  This blocks insns from being moved across this point.
2430 (define_insn "blockage"
2431   [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
2432   ""
2433   "")
2435 ;; Special pattern to flush the icache.
2437 (define_insn "flush_icache"
2438   [(unspec_volatile [(match_operand 0 "memory_operand" "m")]
2439                     UNSPECV_FLUSH_ICACHE)
2440    (match_operand 1 "" "")
2441    (clobber (reg:SI 17))]
2442   ""
2443   "* return \"trap %#%1 ; flush-icache\";"
2444   [(set_attr "type" "int4")
2445    (set_attr "length" "4")])
2447 ;; Speed up fabs and provide correct sign handling for -0
2449 (define_insn "absdf2"
2450   [(set (match_operand:DF 0 "register_operand" "=r")
2451         (abs:DF (match_operand:DF 1 "register_operand" "0")))]
2452   ""
2453   "#"
2454   [(set_attr "type" "multi")
2455    (set_attr "length" "4")])
2457 (define_split
2458   [(set (match_operand:DF 0 "register_operand" "")
2459         (abs:DF (match_operand:DF 1 "register_operand" "")))]
2460   "reload_completed"
2461   [(set (match_dup 2)
2462         (ashift:SI (match_dup 2)
2463                    (const_int 1)))
2464    (set (match_dup 2)
2465         (lshiftrt:SI (match_dup 2)
2466                      (const_int 1)))]
2467   "operands[2] = gen_highpart (SImode, operands[0]);")
2469 (define_insn "abssf2"
2470   [(set (match_operand:SF 0 "register_operand" "=r")
2471         (abs:SF (match_operand:SF 1 "register_operand" "0")))]
2472   ""
2473   "#"
2474   [(set_attr "type" "multi")
2475    (set_attr "length" "4")])
2477 (define_split
2478   [(set (match_operand:SF 0 "register_operand" "")
2479         (abs:SF (match_operand:SF 1 "register_operand" "")))]
2480   "reload_completed"
2481   [(set (match_dup 2)
2482         (ashift:SI (match_dup 2)
2483                    (const_int 1)))
2484    (set (match_dup 2)
2485         (lshiftrt:SI (match_dup 2)
2486                      (const_int 1)))]
2487   "operands[2] = gen_highpart (SImode, operands[0]);")
2489 ;; Conditional move instructions
2490 ;; Based on those done for the d10v
2492 (define_expand "movsicc"
2493   [
2494    (set (match_operand:SI 0 "register_operand" "r")
2495         (if_then_else:SI (match_operand 1 "" "")
2496                          (match_operand:SI 2 "conditional_move_operand" "O")
2497                          (match_operand:SI 3 "conditional_move_operand" "O")
2498         )
2499    )
2500   ]
2501   ""
2502   "
2504   if (! zero_and_one (operands [2], operands [3]))
2505     FAIL;
2507   /* Generate the comparison that will set the carry flag.  */
2508   operands[1] = gen_compare (GET_CODE (operands[1]), m32r_compare_op0,
2509                              m32r_compare_op1, TRUE);
2511   /* See other movsicc pattern below for reason why.  */
2512   emit_insn (gen_blockage ());
2515 ;; Generate the conditional instructions based on how the carry flag is examined.
2516 (define_insn "*movsicc_internal"
2517   [(set (match_operand:SI 0 "register_operand" "=r")
2518         (if_then_else:SI (match_operand 1 "carry_compare_operand" "")
2519                          (match_operand:SI 2 "conditional_move_operand" "O")
2520                          (match_operand:SI 3 "conditional_move_operand" "O")
2521         )
2522    )]
2523   "zero_and_one (operands [2], operands[3])"
2524   "* return emit_cond_move (operands, insn);"
2525   [(set_attr "type" "multi")
2526    (set_attr "length" "8")
2527   ]
2531 ;; Block moves, see m32r.c for more details.
2532 ;; Argument 0 is the destination
2533 ;; Argument 1 is the source
2534 ;; Argument 2 is the length
2535 ;; Argument 3 is the alignment
2537 (define_expand "movmemsi"
2538   [(parallel [(set (match_operand:BLK 0 "general_operand" "")
2539                    (match_operand:BLK 1 "general_operand" ""))
2540               (use (match_operand:SI  2 "immediate_operand" ""))
2541               (use (match_operand:SI  3 "immediate_operand" ""))])]
2542   ""
2543   "
2545   if (operands[0])              /* Avoid unused code messages.  */
2546     {
2547      if (m32r_expand_block_move (operands))
2548        DONE;
2549      else
2550        FAIL;
2551     }
2554 ;; Insn generated by block moves
2556 (define_insn "movmemsi_internal"
2557   [(set (mem:BLK (match_operand:SI 0 "register_operand" "r"))   ;; destination
2558         (mem:BLK (match_operand:SI 1 "register_operand" "r")))  ;; source
2559    (use (match_operand:SI 2 "m32r_block_immediate_operand" "J"));; # bytes to move
2560    (set (match_operand:SI 3 "register_operand" "=0")
2561         (plus:SI (match_dup 0)
2562                  (minus (match_dup 2) (const_int 4))))
2563    (set (match_operand:SI 4 "register_operand" "=1")
2564         (plus:SI (match_dup 1)
2565                  (match_dup 2)))
2566    (clobber (match_scratch:SI 5 "=&r"))  ;; temp1
2567    (clobber (match_scratch:SI 6 "=&r"))] ;; temp2
2568   ""
2569   "* m32r_output_block_move (insn, operands); return \"\"; "
2570   [(set_attr "type"     "store8")
2571    (set_attr "length"   "72")]) ;; Maximum
2573 ;; PIC
2575 /* When generating pic, we need to load the symbol offset into a register.
2576    So that the optimizer does not confuse this with a normal symbol load
2577    we use an unspec.  The offset will be loaded from a constant pool entry,
2578    since that is the only type of relocation we can use.  */
2580 (define_insn "pic_load_addr"
2581   [(set (match_operand:SI 0 "register_operand" "=r")
2582         (unspec:SI [(match_operand 1 "" "")] UNSPEC_PIC_LOAD_ADDR))]
2583   "flag_pic"
2584   "ld24 %0,%#%1"
2585   [(set_attr "type" "int4")])
2587 (define_insn "gotoff_load_addr"
2588   [(set (match_operand:SI 0 "register_operand" "=r")
2589         (unspec:SI [(match_operand 1 "" "")] UNSPEC_GOTOFF))]
2590   "flag_pic"
2591   "seth %0, %#shigh(%1@GOTOFF)\;add3 %0, %0, low(%1@GOTOFF)"
2592   [(set_attr "type"     "int4")
2593    (set_attr "length"   "8")])
2595 ;; Load program counter insns.
2597 (define_insn "get_pc"
2598   [(clobber (reg:SI 14))
2599    (set (match_operand 0 "register_operand" "=r")
2600         (unspec [(match_operand 1 "" "")] UNSPEC_GET_PC))
2601    (use (match_operand:SI 2 "immediate_operand" ""))]
2602   "flag_pic"
2603   "*
2605   if (INTVAL(operands[2]))
2606     return \"bl.s .+4\;ld24 %0,%#%1\;add %0,lr\";
2607   else
2608     return \"bl.s .+4\;seth %0,%#shigh(%1)\;add3 %0,%0,%#low(%1+4)\;add %0,lr\";}"
2609   [(set (attr "length") (if_then_else (ne (match_dup 2) (const_int 0))
2610                                       (const_int 8)
2611                                       (const_int 12)))])
2613 (define_expand "builtin_setjmp_receiver"
2614   [(label_ref (match_operand 0 "" ""))]
2615   "flag_pic"
2616   "
2618   m32r_load_pic_register ();
2619   DONE;