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