1 ;; ARM Thumb-2 Machine Description
2 ;; Copyright (C) 2007-2014 Free Software Foundation, Inc.
3 ;; Written by CodeSourcery, LLC.
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3, or (at your option)
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.
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/>. */
21 ;; Note: Thumb-2 is the variant of the Thumb architecture that adds
22 ;; 32-bit encodings of [almost all of] the Arm instruction set.
23 ;; Some old documents refer to the relatively minor interworking
24 ;; changes made in armv5t as "thumb2". These are considered part
25 ;; the 16-bit Thumb-1 instruction set.
27 ;; Thumb-2 only allows shift by constant on data processing instructions
28 (define_insn "*thumb_andsi_not_shiftsi_si"
29 [(set (match_operand:SI 0 "s_register_operand" "=r")
30 (and:SI (not:SI (match_operator:SI 4 "shift_operator"
31 [(match_operand:SI 2 "s_register_operand" "r")
32 (match_operand:SI 3 "const_int_operand" "M")]))
33 (match_operand:SI 1 "s_register_operand" "r")))]
35 "bic%?\\t%0, %1, %2%S4"
36 [(set_attr "predicable" "yes")
37 (set_attr "predicable_short_it" "no")
38 (set_attr "shift" "2")
39 (set_attr "type" "alu_shift_imm")]
42 ;; We use the '0' constraint for operand 1 because reload should
43 ;; be smart enough to generate an appropriate move for the r/r/r case.
44 (define_insn_and_split "*thumb2_smaxsi3"
45 [(set (match_operand:SI 0 "s_register_operand" "=r,l,r")
46 (smax:SI (match_operand:SI 1 "s_register_operand" "%0,0,0")
47 (match_operand:SI 2 "arm_rhs_operand" "r,Py,I")))
48 (clobber (reg:CC CC_REGNUM))]
51 ; cmp\\t%1, %2\;it\\tlt\;movlt\\t%0, %2
52 "TARGET_THUMB2 && reload_completed"
53 [(set (reg:CC CC_REGNUM)
54 (compare:CC (match_dup 1) (match_dup 2)))
55 (cond_exec (lt:SI (reg:CC CC_REGNUM) (const_int 0))
59 [(set_attr "conds" "clob")
60 (set_attr "enabled_for_depr_it" "yes,yes,no")
61 (set_attr "length" "6,6,10")
62 (set_attr "type" "multiple")]
65 (define_insn_and_split "*thumb2_sminsi3"
66 [(set (match_operand:SI 0 "s_register_operand" "=r,l,r")
67 (smin:SI (match_operand:SI 1 "s_register_operand" "%0,0,0")
68 (match_operand:SI 2 "arm_rhs_operand" "r,Py,I")))
69 (clobber (reg:CC CC_REGNUM))]
72 ; cmp\\t%1, %2\;it\\tge\;movge\\t%0, %2
73 "TARGET_THUMB2 && reload_completed"
74 [(set (reg:CC CC_REGNUM)
75 (compare:CC (match_dup 1) (match_dup 2)))
76 (cond_exec (ge:SI (reg:CC CC_REGNUM) (const_int 0))
80 [(set_attr "conds" "clob")
81 (set_attr "enabled_for_depr_it" "yes,yes,no")
82 (set_attr "length" "6,6,10")
83 (set_attr "type" "multiple")]
86 (define_insn_and_split "*thumb32_umaxsi3"
87 [(set (match_operand:SI 0 "s_register_operand" "=r,l,r")
88 (umax:SI (match_operand:SI 1 "s_register_operand" "%0,0,0")
89 (match_operand:SI 2 "arm_rhs_operand" "r,Py,I")))
90 (clobber (reg:CC CC_REGNUM))]
93 ; cmp\\t%1, %2\;it\\tcc\;movcc\\t%0, %2
94 "TARGET_THUMB2 && reload_completed"
95 [(set (reg:CC CC_REGNUM)
96 (compare:CC (match_dup 1) (match_dup 2)))
97 (cond_exec (ltu:SI (reg:CC CC_REGNUM) (const_int 0))
101 [(set_attr "conds" "clob")
102 (set_attr "length" "6,6,10")
103 (set_attr "enabled_for_depr_it" "yes,yes,no")
104 (set_attr "type" "multiple")]
107 (define_insn_and_split "*thumb2_uminsi3"
108 [(set (match_operand:SI 0 "s_register_operand" "=r,l,r")
109 (umin:SI (match_operand:SI 1 "s_register_operand" "%0,0,0")
110 (match_operand:SI 2 "arm_rhs_operand" "r,Py,I")))
111 (clobber (reg:CC CC_REGNUM))]
114 ; cmp\\t%1, %2\;it\\tcs\;movcs\\t%0, %2
115 "TARGET_THUMB2 && reload_completed"
116 [(set (reg:CC CC_REGNUM)
117 (compare:CC (match_dup 1) (match_dup 2)))
118 (cond_exec (geu:SI (reg:CC CC_REGNUM) (const_int 0))
122 [(set_attr "conds" "clob")
123 (set_attr "length" "6,6,10")
124 (set_attr "enabled_for_depr_it" "yes,yes,no")
125 (set_attr "type" "multiple")]
128 ;; Thumb-2 does not have rsc, so use a clever trick with shifter operands.
129 (define_insn_and_split "*thumb2_negdi2"
130 [(set (match_operand:DI 0 "s_register_operand" "=&r,r")
131 (neg:DI (match_operand:DI 1 "s_register_operand" "?r,0")))
132 (clobber (reg:CC CC_REGNUM))]
134 "#" ; negs\\t%Q0, %Q1\;sbc\\t%R0, %R1, %R1, lsl #1
135 "&& reload_completed"
136 [(parallel [(set (reg:CC CC_REGNUM)
137 (compare:CC (const_int 0) (match_dup 1)))
138 (set (match_dup 0) (minus:SI (const_int 0) (match_dup 1)))])
139 (set (match_dup 2) (minus:SI (minus:SI (match_dup 3)
140 (ashift:SI (match_dup 3)
142 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
144 operands[2] = gen_highpart (SImode, operands[0]);
145 operands[0] = gen_lowpart (SImode, operands[0]);
146 operands[3] = gen_highpart (SImode, operands[1]);
147 operands[1] = gen_lowpart (SImode, operands[1]);
149 [(set_attr "conds" "clob")
150 (set_attr "length" "8")
151 (set_attr "type" "multiple")]
154 (define_insn_and_split "*thumb2_abssi2"
155 [(set (match_operand:SI 0 "s_register_operand" "=&r,l,r")
156 (abs:SI (match_operand:SI 1 "s_register_operand" "r,0,0")))
157 (clobber (reg:CC CC_REGNUM))]
160 ; eor%?\\t%0, %1, %1, asr #31\;sub%?\\t%0, %0, %1, asr #31
161 ; cmp\\t%0, #0\;it\tlt\;rsblt\\t%0, %0, #0
162 ; cmp\\t%0, #0\;it\tlt\;rsblt\\t%0, %0, #0
163 "&& reload_completed"
166 if (REGNO(operands[0]) == REGNO(operands[1]))
168 rtx cc_reg = gen_rtx_REG (CCmode, CC_REGNUM);
170 emit_insn (gen_rtx_SET (VOIDmode,
172 gen_rtx_COMPARE (CCmode, operands[0], const0_rtx)));
173 emit_insn (gen_rtx_COND_EXEC (VOIDmode,
177 (gen_rtx_SET (VOIDmode,
179 (gen_rtx_MINUS (SImode,
185 emit_insn (gen_rtx_SET (VOIDmode,
188 gen_rtx_ASHIFTRT (SImode,
192 emit_insn (gen_rtx_SET (VOIDmode,
194 gen_rtx_MINUS (SImode,
196 gen_rtx_ASHIFTRT (SImode,
202 [(set_attr "conds" "*,clob,clob")
203 (set_attr "shift" "1")
204 (set_attr "predicable" "yes,no,no")
205 (set_attr "predicable_short_it" "no")
206 (set_attr "enabled_for_depr_it" "yes,yes,no")
207 (set_attr "ce_count" "2")
208 (set_attr "length" "8,6,10")
209 (set_attr "type" "multiple")]
212 (define_insn_and_split "*thumb2_neg_abssi2"
213 [(set (match_operand:SI 0 "s_register_operand" "=&r,l,r")
214 (neg:SI (abs:SI (match_operand:SI 1 "s_register_operand" "r,0,0"))))
215 (clobber (reg:CC CC_REGNUM))]
218 ; eor%?\\t%0, %1, %1, asr #31\;rsb%?\\t%0, %0, %1, asr #31
219 ; cmp\\t%0, #0\;it\\tgt\;rsbgt\\t%0, %0, #0
220 ; cmp\\t%0, #0\;it\\tgt\;rsbgt\\t%0, %0, #0
221 "&& reload_completed"
224 if (REGNO(operands[0]) == REGNO(operands[1]))
226 rtx cc_reg = gen_rtx_REG (CCmode, CC_REGNUM);
228 emit_insn (gen_rtx_SET (VOIDmode,
230 gen_rtx_COMPARE (CCmode, operands[0], const0_rtx)));
231 emit_insn (gen_rtx_COND_EXEC (VOIDmode,
235 (gen_rtx_SET (VOIDmode,
237 (gen_rtx_MINUS (SImode,
243 emit_insn (gen_rtx_SET (VOIDmode,
246 gen_rtx_ASHIFTRT (SImode,
250 emit_insn (gen_rtx_SET (VOIDmode,
252 gen_rtx_MINUS (SImode,
253 gen_rtx_ASHIFTRT (SImode,
260 [(set_attr "conds" "*,clob,clob")
261 (set_attr "shift" "1")
262 (set_attr "predicable" "yes,no,no")
263 (set_attr "enabled_for_depr_it" "yes,yes,no")
264 (set_attr "predicable_short_it" "no")
265 (set_attr "ce_count" "2")
266 (set_attr "length" "8,6,10")
267 (set_attr "type" "multiple")]
270 ;; We have two alternatives here for memory loads (and similarly for stores)
271 ;; to reflect the fact that the permissible constant pool ranges differ
272 ;; between ldr instructions taking low regs and ldr instructions taking high
273 ;; regs. The high register alternatives are not taken into account when
274 ;; choosing register preferences in order to reflect their expense.
275 (define_insn "*thumb2_movsi_insn"
276 [(set (match_operand:SI 0 "nonimmediate_operand" "=rk,r,l,r,r,l ,*hk,m,*m")
277 (match_operand:SI 1 "general_operand" "rk,I,Py,K,j,mi,*mi,l,*hk"))]
278 "TARGET_THUMB2 && ! TARGET_IWMMXT
279 && !(TARGET_HARD_FLOAT && TARGET_VFP)
280 && ( register_operand (operands[0], SImode)
281 || register_operand (operands[1], SImode))"
292 [(set_attr "type" "mov_reg,alu_imm,alu_imm,alu_imm,mov_imm,load1,load1,store1,store1")
293 (set_attr "length" "2,4,2,4,4,4,4,4,4")
294 (set_attr "predicable" "yes")
295 (set_attr "predicable_short_it" "yes,no,yes,no,no,no,no,no,no")
296 (set_attr "pool_range" "*,*,*,*,*,1018,4094,*,*")
297 (set_attr "neg_pool_range" "*,*,*,*,*,0,0,*,*")]
300 (define_insn "tls_load_dot_plus_four"
301 [(set (match_operand:SI 0 "register_operand" "=l,l,r,r")
302 (mem:SI (unspec:SI [(match_operand:SI 2 "register_operand" "0,1,0,1")
304 (match_operand 3 "" "")]
306 (clobber (match_scratch:SI 1 "=X,l,X,r"))]
309 (*targetm.asm_out.internal_label) (asm_out_file, \"LPIC\",
310 INTVAL (operands[3]));
311 return \"add\\t%2, %|pc\;ldr%?\\t%0, [%2]\";
313 [(set_attr "length" "4,4,6,6")
314 (set_attr "type" "multiple")]
317 ;; Thumb-2 always has load/store halfword instructions, so we can avoid a lot
318 ;; of the messiness associated with the ARM patterns.
319 (define_insn "*thumb2_movhi_insn"
320 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r")
321 (match_operand:HI 1 "general_operand" "rI,n,r,m"))]
323 && (register_operand (operands[0], HImode)
324 || register_operand (operands[1], HImode))"
326 mov%?\\t%0, %1\\t%@ movhi
327 movw%?\\t%0, %L1\\t%@ movhi
328 str%(h%)\\t%1, %0\\t%@ movhi
329 ldr%(h%)\\t%0, %1\\t%@ movhi"
330 [(set_attr "type" "mov_imm,mov_reg,store1,load1")
331 (set_attr "predicable" "yes")
332 (set_attr "pool_range" "*,*,*,4094")
333 (set_attr "neg_pool_range" "*,*,*,250")]
336 (define_insn "*thumb2_storewb_pairsi"
337 [(set (match_operand:SI 0 "register_operand" "=&kr")
338 (plus:SI (match_operand:SI 1 "register_operand" "0")
339 (match_operand:SI 2 "const_int_operand" "n")))
340 (set (mem:SI (plus:SI (match_dup 0) (match_dup 2)))
341 (match_operand:SI 3 "register_operand" "r"))
342 (set (mem:SI (plus:SI (match_dup 0)
343 (match_operand:SI 5 "const_int_operand" "n")))
344 (match_operand:SI 4 "register_operand" "r"))]
346 && INTVAL (operands[5]) == INTVAL (operands[2]) + 4"
347 "strd\\t%3, %4, [%0, %2]!"
348 [(set_attr "type" "store2")]
351 (define_insn "*thumb2_cmpsi_neg_shiftsi"
352 [(set (reg:CC CC_REGNUM)
353 (compare:CC (match_operand:SI 0 "s_register_operand" "r")
354 (neg:SI (match_operator:SI 3 "shift_operator"
355 [(match_operand:SI 1 "s_register_operand" "r")
356 (match_operand:SI 2 "const_int_operand" "M")]))))]
359 [(set_attr "conds" "set")
360 (set_attr "shift" "1")
361 (set_attr "type" "alus_shift_imm")]
364 (define_insn_and_split "*thumb2_mov_scc"
365 [(set (match_operand:SI 0 "s_register_operand" "=l,r")
366 (match_operator:SI 1 "arm_comparison_operator"
367 [(match_operand 2 "cc_register" "") (const_int 0)]))]
369 "#" ; "ite\\t%D1\;mov%D1\\t%0, #0\;mov%d1\\t%0, #1"
372 (if_then_else:SI (match_dup 1)
376 [(set_attr "conds" "use")
377 (set_attr "enabled_for_depr_it" "yes,no")
378 (set_attr "length" "8,10")
379 (set_attr "type" "multiple")]
382 (define_insn_and_split "*thumb2_mov_negscc"
383 [(set (match_operand:SI 0 "s_register_operand" "=r")
384 (neg:SI (match_operator:SI 1 "arm_comparison_operator"
385 [(match_operand 2 "cc_register" "") (const_int 0)])))]
386 "TARGET_THUMB2 && !arm_restrict_it"
387 "#" ; "ite\\t%D1\;mov%D1\\t%0, #0\;mvn%d1\\t%0, #0"
390 (if_then_else:SI (match_dup 1)
394 operands[3] = GEN_INT (~0);
396 [(set_attr "conds" "use")
397 (set_attr "length" "10")
398 (set_attr "type" "multiple")]
401 (define_insn_and_split "*thumb2_mov_negscc_strict_it"
402 [(set (match_operand:SI 0 "low_register_operand" "=l")
403 (neg:SI (match_operator:SI 1 "arm_comparison_operator"
404 [(match_operand 2 "cc_register" "") (const_int 0)])))]
405 "TARGET_THUMB2 && arm_restrict_it"
406 "#" ; ";mvn\\t%0, #0 ;it\\t%D1\;mov%D1\\t%0, #0\"
407 "&& reload_completed"
410 (cond_exec (match_dup 4)
414 operands[3] = GEN_INT (~0);
415 enum machine_mode mode = GET_MODE (operands[2]);
416 enum rtx_code rc = GET_CODE (operands[1]);
418 if (mode == CCFPmode || mode == CCFPEmode)
419 rc = reverse_condition_maybe_unordered (rc);
421 rc = reverse_condition (rc);
422 operands[4] = gen_rtx_fmt_ee (rc, VOIDmode, operands[2], const0_rtx);
425 [(set_attr "conds" "use")
426 (set_attr "length" "8")
427 (set_attr "type" "multiple")]
430 (define_insn_and_split "*thumb2_mov_notscc"
431 [(set (match_operand:SI 0 "s_register_operand" "=r")
432 (not:SI (match_operator:SI 1 "arm_comparison_operator"
433 [(match_operand 2 "cc_register" "") (const_int 0)])))]
434 "TARGET_THUMB2 && !arm_restrict_it"
435 "#" ; "ite\\t%D1\;mvn%D1\\t%0, #0\;mvn%d1\\t%0, #1"
438 (if_then_else:SI (match_dup 1)
442 operands[3] = GEN_INT (~1);
443 operands[4] = GEN_INT (~0);
445 [(set_attr "conds" "use")
446 (set_attr "length" "10")
447 (set_attr "type" "multiple")]
450 (define_insn_and_split "*thumb2_mov_notscc_strict_it"
451 [(set (match_operand:SI 0 "low_register_operand" "=l")
452 (not:SI (match_operator:SI 1 "arm_comparison_operator"
453 [(match_operand 2 "cc_register" "") (const_int 0)])))]
454 "TARGET_THUMB2 && arm_restrict_it"
455 "#" ; "mvn %0, #0 ; it%d1 ; lsl%d1 %0, %0, #1"
456 "&& reload_completed"
459 (cond_exec (match_dup 4)
461 (ashift:SI (match_dup 0)
464 operands[3] = GEN_INT (~0);
465 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[1]),
466 VOIDmode, operands[2], const0_rtx);
468 [(set_attr "conds" "use")
469 (set_attr "length" "8")
470 (set_attr "type" "multiple")]
473 (define_insn_and_split "*thumb2_movsicc_insn"
474 [(set (match_operand:SI 0 "s_register_operand" "=l,l,r,r,r,r,r,r,r,r,r")
476 (match_operator 3 "arm_comparison_operator"
477 [(match_operand 4 "cc_register" "") (const_int 0)])
478 (match_operand:SI 1 "arm_not_operand" "0 ,lPy,0 ,0,rI,K,rI,rI,K ,K,r")
479 (match_operand:SI 2 "arm_not_operand" "lPy,0 ,rI,K,0 ,0,rI,K ,rI,K,r")))]
482 it\\t%D3\;mov%D3\\t%0, %2
483 it\\t%d3\;mov%d3\\t%0, %1
484 it\\t%D3\;mov%D3\\t%0, %2
485 it\\t%D3\;mvn%D3\\t%0, #%B2
486 it\\t%d3\;mov%d3\\t%0, %1
487 it\\t%d3\;mvn%d3\\t%0, #%B1
493 ; alt 6: ite\\t%d3\;mov%d3\\t%0, %1\;mov%D3\\t%0, %2
494 ; alt 7: ite\\t%d3\;mov%d3\\t%0, %1\;mvn%D3\\t%0, #%B2
495 ; alt 8: ite\\t%d3\;mvn%d3\\t%0, #%B1\;mov%D3\\t%0, %2
496 ; alt 9: ite\\t%d3\;mvn%d3\\t%0, #%B1\;mvn%D3\\t%0, #%B2
497 ; alt 10: ite\\t%d3\;mov%d3\\t%0, %1\;mov%D3\\t%0, %2
498 "&& reload_completed"
501 enum rtx_code rev_code;
502 enum machine_mode mode;
505 emit_insn (gen_rtx_COND_EXEC (VOIDmode,
507 gen_rtx_SET (VOIDmode,
510 rev_code = GET_CODE (operands[3]);
511 mode = GET_MODE (operands[4]);
512 if (mode == CCFPmode || mode == CCFPEmode)
513 rev_code = reverse_condition_maybe_unordered (rev_code);
515 rev_code = reverse_condition (rev_code);
517 rev_cond = gen_rtx_fmt_ee (rev_code,
519 gen_rtx_REG (mode, CC_REGNUM),
521 emit_insn (gen_rtx_COND_EXEC (VOIDmode,
523 gen_rtx_SET (VOIDmode,
528 [(set_attr "length" "4,4,6,6,6,6,10,10,10,10,6")
529 (set_attr "enabled_for_depr_it" "yes,yes,no,no,no,no,no,no,no,no,yes")
530 (set_attr "conds" "use")
531 (set_attr "type" "multiple")]
534 (define_insn "*thumb2_movsfcc_soft_insn"
535 [(set (match_operand:SF 0 "s_register_operand" "=r,r")
536 (if_then_else:SF (match_operator 3 "arm_comparison_operator"
537 [(match_operand 4 "cc_register" "") (const_int 0)])
538 (match_operand:SF 1 "s_register_operand" "0,r")
539 (match_operand:SF 2 "s_register_operand" "r,0")))]
540 "TARGET_THUMB2 && TARGET_SOFT_FLOAT"
542 it\\t%D3\;mov%D3\\t%0, %2
543 it\\t%d3\;mov%d3\\t%0, %1"
544 [(set_attr "length" "6,6")
545 (set_attr "conds" "use")
546 (set_attr "type" "multiple")]
549 (define_insn "*call_reg_thumb2"
550 [(call (mem:SI (match_operand:SI 0 "s_register_operand" "r"))
551 (match_operand 1 "" ""))
552 (use (match_operand 2 "" ""))
553 (clobber (reg:SI LR_REGNUM))]
556 [(set_attr "type" "call")]
559 (define_insn "*call_value_reg_thumb2"
560 [(set (match_operand 0 "" "")
561 (call (mem:SI (match_operand:SI 1 "register_operand" "l*r"))
562 (match_operand 2 "" "")))
563 (use (match_operand 3 "" ""))
564 (clobber (reg:SI LR_REGNUM))]
567 [(set_attr "type" "call")]
570 (define_insn "*thumb2_indirect_jump"
572 (match_operand:SI 0 "register_operand" "l*r"))]
575 [(set_attr "conds" "clob")
576 (set_attr "type" "branch")]
578 ;; Don't define thumb2_load_indirect_jump because we can't guarantee label
579 ;; addresses will have the thumb bit set correctly.
582 (define_insn_and_split "*thumb2_and_scc"
583 [(set (match_operand:SI 0 "s_register_operand" "=Ts")
584 (and:SI (match_operator:SI 1 "arm_comparison_operator"
585 [(match_operand 2 "cc_register" "") (const_int 0)])
586 (match_operand:SI 3 "s_register_operand" "r")))]
588 "#" ; "and\\t%0, %3, #1\;it\\t%D1\;mov%D1\\t%0, #0"
589 "&& reload_completed"
591 (and:SI (match_dup 3) (const_int 1)))
592 (cond_exec (match_dup 4) (set (match_dup 0) (const_int 0)))]
594 enum machine_mode mode = GET_MODE (operands[2]);
595 enum rtx_code rc = GET_CODE (operands[1]);
597 if (mode == CCFPmode || mode == CCFPEmode)
598 rc = reverse_condition_maybe_unordered (rc);
600 rc = reverse_condition (rc);
601 operands[4] = gen_rtx_fmt_ee (rc, VOIDmode, operands[2], const0_rtx);
603 [(set_attr "conds" "use")
604 (set_attr "type" "multiple")
605 (set (attr "length") (if_then_else (match_test "arm_restrict_it")
610 (define_insn_and_split "*thumb2_ior_scc"
611 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
612 (ior:SI (match_operator:SI 1 "arm_comparison_operator"
613 [(match_operand 2 "cc_register" "") (const_int 0)])
614 (match_operand:SI 3 "s_register_operand" "0,?r")))]
615 "TARGET_THUMB2 && !arm_restrict_it"
617 it\\t%d1\;orr%d1\\t%0, %3, #1
619 ; alt 1: ite\\t%D1\;mov%D1\\t%0, %3\;orr%d1\\t%0, %3, #1
621 && REGNO (operands [0]) != REGNO (operands[3])"
622 [(cond_exec (match_dup 5) (set (match_dup 0) (match_dup 3)))
623 (cond_exec (match_dup 4) (set (match_dup 0)
624 (ior:SI (match_dup 3) (const_int 1))))]
626 enum machine_mode mode = GET_MODE (operands[2]);
627 enum rtx_code rc = GET_CODE (operands[1]);
629 operands[4] = gen_rtx_fmt_ee (rc, VOIDmode, operands[2], const0_rtx);
630 if (mode == CCFPmode || mode == CCFPEmode)
631 rc = reverse_condition_maybe_unordered (rc);
633 rc = reverse_condition (rc);
634 operands[5] = gen_rtx_fmt_ee (rc, VOIDmode, operands[2], const0_rtx);
636 [(set_attr "conds" "use")
637 (set_attr "length" "6,10")
638 (set_attr "type" "multiple")]
641 (define_insn "*thumb2_ior_scc_strict_it"
642 [(set (match_operand:SI 0 "s_register_operand" "=l,l")
643 (ior:SI (match_operator:SI 2 "arm_comparison_operator"
644 [(match_operand 3 "cc_register" "") (const_int 0)])
645 (match_operand:SI 1 "s_register_operand" "0,?l")))]
646 "TARGET_THUMB2 && arm_restrict_it"
648 it\\t%d2\;mov%d2\\t%0, #1\;it\\t%d2\;orr%d2\\t%0, %1
649 mov\\t%0, #1\;orr\\t%0, %1\;it\\t%D2\;mov%D2\\t%0, %1"
650 [(set_attr "conds" "use")
651 (set_attr "length" "8")
652 (set_attr "type" "multiple")]
655 (define_insn "*thumb2_cond_move"
656 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
657 (if_then_else:SI (match_operator 3 "equality_operator"
658 [(match_operator 4 "arm_comparison_operator"
659 [(match_operand 5 "cc_register" "") (const_int 0)])
661 (match_operand:SI 1 "arm_rhs_operand" "0,rI,?rI")
662 (match_operand:SI 2 "arm_rhs_operand" "rI,0,rI")))]
665 if (GET_CODE (operands[3]) == NE)
667 if (which_alternative != 1)
668 output_asm_insn (\"it\\t%D4\;mov%D4\\t%0, %2\", operands);
669 if (which_alternative != 0)
670 output_asm_insn (\"it\\t%d4\;mov%d4\\t%0, %1\", operands);
673 switch (which_alternative)
676 output_asm_insn (\"it\\t%d4\", operands);
679 output_asm_insn (\"it\\t%D4\", operands);
683 output_asm_insn (\"it\\t%D4\", operands);
685 output_asm_insn (\"ite\\t%D4\", operands);
690 if (which_alternative != 0)
692 output_asm_insn (\"mov%D4\\t%0, %1\", operands);
693 if (arm_restrict_it && which_alternative == 2)
694 output_asm_insn (\"it\\t%d4\", operands);
696 if (which_alternative != 1)
697 output_asm_insn (\"mov%d4\\t%0, %2\", operands);
700 [(set_attr "conds" "use")
701 (set_attr "length" "6,6,10")
702 (set_attr "type" "multiple")]
705 (define_insn "*thumb2_cond_arith"
706 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
707 (match_operator:SI 5 "shiftable_operator"
708 [(match_operator:SI 4 "arm_comparison_operator"
709 [(match_operand:SI 2 "s_register_operand" "r,r")
710 (match_operand:SI 3 "arm_rhs_operand" "rI,rI")])
711 (match_operand:SI 1 "s_register_operand" "0,?r")]))
712 (clobber (reg:CC CC_REGNUM))]
713 "TARGET_THUMB2 && !arm_restrict_it"
715 if (GET_CODE (operands[4]) == LT && operands[3] == const0_rtx)
716 return \"%i5\\t%0, %1, %2, lsr #31\";
718 output_asm_insn (\"cmp\\t%2, %3\", operands);
719 if (GET_CODE (operands[5]) == AND)
721 output_asm_insn (\"ite\\t%D4\", operands);
722 output_asm_insn (\"mov%D4\\t%0, #0\", operands);
724 else if (GET_CODE (operands[5]) == MINUS)
726 output_asm_insn (\"ite\\t%D4\", operands);
727 output_asm_insn (\"rsb%D4\\t%0, %1, #0\", operands);
729 else if (which_alternative != 0)
731 output_asm_insn (\"ite\\t%D4\", operands);
732 output_asm_insn (\"mov%D4\\t%0, %1\", operands);
735 output_asm_insn (\"it\\t%d4\", operands);
736 return \"%i5%d4\\t%0, %1, #1\";
738 [(set_attr "conds" "clob")
739 (set_attr "length" "14")
740 (set_attr "type" "multiple")]
743 (define_insn_and_split "*thumb2_cond_arith_strict_it"
744 [(set (match_operand:SI 0 "s_register_operand" "=l")
745 (match_operator:SI 5 "shiftable_operator_strict_it"
746 [(match_operator:SI 4 "arm_comparison_operator"
747 [(match_operand:SI 2 "s_register_operand" "r")
748 (match_operand:SI 3 "arm_rhs_operand" "rI")])
749 (match_operand:SI 1 "s_register_operand" "0")]))
750 (clobber (reg:CC CC_REGNUM))]
751 "TARGET_THUMB2 && arm_restrict_it"
753 "&& reload_completed"
756 if (GET_CODE (operands[4]) == LT && operands[3] == const0_rtx)
758 /* %i5 %0, %1, %2, lsr #31 */
759 rtx shifted_op = gen_rtx_LSHIFTRT (SImode, operands[2], GEN_INT (31));
762 switch (GET_CODE (operands[5]))
765 op = gen_rtx_AND (SImode, shifted_op, operands[1]);
768 op = gen_rtx_PLUS (SImode, shifted_op, operands[1]);
770 default: gcc_unreachable ();
772 emit_insn (gen_rtx_SET (VOIDmode, operands[0], op));
777 emit_insn (gen_rtx_SET (VOIDmode,
778 gen_rtx_REG (CCmode, CC_REGNUM),
779 gen_rtx_COMPARE (CCmode, operands[2], operands[3])));
781 if (GET_CODE (operands[5]) == AND)
786 enum rtx_code rc = reverse_condition (GET_CODE (operands[4]));
787 emit_insn (gen_rtx_SET (VOIDmode, operands[0], gen_rtx_AND (SImode, operands[1], GEN_INT (1))));
788 emit_insn (gen_rtx_COND_EXEC (VOIDmode,
789 gen_rtx_fmt_ee (rc, VOIDmode, gen_rtx_REG (CCmode, CC_REGNUM), const0_rtx),
790 gen_rtx_SET (VOIDmode, operands[0], const0_rtx)));
796 %i5%d4\\t%0, %1, #1 */
797 emit_insn (gen_rtx_COND_EXEC (VOIDmode, gen_rtx_fmt_ee (GET_CODE (operands[4]),
799 gen_rtx_REG (CCmode, CC_REGNUM), const0_rtx),
800 gen_rtx_SET(VOIDmode, operands[0],
801 gen_rtx_PLUS (SImode,
808 [(set_attr "conds" "clob")
809 (set_attr "length" "12")
810 (set_attr "type" "multiple")]
813 (define_insn "*thumb2_cond_sub"
814 [(set (match_operand:SI 0 "s_register_operand" "=Ts,Ts")
815 (minus:SI (match_operand:SI 1 "s_register_operand" "0,?Ts")
816 (match_operator:SI 4 "arm_comparison_operator"
817 [(match_operand:SI 2 "s_register_operand" "r,r")
818 (match_operand:SI 3 "arm_rhs_operand" "rI,rI")])))
819 (clobber (reg:CC CC_REGNUM))]
822 output_asm_insn (\"cmp\\t%2, %3\", operands);
823 if (which_alternative != 0)
827 output_asm_insn (\"mov\\t%0, %1\", operands);
828 output_asm_insn (\"it\\t%d4\", operands);
832 output_asm_insn (\"ite\\t%D4\", operands);
833 output_asm_insn (\"mov%D4\\t%0, %1\", operands);
837 output_asm_insn (\"it\\t%d4\", operands);
838 return \"sub%d4\\t%0, %1, #1\";
840 [(set_attr "conds" "clob")
841 (set_attr "length" "10,14")
842 (set_attr "type" "multiple")]
845 (define_insn_and_split "*thumb2_negscc"
846 [(set (match_operand:SI 0 "s_register_operand" "=Ts")
847 (neg:SI (match_operator 3 "arm_comparison_operator"
848 [(match_operand:SI 1 "s_register_operand" "r")
849 (match_operand:SI 2 "arm_rhs_operand" "rI")])))
850 (clobber (reg:CC CC_REGNUM))]
853 "&& reload_completed"
856 rtx cc_reg = gen_rtx_REG (CCmode, CC_REGNUM);
858 if (GET_CODE (operands[3]) == LT && operands[2] == const0_rtx)
860 /* Emit asr\\t%0, %1, #31 */
861 emit_insn (gen_rtx_SET (VOIDmode,
863 gen_rtx_ASHIFTRT (SImode,
868 else if (GET_CODE (operands[3]) == NE && !arm_restrict_it)
870 /* Emit subs\\t%0, %1, %2\;it\\tne\;mvnne\\t%0, #0 */
871 if (CONST_INT_P (operands[2]))
872 emit_insn (gen_cmpsi2_addneg (operands[0], operands[1], operands[2],
873 GEN_INT (- INTVAL (operands[2]))));
875 emit_insn (gen_subsi3_compare (operands[0], operands[1], operands[2]));
877 emit_insn (gen_rtx_COND_EXEC (VOIDmode,
888 /* Emit: cmp\\t%1, %2\;mvn\\t%0, #0\;it\\t%D3\;mov%D3\\t%0, #0\;*/
889 enum rtx_code rc = reverse_condition (GET_CODE (operands[3]));
890 enum machine_mode mode = SELECT_CC_MODE (rc, operands[1], operands[2]);
891 rtx tmp1 = gen_rtx_REG (mode, CC_REGNUM);
893 emit_insn (gen_rtx_SET (VOIDmode,
895 gen_rtx_COMPARE (CCmode, operands[1], operands[2])));
897 emit_insn (gen_rtx_SET (VOIDmode, operands[0], GEN_INT (~0)));
899 emit_insn (gen_rtx_COND_EXEC (VOIDmode,
904 gen_rtx_SET (VOIDmode, operands[0], const0_rtx)));
909 [(set_attr "conds" "clob")
910 (set_attr "length" "14")
911 (set_attr "type" "multiple")]
914 (define_insn "*thumb2_movcond"
915 [(set (match_operand:SI 0 "s_register_operand" "=Ts,Ts,Ts")
917 (match_operator 5 "arm_comparison_operator"
918 [(match_operand:SI 3 "s_register_operand" "r,r,r")
919 (match_operand:SI 4 "arm_add_operand" "rIL,rIL,rIL")])
920 (match_operand:SI 1 "arm_rhs_operand" "0,TsI,?TsI")
921 (match_operand:SI 2 "arm_rhs_operand" "TsI,0,TsI")))
922 (clobber (reg:CC CC_REGNUM))]
925 if (GET_CODE (operands[5]) == LT
926 && (operands[4] == const0_rtx))
928 if (which_alternative != 1 && REG_P (operands[1]))
930 if (operands[2] == const0_rtx)
931 return \"and\\t%0, %1, %3, asr #31\";
932 return \"ands\\t%0, %1, %3, asr #32\;it\\tcc\;movcc\\t%0, %2\";
934 else if (which_alternative != 0 && REG_P (operands[2]))
936 if (operands[1] == const0_rtx)
937 return \"bic\\t%0, %2, %3, asr #31\";
938 return \"bics\\t%0, %2, %3, asr #32\;it\\tcs\;movcs\\t%0, %1\";
940 /* The only case that falls through to here is when both ops 1 & 2
944 if (GET_CODE (operands[5]) == GE
945 && (operands[4] == const0_rtx))
947 if (which_alternative != 1 && REG_P (operands[1]))
949 if (operands[2] == const0_rtx)
950 return \"bic\\t%0, %1, %3, asr #31\";
951 return \"bics\\t%0, %1, %3, asr #32\;it\\tcs\;movcs\\t%0, %2\";
953 else if (which_alternative != 0 && REG_P (operands[2]))
955 if (operands[1] == const0_rtx)
956 return \"and\\t%0, %2, %3, asr #31\";
957 return \"ands\\t%0, %2, %3, asr #32\;it\tcc\;movcc\\t%0, %1\";
959 /* The only case that falls through to here is when both ops 1 & 2
962 if (CONST_INT_P (operands[4])
963 && !const_ok_for_arm (INTVAL (operands[4])))
964 output_asm_insn (\"cmn\\t%3, #%n4\", operands);
966 output_asm_insn (\"cmp\\t%3, %4\", operands);
967 switch (which_alternative)
970 output_asm_insn (\"it\\t%D5\", operands);
973 output_asm_insn (\"it\\t%d5\", operands);
978 output_asm_insn (\"mov\\t%0, %1\", operands);
979 output_asm_insn (\"it\\t%D5\", operands);
982 output_asm_insn (\"ite\\t%d5\", operands);
987 if (which_alternative != 0 && !(arm_restrict_it && which_alternative == 2))
988 output_asm_insn (\"mov%d5\\t%0, %1\", operands);
989 if (which_alternative != 1)
990 output_asm_insn (\"mov%D5\\t%0, %2\", operands);
993 [(set_attr "conds" "clob")
994 (set_attr "length" "10,10,14")
995 (set_attr "type" "multiple")]
998 ;; Zero and sign extension instructions.
1000 ;; All supported Thumb2 implementations are armv6, so only that case is
1002 (define_insn "*thumb2_extendqisi_v6"
1003 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
1004 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
1005 "TARGET_THUMB2 && arm_arch6"
1009 [(set_attr "type" "extend,load_byte")
1010 (set_attr "predicable" "yes")
1011 (set_attr "predicable_short_it" "no")
1012 (set_attr "pool_range" "*,4094")
1013 (set_attr "neg_pool_range" "*,250")]
1016 (define_insn "*thumb2_zero_extendhisi2_v6"
1017 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
1018 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
1019 "TARGET_THUMB2 && arm_arch6"
1023 [(set_attr "type" "extend,load_byte")
1024 (set_attr "predicable" "yes")
1025 (set_attr "predicable_short_it" "no")
1026 (set_attr "pool_range" "*,4094")
1027 (set_attr "neg_pool_range" "*,250")]
1030 (define_insn "thumb2_zero_extendqisi2_v6"
1031 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
1032 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
1033 "TARGET_THUMB2 && arm_arch6"
1036 ldr%(b%)\\t%0, %1\\t%@ zero_extendqisi2"
1037 [(set_attr "type" "extend,load_byte")
1038 (set_attr "predicable" "yes")
1039 (set_attr "predicable_short_it" "no")
1040 (set_attr "pool_range" "*,4094")
1041 (set_attr "neg_pool_range" "*,250")]
1044 (define_insn "thumb2_casesi_internal"
1045 [(parallel [(set (pc)
1047 (leu (match_operand:SI 0 "s_register_operand" "r")
1048 (match_operand:SI 1 "arm_rhs_operand" "rI"))
1049 (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
1050 (label_ref (match_operand 2 "" ""))))
1051 (label_ref (match_operand 3 "" ""))))
1052 (clobber (reg:CC CC_REGNUM))
1053 (clobber (match_scratch:SI 4 "=&r"))
1054 (use (label_ref (match_dup 2)))])]
1055 "TARGET_THUMB2 && !flag_pic"
1056 "* return thumb2_output_casesi(operands);"
1057 [(set_attr "conds" "clob")
1058 (set_attr "length" "16")
1059 (set_attr "type" "multiple")]
1062 (define_insn "thumb2_casesi_internal_pic"
1063 [(parallel [(set (pc)
1065 (leu (match_operand:SI 0 "s_register_operand" "r")
1066 (match_operand:SI 1 "arm_rhs_operand" "rI"))
1067 (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
1068 (label_ref (match_operand 2 "" ""))))
1069 (label_ref (match_operand 3 "" ""))))
1070 (clobber (reg:CC CC_REGNUM))
1071 (clobber (match_scratch:SI 4 "=&r"))
1072 (clobber (match_scratch:SI 5 "=r"))
1073 (use (label_ref (match_dup 2)))])]
1074 "TARGET_THUMB2 && flag_pic"
1075 "* return thumb2_output_casesi(operands);"
1076 [(set_attr "conds" "clob")
1077 (set_attr "length" "20")
1078 (set_attr "type" "multiple")]
1081 (define_insn "*thumb2_return"
1084 "* return output_return_instruction (const_true_rtx, true, false, true);"
1085 [(set_attr "type" "branch")
1086 (set_attr "length" "4")]
1089 (define_insn_and_split "thumb2_eh_return"
1090 [(unspec_volatile [(match_operand:SI 0 "s_register_operand" "r")]
1092 (clobber (match_scratch:SI 1 "=&r"))]
1095 "&& reload_completed"
1099 thumb_set_return_address (operands[0], operands[1]);
1104 (define_insn "*thumb2_alusi3_short"
1105 [(set (match_operand:SI 0 "s_register_operand" "=l")
1106 (match_operator:SI 3 "thumb_16bit_operator"
1107 [(match_operand:SI 1 "s_register_operand" "0")
1108 (match_operand:SI 2 "s_register_operand" "l")]))
1109 (clobber (reg:CC CC_REGNUM))]
1110 "TARGET_THUMB2 && reload_completed
1111 && GET_CODE(operands[3]) != PLUS
1112 && GET_CODE(operands[3]) != MINUS"
1113 "%I3%!\\t%0, %1, %2"
1114 [(set_attr "predicable" "yes")
1115 (set_attr "length" "2")
1116 (set_attr "type" "alu_reg")]
1119 (define_insn "*thumb2_shiftsi3_short"
1120 [(set (match_operand:SI 0 "low_register_operand" "=l,l")
1121 (match_operator:SI 3 "shift_operator"
1122 [(match_operand:SI 1 "low_register_operand" "0,l")
1123 (match_operand:SI 2 "low_reg_or_int_operand" "l,M")]))
1124 (clobber (reg:CC CC_REGNUM))]
1125 "TARGET_THUMB2 && reload_completed
1126 && ((GET_CODE(operands[3]) != ROTATE && GET_CODE(operands[3]) != ROTATERT)
1127 || REG_P (operands[2]))"
1128 "* return arm_output_shift(operands, 2);"
1129 [(set_attr "predicable" "yes")
1130 (set_attr "shift" "1")
1131 (set_attr "length" "2")
1132 (set (attr "type") (if_then_else (match_operand 2 "const_int_operand" "")
1133 (const_string "alu_shift_imm")
1134 (const_string "alu_shift_reg")))]
1137 (define_insn "*thumb2_mov<mode>_shortim"
1138 [(set (match_operand:QHSI 0 "low_register_operand" "=l")
1139 (match_operand:QHSI 1 "const_int_operand" "I"))
1140 (clobber (reg:CC CC_REGNUM))]
1141 "TARGET_THUMB2 && reload_completed"
1143 [(set_attr "predicable" "yes")
1144 (set_attr "length" "2")
1145 (set_attr "type" "mov_imm")]
1148 (define_insn "*thumb2_addsi_short"
1149 [(set (match_operand:SI 0 "low_register_operand" "=l,l")
1150 (plus:SI (match_operand:SI 1 "low_register_operand" "l,0")
1151 (match_operand:SI 2 "low_reg_or_int_operand" "lPt,Ps")))
1152 (clobber (reg:CC CC_REGNUM))]
1153 "TARGET_THUMB2 && reload_completed"
1157 if (CONST_INT_P (operands[2]))
1158 val = INTVAL(operands[2]);
1162 /* We prefer eg. subs rn, rn, #1 over adds rn, rn, #0xffffffff. */
1163 if (val < 0 && const_ok_for_arm(ARM_SIGN_EXTEND (-val)))
1164 return \"sub%!\\t%0, %1, #%n2\";
1166 return \"add%!\\t%0, %1, %2\";
1168 [(set_attr "predicable" "yes")
1169 (set_attr "length" "2")
1170 (set_attr "type" "alu_reg")]
1173 (define_insn "*thumb2_subsi_short"
1174 [(set (match_operand:SI 0 "low_register_operand" "=l")
1175 (minus:SI (match_operand:SI 1 "low_register_operand" "l")
1176 (match_operand:SI 2 "low_register_operand" "l")))
1177 (clobber (reg:CC CC_REGNUM))]
1178 "TARGET_THUMB2 && reload_completed"
1179 "sub%!\\t%0, %1, %2"
1180 [(set_attr "predicable" "yes")
1181 (set_attr "length" "2")
1182 (set_attr "type" "alu_reg")]
1186 [(set (match_operand:CC 0 "cc_register" "")
1187 (compare:CC (match_operand:SI 1 "low_register_operand" "")
1188 (match_operand:SI 2 "const_int_operand" "")))]
1190 && peep2_reg_dead_p (1, operands[1])
1191 && satisfies_constraint_Pw (operands[2])"
1193 [(set (match_dup 0) (compare:CC (match_dup 1) (match_dup 2)))
1194 (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 3)))])]
1195 "operands[3] = GEN_INT (- INTVAL (operands[2]));"
1199 [(match_scratch:SI 3 "l")
1200 (set (match_operand:CC 0 "cc_register" "")
1201 (compare:CC (match_operand:SI 1 "low_register_operand" "")
1202 (match_operand:SI 2 "const_int_operand" "")))]
1204 && satisfies_constraint_Px (operands[2])"
1206 [(set (match_dup 0) (compare:CC (match_dup 1) (match_dup 2)))
1207 (set (match_dup 3) (plus:SI (match_dup 1) (match_dup 4)))])]
1208 "operands[4] = GEN_INT (- INTVAL (operands[2]));"
1211 (define_insn "thumb2_addsi3_compare0"
1212 [(set (reg:CC_NOOV CC_REGNUM)
1214 (plus:SI (match_operand:SI 1 "s_register_operand" "l, 0, r")
1215 (match_operand:SI 2 "arm_add_operand" "lPt,Ps,rIL"))
1217 (set (match_operand:SI 0 "s_register_operand" "=l,l,r")
1218 (plus:SI (match_dup 1) (match_dup 2)))]
1223 if (CONST_INT_P (operands[2]))
1224 val = INTVAL (operands[2]);
1228 if (val < 0 && const_ok_for_arm (ARM_SIGN_EXTEND (-val)))
1229 return \"subs\\t%0, %1, #%n2\";
1231 return \"adds\\t%0, %1, %2\";
1233 [(set_attr "conds" "set")
1234 (set_attr "length" "2,2,4")
1235 (set_attr "type" "alu_reg")]
1238 (define_insn "*thumb2_addsi3_compare0_scratch"
1239 [(set (reg:CC_NOOV CC_REGNUM)
1241 (plus:SI (match_operand:SI 0 "s_register_operand" "l,l, r,r")
1242 (match_operand:SI 1 "arm_add_operand" "Pv,l,IL,r"))
1248 if (CONST_INT_P (operands[1]))
1249 val = INTVAL (operands[1]);
1253 if (val < 0 && const_ok_for_arm (ARM_SIGN_EXTEND (-val)))
1254 return \"cmp\\t%0, #%n1\";
1256 return \"cmn\\t%0, %1\";
1258 [(set_attr "conds" "set")
1259 (set_attr "length" "2,2,4,4")
1260 (set_attr "type" "alus_imm,alus_reg,alus_imm,alus_reg")]
1263 (define_insn "*thumb2_mulsi_short"
1264 [(set (match_operand:SI 0 "low_register_operand" "=l")
1265 (mult:SI (match_operand:SI 1 "low_register_operand" "%0")
1266 (match_operand:SI 2 "low_register_operand" "l")))
1267 (clobber (reg:CC CC_REGNUM))]
1268 "TARGET_THUMB2 && optimize_size && reload_completed"
1269 "mul%!\\t%0, %2, %0"
1270 [(set_attr "predicable" "yes")
1271 (set_attr "length" "2")
1272 (set_attr "type" "muls")])
1274 (define_insn "*thumb2_mulsi_short_compare0"
1275 [(set (reg:CC_NOOV CC_REGNUM)
1277 (mult:SI (match_operand:SI 1 "register_operand" "%0")
1278 (match_operand:SI 2 "register_operand" "l"))
1280 (set (match_operand:SI 0 "register_operand" "=l")
1281 (mult:SI (match_dup 1) (match_dup 2)))]
1282 "TARGET_THUMB2 && optimize_size"
1284 [(set_attr "length" "2")
1285 (set_attr "type" "muls")])
1287 (define_insn "*thumb2_mulsi_short_compare0_scratch"
1288 [(set (reg:CC_NOOV CC_REGNUM)
1290 (mult:SI (match_operand:SI 1 "register_operand" "%0")
1291 (match_operand:SI 2 "register_operand" "l"))
1293 (clobber (match_scratch:SI 0 "=l"))]
1294 "TARGET_THUMB2 && optimize_size"
1296 [(set_attr "length" "2")
1297 (set_attr "type" "muls")])
1299 (define_insn "*thumb2_cbz"
1300 [(set (pc) (if_then_else
1301 (eq (match_operand:SI 0 "s_register_operand" "l,?r")
1303 (label_ref (match_operand 1 "" ""))
1305 (clobber (reg:CC CC_REGNUM))]
1308 if (get_attr_length (insn) == 2)
1309 return \"cbz\\t%0, %l1\";
1311 return \"cmp\\t%0, #0\;beq\\t%l1\";
1313 [(set (attr "length")
1315 (and (ge (minus (match_dup 1) (pc)) (const_int 2))
1316 (le (minus (match_dup 1) (pc)) (const_int 128))
1317 (not (match_test "which_alternative")))
1320 (set_attr "type" "branch,multiple")]
1323 (define_insn "*thumb2_cbnz"
1324 [(set (pc) (if_then_else
1325 (ne (match_operand:SI 0 "s_register_operand" "l,?r")
1327 (label_ref (match_operand 1 "" ""))
1329 (clobber (reg:CC CC_REGNUM))]
1332 if (get_attr_length (insn) == 2)
1333 return \"cbnz\\t%0, %l1\";
1335 return \"cmp\\t%0, #0\;bne\\t%l1\";
1337 [(set (attr "length")
1339 (and (ge (minus (match_dup 1) (pc)) (const_int 2))
1340 (le (minus (match_dup 1) (pc)) (const_int 128))
1341 (not (match_test "which_alternative")))
1344 (set_attr "type" "branch,multiple")]
1347 (define_insn "*thumb2_one_cmplsi2_short"
1348 [(set (match_operand:SI 0 "low_register_operand" "=l")
1349 (not:SI (match_operand:SI 1 "low_register_operand" "l")))
1350 (clobber (reg:CC CC_REGNUM))]
1351 "TARGET_THUMB2 && reload_completed"
1353 [(set_attr "predicable" "yes")
1354 (set_attr "length" "2")
1355 (set_attr "type" "mvn_reg")]
1358 (define_insn "*thumb2_negsi2_short"
1359 [(set (match_operand:SI 0 "low_register_operand" "=l")
1360 (neg:SI (match_operand:SI 1 "low_register_operand" "l")))
1361 (clobber (reg:CC CC_REGNUM))]
1362 "TARGET_THUMB2 && reload_completed"
1364 [(set_attr "predicable" "yes")
1365 (set_attr "length" "2")
1366 (set_attr "type" "alu_reg")]
1369 (define_insn "*orsi_notsi_si"
1370 [(set (match_operand:SI 0 "s_register_operand" "=r")
1371 (ior:SI (not:SI (match_operand:SI 2 "s_register_operand" "r"))
1372 (match_operand:SI 1 "s_register_operand" "r")))]
1374 "orn%?\\t%0, %1, %2"
1375 [(set_attr "predicable" "yes")
1376 (set_attr "predicable_short_it" "no")
1377 (set_attr "type" "logic_reg")]
1380 (define_insn "*orsi_not_shiftsi_si"
1381 [(set (match_operand:SI 0 "s_register_operand" "=r")
1382 (ior:SI (not:SI (match_operator:SI 4 "shift_operator"
1383 [(match_operand:SI 2 "s_register_operand" "r")
1384 (match_operand:SI 3 "const_int_operand" "M")]))
1385 (match_operand:SI 1 "s_register_operand" "r")))]
1387 "orn%?\\t%0, %1, %2%S4"
1388 [(set_attr "predicable" "yes")
1389 (set_attr "predicable_short_it" "no")
1390 (set_attr "shift" "2")
1391 (set_attr "type" "alu_shift_imm")]
1395 [(set (match_operand:CC_NOOV 0 "cc_register" "")
1396 (compare:CC_NOOV (zero_extract:SI
1397 (match_operand:SI 1 "low_register_operand" "")
1399 (match_operand:SI 2 "const_int_operand" ""))
1401 (match_scratch:SI 3 "l")
1403 (if_then_else (match_operator:CC_NOOV 4 "equality_operator"
1404 [(match_dup 0) (const_int 0)])
1405 (match_operand 5 "" "")
1406 (match_operand 6 "" "")))]
1408 && (INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) < 32)"
1409 [(parallel [(set (match_dup 0)
1410 (compare:CC_NOOV (ashift:SI (match_dup 1) (match_dup 2))
1412 (clobber (match_dup 3))])
1414 (if_then_else (match_op_dup 4 [(match_dup 0) (const_int 0)])
1415 (match_dup 5) (match_dup 6)))]
1417 operands[2] = GEN_INT (31 - INTVAL (operands[2]));
1418 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[4]) == NE ? LT : GE,
1419 VOIDmode, operands[0], const0_rtx);
1423 [(set (match_operand:CC_NOOV 0 "cc_register" "")
1424 (compare:CC_NOOV (zero_extract:SI
1425 (match_operand:SI 1 "low_register_operand" "")
1426 (match_operand:SI 2 "const_int_operand" "")
1429 (match_scratch:SI 3 "l")
1431 (if_then_else (match_operator:CC_NOOV 4 "equality_operator"
1432 [(match_dup 0) (const_int 0)])
1433 (match_operand 5 "" "")
1434 (match_operand 6 "" "")))]
1436 && (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 32)"
1437 [(parallel [(set (match_dup 0)
1438 (compare:CC_NOOV (ashift:SI (match_dup 1) (match_dup 2))
1440 (clobber (match_dup 3))])
1442 (if_then_else (match_op_dup 4 [(match_dup 0) (const_int 0)])
1443 (match_dup 5) (match_dup 6)))]
1445 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
1448 ;; Define the subtract-one-and-jump insns so loop.c
1449 ;; knows what to generate.
1450 (define_expand "doloop_end"
1451 [(use (match_operand 0 "" "")) ; loop pseudo
1452 (use (match_operand 1 "" ""))] ; label
1456 /* Currently SMS relies on the do-loop pattern to recognize loops
1457 where (1) the control part consists of all insns defining and/or
1458 using a certain 'count' register and (2) the loop count can be
1459 adjusted by modifying this register prior to the loop.
1460 ??? The possible introduction of a new block to initialize the
1461 new IV can potentially affect branch optimizations. */
1462 if (optimize > 0 && flag_modulo_sched)
1471 if (GET_MODE (operands[0]) != SImode)
1476 insn = emit_insn (gen_thumb2_addsi3_compare0 (s0, s0, GEN_INT (-1)));
1478 insn = emit_insn (gen_addsi3_compare0 (s0, s0, GEN_INT (-1)));
1480 cmp = XVECEXP (PATTERN (insn), 0, 0);
1481 cc_reg = SET_DEST (cmp);
1482 bcomp = gen_rtx_NE (VOIDmode, cc_reg, const0_rtx);
1483 loc_ref = gen_rtx_LABEL_REF (VOIDmode, operands [1]);
1484 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
1485 gen_rtx_IF_THEN_ELSE (VOIDmode, bcomp,