Debian Codegraph @

gcc/config/csky/csky.md

raw
1 ;; Machine description for C-SKY processors.
2 ;; Copyright (C) 2018-2025 Free Software Foundation, Inc.
3 ;; Contributed by C-SKY Microsystems and Mentor Graphics.
4 ;;
5 ;; This file is part of GCC.
6 ;;
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3, or (at your option)
10 ;; any later version.
11 ;;
12 ;; GCC is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;; General Public License for more details.
16 ;;
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>. */
20
21
22 ;; ------------------------------------------------------------------------
23 ;; Constant
24 ;; ------------------------------------------------------------------------
25
26 ;; Register numbering.
27
28 (define_constants
29 [(CSKY_NGPR_REGS 32)
30 (CSKY_NPARM_REGS 4)
31 (CSKY_FIRST_PARM_REGNUM 0)
32 (CSKY_FIRST_RET_REGNUM 0)
33 (CSKY_FIRST_VFP_REGNUM 52)
34 (CSKY_LAST_VFP_REGNUM 67)
35 (CSKY_FIRST_VFP3_REGNUM 71)
36 (CSKY_LAST_VFP3_REGNUM 86)
37 (CSKY_FIRST_HIGH_REGNUM 16)
38 (CSKY_LAST_HIGH_REGNUM 31)
39 (CSKY_FIRST_MINI_REGNUM 0)
40 (CSKY_LAST_MINI_REGNUM 7)
41 (CSKY_T0_REGNUM 12)
42 (CSKY_T1_REGNUM 13)
43 (CSKY_SP_REGNUM 14)
44 (CSKY_CC_REGNUM 33)
45 (CSKY_HI_REGNUM 34)
46 (CSKY_LO_REGNUM 35)
47 (CSKY_LR_REGNUM 15)
48 (CSKY_LAST_HIGH_UNFIXED_REGNUM 25)
49 (CSKY_GB_REGNUM 28)
50 (CSKY_TLS_REGNUM 31)
51 (CSKY_FIRST_EH_RETDATA_REGNUM 0)
52 (CSKY_LAST_EH_RETDATA_REGNUM 1)
53 (CSKY_EH_STACKADJ_REGNUM 2)
54 (CSKY_STACKADJUST_REGNUM 4)
55 (CSKY_NPARM_FREGS 4)
56 ])
57
58 ;; Supported TLS relocations.
59
60 (define_constants
61 [(TLS_GD32 0)
62 (TLS_LDM32 1)
63 (TLS_LDO32 2)
64 (TLS_IE32 3)
65 (TLS_LE32 4)
66 ])
67
68 ;; Unspec constants.
69
70 (define_c_enum "unspec"
71 [
72 ; Push or pop multiple operation: operand 0 is the first register,
73 ; subsequent registers are in parallel (use ...) expressions.
74 UNSPEC_PUSHPOP_MULT
75
76 ; Represent TLS base, TLS offset, and TLS base + offset, respectively.
77 UNSPEC_TLS_BASE
78 UNSPEC_TLS_LABEL
79 UNSPEC_TLS
80
81 ; PIC symbol relocations.
82 UNSPEC_PIC_SYMBOL_GOTPC
83 UNSPEC_PIC_SYMBOL_GOTPC_GRS
84 UNSPEC_PIC_SYMBOL_GOTOFF
85 UNSPEC_PIC_SYMBOL_GOT
86 UNSPEC_PIC_SYMBOL_PLT
87 UNSPEC_PIC_SYMBOL_BSR
88 UNSPEC_PIC_SYMBOL_GRS
89
90 ; casesi dispatch table.
91 UNSPEC_CSKY_CASESI
92 ])
93
94
95 (define_c_enum "unspecv"
96 [
97 ; Used for constant pools.
98 VUNSPEC_ALIGN
99 VUNSPEC_POOL_LABEL
100 VUNSPEC_POOL_4
101 VUNSPEC_POOL_8
102 VUNSPEC_SYMBOL_REF
103
104 ; Support for the eh_return pattern.
105 VUNSPEC_EH_RETURN
106 VUNSPEC_BLOCKAGE
107 ])
108
109
110 ;; ------------------------------------------------------------------------
111 ;; Attributes
112 ;; ------------------------------------------------------------------------
113
114 ;; LENGTH of an instruction (in bytes).
115
116 (define_attr "length" ""
117 (if_then_else (match_test "CSKY_TARGET_ARCH (CK801)")
118 (const_int 2)
119 (const_int 4)))
120
121 ;; Used for ck801 to represent whether we need to use bsr for long
122 ;; distance jumps. If set to yes, the function will save lr in the
123 ;; prologue.
124
125 (define_attr "far_jump" "yes,no" (const_string "no"))
126
127 ;; Used for insn schedule.
128
129 (define_attr "type"
130 "alu,load,store,cmp,branch,cbranch,addsub,alu_ix,branch_jmp,call_jsr,call"
131 (const_string "alu"))
132
133
134 ;; ------------------------------------------------------------------------
135 ;; Include files
136 ;; ------------------------------------------------------------------------
137
138 (include "constraints.md")
139 (include "predicates.md")
140 (include "csky_insn_fpu.md")
141 (include "csky_insn_dsp.md")
142 (include "csky_pipeline_ck801.md")
143 (include "csky_pipeline_ck802.md")
144 (include "csky_pipeline_ck803.md")
145 (include "csky_pipeline_ck810.md")
146
147 ;; ------------------------------------------------------------------------
148 ;; Mov insns
149 ;; ------------------------------------------------------------------------
150
151 (define_mode_iterator QHI [QI HI])
152
153 (define_expand "movsi"
154 [(set (match_operand:SI 0 "general_operand" "")
155 (match_operand:SI 1 "general_operand" ""))]
156 ""
157 "
158 {
159 rtx scratch = !can_create_pseudo_p () ? operands[0] : 0;
160 if (can_create_pseudo_p () && MEM_P (operands[0]))
161 {
162 operands[1] = force_reg (SImode, operands[1]);
163 emit_insn (gen_rtx_SET (operands[0], operands[1]));
164 DONE;
165 }
166
167 /* Recognize the case where operand[1] is a reference to thread-local
168 data and load its address to a register. */
169 if (csky_tls_referenced_p (operands[1]))
170 {
171 rtx tmp = operands[1];
172 rtx addend = NULL;
173
174 if (GET_CODE (tmp) == CONST && GET_CODE (XEXP (tmp, 0)) == PLUS)
175 {
176 addend = XEXP (XEXP (tmp, 0), 1);
177 tmp = XEXP (XEXP (tmp, 0), 0);
178 }
179
180 gcc_assert (GET_CODE (tmp) == SYMBOL_REF);
181 gcc_assert (SYMBOL_REF_TLS_MODEL (tmp) != 0);
182
183 tmp = csky_legitimize_tls_address (tmp, scratch);
184 if (addend)
185 {
186 tmp = gen_rtx_PLUS (SImode, tmp, addend);
187 tmp = force_operand (tmp, operands[0]);
188 }
189 operands[1] = tmp;
190 }
191 else if (flag_pic
192 && (CONSTANT_P (operands[1])
193 || csky_symbol_mentioned_p (operands[1])
194 || csky_label_mentioned_p (operands[1])))
195 operands[1] = csky_legitimize_pic_address (operands[1], scratch, true);
196 }"
197 )
198
199 ;; Note that we conservatively estimate all load and store insns as having
200 ;; a size of 4 bytes throughout even though some variants can be encoded
201 ;; as 2-byte machine instructions. Getting more accurate instruction counts
202 ;; would be better handled by calling into a C function than encoding it
203 ;; as an RTL conditional here.
204 ;; Also note that we don't count the extra space required for constant
205 ;; pool entries here; that's handled by the constant pool entries themselves.
206 ;; In -mno-constpool cases where we're relying on the assembler to create
207 ;; the constant pool, we'll undercount branch lengths, but in that case the
208 ;; assembler also handles branch relaxation as needed. It's only ck801 that
209 ;; requires compiler cooperation when long branches are needed.
210
211 (define_insn "*cskyv2_movsi"
212 [(set (match_operand:SI 0 "nonimmediate_operand" "=b,r,r,r, r, r, r,r, m,r,*y,*r,*v,*r,*v")
213 (match_operand:SI 1 "general_operand" " b,r,I,Un,Uc,Uo,m,miF,r,c,*r,*y,*r,*v,*v"))]
214 "CSKY_ISA_FEATURE (E2)"
215 "* return csky_output_move (insn, operands, SImode);"
216 [(set_attr "length" "2,4,4,4,4,8,4,4,4,4,4,4,4,4,4")
217 (set_attr "type" "alu,alu,alu,alu,alu,alu,load,load,store,alu,alu,alu,alu,alu,alu")]
218 )
219
220 (define_insn "*ck801_movsi"
221 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,a, a,r,r, m,r")
222 (match_operand:SI 1 "general_operand" "r, Up,T,m,miF,r,c"))]
223 "CSKY_ISA_FEATURE (E1)"
224 "* return csky_output_ck801_move (insn, operands, SImode);"
225 [(set_attr "length" "2,2,2,4,4,4,2")
226 (set_attr "type" "alu,alu,alu,load,load,store,alu")]
227 )
228
229 ;; Convert negative assignments to zero minus positive numbers.
230 (define_split
231 [(set (match_operand:SI 0 "register_operand" "")
232 (match_operand:SI 1 "const_int_operand" ""))]
233 "satisfies_constraint_T (operands[1])"
234 [(set (match_dup 0) (match_dup 2))
235 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))]
236 "operands[2] = const0_rtx;"
237 )
238
239 ;; Convert const assignments to small number of assignments and left shift.
240 (define_split
241 [(set (match_operand:SI 0 "register_operand" "")
242 (match_operand:SI 1 "const_int_operand" ""))]
243 ""
244 [(set (match_dup 0) (match_dup 1))
245 (set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))]
246 "
247 {
248 unsigned int base, shift;
249
250 if (!csky_shifted_imm8_constant (INTVAL (operands[1]), &base, &shift))
251 FAIL;
252 if (shift == 0)
253 FAIL;
254 operands[1] = GEN_INT (base);
255 operands[2] = GEN_INT (shift);
256 }"
257 )
258
259
260 (define_expand "movhi"
261 [(set (match_operand:HI 0 "general_operand" "")
262 (match_operand:HI 1 "general_operand" ""))]
263 ""
264 "
265 {
266 if (GET_CODE (operands[0]) == MEM)
267 operands[1] = force_reg (HImode, operands[1]);
268 else if (CONSTANT_P (operands[1])
269 && (GET_CODE (operands[1]) != CONST_INT
270 || (! CSKY_CONST_OK_FOR_I (INTVAL (operands[1]))
271 && ! CSKY_CONST_OK_FOR_Ub (INTVAL (operands[1]))
272 && ! CSKY_CONST_OK_FOR_Uc (INTVAL (operands[1]))))
273 && ! reload_completed && ! reload_in_progress)
274 {
275 rtx reg = gen_reg_rtx (SImode);
276 emit_insn (gen_movsi (reg, operands[1]));
277 operands[1] = gen_lowpart (HImode, reg);
278 }
279 }"
280 )
281
282 (define_insn "*cskyv2_movhi"
283 [(set (match_operand:HI 0 "nonimmediate_operand" "=b,r,r,r, r, r, r,r, m,r,*y,*r,*v,*r,*v")
284 (match_operand:HI 1 "general_operand" " b,r,I,Un,Uc,Uo,m,miF,r,c,*r,*y,*r,*v,*v"))]
285 "CSKY_ISA_FEATURE (E2)"
286 "* return csky_output_move (insn, operands, HImode);"
287 [(set_attr "length" "2,4,4,4,4,8,4,4,4,4,4,4,4,4,4")
288 (set_attr "type" "alu,alu,alu,alu,alu,alu,load,load,store,alu,alu,alu,alu,alu,alu")]
289 )
290
291 (define_insn "*ck801_movhi"
292 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,a, a,r,r, m,r")
293 (match_operand:HI 1 "general_operand" "r, Up,T,m,miF,r,c"))]
294 "CSKY_ISA_FEATURE (E1)"
295 "* return csky_output_ck801_move (insn, operands, HImode);"
296 [(set_attr "length" "2,2,2,4,4,4,2")
297 (set_attr "type" "alu,alu,alu,load,load,store,alu")]
298 )
299
300
301 (define_expand "movqi"
302 [(set (match_operand:QI 0 "general_operand" "")
303 (match_operand:QI 1 "general_operand" ""))]
304 ""
305 "
306 {
307 if (can_create_pseudo_p () && GET_CODE (operands[0]) == MEM)
308 operands[1] = force_reg (QImode, operands[1]);
309 else if (CONSTANT_P (operands[1])
310 && (GET_CODE (operands[1]) != CONST_INT
311 || (! CSKY_CONST_OK_FOR_I (INTVAL (operands[1]))
312 && ! CSKY_CONST_OK_FOR_Ub (INTVAL (operands[1]))
313 && ! CSKY_CONST_OK_FOR_Uc (INTVAL (operands[1]))))
314 && ! reload_completed && ! reload_in_progress)
315 {
316 rtx reg = gen_reg_rtx (SImode);
317 emit_insn (gen_movsi (reg, operands[1]));
318 operands[1] = gen_lowpart (QImode, reg);
319 }
320 }"
321 )
322
323 (define_insn "*cskyv2_movqi"
324 [(set (match_operand:QI 0 "nonimmediate_operand" "=b,r,r,r, r, r, r,r, m,r,*y,*r,*v,*r,*v")
325 (match_operand:QI 1 "general_operand" " b,r,I,Un,Uc,Uo,m,miF,r,c,*r,*y,*r,*v,*v"))]
326 "CSKY_ISA_FEATURE (E2)"
327 "* return csky_output_move (insn, operands, QImode);"
328 [(set_attr "length" "2,4,4,4,4,8,4,4,4,4,4,4,4,4,4")
329 (set_attr "type" "alu,alu,alu,alu,alu,alu,load,load,store,alu,alu,alu,alu,alu,alu")]
330 )
331
332 (define_insn "*ck801_movqi"
333 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,a, a,r,r, m,r")
334 (match_operand:QI 1 "general_operand" "r, Up,T,m,miF,r,c"))]
335 "CSKY_ISA_FEATURE (E1)"
336 "* return csky_output_ck801_move (insn, operands, QImode);"
337 [(set_attr "length" "2,2,2,4,4,4,2")
338 (set_attr "type" "alu,alu,alu,load,load,store,alu")]
339 )
340
341
342 (define_expand "movdi"
343 [(set (match_operand:DI 0 "general_operand" "")
344 (match_operand:DI 1 "general_operand" ""))]
345 ""
346 "if (can_create_pseudo_p () && GET_CODE (operands[0]) == MEM)
347 operands[1] = force_reg (DImode, operands[1]);"
348 )
349
350 ;; Convert negative assignments to zero minus positive numbers.
351 (define_split
352 [(set (match_operand:QHI 0 "register_operand" "")
353 (match_operand:QHI 1 "const_int_operand" ""))]
354 "satisfies_constraint_T (operands[1])"
355 [(set (match_dup 4) (match_dup 2))
356 (set (match_dup 4) (match_dup 3))
357 (set (match_dup 0) (match_dup 5))]
358 "
359 {
360 int low;
361
362 if (TARGET_BIG_ENDIAN)
363 low = 4 - mode_size[GET_MODE (operands[0])];
364 else
365 low = 0;
366 operands[2] = const0_rtx;
367 if (can_create_pseudo_p ())
368 operands[4] = gen_reg_rtx (SImode);
369 else
370 operands[4] = gen_rtx_REG (SImode, REGNO (operands[0]));
371 operands[3] = gen_rtx_PLUS (SImode, operands[4], operands[1]);
372 operands[5] = gen_rtx_SUBREG (GET_MODE (operands[0]), operands[4], low);
373 }"
374 )
375
376 ;; Convert const assignments to small number of assignments and left shift.
377 (define_split
378 [(set (match_operand:QHI 0 "register_operand" "")
379 (match_operand:QHI 1 "const_int_operand" ""))]
380 ""
381 [(set (match_dup 3) (match_dup 1))
382 (set (match_dup 3) (ashift:SI (match_dup 3) (match_dup 2)))
383 (set (match_dup 0) (match_dup 4))]
384 "
385 {
386 unsigned int base, shift;
387 int low;
388
389 if (!csky_shifted_imm8_constant (INTVAL (operands[1]), &base, &shift))
390 FAIL;
391 if (shift == 0)
392 FAIL;
393
394 if (TARGET_BIG_ENDIAN)
395 low = 4 - mode_size[GET_MODE (operands[0])];
396 else
397 low = 0;
398
399 operands[1] = GEN_INT (base);
400 operands[2] = GEN_INT (shift);
401 if (can_create_pseudo_p ())
402 operands[3] = gen_reg_rtx (SImode);
403 else
404 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]));
405 operands[4] = gen_rtx_SUBREG (GET_MODE (operands[0]), operands[3], low);
406 }"
407 )
408
409
410 (define_insn "*csky_movdi"
411 [(set (match_operand:DI 0 "nonimmediate_operand" "=b,r,r, r,r, m,*r,*y,*v,*r,*v")
412 (match_operand:DI 1 "general_operand" " b,r,Ud,m,miF,r,*y,*r,*r,*v,*v"))]
413 "CSKY_ISA_FEATURE (E2)"
414 "* return csky_output_movedouble (operands, DImode);"
415 [(set_attr "length" "4,8,8,8,8,8,16,16,16,16,16")
416 (set_attr "type" "alu,alu,alu,load,load,store,alu,alu,alu,alu,alu")]
417 )
418
419 (define_insn "*ck801_movdi"
420 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,a, a,r,r, m")
421 (match_operand:DI 1 "general_operand" "r, Up,T,m,miF,r"))]
422 "CSKY_ISA_FEATURE (E1)"
423 "* return csky_output_ck801_movedouble (operands, DImode);"
424 [(set_attr "length" "4,4,4,8,8,8")
425 (set_attr "type" "alu,alu,alu,load,load,store")]
426 )
427
428 ;; The only CCmode move supported is a nop. Without this pattern,
429 ;; CSE is unable to eliminate redundant comparisons in conditional
430 ;; execution expressions.
431
432 (define_insn "*movcc_nop"
433 [(set (reg:CC CSKY_CC_REGNUM) (reg:CC CSKY_CC_REGNUM))]
434 ""
435 ""
436 [(set_attr "length" "0")]
437 )
438
439 ;; ------------------------------------------------------------------------
440 ;; Conditional mov insns
441 ;; ------------------------------------------------------------------------
442
443 ;; Only handle integer comparisons because float and double require
444 ;; library calls.
445
446 (define_expand "movsicc"
447 [(set (match_operand 0 "register_operand" "")
448 (if_then_else:SI (match_operand 1 "comparison_operator" "")
449 (match_operand:SI 2 "register_operand" "")
450 (match_operand:SI 3 "register_operand" "")))]
451 "CSKY_ISA_FEATURE (E2)"
452 "
453 {
454 bool invert = csky_emit_compare (GET_CODE (operands[1]),
455 XEXP (operands[1], 0),
456 XEXP (operands[1], 1));
457
458 if (invert)
459 emit_insn (gen_movf (operands[0], operands[2], operands[3]));
460 else
461 emit_insn (gen_movt (operands[0], operands[2], operands[3]));
462 DONE;
463 }")
464
465 (define_insn "movt"
466 [(set (match_operand:SI 0 "register_operand" "=r, r")
467 (if_then_else:SI (ne (reg:CC CSKY_CC_REGNUM) (const_int 0))
468 (match_operand:SI 1 "register_operand" "r, 0")
469 (match_operand:SI 2 "register_operand" "0, r")))]
470 "CSKY_ISA_FEATURE (E2)"
471 "@
472 movt\t%0, %1
473 movf\t%0, %2"
474 [(set_attr "length" "4,4")]
475 )
476
477 (define_insn "movf"
478 [(set (match_operand:SI 0 "register_operand" "=r, r")
479 (if_then_else:SI (eq (reg:CC CSKY_CC_REGNUM) (const_int 0))
480 (match_operand:SI 1 "register_operand" "r, 0")
481 (match_operand:SI 2 "register_operand" "0, r")))]
482 "CSKY_ISA_FEATURE (E2)"
483 "@
484 movf\t%0, %1
485 movt\t%0, %2"
486 [(set_attr "length" "4,4")]
487 )
488
489 (define_expand "cstoresi4"
490 [(set (match_operand:SI 0 "register_operand" "")
491 (match_operator 1 "ordered_comparison_operator"
492 [(match_operand:SI 2 "csky_compare_operand" "")
493 (match_operand:SI 3 "nonmemory_operand" "")]))]
494 ""
495 "
496 {
497 bool invert = csky_emit_compare (GET_CODE (operands[1]),
498 operands[2], operands[3]);
499
500 if (invert)
501 emit_insn (gen_mvcv (operands[0]));
502 else if (CSKY_ISA_FEATURE (E1))
503 {
504 emit_insn (gen_movsi (operands[0], const0_rtx));
505 emit_insn (gen_ck801_addc (operands[0], operands[0], operands[0]));
506 }
507 else
508 emit_insn (gen_mvc (operands[0]));
509 DONE;
510 }"
511 )
512
513 (define_insn "mvc"
514 [(set (match_operand:SI 0 "register_operand" "=r")
515 (ne:SI (reg:CC CSKY_CC_REGNUM) (const_int 0)))]
516 "CSKY_ISA_FEATURE (E2)"
517 "mvc\t%0"
518 )
519
520 (define_insn "mvcv"
521 [(set (match_operand:SI 0 "register_operand" "=r")
522 (eq:SI (reg:CC CSKY_CC_REGNUM) (const_int 0)))]
523 ""
524 "mvcv\t%0"
525 )
526
527 ;; ------------------------------------------------------------------------
528 ;; Arithmetic insns
529 ;; ------------------------------------------------------------------------
530
531 (define_insn "abssi2"
532 [(set (match_operand:SI 0 "register_operand" "=r")
533 (abs:SI (match_operand:SI 1 "register_operand" "r")))]
534 "CSKY_ISA_FEATURE (2E3)"
535 "abs\t%0, %1"
536 [(set_attr "type" "alu")]
537 )
538
539 (define_insn "extvsi"
540 [(set (match_operand:SI 0 "register_operand" "=r")
541 (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
542 (match_operand:SI 2 "const_int_operand" "")
543 (match_operand:SI 3 "const_int_operand" "")))]
544 "CSKY_ISA_FEATURE (2E3)"
545 {
546 operands[2] = GEN_INT (INTVAL (operands[3]) + INTVAL (operands[2]) - 1);
547 return \"sext\t%0, %1, %2, %3\";
548 }
549 )
550
551 (define_insn "insvsi"
552 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
553 (match_operand:SI 1 "const_int_operand" "i")
554 (match_operand:SI 2 "const_int_operand" "i"))
555 (match_operand:SI 3 "register_operand" "r"))]
556 "CSKY_ISA_FEATURE (2E3)"
557 {
558 operands[1] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[1]) - 1);
559 return \"ins\t%0, %3, %1, %2\";
560 }
561 )
562
563 (define_expand "bseti"
564 [(set (match_operand:SI 0 "register_operand" "")
565 (ior:SI (match_operand:SI 1 "register_operand" "")
566 (ashift:SI (const_int 1)
567 (match_operand:SI 2 "csky_literal_K_operand" ""))))]
568 ""
569 "")
570
571 (define_insn "smart_bseti"
572 [(set (match_operand:SI 0 "register_operand" "=r")
573 (ior:SI (match_operand:SI 1 "register_operand" "0")
574 (ashift:SI (const_int 1)
575 (match_operand:SI 2 "csky_literal_K_operand" "K"))))]
576 "CSKY_ISA_FEATURE (E1)"
577 "bseti\t%0, %2"
578 [(set_attr "length" "2")])
579
580 (define_insn "fast_bseti"
581 [(set (match_operand:SI 0 "register_operand" "=a,r")
582 (ior:SI (match_operand:SI 1 "register_operand" "0,r")
583 (ashift:SI (const_int 1)
584 (match_operand:SI 2 "csky_literal_K_operand" "K,K"))))]
585 "CSKY_ISA_FEATURE (E2)"
586 "bseti\t%0, %1, %2"
587 [(set_attr "length" "2,4")])
588
589 (define_expand "bclri"
590 [(set (match_operand:SI 0 "register_operand" "")
591 (and:SI (match_operand:SI 1 "register_operand" "")
592 (not:SI (ashift:SI (const_int 1)
593 (match_operand:SI 2 "csky_literal_K_operand" "")))))]
594 ""
595 "")
596
597 (define_insn "smart_bclri"
598 [(set (match_operand:SI 0 "register_operand" "=r")
599 (and:SI (match_operand:SI 1 "register_operand" "0")
600 (not:SI (ashift:SI (const_int 1)
601 (match_operand:SI 2 "csky_literal_K_operand" "K")))))]
602 "CSKY_ISA_FEATURE (E1)"
603 "bclri\t%0, %2"
604 [(set_attr "length" "2")])
605
606 (define_insn "fast_bclri"
607 [(set (match_operand:SI 0 "register_operand" "=a,r")
608 (and:SI (match_operand:SI 1 "register_operand" "0,r")
609 (not:SI (ashift:SI (const_int 1)
610 (match_operand:SI 2 "csky_literal_K_operand" "K,K")))))]
611 "CSKY_ISA_FEATURE (E2)"
612 "bclri\t%0, %1, %2"
613 [(set_attr "length" "2,4")])
614
615
616 ;; Shift instructions.
617
618 (define_expand "ashlsi3"
619 [(set (match_operand:SI 0 "register_operand" "")
620 (ashift:SI (match_operand:SI 1 "register_operand" "")
621 (match_operand:SI 2 "csky_arith_K_operand" "")))]
622 ""
623 ""
624 )
625
626 (define_insn "*cskyv2_ashlsi3"
627 [(set (match_operand:SI 0 "register_operand" "=b,r,a,r")
628 (ashift:SI (match_operand:SI 1 "register_operand" "0,r,a,r")
629 (match_operand:SI 2 "csky_arith_K_operand" "b,r,K,K")))]
630 "CSKY_ISA_FEATURE (E2)"
631 "@
632 lsl %0, %1, %2
633 lsl %0, %1, %2
634 lsli %0, %1, %2
635 lsli %0, %1, %2"
636 [(set_attr "length" "2,4,2,4")]
637 )
638
639 (define_insn "ck801_ashlsi3"
640 [(set (match_operand:SI 0 "register_operand" "=a,r")
641 (ashift:SI (match_operand:SI 1 "register_operand" "a,0")
642 (match_operand:SI 2 "csky_arith_K_operand" "K,r")))]
643 "CSKY_ISA_FEATURE (E1)"
644 "@
645 lsli %0, %1, %2
646 lsl %0, %1, %2"
647 )
648
649
650 (define_expand "ashrsi3"
651 [(set (match_operand:SI 0 "register_operand" "")
652 (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
653 (match_operand:SI 2 "csky_arith_K_operand" "")))]
654 ""
655 ""
656 )
657
658 (define_insn "*cskyv2_ashrsi3"
659 [(set (match_operand:SI 0 "register_operand" "=b,r,a,r")
660 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,r,a,r")
661 (match_operand:SI 2 "csky_arith_K_operand" "b,r,K,K")))]
662 "CSKY_ISA_FEATURE (E2)"
663 "@
664 asr %0, %1, %2
665 asr %0, %1, %2
666 asri %0, %1, %2
667 asri %0, %1, %2"
668 [(set_attr "length" "2,4,2,4")]
669 )
670
671 (define_insn "*ck801_ashrsi3"
672 [(set (match_operand:SI 0 "register_operand" "=a,r")
673 (ashiftrt:SI (match_operand:SI 1 "register_operand" "a,0")
674 (match_operand:SI 2 "csky_arith_K_operand" "K,r")))]
675 "CSKY_ISA_FEATURE (E1)"
676 "@
677 asri %0, %1, %2
678 asr %0, %1, %2"
679 )
680
681
682 (define_expand "lshrsi3"
683 [(set (match_operand:SI 0 "register_operand" "")
684 (lshiftrt:SI (match_operand:SI 1 "register_operand" "")
685 (match_operand:SI 2 "csky_arith_K_operand" "")))]
686 ""
687 ""
688 )
689
690 (define_insn "*cskyv2_lshrsi3"
691 [(set (match_operand:SI 0 "register_operand" "=b,r,a,r")
692 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0,r,a,r")
693 (match_operand:SI 2 "csky_arith_K_operand" "b,r,K,K")))]
694 "CSKY_ISA_FEATURE (E2)"
695 "@
696 lsr %0, %1, %2
697 lsr %0, %1, %2
698 lsri %0, %1, %2
699 lsri %0, %1, %2"
700 [(set_attr "length" "2,4,2,4")]
701 )
702
703 (define_insn "ck801_lshrsi3"
704 [(set (match_operand:SI 0 "register_operand" "=a,r")
705 (lshiftrt:SI (match_operand:SI 1 "register_operand" "a,0")
706 (match_operand:SI 2 "csky_arith_K_operand" "K,r")))]
707 "CSKY_ISA_FEATURE (E1)"
708 "@
709 lsri %0, %1, %2
710 lsr %0, %1, %2"
711 )
712
713
714 (define_expand "rotlsi3"
715 [(set (match_operand:SI 0 "register_operand" "")
716 (rotate:SI (match_operand:SI 1 "register_operand" "")
717 (match_operand:SI 2 "csky_arith_K_operand" "")))]
718 ""
719 ""
720 )
721
722 (define_insn "*cskyv2_rotlsi3"
723 [(set (match_operand:SI 0 "register_operand" "=b,r,r")
724 (rotate:SI (match_operand:SI 1 "register_operand" "0,r,r")
725 (match_operand:SI 2 "csky_arith_K_operand" "b,r,K")))]
726 "CSKY_ISA_FEATURE (E2)"
727 "@
728 rotl %0, %1, %2
729 rotl %0, %1, %2
730 rotli %0, %1, %2"
731 [(set_attr "length" "2,4,4")]
732 )
733
734 (define_insn "*ck801_rotlsi3"
735 [(set (match_operand:SI 0 "register_operand" "=r")
736 (rotate:SI (match_operand:SI 1 "register_operand" "0")
737 (match_operand:SI 2 "csky_arith_K_operand" "r")))]
738 "CSKY_ISA_FEATURE (E1)"
739 "rotl %0, %1, %2"
740 )
741
742
743 ;; Add instructions.
744 ;; C-SKY addi and subi machine instructions only accept positive immediate
745 ;; values, so we have to special case immediates <= 0 in these patterns.
746
747 (define_expand "addsi3"
748 [(set (match_operand:SI 0 "register_operand" "")
749 (plus:SI (match_operand:SI 1 "register_operand" "")
750 (match_operand:SI 2 "nonmemory_operand" "")))]
751 ""
752 ""
753 )
754
755 (define_insn "smart_addsi3"
756 [(set (match_operand:SI 0 "register_operand" "=a,r,a,a,a,a, r,r")
757 (plus:SI (match_operand:SI 1 "register_operand" "%a,0,0,a,0,a, r,r")
758 (match_operand:SI 2 "nonmemory_operand" "a, r,N,L,T,Us,M,Um")))]
759 "TARGET_MINI_REGISTERS && CSKY_ISA_FEATURE (E2)
760 && operands[0] != stack_pointer_rtx
761 && operands[1] != stack_pointer_rtx"
762 "@
763 addu\t%0, %1, %2
764 addu\t%0, %1, %2
765 addi\t%0, %1, %2
766 addi\t%0, %1, %2
767 subi\t%0, %1, %M2
768 subi\t%0, %1, %M2
769 addi\t%0, %1, %2
770 subi\t%0, %1, %M2"
771 [(set_attr "length" "2,2,2,2,2,2,4,4")
772 (set_attr "type" "addsub")]
773 )
774
775 (define_insn_and_split "*smart_addsi3_sp"
776 [(set (match_operand:SI 0 "register_operand" "=z,z, z,a,&a,z,a,r")
777 (plus:SI (match_operand:SI 1 "register_operand" "0, 0, 0,z, z,a,z,r")
778 (match_operand:SI 2 "nonmemory_operand" "P, Ug,r,Uq,i,a,a,M")))]
779 "TARGET_MINI_REGISTERS && CSKY_ISA_FEATURE (E2)
780 && (operands[0] == stack_pointer_rtx || operands[1] == stack_pointer_rtx)"
781 "@
782 addi\t%0, %1, %2
783 subi\t%0, %1, %M2
784 addu\t%0, %1, %2
785 addi\t%0, %1, %2
786 #
787 addu\t%0, %1, %2
788 addu\t%0, %1, %2
789 addi\t%0, %1, %2"
790 "(operands[0] != stack_pointer_rtx
791 && operands[1] == stack_pointer_rtx
792 && !satisfies_constraint_Uq (operands[2]))"
793 [(set (match_dup 0)
794 (plus:SI (match_dup 1) (match_dup 0)))]
795 "emit_move_insn (operands[0], operands[2]);"
796 [(set_attr "type" "addsub")]
797 )
798
799 (define_insn "*ck801_addsi3"
800 [(set (match_operand:SI 0 "register_operand" "=r,a,a,a,a,a, !z,!z,!z,a")
801 (plus:SI (match_operand:SI 1 "register_operand" "%0,a,0,a,0,a, 0, 0, 0, !z")
802 (match_operand:SI 2 "nonmemory_operand" "r, a,N,L,T,Us,P, Ug,r, Uq")))]
803 "CSKY_ISA_FEATURE (E1)"
804 "@
805 addu\t%0, %1, %2
806 addu\t%0, %1, %2
807 addi\t%0, %1, %2
808 addi\t%0, %1, %2
809 subi\t%0, %1, %M2
810 subi\t%0, %1, %M2
811 addi\t%0, %1, %2
812 subi\t%0, %1, %M2
813 addu\t%0, %1, %2
814 addi\t%0, %1, %2"
815 [(set_attr "type" "addsub")]
816 )
817
818 (define_insn "fast_addsi3"
819 [(set (match_operand:SI 0 "register_operand" "=r,r, r")
820 (plus:SI (match_operand:SI 1 "register_operand" "%r,r, r")
821 (match_operand:SI 2 "nonmemory_operand" "M, Um,r")))]
822 "!TARGET_MINI_REGISTERS && CSKY_ISA_FEATURE (E2)"
823 "@
824 addi\t%0, %1, %2
825 subi\t%0, %1, %M2
826 addu\t%0, %1, %2"
827 [(set_attr "type" "addsub")]
828 )
829
830 (define_expand "adddi3"
831 [(parallel [(set (match_operand:DI 0 "register_operand" "")
832 (plus:DI (match_operand:DI 1 "register_operand" "")
833 (match_operand:DI 2 "csky_arith_int1_operand" "")))
834 (clobber (reg:CC CSKY_CC_REGNUM))])]
835 ""
836 "
837 if (CSKY_ISA_FEATURE (E1) && (GET_CODE (operands[2]) != REG))
838 operands[2] = force_reg (DImode, operands[2]);
839 "
840 )
841
842 /* Note that the csky addc instruction both reads and writes the carry bit.
843 The purpose of the initial cmplt instruction in the expansion is to
844 clear the carry bit before adding the lo words. */
845
846 (define_insn_and_split "*cskyv2_adddi3"
847 [(set (match_operand:DI 0 "register_operand" "=&b,&r")
848 (plus:DI (match_operand:DI 1 "register_operand" "%0,r")
849 (match_operand:DI 2 "register_operand" "b, r")))
850 (clobber (reg:CC CSKY_CC_REGNUM))]
851 "CSKY_ISA_FEATURE (E2)"
852 "#"
853 "reload_completed"
854 [(const_int 0)]
855 {
856 int hi = TARGET_BIG_ENDIAN ? 0 : UNITS_PER_WORD;
857 int lo = TARGET_BIG_ENDIAN ? UNITS_PER_WORD : 0;
858 rtx l0 = simplify_gen_subreg (SImode, operands[0], DImode, lo);
859 rtx h0 = simplify_gen_subreg (SImode, operands[0], DImode, hi);
860 rtx l1 = simplify_gen_subreg (SImode, operands[1], DImode, lo);
861 rtx h1 = simplify_gen_subreg (SImode, operands[1], DImode, hi);
862 rtx l2 = simplify_gen_subreg (SImode, operands[2], DImode, lo);
863 rtx h2 = simplify_gen_subreg (SImode, operands[2], DImode, hi);
864
865 emit_insn (gen_cmpltsi_r (copy_rtx (l1), copy_rtx (l1)));
866 emit_insn (gen_cskyv2_addc (l0, l1, l2));
867 emit_insn (gen_cskyv2_addc (h0, h1, h2));
868 DONE;
869 }
870 [(set_attr "length" "6,12")]
871 )
872
873 (define_insn_and_split "*ck801_adddi3"
874 [(set (match_operand:DI 0 "register_operand" "=r")
875 (plus:DI (match_operand:DI 1 "register_operand" "%0")
876 (match_operand:DI 2 "register_operand" "r")))
877 (clobber (reg:CC CSKY_CC_REGNUM))]
878 "CSKY_ISA_FEATURE (E1)"
879 "#"
880 "reload_completed"
881 [(const_int 0)]
882 {
883 int hi = TARGET_BIG_ENDIAN ? 0 : UNITS_PER_WORD;
884 int lo = TARGET_BIG_ENDIAN ? UNITS_PER_WORD : 0;
885 rtx l0 = simplify_gen_subreg (SImode, operands[0], DImode, lo);
886 rtx h0 = simplify_gen_subreg (SImode, operands[0], DImode, hi);
887 rtx l1 = simplify_gen_subreg (SImode, operands[1], DImode, lo);
888 rtx h1 = simplify_gen_subreg (SImode, operands[1], DImode, hi);
889 rtx l2 = simplify_gen_subreg (SImode, operands[2], DImode, lo);
890 rtx h2 = simplify_gen_subreg (SImode, operands[2], DImode, hi);
891
892 emit_insn (gen_cmpltsi_r (copy_rtx (l1), copy_rtx (l1)));
893 emit_insn (gen_ck801_addc (l0, l1, l2));
894 emit_insn (gen_ck801_addc (h0, h1, h2));
895 DONE;
896 }
897 [(set_attr "length" "6")]
898 )
899
900 ;; Special case for "longlong += 1".
901
902 (define_insn_and_split "*cskyv2_adddi1_1"
903 [(set (match_operand:DI 0 "register_operand" "=&r")
904 (plus:DI (match_operand:DI 1 "register_operand" "0")
905 (const_int 1)))
906 (clobber (reg:CC CSKY_CC_REGNUM))]
907 "CSKY_ISA_FEATURE (E2)"
908 "#"
909 "reload_completed"
910 [(const_int 0)]
911 {
912 int hi = TARGET_BIG_ENDIAN ? 0 : UNITS_PER_WORD;
913 int lo = TARGET_BIG_ENDIAN ? UNITS_PER_WORD : 0;
914 rtx l0 = simplify_gen_subreg (SImode, operands[0], DImode, lo);
915 rtx h0 = simplify_gen_subreg (SImode, operands[0], DImode, hi);
916
917 if (TARGET_MINI_REGISTERS)
918 {
919 emit_insn (gen_smart_addsi3 (l0, copy_rtx (l0),
920 gen_int_mode (1, SImode)));
921 emit_insn (gen_smart_cmpnesi_i (copy_rtx (l0),
922 gen_int_mode (0, SImode)));
923 emit_insn (gen_cskyv2_addcc_invert (h0, copy_rtx (h0),
924 gen_int_mode (1, SImode)));
925 }
926 else
927 {
928 emit_insn (gen_fast_addsi3 (l0, copy_rtx (l0),
929 gen_int_mode (1, SImode)));
930 emit_insn (gen_fast_cmpnesi_i (copy_rtx (l0),
931 gen_int_mode (0, SImode)));
932 emit_insn (gen_cskyv2_addcc_invert (h0, copy_rtx (h0),
933 gen_int_mode (1, SImode)));
934 }
935 DONE;
936 }
937 [(set (attr "length")
938 (if_then_else (match_test "TARGET_MINI_REGISTERS")
939 (const_int 8)
940 (const_int 12)))]
941 )
942
943 ;; sub instructions.
944
945 (define_expand "subsi3"
946 [(set (match_operand:SI 0 "register_operand" "")
947 (minus:SI (match_operand:SI 1 "register_operand" "")
948 (match_operand:SI 2 "nonmemory_operand" "")))]
949 ""
950 ""
951 )
952
953 (define_insn "smart_subsi3"
954 [(set (match_operand:SI 0 "register_operand" "=a,a,a,a,a,a")
955 (minus:SI (match_operand:SI 1 "register_operand" "a, 0,0,a,0,a")
956 (match_operand:SI 2 "nonmemory_operand" "a, a,N,L,T,Us")))]
957 "TARGET_MINI_REGISTERS && CSKY_ISA_FEATURE (E2)
958 && operands[0] != stack_pointer_rtx
959 && operands[1] != stack_pointer_rtx"
960 "@
961 subu\t%0, %1, %2
962 subu\t%0, %1, %2
963 subi\t%0, %1, %2
964 subi\t%0, %1, %2
965 addi\t%0, %1, %M2
966 addi\t%0, %1, %M2"
967 [(set_attr "length" "2,2,2,2,2,2")
968 (set_attr "type" "addsub")]
969 )
970
971 (define_insn "*smart_subsi3_sp"
972 [(set (match_operand:SI 0 "register_operand" "=z,z, z,a, a,r")
973 (minus:SI (match_operand:SI 1 "register_operand" "0, 0, 0,z, a,r")
974 (match_operand:SI 2 "nonmemory_operand" "P, Ug,a,Ur,a,M")))]
975 "TARGET_MINI_REGISTERS && CSKY_ISA_FEATURE (E2)
976 && (operands[0] == stack_pointer_rtx || operands[1] == stack_pointer_rtx)"
977 "@
978 subi\t%0, %1, %2
979 addi\t%0, %1, %M2
980 subu\t%0, %1, %2
981 addi\t%0, %1, %M2
982 subu\t%0, %1, %2
983 subi\t%0, %1, %2"
984 [(set_attr "length" "2,2,2,2,2,4")
985 (set_attr "type" "addsub")]
986 )
987
988 (define_insn "*ck801_subsi3"
989 [(set (match_operand:SI 0 "register_operand" "=a,a,a,a,a,a")
990 (minus:SI (match_operand:SI 1 "register_operand" "0, a,0,a,0,a")
991 (match_operand:SI 2 "nonmemory_operand" "a, a,N,L,T,Us")))]
992 "CSKY_ISA_FEATURE (E1)
993 && operands[0] != stack_pointer_rtx
994 && operands[1] != stack_pointer_rtx"
995 "@
996 subu\t%0, %1, %2
997 subu\t%0, %1, %2
998 subi\t%0, %1, %2
999 subi\t%0, %1, %2
1000 addi\t%0, %1, %M2
1001 addi\t%0, %1, %M2"
1002 [(set_attr "type" "addsub")]
1003 )
1004
1005 (define_insn "*ck801_subsi3_sp"
1006 [(set (match_operand:SI 0 "register_operand" "=a,z,z, z")
1007 (minus:SI (match_operand:SI 1 "register_operand" "z, 0,0, 0")
1008 (match_operand:SI 2 "nonmemory_operand" "Ur,P,Ug,r")))]
1009 "CSKY_ISA_FEATURE (E1)
1010 && (operands[0] == stack_pointer_rtx || operands[1] == stack_pointer_rtx)"
1011 "@
1012 addi\t%0, %1, %M2
1013 subi\t%0, %1, %2
1014 addi\t%0, %1, %M2
1015 subu\t%0, %1, %2"
1016 [(set_attr "type" "addsub")]
1017 )
1018
1019 (define_insn "fast_subsi3"
1020 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1021 (minus:SI (match_operand:SI 1 "register_operand" "r, r,r")
1022 (match_operand:SI 2 "nonmemory_operand" "r, M,Um")))]
1023 "!TARGET_MINI_REGISTERS && CSKY_ISA_FEATURE (E2)"
1024 "@
1025 subu\t%0, %1, %2
1026 subi\t%0, %1, %2
1027 addi\t%0, %1, %M2"
1028 [(set_attr "type" "addsub")]
1029 )
1030
1031 (define_expand "subdi3"
1032 [(parallel [(set (match_operand:DI 0 "register_operand" "")
1033 (minus:DI (match_operand:DI 1 "register_operand" "")
1034 (match_operand:DI 2 "register_operand" "")))
1035 (clobber (reg:CC CSKY_CC_REGNUM))])]
1036 ""
1037 ""
1038 )
1039
1040 /* Note that the csky subc instruction both reads and writes the C bit.
1041 The purpose of the initial cmphs instruction in the expansion is to
1042 set the C bit before subtracting the lo words. */
1043
1044 (define_insn_and_split "*cskyv2_subdi3"
1045 [(set (match_operand:DI 0 "register_operand" "=&b,&r")
1046 (minus:DI (match_operand:DI 1 "register_operand" "0, r")
1047 (match_operand:DI 2 "register_operand" "b, r")))
1048 (clobber (reg:CC CSKY_CC_REGNUM))]
1049 "CSKY_ISA_FEATURE (E2)"
1050 "#"
1051 "reload_completed"
1052 [(const_int 0)]
1053 {
1054 int hi = TARGET_BIG_ENDIAN ? 0 : UNITS_PER_WORD;
1055 int lo = TARGET_BIG_ENDIAN ? UNITS_PER_WORD : 0;
1056 rtx l0 = simplify_gen_subreg (SImode, operands[0], DImode, lo);
1057 rtx h0 = simplify_gen_subreg (SImode, operands[0], DImode, hi);
1058 rtx l1 = simplify_gen_subreg (SImode, operands[1], DImode, lo);
1059 rtx h1 = simplify_gen_subreg (SImode, operands[1], DImode, hi);
1060 rtx l2 = simplify_gen_subreg (SImode, operands[2], DImode, lo);
1061 rtx h2 = simplify_gen_subreg (SImode, operands[2], DImode, hi);
1062
1063 emit_insn (gen_cmpgeusi_r (copy_rtx (l1), copy_rtx (l1)));
1064 emit_insn (gen_cskyv2_subc (l0, l1, l2));
1065 emit_insn (gen_cskyv2_subc (h0, h1, h2));
1066 DONE;
1067 }
1068 [(set_attr "length" "6,12")]
1069 )
1070
1071 (define_insn_and_split "*ck801_subdi3"
1072 [(set (match_operand:DI 0 "register_operand" "=r")
1073 (minus:DI (match_operand:DI 1 "register_operand" "0")
1074 (match_operand:DI 2 "register_operand" "r")))
1075 (clobber (reg:CC CSKY_CC_REGNUM))]
1076 "CSKY_ISA_FEATURE (E1)"
1077 "#"
1078 "reload_completed"
1079 [(const_int 0)]
1080 {
1081 int hi = TARGET_BIG_ENDIAN ? 0 : UNITS_PER_WORD;
1082 int lo = TARGET_BIG_ENDIAN ? UNITS_PER_WORD : 0;
1083 rtx l0 = simplify_gen_subreg (SImode, operands[0], DImode, lo);
1084 rtx h0 = simplify_gen_subreg (SImode, operands[0], DImode, hi);
1085 rtx l1 = simplify_gen_subreg (SImode, operands[1], DImode, lo);
1086 rtx h1 = simplify_gen_subreg (SImode, operands[1], DImode, hi);
1087 rtx l2 = simplify_gen_subreg (SImode, operands[2], DImode, lo);
1088 rtx h2 = simplify_gen_subreg (SImode, operands[2], DImode, hi);
1089
1090 emit_insn (gen_cmpgeusi_r (copy_rtx (l1), copy_rtx (l1)));
1091 emit_insn (gen_ck801_subc (l0, l1, l2));
1092 emit_insn (gen_ck801_subc (h0, h1, h2));
1093 DONE;
1094 }
1095 [(set_attr "length" "6")]
1096 )
1097
1098 ;; Special case for "longlong -= 1".
1099
1100 (define_insn_and_split "*cskyv2_subdi1_1"
1101 [(set (match_operand:DI 0 "register_operand" "=&r")
1102 (plus:DI (match_operand:DI 1 "register_operand" "0")
1103 (const_int -1)))
1104 (clobber (reg:CC CSKY_CC_REGNUM))]
1105 "CSKY_ISA_FEATURE (E2)"
1106 "#"
1107 "reload_completed"
1108 [(const_int 0)]
1109 {
1110 int hi = TARGET_BIG_ENDIAN ? 0 : UNITS_PER_WORD;
1111 int lo = TARGET_BIG_ENDIAN ? UNITS_PER_WORD : 0;
1112 rtx l0 = simplify_gen_subreg (SImode, operands[0], DImode, lo);
1113 rtx h0 = simplify_gen_subreg (SImode, operands[0], DImode, hi);
1114
1115 if (TARGET_MINI_REGISTERS)
1116 {
1117 emit_insn (gen_smart_cmpnesi_i (copy_rtx (l0),
1118 gen_int_mode (0, SImode)));
1119 emit_insn (gen_cskyv2_addcc_invert (h0, copy_rtx (h0),
1120 gen_int_mode (-1, SImode)));
1121 emit_insn (gen_smart_subsi3 (l0, copy_rtx (l0),
1122 gen_int_mode (1, SImode)));
1123 }
1124 else
1125 {
1126 emit_insn (gen_fast_cmpnesi_i (copy_rtx (l0),
1127 gen_int_mode (0, SImode)));
1128 emit_insn (gen_cskyv2_addcc_invert (h0, copy_rtx (h0),
1129 gen_int_mode (-1, SImode)));
1130 emit_insn (gen_fast_subsi3 (l0, copy_rtx (l0),
1131 gen_int_mode (1, SImode)));
1132 }
1133 DONE;
1134 }
1135 [(set (attr "length")
1136 (if_then_else (match_test "TARGET_MINI_REGISTERS")
1137 (const_int 8)
1138 (const_int 12)))]
1139 )
1140
1141 ;; Add with carry.
1142
1143 (define_insn "cskyv2_addc"
1144 [(set (match_operand:SI 0 "register_operand" "=r,r")
1145 (plus:SI (ne:SI (reg:CC CSKY_CC_REGNUM) (const_int 0))
1146 (plus:SI (match_operand:SI 1 "register_operand" "%0,r")
1147 (match_operand:SI 2 "register_operand" "r,r"))))
1148 (set (reg:CC CSKY_CC_REGNUM)
1149 (compare:CC
1150 (plus:SI (match_dup 1) (match_dup 2))
1151 (match_dup 1)))]
1152 "CSKY_ISA_FEATURE (E2)"
1153 "addc\t%0, %1, %2"
1154 [(set_attr "length" "2,4")
1155 (set_attr "type" "addsub")]
1156 )
1157
1158 (define_insn "ck801_addc"
1159 [(set (match_operand:SI 0 "register_operand" "=r")
1160 (plus:SI (ne:SI (reg:CC CSKY_CC_REGNUM) (const_int 0))
1161 (plus:SI (match_operand:SI 1 "register_operand" "%0")
1162 (match_operand:SI 2 "register_operand" "r"))))
1163 (set (reg:CC CSKY_CC_REGNUM)
1164 (compare:CC
1165 (plus:SI (match_dup 1) (match_dup 2))
1166 (match_dup 1)))]
1167 "CSKY_ISA_FEATURE (E1)"
1168 "addc\t%0, %1, %2"
1169 [(set_attr "length" "2")
1170 (set_attr "type" "addsub")]
1171 )
1172
1173 ;; Subtract with borrow.
1174 ;; Note that in these insns, the sense of C bit is reversed; they subtract 1
1175 ;; if the C bit is not set, and on output the bit is set to 0 for borrow
1176 ;; and 1 for no borrow.
1177
1178 (define_insn "cskyv2_subc"
1179 [(set (match_operand:SI 0 "register_operand" "=r,r")
1180 (minus:SI (match_operand:SI 1 "register_operand" "0, r")
1181 (plus:SI (match_operand:SI 2 "register_operand" "r, r")
1182 (eq:SI (reg:CC CSKY_CC_REGNUM) (const_int 0)))))
1183 (set (reg:CC CSKY_CC_REGNUM)
1184 (not (compare:CC (match_dup 1) (match_dup 2))))]
1185 "CSKY_ISA_FEATURE (E2)"
1186 "subc\t%0, %1, %2"
1187 [(set_attr "length" "2,4")
1188 (set_attr "type" "addsub")]
1189 )
1190
1191 (define_insn "ck801_subc"
1192 [(set (match_operand:SI 0 "register_operand" "=r")
1193 (minus:SI (match_operand:SI 1 "register_operand" "0")
1194 (plus:SI (match_operand:SI 2 "register_operand" "r")
1195 (eq:SI (reg:CC CSKY_CC_REGNUM) (const_int 0)))))
1196 (set (reg:CC CSKY_CC_REGNUM)
1197 (not (compare:CC (match_dup 1) (match_dup 2))))]
1198 "CSKY_ISA_FEATURE (E1)"
1199 "subc\t%0, %1, %2"
1200 [(set_attr "length" "2")
1201 (set_attr "type" "addsub")]
1202 )
1203
1204 ;; ------------------------------------------------------------------------
1205 ;; Multiplication insns
1206 ;; ------------------------------------------------------------------------
1207
1208 (define_expand "mulsi3"
1209 [(set (match_operand:SI 0 "register_operand" "")
1210 (mult:SI (match_operand:SI 1 "register_operand" "")
1211 (match_operand:SI 2 "register_operand" "")))]
1212 ""
1213 ""
1214 )
1215
1216 (define_insn "*cskyv2_mulsi3"
1217 [(set (match_operand:SI 0 "register_operand" "=r")
1218 (mult:SI (match_operand:SI 1 "register_operand" "%r")
1219 (match_operand:SI 2 "register_operand" "r")))]
1220 "CSKY_ISA_FEATURE (E2)"
1221 "mult\t%0, %1, %2"
1222 )
1223
1224 (define_insn "*ck801_mulsi3"
1225 [(set (match_operand:SI 0 "register_operand" "=r")
1226 (mult:SI (match_operand:SI 1 "register_operand" "%0")
1227 (match_operand:SI 2 "register_operand" "r")))]
1228 "CSKY_ISA_FEATURE (E1)"
1229 "mult\t%0, %1, %2"
1230 )
1231
1232 (define_insn "mulhisi3"
1233 [(set (match_operand:SI 0 "register_operand" "=r")
1234 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "%r"))
1235 (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
1236 "CSKY_ISA_FEATURE (2E3)"
1237 "mulsh\t%0, %1, %2"
1238 )
1239
1240
1241 ;; ------------------------------------------------------------------------
1242 ;; Conditional add insns
1243 ;; ------------------------------------------------------------------------
1244
1245 (define_expand "addsicc"
1246 [(match_operand:SI 0 "register_operand" "")
1247 (match_operand 1 "comparison_operator" "")
1248 (match_operand:SI 2 "register_operand" "")
1249 (match_operand:SI 3 "csky_literal_K_Uh_operand" "")]
1250 "CSKY_ISA_FEATURE (E2)"
1251 "
1252 {
1253 bool invert = csky_emit_compare (GET_CODE (operands[1]),
1254 XEXP (operands[1], 0),
1255 XEXP (operands[1], 1));
1256 if (invert)
1257 emit_insn (gen_cskyv2_addcc_invert (operands[0], operands[2],
1258 operands[3]));
1259 else
1260 emit_insn (gen_cskyv2_addcc (operands[0], operands[2], operands[3]));
1261
1262 DONE;
1263 }"
1264 )
1265
1266 (define_insn_and_split "cskyv2_addcc"
1267 [(set (match_operand:SI 0 "register_operand" "=r,r,&r,&r")
1268 (if_then_else:SI
1269 (ne (reg:CC CSKY_CC_REGNUM) (const_int 0))
1270 (plus:SI (match_operand:SI 1 "register_operand" "0,0,r,r")
1271 (match_operand:SI 2 "csky_literal_K_Uh_operand" "K,Uh,K,Uh"))
1272 (match_dup 1)))]
1273 "CSKY_ISA_FEATURE (E2)"
1274 "@
1275 inct\t%0, %1, %2
1276 dect\t%0, %1, %M2
1277 #
1278 #"
1279 "reload_completed && !rtx_equal_p (operands[0], operands[1])"
1280 [(set (match_dup 0)
1281 (if_then_else:SI (ne (reg:CC CSKY_CC_REGNUM) (const_int 0))
1282 (plus:SI (match_dup 0) (match_dup 2))
1283 (match_dup 0)))]
1284 {
1285 emit_insn (gen_movf (copy_rtx (operands[0]),
1286 copy_rtx (operands[1]),
1287 copy_rtx (operands[0])));
1288 }
1289 [(set_attr "length" "4,4,8,8")
1290 (set_attr "type" "addsub")]
1291 )
1292
1293 (define_insn_and_split "cskyv2_addcc_invert"
1294 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1295 (if_then_else:SI
1296 (eq (reg:CC CSKY_CC_REGNUM) (const_int 0))
1297 (plus:SI (match_operand:SI 1 "register_operand" "0,0,r,r")
1298 (match_operand:SI 2 "csky_literal_K_Uh_operand" "K,Uh,K,Uh"))
1299 (match_dup 1)))]
1300 "CSKY_ISA_FEATURE (E2)"
1301 "@
1302 incf\t%0, %1, %2
1303 decf\t%0, %1, %M2
1304 #
1305 #"
1306 "reload_completed && !rtx_equal_p (operands[0], operands[1])"
1307 [(set (match_dup 0)
1308 (if_then_else:SI (eq (reg:CC CSKY_CC_REGNUM) (const_int 0))
1309 (plus:SI (match_dup 0) (match_dup 2))
1310 (match_dup 0)))]
1311 {
1312 emit_insn (gen_movt (copy_rtx (operands[0]),
1313 copy_rtx (operands[1]),
1314 copy_rtx (operands[0])));
1315 }
1316 [(set_attr "length" "4,4,8,8")
1317 (set_attr "type" "addsub")]
1318 )
1319
1320
1321 ;; ------------------------------------------------------------------------
1322 ;; Extzv insns
1323 ;; ------------------------------------------------------------------------
1324
1325 (define_expand "extzvsi"
1326 [(set (match_operand:SI 0 "register_operand" "")
1327 (zero_extract:SI (match_operand:SI 1 "register_operand" "")
1328 (match_operand:SI 2 "const_int_operand" "")
1329 (match_operand:SI 3 "const_int_operand" "")))]
1330 ""
1331 "{
1332 /* ck802 has xtrb but not zext, so we'll use xtrb if we can. */
1333 if (CSKY_ISA_FEATURE (E2) && !CSKY_ISA_FEATURE (2E3)
1334 && (INTVAL (operands[2]) == 8)
1335 && (INTVAL (operands[3]) % 8 == 0))
1336 {
1337 rtx xtrb = gen_rtx_SET (operands[0],
1338 gen_rtx_ZERO_EXTRACT (SImode,
1339 operands[1],
1340 operands[2],
1341 operands[3]));
1342 emit (gen_rtx_PARALLEL (VOIDmode,
1343 gen_rtvec (2, xtrb,
1344 gen_hard_reg_clobber (CCmode, 33))));
1345 DONE;
1346 }
1347 else if (!CSKY_ISA_FEATURE (2E3))
1348 {
1349 /* Use lsri and lsli to do extzv on targets without zext. */
1350 rtx lshft = GEN_INT (32 - (INTVAL (operands[2])
1351 + INTVAL (operands[3])));
1352 rtx rshft = GEN_INT (32 - INTVAL (operands[2]));
1353 rtx tmp1 = gen_reg_rtx (SImode);
1354 rtx tmp2 = gen_reg_rtx (SImode);
1355
1356 emit_insn (gen_rtx_SET (tmp1, operands[1]));
1357 emit_insn (gen_rtx_SET (tmp2, gen_rtx_ASHIFT (SImode, tmp1, lshft)));
1358 emit_insn (gen_rtx_SET (operands[0],
1359 gen_rtx_LSHIFTRT (SImode, tmp2, rshft)));
1360 DONE;
1361 }
1362 else
1363 {
1364 emit_insn (gen_cskyv2_extzv (operands[0], operands[1],
1365 operands[2], operands[3]));
1366 DONE;
1367 }
1368 }")
1369
1370 (define_insn "cskyv2_extzv"
1371 [(set (match_operand:SI 0 "register_operand" "=r")
1372 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
1373 (match_operand:SI 2 "csky_literal_K_operand" "K")
1374 (match_operand:SI 3 "csky_literal_K_operand" "K")))]
1375 "CSKY_ISA_FEATURE (2E3)"
1376 {
1377 operands[2] = GEN_INT (INTVAL (operands[3]) + INTVAL (operands[2]) - 1);
1378 return \"zext\t%0, %1, %2, %3\";
1379 }
1380 )
1381
1382 (define_insn "*cskyv2_xtrb0"
1383 [(set (match_operand:SI 0 "register_operand" "=r,r")
1384 (zero_extract:SI (match_operand:SI 1 "register_operand" "0,r")
1385 (const_int 8)
1386 (const_int 24)))
1387 (clobber (reg:CC CSKY_CC_REGNUM))]
1388 "CSKY_ISA_FEATURE (E2)"
1389 "@
1390 lsri\t%0, %0, 24
1391 xtrb0\t%0, %1"
1392 )
1393
1394 (define_insn "*cskyv2_xtrb1"
1395 [(set (match_operand:SI 0 "register_operand" "=r")
1396 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
1397 (const_int 8)
1398 (const_int 16)))
1399 (clobber (reg:CC CSKY_CC_REGNUM))]
1400 "CSKY_ISA_FEATURE (E2)"
1401 "xtrb1\t%0, %1"
1402 )
1403
1404 (define_insn "*cskyv2_xtrb2"
1405 [(set (match_operand:SI 0 "register_operand" "=r")
1406 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
1407 (const_int 8)
1408 (const_int 8)))
1409 (clobber (reg:CC CSKY_CC_REGNUM))]
1410 "CSKY_ISA_FEATURE (E2)"
1411 "xtrb2\t%0, %1"
1412 )
1413
1414
1415 ;; -------------------------------------------------------------------------
1416 ;; Zero extension instructions
1417 ;; -------------------------------------------------------------------------
1418
1419 (define_insn "zero_extendhisi2"
1420 [(set (match_operand:SI 0 "register_operand" "=r")
1421 (zero_extend:SI (match_operand:HI 1 "register_operand" "r")))]
1422 ""
1423 "zexth\t%0, %1"
1424 )
1425
1426 (define_insn "*cskyv2_zextend_ldh"
1427 [(set (match_operand:SI 0 "register_operand" "=r")
1428 (zero_extend:SI (match_operand:HI 1 "csky_simple_mem_operand" "m")))]
1429 ""
1430 "ld.h\t%0, %1"
1431 [(set_attr "length" "4")
1432 (set_attr "type" "load")]
1433 )
1434
1435 (define_insn "zero_extendqisi2"
1436 [(set (match_operand:SI 0 "register_operand" "=r")
1437 (zero_extend:SI (match_operand:QI 1 "register_operand" "r")))]
1438 ""
1439 "zextb\t%0, %1"
1440 )
1441
1442 (define_insn "*cskyv2_zextend_ldb"
1443 [(set (match_operand:SI 0 "register_operand" "=r")
1444 (zero_extend:SI (match_operand:QI 1 "csky_simple_mem_operand" "m")))]
1445 ""
1446 "ld.b\t%0, %1"
1447 [(set_attr "length" "4")
1448 (set_attr "type" "load")]
1449 )
1450
1451 (define_insn "zero_extendqihi2"
1452 [(set (match_operand:HI 0 "register_operand" "=r")
1453 (zero_extend:HI (match_operand:QI 1 "register_operand" "r")))]
1454 ""
1455 "zextb\t%0, %1"
1456 )
1457
1458 (define_insn "*cskyv2_zextend_ldbhi"
1459 [(set (match_operand:HI 0 "register_operand" "=r")
1460 (zero_extend:HI (match_operand:QI 1 "csky_simple_mem_operand" "m")))]
1461 ""
1462 "ld.b\t%0, %1"
1463 [(set_attr "length" "4")
1464 (set_attr "type" "load")]
1465 )
1466
1467 ;; -------------------------------------------------------------------------
1468 ;; clzm2 instructions
1469 ;; -------------------------------------------------------------------------
1470
1471 (define_insn "clzsi2"
1472 [(set (match_operand:SI 0 "register_operand" "=r")
1473 (clz:SI (match_operand:SI 1 "register_operand" "r")))]
1474 "CSKY_ISA_FEATURE (E2)"
1475 "ff1 %0,%1"
1476 )
1477
1478 ;; -------------------------------------------------------------------------
1479 ;; one_cmplm2 instructions
1480 ;; -------------------------------------------------------------------------
1481
1482 (define_expand "one_cmplsi2"
1483 [(set (match_operand:SI 0 "register_operand" "")
1484 (not:SI (match_operand:SI 1 "register_operand" "")))]
1485 ""
1486 ""
1487 )
1488
1489 (define_insn "cskyv2_one_cmplsi2"
1490 [(set (match_operand:SI 0 "register_operand" "=b,r")
1491 (not:SI (match_operand:SI 1 "register_operand" "0,r")))]
1492 "CSKY_ISA_FEATURE (E2)"
1493 "not %0, %1"
1494 [(set_attr "length" "2,4")
1495 (set_attr "type" "alu,alu")]
1496 )
1497
1498 (define_insn "ck801_one_cmplsi2"
1499 [(set (match_operand:SI 0 "register_operand" "=r")
1500 (not:SI (match_operand:SI 1 "register_operand" "0")))]
1501 "CSKY_ISA_FEATURE (E1)"
1502 "not %0, %1"
1503 [(set_attr "length" "2")
1504 (set_attr "type" "alu")]
1505 )
1506
1507 ;; -------------------------------------------------------------------------
1508 ;; Sign extension instructions
1509 ;; -------------------------------------------------------------------------
1510
1511 ;; One test shows that the following code helps to
1512 ;; reduce one 'load' and two 'mov'.
1513 (define_expand "extendsidi2"
1514 [(set (match_operand:DI 0 "register_operand" "=r")
1515 (match_operand:SI 1 "register_operand" "r"))]
1516 ""
1517 "{
1518 int low, high;
1519
1520 if (TARGET_BIG_ENDIAN)
1521 low = 4, high = 0;
1522 else
1523 low = 0, high = 4;
1524
1525 emit_insn (gen_rtx_SET (gen_rtx_SUBREG (SImode, operands[0], low),
1526 operands[1]));
1527
1528 emit_insn (gen_rtx_SET (gen_rtx_SUBREG (SImode, operands[0], high),
1529 gen_rtx_ASHIFTRT (SImode,
1530 gen_rtx_SUBREG (SImode,
1531 operands[0],
1532 low),
1533 GEN_INT (31))));
1534 DONE;
1535 }"
1536 )
1537
1538 ;; hi -> si
1539 (define_insn "extendhisi2"
1540 [(set (match_operand:SI 0 "register_operand" "=r")
1541 (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
1542 ""
1543 "sexth %0, %1"
1544 )
1545
1546 (define_insn "*cskyv2_sextend_ldhs"
1547 [(set (match_operand:SI 0 "register_operand" "=r")
1548 (sign_extend:SI (match_operand:HI 1 "csky_simple_mem_operand" "m")))]
1549 "CSKY_ISA_FEATURE (E2)"
1550 "ld.hs\t%0, %1"
1551 [(set_attr "length" "4")
1552 (set_attr "type" "load")]
1553 )
1554
1555 ;; qi -> si
1556 (define_insn "extendqisi2"
1557 [(set (match_operand:SI 0 "register_operand" "=r")
1558 (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
1559 ""
1560 "sextb %0, %1"
1561 )
1562
1563 (define_insn "*cskyv2_sextend_ldbs"
1564 [(set (match_operand:SI 0 "register_operand" "=r")
1565 (sign_extend:SI (match_operand:QI 1 "csky_simple_mem_operand" "m")))]
1566 "CSKY_ISA_FEATURE (E2)"
1567 "ld.bs\t%0, %1"
1568 [(set_attr "length" "4")
1569 (set_attr "type" "load")]
1570 )
1571
1572 ;; qi -> hi
1573 (define_insn "extendqihi2"
1574 [(set (match_operand:HI 0 "register_operand" "=r")
1575 (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
1576 ""
1577 "sextb %0, %1"
1578 )
1579
1580 ;; -------------------------------------------------------------------------
1581 ;; And instructions
1582 ;; -------------------------------------------------------------------------
1583
1584 (define_expand "andsi3"
1585 [(set (match_operand:SI 0 "register_operand" "")
1586 (and:SI (match_operand:SI 1 "register_operand" "")
1587 (match_operand:SI 2 "csky_arith_any_imm_operand" "")))]
1588 ""
1589 "")
1590
1591 (define_insn_and_split "cskyv2_andsi3"
1592 [(set (match_operand:SI 0 "register_operand" "=b,r,r,&r")
1593 (and:SI (match_operand:SI 1 "register_operand" "%0,r,r,r")
1594 (match_operand:SI 2 "csky_arith_any_imm_operand" "b,r,O,i")))]
1595 "CSKY_ISA_FEATURE (E2)"
1596 "@
1597 and\t%0, %1, %2
1598 and\t%0, %1, %2
1599 andi\t%0, %1, %2
1600 #"
1601 "(CONST_INT_P (operands[2])
1602 && (operands[2] == const0_rtx
1603 || !csky_arith_O_operand (operands[2], SImode)))"
1604 [(set (match_dup 0) (and:SI (match_dup 1) (match_dup 2)))]
1605 {
1606 if (csky_split_and (operands))
1607 DONE;
1608 }
1609 [(set_attr "length" "2,4,4,8")
1610 (set_attr "type" "alu,alu,alu,alu")]
1611 )
1612
1613 (define_insn_and_split "ck801_andsi3"
1614 [(set (match_operand:SI 0 "register_operand" "=r,&r")
1615 (and:SI (match_operand:SI 1 "register_operand" "%0,r")
1616 (match_operand:SI 2 "csky_arith_any_imm_operand" "r,i")))]
1617 "CSKY_ISA_FEATURE (E1)"
1618 "@
1619 and\t%0, %1, %2
1620 #"
1621 "CONST_INT_P (operands[2])"
1622 [(set (match_dup 0) (and:SI (match_dup 1) (match_dup 2)))]
1623 {
1624 if (csky_split_and (operands))
1625 DONE;
1626 }
1627 [(set_attr "length" "2,4")
1628 (set_attr "type" "alu,alu")]
1629 )
1630
1631 ;; Note that the operands for the andnsi3 patterns are reversed compared
1632 ;; to the actual machine insn: operand 1 is the inverted operand.
1633
1634 (define_insn "cskyv2_andnsi3"
1635 [(use (and:SI (not:SI (match_operand:SI 1 "csky_arith_O_operand" "b,r,O"))
1636 (match_operand:SI 2 "register_operand" "0,r,r")))
1637 (set (match_operand:SI 0 "register_operand" "=b,r,r")
1638 (and:SI (not:SI (match_dup 1))
1639 (match_dup 2)))]
1640 "CSKY_ISA_FEATURE (E2)"
1641 "@
1642 andn\t%0, %2, %1
1643 andn\t%0, %2, %1
1644 andni\t%0, %2, %1"
1645 [(set_attr "length" "2,4,4")
1646 (set_attr "type" "alu,alu,alu")]
1647 )
1648
1649 (define_insn "ck801_andnsi3"
1650 [(use (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
1651 (match_operand:SI 2 "register_operand" "0")))
1652 (set (match_operand:SI 0 "register_operand" "=r")
1653 (and:SI (not:SI (match_dup 1))
1654 (match_dup 2)))]
1655 "CSKY_ISA_FEATURE (E1)"
1656 "andn\t%0, %2, %1"
1657 )
1658
1659 (define_expand "anddi3"
1660 [(set (match_operand:DI 0 "register_operand" "")
1661 (and:DI (match_operand:DI 1 "register_operand" "")
1662 (match_operand:DI 2 "csky_arith_any_imm_operand" "")))]
1663 ""
1664 "
1665 {
1666 if (CONST_INT_P (operands[2]))
1667 {
1668 HOST_WIDE_INT ival = INTVAL (operands[2]);
1669 if (ival == (HOST_WIDE_INT) 0xffffffff)
1670 {
1671 emit_move_insn (gen_lowpart (SImode, operands[0]),
1672 gen_lowpart (SImode, operands[1]));
1673 emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
1674 DONE;
1675 }
1676 else if (ival == (HOST_WIDE_INT) ((unsigned HOST_WIDE_INT) -1 << 32))
1677 {
1678 emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
1679 emit_move_insn (gen_highpart (SImode, operands[0]),
1680 gen_highpart (SImode, operands[1]));
1681 DONE;
1682 }
1683 else
1684 FAIL;
1685 }
1686 }")
1687
1688
1689
1690 (define_insn_and_split "*cskyv2_anddi3"
1691 [(set (match_operand:DI 0 "register_operand" "=&b,&r")
1692 (and:DI (match_operand:DI 1 "register_operand" "%0,r")
1693 (match_operand:DI 2 "register_operand" "b,r")))]
1694 "CSKY_ISA_FEATURE (E2)"
1695 "#"
1696 "reload_completed"
1697 [(const_int 0)]
1698 {
1699 int hi = TARGET_BIG_ENDIAN ? 0 : UNITS_PER_WORD;
1700 int lo = TARGET_BIG_ENDIAN ? UNITS_PER_WORD : 0;
1701 rtx l0 = simplify_gen_subreg (SImode, operands[0], DImode, lo);
1702 rtx h0 = simplify_gen_subreg (SImode, operands[0], DImode, hi);
1703 rtx l1 = simplify_gen_subreg (SImode, operands[1], DImode, lo);
1704 rtx h1 = simplify_gen_subreg (SImode, operands[1], DImode, hi);
1705 rtx l2 = simplify_gen_subreg (SImode, operands[2], DImode, lo);
1706 rtx h2 = simplify_gen_subreg (SImode, operands[2], DImode, hi);
1707
1708 emit_insn (gen_cskyv2_andsi3 (l0, l1, l2));
1709 emit_insn (gen_cskyv2_andsi3 (h0, h1, h2));
1710 DONE;
1711 }
1712 [(set_attr "length" "4,8")]
1713 )
1714
1715 (define_insn_and_split "*ck801_anddi3"
1716 [(set (match_operand:DI 0 "register_operand" "=&r")
1717 (and:DI (match_operand:DI 1 "register_operand" "%0")
1718 (match_operand:DI 2 "register_operand" "r")))]
1719 "CSKY_ISA_FEATURE (E1)"
1720 "#"
1721 "reload_completed"
1722 [(const_int 0)]
1723 {
1724 int hi = TARGET_BIG_ENDIAN ? 0 : UNITS_PER_WORD;
1725 int lo = TARGET_BIG_ENDIAN ? UNITS_PER_WORD : 0;
1726 rtx l0 = simplify_gen_subreg (SImode, operands[0], DImode, lo);
1727 rtx h0 = simplify_gen_subreg (SImode, operands[0], DImode, hi);
1728 rtx l1 = simplify_gen_subreg (SImode, operands[1], DImode, lo);
1729 rtx h1 = simplify_gen_subreg (SImode, operands[1], DImode, hi);
1730 rtx l2 = simplify_gen_subreg (SImode, operands[2], DImode, lo);
1731 rtx h2 = simplify_gen_subreg (SImode, operands[2], DImode, hi);
1732
1733 emit_insn (gen_ck801_andsi3 (l0, l1, l2));
1734 emit_insn (gen_ck801_andsi3 (h0, h1, h2));
1735 DONE;
1736 }
1737 [(set_attr "length" "4")]
1738 )
1739
1740
1741 ;; -------------------------------------------------------------------------
1742 ;; Ior instructions
1743 ;; -------------------------------------------------------------------------
1744
1745 (define_expand "iorsi3"
1746 [(set (match_operand:SI 0 "register_operand" "")
1747 (ior:SI (match_operand:SI 1 "register_operand" "")
1748 (match_operand:SI 2 "csky_arith_any_imm_operand" "")))]
1749 ""
1750 "")
1751
1752 (define_insn_and_split "cskyv2_iorsi3"
1753 [(set (match_operand:SI 0 "register_operand" "=b,r,r,&r")
1754 (ior:SI (match_operand:SI 1 "register_operand" "%0,r,r,r")
1755 (match_operand:SI 2 "csky_arith_any_imm_operand" "b, r,I,i")))]
1756 "CSKY_ISA_FEATURE (E2)"
1757 "@
1758 or\t%0, %1, %2
1759 or\t%0, %1, %2
1760 ori\t%0, %1, %2
1761 #"
1762 "(CONST_INT_P (operands[2])
1763 && (operands[2] == const0_rtx
1764 || !csky_literal_I_operand (operands[2], SImode)))"
1765 [(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 2)))]
1766 {
1767 if (csky_split_ior (operands))
1768 DONE;
1769 }
1770 [(set_attr "length" "2,4,4,8")
1771 (set_attr "type" "alu,alu,alu,alu")]
1772 )
1773
1774 (define_insn_and_split "ck801_iorsi3"
1775 [(set (match_operand:SI 0 "register_operand" "=r,&r")
1776 (ior:SI (match_operand:SI 1 "register_operand" "%0,r")
1777 (match_operand:SI 2 "csky_arith_any_imm_operand" "r,i")))]
1778 "CSKY_ISA_FEATURE (E1)"
1779 "@
1780 or\t%0, %1, %2
1781 #"
1782 "CONST_INT_P (operands[2])"
1783 [(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 2)))]
1784 {
1785 if (csky_split_ior (operands))
1786 DONE;
1787 }
1788 [(set_attr "length" "2,4")
1789 (set_attr "type" "alu,alu")]
1790 )
1791
1792 (define_expand "iordi3"
1793 [(set (match_operand:DI 0 "register_operand" "")
1794 (ior:DI (match_operand:DI 1 "register_operand" "")
1795 (match_operand:DI 2 "register_operand" "")))]
1796 ""
1797 ""
1798 )
1799
1800 (define_insn_and_split "*cskyv2_iordi3"
1801 [(set (match_operand:DI 0 "register_operand" "=&b,&r")
1802 (ior:DI (match_operand:DI 1 "register_operand" "%0, r")
1803 (match_operand:DI 2 "register_operand" "b, r")))]
1804 "CSKY_ISA_FEATURE (E2)"
1805 "#"
1806 "reload_completed"
1807 [(const_int 0)]
1808 {
1809 int hi = TARGET_BIG_ENDIAN ? 0 : UNITS_PER_WORD;
1810 int lo = TARGET_BIG_ENDIAN ? UNITS_PER_WORD : 0;
1811 rtx l0 = simplify_gen_subreg (SImode, operands[0], DImode, lo);
1812 rtx h0 = simplify_gen_subreg (SImode, operands[0], DImode, hi);
1813 rtx l1 = simplify_gen_subreg (SImode, operands[1], DImode, lo);
1814 rtx h1 = simplify_gen_subreg (SImode, operands[1], DImode, hi);
1815 rtx l2 = simplify_gen_subreg (SImode, operands[2], DImode, lo);
1816 rtx h2 = simplify_gen_subreg (SImode, operands[2], DImode, hi);
1817
1818 emit_insn (gen_cskyv2_iorsi3 (l0, l1, l2));
1819 emit_insn (gen_cskyv2_iorsi3 (h0, h1, h2));
1820 DONE;
1821 }
1822 [(set_attr "length" "4,8")]
1823 )
1824
1825 (define_insn_and_split "*ck801_iordi3"
1826 [(set (match_operand:DI 0 "register_operand" "=&r")
1827 (ior:DI (match_operand:DI 1 "register_operand" "%0")
1828 (match_operand:DI 2 "register_operand" "r")))]
1829 "CSKY_ISA_FEATURE (E1)"
1830 "#"
1831 "reload_completed"
1832 [(const_int 0)]
1833 {
1834 int hi = TARGET_BIG_ENDIAN ? 0 : UNITS_PER_WORD;
1835 int lo = TARGET_BIG_ENDIAN ? UNITS_PER_WORD : 0;
1836 rtx l0 = simplify_gen_subreg (SImode, operands[0], DImode, lo);
1837 rtx h0 = simplify_gen_subreg (SImode, operands[0], DImode, hi);
1838 rtx l1 = simplify_gen_subreg (SImode, operands[1], DImode, lo);
1839 rtx h1 = simplify_gen_subreg (SImode, operands[1], DImode, hi);
1840 rtx l2 = simplify_gen_subreg (SImode, operands[2], DImode, lo);
1841 rtx h2 = simplify_gen_subreg (SImode, operands[2], DImode, hi);
1842
1843 emit_insn (gen_ck801_iorsi3 (l0, l1, l2));
1844 emit_insn (gen_ck801_iorsi3 (h0, h1, h2));
1845 DONE;
1846 }
1847 [(set_attr "length" "4")]
1848 )
1849
1850
1851 ;; -------------------------------------------------------------------------
1852 ;; Xor instructions
1853 ;; -------------------------------------------------------------------------
1854
1855 (define_expand "xorsi3"
1856 [(set (match_operand:SI 0 "register_operand" "")
1857 (xor:SI (match_operand:SI 1 "register_operand" "")
1858 (match_operand:SI 2 "csky_arith_any_imm_operand" "")))]
1859 ""
1860 "")
1861
1862 (define_insn_and_split "cskyv2_xorsi3"
1863 [(set (match_operand:SI 0 "register_operand" "=b,r,r,&r")
1864 (xor:SI (match_operand:SI 1 "register_operand" "%0,r,r,r")
1865 (match_operand:SI 2 "csky_arith_any_imm_operand" "b, r,O,i")))]
1866 "CSKY_ISA_FEATURE (E2)"
1867 "@
1868 xor\t%0, %1, %2
1869 xor\t%0, %1, %2
1870 xori\t%0, %1, %2
1871 #"
1872 "(CONST_INT_P (operands[2])
1873 && (operands[2] == const0_rtx
1874 || !csky_arith_O_operand (operands[2], SImode)))"
1875 [(set (match_dup 0) (xor:SI (match_dup 1) (match_dup 2)))]
1876 {
1877 if (csky_split_xor (operands))
1878 DONE;
1879 }
1880 [(set_attr "length" "2,4,4,8")
1881 (set_attr "type" "alu,alu,alu,alu")]
1882 )
1883
1884 (define_insn_and_split "ck801_xorsi3"
1885 [(set (match_operand:SI 0 "register_operand" "=r,&r")
1886 (xor:SI (match_operand:SI 1 "register_operand" "%0,r")
1887 (match_operand:SI 2 "csky_arith_any_imm_operand" "r,i")))]
1888 "CSKY_ISA_FEATURE (E1)"
1889 "@
1890 xor\t%0, %1, %2
1891 #"
1892 "CONST_INT_P (operands[2])"
1893 [(set (match_dup 0) (xor:SI (match_dup 1) (match_dup 2)))]
1894 {
1895 if (csky_split_xor (operands))
1896 DONE;
1897 }
1898 [(set_attr "length" "2,4")
1899 (set_attr "type" "alu,alu")]
1900 )
1901
1902 (define_expand "xordi3"
1903 [(set (match_operand:DI 0 "register_operand" "")
1904 (xor:DI (match_operand:DI 1 "register_operand" "")
1905 (match_operand:DI 2 "register_operand" "")))]
1906 ""
1907 ""
1908 )
1909
1910 (define_insn_and_split "*cskyv2_xordi3"
1911 [(set (match_operand:DI 0 "register_operand" "=&b,&r")
1912 (xor:DI (match_operand:DI 1 "register_operand" "%0, r")
1913 (match_operand:DI 2 "register_operand" "b, r")))]
1914 "CSKY_ISA_FEATURE (E2)"
1915 "#"
1916 "reload_completed"
1917 [(const_int 0)]
1918 {
1919 int hi = TARGET_BIG_ENDIAN ? 0 : UNITS_PER_WORD;
1920 int lo = TARGET_BIG_ENDIAN ? UNITS_PER_WORD : 0;
1921 rtx l0 = simplify_gen_subreg (SImode, operands[0], DImode, lo);
1922 rtx h0 = simplify_gen_subreg (SImode, operands[0], DImode, hi);
1923 rtx l1 = simplify_gen_subreg (SImode, operands[1], DImode, lo);
1924 rtx h1 = simplify_gen_subreg (SImode, operands[1], DImode, hi);
1925 rtx l2 = simplify_gen_subreg (SImode, operands[2], DImode, lo);
1926 rtx h2 = simplify_gen_subreg (SImode, operands[2], DImode, hi);
1927
1928 emit_insn (gen_cskyv2_xorsi3 (l0, l1, l2));
1929 emit_insn (gen_cskyv2_xorsi3 (h0, h1, h2));
1930 DONE;
1931 }
1932 [(set_attr "length" "4,8")]
1933 )
1934
1935 (define_insn_and_split "*ck801_xordi3"
1936 [(set (match_operand:DI 0 "register_operand" "=&r")
1937 (xor:DI (match_operand:DI 1 "register_operand" "%0")
1938 (match_operand:DI 2 "register_operand" "r")))]
1939 "CSKY_ISA_FEATURE (E1)"
1940 "#"
1941 "reload_completed"
1942 [(const_int 0)]
1943 {
1944 int hi = TARGET_BIG_ENDIAN ? 0 : UNITS_PER_WORD;
1945 int lo = TARGET_BIG_ENDIAN ? UNITS_PER_WORD : 0;
1946 rtx l0 = simplify_gen_subreg (SImode, operands[0], DImode, lo);
1947 rtx h0 = simplify_gen_subreg (SImode, operands[0], DImode, hi);
1948 rtx l1 = simplify_gen_subreg (SImode, operands[1], DImode, lo);
1949 rtx h1 = simplify_gen_subreg (SImode, operands[1], DImode, hi);
1950 rtx l2 = simplify_gen_subreg (SImode, operands[2], DImode, lo);
1951 rtx h2 = simplify_gen_subreg (SImode, operands[2], DImode, hi);
1952
1953 emit_insn (gen_ck801_xorsi3 (l0, l1, l2));
1954 emit_insn (gen_ck801_xorsi3 (h0, h1, h2));
1955 DONE;
1956 }
1957 [(set_attr "length" "4")]
1958 )
1959
1960 ;; -------------------------------------------------------------------------
1961 ;; Div instructions
1962 ;; -------------------------------------------------------------------------
1963
1964 (define_insn "divsi3"
1965 [(set (match_operand:SI 0 "register_operand" "=r")
1966 (div:SI (match_operand:SI 1 "register_operand" "r")
1967 (match_operand:SI 2 "register_operand" "r")))]
1968 "TARGET_DIV"
1969 "divs\t%0, %1, %2"
1970 )
1971
1972 (define_insn "udivsi3"
1973 [(set (match_operand:SI 0 "register_operand" "=r")
1974 (udiv:SI (match_operand:SI 1 "register_operand" "r")
1975 (match_operand:SI 2 "register_operand" "r")))]
1976 "TARGET_DIV"
1977 "divu\t%0, %1, %2"
1978 )
1979
1980
1981 ;; -----------------------------------------------------------------
1982 ;; Multiple load and store insns
1983 ;; -----------------------------------------------------------------
1984
1985 (define_expand "load_multiple"
1986 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
1987 (match_operand:SI 1 "" ""))
1988 (use (match_operand:SI 2 "" ""))])]
1989 "TARGET_MULTIPLE_STLD"
1990 "{
1991 int regno, count, i;
1992 rtx base,src;
1993
1994 if (GET_CODE (operands[2]) != CONST_INT
1995 || INTVAL (operands[2]) < 2
1996 || INTVAL (operands[2]) > CSKY_MAX_MULTIPLE_STLD
1997 || GET_CODE (operands[1]) != MEM
1998 || !REG_P (XEXP (operands[1], 0))
1999 || XEXP (operands[1], 0) != stack_pointer_rtx
2000 || GET_CODE (operands[0]) != REG
2001 || (REGNO (XEXP (operands[1], 0)) > REGNO (operands[0])
2002 && (REGNO (XEXP (operands[1], 0))
2003 < REGNO (operands[0]) + INTVAL (operands[2]))))
2004 FAIL;
2005
2006 count = INTVAL (operands[2]);
2007 regno = REGNO (operands[0]);
2008
2009 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2010
2011 base = force_reg (SImode, XEXP (operands[1], 0));
2012 src = replace_equiv_address (operands[1], base);
2013
2014 for (i = 0; i < count; i++)
2015 XVECEXP (operands[3], 0, i)
2016 = gen_rtx_SET (gen_rtx_REG (SImode, regno + i),
2017 adjust_address_nv (src, SImode, i * 4));
2018 }"
2019 )
2020
2021 (define_expand "store_multiple"
2022 [(match_par_dup 3 [(set (match_operand:SI 0 "")
2023 (match_operand:SI 1 ""))
2024 (use (match_operand:SI 2 ""))])]
2025 "TARGET_MULTIPLE_STLD"
2026 "{
2027 int regno, count, i;
2028 rtx base, dest;
2029
2030 /* Support only storing a constant number of registers to memory and
2031 only if at least two registers. */
2032 if (GET_CODE (operands[2]) != CONST_INT
2033 || INTVAL (operands[2]) < 2
2034 || INTVAL (operands[2]) > CSKY_MAX_MULTIPLE_STLD
2035 || GET_CODE (operands[0]) != MEM
2036 || !REG_P (XEXP (operands[0], 0))
2037 || XEXP (operands[0], 0) != stack_pointer_rtx
2038 || GET_CODE (operands[1]) != REG
2039 || (REGNO (XEXP (operands[0], 0)) >= REGNO (operands[1])
2040 && (REGNO (XEXP (operands[0], 0))
2041 < REGNO (operands[1]) + INTVAL (operands[2]))))
2042 FAIL;
2043
2044 count = INTVAL (operands[2]);
2045 regno = REGNO (operands[1]);
2046
2047 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2048
2049 base = force_reg (SImode, XEXP (operands[0], 0));
2050 dest = replace_equiv_address (operands[0], base);
2051
2052 for (i = 0; i < count; i++)
2053 XVECEXP (operands[3], 0, i)
2054 = gen_rtx_SET (adjust_address_nv (dest, SImode, i * 4),
2055 gen_rtx_REG (SImode, regno + i));
2056 }"
2057 )
2058
2059
2060 (define_insn "*csky_ldmsi12"
2061 [(match_parallel 0 "csky_load_multiple_operation"
2062 [(set (match_operand:SI 1 "register_operand" "=r")
2063 (mem:SI (match_operand:SI 2 "register_operand" "r")))
2064 (set (match_operand:SI 3 "register_operand" "=r")
2065 (mem:SI (plus:SI (match_dup 2) (const_int 4))))
2066 (set (match_operand:SI 4 "register_operand" "=r")
2067 (mem:SI (plus:SI (match_dup 2) (const_int 8))))
2068 (set (match_operand:SI 5 "register_operand" "=r")
2069 (mem:SI (plus:SI (match_dup 2) (const_int 12))))
2070 (set (match_operand:SI 6 "register_operand" "=r")
2071 (mem:SI (plus:SI (match_dup 2) (const_int 16))))
2072 (set (match_operand:SI 7 "register_operand" "=r")
2073 (mem:SI (plus:SI (match_dup 2) (const_int 20))))
2074 (set (match_operand:SI 8 "register_operand" "=r")
2075 (mem:SI (plus:SI (match_dup 2) (const_int 24))))
2076 (set (match_operand:SI 9 "register_operand" "=r")
2077 (mem:SI (plus:SI (match_dup 2) (const_int 28))))
2078 (set (match_operand:SI 10 "register_operand" "=r")
2079 (mem:SI (plus:SI (match_dup 2) (const_int 32))))
2080 (set (match_operand:SI 11 "register_operand" "=r")
2081 (mem:SI (plus:SI (match_dup 2) (const_int 36))))
2082 (set (match_operand:SI 12 "register_operand" "=r")
2083 (mem:SI (plus:SI (match_dup 2) (const_int 40))))
2084 (set (match_operand:SI 13 "register_operand" "=r")
2085 (mem:SI (plus:SI (match_dup 2) (const_int 44))))
2086 ])]
2087 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 12"
2088 {
2089 static char load_op[256] = {0};
2090 int count = REGNO (operands[1]) + XVECLEN (operands[0], 0) - 1;
2091 const char *reg_rz = reg_names[count];
2092 sprintf (load_op, \"ldm\t%%1 - %s, (%%2)\", reg_rz);
2093 return load_op;
2094 }
2095 )
2096
2097 (define_insn "*csky_ldmsi11"
2098 [(match_parallel 0 "csky_load_multiple_operation"
2099 [(set (match_operand:SI 1 "register_operand" "=r")
2100 (mem:SI (match_operand:SI 2 "register_operand" "r")))
2101 (set (match_operand:SI 3 "register_operand" "=r")
2102 (mem:SI (plus:SI (match_dup 2) (const_int 4))))
2103 (set (match_operand:SI 4 "register_operand" "=r")
2104 (mem:SI (plus:SI (match_dup 2) (const_int 8))))
2105 (set (match_operand:SI 5 "register_operand" "=r")
2106 (mem:SI (plus:SI (match_dup 2) (const_int 12))))
2107 (set (match_operand:SI 6 "register_operand" "=r")
2108 (mem:SI (plus:SI (match_dup 2) (const_int 16))))
2109 (set (match_operand:SI 7 "register_operand" "=r")
2110 (mem:SI (plus:SI (match_dup 2) (const_int 20))))
2111 (set (match_operand:SI 8 "register_operand" "=r")
2112 (mem:SI (plus:SI (match_dup 2) (const_int 24))))
2113 (set (match_operand:SI 9 "register_operand" "=r")
2114 (mem:SI (plus:SI (match_dup 2) (const_int 28))))
2115 (set (match_operand:SI 10 "register_operand" "=r")
2116 (mem:SI (plus:SI (match_dup 2) (const_int 32))))
2117 (set (match_operand:SI 11 "register_operand" "=r")
2118 (mem:SI (plus:SI (match_dup 2) (const_int 36))))
2119 (set (match_operand:SI 12 "register_operand" "=r")
2120 (mem:SI (plus:SI (match_dup 2) (const_int 40))))
2121 ])]
2122 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 11"
2123 {
2124 static char load_op[256] = {0};
2125 int count = REGNO (operands[1]) + XVECLEN (operands[0], 0) - 1;
2126 const char *reg_rz = reg_names[count];
2127 sprintf (load_op, \"ldm\t%%1 - %s, (%%2)\", reg_rz);
2128 return load_op;
2129 }
2130 )
2131
2132 (define_insn "*csky_ldmsi10"
2133 [(match_parallel 0 "csky_load_multiple_operation"
2134 [(set (match_operand:SI 1 "register_operand" "=r")
2135 (mem:SI (match_operand:SI 2 "register_operand" "r")))
2136 (set (match_operand:SI 3 "register_operand" "=r")
2137 (mem:SI (plus:SI (match_dup 2) (const_int 4))))
2138 (set (match_operand:SI 4 "register_operand" "=r")
2139 (mem:SI (plus:SI (match_dup 2) (const_int 8))))
2140 (set (match_operand:SI 5 "register_operand" "=r")
2141 (mem:SI (plus:SI (match_dup 2) (const_int 12))))
2142 (set (match_operand:SI 6 "register_operand" "=r")
2143 (mem:SI (plus:SI (match_dup 2) (const_int 16))))
2144 (set (match_operand:SI 7 "register_operand" "=r")
2145 (mem:SI (plus:SI (match_dup 2) (const_int 20))))
2146 (set (match_operand:SI 8 "register_operand" "=r")
2147 (mem:SI (plus:SI (match_dup 2) (const_int 24))))
2148 (set (match_operand:SI 9 "register_operand" "=r")
2149 (mem:SI (plus:SI (match_dup 2) (const_int 28))))
2150 (set (match_operand:SI 10 "register_operand" "=r")
2151 (mem:SI (plus:SI (match_dup 2) (const_int 32))))
2152 (set (match_operand:SI 11 "register_operand" "=r")
2153 (mem:SI (plus:SI (match_dup 2) (const_int 36))))
2154 ])]
2155 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 10"
2156 {
2157 static char load_op[256] = {0};
2158 int count = REGNO (operands[1]) + XVECLEN (operands[0], 0) - 1;
2159 const char *reg_rz = reg_names[count];
2160 sprintf (load_op, \"ldm\t%%1 - %s, (%%2)\", reg_rz);
2161 return load_op;
2162 }
2163 )
2164
2165 (define_insn "*csky_ldmsi9"
2166 [(match_parallel 0 "csky_load_multiple_operation"
2167 [(set (match_operand:SI 1 "register_operand" "=r")
2168 (mem:SI (match_operand:SI 2 "register_operand" "r")))
2169 (set (match_operand:SI 3 "register_operand" "=r")
2170 (mem:SI (plus:SI (match_dup 2) (const_int 4))))
2171 (set (match_operand:SI 4 "register_operand" "=r")
2172 (mem:SI (plus:SI (match_dup 2) (const_int 8))))
2173 (set (match_operand:SI 5 "register_operand" "=r")
2174 (mem:SI (plus:SI (match_dup 2) (const_int 12))))
2175 (set (match_operand:SI 6 "register_operand" "=r")
2176 (mem:SI (plus:SI (match_dup 2) (const_int 16))))
2177 (set (match_operand:SI 7 "register_operand" "=r")
2178 (mem:SI (plus:SI (match_dup 2) (const_int 20))))
2179 (set (match_operand:SI 8 "register_operand" "=r")
2180 (mem:SI (plus:SI (match_dup 2) (const_int 24))))
2181 (set (match_operand:SI 9 "register_operand" "=r")
2182 (mem:SI (plus:SI (match_dup 2) (const_int 28))))
2183 (set (match_operand:SI 10 "register_operand" "=r")
2184 (mem:SI (plus:SI (match_dup 2) (const_int 32))))
2185 ])]
2186 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 9"
2187 {
2188 static char load_op[256] = {0};
2189 int count = REGNO (operands[1]) + XVECLEN (operands[0], 0) - 1;
2190 const char *reg_rz = reg_names[count];
2191 sprintf (load_op, \"ldm\t%%1 - %s, (%%2)\", reg_rz);
2192 return load_op;
2193 }
2194 )
2195
2196 (define_insn "*csky_ldmsi8"
2197 [(match_parallel 0 "csky_load_multiple_operation"
2198 [(set (match_operand:SI 1 "register_operand" "=r")
2199 (mem:SI (match_operand:SI 2 "register_operand" "r")))
2200 (set (match_operand:SI 3 "register_operand" "=r")
2201 (mem:SI (plus:SI (match_dup 2) (const_int 4))))
2202 (set (match_operand:SI 4 "register_operand" "=r")
2203 (mem:SI (plus:SI (match_dup 2) (const_int 8))))
2204 (set (match_operand:SI 5 "register_operand" "=r")
2205 (mem:SI (plus:SI (match_dup 2) (const_int 12))))
2206 (set (match_operand:SI 6 "register_operand" "=r")
2207 (mem:SI (plus:SI (match_dup 2) (const_int 16))))
2208 (set (match_operand:SI 7 "register_operand" "=r")
2209 (mem:SI (plus:SI (match_dup 2) (const_int 20))))
2210 (set (match_operand:SI 8 "register_operand" "=r")
2211 (mem:SI (plus:SI (match_dup 2) (const_int 24))))
2212 (set (match_operand:SI 9 "register_operand" "=r")
2213 (mem:SI (plus:SI (match_dup 2) (const_int 28))))
2214 ])]
2215 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 8"
2216 {
2217 static char load_op[256] = {0};
2218 int count = REGNO (operands[1]) + XVECLEN (operands[0], 0) - 1;
2219 const char *reg_rz = reg_names[count];
2220 sprintf (load_op, \"ldm\t%%1 - %s, (%%2)\", reg_rz);
2221 return load_op;
2222 }
2223 )
2224
2225 (define_insn "*csky_ldmsi7"
2226 [(match_parallel 0 "csky_load_multiple_operation"
2227 [(set (match_operand:SI 1 "register_operand" "=r")
2228 (mem:SI (match_operand:SI 2 "register_operand" "r")))
2229 (set (match_operand:SI 3 "register_operand" "=r")
2230 (mem:SI (plus:SI (match_dup 2) (const_int 4))))
2231 (set (match_operand:SI 4 "register_operand" "=r")
2232 (mem:SI (plus:SI (match_dup 2) (const_int 8))))
2233 (set (match_operand:SI 5 "register_operand" "=r")
2234 (mem:SI (plus:SI (match_dup 2) (const_int 12))))
2235 (set (match_operand:SI 6 "register_operand" "=r")
2236 (mem:SI (plus:SI (match_dup 2) (const_int 16))))
2237 (set (match_operand:SI 7 "register_operand" "=r")
2238 (mem:SI (plus:SI (match_dup 2) (const_int 20))))
2239 (set (match_operand:SI 8 "register_operand" "=r")
2240 (mem:SI (plus:SI (match_dup 2) (const_int 24))))
2241 ])]
2242 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 7"
2243 {
2244 static char load_op[256] = {0};
2245 int count = REGNO (operands[1]) + XVECLEN (operands[0], 0) - 1;
2246 const char *reg_rz = reg_names[count];
2247 sprintf (load_op, \"ldm\t%%1 - %s, (%%2)\", reg_rz);
2248 return load_op;
2249 }
2250 )
2251
2252 (define_insn "*csky_ldmsi6"
2253 [(match_parallel 0 "csky_load_multiple_operation"
2254 [(set (match_operand:SI 1 "register_operand" "=r")
2255 (mem:SI (match_operand:SI 2 "register_operand" "r")))
2256 (set (match_operand:SI 3 "register_operand" "=r")
2257 (mem:SI (plus:SI (match_dup 2) (const_int 4))))
2258 (set (match_operand:SI 4 "register_operand" "=r")
2259 (mem:SI (plus:SI (match_dup 2) (const_int 8))))
2260 (set (match_operand:SI 5 "register_operand" "=r")
2261 (mem:SI (plus:SI (match_dup 2) (const_int 12))))
2262 (set (match_operand:SI 6 "register_operand" "=r")
2263 (mem:SI (plus:SI (match_dup 2) (const_int 16))))
2264 (set (match_operand:SI 7 "register_operand" "=r")
2265 (mem:SI (plus:SI (match_dup 2) (const_int 20))))
2266 ])]
2267 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 6"
2268 {
2269 static char load_op[256] = {0};
2270 int count = REGNO (operands[1]) + XVECLEN (operands[0], 0) - 1;
2271 const char *reg_rz = reg_names[count];
2272 sprintf (load_op, \"ldm\t%%1 - %s, (%%2)\", reg_rz);
2273 return load_op;
2274 }
2275 )
2276
2277
2278 (define_insn "*csky_ldmsi5"
2279 [(match_parallel 0 "csky_load_multiple_operation"
2280 [(set (match_operand:SI 1 "register_operand" "=r")
2281 (mem:SI (match_operand:SI 2 "register_operand" "r")))
2282 (set (match_operand:SI 3 "register_operand" "=r")
2283 (mem:SI (plus:SI (match_dup 2) (const_int 4))))
2284 (set (match_operand:SI 4 "register_operand" "=r")
2285 (mem:SI (plus:SI (match_dup 2) (const_int 8))))
2286 (set (match_operand:SI 5 "register_operand" "=r")
2287 (mem:SI (plus:SI (match_dup 2) (const_int 12))))
2288 (set (match_operand:SI 6 "register_operand" "=r")
2289 (mem:SI (plus:SI (match_dup 2) (const_int 16))))
2290 ])]
2291 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 5"
2292 {
2293 static char load_op[256] = {0};
2294 int count = REGNO (operands[1]) + XVECLEN (operands[0], 0) - 1;
2295 const char *reg_rz = reg_names[count];
2296 sprintf (load_op, \"ldm\t%%1 - %s, (%%2)\", reg_rz);
2297 return load_op;
2298 }
2299 )
2300
2301
2302 (define_insn "*csky_ldmsi4"
2303 [(match_parallel 0 "csky_load_multiple_operation"
2304 [(set (match_operand:SI 1 "register_operand" "=r")
2305 (mem:SI (match_operand:SI 2 "register_operand" "r")))
2306 (set (match_operand:SI 3 "register_operand" "=r")
2307 (mem:SI (plus:SI (match_dup 2) (const_int 4))))
2308 (set (match_operand:SI 4 "register_operand" "=r")
2309 (mem:SI (plus:SI (match_dup 2) (const_int 8))))
2310 (set (match_operand:SI 5 "register_operand" "=r")
2311 (mem:SI (plus:SI (match_dup 2) (const_int 12))))
2312 ])]
2313 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 4"
2314 {
2315 static char load_op[256] = {0};
2316 int count = REGNO (operands[1]) + XVECLEN (operands[0], 0) - 1;
2317 const char *reg_rz = reg_names[count];
2318 sprintf (load_op, \"ldm\t%%1 - %s, (%%2)\", reg_rz);
2319 return load_op;
2320 }
2321 )
2322
2323
2324 (define_insn "*csky_ldmsi3"
2325 [(match_parallel 0 "csky_load_multiple_operation"
2326 [(set (match_operand:SI 1 "register_operand" "=r")
2327 (mem:SI (match_operand:SI 2 "register_operand" "r")))
2328 (set (match_operand:SI 3 "register_operand" "=r")
2329 (mem:SI (plus:SI (match_dup 2) (const_int 4))))
2330 (set (match_operand:SI 4 "register_operand" "=r")
2331 (mem:SI (plus:SI (match_dup 2) (const_int 8))))
2332 ])]
2333 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 3"
2334 {
2335 static char load_op[256] = {0};
2336 int count = REGNO (operands[1]) + XVECLEN (operands[0], 0) - 1;
2337 const char *reg_rz = reg_names[count];
2338 sprintf (load_op, \"ldm\t%%1 - %s, (%%2)\", reg_rz);
2339 return load_op;
2340 }
2341 )
2342
2343
2344 (define_insn "*csky_ldmsi2"
2345 [(match_parallel 0 "csky_load_multiple_operation"
2346 [(set (match_operand:SI 1 "register_operand" "=r")
2347 (mem:SI (match_operand:SI 2 "register_operand" "r")))
2348 (set (match_operand:SI 3 "register_operand" "=r")
2349 (mem:SI (plus:SI (match_dup 2) (const_int 4))))
2350 ])]
2351 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 2"
2352 {
2353 static char load_op[256] = {0};
2354 int count = REGNO (operands[1]) + XVECLEN (operands[0], 0) - 1;
2355 const char *reg_rz = reg_names[count];
2356 sprintf (load_op, \"ldm\t%%1 - %s, (%%2)\", reg_rz);
2357 return load_op;
2358 }
2359 )
2360
2361 (define_insn "*csky_stmsi12"
2362 [(match_parallel 0 "csky_store_multiple_operation"
2363 [(set (mem:SI (match_operand:SI 1 "register_operand" "r"))
2364 (match_operand:SI 2 "register_operand" "r"))
2365 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
2366 (match_operand:SI 3 "register_operand" "r"))
2367 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
2368 (match_operand:SI 4 "register_operand" "r"))
2369 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
2370 (match_operand:SI 5 "register_operand" "r"))
2371 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
2372 (match_operand:SI 6 "register_operand" "r"))
2373 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
2374 (match_operand:SI 7 "register_operand" "r"))
2375 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
2376 (match_operand:SI 8 "register_operand" "r"))
2377 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
2378 (match_operand:SI 9 "register_operand" "r"))
2379 (set (mem:SI (plus:SI (match_dup 1) (const_int 32)))
2380 (match_operand:SI 10 "register_operand" "r"))
2381 (set (mem:SI (plus:SI (match_dup 1) (const_int 36)))
2382 (match_operand:SI 11 "register_operand" "r"))
2383 (set (mem:SI (plus:SI (match_dup 1) (const_int 40)))
2384 (match_operand:SI 12 "register_operand" "r"))
2385 (set (mem:SI (plus:SI (match_dup 1) (const_int 44)))
2386 (match_operand:SI 13 "register_operand" "r"))
2387 ])]
2388 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 12"
2389 {
2390 static char load_op[256] = {0};
2391 int end = REGNO (operands[2]) + XVECLEN (operands[0], 0) - 1;
2392 const char *reg_rz = reg_names[end];
2393 sprintf (load_op, \"stm\t%%2 - %s, (%%1)\", reg_rz);
2394 return load_op;
2395 }
2396 )
2397
2398
2399 (define_insn "*csky_stmsi11"
2400 [(match_parallel 0 "csky_store_multiple_operation"
2401 [(set (mem:SI (match_operand:SI 1 "register_operand" "r"))
2402 (match_operand:SI 2 "register_operand" "r"))
2403 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
2404 (match_operand:SI 3 "register_operand" "r"))
2405 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
2406 (match_operand:SI 4 "register_operand" "r"))
2407 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
2408 (match_operand:SI 5 "register_operand" "r"))
2409 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
2410 (match_operand:SI 6 "register_operand" "r"))
2411 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
2412 (match_operand:SI 7 "register_operand" "r"))
2413 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
2414 (match_operand:SI 8 "register_operand" "r"))
2415 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
2416 (match_operand:SI 9 "register_operand" "r"))
2417 (set (mem:SI (plus:SI (match_dup 1) (const_int 32)))
2418 (match_operand:SI 10 "register_operand" "r"))
2419 (set (mem:SI (plus:SI (match_dup 1) (const_int 36)))
2420 (match_operand:SI 11 "register_operand" "r"))
2421 (set (mem:SI (plus:SI (match_dup 1) (const_int 40)))
2422 (match_operand:SI 12 "register_operand" "r"))
2423 ])]
2424 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 11"
2425 {
2426 static char load_op[256] = {0};
2427 int end = REGNO (operands[2]) + XVECLEN (operands[0], 0) - 1;
2428 const char *reg_rz = reg_names[end];
2429 sprintf (load_op, \"stm\t%%2 - %s, (%%1)\", reg_rz);
2430 return load_op;
2431 }
2432 )
2433
2434
2435 (define_insn "*csky_stmsi10"
2436 [(match_parallel 0 "csky_store_multiple_operation"
2437 [(set (mem:SI (match_operand:SI 1 "register_operand" "r"))
2438 (match_operand:SI 2 "register_operand" "r"))
2439 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
2440 (match_operand:SI 3 "register_operand" "r"))
2441 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
2442 (match_operand:SI 4 "register_operand" "r"))
2443 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
2444 (match_operand:SI 5 "register_operand" "r"))
2445 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
2446 (match_operand:SI 6 "register_operand" "r"))
2447 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
2448 (match_operand:SI 7 "register_operand" "r"))
2449 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
2450 (match_operand:SI 8 "register_operand" "r"))
2451 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
2452 (match_operand:SI 9 "register_operand" "r"))
2453 (set (mem:SI (plus:SI (match_dup 1) (const_int 32)))
2454 (match_operand:SI 10 "register_operand" "r"))
2455 (set (mem:SI (plus:SI (match_dup 1) (const_int 36)))
2456 (match_operand:SI 11 "register_operand" "r"))
2457 ])]
2458 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 10"
2459 {
2460 static char load_op[256] = {0};
2461 int end = REGNO (operands[2]) + XVECLEN (operands[0], 0) - 1;
2462 const char *reg_rz = reg_names[end];
2463 sprintf (load_op, \"stm\t%%2 - %s, (%%1)\", reg_rz);
2464 return load_op;
2465 }
2466 )
2467
2468
2469 (define_insn "*csky_stmsi9"
2470 [(match_parallel 0 "csky_store_multiple_operation"
2471 [(set (mem:SI (match_operand:SI 1 "register_operand" "r"))
2472 (match_operand:SI 2 "register_operand" "r"))
2473 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
2474 (match_operand:SI 3 "register_operand" "r"))
2475 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
2476 (match_operand:SI 4 "register_operand" "r"))
2477 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
2478 (match_operand:SI 5 "register_operand" "r"))
2479 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
2480 (match_operand:SI 6 "register_operand" "r"))
2481 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
2482 (match_operand:SI 7 "register_operand" "r"))
2483 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
2484 (match_operand:SI 8 "register_operand" "r"))
2485 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
2486 (match_operand:SI 9 "register_operand" "r"))
2487 (set (mem:SI (plus:SI (match_dup 1) (const_int 32)))
2488 (match_operand:SI 10 "register_operand" "r"))
2489 ])]
2490 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 9"
2491 {
2492 static char load_op[256] = {0};
2493 int end = REGNO (operands[2]) + XVECLEN (operands[0], 0) - 1;
2494 const char *reg_rz = reg_names[end];
2495 sprintf (load_op, \"stm\t%%2 - %s, (%%1)\", reg_rz);
2496 return load_op;
2497 }
2498 )
2499
2500
2501 (define_insn "*csky_stmsi8"
2502 [(match_parallel 0 "csky_store_multiple_operation"
2503 [(set (mem:SI (match_operand:SI 1 "register_operand" "r"))
2504 (match_operand:SI 2 "register_operand" "r"))
2505 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
2506 (match_operand:SI 3 "register_operand" "r"))
2507 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
2508 (match_operand:SI 4 "register_operand" "r"))
2509 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
2510 (match_operand:SI 5 "register_operand" "r"))
2511 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
2512 (match_operand:SI 6 "register_operand" "r"))
2513 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
2514 (match_operand:SI 7 "register_operand" "r"))
2515 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
2516 (match_operand:SI 8 "register_operand" "r"))
2517 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
2518 (match_operand:SI 9 "register_operand" "r"))
2519 ])]
2520 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 8"
2521 {
2522 static char load_op[256] = {0};
2523 int end = REGNO (operands[2]) + XVECLEN (operands[0], 0) - 1;
2524 const char *reg_rz = reg_names[end];
2525 sprintf (load_op, \"stm\t%%2 - %s, (%%1)\", reg_rz);
2526 return load_op;
2527 }
2528 )
2529
2530
2531 (define_insn "*csky_stmsi7"
2532 [(match_parallel 0 "csky_store_multiple_operation"
2533 [(set (mem:SI (match_operand:SI 1 "register_operand" "r"))
2534 (match_operand:SI 2 "register_operand" "r"))
2535 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
2536 (match_operand:SI 3 "register_operand" "r"))
2537 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
2538 (match_operand:SI 4 "register_operand" "r"))
2539 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
2540 (match_operand:SI 5 "register_operand" "r"))
2541 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
2542 (match_operand:SI 6 "register_operand" "r"))
2543 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
2544 (match_operand:SI 7 "register_operand" "r"))
2545 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
2546 (match_operand:SI 8 "register_operand" "r"))
2547 ])]
2548 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 7"
2549 {
2550 static char load_op[256] = {0};
2551 int end = REGNO (operands[2]) + XVECLEN (operands[0], 0) - 1;
2552 const char *reg_rz = reg_names[end];
2553 sprintf (load_op, \"stm\t%%2 - %s, (%%1)\", reg_rz);
2554 return load_op;
2555 }
2556 )
2557
2558
2559 (define_insn "*csky_stmsi6"
2560 [(match_parallel 0 "csky_store_multiple_operation"
2561 [(set (mem:SI (match_operand:SI 1 "register_operand" "r"))
2562 (match_operand:SI 2 "register_operand" "r"))
2563 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
2564 (match_operand:SI 3 "register_operand" "r"))
2565 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
2566 (match_operand:SI 4 "register_operand" "r"))
2567 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
2568 (match_operand:SI 5 "register_operand" "r"))
2569 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
2570 (match_operand:SI 6 "register_operand" "r"))
2571 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
2572 (match_operand:SI 7 "register_operand" "r"))
2573 ])]
2574 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 6"
2575 {
2576 static char load_op[256] = {0};
2577 int end = REGNO (operands[2]) + XVECLEN (operands[0], 0) - 1;
2578 const char *reg_rz = reg_names[end];
2579 sprintf (load_op, \"stm\t%%2 - %s, (%%1)\", reg_rz);
2580 return load_op;
2581 }
2582 )
2583
2584 (define_insn "*csky_stmsi5"
2585 [(match_parallel 0 "csky_store_multiple_operation"
2586 [(set (mem:SI (match_operand:SI 1 "register_operand" "r"))
2587 (match_operand:SI 2 "register_operand" "r"))
2588 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
2589 (match_operand:SI 3 "register_operand" "r"))
2590 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
2591 (match_operand:SI 4 "register_operand" "r"))
2592 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
2593 (match_operand:SI 5 "register_operand" "r"))
2594 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
2595 (match_operand:SI 6 "register_operand" "r"))
2596 ])]
2597 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 5"
2598 {
2599 static char load_op[256] = {0};
2600 int end = REGNO (operands[2]) + XVECLEN (operands[0], 0) - 1;
2601 const char *reg_rz = reg_names[end];
2602 sprintf (load_op, \"stm\t%%2 - %s, (%%1)\", reg_rz);
2603 return load_op;
2604 }
2605 )
2606
2607
2608 (define_insn "*csky_stmsi4"
2609 [(match_parallel 0 "csky_store_multiple_operation"
2610 [(set (mem:SI (match_operand:SI 1 "register_operand" "r"))
2611 (match_operand:SI 2 "register_operand" "r"))
2612 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
2613 (match_operand:SI 3 "register_operand" "r"))
2614 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
2615 (match_operand:SI 4 "register_operand" "r"))
2616 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
2617 (match_operand:SI 5 "register_operand" "r"))
2618 ])]
2619 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 4"
2620 {
2621 static char load_op[256] = {0};
2622 int end = REGNO (operands[2]) + XVECLEN (operands[0], 0) - 1;
2623 const char *reg_rz = reg_names[end];
2624 sprintf (load_op, \"stm\t%%2 - %s, (%%1)\", reg_rz);
2625 return load_op;
2626 }
2627 )
2628
2629
2630 (define_insn "*csky_stmsi3"
2631 [(match_parallel 0 "csky_store_multiple_operation"
2632 [(set (mem:SI (match_operand:SI 1 "register_operand" "r"))
2633 (match_operand:SI 2 "register_operand" "r"))
2634 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
2635 (match_operand:SI 3 "register_operand" "r"))
2636 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
2637 (match_operand:SI 4 "register_operand" "r"))
2638 ])]
2639 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 3"
2640 {
2641 static char load_op[256] = {0};
2642 int end = REGNO (operands[2]) + XVECLEN (operands[0], 0) - 1;
2643 const char *reg_rz = reg_names[end];
2644 sprintf (load_op, \"stm\t%%2 - %s, (%%1)\", reg_rz);
2645 return load_op;
2646 }
2647 )
2648
2649
2650 (define_insn "*csky_stmsi2"
2651 [(match_parallel 0 "csky_store_multiple_operation"
2652 [(set (mem:SI (match_operand:SI 1 "register_operand" "r"))
2653 (match_operand:SI 2 "register_operand" "r"))
2654 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
2655 (match_operand:SI 3 "register_operand" "r"))
2656 ])]
2657 "TARGET_MULTIPLE_STLD && XVECLEN (operands[0], 0) == 2"
2658 {
2659 static char load_op[256] = {0};
2660 int end = REGNO (operands[2]) + XVECLEN (operands[0], 0) - 1;
2661 const char *reg_rz = reg_names[end];
2662 sprintf (load_op, \"stm\t%%2 - %s, (%%1)\", reg_rz);
2663 return load_op;
2664 }
2665 )
2666
2667
2668 ;; ------------------------------------------------------------------------
2669 ;; Jump and linkage insns
2670 ;; ------------------------------------------------------------------------
2671
2672 (define_expand "tablejump"
2673 [(parallel [(set (pc) (match_operand:SI 0 "register_operand" "r"))
2674 (use (label_ref (match_operand 1 "" "")))])]
2675 ""
2676 "
2677 if (flag_pic)
2678 operands[0] = expand_simple_binop (Pmode, PLUS, operands[0],
2679 pic_offset_table_rtx, NULL_RTX,
2680 1, OPTAB_DIRECT);
2681 "
2682 )
2683
2684 (define_insn "*tablejump"
2685 [(set (pc) (match_operand:SI 0 "register_operand" "r"))
2686 (use (label_ref (match_operand 1 "" "")))]
2687 ""
2688 "jmp %0"
2689 [(set_attr "type" "branch_jmp")]
2690 )
2691
2692 (define_expand "jump"
2693 [(set (pc) (label_ref (match_operand 0 "" "")))]
2694 ""
2695 ""
2696 )
2697
2698 (define_insn "*csky_jump"
2699 [(set (pc) (label_ref (match_operand 0 "" "")))]
2700 "CSKY_ISA_FEATURE (E2)"
2701 "jbr %l0"
2702 [(set_attr "type" "branch")]
2703 )
2704
2705 ;; The length of bsr is not really 5; it's used to distinguish from br32.
2706 ;; Since the length attribute is treated specially it doesn't seem possible
2707 ;; to compute the far_jump attribute directly and use that.
2708
2709 (define_insn "*ck801_ck802_jump"
2710 [(set (pc) (label_ref (match_operand 0 "" "")))]
2711 "CSKY_ISA_FEATURE (E1) || CSKY_ISA_FEATURE (E2)"
2712 "*{
2713 if (get_attr_length (insn) != 5)
2714 return \"jbr\\t%l0\";
2715 else
2716 return \"bsr\\t%l0\\t//far jump\";
2717 }"
2718 [(set_attr "type" "branch")
2719 (set (attr "far_jump")
2720 (if_then_else
2721 (eq_attr "length" "5")
2722 (const_string "yes")
2723 (const_string "no")))
2724 (set (attr "length")
2725 (if_then_else
2726 (and (ge (minus (match_dup 0) (pc)) (const_int -1024))
2727 (le (minus (match_dup 0) (pc)) (const_int 1022)))
2728 (const_int 2)
2729 (if_then_else
2730 (and (ge (minus (match_dup 0) (pc)) (const_int -65536))
2731 (le (minus (match_dup 0) (pc)) (const_int 65534)))
2732 (const_int 4)
2733 (const_int 5))))]
2734 )
2735
2736 (define_insn "indirect_jump"
2737 [(set (pc) (match_operand:SI 0 "register_operand" "b,r"))]
2738 ""
2739 "@
2740 jmp\t%0
2741 jmp\t%0"
2742 [(set_attr "length" "2,4")
2743 (set_attr "type" "branch_jmp")]
2744 )
2745
2746
2747 ;; ------------------------------------------------------------------------
2748 ;; Conditional jump insns
2749 ;; ------------------------------------------------------------------------
2750
2751 (define_expand "cbranchsi4"
2752 [(set (pc)
2753 (if_then_else (match_operator 0 "ordered_comparison_operator"
2754 [(match_operand:SI 1 "csky_compare_operand")
2755 (match_operand:SI 2 "nonmemory_operand")])
2756 (label_ref (match_operand 3 ""))
2757 (pc)))]
2758 ""
2759 "{
2760 enum rtx_code code = GET_CODE (operands[0]);
2761
2762 if (CSKY_ISA_FEATURE (2E3)
2763 && (code == LE || code == LT || code == GT
2764 || code == GE || code == EQ || code == NE)
2765 && operands[2] == const0_rtx)
2766 {
2767 /* These cases match the jbez, jbnez, etc insns below.
2768 TODO: Handling this in the expander is suboptimal since it
2769 fails to detect cases where the constant 0 would fall out
2770 from subsequent forward propagation or loop optimizers; maybe
2771 it would be better to have a splitter here, but when to split? */
2772 }
2773 else
2774 {
2775 bool invert = csky_emit_compare (code, operands[1], operands[2]);
2776
2777 if (invert)
2778 emit_jump_insn (gen_csky_jbf (operands[3]));
2779 else
2780 emit_jump_insn (gen_csky_jbt (operands[3]));
2781 DONE;
2782 }
2783 }"
2784 )
2785
2786 (define_insn "csky_jbt"
2787 [(set (pc)
2788 (if_then_else (ne (reg:CC CSKY_CC_REGNUM) (const_int 0))
2789 (label_ref (match_operand 0 "" ""))
2790 (pc)))]
2791 "CSKY_ISA_FEATURE (2E3)"
2792 "jbt\t%l0"
2793 [(set_attr "type" "cbranch")]
2794 )
2795
2796 (define_insn "csky_jbf"
2797 [(set (pc)
2798 (if_then_else (eq (reg:CC CSKY_CC_REGNUM) (const_int 0))
2799 (label_ref (match_operand 0 "" ""))
2800 (pc)))]
2801 "CSKY_ISA_FEATURE (2E3)"
2802 "jbf\t%l0"
2803 [(set_attr "type" "cbranch")]
2804 )
2805
2806
2807 ;;; CK802 has 32-bit jbt/jbf instructions, but no insn other
2808 ;;; than bsr for far jumps.
2809
2810 (define_insn "ck802_jbt"
2811 [(set (pc) (if_then_else (ne (reg:CC CSKY_CC_REGNUM) (const_int 0))
2812 (label_ref (match_operand 0 "" ""))
2813 (pc)))]
2814 "CSKY_ISA_FEATURE (E2)"
2815 {
2816 if (get_attr_length (insn) == 6)
2817 return \"jbf\\t.LCB%=\;bsr\\t%l0\\t//far jump\\n.LCB%=:\";
2818 else
2819 return \"jbt\\t%l0\";
2820 }
2821 [(set_attr "type" "cbranch")
2822 (set (attr "far_jump")
2823 (if_then_else
2824 (eq_attr "length" "6")
2825 (const_string "yes")
2826 (const_string "no")))
2827 (set (attr "length")
2828 (if_then_else
2829 (and (ge (minus (match_dup 0) (pc)) (const_int -1024))
2830 (le (minus (match_dup 0) (pc)) (const_int 1022)))
2831 (const_int 2)
2832 (if_then_else
2833 (and (ge (minus (match_dup 0) (pc)) (const_int -65534))
2834 (le (minus (match_dup 0) (pc)) (const_int 65534)))
2835 (const_int 4)
2836 (const_int 6))))]
2837 )
2838
2839 (define_insn "ck802_jbf"
2840 [(set (pc) (if_then_else (eq (reg:CC CSKY_CC_REGNUM) (const_int 0))
2841 (label_ref (match_operand 0 "" ""))
2842 (pc)))]
2843 "CSKY_ISA_FEATURE (E2)"
2844 {
2845 if (get_attr_length (insn) == 6)
2846 return \"jbt\\t.LCB%=\;bsr\\t%l0\\t//far jump\\n.LCB%=:\";
2847 else
2848 return \"jbf\\t%l0\";
2849 }
2850 [(set_attr "type" "cbranch")
2851 (set (attr "far_jump")
2852 (if_then_else
2853 (eq_attr "length" "6")
2854 (const_string "yes")
2855 (const_string "no")))
2856 (set (attr "length")
2857 (if_then_else
2858 (and (ge (minus (match_dup 0) (pc)) (const_int -1024))
2859 (le (minus (match_dup 0) (pc)) (const_int 1022)))
2860 (const_int 2)
2861 (if_then_else
2862 (and (ge (minus (match_dup 0) (pc)) (const_int -65534))
2863 (le (minus (match_dup 0) (pc)) (const_int 65534)))
2864 (const_int 4)
2865 (const_int 6))))]
2866 )
2867
2868 ;; The length of the bsr case is not really 7; it's used to distinguish
2869 ;; from br32.
2870 ;; Note that we have to adjust the backward range of the jbr case to
2871 ;; account for the jbf in front of it.
2872 (define_insn "ck801_jbt"
2873 [(set (pc) (if_then_else (ne (reg:CC CSKY_CC_REGNUM) (const_int 0))
2874 (label_ref (match_operand 0 "" ""))
2875 (pc)))]
2876 "CSKY_ISA_FEATURE (E1)"
2877 {
2878 if (get_attr_length (insn) == 6)
2879 return \"jbf\\t.LCB%=\;jbr\\t%l0\\n.LCB%=:\";
2880 else if (get_attr_length (insn) == 7)
2881 return \"jbf\\t.LCB%=\;bsr\\t%l0\\t//far jump\\n.LCB%=:\";
2882 else
2883 return \"jbt\\t%l0\";
2884 }
2885 [(set_attr "type" "cbranch")
2886 (set (attr "far_jump")
2887 (if_then_else
2888 (eq_attr "length" "7")
2889 (const_string "yes")
2890 (const_string "no")))
2891 (set (attr "length")
2892 (if_then_else
2893 (and (ge (minus (match_dup 0) (pc)) (const_int -1024))
2894 (le (minus (match_dup 0) (pc)) (const_int 1022)))
2895 (const_int 2)
2896 (if_then_else
2897 (and (ge (minus (match_dup 0) (pc)) (const_int -65534))
2898 (le (minus (match_dup 0) (pc)) (const_int 65534)))
2899 (const_int 6)
2900 (const_int 7))))]
2901 )
2902
2903 (define_insn "ck801_jbf"
2904 [(set (pc)
2905 (if_then_else (eq (reg:CC CSKY_CC_REGNUM) (const_int 0))
2906 (label_ref (match_operand 0 "" ""))
2907 (pc)))]
2908 "CSKY_ISA_FEATURE (E1)"
2909 {
2910 if (get_attr_length (insn) == 6)
2911 return \"jbt\\t.LCB%=\;jbr\\t%l0\\n.LCB%=:\";
2912 else if (get_attr_length (insn) == 7)
2913 return \"jbt\\t.LCB%=\;bsr\\t%l0\\t//far jump\\n.LCB%=:\";
2914 else
2915 return \"jbf\\t%l0\";
2916 }
2917 [(set_attr "type" "cbranch")
2918 (set (attr "far_jump")
2919 (if_then_else
2920 (eq_attr "length" "7")
2921 (const_string "yes")
2922 (const_string "no")))
2923 (set (attr "length")
2924 (if_then_else
2925 (and (ge (minus (match_dup 0) (pc)) (const_int -1024))
2926 (le (minus (match_dup 0) (pc)) (const_int 1022)))
2927 (const_int 2)
2928 (if_then_else
2929 (and (ge (minus (match_dup 0) (pc)) (const_int -65534))
2930 (le (minus (match_dup 0) (pc)) (const_int 65534)))
2931 (const_int 6)
2932 (const_int 7))))]
2933 )
2934
2935 (define_code_iterator zero_cond [lt le gt ge eq ne])
2936
2937 (define_code_attr inst [(lt "jblz") (le "jblsz") (gt "jbhz") (ge "jbhsz") (eq "jbez") (ne "jbnez")])
2938
2939 (define_insn "*<inst>"
2940 [(set (pc)
2941 (if_then_else (zero_cond (match_operand:SI 0 "register_operand" "r")
2942 (const_int 0))
2943 (label_ref (match_operand 1 "" ""))
2944 (pc)))]
2945 "CSKY_ISA_FEATURE (2E3)"
2946 "<inst>\t%0, %l1"
2947 [(set_attr "type" "cbranch")]
2948 )
2949
2950 ;; ------------------------------------------------------------------------
2951 ;; return insns
2952 ;; ------------------------------------------------------------------------
2953
2954 (define_insn "simple_return"
2955 [(simple_return)]
2956 "reload_completed"
2957 "*
2958 return csky_output_return_instruction ();
2959 "
2960 )
2961
2962 (define_expand "eh_return"
2963 [(use (match_operand 0 "general_operand" ""))]
2964 ""
2965 "{
2966 emit_insn (gen_csky_eh_return (operands[0]));
2967 DONE;
2968 }"
2969 )
2970
2971 ;; We can't expand this before we know where the link register is stored.
2972 (define_insn_and_split "csky_eh_return"
2973 [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")]
2974 VUNSPEC_EH_RETURN)
2975 (clobber (match_scratch:SI 1 "=&r"))]
2976 ""
2977 "#"
2978 "reload_completed"
2979 [(const_int 0)]
2980 "{
2981 csky_set_eh_return_address (operands[0], operands[1]);
2982 DONE;
2983 }"
2984 )
2985
2986 ;; -------------------------------------------------------------------------
2987 ;; SImode signed integer comparisons
2988 ;; -------------------------------------------------------------------------
2989
2990 (define_insn "*cmpnesi_r"
2991 [(set (reg:CC CSKY_CC_REGNUM)
2992 (ne:CC (match_operand:SI 0 "register_operand" "b,r")
2993 (match_operand:SI 1 "register_operand" "b,r")))]
2994 ""
2995 "@
2996 cmpne\t%0, %1
2997 cmpne\t%0, %1"
2998 [(set_attr "length" "2,4")
2999 (set_attr "type" "cmp")]
3000 )
3001
3002 ;; cmpnei range is 0-31 for Smart mode.
3003 (define_insn "smart_cmpnesi_i"
3004 [(set (reg:CC CSKY_CC_REGNUM)
3005 (ne:CC (match_operand:SI 0 "register_operand" "a")
3006 (match_operand:SI 1 "csky_literal_K_operand" "K")))]
3007 "TARGET_MINI_REGISTERS"
3008 "cmpnei\t%0, %1"
3009 [(set_attr "type" "cmp")]
3010 )
3011
3012 ;; cmpnei range is 0 - 65536 for Fast mode.
3013 (define_insn "fast_cmpnesi_i"
3014 [(set (reg:CC CSKY_CC_REGNUM)
3015 (ne:CC (match_operand:SI 0 "register_operand" "r")
3016 (match_operand:SI 1 "csky_literal_I_operand" "I")))]
3017 "CSKY_ISA_FEATURE (E2)"
3018 "cmpnei\t%0, %1"
3019 [(set_attr "type" "cmp")]
3020 )
3021
3022 (define_insn "*cmpgtsi"
3023 [(set (reg:CC CSKY_CC_REGNUM)
3024 (gt:CC (match_operand:SI 0 "register_operand" "b,r")
3025 (match_operand:SI 1 "register_operand" "b,r")))]
3026 ""
3027 "cmplt\t%1, %0"
3028 [(set_attr "length" "2,4")
3029 (set_attr "type" "cmp")]
3030 )
3031
3032 (define_insn "cmpltsi_r"
3033 [(set (reg:CC CSKY_CC_REGNUM)
3034 (lt:CC (match_operand:SI 0 "register_operand" "b,r")
3035 (match_operand:SI 1 "register_operand" "b,r")))]
3036 ""
3037 "cmplt\t%0, %1"
3038 [(set_attr "length" "2,4")
3039 (set_attr "type" "cmp")]
3040 )
3041
3042 ;; cmplti range is 1-32 for Smart mode.
3043 (define_insn "*smart_cmpltsi_i"
3044 [(set (reg:CC CSKY_CC_REGNUM)
3045 (lt:CC (match_operand:SI 0 "register_operand" "a")
3046 (match_operand:SI 1 "csky_literal_J_operand" "J")))]
3047 "TARGET_MINI_REGISTERS"
3048 "cmplti\t%0, %1"
3049 [(set_attr "length" "2")
3050 (set_attr "type" "cmp")]
3051 )
3052
3053
3054 ;; cmplti range is 1-65536 for Fast mode.
3055 (define_insn "*fast_cmpltsi_i"
3056 [(set (reg:CC CSKY_CC_REGNUM)
3057 (lt:CC (match_operand:SI 0 "register_operand" "a,r")
3058 (match_operand:SI 1 "csky_literal_Uk_operand" "J,Uk")))]
3059 "CSKY_ISA_FEATURE (E2)"
3060 "cmplti\t%0, %1"
3061 [(set_attr "length" "2,4")
3062 (set_attr "type" "cmp")]
3063 )
3064
3065 ; Covers cmplti x,0.
3066 (define_insn "*cskyv2_cmpltsi_0"
3067 [(set (reg:CC CSKY_CC_REGNUM)
3068 (lt:CC (match_operand:SI 0 "register_operand" "a,r")
3069 (const_int 0)))]
3070 "CSKY_ISA_FEATURE (E2)"
3071 "btsti\t%0, 31"
3072 [(set_attr "length" "2,4")
3073 (set_attr "type" "cmp")]
3074 )
3075
3076 (define_insn "*ck801_cmpltsi_0"
3077 [(set (reg:CC CSKY_CC_REGNUM)
3078 (lt:CC (match_operand:SI 0 "register_operand" "a")
3079 (const_int 0)))]
3080 "CSKY_ISA_FEATURE (E1)"
3081 "btsti\t%0, 31"
3082 [(set_attr "type" "cmp")]
3083 )
3084
3085 ;; Decrement and test instructions.
3086 ;; In theory decne could be used in conjunction with jbt to implement
3087 ;; doloop_end, but that seems to encourage the loop optimizer to introduce
3088 ;; an additional induction variable and doesn't actually result in tighter
3089 ;; loop code for that reason.
3090
3091 (define_insn "*cskyv2_declt"
3092 [(set (match_operand:SI 0 "register_operand" "=r")
3093 (plus:SI (match_operand:SI 1 "register_operand" "r")
3094 (match_operand:SI 2 "const_int_operand" "Uh")))
3095 (set (reg:CC CSKY_CC_REGNUM)
3096 (lt:CC (plus:SI (match_dup 1) (match_dup 2))
3097 (const_int 0)))]
3098 "CSKY_ISA_FEATURE (2E3)"
3099 "declt\t%0, %1, %M2"
3100 )
3101
3102 (define_insn "*cskyv2_decgt"
3103 [(set (match_operand:SI 0 "register_operand" "=r")
3104 (plus:SI (match_operand:SI 1 "register_operand" "r")
3105 (match_operand:SI 2 "const_int_operand" "Uh")))
3106 (set (reg:CC CSKY_CC_REGNUM)
3107 (gt:CC (plus:SI (match_dup 1) (match_dup 2))
3108 (const_int 0)))]
3109 "CSKY_ISA_FEATURE (2E3)"
3110 "decgt\t%0, %1, %M2"
3111 )
3112
3113 (define_insn "*cskyv2_decne"
3114 [(set (match_operand:SI 0 "register_operand" "=r")
3115 (plus:SI (match_operand:SI 1 "register_operand" "r")
3116 (match_operand:SI 2 "const_int_operand" "Uh")))
3117 (set (reg:CC CSKY_CC_REGNUM)
3118 (ne:CC (plus:SI (match_dup 1) (match_dup 2))
3119 (const_int 0)))]
3120 "CSKY_ISA_FEATURE (2E3)"
3121 "decne\t%0, %1, %M2"
3122 )
3123
3124 ;; -------------------------------------------------------------------------
3125 ;; SImode unsigned integer comparisons
3126 ;; -------------------------------------------------------------------------
3127
3128 (define_insn "cmpgeusi_r"
3129 [(set (reg:CC CSKY_CC_REGNUM)
3130 (geu:CC (match_operand:SI 0 "register_operand" "b,r")
3131 (match_operand:SI 1 "register_operand" "b,r")))]
3132 ""
3133 "cmphs\t%0, %1"
3134 [(set_attr "length" "2,4")
3135 (set_attr "type" "cmp")]
3136 )
3137
3138 (define_insn "*smart_cmpgeusi_i"
3139 [(set (reg:CC CSKY_CC_REGNUM)
3140 (geu:CC (match_operand:SI 0 "register_operand" "a")
3141 (match_operand:SI 1 "csky_literal_J_operand" "J")))]
3142 "TARGET_MINI_REGISTERS"
3143 "cmphsi\t%0, %1"
3144 [(set_attr "length" "2")
3145 (set_attr "type" "cmp")]
3146 )
3147
3148 (define_insn "*fast_cmpgeusi_i"
3149 [(set (reg:CC CSKY_CC_REGNUM)
3150 (geu:CC (match_operand:SI 0 "register_operand" "a,r")
3151 (match_operand:SI 1 "csky_literal_Uk_operand" "J,Uk")))]
3152 "CSKY_ISA_FEATURE (E2)"
3153 "cmphsi\t%0, %1"
3154 [(set_attr "length" "2,4")
3155 (set_attr "type" "cmp")]
3156 )
3157
3158 (define_insn "*cmpleusi"
3159 [(set (reg:CC CSKY_CC_REGNUM)
3160 (leu:CC (match_operand:SI 0 "register_operand" "b,r")
3161 (match_operand:SI 1 "register_operand" "b,r")))]
3162 ""
3163 "cmphs\t%1, %0"
3164 [(set_attr "length" "2,4")
3165 (set_attr "type" "cmp")]
3166 )
3167
3168 ;; -------------------------------------------------------------------------
3169 ;; Function call insns
3170 ;; -------------------------------------------------------------------------
3171
3172 (define_expand "call"
3173 [(parallel [(call (match_operand:SI 0 "" "") (match_operand 1 "" ""))
3174 (clobber (reg:SI CSKY_LR_REGNUM))])]
3175 ""
3176 "
3177 {
3178 rtx pic_ref;
3179 rtx addr_ref = XEXP (operands[0], 0);
3180
3181 if (flag_pic
3182 && (CONSTANT_P (addr_ref)
3183 || csky_symbol_mentioned_p (addr_ref)
3184 || csky_label_mentioned_p (addr_ref)))
3185 {
3186 pic_ref = csky_legitimize_pic_address (addr_ref, 0, false);
3187 operands[0] = gen_rtx_MEM (GET_MODE (pic_ref), pic_ref);
3188 }
3189
3190 if (GET_CODE (operands[0]) == MEM
3191 && ! register_operand (XEXP (operands[0], 0), SImode)
3192 && ! csky_symbolic_address_p (XEXP (operands[0], 0))
3193 && ! (flag_pic
3194 && csky_unspec_operand (XEXP (operands[0], 0), SImode)))
3195 operands[0] = gen_rtx_MEM (GET_MODE (operands[0]),
3196 force_reg (Pmode, XEXP (operands[0], 0)));
3197 }"
3198 )
3199
3200
3201 (define_insn "*call_internal"
3202 [(call (mem:SI (match_operand:SI 0 "csky_call_address_operand" "b,r,S"))
3203 (match_operand 1 "" ""))
3204 (clobber (reg:SI CSKY_LR_REGNUM))]
3205 ""
3206 "@
3207 jsr\t%0
3208 jsr\t%0
3209 jbsr\t%0"
3210 [(set_attr "length" "2,4,4")
3211 (set_attr "type" "call_jsr,call_jsr,call")]
3212 )
3213
3214 (define_insn "*call_internal_pic"
3215 [(call (mem:SI (match_operand:SI 0 "csky_unspec_operand" "X"))
3216 (match_operand 1 "" ""))
3217 (clobber (reg:SI CSKY_LR_REGNUM))]
3218 "flag_pic"
3219 "* return csky_output_call (operands, 0);"
3220 [(set_attr "length" "4")]
3221 )
3222
3223 (define_expand "call_value"
3224 [(parallel [(set (match_operand 0 "register_operand" "")
3225 (call (match_operand:SI 1 "" "") (match_operand 2 "" "")))
3226 (clobber (reg:SI CSKY_LR_REGNUM))])]
3227 ""
3228 "{
3229 rtx pic_ref;
3230 rtx addr_ref = XEXP (operands[1], 0);
3231
3232 if (flag_pic
3233 && (CONSTANT_P (addr_ref)
3234 || csky_symbol_mentioned_p (addr_ref)
3235 || csky_label_mentioned_p (addr_ref)))
3236 {
3237 pic_ref = csky_legitimize_pic_address (addr_ref, 0, false);
3238 operands[1] = gen_rtx_MEM (GET_MODE (pic_ref), pic_ref);
3239 }
3240
3241 if (GET_CODE (operands[1]) == MEM
3242 && ! register_operand (XEXP (operands[1], 0), SImode)
3243 && ! csky_symbolic_address_p (XEXP (operands[1], 0))
3244 && ! (flag_pic
3245 && csky_unspec_operand (XEXP (operands[1], 0), SImode)))
3246 operands[1] = gen_rtx_MEM (GET_MODE (operands[1]),
3247 force_reg (Pmode, XEXP (operands[1], 0)));
3248 }")
3249
3250 ;; Call subroutine returning any type.
3251
3252 (define_expand "untyped_call"
3253 [(parallel [(call (match_operand 0 "" "")
3254 (const_int 0))
3255 (match_operand 1 "" "")
3256 (match_operand 2 "" "")])]
3257 ""
3258 {
3259 int i;
3260
3261 emit_call_insn (gen_call (operands[0], const0_rtx));
3262
3263 for (int i = 0; i < XVECLEN (operands[2], 0); i++)
3264 emit_clobber (SET_SRC (XVECEXP (operands[2], 0, i)));
3265 emit_insn (gen_blockage ());
3266
3267 for (i = 0; i < XVECLEN (operands[2], 0); i++)
3268 {
3269 rtx set = XVECEXP (operands[2], 0, i);
3270 emit_move_insn (SET_DEST (set), SET_SRC (set));
3271 }
3272
3273 /* The optimizer does not know that the call sets the function value
3274 registers we stored in the result block. We avoid problems by
3275 claiming that all hard registers are used and clobbered at this
3276 point. */
3277 emit_insn (gen_blockage ());
3278
3279 DONE;
3280 })
3281
3282 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
3283 ;; all of memory. This blocks insns from being moved across this point.
3284
3285 (define_insn "blockage"
3286 [(unspec_volatile [(const_int 0)] VUNSPEC_BLOCKAGE)]
3287 ""
3288 ""
3289 [(set_attr "length" "0")])
3290
3291 (define_insn "*call_value_internal_vh"
3292 [(set (match_operand:HF 0 "register_operand" "=v,v,v")
3293 (call (mem:SI (match_operand:SI 1 "csky_call_address_operand" "b, r,S"))
3294 (match_operand 2 "" "")))
3295 (clobber (reg:SI CSKY_LR_REGNUM))]
3296 "TARGET_HARD_FLOAT_ABI && CSKY_ISA_FEATURE (fpv3_hf)"
3297 "@
3298 jsr\t%1
3299 jsr\t%1
3300 jbsr\t%1"
3301 [(set_attr "length" "2,4,4")
3302 (set_attr "type" "call_jsr,call_jsr,call")]
3303 )
3304
3305 (define_insn "*call_value_internal_vs"
3306 [(set (match_operand:SF 0 "register_operand" "=v,v,v")
3307 (call (mem:SI (match_operand:SI 1 "csky_call_address_operand" "b, r,S"))
3308 (match_operand 2 "" "")))
3309 (clobber (reg:SI CSKY_LR_REGNUM))]
3310 "TARGET_HARD_FLOAT_ABI"
3311 "@
3312 jsr\t%1
3313 jsr\t%1
3314 jbsr\t%1"
3315 [(set_attr "length" "2,4,4")
3316 (set_attr "type" "call_jsr,call_jsr,call")]
3317 )
3318
3319 (define_insn "*call_value_internal_vd"
3320 [(set (match_operand:DF 0 "register_operand" "=v,v,v")
3321 (call (mem:SI (match_operand:SI 1 "csky_call_address_operand" "b, r,S"))
3322 (match_operand 2 "" "")))
3323 (clobber (reg:SI CSKY_LR_REGNUM))]
3324 "TARGET_HARD_FLOAT_ABI && TARGET_DOUBLE_FPU"
3325 "@
3326 jsr\t%1
3327 jsr\t%1
3328 jbsr\t%1"
3329 [(set_attr "length" "2,4,4")
3330 (set_attr "type" "call_jsr,call_jsr,call")]
3331 )
3332
3333 (define_insn "*call_value_internal_pic_vs"
3334 [(set (match_operand:SF 0 "register_operand" "=v")
3335 (call (mem:SI (match_operand:SI 1 "csky_unspec_operand" "X"))
3336 (match_operand 2 "" "")))
3337 (clobber (reg:SI CSKY_LR_REGNUM))]
3338 "flag_pic && TARGET_HARD_FLOAT_ABI"
3339 "* return csky_output_call (operands, 1);"
3340 )
3341
3342 (define_insn "*call_value_internal_pic_vd"
3343 [(set (match_operand:DF 0 "register_operand" "=v")
3344 (call (mem:SI (match_operand:SI 1 "csky_unspec_operand" "X"))
3345 (match_operand 2 "" "")))
3346 (clobber (reg:SI CSKY_LR_REGNUM))]
3347 "flag_pic && TARGET_HARD_FLOAT_ABI && TARGET_DOUBLE_FPU"
3348 "* return csky_output_call (operands, 1);"
3349 )
3350
3351 (define_insn "*call_value_internal"
3352 [(set (match_operand 0 "register_operand" "=r,r,r")
3353 (call (mem:SI (match_operand:SI 1 "csky_call_address_operand" "b, r,S"))
3354 (match_operand 2 "" "")))
3355 (clobber (reg:SI CSKY_LR_REGNUM))]
3356 ""
3357 "@
3358 jsr\t%1
3359 jsr\t%1
3360 jbsr\t%1"
3361 [(set_attr "length" "2,4,4")
3362 (set_attr "type" "call_jsr,call_jsr,call")]
3363 )
3364
3365 (define_insn "*call_value_internal_pic"
3366 [(set (match_operand 0 "register_operand" "=r")
3367 (call (mem:SI (match_operand:SI 1 "csky_unspec_operand" "X"))
3368 (match_operand 2 "" "")))
3369 (clobber (reg:SI CSKY_LR_REGNUM))]
3370 "flag_pic"
3371 "* return csky_output_call (operands, 1);"
3372 )
3373
3374 (define_insn "*call_value_struct"
3375 [(set (match_parallel 0 ""
3376 [(expr_list (match_operand 3 "register_operand" "")
3377 (match_operand 4 "immediate_operand" ""))
3378 (expr_list (match_operand 5 "register_operand" "")
3379 (match_operand 6 "immediate_operand" ""))])
3380 (call (mem:SI (match_operand:SI 1 "csky_call_address_operand" "b,r,S"))
3381 (match_operand 2 "" "")))
3382 (clobber (reg:SI CSKY_LR_REGNUM))]
3383 ""
3384 "@
3385 jsr\t%1
3386 jsr\t%1
3387 jbsr\t%1"
3388 [(set_attr "length" "2,4,4")
3389 (set_attr "type" "call_jsr,call_jsr,call")]
3390 )
3391
3392 (define_insn "*call_value_struct_pic"
3393 [(set (match_parallel 0 ""
3394 [(expr_list (match_operand 3 "register_operand" "")
3395 (match_operand 4 "immediate_operand" ""))
3396 (expr_list (match_operand 5 "register_operand" "")
3397 (match_operand 6 "immediate_operand" ""))])
3398 (call (mem:SI (match_operand:SI 1 "csky_unspec_operand" "X"))
3399 (match_operand 2 "" "")))
3400 (clobber (reg:SI CSKY_LR_REGNUM))]
3401 "flag_pic"
3402 "* return csky_output_call (operands, 1);"
3403 )
3404
3405
3406 ;; -------------------------------------------------------------
3407 ;; prologue & epilogue
3408 ;; -------------------------------------------------------------
3409
3410 (define_expand "prologue"
3411 [(clobber (const_int 0))]
3412 ""
3413 "
3414 {
3415 csky_expand_prologue ();
3416 DONE;
3417 }"
3418 )
3419
3420 (define_expand "epilogue"
3421 [(clobber (const_int 0))]
3422 ""
3423 "
3424 {
3425 csky_expand_epilogue ();
3426 DONE;
3427 }"
3428 )
3429
3430 /* TODO: pushpop */
3431 ;; Push multiple registers to the stack. Registers are in parallel (use ...)
3432 ;; expressions. For simplicity, the first register is also in the unspec
3433 ;; part.
3434 (define_insn "*push_multi"
3435 [(match_parallel 2 "registers_push"
3436 [(set (match_operand:BLK 0 "push_memory_operand" "")
3437 (unspec:BLK [(match_operand:SI 1 "register_operand" "")]
3438 UNSPEC_PUSHPOP_MULT))])]
3439 ""
3440 {
3441 int num_saves = XVECLEN (operands[2], 0);
3442 int i;
3443 char pattern[100];
3444
3445 strcpy (pattern, \"push\\t%1\");
3446
3447 for (i = 1; i < num_saves; i++)
3448 {
3449 strcat (pattern, \", \");
3450 strcat (pattern,
3451 reg_names[REGNO (XEXP (XVECEXP (operands[2], 0, i), 0))]);
3452 }
3453
3454 output_asm_insn (pattern, operands);
3455
3456 return \"\";
3457 }
3458 [(set (attr "length")
3459 (symbol_ref "csky_compute_pushpop_length (operands)"))]
3460 )
3461
3462 ;; Pop (as used in epilogue RTL)
3463 ;;
3464 (define_insn "*pop_multi"
3465 [(match_parallel 2 "registers_pop"
3466 [(return)
3467 (set (match_operand:SI 1 "register_operand" "")
3468 (unspec:SI [(match_operand:SI 0 "pop_memory_operand" "")]
3469 UNSPEC_PUSHPOP_MULT))])]
3470 ""
3471 {
3472 int num_saves = XVECLEN (operands[2], 0);
3473 int i;
3474 char pattern[100];
3475
3476 strcpy (pattern, \"pop\\t%1\");
3477
3478 for (i = 2; i < num_saves; i++)
3479 {
3480 strcat (pattern, \", \");
3481 strcat (pattern,
3482 reg_names[REGNO (XEXP (XVECEXP (operands[2], 0, i), 0))]);
3483 }
3484
3485 output_asm_insn (pattern, operands);
3486
3487 return \"\";
3488 }
3489 [(set (attr "length")
3490 (symbol_ref "csky_compute_pushpop_length (operands)"))]
3491 )
3492
3493
3494 ;; -------------------------------------------------------------------------
3495 ;; PIC related insns
3496 ;; -------------------------------------------------------------------------
3497
3498 (define_insn "prologue_get_pc"
3499 [(set (reg:SI 28)
3500 (match_operand:SI 0 "" "X"))]
3501 "(GET_CODE (operands[0]) == UNSPEC)
3502 && (XINT (operands[0], 1) == UNSPEC_PIC_SYMBOL_GOTPC_GRS)"
3503 {
3504 operands[0] = XVECEXP (operands[0], 0, 0);
3505 output_asm_insn (\"grs\tgb, %0\", operands);
3506 default_internal_label (asm_out_file, \"L\",
3507 CODE_LABEL_NUMBER (XEXP (operands[0], 0)));
3508 return \"\";
3509 }
3510 )
3511
3512 (define_insn "*pic_got_pc"
3513 [(set (match_operand:SI 0 "register_operand" "=r")
3514 (unspec:SI [(match_operand:SI 1 "" "")] UNSPEC_PIC_SYMBOL_GOTPC))]
3515 "flag_pic"
3516 "lrw\t%0, %1@GOTPC"
3517 )
3518
3519 (define_insn "*pic_symbol_gotoff"
3520 [(set (match_operand:SI 0 "register_operand" "=r")
3521 (unspec:SI [(match_operand:SI 1 "" "")] UNSPEC_PIC_SYMBOL_GOTOFF))]
3522 "flag_pic"
3523 "lrw\t%0, %1@GOTOFF"
3524 )
3525
3526 (define_insn "*pic_symbol_got"
3527 [(set (match_operand:SI 0 "register_operand" "=r")
3528 (unspec:SI [(match_operand:SI 1 "" "")] UNSPEC_PIC_SYMBOL_GOT))]
3529 "flag_pic"
3530 "lrw\t%0, %1@GOT"
3531 )
3532
3533 (define_insn "*pic_symbol_plt"
3534 [(set (match_operand:SI 0 "register_operand" "=r")
3535 (unspec:SI [(match_operand:SI 1 "" "")] UNSPEC_PIC_SYMBOL_PLT))]
3536 "flag_pic"
3537 "lrw\t%0, %1@PLT"
3538 )
3539
3540 (define_insn "*pic_symbol_grs"
3541 [(set (match_operand:SI 0 "register_operand" "=r")
3542 (unspec:SI [(match_operand:SI 1 "" "")] UNSPEC_PIC_SYMBOL_GRS))]
3543 "flag_pic"
3544 "grs\t%0, %1"
3545 )
3546
3547 (define_expand "builtin_setjmp_receiver"
3548 [(label_ref (match_operand 0 "" ""))]
3549 "flag_pic"
3550 "{
3551 rtx l1 = gen_label_rtx();
3552 rtx grs_label = gen_rtx_LABEL_REF (SImode, l1);
3553 rtx reg_gb = gen_rtx_REG (SImode, PIC_OFFSET_TABLE_REGNUM);
3554 rtx reg_temp = gen_rtx_REG (SImode, 12);
3555
3556 rtx tmp0_unspec = gen_rtx_UNSPEC (Pmode,
3557 gen_rtvec (1, grs_label),
3558 UNSPEC_PIC_SYMBOL_GOTPC_GRS);
3559 rtx tmp1_unspec = gen_rtx_UNSPEC (Pmode,
3560 gen_rtvec (1, grs_label),
3561 UNSPEC_PIC_SYMBOL_GOTPC);
3562
3563 emit_insn (gen_prologue_get_pc (tmp0_unspec));
3564 emit_move_insn (reg_temp, tmp1_unspec);
3565 emit_insn (gen_addsi3 (reg_gb, reg_gb, reg_temp));
3566 emit_use (reg_gb);
3567
3568 DONE;
3569 }"
3570 )
3571
3572 ;; -------------------------------------------------------------------------
3573 ;; TLS related insns
3574 ;; -------------------------------------------------------------------------
3575
3576
3577 ;; UNSPEC_TLS can take either 2 or 3 operands. Operand 0 is the symbol_ref,
3578 ;; operand 1 is a CONST_INT identifying the TLS model, and the optional
3579 ;; operand 3 is an UNSPEC_TLS_LABEL.
3580 ;; The 3-operand case is for TLS_GD32, TLS_LDM32, and TLS_IE32.
3581 ;; The 2-operand case is for TLS_LE32 and TLS_LDO32.
3582
3583 ;; Move PC-relative TLS label to reg. This is used for the TLS_GD32
3584 ;; and TLS_GD32 models (when setting up a call to tls_get_addr) and
3585 ;; also TLS_IE32.
3586
3587 (define_insn "*tls_pcrel_label"
3588 [(set (match_operand:SI 0 "register_operand" "=r")
3589 (unspec:SI [(match_operand:SI 1 "const_int_operand" "")]
3590 UNSPEC_TLS_LABEL))]
3591 "TARGET_TLS"
3592 "grs\t%0, .LTLS%1"
3593 [(set_attr "length" "4")]
3594 )
3595
3596 ;; This pattern is used to load the TLS base for the same models as above.
3597 ;; The embedded UNSPEC_TLS_LABEL only identifies the label to emit and
3598 ;; doesn't generate a reference to it; that's handled by the *tls_pcrel_label
3599 ;; pattern above. The label offset needs to be added to the result stored
3600 ;; in operand 0 by this insn.
3601
3602 (define_insn "*tls_get_symbol_1"
3603 [(set (match_operand:SI 0 "register_operand" "=r")
3604 (unspec:SI [(match_operand 1 "" "")
3605 (match_operand 2 "" "")
3606 (unspec:SI [(match_operand 3 "" "")] UNSPEC_TLS_LABEL)]
3607 UNSPEC_TLS))]
3608 "TARGET_TLS"
3609 {
3610 default_internal_label (asm_out_file, \"LTLS\", INTVAL (operands[3]));
3611 switch (INTVAL (operands[2]))
3612 {
3613 case TLS_GD32:
3614 return \"lrw\t%0, %1@TLSGD32\";
3615 case TLS_LDM32:
3616 return \"lrw\t%0, %1@TLSLDM32\";
3617 case TLS_IE32:
3618 return \"lrw\t%0, %1@GOTTPOFF\";
3619 default:
3620 return \"\";
3621 }
3622 }
3623 )
3624
3625 ;; This pattern matches the two-operand form of UNSPEC_TLS.
3626
3627 (define_insn "*tls_get_symbol_2"
3628 [(set (match_operand:SI 0 "register_operand" "=r")
3629 (unspec:SI [(match_operand 1 "" "")
3630 (match_operand 2 "" "")]
3631 UNSPEC_TLS))]
3632 "TARGET_TLS"
3633 {
3634 switch (INTVAL (operands[2]))
3635 {
3636 case TLS_LE32:
3637 return \"lrw\t%0, %1@TPOFF\";
3638 case TLS_LDO32:
3639 return \"lrw\t%0, %1@TLSLDO32\";
3640 default:
3641 return \"\";
3642 }
3643 }
3644 )
3645
3646
3647 ;; -------------------------------------------------------------
3648 ;; Misc insns
3649 ;; -------------------------------------------------------------
3650
3651 (define_insn "nop"
3652 [(const_int 0)]
3653 ""
3654 "nop"
3655 [(set_attr "length" "2")]
3656 )
3657
3658 (define_insn "trap"
3659 [(trap_if (const_int 1) (const_int 0))]
3660 ""
3661 "bkpt"
3662 [(set (attr "length") (const_int 2))
3663 (set_attr "type" "alu")]
3664 )
3665
3666
3667 ;; -------------------------------------------------------------
3668 ;; Special patterns for dealing with the constant pool
3669 ;; -------------------------------------------------------------
3670
3671 (define_insn "align_4"
3672 [(unspec_volatile [(const_int 0)] VUNSPEC_ALIGN)]
3673 ""
3674 {
3675 assemble_align(32);
3676 return \"\";
3677 }
3678 [(set_attr "length" "0")]
3679 )
3680
3681 (define_insn "csky_constpool_label"
3682 [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_LABEL)]
3683 ""
3684 {
3685 char tmp_label[15];
3686 ASM_GENERATE_INTERNAL_LABEL (tmp_label, \"LCP\", INTVAL (operands[0]));
3687 assemble_label (asm_out_file, tmp_label);
3688 return \"\";
3689 }
3690 [(set_attr "length" "0")]
3691 )
3692
3693 (define_insn "consttable_4"
3694 [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_4)]
3695 ""
3696 {
3697 if (CONST_DOUBLE_P (operands[0]))
3698 assemble_real (*CONST_DOUBLE_REAL_VALUE (operands[0]),
3699 SFmode, BITS_PER_WORD);
3700 else
3701 {
3702 assemble_integer (operands[0], 4, BITS_PER_WORD, 1);
3703 mark_symbol_refs_as_used (operands[0]);
3704 }
3705 return \"\";
3706 }
3707 [(set_attr "length" "4")]
3708 )
3709
3710 (define_insn "consttable_8"
3711 [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_8)]
3712 ""
3713 {
3714 if (CONST_DOUBLE_P (operands[0]))
3715 assemble_real (*CONST_DOUBLE_REAL_VALUE (operands[0]),
3716 DFmode, BITS_PER_WORD);
3717 else
3718 assemble_integer (operands[0], 8, BITS_PER_WORD, 1);
3719 return \"\";
3720 }
3721 [(set_attr "length" "8")]
3722 )
3723
3724 ;;FIXME record the deferred symbol_ref information with use insn
3725 (define_insn "*cskyv2_use_symbol_ref"
3726 [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_SYMBOL_REF)]
3727 ""
3728 ""
3729 [(set_attr "length" "0")]
3730 )
3731
3732
3733 ;; ------------------------------------------------------------
3734 ;; switch case optimize
3735 ;; ------------------------------------------------------------
3736
3737 (define_expand "casesi"
3738 [(match_operand:SI 0 "register_operand" "") ; index to jump on
3739 (match_operand:SI 1 "const_int_operand" "") ; lower bound
3740 (match_operand:SI 2 "const_int_operand" "") ; total range (max - min)
3741 (match_operand:SI 3 "" "") ; table label
3742 (match_operand:SI 4 "" "")] ; Out of range label (default:)
3743 "TARGET_CASESI"
3744 "
3745 {
3746 enum insn_code code;
3747 if (operands[1] != const0_rtx)
3748 {
3749 rtx reg = gen_reg_rtx (SImode);
3750 emit_insn (gen_subsi3 (reg,
3751 operands[0],
3752 GEN_INT (INTVAL (operands[1]))));
3753 operands[0] = reg;
3754 }
3755
3756 code = CODE_FOR_csky_casesi_internal;
3757
3758 if (!insn_data[(int) code].operand[1].predicate(operands[2], SImode))
3759 operands[2] = force_reg (SImode,operands[2]);
3760
3761 emit_jump_insn (GEN_FCN ((int) code) (operands[0],operands[2],
3762 operands[3],operands[4]));
3763 DONE;
3764 }"
3765 )
3766
3767 (define_expand "csky_casesi_internal"
3768 [(match_operand:SI 0 "register_operand" "")
3769 (match_operand:SI 1 "csky_literal_Uk_operand" "")
3770 (match_operand 2 "" "")
3771 (match_operand 3 "" "")]
3772 ""
3773 {
3774 rtx reg0;
3775 rtx test = gen_rtx_GTU (VOIDmode, operands[0], operands[1]);
3776 emit_jump_insn (gen_cbranchsi4 (test, operands[0], operands[1],
3777 operands[3]));
3778 reg0 = gen_rtx_REG (SImode, 0);
3779 emit_move_insn (reg0, operands[0]);
3780 emit_jump_insn (gen_csky_casesi_dispatch (operands[2]));
3781 DONE;
3782 }
3783 )
3784
3785 (define_insn "csky_casesi_dispatch"
3786 [(parallel [(set (pc) (unspec [(reg:SI 0)
3787 (label_ref (match_operand 0 "" ""))]
3788 UNSPEC_CSKY_CASESI))
3789 (clobber (reg:SI CSKY_LR_REGNUM))])]
3790 ""
3791 "*return csky_output_casesi (operands);"
3792 [(set_attr "length" "4")]
3793 )
3794
3795 ;; ------------------------------------------------------------------------
3796 ;; index insns
3797 ;; ------------------------------------------------------------------------
3798
3799 (define_insn "*cskyv2_indexsi_t"
3800 [(set (match_operand:SI 0 "register_operand" "=r")
3801 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
3802 (const_int 4))
3803 (match_operand:SI 2 "register_operand" "r")))]
3804 "CSKY_ISA_FEATURE (E2)"
3805 "ixw\t%0, %2, %1"
3806 )
3807
3808 (define_insn "*cskyv2_indexhi_t"
3809 [(set (match_operand:SI 0 "register_operand" "=r")
3810 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
3811 (const_int 2))
3812 (match_operand:SI 2 "register_operand" "r")))]
3813 "CSKY_ISA_FEATURE (E2)"
3814 "ixh\t%0, %2, %1"
3815 )
3816
3817 (define_insn "*cskyv2_indexdi_t"
3818 [(set (match_operand:SI 0 "register_operand" "=r")
3819 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
3820 (const_int 8))
3821 (match_operand:SI 2 "register_operand" "r")))]
3822 "CSKY_ISA_FEATURE (2E3)"
3823 "ixd\t%0, %2, %1"
3824 )
3825
3826 ;; ------------------------------------------------------------------------
3827 ;; swap insns
3828 ;; ------------------------------------------------------------------------
3829
3830 (define_insn "bswapsi2"
3831 [(set (match_operand:SI 0 "register_operand" "=r")
3832 (bswap:SI (match_operand:SI 1 "register_operand" "r")))]
3833 "CSKY_ISA_FEATURE (E2)"
3834 "revb\t%0, %1"
3835 )