1 ;; GCC machine description for NEC V850
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2002, 2004, 2005, 2007, 2008, 2010,
3 ;; 2011, 2012 Free Software Foundation, Inc.
4 ;; Contributed by Jeff Law (law@cygnus.com).
6 ;; This file is part of GCC.
8 ;; GCC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 3, or (at your option)
13 ;; GCC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING3. If not see
20 ;; <http://www.gnu.org/licenses/>.
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 ;;---------------------------------------------------------------------------
40 [(ZERO_REGNUM 0) ; constant zero
41 (SP_REGNUM 3) ; Stack Pointer
42 (GP_REGNUM 4) ; GP Pointer
43 (EP_REGNUM 30) ; EP pointer
44 (LP_REGNUM 31) ; Return address register
45 (CC_REGNUM 32) ; Condition code pseudo register
46 (FCC_REGNUM 33) ; Floating Condition code pseudo register
50 (define_attr "length" ""
53 (define_attr "long_calls" "yes,no"
54 (const (if_then_else (symbol_ref "TARGET_LONG_CALLS")
56 (const_string "no"))))
58 ;; Types of instructions (for scheduling purposes).
60 (define_attr "type" "load,store,bit1,mult,macc,div,fpu,single,other"
61 (const_string "other"))
63 (define_attr "cpu" "none,v850,v850e,v850e1,v850e2,v850e2v3"
64 (cond [(match_test "TARGET_V850")
66 (match_test "TARGET_V850E")
67 (const_string "v850e")
68 (match_test "TARGET_V850E1")
69 (const_string "v850e1")
70 (match_test "TARGET_V850E2")
71 (const_string "v850e2")
72 (match_test "TARGET_V850E2")
73 (const_string "v850e2v3")]
74 (const_string "none")))
76 ;; Condition code settings.
77 ;; none - insn does not affect cc
78 ;; none_0hit - insn does not affect cc but it does modify operand 0
79 ;; This attribute is used to keep track of when operand 0 changes.
80 ;; See the description of NOTICE_UPDATE_CC for more info.
81 ;; set_znv - sets z,n,v to usable values; c is unknown.
82 ;; set_zn - sets z,n to usable values; v,c is unknown.
83 ;; compare - compare instruction
84 ;; clobber - value of cc is unknown
85 (define_attr "cc" "none,none_0hit,set_z,set_zn,set_znv,compare,clobber"
86 (const_string "clobber"))
88 ;; Function units for the V850. As best as I can tell, there's
89 ;; a traditional memory load/use stall as well as a stall if
90 ;; the result of a multiply is used too early.
92 (define_insn_reservation "v850_other" 1
93 (eq_attr "type" "other")
95 (define_insn_reservation "v850_mult" 2
96 (eq_attr "type" "mult")
98 (define_insn_reservation "v850_memory" 2
99 (eq_attr "type" "load")
102 (include "predicates.md")
103 (include "constraints.md")
105 ;; ----------------------------------------------------------------------
107 ;; ----------------------------------------------------------------------
108 (define_insn "sign23byte_load"
109 [(set (match_operand:SI 0 "register_operand" "=r")
111 (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "r")
112 (match_operand 2 "disp23_operand" "W")))))]
115 [(set_attr "length" "4")
116 (set_attr "cc" "none_0hit")])
118 (define_insn "unsign23byte_load"
119 [(set (match_operand:SI 0 "register_operand" "=r")
121 (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "r")
122 (match_operand 2 "disp23_operand" "W")))))]
125 [(set_attr "length" "4")
126 (set_attr "cc" "none_0hit")])
128 (define_insn "sign23hword_load"
129 [(set (match_operand:SI 0 "register_operand" "=r")
131 (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "r")
132 (match_operand 2 "disp23_operand" "W")))))]
135 [(set_attr "length" "4")
136 (set_attr "cc" "none_0hit")])
138 (define_insn "unsign23hword_load"
139 [(set (match_operand:SI 0 "register_operand" "=r")
141 (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "r")
142 (match_operand 2 "disp23_operand" "W")))))]
145 [(set_attr "length" "4")
146 (set_attr "cc" "none_0hit")])
148 (define_insn "23word_load"
149 [(set (match_operand:SI 0 "register_operand" "=r")
150 (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "r")
151 (match_operand 2 "disp23_operand" "W"))))]
154 [(set_attr "length" "4")
155 (set_attr "cc" "none_0hit")])
157 (define_insn "23byte_store"
158 [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "r")
159 (match_operand 1 "disp23_operand" "W")))
160 (match_operand:QI 2 "register_operand" "r"))]
163 [(set_attr "length" "4")
164 (set_attr "cc" "none_0hit")])
166 (define_insn "23hword_store"
167 [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "r")
168 (match_operand 1 "disp23_operand" "W")))
169 (match_operand:HI 2 "register_operand" "r"))]
172 [(set_attr "length" "4")
173 (set_attr "cc" "none_0hit")])
175 (define_insn "23word_store"
176 [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "r")
177 (match_operand 1 "disp23_operand" "W")))
178 (match_operand:SI 2 "register_operand" "r"))]
181 [(set_attr "length" "4")
182 (set_attr "cc" "none_0hit")])
186 (define_expand "movqi"
187 [(set (match_operand:QI 0 "general_operand" "")
188 (match_operand:QI 1 "general_operand" ""))]
191 /* One of the ops has to be in a register or 0 */
192 if (!register_operand (operand0, QImode)
193 && !reg_or_0_operand (operand1, QImode))
194 operands[1] = copy_to_mode_reg (QImode, operand1);
197 (define_insn "*movqi_internal"
198 [(set (match_operand:QI 0 "general_operand" "=r,r,r,Q,r,m,m")
199 (match_operand:QI 1 "general_operand" "Jr,n,Q,Ir,m,r,I"))]
200 "register_operand (operands[0], QImode)
201 || reg_or_0_operand (operands[1], QImode)"
203 return output_move_single (operands);
205 [(set_attr "length" "2,4,2,2,4,4,4")
206 (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")
207 (set_attr "type" "other,other,load,other,load,store,store")])
211 (define_expand "movhi"
212 [(set (match_operand:HI 0 "general_operand" "")
213 (match_operand:HI 1 "general_operand" ""))]
216 /* One of the ops has to be in a register or 0 */
217 if (!register_operand (operand0, HImode)
218 && !reg_or_0_operand (operand1, HImode))
219 operands[1] = copy_to_mode_reg (HImode, operand1);
222 (define_insn "*movhi_internal"
223 [(set (match_operand:HI 0 "general_operand" "=r,r,r,Q,r,m,m")
224 (match_operand:HI 1 "general_operand" "Jr,n,Q,Ir,m,r,I"))]
225 "register_operand (operands[0], HImode)
226 || reg_or_0_operand (operands[1], HImode)"
228 return output_move_single (operands);
230 [(set_attr "length" "2,4,2,2,4,4,4")
231 (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")
232 (set_attr "type" "other,other,load,other,load,store,store")])
236 (define_insn "*movsi_high"
237 [(set (match_operand:SI 0 "register_operand" "=r")
238 (high:SI (match_operand 1 "immediate_operand" "i")))]
241 [(set_attr "length" "4")
242 (set_attr "cc" "none_0hit")
243 (set_attr "type" "other")])
245 (define_insn "*movsi_lo"
246 [(set (match_operand:SI 0 "register_operand" "=r")
247 (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
248 (match_operand:SI 2 "immediate_operand" "i")))]
251 [(set_attr "length" "4")
252 (set_attr "cc" "none_0hit")
253 (set_attr "type" "other")])
255 (define_expand "movsi"
256 [(set (match_operand:SI 0 "general_operand" "")
257 (match_operand:SI 1 "general_operand" ""))]
260 /* One of the ops has to be in a register or 0 */
261 if (!register_operand (operand0, SImode)
262 && !reg_or_0_operand (operand1, SImode))
263 operands[1] = copy_to_mode_reg (SImode, operand1);
265 /* Some constants, as well as symbolic operands
266 must be done with HIGH & LO_SUM patterns. */
267 if (CONSTANT_P (operands[1])
268 && GET_CODE (operands[1]) != HIGH
269 && ! (TARGET_V850E || TARGET_V850E2_ALL)
270 && !special_symbolref_operand (operands[1], VOIDmode)
271 && !(GET_CODE (operands[1]) == CONST_INT
272 && (CONST_OK_FOR_J (INTVAL (operands[1]))
273 || CONST_OK_FOR_K (INTVAL (operands[1]))
274 || CONST_OK_FOR_L (INTVAL (operands[1])))))
278 if (reload_in_progress || reload_completed)
281 temp = gen_reg_rtx (SImode);
283 emit_insn (gen_rtx_SET (SImode, temp,
284 gen_rtx_HIGH (SImode, operand1)));
285 emit_insn (gen_rtx_SET (SImode, operand0,
286 gen_rtx_LO_SUM (SImode, temp, operand1)));
291 ;; This is the same as the following pattern, except that it includes
292 ;; support for arbitrary 32-bit immediates.
294 ;; ??? This always loads addresses using hilo. If the only use of this address
295 ;; was in a load/store, then we would get smaller code if we only loaded the
296 ;; upper part with hi, and then put the lower part in the load/store insn.
298 (define_insn "*movsi_internal_v850e"
299 [(set (match_operand:SI 0 "general_operand" "=r,r,r,r,Q,r,r,m,m,r")
300 (match_operand:SI 1 "general_operand" "Jr,K,L,Q,Ir,m,R,r,I,i"))]
301 "(TARGET_V850E || TARGET_V850E2_ALL)
302 && (register_operand (operands[0], SImode)
303 || reg_or_0_operand (operands[1], SImode))"
305 return output_move_single (operands);
307 [(set_attr "length" "2,4,4,2,2,4,4,4,4,6")
308 (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")
309 (set_attr "type" "other,other,other,load,other,load,other,store,store,other")])
311 (define_insn "*movsi_internal"
312 [(set (match_operand:SI 0 "general_operand" "=r,r,r,r,Q,r,r,m,m")
313 (match_operand:SI 1 "movsi_source_operand" "Jr,K,L,Q,Ir,m,R,r,I"))]
314 "register_operand (operands[0], SImode)
315 || reg_or_0_operand (operands[1], SImode)"
317 return output_move_single (operands);
319 [(set_attr "length" "2,4,4,2,2,4,4,4,4")
320 (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")
321 (set_attr "type" "other,other,other,load,other,load,store,store,other")])
323 (define_insn "*movsf_internal"
324 [(set (match_operand:SF 0 "general_operand" "=r,r,r,r,r,Q,r,m,m,r")
325 (match_operand:SF 1 "general_operand" "Jr,K,L,n,Q,Ir,m,r,IG,iF"))]
326 "register_operand (operands[0], SFmode)
327 || reg_or_0_operand (operands[1], SFmode)"
329 return output_move_single (operands);
331 [(set_attr "length" "2,4,4,8,2,2,4,4,4,8")
332 (set_attr "cc" "none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")
333 (set_attr "type" "other,other,other,other,load,other,load,store,store,other")])
335 ;; ----------------------------------------------------------------------
337 ;; ----------------------------------------------------------------------
339 (define_insn "*v850_tst1"
341 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "m")
343 (match_operand:QI 1 "const_int_operand" "n"))
347 [(set_attr "length" "4")
348 (set_attr "cc" "clobber")])
350 ;; This replaces ld.b;sar;andi with tst1;setf nz.
353 [(set (match_operand:SI 0 "register_operand" "")
354 (compare (zero_extract:SI (match_operand:QI 1 "memory_operand" "")
356 (match_operand 2 "const_int_operand" ""))
359 [(set (cc0) (compare (zero_extract:SI (match_dup 1)
363 (set (match_dup 0) (ne:SI (cc0) (const_int 0)))])
365 (define_expand "cbranchsi4"
367 (compare (match_operand:SI 1 "register_operand" "")
368 (match_operand:SI 2 "reg_or_int5_operand" "")))
371 (match_operator 0 "ordered_comparison_operator" [(cc0)
373 (label_ref (match_operand 3 "" ""))
377 (define_expand "cstoresi4"
379 (compare (match_operand:SI 2 "register_operand" "")
380 (match_operand:SI 3 "reg_or_int5_operand" "")))
381 (set (match_operand:SI 0 "register_operand")
382 (match_operator:SI 1 "ordered_comparison_operator" [(cc0)
386 (define_expand "cmpsi"
388 (compare (match_operand:SI 0 "register_operand" "r,r")
389 (match_operand:SI 1 "reg_or_int5_operand" "r,J")))]
392 v850_compare_op0 = operands[0];
393 v850_compare_op1 = operands[1];
397 (define_insn "cmpsi_insn"
399 (compare (match_operand:SI 0 "register_operand" "r,r")
400 (match_operand:SI 1 "reg_or_int5_operand" "r,J")))]
405 [(set_attr "length" "2,2")
406 (set_attr "cc" "compare")])
408 (define_expand "cmpsf"
409 [(set (reg:CC CC_REGNUM)
410 (compare (match_operand:SF 0 "register_operand" "r")
411 (match_operand:SF 1 "register_operand" "r")))]
414 v850_compare_op0 = operands[0];
415 v850_compare_op1 = operands[1];
419 (define_expand "cmpdf"
420 [(set (reg:CC CC_REGNUM)
421 (compare (match_operand:DF 0 "even_reg_operand" "r")
422 (match_operand:DF 1 "even_reg_operand" "r")))]
425 v850_compare_op0 = operands[0];
426 v850_compare_op1 = operands[1];
430 ;; ----------------------------------------------------------------------
432 ;; ----------------------------------------------------------------------
434 (define_insn "addsi3"
435 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
436 (plus:SI (match_operand:SI 1 "register_operand" "%0,r,r")
437 (match_operand:SI 2 "nonmemory_operand" "rJ,K,U")))
438 (clobber (reg:CC CC_REGNUM))]
445 [(set_attr "length" "2,4,4")
446 (set_attr "cc" "set_zn,set_zn,set_zn")])
448 ;; ----------------------------------------------------------------------
449 ;; SUBTRACT INSTRUCTIONS
450 ;; ----------------------------------------------------------------------
452 (define_insn "subsi3"
453 [(set (match_operand:SI 0 "register_operand" "=r,r")
454 (minus:SI (match_operand:SI 1 "register_operand" "0,r")
455 (match_operand:SI 2 "register_operand" "r,0")))
456 (clobber (reg:CC CC_REGNUM))]
461 [(set_attr "length" "2,2")
462 (set_attr "cc" "set_zn,set_zn")])
464 (define_insn "negsi2"
465 [(set (match_operand:SI 0 "register_operand" "=r")
466 (neg:SI (match_operand:SI 1 "register_operand" "0")))
467 (clobber (reg:CC CC_REGNUM))]
470 [(set_attr "length" "2")
471 (set_attr "cc" "set_zn")])
473 ;; ----------------------------------------------------------------------
474 ;; MULTIPLY INSTRUCTIONS
475 ;; ----------------------------------------------------------------------
477 (define_expand "mulhisi3"
478 [(set (match_operand:SI 0 "register_operand" "")
480 (sign_extend:SI (match_operand:HI 1 "register_operand" ""))
481 (sign_extend:SI (match_operand:HI 2 "nonmemory_operand" ""))))]
484 if (GET_CODE (operands[2]) == CONST_INT)
486 emit_insn (gen_mulhisi3_internal2 (operands[0], operands[1], operands[2]));
491 (define_insn "*mulhisi3_internal1"
492 [(set (match_operand:SI 0 "register_operand" "=r")
494 (sign_extend:SI (match_operand:HI 1 "register_operand" "%0"))
495 (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
498 [(set_attr "length" "2")
499 (set_attr "cc" "none_0hit")
500 (set_attr "type" "mult")])
502 (define_insn "mulhisi3_internal2"
503 [(set (match_operand:SI 0 "register_operand" "=r,r")
505 (sign_extend:SI (match_operand:HI 1 "register_operand" "%0,r"))
506 (match_operand:HI 2 "const_int_operand" "J,K")))]
511 [(set_attr "length" "2,4")
512 (set_attr "cc" "none_0hit,none_0hit")
513 (set_attr "type" "mult")])
515 ;; ??? The scheduling info is probably wrong.
517 ;; ??? This instruction can also generate the 32-bit highpart, but using it
518 ;; may increase code size counter to the desired result.
520 ;; ??? This instructions can also give a DImode result.
522 ;; ??? There is unsigned version, but it matters only for the DImode/highpart
525 (define_insn "mulsi3"
526 [(set (match_operand:SI 0 "register_operand" "=r")
527 (mult:SI (match_operand:SI 1 "register_operand" "%0")
528 (match_operand:SI 2 "reg_or_int9_operand" "rO")))]
529 "(TARGET_V850E || TARGET_V850E2_ALL)"
531 [(set_attr "length" "4")
532 (set_attr "cc" "none_0hit")
533 (set_attr "type" "mult")])
535 ;; ----------------------------------------------------------------------
536 ;; DIVIDE INSTRUCTIONS
537 ;; ----------------------------------------------------------------------
539 ;; ??? These insns do set the Z/N condition codes, except that they are based
540 ;; on only one of the two results, so it doesn't seem to make sense to use
543 ;; ??? The scheduling info is probably wrong.
545 (define_insn "divmodsi4"
546 [(set (match_operand:SI 0 "register_operand" "=r")
547 (div:SI (match_operand:SI 1 "register_operand" "0")
548 (match_operand:SI 2 "register_operand" "r")))
549 (set (match_operand:SI 3 "register_operand" "=r")
550 (mod:SI (match_dup 1)
552 (clobber (reg:CC CC_REGNUM))]
553 "TARGET_V850E || TARGET_V850E2_ALL"
555 if (TARGET_V850E2_ALL)
556 return "divq %2,%0,%3";
558 return "div %2,%0,%3";
560 [(set_attr "length" "4")
561 (set_attr "cc" "clobber")
562 (set_attr "type" "div")])
564 (define_insn "udivmodsi4"
565 [(set (match_operand:SI 0 "register_operand" "=r")
566 (udiv:SI (match_operand:SI 1 "register_operand" "0")
567 (match_operand:SI 2 "register_operand" "r")))
568 (set (match_operand:SI 3 "register_operand" "=r")
569 (umod:SI (match_dup 1)
571 (clobber (reg:CC CC_REGNUM))]
572 "TARGET_V850E || TARGET_V850E2_ALL"
574 if (TARGET_V850E2_ALL)
575 return "divqu %2,%0,%3";
577 return "divu %2,%0,%3";
579 [(set_attr "length" "4")
580 (set_attr "cc" "clobber")
581 (set_attr "type" "div")])
583 ;; ??? There is a 2 byte instruction for generating only the quotient.
584 ;; However, it isn't clear how to compute the length field correctly.
586 (define_insn "divmodhi4"
587 [(set (match_operand:HI 0 "register_operand" "=r")
588 (div:HI (match_operand:HI 1 "register_operand" "0")
589 (match_operand:HI 2 "register_operand" "r")))
590 (set (match_operand:HI 3 "register_operand" "=r")
591 (mod:HI (match_dup 1)
593 (clobber (reg:CC CC_REGNUM))]
594 "TARGET_V850E || TARGET_V850E2_ALL"
596 [(set_attr "length" "4")
597 (set_attr "cc" "clobber")
598 (set_attr "type" "div")])
600 ;; Half-words are sign-extended by default, so we must zero extend to a word
601 ;; here before doing the divide.
603 (define_insn "udivmodhi4"
604 [(set (match_operand:HI 0 "register_operand" "=r")
605 (udiv:HI (match_operand:HI 1 "register_operand" "0")
606 (match_operand:HI 2 "register_operand" "r")))
607 (set (match_operand:HI 3 "register_operand" "=r")
608 (umod:HI (match_dup 1)
610 (clobber (reg:CC CC_REGNUM))]
611 "TARGET_V850E || TARGET_V850E2_ALL"
612 "zxh %0 ; divhu %2,%0,%3"
613 [(set_attr "length" "4")
614 (set_attr "cc" "clobber")
615 (set_attr "type" "div")])
617 ;; ----------------------------------------------------------------------
619 ;; ----------------------------------------------------------------------
621 (define_insn "*v850_clr1_1"
622 [(set (match_operand:QI 0 "memory_operand" "=m")
624 (and:SI (subreg:SI (match_dup 0) 0)
625 (match_operand:QI 1 "not_power_of_two_operand" "")) 0))
626 (clobber (reg:CC CC_REGNUM))]
630 xoperands[0] = operands[0];
631 xoperands[1] = GEN_INT (~INTVAL (operands[1]) & 0xff);
632 output_asm_insn ("clr1 %M1,%0", xoperands);
635 [(set_attr "length" "4")
636 (set_attr "cc" "clobber")
637 (set_attr "type" "bit1")])
639 (define_insn "*v850_clr1_2"
640 [(set (match_operand:HI 0 "indirect_operand" "=m")
642 (and:SI (subreg:SI (match_dup 0) 0)
643 (match_operand:HI 1 "not_power_of_two_operand" "")) 0))
644 (clobber (reg:CC CC_REGNUM))]
647 int log2 = exact_log2 (~INTVAL (operands[1]) & 0xffff);
650 xoperands[0] = gen_rtx_MEM (QImode,
651 plus_constant (Pmode, XEXP (operands[0], 0),
653 xoperands[1] = GEN_INT (log2 % 8);
654 output_asm_insn ("clr1 %1,%0", xoperands);
657 [(set_attr "length" "4")
658 (set_attr "cc" "clobber")
659 (set_attr "type" "bit1")])
661 (define_insn "*v850_clr1_3"
662 [(set (match_operand:SI 0 "indirect_operand" "=m")
663 (and:SI (match_dup 0)
664 (match_operand:SI 1 "not_power_of_two_operand" "")))
665 (clobber (reg:CC CC_REGNUM))]
668 int log2 = exact_log2 (~INTVAL (operands[1]) & 0xffffffff);
671 xoperands[0] = gen_rtx_MEM (QImode,
672 plus_constant (Pmode, XEXP (operands[0], 0),
674 xoperands[1] = GEN_INT (log2 % 8);
675 output_asm_insn ("clr1 %1,%0", xoperands);
678 [(set_attr "length" "4")
679 (set_attr "cc" "clobber")
680 (set_attr "type" "bit1")])
682 (define_insn "andsi3"
683 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
684 (and:SI (match_operand:SI 1 "register_operand" "%0,0,r")
685 (match_operand:SI 2 "nonmemory_operand" "r,I,M")))
686 (clobber (reg:CC CC_REGNUM))]
692 [(set_attr "length" "2,2,4")
693 (set_attr "cc" "set_zn")])
695 ;; ----------------------------------------------------------------------
697 ;; ----------------------------------------------------------------------
699 (define_insn "*v850_set1_1"
700 [(set (match_operand:QI 0 "memory_operand" "=m")
701 (subreg:QI (ior:SI (subreg:SI (match_dup 0) 0)
702 (match_operand 1 "power_of_two_operand" "")) 0))
703 (clobber (reg:CC CC_REGNUM))]
706 [(set_attr "length" "4")
707 (set_attr "cc" "clobber")
708 (set_attr "type" "bit1")])
710 (define_insn "*v850_set1_2"
711 [(set (match_operand:HI 0 "indirect_operand" "=m")
712 (subreg:HI (ior:SI (subreg:SI (match_dup 0) 0)
713 (match_operand 1 "power_of_two_operand" "")) 0))]
716 int log2 = exact_log2 (INTVAL (operands[1]));
719 return "set1 %M1,%0";
723 xoperands[0] = gen_rtx_MEM (QImode,
724 plus_constant (Pmode, XEXP (operands[0], 0),
726 xoperands[1] = GEN_INT (log2 % 8);
727 output_asm_insn ("set1 %1,%0", xoperands);
731 [(set_attr "length" "4")
732 (set_attr "cc" "clobber")
733 (set_attr "type" "bit1")])
735 (define_insn "*v850_set1_3"
736 [(set (match_operand:SI 0 "indirect_operand" "=m")
737 (ior:SI (match_dup 0)
738 (match_operand 1 "power_of_two_operand" "")))
739 (clobber (reg:CC CC_REGNUM))]
742 int log2 = exact_log2 (INTVAL (operands[1]));
745 return "set1 %M1,%0";
749 xoperands[0] = gen_rtx_MEM (QImode,
750 plus_constant (Pmode, XEXP (operands[0], 0),
752 xoperands[1] = GEN_INT (log2 % 8);
753 output_asm_insn ("set1 %1,%0", xoperands);
757 [(set_attr "length" "4")
758 (set_attr "cc" "clobber")
759 (set_attr "type" "bit1")])
761 (define_insn "iorsi3"
762 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
763 (ior:SI (match_operand:SI 1 "register_operand" "%0,0,r")
764 (match_operand:SI 2 "nonmemory_operand" "r,I,M")))
765 (clobber (reg:CC CC_REGNUM))]
771 [(set_attr "length" "2,2,4")
772 (set_attr "cc" "set_zn")])
774 ;; ----------------------------------------------------------------------
776 ;; ----------------------------------------------------------------------
778 (define_insn "*v850_not1_1"
779 [(set (match_operand:QI 0 "memory_operand" "=m")
780 (subreg:QI (xor:SI (subreg:SI (match_dup 0) 0)
781 (match_operand 1 "power_of_two_operand" "")) 0))
782 (clobber (reg:CC CC_REGNUM))]
785 [(set_attr "length" "4")
786 (set_attr "cc" "clobber")
787 (set_attr "type" "bit1")])
789 (define_insn "*v850_not1_2"
790 [(set (match_operand:HI 0 "indirect_operand" "=m")
791 (subreg:HI (xor:SI (subreg:SI (match_dup 0) 0)
792 (match_operand 1 "power_of_two_operand" "")) 0))]
795 int log2 = exact_log2 (INTVAL (operands[1]));
798 return "not1 %M1,%0";
802 xoperands[0] = gen_rtx_MEM (QImode,
803 plus_constant (Pmode, XEXP (operands[0], 0),
805 xoperands[1] = GEN_INT (log2 % 8);
806 output_asm_insn ("not1 %1,%0", xoperands);
810 [(set_attr "length" "4")
811 (set_attr "cc" "clobber")
812 (set_attr "type" "bit1")])
814 (define_insn "*v850_not1_3"
815 [(set (match_operand:SI 0 "indirect_operand" "=m")
816 (xor:SI (match_dup 0)
817 (match_operand 1 "power_of_two_operand" "")))
818 (clobber (reg:CC CC_REGNUM))]
821 int log2 = exact_log2 (INTVAL (operands[1]));
824 return "not1 %M1,%0";
828 xoperands[0] = gen_rtx_MEM (QImode,
829 plus_constant (Pmode, XEXP (operands[0], 0),
831 xoperands[1] = GEN_INT (log2 % 8);
832 output_asm_insn ("not1 %1,%0", xoperands);
836 [(set_attr "length" "4")
837 (set_attr "cc" "clobber")
838 (set_attr "type" "bit1")])
840 (define_insn "xorsi3"
841 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
842 (xor:SI (match_operand:SI 1 "register_operand" "%0,0,r")
843 (match_operand:SI 2 "nonmemory_operand" "r,I,M")))
844 (clobber (reg:CC CC_REGNUM))]
850 [(set_attr "length" "2,2,4")
851 (set_attr "cc" "set_zn")])
853 ;; ----------------------------------------------------------------------
855 ;; ----------------------------------------------------------------------
857 (define_insn "one_cmplsi2"
858 [(set (match_operand:SI 0 "register_operand" "=r")
859 (not:SI (match_operand:SI 1 "register_operand" "r")))
860 (clobber (reg:CC CC_REGNUM))]
863 [(set_attr "length" "2")
864 (set_attr "cc" "set_zn")])
866 ;; -----------------------------------------------------------------
868 ;; -----------------------------------------------------------------
870 ;; ??? Is it worth defining insv and extv for the V850 series?!?
872 ;; An insv pattern would be useful, but does not get used because
873 ;; store_bit_field never calls insv when storing a constant value into a
874 ;; single-bit bitfield.
876 ;; extv/extzv patterns would be useful, but do not get used because
877 ;; optimize_bitfield_compare in fold-const usually converts single
878 ;; bit extracts into an AND with a mask.
880 ;; -----------------------------------------------------------------
882 ;; -----------------------------------------------------------------
884 (define_insn "*setcc"
885 [(set (match_operand:SI 0 "register_operand" "=r")
886 (match_operator:SI 1 "comparison_operator"
887 [(cc0) (const_int 0)]))]
890 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
891 && (GET_CODE (operands[1]) == GT
892 || GET_CODE (operands[1]) == GE
893 || GET_CODE (operands[1]) == LE
894 || GET_CODE (operands[1]) == LT))
897 return "setf %c1,%0";
899 [(set_attr "length" "4")
900 (set_attr "cc" "none_0hit")])
902 (define_insn "setf_insn"
903 [(set (match_operand:SI 0 "register_operand" "=r")
904 (match_operator:SI 1 "comparison_operator"
905 [(reg:CC CC_REGNUM) (const_int 0)]))]
908 [(set_attr "length" "4")
909 (set_attr "cc" "none_0hit")])
911 (define_insn "set_z_insn"
912 [(set (match_operand:SI 0 "register_operand" "=r")
913 (match_operand 1 "v850_float_z_comparison_operator" ""))]
916 [(set_attr "length" "4")
917 (set_attr "cc" "none_0hit")])
919 (define_insn "set_nz_insn"
920 [(set (match_operand:SI 0 "register_operand" "=r")
921 (match_operand 1 "v850_float_nz_comparison_operator" ""))]
924 [(set_attr "length" "4")
925 (set_attr "cc" "none_0hit")])
927 ;; ----------------------------------------------------------------------
928 ;; CONDITIONAL MOVE INSTRUCTIONS
929 ;; ----------------------------------------------------------------------
931 ;; Instructions using cc0 aren't allowed to have input reloads, so we must
932 ;; hide the fact that this instruction uses cc0. We do so by including the
933 ;; compare instruction inside it.
935 (define_expand "movsicc"
936 [(set (match_operand:SI 0 "register_operand" "=r")
938 (match_operand 1 "comparison_operator")
939 (match_operand:SI 2 "reg_or_const_operand" "rJ")
940 (match_operand:SI 3 "reg_or_const_operand" "rI")))]
941 "(TARGET_V850E || TARGET_V850E2_ALL)"
943 if ((GET_CODE (operands[2]) == CONST_INT
944 && GET_CODE (operands[3]) == CONST_INT))
946 int o2 = INTVAL (operands[2]);
947 int o3 = INTVAL (operands[3]);
949 if (o2 == 1 && o3 == 0)
951 if (o3 == 1 && o2 == 0)
953 if (o2 == 0 && (o3 < -16 || o3 > 15) && exact_log2 (o3) >= 0)
954 FAIL; /* setf + shift */
955 if (o3 == 0 && (o2 < -16 || o2 > 15) && exact_log2 (o2) >=0)
956 FAIL; /* setf + shift */
958 operands[2] = copy_to_mode_reg (SImode, operands[2]);
960 operands[3] = copy_to_mode_reg (SImode, operands[3]);
964 if (GET_CODE (operands[2]) != REG)
965 operands[2] = copy_to_mode_reg (SImode,operands[2]);
966 if (GET_CODE (operands[3]) != REG)
967 operands[3] = copy_to_mode_reg (SImode, operands[3]);
971 ;; ??? Clobbering the condition codes is overkill.
973 ;; ??? We sometimes emit an unnecessary compare instruction because the
974 ;; condition codes may have already been set by an earlier instruction,
975 ;; but we have no code here to avoid the compare if it is unnecessary.
977 (define_insn "movsicc_normal_cc"
978 [(set (match_operand:SI 0 "register_operand" "=r")
980 (match_operator 1 "comparison_operator"
981 [(reg:CC CC_REGNUM) (const_int 0)])
982 (match_operand:SI 2 "reg_or_int5_operand" "rJ")
983 (match_operand:SI 3 "reg_or_0_operand" "rI")))]
984 "(TARGET_V850E || TARGET_V850E2_ALL)"
985 "cmov %c1,%2,%z3,%0";
986 [(set_attr "length" "6")
987 (set_attr "cc" "compare")])
989 (define_insn "movsicc_reversed_cc"
990 [(set (match_operand:SI 0 "register_operand" "=r")
992 (match_operator 1 "comparison_operator"
993 [(reg:CC CC_REGNUM) (const_int 0)])
994 (match_operand:SI 2 "reg_or_0_operand" "rI")
995 (match_operand:SI 3 "reg_or_int5_operand" "rJ")))]
996 "(TARGET_V850E || TARGET_V850E2_ALL)"
998 [(set_attr "length" "6")
999 (set_attr "cc" "compare")])
1001 (define_insn "*movsicc_normal"
1002 [(set (match_operand:SI 0 "register_operand" "=r")
1004 (match_operator 1 "comparison_operator"
1005 [(match_operand:SI 4 "register_operand" "r")
1006 (match_operand:SI 5 "reg_or_int5_operand" "rJ")])
1007 (match_operand:SI 2 "reg_or_int5_operand" "rJ")
1008 (match_operand:SI 3 "reg_or_0_operand" "rI")))]
1009 "(TARGET_V850E || TARGET_V850E2_ALL)"
1010 "cmp %5,%4 ; cmov %c1,%2,%z3,%0"
1011 [(set_attr "length" "6")
1012 (set_attr "cc" "clobber")])
1014 (define_insn "*movsicc_reversed"
1015 [(set (match_operand:SI 0 "register_operand" "=r")
1017 (match_operator 1 "comparison_operator"
1018 [(match_operand:SI 4 "register_operand" "r")
1019 (match_operand:SI 5 "reg_or_int5_operand" "rJ")])
1020 (match_operand:SI 2 "reg_or_0_operand" "rI")
1021 (match_operand:SI 3 "reg_or_int5_operand" "rJ")))]
1022 "(TARGET_V850E || TARGET_V850E2_ALL)"
1023 "cmp %5,%4 ; cmov %C1,%3,%z2,%0"
1024 [(set_attr "length" "6")
1025 (set_attr "cc" "clobber")])
1027 (define_insn "*movsicc_tst1"
1028 [(set (match_operand:SI 0 "register_operand" "=r")
1030 (match_operator 1 "comparison_operator"
1032 (match_operand:QI 2 "memory_operand" "m")
1034 (match_operand 3 "const_int_operand" "n"))
1036 (match_operand:SI 4 "reg_or_int5_operand" "rJ")
1037 (match_operand:SI 5 "reg_or_0_operand" "rI")))]
1038 "(TARGET_V850E || TARGET_V850E2_ALL)"
1039 "tst1 %3,%2 ; cmov %c1,%4,%z5,%0"
1040 [(set_attr "length" "8")
1041 (set_attr "cc" "clobber")])
1043 (define_insn "*movsicc_tst1_reversed"
1044 [(set (match_operand:SI 0 "register_operand" "=r")
1046 (match_operator 1 "comparison_operator"
1048 (match_operand:QI 2 "memory_operand" "m")
1050 (match_operand 3 "const_int_operand" "n"))
1052 (match_operand:SI 4 "reg_or_0_operand" "rI")
1053 (match_operand:SI 5 "reg_or_int5_operand" "rJ")))]
1054 "(TARGET_V850E || TARGET_V850E2_ALL)"
1055 "tst1 %3,%2 ; cmov %C1,%5,%z4,%0"
1056 [(set_attr "length" "8")
1057 (set_attr "cc" "clobber")])
1059 ;; Matching for sasf requires combining 4 instructions, so we provide a
1060 ;; dummy pattern to match the first 3, which will always be turned into the
1061 ;; second pattern by subsequent combining. As above, we must include the
1062 ;; comparison to avoid input reloads in an insn using cc0.
1064 (define_insn "*sasf"
1065 [(set (match_operand:SI 0 "register_operand" "=r")
1067 (match_operator 1 "comparison_operator"
1068 [(match_operand:SI 3 "register_operand" "r")
1069 (match_operand:SI 4 "reg_or_int5_operand" "rJ")])
1070 (ashift:SI (match_operand:SI 2 "register_operand" "0")
1072 (clobber (reg:CC CC_REGNUM))]
1073 "(TARGET_V850E || TARGET_V850E2_ALL)"
1074 "cmp %4,%3 ; sasf %c1,%0"
1075 [(set_attr "length" "6")
1076 (set_attr "cc" "clobber")])
1079 [(set (match_operand:SI 0 "register_operand" "")
1081 (match_operator 1 "comparison_operator"
1082 [(match_operand:SI 4 "register_operand" "")
1083 (match_operand:SI 5 "reg_or_int5_operand" "")])
1084 (match_operand:SI 2 "const_int_operand" "")
1085 (match_operand:SI 3 "const_int_operand" "")))
1086 (clobber (reg:CC CC_REGNUM))]
1087 "(TARGET_V850E || TARGET_V850E2_ALL)
1088 && ((INTVAL (operands[2]) ^ INTVAL (operands[3])) == 1)
1089 && ((INTVAL (operands[2]) + INTVAL (operands[3])) != 1)
1090 && (GET_CODE (operands[5]) == CONST_INT
1091 || REGNO (operands[0]) != REGNO (operands[5]))
1092 && REGNO (operands[0]) != REGNO (operands[4])"
1093 [(set (match_dup 0) (match_dup 6))
1094 (parallel [(set (match_dup 0)
1095 (ior:SI (match_op_dup 7 [(match_dup 4) (match_dup 5)])
1096 (ashift:SI (match_dup 0) (const_int 1))))
1097 (clobber (reg:CC CC_REGNUM))])]
1099 operands[6] = GEN_INT (INTVAL (operands[2]) >> 1);
1100 if (INTVAL (operands[2]) & 0x1)
1101 operands[7] = operands[1];
1103 operands[7] = gen_rtx_fmt_ee (reverse_condition (GET_CODE (operands[1])),
1104 GET_MODE (operands[1]),
1105 XEXP (operands[1], 0), XEXP (operands[1], 1));
1108 ;; ---------------------------------------------------------------------
1109 ;; BYTE SWAP INSTRUCTIONS
1110 ;; ---------------------------------------------------------------------
1111 (define_expand "rotlhi3"
1112 [(parallel [(set (match_operand:HI 0 "register_operand" "")
1113 (rotate:HI (match_operand:HI 1 "register_operand" "")
1114 (match_operand:HI 2 "const_int_operand" "")))
1115 (clobber (reg:CC CC_REGNUM))])]
1116 "(TARGET_V850E || TARGET_V850E2_ALL)"
1118 if (INTVAL (operands[2]) != 8)
1122 (define_insn "*rotlhi3_8"
1123 [(set (match_operand:HI 0 "register_operand" "=r")
1124 (rotate:HI (match_operand:HI 1 "register_operand" "r")
1126 (clobber (reg:CC CC_REGNUM))]
1127 "(TARGET_V850E || TARGET_V850E2_ALL)"
1129 [(set_attr "length" "4")
1130 (set_attr "cc" "clobber")])
1132 (define_expand "rotlsi3"
1133 [(parallel [(set (match_operand:SI 0 "register_operand" "")
1134 (rotate:SI (match_operand:SI 1 "register_operand" "")
1135 (match_operand:SI 2 "const_int_operand" "")))
1136 (clobber (reg:CC CC_REGNUM))])]
1137 "(TARGET_V850E || TARGET_V850E2_ALL)"
1139 if (INTVAL (operands[2]) != 16)
1143 (define_insn "*rotlsi3_16"
1144 [(set (match_operand:SI 0 "register_operand" "=r")
1145 (rotate:SI (match_operand:SI 1 "register_operand" "r")
1147 (clobber (reg:CC CC_REGNUM))]
1148 "(TARGET_V850E || TARGET_V850E2_ALL)"
1150 [(set_attr "length" "4")
1151 (set_attr "cc" "clobber")])
1153 ;; ----------------------------------------------------------------------
1154 ;; JUMP INSTRUCTIONS
1155 ;; ----------------------------------------------------------------------
1157 ;; Conditional jump instructions
1159 (define_insn "*branch_normal"
1161 (if_then_else (match_operator 1 "comparison_operator"
1162 [(cc0) (const_int 0)])
1163 (label_ref (match_operand 0 "" ""))
1167 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
1168 && (GET_CODE (operands[1]) == GT
1169 || GET_CODE (operands[1]) == GE
1170 || GET_CODE (operands[1]) == LE
1171 || GET_CODE (operands[1]) == LT))
1174 if (get_attr_length (insn) == 2)
1177 return "b%B1 .+6 ; jr %l0";
1179 [(set (attr "length")
1180 (if_then_else (lt (abs (minus (match_dup 0) (pc)))
1184 (set_attr "cc" "none")])
1186 (define_insn "*branch_invert"
1188 (if_then_else (match_operator 1 "comparison_operator"
1189 [(cc0) (const_int 0)])
1191 (label_ref (match_operand 0 "" ""))))]
1194 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
1195 && (GET_CODE (operands[1]) == GT
1196 || GET_CODE (operands[1]) == GE
1197 || GET_CODE (operands[1]) == LE
1198 || GET_CODE (operands[1]) == LT))
1200 if (get_attr_length (insn) == 2)
1203 return "b%b1 .+6 ; jr %l0";
1205 [(set (attr "length")
1206 (if_then_else (lt (abs (minus (match_dup 0) (pc)))
1210 (set_attr "cc" "none")])
1212 (define_insn "branch_z_normal"
1214 (if_then_else (match_operand 1 "v850_float_z_comparison_operator" "")
1215 (label_ref (match_operand 0 "" ""))
1219 if (get_attr_length (insn) == 2)
1222 return "bnz 1f ; jr %l0 ; 1:";
1224 [(set (attr "length")
1225 (if_then_else (lt (abs (minus (match_dup 0) (pc)))
1229 (set_attr "cc" "none")])
1231 (define_insn "*branch_z_invert"
1233 (if_then_else (match_operand 1 "v850_float_z_comparison_operator" "")
1235 (label_ref (match_operand 0 "" ""))))]
1238 if (get_attr_length (insn) == 2)
1241 return "bz 1f ; jr %l0 ; 1:";
1243 [(set (attr "length")
1244 (if_then_else (lt (abs (minus (match_dup 0) (pc)))
1248 (set_attr "cc" "none")])
1250 (define_insn "branch_nz_normal"
1252 (if_then_else (match_operand 1 "v850_float_nz_comparison_operator" "")
1253 (label_ref (match_operand 0 "" ""))
1257 if (get_attr_length (insn) == 2)
1260 return "bz 1f ; jr %l0 ; 1:";
1262 [(set (attr "length")
1263 (if_then_else (lt (abs (minus (match_dup 0) (pc)))
1267 (set_attr "cc" "none")])
1269 (define_insn "*branch_nz_invert"
1271 (if_then_else (match_operand 1 "v850_float_nz_comparison_operator" "")
1273 (label_ref (match_operand 0 "" ""))))]
1276 if (get_attr_length (insn) == 2)
1279 return "bnz 1f ; jr %l0 ; 1:";
1281 [(set (attr "length")
1282 (if_then_else (lt (abs (minus (match_dup 0) (pc)))
1286 (set_attr "cc" "none")])
1288 ;; Unconditional and other jump instructions.
1292 (label_ref (match_operand 0 "" "")))]
1295 if (get_attr_length (insn) == 2)
1300 [(set (attr "length")
1301 (if_then_else (lt (abs (minus (match_dup 0) (pc)))
1305 (set_attr "cc" "none")])
1307 (define_insn "indirect_jump"
1308 [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
1311 [(set_attr "length" "2")
1312 (set_attr "cc" "none")])
1314 (define_insn "tablejump"
1315 [(set (pc) (match_operand:SI 0 "register_operand" "r"))
1316 (use (label_ref (match_operand 1 "" "")))]
1319 [(set_attr "length" "2")
1320 (set_attr "cc" "none")])
1322 (define_insn "switch"
1327 (plus:SI (ashift:SI (match_operand:SI 0 "register_operand" "r")
1329 (label_ref (match_operand 1 "" "")))))
1330 (label_ref (match_dup 1))))]
1331 "(TARGET_V850E || TARGET_V850E2_ALL)"
1333 [(set_attr "length" "2")
1334 (set_attr "cc" "none")])
1336 (define_expand "casesi"
1337 [(match_operand:SI 0 "register_operand" "")
1338 (match_operand:SI 1 "register_operand" "")
1339 (match_operand:SI 2 "register_operand" "")
1340 (match_operand 3 "" "") (match_operand 4 "" "")]
1343 rtx reg = gen_reg_rtx (SImode);
1344 rtx tableaddress = gen_reg_rtx (SImode);
1348 /* Subtract the lower bound from the index. */
1349 emit_insn (gen_subsi3 (reg, operands[0], operands[1]));
1351 /* Compare the result against the number of table entries;
1352 branch to the default label if out of range of the table. */
1353 test = gen_rtx_fmt_ee (GTU, VOIDmode, reg, operands[2]);
1354 emit_jump_insn (gen_cbranchsi4 (test, reg, operands[2], operands[4]));
1356 /* Shift index for the table array access. */
1357 emit_insn (gen_ashlsi3 (reg, reg, GEN_INT (TARGET_BIG_SWITCH ? 2 : 1)));
1358 /* Load the table address into a pseudo. */
1359 emit_insn (gen_movsi (tableaddress,
1360 gen_rtx_LABEL_REF (Pmode, operands[3])));
1361 /* Add the table address to the index. */
1362 emit_insn (gen_addsi3 (reg, reg, tableaddress));
1363 /* Load the table entry. */
1364 mem = gen_const_mem (CASE_VECTOR_MODE, reg);
1365 if (! TARGET_BIG_SWITCH)
1367 rtx reg2 = gen_reg_rtx (HImode);
1368 emit_insn (gen_movhi (reg2, mem));
1369 emit_insn (gen_extendhisi2 (reg, reg2));
1372 emit_insn (gen_movsi (reg, mem));
1373 /* Add the table address. */
1374 emit_insn (gen_addsi3 (reg, reg, tableaddress));
1375 /* Branch to the switch label. */
1376 emit_jump_insn (gen_tablejump (reg, operands[3]));
1380 ;; Call subroutine with no return value.
1382 (define_expand "call"
1383 [(call (match_operand:QI 0 "general_operand" "")
1384 (match_operand:SI 1 "general_operand" ""))]
1387 if (! call_address_operand (XEXP (operands[0], 0), QImode)
1388 || TARGET_LONG_CALLS)
1389 XEXP (operands[0], 0) = force_reg (SImode, XEXP (operands[0], 0));
1390 if (TARGET_LONG_CALLS)
1391 emit_call_insn (gen_call_internal_long (XEXP (operands[0], 0), operands[1]));
1393 emit_call_insn (gen_call_internal_short (XEXP (operands[0], 0), operands[1]));
1398 (define_insn "call_internal_short"
1399 [(call (mem:QI (match_operand:SI 0 "call_address_operand" "S,r"))
1400 (match_operand:SI 1 "general_operand" "g,g"))
1401 (clobber (reg:SI 31))]
1402 "! TARGET_LONG_CALLS"
1405 jarl .+4,r31 ; add 4,r31 ; jmp %0"
1406 [(set_attr "length" "4,8")
1407 (set_attr "cc" "clobber,clobber")]
1410 (define_insn "call_internal_long"
1411 [(call (mem:QI (match_operand:SI 0 "call_address_operand" "S,r"))
1412 (match_operand:SI 1 "general_operand" "g,g"))
1413 (clobber (reg:SI 31))]
1416 if (which_alternative == 0)
1418 if (GET_CODE (operands[0]) == REG)
1419 return "jarl %0,r31";
1421 return "movhi hi(%0), r0, r11 ; movea lo(%0), r11, r11 ; jarl .+4,r31 ; add 4, r31 ; jmp r11";
1424 return "jarl .+4,r31 ; add 4,r31 ; jmp %0";
1426 [(set_attr "length" "16,8")
1427 (set_attr "cc" "clobber,clobber")]
1430 ;; Call subroutine, returning value in operand 0
1431 ;; (which must be a hard register).
1433 (define_expand "call_value"
1434 [(set (match_operand 0 "" "")
1435 (call (match_operand:QI 1 "general_operand" "")
1436 (match_operand:SI 2 "general_operand" "")))]
1439 if (! call_address_operand (XEXP (operands[1], 0), QImode)
1440 || TARGET_LONG_CALLS)
1441 XEXP (operands[1], 0) = force_reg (SImode, XEXP (operands[1], 0));
1442 if (TARGET_LONG_CALLS)
1443 emit_call_insn (gen_call_value_internal_long (operands[0],
1444 XEXP (operands[1], 0),
1447 emit_call_insn (gen_call_value_internal_short (operands[0],
1448 XEXP (operands[1], 0),
1453 (define_insn "call_value_internal_short"
1454 [(set (match_operand 0 "" "=r,r")
1455 (call (mem:QI (match_operand:SI 1 "call_address_operand" "S,r"))
1456 (match_operand:SI 2 "general_operand" "g,g")))
1457 (clobber (reg:SI 31))]
1458 "! TARGET_LONG_CALLS"
1461 jarl .+4,r31 ; add 4,r31 ; jmp %1"
1462 [(set_attr "length" "4,8")
1463 (set_attr "cc" "clobber,clobber")]
1466 (define_insn "call_value_internal_long"
1467 [(set (match_operand 0 "" "=r,r")
1468 (call (mem:QI (match_operand:SI 1 "call_address_operand" "S,r"))
1469 (match_operand:SI 2 "general_operand" "g,g")))
1470 (clobber (reg:SI 31))]
1473 if (which_alternative == 0)
1475 if (GET_CODE (operands[1]) == REG)
1476 return "jarl %1, r31";
1478 /* Reload can generate this pattern.... */
1479 return "movhi hi(%1), r0, r11 ; movea lo(%1), r11, r11 ; jarl .+4, r31 ; add 4, r31 ; jmp r11";
1482 return "jarl .+4, r31 ; add 4, r31 ; jmp %1";
1484 [(set_attr "length" "16,8")
1485 (set_attr "cc" "clobber,clobber")]
1492 [(set_attr "length" "2")
1493 (set_attr "cc" "none")])
1495 ;; ----------------------------------------------------------------------
1496 ;; EXTEND INSTRUCTIONS
1497 ;; ----------------------------------------------------------------------
1499 (define_insn "*zero_extendhisi2_v850e"
1500 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1502 (match_operand:HI 1 "nonimmediate_operand" "0,r,T,m")))
1503 (clobber (reg:CC CC_REGNUM))]
1504 "(TARGET_V850E || TARGET_V850E2_ALL)"
1510 [(set_attr "length" "2,4,2,4")
1511 (set_attr "cc" "none_0hit,set_zn,none_0hit,none_0hit")])
1513 (define_insn "*zero_extendhisi2_v850"
1514 [(set (match_operand:SI 0 "register_operand" "=r")
1516 (match_operand:HI 1 "register_operand" "r")))
1517 (clobber (reg:CC CC_REGNUM))] ;; A lie, but we have to match the expander
1520 [(set_attr "length" "4")
1521 (set_attr "cc" "set_zn")])
1523 (define_expand "zero_extendhisi2"
1524 [(parallel [(set (match_operand:SI 0 "register_operand")
1526 (match_operand:HI 1 "nonimmediate_operand")))
1527 (clobber (reg:CC CC_REGNUM))])]
1530 if (! (TARGET_V850E || TARGET_V850E2_ALL))
1531 operands[1] = force_reg (HImode, operands[1]);
1534 (define_insn "*zero_extendqisi2_v850e"
1535 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1537 (match_operand:QI 1 "nonimmediate_operand" "0,r,T,m")))
1538 (clobber (reg:CC CC_REGNUM))]
1539 "(TARGET_V850E || TARGET_V850E2_ALL)"
1545 [(set_attr "length" "2,4,2,4")
1546 (set_attr "cc" "none_0hit,set_zn,none_0hit,none_0hit")])
1548 (define_insn "*zero_extendqisi2_v850"
1549 [(set (match_operand:SI 0 "register_operand" "=r")
1551 (match_operand:QI 1 "register_operand" "r")))
1552 (clobber (reg:CC CC_REGNUM))] ;; A lie, but we have to match the expander
1555 [(set_attr "length" "4")
1556 (set_attr "cc" "set_zn")])
1558 (define_expand "zero_extendqisi2"
1559 [(parallel [(set (match_operand:SI 0 "register_operand")
1561 (match_operand:QI 1 "nonimmediate_operand")))
1562 (clobber (reg:CC CC_REGNUM))])]
1565 if (! (TARGET_V850E || TARGET_V850E2_ALL))
1566 operands[1] = force_reg (QImode, operands[1]);
1569 ;;- sign extension instructions
1571 ;; ??? The extendhisi2 pattern should not emit shifts for v850e?
1573 (define_insn "*extendhisi_insn"
1574 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1575 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "0,Q,m")))
1576 (clobber (reg:CC CC_REGNUM))]
1577 "(TARGET_V850E || TARGET_V850E2_ALL)"
1582 [(set_attr "length" "2,2,4")
1583 (set_attr "cc" "none_0hit,none_0hit,none_0hit")])
1585 ;; ??? This is missing a sign extend from memory pattern to match the ld.h
1588 (define_expand "extendhisi2"
1589 [(parallel [(set (match_dup 2)
1590 (ashift:SI (match_operand:HI 1 "register_operand" "")
1592 (clobber (reg:CC CC_REGNUM))])
1593 (parallel [(set (match_operand:SI 0 "register_operand" "")
1594 (ashiftrt:SI (match_dup 2)
1596 (clobber (reg:CC CC_REGNUM))])]
1599 operands[1] = gen_lowpart (SImode, operands[1]);
1600 operands[2] = gen_reg_rtx (SImode);
1603 ;; ??? The extendqisi2 pattern should not emit shifts for v850e?
1605 (define_insn "*extendqisi_insn"
1606 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1607 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0,Q,m")))
1608 (clobber (reg:CC CC_REGNUM))]
1609 "(TARGET_V850E || TARGET_V850E2_ALL)"
1614 [(set_attr "length" "2,2,4")
1615 (set_attr "cc" "none_0hit,none_0hit,none_0hit")])
1617 ;; ??? This is missing a sign extend from memory pattern to match the ld.b
1620 (define_expand "extendqisi2"
1621 [(parallel [(set (match_dup 2)
1622 (ashift:SI (match_operand:QI 1 "register_operand" "")
1624 (clobber (reg:CC CC_REGNUM))])
1625 (parallel [(set (match_operand:SI 0 "register_operand" "")
1626 (ashiftrt:SI (match_dup 2)
1628 (clobber (reg:CC CC_REGNUM))])]
1631 operands[1] = gen_lowpart (SImode, operands[1]);
1632 operands[2] = gen_reg_rtx (SImode);
1635 ;; ----------------------------------------------------------------------
1637 ;; ----------------------------------------------------------------------
1639 (define_insn "ashlsi3"
1640 [(set (match_operand:SI 0 "register_operand" "=r,r")
1642 (match_operand:SI 1 "register_operand" "0,0")
1643 (match_operand:SI 2 "nonmemory_operand" "r,N")))
1644 (clobber (reg:CC CC_REGNUM))]
1649 [(set_attr "length" "4,2")
1650 (set_attr "cc" "set_zn")])
1652 (define_insn "ashlsi3_v850e2"
1653 [(set (match_operand:SI 0 "register_operand" "=r")
1655 (match_operand:SI 1 "register_operand" "r")
1656 (match_operand:SI 2 "nonmemory_operand" "r")))
1657 (clobber (reg:CC CC_REGNUM))]
1660 [(set_attr "length" "4")
1661 (set_attr "cc" "set_znv")])
1663 (define_insn "lshrsi3"
1664 [(set (match_operand:SI 0 "register_operand" "=r,r")
1666 (match_operand:SI 1 "register_operand" "0,0")
1667 (match_operand:SI 2 "nonmemory_operand" "r,N")))
1668 (clobber (reg:CC CC_REGNUM))]
1673 [(set_attr "length" "4,2")
1674 (set_attr "cc" "set_zn")])
1676 (define_insn "lshrsi3_v850e2"
1677 [(set (match_operand:SI 0 "register_operand" "=r")
1679 (match_operand:SI 1 "register_operand" "r")
1680 (match_operand:SI 2 "nonmemory_operand" "r")))
1681 (clobber (reg:CC CC_REGNUM))]
1684 [(set_attr "length" "4")
1685 (set_attr "cc" "set_zn")])
1687 (define_insn "ashrsi3"
1688 [(set (match_operand:SI 0 "register_operand" "=r,r")
1690 (match_operand:SI 1 "register_operand" "0,0")
1691 (match_operand:SI 2 "nonmemory_operand" "r,N")))
1692 (clobber (reg:CC CC_REGNUM))]
1697 [(set_attr "length" "4,2")
1698 (set_attr "cc" "set_zn, set_zn")])
1700 (define_insn "ashrsi3_v850e2"
1701 [(set (match_operand:SI 0 "register_operand" "=r")
1703 (match_operand:SI 1 "register_operand" "r")
1704 (match_operand:SI 2 "nonmemory_operand" "r")))
1705 (clobber (reg:CC CC_REGNUM))]
1708 [(set_attr "length" "4")
1709 (set_attr "cc" "set_zn")])
1711 ;; ----------------------------------------------------------------------
1712 ;; FIND FIRST BIT INSTRUCTION
1713 ;; ----------------------------------------------------------------------
1715 (define_insn "ffssi2"
1716 [(set (match_operand:SI 0 "register_operand" "=r")
1717 (ffs:SI (match_operand:SI 1 "register_operand" "r")))
1718 (clobber (reg:CC CC_REGNUM))]
1721 [(set_attr "length" "4")
1722 (set_attr "cc" "clobber")])
1724 ;; ----------------------------------------------------------------------
1725 ;; PROLOGUE/EPILOGUE
1726 ;; ----------------------------------------------------------------------
1727 (define_expand "prologue"
1735 (define_expand "epilogue"
1743 (define_insn "return_simple"
1747 [(set_attr "length" "2")
1748 (set_attr "cc" "none")])
1750 (define_insn "return_internal"
1755 [(set_attr "length" "2")
1756 (set_attr "cc" "none")])
1758 ;; ----------------------------------------------------------------------
1759 ;; v850e2V3 floating-point hardware support
1760 ;; ----------------------------------------------------------------------
1763 (define_insn "addsf3"
1764 [(set (match_operand:SF 0 "register_operand" "=r")
1765 (plus:SF (match_operand:SF 1 "register_operand" "r")
1766 (match_operand:SF 2 "register_operand" "r")))]
1769 [(set_attr "length" "4")
1770 (set_attr "cc" "none_0hit")
1771 (set_attr "type" "fpu")])
1773 (define_insn "adddf3"
1774 [(set (match_operand:DF 0 "even_reg_operand" "=r")
1775 (plus:DF (match_operand:DF 1 "even_reg_operand" "r")
1776 (match_operand:DF 2 "even_reg_operand" "r")))]
1779 [(set_attr "length" "4")
1780 (set_attr "cc" "none_0hit")
1781 (set_attr "type" "fpu")])
1783 (define_insn "subsf3"
1784 [(set (match_operand:SF 0 "register_operand" "=r")
1785 (minus:SF (match_operand:SF 1 "register_operand" "r")
1786 (match_operand:SF 2 "register_operand" "r")))]
1789 [(set_attr "length" "4")
1790 (set_attr "cc" "none_0hit")
1791 (set_attr "type" "fpu")])
1793 (define_insn "subdf3"
1794 [(set (match_operand:DF 0 "even_reg_operand" "=r")
1795 (minus:DF (match_operand:DF 1 "even_reg_operand" "r")
1796 (match_operand:DF 2 "even_reg_operand" "r")))]
1799 [(set_attr "length" "4")
1800 (set_attr "cc" "none_0hit")
1801 (set_attr "type" "fpu")])
1803 (define_insn "mulsf3"
1804 [(set (match_operand:SF 0 "register_operand" "=r")
1805 (mult:SF (match_operand:SF 1 "register_operand" "r")
1806 (match_operand:SF 2 "register_operand" "r")))]
1809 [(set_attr "length" "4")
1810 (set_attr "cc" "none_0hit")
1811 (set_attr "type" "fpu")])
1813 (define_insn "muldf3"
1814 [(set (match_operand:DF 0 "even_reg_operand" "=r")
1815 (mult:DF (match_operand:DF 1 "even_reg_operand" "r")
1816 (match_operand:DF 2 "even_reg_operand" "r")))]
1819 [(set_attr "length" "4")
1820 (set_attr "cc" "none_0hit")
1821 (set_attr "type" "fpu")])
1823 (define_insn "divsf3"
1824 [(set (match_operand:SF 0 "register_operand" "=r")
1825 (div:SF (match_operand:SF 1 "register_operand" "r")
1826 (match_operand:SF 2 "register_operand" "r")))]
1829 [(set_attr "length" "4")
1830 (set_attr "cc" "none_0hit")
1831 (set_attr "type" "fpu")])
1833 (define_insn "divdf3"
1834 [(set (match_operand:DF 0 "register_operand" "=r")
1835 (div:DF (match_operand:DF 1 "even_reg_operand" "r")
1836 (match_operand:DF 2 "even_reg_operand" "r")))]
1839 [(set_attr "length" "4")
1840 (set_attr "cc" "none_0hit")
1841 (set_attr "type" "fpu")])
1843 (define_insn "minsf3"
1844 [(set (match_operand:SF 0 "register_operand" "=r")
1845 (smin:SF (match_operand:SF 1 "reg_or_0_operand" "r")
1846 (match_operand:SF 2 "reg_or_0_operand" "r")))]
1849 [(set_attr "length" "4")
1850 (set_attr "cc" "none_0hit")
1851 (set_attr "type" "fpu")])
1853 (define_insn "mindf3"
1854 [(set (match_operand:DF 0 "even_reg_operand" "=r")
1855 (smin:DF (match_operand:DF 1 "even_reg_operand" "r")
1856 (match_operand:DF 2 "even_reg_operand" "r")))]
1859 [(set_attr "length" "4")
1860 (set_attr "cc" "none_0hit")
1861 (set_attr "type" "fpu")])
1863 (define_insn "maxsf3"
1864 [(set (match_operand:SF 0 "register_operand" "=r")
1865 (smax:SF (match_operand:SF 1 "reg_or_0_operand" "r")
1866 (match_operand:SF 2 "reg_or_0_operand" "r")))]
1869 [(set_attr "length" "4")
1870 (set_attr "cc" "none_0hit")
1871 (set_attr "type" "fpu")])
1873 (define_insn "maxdf3"
1874 [(set (match_operand:DF 0 "even_reg_operand" "=r")
1875 (smax:DF (match_operand:DF 1 "even_reg_operand" "r")
1876 (match_operand:DF 2 "even_reg_operand" "r")))]
1879 [(set_attr "length" "4")
1880 (set_attr "cc" "none_0hit")
1881 (set_attr "type" "fpu")])
1883 (define_insn "abssf2"
1884 [(set (match_operand:SF 0 "register_operand" "=r")
1885 (abs:SF (match_operand:SF 1 "register_operand" "r")))]
1888 [(set_attr "length" "4")
1889 (set_attr "cc" "none_0hit")
1890 (set_attr "type" "fpu")])
1892 (define_insn "absdf2"
1893 [(set (match_operand:DF 0 "even_reg_operand" "=r")
1894 (abs:DF (match_operand:DF 1 "even_reg_operand" "r")))]
1897 [(set_attr "length" "4")
1898 (set_attr "cc" "none_0hit")
1899 (set_attr "type" "fpu")])
1901 (define_insn "negsf2"
1902 [(set (match_operand:SF 0 "register_operand" "=r")
1903 (neg:SF (match_operand:SF 1 "register_operand" "r")))]
1906 [(set_attr "length" "4")
1907 (set_attr "cc" "none_0hit")
1908 (set_attr "type" "fpu")])
1910 (define_insn "negdf2"
1911 [(set (match_operand:DF 0 "even_reg_operand" "=r")
1912 (neg:DF (match_operand:DF 1 "even_reg_operand" "r")))]
1915 [(set_attr "length" "4")
1916 (set_attr "cc" "none_0hit")
1917 (set_attr "type" "fpu")])
1920 (define_insn "sqrtsf2"
1921 [(set (match_operand:SF 0 "register_operand" "=r")
1922 (sqrt:SF (match_operand:SF 1 "register_operand" "r")))]
1925 [(set_attr "length" "4")
1926 (set_attr "cc" "none_0hit")
1927 (set_attr "type" "fpu")])
1929 (define_insn "sqrtdf2"
1930 [(set (match_operand:DF 0 "even_reg_operand" "=r")
1931 (sqrt:DF (match_operand:DF 1 "even_reg_operand" "r")))]
1934 [(set_attr "length" "4")
1935 (set_attr "cc" "none_0hit")
1936 (set_attr "type" "fpu")])
1939 (define_insn "fix_truncsfsi2"
1940 [(set (match_operand:SI 0 "register_operand" "=r")
1941 (fix:SI (match_operand:SF 1 "register_operand" "r")))]
1944 [(set_attr "length" "4")
1945 (set_attr "cc" "none_0hit")
1946 (set_attr "type" "fpu")])
1948 (define_insn "fixuns_truncsfsi2"
1949 [(set (match_operand:SI 0 "register_operand" "=r")
1950 (unsigned_fix:SI (match_operand:SF 1 "register_operand" "r")))]
1953 [(set_attr "length" "4")
1954 (set_attr "cc" "none_0hit")
1955 (set_attr "type" "fpu")]
1958 (define_insn "fix_truncdfsi2"
1959 [(set (match_operand:SI 0 "register_operand" "=r")
1960 (fix:SI (match_operand:DF 1 "even_reg_operand" "r")))]
1963 [(set_attr "length" "4")
1964 (set_attr "cc" "none_0hit")
1965 (set_attr "type" "fpu")])
1967 (define_insn "fixuns_truncdfsi2"
1968 [(set (match_operand:SI 0 "register_operand" "=r")
1969 (unsigned_fix:SI (match_operand:DF 1 "even_reg_operand" "r")))]
1972 [(set_attr "length" "4")
1973 (set_attr "cc" "none_0hit")
1974 (set_attr "type" "fpu")]
1977 (define_insn "fix_truncsfdi2"
1978 [(set (match_operand:DI 0 "register_operand" "=r")
1979 (fix:DI (match_operand:SF 1 "register_operand" "r")))]
1982 [(set_attr "length" "4")
1983 (set_attr "cc" "none_0hit")
1984 (set_attr "type" "fpu")])
1986 (define_insn "fixuns_truncsfdi2"
1987 [(set (match_operand:DI 0 "register_operand" "=r")
1988 (unsigned_fix:DI (match_operand:SF 1 "register_operand" "r")))]
1991 [(set_attr "length" "4")
1992 (set_attr "cc" "none_0hit")
1993 (set_attr "type" "fpu")]
1996 (define_insn "fix_truncdfdi2"
1997 [(set (match_operand:DI 0 "register_operand" "=r")
1998 (fix:DI (match_operand:DF 1 "even_reg_operand" "r")))]
2001 [(set_attr "length" "4")
2002 (set_attr "cc" "none_0hit")
2003 (set_attr "type" "fpu")])
2005 (define_insn "fixuns_truncdfdi2"
2006 [(set (match_operand:DI 0 "register_operand" "=r")
2007 (unsigned_fix:DI (match_operand:DF 1 "even_reg_operand" "r")))]
2010 [(set_attr "length" "4")
2011 (set_attr "cc" "none_0hit")
2012 (set_attr "type" "fpu")]
2016 (define_insn "floatsisf2"
2017 [(set (match_operand:SF 0 "register_operand" "=r")
2018 (float:SF (match_operand:SI 1 "reg_or_0_operand" "rI")))]
2021 [(set_attr "length" "4")
2022 (set_attr "cc" "none_0hit")
2023 (set_attr "type" "fpu")])
2025 (define_insn "unsfloatsisf2"
2026 [(set (match_operand:SF 0 "register_operand" "=r")
2027 (unsigned_float:SF (match_operand:SI 1 "reg_or_0_operand" "rI")))]
2030 [(set_attr "length" "4")
2031 (set_attr "cc" "none_0hit")
2032 (set_attr "type" "fpu")])
2034 (define_insn "floatsidf2"
2035 [(set (match_operand:DF 0 "even_reg_operand" "=r")
2036 (float:DF (match_operand:SI 1 "reg_or_0_operand" "rI")))]
2039 [(set_attr "length" "4")
2040 (set_attr "cc" "none_0hit")
2041 (set_attr "type" "fpu")])
2043 (define_insn "unsfloatsidf2"
2044 [(set (match_operand:DF 0 "even_reg_operand" "=r")
2045 (unsigned_float:DF (match_operand:SI 1 "reg_or_0_operand" "rI")))]
2048 [(set_attr "length" "4")
2049 (set_attr "cc" "none_0hit")
2050 (set_attr "type" "fpu")])
2052 (define_insn "floatdisf2"
2053 [(set (match_operand:SF 0 "even_reg_operand" "=r")
2054 (float:SF (match_operand:DI 1 "reg_or_0_operand" "rI")))]
2057 [(set_attr "length" "4")
2058 (set_attr "cc" "none_0hit")
2059 (set_attr "type" "fpu")])
2061 (define_insn "unsfloatdisf2"
2062 [(set (match_operand:SF 0 "even_reg_operand" "=r")
2063 (unsigned_float:SF (match_operand:DI 1 "reg_or_0_operand" "rI")))]
2066 [(set_attr "length" "4")
2067 (set_attr "cc" "none_0hit")
2068 (set_attr "type" "fpu")])
2070 (define_insn "floatdidf2"
2071 [(set (match_operand:DF 0 "even_reg_operand" "=r")
2072 (float:DF (match_operand:DI 1 "reg_or_0_operand" "rI")))]
2075 [(set_attr "length" "4")
2076 (set_attr "cc" "none_0hit")
2077 (set_attr "type" "fpu")])
2079 (define_insn "unsfloatdidf2"
2080 [(set (match_operand:DF 0 "even_reg_operand" "=r")
2081 (unsigned_float:DF (match_operand:DI 1 "reg_or_0_operand" "rI")))]
2084 [(set_attr "length" "4")
2085 (set_attr "cc" "none_0hit")
2086 (set_attr "type" "fpu")])
2088 ;; single-float -> double-float
2089 (define_insn "extendsfdf2"
2090 [(set (match_operand:DF 0 "even_reg_operand" "=r")
2092 (match_operand:SF 1 "reg_or_0_operand" "rI")))]
2095 [(set_attr "length" "4")
2096 (set_attr "cc" "none_0hit")
2097 (set_attr "type" "fpu")])
2099 ;; double-float -> single-float
2100 (define_insn "truncdfsf2"
2101 [(set (match_operand:SF 0 "register_operand" "=r")
2103 (match_operand:DF 1 "even_reg_operand" "r")))]
2106 [(set_attr "length" "4")
2107 (set_attr "cc" "none_0hit")
2108 (set_attr "type" "fpu")])
2111 ;; ---------------- special insns
2115 (define_insn "recipsf2"
2116 [(set (match_operand:SF 0 "register_operand" "=r")
2117 (div:SF (match_operand:SF 1 "const_float_1_operand" "")
2118 (match_operand:SF 2 "register_operand" "r")))]
2121 [(set_attr "length" "4")
2122 (set_attr "cc" "none_0hit")
2123 (set_attr "type" "fpu")])
2125 (define_insn "recipdf2"
2126 [(set (match_operand:DF 0 "even_reg_operand" "=r")
2127 (div:DF (match_operand:DF 1 "const_float_1_operand" "")
2128 (match_operand:DF 2 "even_reg_operand" "r")))]
2131 [(set_attr "length" "4")
2132 (set_attr "cc" "none_0hit")
2133 (set_attr "type" "fpu")])
2135 ;;; reciprocal of square-root
2136 (define_insn "rsqrtsf2"
2137 [(set (match_operand:SF 0 "register_operand" "=r")
2138 (div:SF (match_operand:SF 1 "const_float_1_operand" "")
2139 (sqrt:SF (match_operand:SF 2 "register_operand" "r"))))]
2142 [(set_attr "length" "4")
2143 (set_attr "cc" "none_0hit")
2144 (set_attr "type" "fpu")])
2146 (define_insn "rsqrtdf2"
2147 [(set (match_operand:DF 0 "even_reg_operand" "=r")
2148 (div:DF (match_operand:DF 1 "const_float_1_operand" "")
2149 (sqrt:DF (match_operand:DF 2 "even_reg_operand" "r"))))]
2152 [(set_attr "length" "4")
2153 (set_attr "cc" "none_0hit")
2154 (set_attr "type" "fpu")])
2157 (define_insn "fmasf4"
2158 [(set (match_operand:SF 0 "register_operand" "=r")
2159 (fma:SF (match_operand:SF 1 "register_operand" "r")
2160 (match_operand:SF 2 "register_operand" "r")
2161 (match_operand:SF 3 "register_operand" "r")))]
2163 "maddf.s %2,%1,%3,%0"
2164 [(set_attr "length" "4")
2165 (set_attr "cc" "none_0hit")
2166 (set_attr "type" "fpu")])
2168 ;;; multiply-subtract
2169 (define_insn "fmssf4"
2170 [(set (match_operand:SF 0 "register_operand" "=r")
2171 (fma:SF (match_operand:SF 1 "register_operand" "r")
2172 (match_operand:SF 2 "register_operand" "r")
2173 (neg:SF (match_operand:SF 3 "register_operand" "r"))))]
2175 "msubf.s %2,%1,%3,%0"
2176 [(set_attr "length" "4")
2177 (set_attr "cc" "none_0hit")
2178 (set_attr "type" "fpu")])
2180 ;;; negative-multiply-add
2181 (define_insn "fnmasf4"
2182 [(set (match_operand:SF 0 "register_operand" "=r")
2183 (neg:SF (fma:SF (match_operand:SF 1 "register_operand" "r")
2184 (match_operand:SF 2 "register_operand" "r")
2185 (match_operand:SF 3 "register_operand" "r"))))]
2187 "nmaddf.s %2,%1,%3,%0"
2188 [(set_attr "length" "4")
2189 (set_attr "cc" "none_0hit")
2190 (set_attr "type" "fpu")])
2192 ;; negative-multiply-subtract
2193 (define_insn "fnmssf4"
2194 [(set (match_operand:SF 0 "register_operand" "=r")
2195 (neg:SF (fma:SF (match_operand:SF 1 "register_operand" "r")
2196 (match_operand:SF 2 "register_operand" "r")
2197 (neg:SF (match_operand:SF 3 "register_operand" "r")))))]
2199 "nmsubf.s %2,%1,%3,%0"
2200 [(set_attr "length" "4")
2201 (set_attr "cc" "none_0hit")
2202 (set_attr "type" "fpu")])
2204 ; ---------------- comparison/conditionals
2208 (define_insn "cmpsf_le_insn"
2209 [(set (reg:CC_FPU_LE FCC_REGNUM)
2210 (compare:CC_FPU_LE (match_operand:SF 0 "register_operand" "r")
2211 (match_operand:SF 1 "register_operand" "r")))]
2214 [(set_attr "length" "4")
2215 (set_attr "cc" "none_0hit")
2216 (set_attr "type" "fpu")])
2218 (define_insn "cmpsf_lt_insn"
2219 [(set (reg:CC_FPU_LT FCC_REGNUM)
2220 (compare:CC_FPU_LT (match_operand:SF 0 "register_operand" "r")
2221 (match_operand:SF 1 "register_operand" "r")))]
2224 [(set_attr "length" "4")
2225 (set_attr "cc" "none_0hit")
2226 (set_attr "type" "fpu")])
2228 (define_insn "cmpsf_ge_insn"
2229 [(set (reg:CC_FPU_GE FCC_REGNUM)
2230 (compare:CC_FPU_GE (match_operand:SF 0 "register_operand" "r")
2231 (match_operand:SF 1 "register_operand" "r")))]
2234 [(set_attr "length" "4")
2235 (set_attr "cc" "none_0hit")
2236 (set_attr "type" "fpu")])
2238 (define_insn "cmpsf_gt_insn"
2239 [(set (reg:CC_FPU_GT FCC_REGNUM)
2240 (compare:CC_FPU_GT (match_operand:SF 0 "register_operand" "r")
2241 (match_operand:SF 1 "register_operand" "r")))]
2244 [(set_attr "length" "4")
2245 (set_attr "cc" "none_0hit")
2246 (set_attr "type" "fpu")])
2248 (define_insn "cmpsf_eq_insn"
2249 [(set (reg:CC_FPU_EQ FCC_REGNUM)
2250 (compare:CC_FPU_EQ (match_operand:SF 0 "register_operand" "r")
2251 (match_operand:SF 1 "register_operand" "r")))]
2254 [(set_attr "length" "4")
2255 (set_attr "cc" "none_0hit")
2256 (set_attr "type" "fpu")])
2258 (define_insn "cmpsf_ne_insn"
2259 [(set (reg:CC_FPU_NE FCC_REGNUM)
2260 (compare:CC_FPU_NE (match_operand:SF 0 "register_operand" "r")
2261 (match_operand:SF 1 "register_operand" "r")))]
2263 "cmpf.s neq,%z1,%z0"
2264 [(set_attr "length" "4")
2265 (set_attr "cc" "none_0hit")
2266 (set_attr "type" "fpu")])
2270 (define_insn "cmpdf_le_insn"
2271 [(set (reg:CC_FPU_LE FCC_REGNUM)
2272 (compare:CC_FPU_LE (match_operand:DF 0 "even_reg_operand" "r")
2273 (match_operand:DF 1 "even_reg_operand" "r")))]
2276 [(set_attr "length" "4")
2277 (set_attr "cc" "none_0hit")
2278 (set_attr "type" "fpu")])
2280 (define_insn "cmpdf_lt_insn"
2281 [(set (reg:CC_FPU_LT FCC_REGNUM)
2282 (compare:CC_FPU_LT (match_operand:DF 0 "even_reg_operand" "r")
2283 (match_operand:DF 1 "even_reg_operand" "r")))]
2286 [(set_attr "length" "4")
2287 (set_attr "cc" "none_0hit")
2288 (set_attr "type" "fpu")])
2290 (define_insn "cmpdf_ge_insn"
2291 [(set (reg:CC_FPU_GE FCC_REGNUM)
2292 (compare:CC_FPU_GE (match_operand:DF 0 "even_reg_operand" "r")
2293 (match_operand:DF 1 "even_reg_operand" "r")))]
2296 [(set_attr "length" "4")
2297 (set_attr "cc" "none_0hit")
2298 (set_attr "type" "fpu")])
2300 (define_insn "cmpdf_gt_insn"
2301 [(set (reg:CC_FPU_GT FCC_REGNUM)
2302 (compare:CC_FPU_GT (match_operand:DF 0 "even_reg_operand" "r")
2303 (match_operand:DF 1 "even_reg_operand" "r")))]
2306 [(set_attr "length" "4")
2307 (set_attr "cc" "none_0hit")
2308 (set_attr "type" "fpu")])
2310 (define_insn "cmpdf_eq_insn"
2311 [(set (reg:CC_FPU_EQ FCC_REGNUM)
2312 (compare:CC_FPU_EQ (match_operand:DF 0 "even_reg_operand" "r")
2313 (match_operand:DF 1 "even_reg_operand" "r")))]
2316 [(set_attr "length" "4")
2317 (set_attr "cc" "none_0hit")
2318 (set_attr "type" "fpu")])
2320 (define_insn "cmpdf_ne_insn"
2321 [(set (reg:CC_FPU_NE FCC_REGNUM)
2322 (compare:CC_FPU_NE (match_operand:DF 0 "even_reg_operand" "r")
2323 (match_operand:DF 1 "even_reg_operand" "r")))]
2325 "cmpf.d neq,%z1,%z0"
2326 [(set_attr "length" "4")
2327 (set_attr "cc" "none_0hit")
2328 (set_attr "type" "fpu")])
2332 ;; Transfer a v850e2v3 fcc to the Z bit of CC0 (this is necessary to do a
2333 ;; conditional branch based on a floating-point compare)
2336 (define_insn "trfsr"
2337 [(set (match_operand 0 "" "") (match_operand 1 "" ""))]
2339 && GET_MODE(operands[0]) == GET_MODE(operands[1])
2340 && GET_CODE(operands[0]) == REG && REGNO (operands[0]) == CC_REGNUM
2341 && GET_CODE(operands[1]) == REG && REGNO (operands[1]) == FCC_REGNUM
2342 && (GET_MODE(operands[0]) == CC_FPU_LEmode
2343 || GET_MODE(operands[0]) == CC_FPU_GEmode
2344 || GET_MODE(operands[0]) == CC_FPU_LTmode
2345 || GET_MODE(operands[0]) == CC_FPU_GTmode
2346 || GET_MODE(operands[0]) == CC_FPU_EQmode
2347 || GET_MODE(operands[0]) == CC_FPU_NEmode)"
2349 [(set_attr "length" "4")
2350 (set_attr "cc" "set_z")
2351 (set_attr "type" "fpu")])
2354 ;; Floating-point conditional moves for the v850e2v3.
2357 ;; The actual v850e2v3 conditional move instructions
2359 (define_insn "movsfcc_z_insn"
2360 [(set (match_operand:SF 0 "register_operand" "=r")
2362 (match_operand 3 "v850_float_z_comparison_operator" "")
2363 (match_operand:SF 1 "reg_or_0_operand" "rIG")
2364 (match_operand:SF 2 "reg_or_0_operand" "rIG")))]
2366 "cmovf.s 0,%z1,%z2,%0"
2367 [(set_attr "cc" "clobber")]) ;; ??? or none_0hit
2369 (define_insn "movsfcc_nz_insn"
2370 [(set (match_operand:SF 0 "register_operand" "=r")
2372 (match_operand 3 "v850_float_nz_comparison_operator" "")
2373 (match_operand:SF 1 "reg_or_0_operand" "rIG")
2374 (match_operand:SF 2 "reg_or_0_operand" "rIG")))]
2376 "cmovf.s 0,%z2,%z1,%0"
2377 [(set_attr "cc" "clobber")]) ;; ??? or none_0hit
2379 (define_insn "movdfcc_z_insn"
2380 [(set (match_operand:DF 0 "even_reg_operand" "=r")
2382 (match_operand 3 "v850_float_z_comparison_operator" "")
2383 (match_operand:DF 1 "even_reg_operand" "r")
2384 (match_operand:DF 2 "even_reg_operand" "r")))]
2386 "cmovf.d 0,%z1,%z2,%0"
2387 [(set_attr "cc" "clobber")]) ;; ??? or none_0hit
2389 (define_insn "movdfcc_nz_insn"
2390 [(set (match_operand:DF 0 "even_reg_operand" "=r")
2392 (match_operand 3 "v850_float_nz_comparison_operator" "")
2393 (match_operand:DF 1 "even_reg_operand" "r")
2394 (match_operand:DF 2 "even_reg_operand" "r")))]
2396 "cmovf.d 0,%z2,%z1,%0"
2397 [(set_attr "cc" "clobber")]) ;; ??? or none_0hit
2399 (define_insn "movedfcc_z_zero"
2400 [(set (match_operand:DF 0 "register_operand" "=r")
2402 (match_operand 3 "v850_float_z_comparison_operator" "")
2403 (match_operand:DF 1 "reg_or_0_operand" "rIG")
2404 (match_operand:DF 2 "reg_or_0_operand" "rIG")))]
2406 "cmovf.s 0,%z1,%z2,%0 ; cmovf.s 0,%Z1,%Z2,%R0"
2407 [(set_attr "length" "8")
2408 (set_attr "cc" "clobber")]) ;; ??? or none_0hit
2410 (define_insn "movedfcc_nz_zero"
2411 [(set (match_operand:DF 0 "register_operand" "=r")
2413 (match_operand 3 "v850_float_nz_comparison_operator" "")
2414 (match_operand:DF 1 "reg_or_0_operand" "rIG")
2415 (match_operand:DF 2 "reg_or_0_operand" "rIG")))]
2417 "cmovf.s 0,%z2,%z1,%0 ; cmovf.s 0,%Z2,%Z1,%R0"
2418 [(set_attr "length" "8")
2419 (set_attr "cc" "clobber")]) ;; ??? or none_0hit
2422 ;; ----------------------------------------------------------------------
2423 ;; HELPER INSTRUCTIONS for saving the prologue and epilogue registers
2424 ;; ----------------------------------------------------------------------
2426 ;; This pattern will match a stack adjust RTX followed by any number of push
2427 ;; RTXs. These RTXs will then be turned into a suitable call to a worker
2431 ;; Actually, convert the RTXs into a PREPARE instruction.
2435 [(match_parallel 0 "pattern_is_ok_for_prepare"
2437 (plus:SI (reg:SI 3) (match_operand:SI 1 "immediate_operand" "i")))
2438 (set (mem:SI (plus:SI (reg:SI 3)
2439 (match_operand:SI 2 "immediate_operand" "i")))
2440 (match_operand:SI 3 "register_is_ok_for_epilogue" "r"))])]
2441 "TARGET_PROLOG_FUNCTION && (TARGET_V850E || TARGET_V850E2_ALL)"
2443 return construct_prepare_instruction (operands[0]);
2445 [(set_attr "length" "4")
2446 (set_attr "cc" "clobber")])
2449 [(match_parallel 0 "pattern_is_ok_for_prologue"
2451 (plus:SI (reg:SI 3) (match_operand:SI 1 "immediate_operand" "i")))
2452 (set (mem:SI (plus:SI (reg:SI 3)
2453 (match_operand:SI 2 "immediate_operand" "i")))
2454 (match_operand:SI 3 "register_is_ok_for_epilogue" "r"))])]
2455 "TARGET_PROLOG_FUNCTION"
2457 return construct_save_jarl (operands[0]);
2459 [(set (attr "length") (if_then_else (eq_attr "long_calls" "yes")
2461 (const_string "4")))
2462 (set_attr "cc" "clobber")])
2465 ;; Actually, turn the RTXs into a DISPOSE instruction.
2468 [(match_parallel 0 "pattern_is_ok_for_dispose"
2471 (plus:SI (reg:SI 3) (match_operand:SI 1 "immediate_operand" "i")))
2472 (set (match_operand:SI 2 "register_is_ok_for_epilogue" "=r")
2473 (mem:SI (plus:SI (reg:SI 3)
2474 (match_operand:SI 3 "immediate_operand" "i"))))])]
2475 "TARGET_PROLOG_FUNCTION && (TARGET_V850E || TARGET_V850E2_ALL)"
2477 return construct_dispose_instruction (operands[0]);
2479 [(set_attr "length" "4")
2480 (set_attr "cc" "clobber")])
2482 ;; This pattern will match a return RTX followed by any number of pop RTXs
2483 ;; and possible a stack adjustment as well. These RTXs will be turned into
2484 ;; a suitable call to a worker function.
2487 [(match_parallel 0 "pattern_is_ok_for_epilogue"
2490 (plus:SI (reg:SI 3) (match_operand:SI 1 "immediate_operand" "i")))
2491 (set (match_operand:SI 2 "register_is_ok_for_epilogue" "=r")
2492 (mem:SI (plus:SI (reg:SI 3)
2493 (match_operand:SI 3 "immediate_operand" "i"))))])]
2494 "TARGET_PROLOG_FUNCTION"
2496 return construct_restore_jr (operands[0]);
2498 [(set (attr "length") (if_then_else (eq_attr "long_calls" "yes")
2500 (const_string "4")))
2501 (set_attr "cc" "clobber")])
2503 ;; Initialize an interrupt function. Do not depend on TARGET_PROLOG_FUNCTION.
2504 (define_insn "callt_save_interrupt"
2505 [(unspec_volatile [(const_int 0)] 2)]
2506 "(TARGET_V850E || TARGET_V850E2_ALL) && !TARGET_DISABLE_CALLT"
2507 ;; The CALLT instruction stores the next address of CALLT to CTPC register
2508 ;; without saving its previous value. So if the interrupt handler
2509 ;; or its caller could possibly execute the CALLT insn, save_interrupt
2510 ;; MUST NOT be called via CALLT.
2512 output_asm_insn ("addi -28, sp, sp", operands);
2513 output_asm_insn ("st.w r1, 24[sp]", operands);
2514 output_asm_insn ("st.w r10, 12[sp]", operands);
2515 output_asm_insn ("st.w r11, 16[sp]", operands);
2516 output_asm_insn ("stsr ctpc, r10", operands);
2517 output_asm_insn ("st.w r10, 20[sp]", operands);
2518 output_asm_insn ("stsr ctpsw, r10", operands);
2519 output_asm_insn ("st.w r10, 24[sp]", operands);
2520 output_asm_insn ("callt ctoff(__callt_save_interrupt)", operands);
2523 [(set_attr "length" "26")
2524 (set_attr "cc" "clobber")])
2526 (define_insn "callt_return_interrupt"
2527 [(unspec_volatile [(const_int 0)] 3)]
2528 "(TARGET_V850E || TARGET_V850E2_ALL) && !TARGET_DISABLE_CALLT"
2529 "callt ctoff(__callt_return_interrupt)"
2530 [(set_attr "length" "2")
2531 (set_attr "cc" "clobber")])
2533 (define_insn "save_interrupt"
2534 [(set (reg:SI 3) (plus:SI (reg:SI 3) (const_int -20)))
2535 (set (mem:SI (plus:SI (reg:SI 3) (const_int -20))) (reg:SI 30))
2536 (set (mem:SI (plus:SI (reg:SI 3) (const_int -16))) (reg:SI 4))
2537 (set (mem:SI (plus:SI (reg:SI 3) (const_int -12))) (reg:SI 1))
2538 (set (mem:SI (plus:SI (reg:SI 3) (const_int -8))) (reg:SI 10))
2539 (set (mem:SI (plus:SI (reg:SI 3) (const_int -4))) (reg:SI 11))]
2542 if (TARGET_PROLOG_FUNCTION && !TARGET_LONG_CALLS)
2543 return "addi -20,sp,sp \; st.w r11,16[sp] \; st.w r10,12[sp] \; jarl __save_interrupt,r10";
2546 output_asm_insn ("addi -20, sp, sp", operands);
2547 output_asm_insn ("st.w r11, 16[sp]", operands);
2548 output_asm_insn ("st.w r10, 12[sp]", operands);
2549 output_asm_insn ("st.w ep, 0[sp]", operands);
2550 output_asm_insn ("st.w gp, 4[sp]", operands);
2551 output_asm_insn ("st.w r1, 8[sp]", operands);
2552 output_asm_insn ("movhi hi(__ep), r0, ep", operands);
2553 output_asm_insn ("movea lo(__ep), ep, ep", operands);
2554 output_asm_insn ("movhi hi(__gp), r0, gp", operands);
2555 output_asm_insn ("movea lo(__gp), gp, gp", operands);
2559 [(set (attr "length")
2560 (if_then_else (match_test "TARGET_LONG_CALLS")
2563 (set_attr "cc" "clobber")])
2565 ;; Restore r1, r4, r10, and return from the interrupt
2566 (define_insn "return_interrupt"
2568 (set (reg:SI 3) (plus:SI (reg:SI 3) (const_int 20)))
2569 (set (reg:SI 11) (mem:SI (plus:SI (reg:SI 3) (const_int 16))))
2570 (set (reg:SI 10) (mem:SI (plus:SI (reg:SI 3) (const_int 12))))
2571 (set (reg:SI 1) (mem:SI (plus:SI (reg:SI 3) (const_int 8))))
2572 (set (reg:SI 4) (mem:SI (plus:SI (reg:SI 3) (const_int 4))))
2573 (set (reg:SI 30) (mem:SI (reg:SI 3)))]
2576 if (TARGET_PROLOG_FUNCTION && !TARGET_LONG_CALLS)
2577 return "jr __return_interrupt";
2580 output_asm_insn ("ld.w 0[sp], ep", operands);
2581 output_asm_insn ("ld.w 4[sp], gp", operands);
2582 output_asm_insn ("ld.w 8[sp], r1", operands);
2583 output_asm_insn ("ld.w 12[sp], r10", operands);
2584 output_asm_insn ("ld.w 16[sp], r11", operands);
2585 output_asm_insn ("addi 20, sp, sp", operands);
2586 output_asm_insn ("reti", operands);
2590 [(set (attr "length")
2591 (if_then_else (match_test "TARGET_LONG_CALLS")
2594 (set_attr "cc" "clobber")])
2596 ;; Save all registers except for the registers saved in save_interrupt when
2597 ;; an interrupt function makes a call.
2598 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
2599 ;; all of memory. This blocks insns from being moved across this point.
2600 ;; This is needed because the rest of the compiler is not ready to handle
2601 ;; insns this complicated.
2603 (define_insn "callt_save_all_interrupt"
2604 [(unspec_volatile [(const_int 0)] 0)]
2605 "(TARGET_V850E || TARGET_V850E2_ALL) && !TARGET_DISABLE_CALLT"
2606 "callt ctoff(__callt_save_all_interrupt)"
2607 [(set_attr "length" "2")
2608 (set_attr "cc" "none")])
2610 (define_insn "save_all_interrupt"
2611 [(unspec_volatile [(const_int 0)] 0)]
2614 if (TARGET_PROLOG_FUNCTION && !TARGET_LONG_CALLS)
2615 return "jarl __save_all_interrupt,r10";
2617 output_asm_insn ("addi -120, sp, sp", operands);
2621 output_asm_insn ("mov ep, r1", operands);
2622 output_asm_insn ("mov sp, ep", operands);
2623 output_asm_insn ("sst.w r31, 116[ep]", operands);
2624 output_asm_insn ("sst.w r2, 112[ep]", operands);
2625 output_asm_insn ("sst.w gp, 108[ep]", operands);
2626 output_asm_insn ("sst.w r6, 104[ep]", operands);
2627 output_asm_insn ("sst.w r7, 100[ep]", operands);
2628 output_asm_insn ("sst.w r8, 96[ep]", operands);
2629 output_asm_insn ("sst.w r9, 92[ep]", operands);
2630 output_asm_insn ("sst.w r11, 88[ep]", operands);
2631 output_asm_insn ("sst.w r12, 84[ep]", operands);
2632 output_asm_insn ("sst.w r13, 80[ep]", operands);
2633 output_asm_insn ("sst.w r14, 76[ep]", operands);
2634 output_asm_insn ("sst.w r15, 72[ep]", operands);
2635 output_asm_insn ("sst.w r16, 68[ep]", operands);
2636 output_asm_insn ("sst.w r17, 64[ep]", operands);
2637 output_asm_insn ("sst.w r18, 60[ep]", operands);
2638 output_asm_insn ("sst.w r19, 56[ep]", operands);
2639 output_asm_insn ("sst.w r20, 52[ep]", operands);
2640 output_asm_insn ("sst.w r21, 48[ep]", operands);
2641 output_asm_insn ("sst.w r22, 44[ep]", operands);
2642 output_asm_insn ("sst.w r23, 40[ep]", operands);
2643 output_asm_insn ("sst.w r24, 36[ep]", operands);
2644 output_asm_insn ("sst.w r25, 32[ep]", operands);
2645 output_asm_insn ("sst.w r26, 28[ep]", operands);
2646 output_asm_insn ("sst.w r27, 24[ep]", operands);
2647 output_asm_insn ("sst.w r28, 20[ep]", operands);
2648 output_asm_insn ("sst.w r29, 16[ep]", operands);
2649 output_asm_insn ("mov r1, ep", operands);
2653 output_asm_insn ("st.w r31, 116[sp]", operands);
2654 output_asm_insn ("st.w r2, 112[sp]", operands);
2655 output_asm_insn ("st.w gp, 108[sp]", operands);
2656 output_asm_insn ("st.w r6, 104[sp]", operands);
2657 output_asm_insn ("st.w r7, 100[sp]", operands);
2658 output_asm_insn ("st.w r8, 96[sp]", operands);
2659 output_asm_insn ("st.w r9, 92[sp]", operands);
2660 output_asm_insn ("st.w r11, 88[sp]", operands);
2661 output_asm_insn ("st.w r12, 84[sp]", operands);
2662 output_asm_insn ("st.w r13, 80[sp]", operands);
2663 output_asm_insn ("st.w r14, 76[sp]", operands);
2664 output_asm_insn ("st.w r15, 72[sp]", operands);
2665 output_asm_insn ("st.w r16, 68[sp]", operands);
2666 output_asm_insn ("st.w r17, 64[sp]", operands);
2667 output_asm_insn ("st.w r18, 60[sp]", operands);
2668 output_asm_insn ("st.w r19, 56[sp]", operands);
2669 output_asm_insn ("st.w r20, 52[sp]", operands);
2670 output_asm_insn ("st.w r21, 48[sp]", operands);
2671 output_asm_insn ("st.w r22, 44[sp]", operands);
2672 output_asm_insn ("st.w r23, 40[sp]", operands);
2673 output_asm_insn ("st.w r24, 36[sp]", operands);
2674 output_asm_insn ("st.w r25, 32[sp]", operands);
2675 output_asm_insn ("st.w r26, 28[sp]", operands);
2676 output_asm_insn ("st.w r27, 24[sp]", operands);
2677 output_asm_insn ("st.w r28, 20[sp]", operands);
2678 output_asm_insn ("st.w r29, 16[sp]", operands);
2683 [(set (attr "length")
2684 (if_then_else (match_test "TARGET_LONG_CALLS")
2688 (set_attr "cc" "clobber")])
2690 (define_insn "_save_all_interrupt"
2691 [(unspec_volatile [(const_int 0)] 0)]
2692 "TARGET_V850 && ! TARGET_LONG_CALLS"
2693 "jarl __save_all_interrupt,r10"
2694 [(set_attr "length" "4")
2695 (set_attr "cc" "clobber")])
2697 ;; Restore all registers saved when an interrupt function makes a call.
2698 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
2699 ;; all of memory. This blocks insns from being moved across this point.
2700 ;; This is needed because the rest of the compiler is not ready to handle
2701 ;; insns this complicated.
2703 (define_insn "callt_restore_all_interrupt"
2704 [(unspec_volatile [(const_int 0)] 1)]
2705 "(TARGET_V850E || TARGET_V850E2_ALL) && !TARGET_DISABLE_CALLT"
2706 "callt ctoff(__callt_restore_all_interrupt)"
2707 [(set_attr "length" "2")
2708 (set_attr "cc" "none")])
2710 (define_insn "restore_all_interrupt"
2711 [(unspec_volatile [(const_int 0)] 1)]
2714 if (TARGET_PROLOG_FUNCTION && !TARGET_LONG_CALLS)
2715 return "jarl __restore_all_interrupt,r10";
2719 output_asm_insn ("mov ep, r1", operands);
2720 output_asm_insn ("mov sp, ep", operands);
2721 output_asm_insn ("sld.w 116[ep], r31", operands);
2722 output_asm_insn ("sld.w 112[ep], r2", operands);
2723 output_asm_insn ("sld.w 108[ep], gp", operands);
2724 output_asm_insn ("sld.w 104[ep], r6", operands);
2725 output_asm_insn ("sld.w 100[ep], r7", operands);
2726 output_asm_insn ("sld.w 96[ep], r8", operands);
2727 output_asm_insn ("sld.w 92[ep], r9", operands);
2728 output_asm_insn ("sld.w 88[ep], r11", operands);
2729 output_asm_insn ("sld.w 84[ep], r12", operands);
2730 output_asm_insn ("sld.w 80[ep], r13", operands);
2731 output_asm_insn ("sld.w 76[ep], r14", operands);
2732 output_asm_insn ("sld.w 72[ep], r15", operands);
2733 output_asm_insn ("sld.w 68[ep], r16", operands);
2734 output_asm_insn ("sld.w 64[ep], r17", operands);
2735 output_asm_insn ("sld.w 60[ep], r18", operands);
2736 output_asm_insn ("sld.w 56[ep], r19", operands);
2737 output_asm_insn ("sld.w 52[ep], r20", operands);
2738 output_asm_insn ("sld.w 48[ep], r21", operands);
2739 output_asm_insn ("sld.w 44[ep], r22", operands);
2740 output_asm_insn ("sld.w 40[ep], r23", operands);
2741 output_asm_insn ("sld.w 36[ep], r24", operands);
2742 output_asm_insn ("sld.w 32[ep], r25", operands);
2743 output_asm_insn ("sld.w 28[ep], r26", operands);
2744 output_asm_insn ("sld.w 24[ep], r27", operands);
2745 output_asm_insn ("sld.w 20[ep], r28", operands);
2746 output_asm_insn ("sld.w 16[ep], r29", operands);
2747 output_asm_insn ("mov r1, ep", operands);
2751 output_asm_insn ("ld.w 116[sp], r31", operands);
2752 output_asm_insn ("ld.w 112[sp], r2", operands);
2753 output_asm_insn ("ld.w 108[sp], gp", operands);
2754 output_asm_insn ("ld.w 104[sp], r6", operands);
2755 output_asm_insn ("ld.w 100[sp], r7", operands);
2756 output_asm_insn ("ld.w 96[sp], r8", operands);
2757 output_asm_insn ("ld.w 92[sp], r9", operands);
2758 output_asm_insn ("ld.w 88[sp], r11", operands);
2759 output_asm_insn ("ld.w 84[sp], r12", operands);
2760 output_asm_insn ("ld.w 80[sp], r13", operands);
2761 output_asm_insn ("ld.w 76[sp], r14", operands);
2762 output_asm_insn ("ld.w 72[sp], r15", operands);
2763 output_asm_insn ("ld.w 68[sp], r16", operands);
2764 output_asm_insn ("ld.w 64[sp], r17", operands);
2765 output_asm_insn ("ld.w 60[sp], r18", operands);
2766 output_asm_insn ("ld.w 56[sp], r19", operands);
2767 output_asm_insn ("ld.w 52[sp], r20", operands);
2768 output_asm_insn ("ld.w 48[sp], r21", operands);
2769 output_asm_insn ("ld.w 44[sp], r22", operands);
2770 output_asm_insn ("ld.w 40[sp], r23", operands);
2771 output_asm_insn ("ld.w 36[sp], r24", operands);
2772 output_asm_insn ("ld.w 32[sp], r25", operands);
2773 output_asm_insn ("ld.w 28[sp], r26", operands);
2774 output_asm_insn ("ld.w 24[sp], r27", operands);
2775 output_asm_insn ("ld.w 20[sp], r28", operands);
2776 output_asm_insn ("ld.w 16[sp], r29", operands);
2778 output_asm_insn ("addi 120, sp, sp", operands);
2781 [(set (attr "length")
2782 (if_then_else (match_test "TARGET_LONG_CALLS")
2786 (set_attr "cc" "clobber")])
2788 (define_insn "_restore_all_interrupt"
2789 [(unspec_volatile [(const_int 0)] 1)]
2790 "TARGET_V850 && ! TARGET_LONG_CALLS"
2791 "jarl __restore_all_interrupt,r10"
2792 [(set_attr "length" "4")
2793 (set_attr "cc" "clobber")])