1 ;; GCC machine description for NEC V850
2 ;; Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
3 ;; Contributed by Jeff Law (law@cygnus.com).
5 ;; This file is part of GNU CC.
7 ;; GNU CC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; GNU CC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU CC; 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 ;; The original PO technology requires these to be ordered by speed,
23 ;; so that assigner will pick the fastest.
25 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
27 ;; The V851 manual states that the instruction address space is 16M;
28 ;; the various branch/call instructions only have a 22bit offset (4M range).
30 ;; One day we'll probably need to handle calls to targets more than 4M
33 ;; The size of instructions in bytes.
35 (define_attr "length" ""
38 (define_attr "long_calls" "yes,no"
39 (const (if_then_else (symbol_ref "TARGET_LONG_CALLS")
41 (const_string "no"))))
43 ;; Types of instructions (for scheduling purposes).
45 (define_attr "type" "load,mult,other"
46 (const_string "other"))
48 ;; Condition code settings.
49 ;; none - insn does not affect cc
50 ;; none_0hit - insn does not affect cc but it does modify operand 0
51 ;; This attribute is used to keep track of when operand 0 changes.
52 ;; See the description of NOTICE_UPDATE_CC for more info.
53 ;; set_znv - sets z,n,v to usable values; c is unknown.
54 ;; set_zn - sets z,n to usable values; v,c is unknown.
55 ;; compare - compare instruction
56 ;; clobber - value of cc is unknown
57 (define_attr "cc" "none,none_0hit,set_zn,set_znv,compare,clobber"
58 (const_string "clobber"))
60 ;; Function units for the V850. As best as I can tell, there's
61 ;; a traditional memory load/use stall as well as a stall if
62 ;; the result of a multiply is used too early.
64 (define_function_unit "memory" 1 0 (eq_attr "type" "load") 2 0)
65 (define_function_unit "mult" 1 0 (eq_attr "type" "mult") 2 0)
68 ;; ----------------------------------------------------------------------
70 ;; ----------------------------------------------------------------------
74 (define_expand "movqi"
75 [(set (match_operand:QI 0 "general_operand" "")
76 (match_operand:QI 1 "general_operand" ""))]
80 /* One of the ops has to be in a register or 0 */
81 if (!register_operand (operand0, QImode)
82 && !reg_or_0_operand (operand1, QImode))
83 operands[1] = copy_to_mode_reg (QImode, operand1);
86 (define_insn "*movqi_internal"
87 [(set (match_operand:QI 0 "general_operand" "=r,r,r,Q,r,m,m")
88 (match_operand:QI 1 "general_operand" "Jr,n,Q,Ir,m,r,I"))]
89 "register_operand (operands[0], QImode)
90 || reg_or_0_operand (operands[1], QImode)"
91 "* return output_move_single (operands);"
92 [(set_attr "length" "2,4,2,2,4,4,4")
93 (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")
94 (set_attr "type" "other,other,load,other,load,other,other")])
98 (define_expand "movhi"
99 [(set (match_operand:HI 0 "general_operand" "")
100 (match_operand:HI 1 "general_operand" ""))]
104 /* One of the ops has to be in a register or 0 */
105 if (!register_operand (operand0, HImode)
106 && !reg_or_0_operand (operand1, HImode))
107 operands[1] = copy_to_mode_reg (HImode, operand1);
110 (define_insn "*movhi_internal"
111 [(set (match_operand:HI 0 "general_operand" "=r,r,r,Q,r,m,m")
112 (match_operand:HI 1 "general_operand" "Jr,n,Q,Ir,m,r,I"))]
113 "register_operand (operands[0], HImode)
114 || reg_or_0_operand (operands[1], HImode)"
115 "* return output_move_single (operands);"
116 [(set_attr "length" "2,4,2,2,4,4,4")
117 (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")
118 (set_attr "type" "other,other,load,other,load,other,other")])
122 (define_insn "*movsi_high"
123 [(set (match_operand:SI 0 "register_operand" "=r")
124 (high:SI (match_operand 1 "" "")))]
127 [(set_attr "length" "4")
128 (set_attr "cc" "none_0hit")
129 (set_attr "type" "other")])
131 (define_insn "*movsi_lo"
132 [(set (match_operand:SI 0 "register_operand" "=r")
133 (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
134 (match_operand:SI 2 "immediate_operand" "i")))]
137 [(set_attr "length" "4")
138 (set_attr "cc" "none_0hit")
139 (set_attr "type" "other")])
141 (define_expand "movsi"
142 [(set (match_operand:SI 0 "general_operand" "")
143 (match_operand:SI 1 "general_operand" ""))]
147 /* One of the ops has to be in a register or 0 */
148 if (!register_operand (operand0, SImode)
149 && !reg_or_0_operand (operand1, SImode))
150 operands[1] = copy_to_mode_reg (SImode, operand1);
152 /* Some constants, as well as symbolic operands
153 must be done with HIGH & LO_SUM patterns. */
154 if (CONSTANT_P (operands[1])
155 && GET_CODE (operands[1]) != HIGH
156 && !special_symbolref_operand (operands[1], VOIDmode)
157 && !(GET_CODE (operands[1]) == CONST_INT
158 && (CONST_OK_FOR_J (INTVAL (operands[1]))
159 || CONST_OK_FOR_K (INTVAL (operands[1]))
160 || CONST_OK_FOR_L (INTVAL (operands[1])))))
165 if (reload_in_progress || reload_completed)
168 temp = gen_reg_rtx (SImode);
170 emit_insn (gen_rtx_SET (SImode, temp,
171 gen_rtx_HIGH (SImode, operand1)));
172 emit_insn (gen_rtx_SET (SImode, operand0,
173 gen_rtx_LO_SUM (SImode, temp, operand1)));
178 (define_insn "*movsi_internal"
179 [(set (match_operand:SI 0 "general_operand" "=r,r,r,r,Q,r,r,m,m")
180 (match_operand:SI 1 "movsi_source_operand" "Jr,K,L,Q,Ir,m,R,r,I"))]
181 "register_operand (operands[0], SImode)
182 || reg_or_0_operand (operands[1], SImode)"
183 "* return output_move_single (operands);"
184 [(set_attr "length" "2,4,4,2,2,4,4,4,4")
185 (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")
186 (set_attr "type" "other,other,other,load,other,load,other,other,other")])
190 (define_expand "movdi"
191 [(set (match_operand:DI 0 "general_operand" "")
192 (match_operand:DI 1 "general_operand" ""))]
196 /* One of the ops has to be in a register or 0 */
197 if (!register_operand (operand0, DImode)
198 && !reg_or_0_operand (operand1, DImode))
199 operands[1] = copy_to_mode_reg (DImode, operand1);
202 (define_insn "*movdi_internal"
203 [(set (match_operand:DI 0 "general_operand" "=r,r,r,r,r,m,m,r")
204 (match_operand:DI 1 "general_operand" "Jr,K,L,i,m,r,IG,iF"))]
205 "register_operand (operands[0], DImode)
206 || reg_or_0_operand (operands[1], DImode)"
207 "* return output_move_double (operands);"
208 [(set_attr "length" "4,8,8,16,8,8,8,16")
209 (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")
210 (set_attr "type" "other,other,other,other,load,other,other,other")])
212 (define_expand "movsf"
213 [(set (match_operand:SF 0 "general_operand" "")
214 (match_operand:SF 1 "general_operand" ""))]
218 /* One of the ops has to be in a register or 0 */
219 if (!register_operand (operand0, SFmode)
220 && !reg_or_0_operand (operand1, SFmode))
221 operands[1] = copy_to_mode_reg (SFmode, operand1);
224 (define_insn "*movsf_internal"
225 [(set (match_operand:SF 0 "general_operand" "=r,r,r,r,r,Q,r,m,m,r")
226 (match_operand:SF 1 "general_operand" "Jr,K,L,n,Q,Ir,m,r,IG,iF"))]
227 "register_operand (operands[0], SFmode)
228 || reg_or_0_operand (operands[1], SFmode)"
229 "* return output_move_single (operands);"
230 [(set_attr "length" "2,4,4,8,2,2,4,4,4,8")
231 (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")
232 (set_attr "type" "other,other,other,other,load,other,load,other,other,other")])
234 (define_expand "movdf"
235 [(set (match_operand:DF 0 "general_operand" "")
236 (match_operand:DF 1 "general_operand" ""))]
240 /* One of the ops has to be in a register or 0 */
241 if (!register_operand (operand0, DFmode)
242 && !reg_or_0_operand (operand1, DFmode))
243 operands[1] = copy_to_mode_reg (DFmode, operand1);
246 (define_insn "*movdf_internal"
247 [(set (match_operand:DF 0 "general_operand" "=r,r,r,r,r,m,m,r")
248 (match_operand:DF 1 "general_operand" "Jr,K,L,i,m,r,IG,iF"))]
249 "register_operand (operands[0], DFmode)
250 || reg_or_0_operand (operands[1], DFmode)"
251 "* return output_move_double (operands);"
252 [(set_attr "length" "4,8,8,16,8,8,8,16")
253 (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")
254 (set_attr "type" "other,other,other,other,load,other,other,other")])
257 ;; ----------------------------------------------------------------------
259 ;; ----------------------------------------------------------------------
261 (define_insn "*v850_tst1"
262 [(set (cc0) (zero_extract:SI (match_operand:QI 0 "memory_operand" "m")
264 (match_operand:QI 1 "const_int_operand" "n")))]
267 [(set_attr "length" "4")
268 (set_attr "cc" "clobber")])
270 ;; This replaces ld.b;sar;andi with tst1;setf nz.
272 ;; ??? The zero_extract sets the Z bit to the opposite of what one would
273 ;; expect. This perhaps should be wrapped in a (eq: X (const_int 0)).
276 [(set (match_operand:SI 0 "register_operand" "")
277 (zero_extract:SI (match_operand:QI 1 "memory_operand" "")
279 (match_operand 2 "const_int_operand" "")))]
281 [(set (cc0) (zero_extract:SI (match_dup 1)
284 (set (match_dup 0) (ne:SI (cc0) (const_int 0)))])
287 [(set (cc0) (match_operand:SI 0 "register_operand" "r"))]
290 [(set_attr "length" "2")
291 (set_attr "cc" "set_znv")])
295 (compare (match_operand:SI 0 "register_operand" "r,r")
296 (match_operand:SI 1 "reg_or_int5_operand" "r,J")))]
301 [(set_attr "length" "2,2")
302 (set_attr "cc" "compare")])
304 ;; ----------------------------------------------------------------------
306 ;; ----------------------------------------------------------------------
308 (define_insn "addsi3"
309 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
310 (plus:SI (match_operand:SI 1 "register_operand" "%0,r,r")
311 (match_operand:SI 2 "nonmemory_operand" "rJ,K,U")))]
317 [(set_attr "length" "2,4,4")
318 (set_attr "cc" "set_zn,set_zn,set_zn")])
320 ;; ----------------------------------------------------------------------
321 ;; SUBTRACT INSTRUCTIONS
322 ;; ----------------------------------------------------------------------
324 (define_insn "subsi3"
325 [(set (match_operand:SI 0 "register_operand" "=r,r")
326 (minus:SI (match_operand:SI 1 "register_operand" "0,r")
327 (match_operand:SI 2 "register_operand" "r,0")))]
332 [(set_attr "length" "2,2")
333 (set_attr "cc" "set_zn")])
335 (define_insn "negsi2"
336 [(set (match_operand:SI 0 "register_operand" "=r")
337 (neg:SI (match_operand:SI 1 "register_operand" "0")))]
340 [(set_attr "length" "2")
341 (set_attr "cc" "set_zn")])
343 ;; ----------------------------------------------------------------------
344 ;; MULTIPLY INSTRUCTIONS
345 ;; ----------------------------------------------------------------------
347 (define_expand "mulhisi3"
348 [(set (match_operand:SI 0 "register_operand" "")
350 (sign_extend:SI (match_operand:HI 1 "register_operand" ""))
351 (sign_extend:SI (match_operand:HI 2 "nonmemory_operand" ""))))]
355 (define_insn "*mulhisi3_internal1"
356 [(set (match_operand:SI 0 "register_operand" "=r")
358 (sign_extend:SI (match_operand:HI 1 "register_operand" "%0"))
359 (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
362 [(set_attr "length" "2")
363 (set_attr "cc" "none_0hit")
364 (set_attr "type" "mult")])
366 ;; ??? Sign extending constants isn't valid. Fix?
368 (define_insn "*mulhisi3_internal2"
369 [(set (match_operand:SI 0 "register_operand" "=r,r")
371 (sign_extend:SI (match_operand:HI 1 "register_operand" "%0,r"))
372 (sign_extend:SI (match_operand 2 "const_int_operand" "J,K"))))]
377 [(set_attr "length" "2,4")
378 (set_attr "cc" "none_0hit,none_0hit")
379 (set_attr "type" "mult")])
382 ;; ----------------------------------------------------------------------
384 ;; ----------------------------------------------------------------------
386 (define_insn "*v850_clr1_1"
387 [(set (match_operand:QI 0 "memory_operand" "=m")
389 (and:SI (subreg:SI (match_dup 0) 0)
390 (match_operand:QI 1 "not_power_of_two_operand" "")) 0))]
395 xoperands[0] = operands[0];
396 xoperands[1] = GEN_INT (~INTVAL (operands[1]) & 0xff);
397 output_asm_insn (\"clr1 %M1,%0\", xoperands);
400 [(set_attr "length" "4")
401 (set_attr "cc" "clobber")])
403 (define_insn "*v850_clr1_2"
404 [(set (match_operand:HI 0 "indirect_operand" "=m")
406 (and:SI (subreg:SI (match_dup 0) 0)
407 (match_operand:HI 1 "not_power_of_two_operand" "")) 0))]
411 int log2 = exact_log2 (~INTVAL (operands[1]) & 0xffff);
414 xoperands[0] = gen_rtx_MEM (QImode,
415 plus_constant (XEXP (operands[0], 0), log2 / 8));
416 xoperands[1] = GEN_INT (log2 % 8);
417 output_asm_insn (\"clr1 %1,%0\", xoperands);
420 [(set_attr "length" "4")
421 (set_attr "cc" "clobber")])
423 (define_insn "*v850_clr1_3"
424 [(set (match_operand:SI 0 "indirect_operand" "=m")
425 (and:SI (match_dup 0)
426 (match_operand:SI 1 "not_power_of_two_operand" "")))]
430 int log2 = exact_log2 (~INTVAL (operands[1]) & 0xffffffff);
433 xoperands[0] = gen_rtx_MEM (QImode,
434 plus_constant (XEXP (operands[0], 0), log2 / 8));
435 xoperands[1] = GEN_INT (log2 % 8);
436 output_asm_insn (\"clr1 %1,%0\", xoperands);
439 [(set_attr "length" "4")
440 (set_attr "cc" "clobber")])
442 (define_insn "andsi3"
443 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
444 (and:SI (match_operand:SI 1 "register_operand" "%0,0,r")
445 (match_operand:SI 2 "nonmemory_operand" "r,I,M")))]
451 [(set_attr "length" "2,2,4")
452 (set_attr "cc" "set_znv")])
454 ;; ----------------------------------------------------------------------
456 ;; ----------------------------------------------------------------------
458 (define_insn "*v850_set1_1"
459 [(set (match_operand:QI 0 "memory_operand" "=m")
460 (subreg:QI (ior:SI (subreg:SI (match_dup 0) 0)
461 (match_operand 1 "power_of_two_operand" "")) 0))]
464 [(set_attr "length" "4")
465 (set_attr "cc" "clobber")])
467 (define_insn "*v850_set1_2"
468 [(set (match_operand:HI 0 "indirect_operand" "=m")
469 (subreg:HI (ior:SI (subreg:SI (match_dup 0) 0)
470 (match_operand 1 "power_of_two_operand" "")) 0))]
474 int log2 = exact_log2 (INTVAL (operands[1]));
477 return \"set1 %M1,%0\";
481 xoperands[0] = gen_rtx_MEM (QImode,
482 plus_constant (XEXP (operands[0], 0),
484 xoperands[1] = GEN_INT (log2 % 8);
485 output_asm_insn (\"set1 %1,%0\", xoperands);
489 [(set_attr "length" "4")
490 (set_attr "cc" "clobber")])
492 (define_insn "*v850_set1_3"
493 [(set (match_operand:SI 0 "indirect_operand" "=m")
494 (ior:SI (match_dup 0)
495 (match_operand 1 "power_of_two_operand" "")))]
499 int log2 = exact_log2 (INTVAL (operands[1]));
502 return \"set1 %M1,%0\";
506 xoperands[0] = gen_rtx_MEM (QImode,
507 plus_constant (XEXP (operands[0], 0),
509 xoperands[1] = GEN_INT (log2 % 8);
510 output_asm_insn (\"set1 %1,%0\", xoperands);
514 [(set_attr "length" "4")
515 (set_attr "cc" "clobber")])
517 (define_insn "iorsi3"
518 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
519 (ior:SI (match_operand:SI 1 "register_operand" "%0,0,r")
520 (match_operand:SI 2 "nonmemory_operand" "r,I,M")))]
526 [(set_attr "length" "2,2,4")
527 (set_attr "cc" "set_znv")])
529 ;; ----------------------------------------------------------------------
531 ;; ----------------------------------------------------------------------
533 (define_insn "*v850_not1_1"
534 [(set (match_operand:QI 0 "memory_operand" "=m")
535 (subreg:QI (xor:SI (subreg:SI (match_dup 0) 0)
536 (match_operand 1 "power_of_two_operand" "")) 0))]
539 [(set_attr "length" "4")
540 (set_attr "cc" "clobber")])
542 (define_insn "*v850_not1_2"
543 [(set (match_operand:HI 0 "indirect_operand" "=m")
544 (subreg:HI (xor:SI (subreg:SI (match_dup 0) 0)
545 (match_operand 1 "power_of_two_operand" "")) 0))]
549 int log2 = exact_log2 (INTVAL (operands[1]));
552 return \"not1 %M1,%0\";
556 xoperands[0] = gen_rtx_MEM (QImode,
557 plus_constant (XEXP (operands[0], 0),
559 xoperands[1] = GEN_INT (log2 % 8);
560 output_asm_insn (\"not1 %1,%0\", xoperands);
564 [(set_attr "length" "4")
565 (set_attr "cc" "clobber")])
567 (define_insn "*v850_not1_3"
568 [(set (match_operand:SI 0 "indirect_operand" "=m")
569 (xor:SI (match_dup 0)
570 (match_operand 1 "power_of_two_operand" "")))]
574 int log2 = exact_log2 (INTVAL (operands[1]));
577 return \"not1 %M1,%0\";
581 xoperands[0] = gen_rtx_MEM (QImode,
582 plus_constant (XEXP (operands[0], 0),
584 xoperands[1] = GEN_INT (log2 % 8);
585 output_asm_insn (\"not1 %1,%0\", xoperands);
589 [(set_attr "length" "4")
590 (set_attr "cc" "clobber")])
592 (define_insn "xorsi3"
593 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
594 (xor:SI (match_operand:SI 1 "register_operand" "%0,0,r")
595 (match_operand:SI 2 "nonmemory_operand" "r,I,M")))]
601 [(set_attr "length" "2,2,4")
602 (set_attr "cc" "set_znv")])
604 ;; ----------------------------------------------------------------------
606 ;; ----------------------------------------------------------------------
608 (define_insn "one_cmplsi2"
609 [(set (match_operand:SI 0 "register_operand" "=r")
610 (not:SI (match_operand:SI 1 "register_operand" "r")))]
613 [(set_attr "length" "2")
614 (set_attr "cc" "set_znv")])
616 ;; -----------------------------------------------------------------
618 ;; -----------------------------------------------------------------
620 ;; ??? Is it worth defining insv and extv for the V850 series?!?
622 ;; An insv pattern would be useful, but does not get used because
623 ;; store_bit_field never calls insv when storing a constant value into a
624 ;; single-bit bitfield.
626 ;; extv/extzv patterns would be useful, but do not get used because
627 ;; optimize_bitfield_compare in fold-const usually converts single
628 ;; bit extracts into an AND with a mask.
630 ;; -----------------------------------------------------------------
632 ;; -----------------------------------------------------------------
635 [(set (match_operand:SI 0 "register_operand" "=r")
636 (le:SI (cc0) (const_int 0)))]
640 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
643 return \"setf le,%0\";
645 [(set_attr "length" "4")
646 (set_attr "cc" "none_0hit")])
649 [(set (match_operand:SI 0 "register_operand" "=r")
650 (leu:SI (cc0) (const_int 0)))]
653 [(set_attr "length" "4")
654 (set_attr "cc" "none_0hit")])
657 [(set (match_operand:SI 0 "register_operand" "=r")
658 (ge:SI (cc0) (const_int 0)))]
662 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
665 return \"setf ge,%0\";
667 [(set_attr "length" "4")
668 (set_attr "cc" "none_0hit")])
671 [(set (match_operand:SI 0 "register_operand" "=r")
672 (geu:SI (cc0) (const_int 0)))]
675 [(set_attr "length" "4")
676 (set_attr "cc" "none_0hit")])
679 [(set (match_operand:SI 0 "register_operand" "=r")
680 (lt:SI (cc0) (const_int 0)))]
684 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
687 return \"setf lt,%0\";
689 [(set_attr "length" "4")
690 (set_attr "cc" "none_0hit")])
693 [(set (match_operand:SI 0 "register_operand" "=r")
694 (ltu:SI (cc0) (const_int 0)))]
697 [(set_attr "length" "4")
698 (set_attr "cc" "none_0hit")])
701 [(set (match_operand:SI 0 "register_operand" "=r")
702 (gt:SI (cc0) (const_int 0)))]
706 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
709 return \"setf gt,%0\";
711 [(set_attr "length" "4")
712 (set_attr "cc" "none_0hit")])
715 [(set (match_operand:SI 0 "register_operand" "=r")
716 (gtu:SI (cc0) (const_int 0)))]
719 [(set_attr "length" "4")
720 (set_attr "cc" "none_0hit")])
723 [(set (match_operand:SI 0 "register_operand" "=r")
724 (eq:SI (cc0) (const_int 0)))]
727 [(set_attr "length" "4")
728 (set_attr "cc" "none_0hit")])
731 [(set (match_operand:SI 0 "register_operand" "=r")
732 (ne:SI (cc0) (const_int 0)))]
735 [(set_attr "length" "4")
736 (set_attr "cc" "none_0hit")])
739 ;; ----------------------------------------------------------------------
741 ;; ----------------------------------------------------------------------
743 ;; Conditional jump instructions
747 (if_then_else (le (cc0)
749 (label_ref (match_operand 0 "" ""))
754 (define_expand "bleu"
756 (if_then_else (leu (cc0)
758 (label_ref (match_operand 0 "" ""))
765 (if_then_else (ge (cc0)
767 (label_ref (match_operand 0 "" ""))
772 (define_expand "bgeu"
774 (if_then_else (geu (cc0)
776 (label_ref (match_operand 0 "" ""))
783 (if_then_else (lt (cc0)
785 (label_ref (match_operand 0 "" ""))
790 (define_expand "bltu"
792 (if_then_else (ltu (cc0)
794 (label_ref (match_operand 0 "" ""))
801 (if_then_else (gt (cc0)
803 (label_ref (match_operand 0 "" ""))
808 (define_expand "bgtu"
810 (if_then_else (gtu (cc0)
812 (label_ref (match_operand 0 "" ""))
819 (if_then_else (eq (cc0)
821 (label_ref (match_operand 0 "" ""))
828 (if_then_else (ne (cc0)
830 (label_ref (match_operand 0 "" ""))
835 (define_insn "*branch_normal"
837 (if_then_else (match_operator 1 "comparison_operator"
838 [(cc0) (const_int 0)])
839 (label_ref (match_operand 0 "" ""))
844 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
845 && (GET_CODE (operands[1]) == GT
846 || GET_CODE (operands[1]) == GE
847 || GET_CODE (operands[1]) == LE
848 || GET_CODE (operands[1]) == LT))
851 if (get_attr_length (insn) == 2)
854 return \"b%B1 .+6 ; jr %l0\";
856 [(set (attr "length")
857 (if_then_else (lt (abs (minus (match_dup 0) (pc)))
861 (set_attr "cc" "none")])
863 (define_insn "*branch_invert"
865 (if_then_else (match_operator 1 "comparison_operator"
866 [(cc0) (const_int 0)])
868 (label_ref (match_operand 0 "" ""))))]
872 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
873 && (GET_CODE (operands[1]) == GT
874 || GET_CODE (operands[1]) == GE
875 || GET_CODE (operands[1]) == LE
876 || GET_CODE (operands[1]) == LT))
878 if (get_attr_length (insn) == 2)
881 return \"b%b1 .+6 ; jr %l0\";
883 [(set (attr "length")
884 (if_then_else (lt (abs (minus (match_dup 0) (pc)))
888 (set_attr "cc" "none")])
890 ;; Unconditional and other jump instructions.
894 (label_ref (match_operand 0 "" "")))]
898 if (get_attr_length (insn) == 2)
903 [(set (attr "length")
904 (if_then_else (lt (abs (minus (match_dup 0) (pc)))
908 (set_attr "cc" "none")])
910 (define_insn "indirect_jump"
911 [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
914 [(set_attr "length" "2")
915 (set_attr "cc" "none")])
917 (define_insn "tablejump"
918 [(set (pc) (match_operand:SI 0 "register_operand" "r"))
919 (use (label_ref (match_operand 1 "" "")))]
922 [(set_attr "length" "2")
923 (set_attr "cc" "none")])
925 (define_expand "casesi"
926 [(match_operand:SI 0 "register_operand" "")
927 (match_operand:SI 1 "register_operand" "")
928 (match_operand:SI 2 "register_operand" "")
929 (match_operand 3 "" "") (match_operand 4 "" "")]
933 rtx reg = gen_reg_rtx (SImode);
934 rtx tableaddress = gen_reg_rtx (SImode);
937 /* Subtract the lower bound from the index. */
938 emit_insn (gen_subsi3 (reg, operands[0], operands[1]));
939 /* Compare the result against the number of table entries. */
940 emit_insn (gen_cmpsi (reg, operands[2]));
941 /* Branch to the default label if out of range of the table. */
942 emit_jump_insn (gen_bgtu (operands[4]));
944 /* Shift index for the table array access. */
945 emit_insn (gen_ashlsi3 (reg, reg, GEN_INT (TARGET_BIG_SWITCH ? 2 : 1)));
946 /* Load the table address into a pseudo. */
947 emit_insn (gen_movsi (tableaddress,
948 gen_rtx_LABEL_REF (VOIDmode, operands[3])));
949 /* Add the table address to the index. */
950 emit_insn (gen_addsi3 (reg, reg, tableaddress));
951 /* Load the table entry. */
952 mem = gen_rtx_MEM (CASE_VECTOR_MODE, reg);
953 RTX_UNCHANGING_P (mem);
954 if (! TARGET_BIG_SWITCH)
956 rtx reg2 = gen_reg_rtx (HImode);
957 emit_insn (gen_movhi (reg2, mem));
958 emit_insn (gen_extendhisi2 (reg, reg2));
961 emit_insn (gen_movsi (reg, mem));
962 /* Add the table address. */
963 emit_insn (gen_addsi3 (reg, reg, tableaddress));
964 /* Branch to the switch label. */
965 emit_jump_insn (gen_tablejump (reg, operands[3]));
969 ;; Call subroutine with no return value.
971 (define_expand "call"
972 [(call (match_operand:QI 0 "general_operand" "")
973 (match_operand:SI 1 "general_operand" ""))]
977 if (! call_address_operand (XEXP (operands[0], 0))
978 || TARGET_LONG_CALLS)
979 XEXP (operands[0], 0) = force_reg (SImode, XEXP (operands[0], 0));
980 if (TARGET_LONG_CALLS)
981 emit_call_insn (gen_call_internal_long (XEXP (operands[0], 0), operands[1]));
983 emit_call_insn (gen_call_internal_short (XEXP (operands[0], 0), operands[1]));
988 (define_insn "call_internal_short"
989 [(call (mem:QI (match_operand:SI 0 "call_address_operand" "S,r"))
990 (match_operand:SI 1 "general_operand" "g,g"))
991 (clobber (reg:SI 31))]
992 "! TARGET_LONG_CALLS"
995 jarl .+4,r31 ; add 4,r31 ; jmp %0"
996 [(set_attr "length" "4,8")]
999 (define_insn "call_internal_long"
1000 [(call (mem:QI (match_operand:SI 0 "call_address_operand" "S,r"))
1001 (match_operand:SI 1 "general_operand" "g,g"))
1002 (clobber (reg:SI 31))]
1006 if (which_alternative == 0)
1008 if (GET_CODE (operands[0]) == REG)
1009 return \"jarl %0,r31\";
1011 return \"movhi hi(%0), r0, r11 ; movea lo(%0), r11, r11 ; jarl .+4,r31 ; add 4, r31 ; jmp r11\";
1014 return \"jarl .+4,r31 ; add 4,r31 ; jmp %0\";
1016 [(set_attr "length" "16,8")]
1019 ;; Call subroutine, returning value in operand 0
1020 ;; (which must be a hard register).
1022 (define_expand "call_value"
1023 [(set (match_operand 0 "" "")
1024 (call (match_operand:QI 1 "general_operand" "")
1025 (match_operand:SI 2 "general_operand" "")))]
1029 if (! call_address_operand (XEXP (operands[1], 0))
1030 || TARGET_LONG_CALLS)
1031 XEXP (operands[1], 0) = force_reg (SImode, XEXP (operands[1], 0));
1032 if (TARGET_LONG_CALLS)
1033 emit_call_insn (gen_call_value_internal_long (operands[0],
1034 XEXP (operands[1], 0),
1037 emit_call_insn (gen_call_value_internal_short (operands[0],
1038 XEXP (operands[1], 0),
1043 (define_insn "call_value_internal_short"
1044 [(set (match_operand 0 "" "=r,r")
1045 (call (mem:QI (match_operand:SI 1 "call_address_operand" "S,r"))
1046 (match_operand:SI 2 "general_operand" "g,g")))
1047 (clobber (reg:SI 31))]
1048 "! TARGET_LONG_CALLS"
1051 jarl .+4,r31 ; add 4,r31 ; jmp %1"
1052 [(set_attr "length" "4,8")]
1055 (define_insn "call_value_internal_long"
1056 [(set (match_operand 0 "" "=r,r")
1057 (call (mem:QI (match_operand:SI 1 "call_address_operand" "S,r"))
1058 (match_operand:SI 2 "general_operand" "g,g")))
1059 (clobber (reg:SI 31))]
1063 if (which_alternative == 0)
1065 if (GET_CODE (operands[1]) == REG)
1066 return \"jarl %1, r31\";
1068 /* Reload can generate this pattern... */
1069 return \"movhi hi(%1), r0, r11 ; movea lo(%1), r11, r11 ; jarl .+4, r31 ; add 4, r31 ; jmp r11\";
1072 return \"jarl .+4, r31 ; add 4, r31 ; jmp %1\";
1074 [(set_attr "length" "16,8")]
1081 [(set_attr "length" "2")
1082 (set_attr "cc" "none")])
1084 ;; ----------------------------------------------------------------------
1085 ;; EXTEND INSTRUCTIONS
1086 ;; ----------------------------------------------------------------------
1089 (define_insn "zero_extendhisi2"
1090 [(set (match_operand:SI 0 "register_operand" "=r")
1092 (match_operand:HI 1 "register_operand" "r")))]
1095 [(set_attr "length" "4")
1096 (set_attr "cc" "set_znv")])
1099 (define_insn "zero_extendqisi2"
1100 [(set (match_operand:SI 0 "register_operand" "=r")
1102 (match_operand:QI 1 "register_operand" "r")))]
1105 [(set_attr "length" "4")
1106 (set_attr "cc" "set_znv")])
1108 ;;- sign extension instructions
1111 ;; ??? This is missing a sign extend from memory pattern to match the ld.h
1114 (define_expand "extendhisi2"
1116 (ashift:SI (match_operand:HI 1 "register_operand" "")
1118 (set (match_operand:SI 0 "register_operand" "")
1119 (ashiftrt:SI (match_dup 2)
1124 operands[1] = gen_lowpart (SImode, operands[1]);
1125 operands[2] = gen_reg_rtx (SImode);
1129 ;; ??? This is missing a sign extend from memory pattern to match the ld.b
1132 (define_expand "extendqisi2"
1134 (ashift:SI (match_operand:QI 1 "register_operand" "")
1136 (set (match_operand:SI 0 "register_operand" "")
1137 (ashiftrt:SI (match_dup 2)
1142 operands[1] = gen_lowpart (SImode, operands[1]);
1143 operands[2] = gen_reg_rtx (SImode);
1146 ;; ----------------------------------------------------------------------
1148 ;; ----------------------------------------------------------------------
1150 (define_insn "ashlsi3"
1151 [(set (match_operand:SI 0 "register_operand" "=r,r")
1153 (match_operand:SI 1 "register_operand" "0,0")
1154 (match_operand:SI 2 "nonmemory_operand" "r,N")))]
1159 [(set_attr "length" "4,2")
1160 (set_attr "cc" "set_znv")])
1162 (define_insn "lshrsi3"
1163 [(set (match_operand:SI 0 "register_operand" "=r,r")
1165 (match_operand:SI 1 "register_operand" "0,0")
1166 (match_operand:SI 2 "nonmemory_operand" "r,N")))]
1171 [(set_attr "length" "4,2")
1172 (set_attr "cc" "set_znv")])
1174 (define_insn "ashrsi3"
1175 [(set (match_operand:SI 0 "register_operand" "=r,r")
1177 (match_operand:SI 1 "register_operand" "0,0")
1178 (match_operand:SI 2 "nonmemory_operand" "r,N")))]
1183 [(set_attr "length" "4,2")
1184 (set_attr "cc" "set_znv")])
1186 ;; ----------------------------------------------------------------------
1187 ;; PROLOGUE/EPILOGUE
1188 ;; ----------------------------------------------------------------------
1189 (define_expand "prologue"
1192 "expand_prologue (); DONE;")
1194 (define_expand "epilogue"
1199 /* Try to use the trivial return first. Else use the
1202 emit_jump_insn (gen_return ());
1208 (define_insn "return"
1210 "reload_completed && compute_frame_size (get_frame_size (), (long *)0) == 0"
1212 [(set_attr "length" "2")
1213 (set_attr "cc" "none")])
1215 (define_insn "return_internal"
1220 [(set_attr "length" "2")
1221 (set_attr "cc" "none")])
1225 ;; ----------------------------------------------------------------------
1226 ;; HELPER INSTRUCTIONS for saving the prologue and epilog registers
1227 ;; ----------------------------------------------------------------------
1229 ;; This pattern will match a stack adjust RTX followed by any number of push
1230 ;; RTXs. These RTXs will then be turned into a suitable call to a worker
1235 [(match_parallel 0 "pattern_is_ok_for_prologue"
1237 (plus:SI (reg:SI 3) (match_operand:SI 1 "immediate_operand" "i")))
1238 (set (mem:SI (plus:SI (reg:SI 3)
1239 (match_operand:SI 2 "immediate_operand" "i")))
1240 (match_operand:SI 3 "register_is_ok_for_epilogue" "r"))])]
1241 "TARGET_PROLOG_FUNCTION"
1242 "* return construct_save_jarl (operands[0]);
1244 [(set (attr "length") (if_then_else (eq_attr "long_calls" "yes")
1246 (const_string "4")))
1247 (set_attr "cc" "clobber")])
1249 ;; This pattern will match a return RTX followed by any number of pop RTXs
1250 ;; and possible a stack adjustment as well. These RTXs will be turned into
1251 ;; a suitable call to a worker function.
1254 [(match_parallel 0 "pattern_is_ok_for_epilogue"
1257 (plus:SI (reg:SI 3) (match_operand:SI 1 "immediate_operand" "i")))
1258 (set (match_operand:SI 2 "register_is_ok_for_epilogue" "=r")
1259 (mem:SI (plus:SI (reg:SI 3)
1260 (match_operand:SI 3 "immediate_operand" "i"))))])]
1261 "TARGET_PROLOG_FUNCTION && TARGET_V850"
1262 "* return construct_restore_jr (operands[0]);
1264 [(set (attr "length") (if_then_else (eq_attr "long_calls" "yes")
1266 (const_string "4")))
1267 (set_attr "cc" "clobber")])
1269 ;; Initialize an interrupt function. Do not depend on TARGET_PROLOG_FUNCTION.
1270 (define_insn "save_interrupt"
1271 [(set (reg:SI 3) (plus:SI (reg:SI 3) (const_int -16)))
1272 (set (mem:SI (reg:SI 3)) (reg:SI 30))
1273 (set (mem:SI (plus:SI (reg:SI 3) (const_int -4))) (reg:SI 10))
1274 (set (mem:SI (plus:SI (reg:SI 3) (const_int -8))) (reg:SI 4))
1275 (set (mem:SI (plus:SI (reg:SI 3) (const_int -12))) (reg:SI 1))]
1276 "TARGET_V850 && ! TARGET_LONG_CALLS"
1277 "add -16, sp ; st.w r10, 12[sp] ; jarl __save_interrupt, r10"
1278 [(set_attr "length" "12")
1279 (set_attr "cc" "clobber")])
1281 ;; Restore r1, r4, r10, and return from the interrupt
1282 (define_insn "restore_interrupt"
1284 (set (reg:SI 3) (plus:SI (reg:SI 3) (const_int 16)))
1285 (set (reg:SI 30) (mem:SI (plus:SI (reg:SI 3) (const_int 12))))
1286 (set (reg:SI 10) (mem:SI (plus:SI (reg:SI 3) (const_int 8))))
1287 (set (reg:SI 4) (mem:SI (plus:SI (reg:SI 3) (const_int 4))))
1288 (set (reg:SI 1) (mem:SI (reg:SI 3)))]
1290 "jr __return_interrupt"
1291 [(set_attr "length" "4")
1292 (set_attr "cc" "clobber")])
1295 ;; Save all registers except for the registers saved in save_interrupt when
1296 ;; an interrupt function makes a call.
1297 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
1298 ;; all of memory. This blocks insns from being moved across this point.
1299 ;; This is needed because the rest of the compiler is not ready to handle
1300 ;; insns this complicated.
1302 (define_insn "save_all_interrupt"
1303 [(unspec_volatile [(const_int 0)] 0)]
1304 "TARGET_V850 && ! TARGET_LONG_CALLS"
1305 "jarl __save_all_interrupt,r10"
1306 [(set_attr "length" "4")
1307 (set_attr "cc" "clobber")])
1310 ;; Restore all registers saved when an interrupt function makes a call.
1311 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
1312 ;; all of memory. This blocks insns from being moved across this point.
1313 ;; This is needed because the rest of the compiler is not ready to handle
1314 ;; insns this complicated.
1316 (define_insn "restore_all_interrupt"
1317 [(unspec_volatile [(const_int 0)] 1)]
1318 "TARGET_V850 && ! TARGET_LONG_CALLS"
1319 "jarl __restore_all_interrupt,r10"
1320 [(set_attr "length" "4")
1321 (set_attr "cc" "clobber")])
1323 ;; Save r6-r9 for a variable argument function
1324 (define_insn "save_r6_r9"
1325 [(set (mem:SI (reg:SI 3)) (reg:SI 6))
1326 (set (mem:SI (plus:SI (reg:SI 3) (const_int 4))) (reg:SI 7))
1327 (set (mem:SI (plus:SI (reg:SI 3) (const_int 8))) (reg:SI 8))
1328 (set (mem:SI (plus:SI (reg:SI 3) (const_int 12))) (reg:SI 9))
1329 (clobber (reg:SI 10))]
1330 "TARGET_PROLOG_FUNCTION && ! TARGET_LONG_CALLS"
1331 "jarl __save_r6_r9,r10"
1332 [(set_attr "length" "4")
1333 (set_attr "cc" "clobber")])