1 ;;- Machine description for ARM for GNU compiler
2 ;; Copyright (C) 1991-2019 Free Software Foundation, Inc.
3 ;; Contributed by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl)
4 ;; and Martin Simmons (@harleqn.co.uk).
5 ;; More major hacks by Richard Earnshaw (rearnsha@arm.com).
7 ;; This file is part of GCC.
9 ;; GCC is free software; you can redistribute it and/or modify it
10 ;; under the terms of the GNU General Public License as published
11 ;; by the Free Software Foundation; either version 3, or (at your
12 ;; option) any later version.
14 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
15 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 ;; License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING3. If not see
21 ;; <http://www.gnu.org/licenses/>.
23 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
26 ;;---------------------------------------------------------------------------
29 ;; Register numbers -- All machine registers should be defined here
31 [(R0_REGNUM 0) ; First CORE register
32 (R1_REGNUM 1) ; Second CORE register
33 (R4_REGNUM 4) ; Fifth CORE register
34 (IP_REGNUM 12) ; Scratch register
35 (SP_REGNUM 13) ; Stack pointer
36 (LR_REGNUM 14) ; Return address register
37 (PC_REGNUM 15) ; Program counter
38 (LAST_ARM_REGNUM 15) ;
39 (CC_REGNUM 100) ; Condition code pseudo register
40 (VFPCC_REGNUM 101) ; VFP Condition code pseudo register
43 ;; 3rd operand to select_dominance_cc_mode
50 ;; conditional compare combination
61 ;;---------------------------------------------------------------------------
64 ;; Processor type. This is created automatically from arm-cores.def.
65 (include "arm-tune.md")
67 ;; Instruction classification types
70 ; IS_THUMB is set to 'yes' when we are generating Thumb code, and 'no' when
71 ; generating ARM code. This is used to control the length of some insn
72 ; patterns that share the same RTL in both ARM and Thumb code.
73 (define_attr "is_thumb" "yes,no"
74 (const (if_then_else (symbol_ref "TARGET_THUMB")
75 (const_string "yes") (const_string "no"))))
77 ; IS_ARCH6 is set to 'yes' when we are generating code form ARMv6.
78 (define_attr "is_arch6" "no,yes" (const (symbol_ref "arm_arch6")))
80 ; IS_THUMB1 is set to 'yes' iff we are generating Thumb-1 code.
81 (define_attr "is_thumb1" "yes,no"
82 (const (if_then_else (symbol_ref "TARGET_THUMB1")
83 (const_string "yes") (const_string "no"))))
85 ; Mark an instruction as suitable for "short IT" blocks in Thumb-2.
86 ; The arm_restrict_it flag enables the "short IT" feature which
87 ; restricts IT blocks to a single 16-bit instruction.
88 ; This attribute should only be used on 16-bit Thumb-2 instructions
89 ; which may be predicated (the "predicable" attribute must be set).
90 (define_attr "predicable_short_it" "no,yes" (const_string "no"))
92 ; Mark an instruction as suitable for "short IT" blocks in Thumb-2.
93 ; This attribute should only be used on instructions which may emit
94 ; an IT block in their expansion which is not a short IT.
95 (define_attr "enabled_for_short_it" "no,yes" (const_string "yes"))
97 ;; Operand number of an input operand that is shifted. Zero if the
98 ;; given instruction does not shift one of its input operands.
99 (define_attr "shift" "" (const_int 0))
101 ;; [For compatibility with AArch64 in pipeline models]
102 ;; Attribute that specifies whether or not the instruction touches fp
104 (define_attr "fp" "no,yes" (const_string "no"))
106 ; Floating Point Unit. If we only have floating point emulation, then there
107 ; is no point in scheduling the floating point insns. (Well, for best
108 ; performance we should try and group them together).
109 (define_attr "fpu" "none,vfp"
110 (const (symbol_ref "arm_fpu_attr")))
112 ; Predicated means that the insn form is conditionally executed based on a
113 ; predicate. We default to 'no' because no Thumb patterns match this rule
114 ; and not all ARM insns do.
115 (define_attr "predicated" "yes,no" (const_string "no"))
117 ; LENGTH of an instruction (in bytes)
118 (define_attr "length" ""
121 ; The architecture which supports the instruction (or alternative).
122 ; This can be "a" for ARM, "t" for either of the Thumbs, "32" for
123 ; TARGET_32BIT, "t1" or "t2" to specify a specific Thumb mode. "v6"
124 ; for ARM or Thumb-2 with arm_arch6, and nov6 for ARM without
125 ; arm_arch6. "v6t2" for Thumb-2 with arm_arch6 and "v8mb" for ARMv8-M
126 ; Baseline. This attribute is used to compute attribute "enabled",
127 ; use type "any" to enable an alternative in all cases.
128 (define_attr "arch" "any,a,t,32,t1,t2,v6,nov6,v6t2,v8mb,neon_for_64bits,avoid_neon_for_64bits,iwmmxt,iwmmxt2,armv6_or_vfpv3,neon"
129 (const_string "any"))
131 (define_attr "arch_enabled" "no,yes"
132 (cond [(eq_attr "arch" "any")
135 (and (eq_attr "arch" "a")
136 (match_test "TARGET_ARM"))
139 (and (eq_attr "arch" "t")
140 (match_test "TARGET_THUMB"))
143 (and (eq_attr "arch" "t1")
144 (match_test "TARGET_THUMB1"))
147 (and (eq_attr "arch" "t2")
148 (match_test "TARGET_THUMB2"))
151 (and (eq_attr "arch" "32")
152 (match_test "TARGET_32BIT"))
155 (and (eq_attr "arch" "v6")
156 (match_test "TARGET_32BIT && arm_arch6"))
159 (and (eq_attr "arch" "nov6")
160 (match_test "TARGET_32BIT && !arm_arch6"))
163 (and (eq_attr "arch" "v6t2")
164 (match_test "TARGET_32BIT && arm_arch6 && arm_arch_thumb2"))
167 (and (eq_attr "arch" "v8mb")
168 (match_test "TARGET_THUMB1 && arm_arch8"))
171 (and (eq_attr "arch" "avoid_neon_for_64bits")
172 (match_test "TARGET_NEON")
173 (not (match_test "TARGET_PREFER_NEON_64BITS")))
176 (and (eq_attr "arch" "neon_for_64bits")
177 (match_test "TARGET_NEON")
178 (match_test "TARGET_PREFER_NEON_64BITS"))
181 (and (eq_attr "arch" "iwmmxt2")
182 (match_test "TARGET_REALLY_IWMMXT2"))
185 (and (eq_attr "arch" "armv6_or_vfpv3")
186 (match_test "arm_arch6 || TARGET_VFP3"))
189 (and (eq_attr "arch" "neon")
190 (match_test "TARGET_NEON"))
194 (const_string "no")))
196 (define_attr "opt" "any,speed,size"
197 (const_string "any"))
199 (define_attr "opt_enabled" "no,yes"
200 (cond [(eq_attr "opt" "any")
203 (and (eq_attr "opt" "speed")
204 (match_test "optimize_function_for_speed_p (cfun)"))
207 (and (eq_attr "opt" "size")
208 (match_test "optimize_function_for_size_p (cfun)"))
209 (const_string "yes")]
210 (const_string "no")))
212 (define_attr "use_literal_pool" "no,yes"
213 (cond [(and (eq_attr "type" "f_loads,f_loadd")
214 (match_test "CONSTANT_P (operands[1])"))
215 (const_string "yes")]
216 (const_string "no")))
218 ; Enable all alternatives that are both arch_enabled and insn_enabled.
219 ; FIXME:: opt_enabled has been temporarily removed till the time we have
220 ; an attribute that allows the use of such alternatives.
221 ; This depends on caching of speed_p, size_p on a per
222 ; alternative basis. The problem is that the enabled attribute
223 ; cannot depend on any state that is not cached or is not constant
224 ; for a compilation unit. We probably need a generic "hot/cold"
225 ; alternative which if implemented can help with this. We disable this
226 ; until such a time as this is implemented and / or the improvements or
227 ; regressions with removing this attribute are double checked.
228 ; See ashldi3_neon and <shift>di3_neon in neon.md.
230 (define_attr "enabled" "no,yes"
231 (cond [(and (eq_attr "predicable_short_it" "no")
232 (and (eq_attr "predicated" "yes")
233 (match_test "arm_restrict_it")))
236 (and (eq_attr "enabled_for_short_it" "no")
237 (match_test "arm_restrict_it"))
240 (eq_attr "arch_enabled" "no")
242 (const_string "yes")))
244 ; POOL_RANGE is how far away from a constant pool entry that this insn
245 ; can be placed. If the distance is zero, then this insn will never
246 ; reference the pool.
247 ; Note that for Thumb constant pools the PC value is rounded down to the
248 ; nearest multiple of four. Therefore, THUMB2_POOL_RANGE (and POOL_RANGE for
249 ; Thumb insns) should be set to <max_range> - 2.
250 ; NEG_POOL_RANGE is nonzero for insns that can reference a constant pool entry
251 ; before its address. It is set to <max_range> - (8 + <data_size>).
252 (define_attr "arm_pool_range" "" (const_int 0))
253 (define_attr "thumb2_pool_range" "" (const_int 0))
254 (define_attr "arm_neg_pool_range" "" (const_int 0))
255 (define_attr "thumb2_neg_pool_range" "" (const_int 0))
257 (define_attr "pool_range" ""
258 (cond [(eq_attr "is_thumb" "yes") (attr "thumb2_pool_range")]
259 (attr "arm_pool_range")))
260 (define_attr "neg_pool_range" ""
261 (cond [(eq_attr "is_thumb" "yes") (attr "thumb2_neg_pool_range")]
262 (attr "arm_neg_pool_range")))
264 ; An assembler sequence may clobber the condition codes without us knowing.
265 ; If such an insn references the pool, then we have no way of knowing how,
266 ; so use the most conservative value for pool_range.
267 (define_asm_attributes
268 [(set_attr "conds" "clob")
269 (set_attr "length" "4")
270 (set_attr "pool_range" "250")])
272 ; Load scheduling, set from the arm_ld_sched variable
273 ; initialized by arm_option_override()
274 (define_attr "ldsched" "no,yes" (const (symbol_ref "arm_ld_sched")))
276 ; condition codes: this one is used by final_prescan_insn to speed up
277 ; conditionalizing instructions. It saves having to scan the rtl to see if
278 ; it uses or alters the condition codes.
280 ; USE means that the condition codes are used by the insn in the process of
281 ; outputting code, this means (at present) that we can't use the insn in
284 ; SET means that the purpose of the insn is to set the condition codes in a
285 ; well defined manner.
287 ; CLOB means that the condition codes are altered in an undefined manner, if
288 ; they are altered at all
290 ; UNCONDITIONAL means the instruction cannot be conditionally executed and
291 ; that the instruction does not use or alter the condition codes.
293 ; NOCOND means that the instruction does not use or alter the condition
294 ; codes but can be converted into a conditionally exectuted instruction.
296 (define_attr "conds" "use,set,clob,unconditional,nocond"
298 (ior (eq_attr "is_thumb1" "yes")
299 (eq_attr "type" "call"))
300 (const_string "clob")
301 (if_then_else (eq_attr "is_neon_type" "no")
302 (const_string "nocond")
303 (const_string "unconditional"))))
305 ; Predicable means that the insn can be conditionally executed based on
306 ; an automatically added predicate (additional patterns are generated by
307 ; gen...). We default to 'no' because no Thumb patterns match this rule
308 ; and not all ARM patterns do.
309 (define_attr "predicable" "no,yes" (const_string "no"))
311 ; Only model the write buffer for ARM6 and ARM7. Earlier processors don't
312 ; have one. Later ones, such as StrongARM, have write-back caches, so don't
313 ; suffer blockages enough to warrant modelling this (and it can adversely
314 ; affect the schedule).
315 (define_attr "model_wbuf" "no,yes" (const (symbol_ref "arm_tune_wbuf")))
317 ; WRITE_CONFLICT implies that a read following an unrelated write is likely
318 ; to stall the processor. Used with model_wbuf above.
319 (define_attr "write_conflict" "no,yes"
320 (if_then_else (eq_attr "type"
323 (const_string "no")))
325 ; Classify the insns into those that take one cycle and those that take more
326 ; than one on the main cpu execution unit.
327 (define_attr "core_cycles" "single,multi"
328 (if_then_else (eq_attr "type"
329 "adc_imm, adc_reg, adcs_imm, adcs_reg, adr, alu_ext, alu_imm, alu_sreg,\
330 alu_shift_imm, alu_shift_reg, alu_dsp_reg, alus_ext, alus_imm, alus_sreg,\
331 alus_shift_imm, alus_shift_reg, bfm, csel, rev, logic_imm, logic_reg,\
332 logic_shift_imm, logic_shift_reg, logics_imm, logics_reg,\
333 logics_shift_imm, logics_shift_reg, extend, shift_imm, float, fcsel,\
334 wmmx_wor, wmmx_wxor, wmmx_wand, wmmx_wandn, wmmx_wmov, wmmx_tmcrr,\
335 wmmx_tmrrc, wmmx_wldr, wmmx_wstr, wmmx_tmcr, wmmx_tmrc, wmmx_wadd,\
336 wmmx_wsub, wmmx_wmul, wmmx_wmac, wmmx_wavg2, wmmx_tinsr, wmmx_textrm,\
337 wmmx_wshufh, wmmx_wcmpeq, wmmx_wcmpgt, wmmx_wmax, wmmx_wmin, wmmx_wpack,\
338 wmmx_wunpckih, wmmx_wunpckil, wmmx_wunpckeh, wmmx_wunpckel, wmmx_wror,\
339 wmmx_wsra, wmmx_wsrl, wmmx_wsll, wmmx_wmadd, wmmx_tmia, wmmx_tmiaph,\
340 wmmx_tmiaxy, wmmx_tbcst, wmmx_tmovmsk, wmmx_wacc, wmmx_waligni,\
341 wmmx_walignr, wmmx_tandc, wmmx_textrc, wmmx_torc, wmmx_torvsc, wmmx_wsad,\
342 wmmx_wabs, wmmx_wabsdiff, wmmx_waddsubhx, wmmx_wsubaddhx, wmmx_wavg4,\
343 wmmx_wmulw, wmmx_wqmulm, wmmx_wqmulwm, wmmx_waddbhus, wmmx_wqmiaxy,\
344 wmmx_wmiaxy, wmmx_wmiawxy, wmmx_wmerge")
345 (const_string "single")
346 (const_string "multi")))
348 ;; FAR_JUMP is "yes" if a BL instruction is used to generate a branch to a
349 ;; distant label. Only applicable to Thumb code.
350 (define_attr "far_jump" "yes,no" (const_string "no"))
353 ;; The number of machine instructions this pattern expands to.
354 ;; Used for Thumb-2 conditional execution.
355 (define_attr "ce_count" "" (const_int 1))
357 ;;---------------------------------------------------------------------------
360 (include "unspecs.md")
362 ;;---------------------------------------------------------------------------
365 (include "iterators.md")
367 ;;---------------------------------------------------------------------------
370 (include "predicates.md")
371 (include "constraints.md")
373 ;;---------------------------------------------------------------------------
374 ;; Pipeline descriptions
376 (define_attr "tune_cortexr4" "yes,no"
378 (eq_attr "tune" "cortexr4,cortexr4f,cortexr5")
380 (const_string "no"))))
382 ;; True if the generic scheduling description should be used.
384 (define_attr "generic_sched" "yes,no"
386 (ior (eq_attr "tune" "fa526,fa626,fa606te,fa626te,fmp626,fa726te,\
387 arm926ejs,arm10e,arm1026ejs,arm1136js,\
388 arm1136jfs,cortexa5,cortexa7,cortexa8,\
389 cortexa9,cortexa12,cortexa15,cortexa17,\
390 cortexa53,cortexa57,cortexm4,cortexm7,\
391 exynosm1,marvell_pj4,xgene1")
392 (eq_attr "tune_cortexr4" "yes"))
394 (const_string "yes"))))
396 (define_attr "generic_vfp" "yes,no"
398 (and (eq_attr "fpu" "vfp")
399 (eq_attr "tune" "!arm10e,cortexa5,cortexa7,\
400 cortexa8,cortexa9,cortexa53,cortexm4,\
401 cortexm7,marvell_pj4,xgene1")
402 (eq_attr "tune_cortexr4" "no"))
404 (const_string "no"))))
406 (include "marvell-f-iwmmxt.md")
407 (include "arm-generic.md")
408 (include "arm926ejs.md")
409 (include "arm1020e.md")
410 (include "arm1026ejs.md")
411 (include "arm1136jfs.md")
413 (include "fa606te.md")
414 (include "fa626te.md")
415 (include "fmp626.md")
416 (include "fa726te.md")
417 (include "cortex-a5.md")
418 (include "cortex-a7.md")
419 (include "cortex-a8.md")
420 (include "cortex-a9.md")
421 (include "cortex-a15.md")
422 (include "cortex-a17.md")
423 (include "cortex-a53.md")
424 (include "cortex-a57.md")
425 (include "cortex-r4.md")
426 (include "cortex-r4f.md")
427 (include "cortex-m7.md")
428 (include "cortex-m4.md")
429 (include "cortex-m4-fpu.md")
430 (include "exynos-m1.md")
432 (include "marvell-pj4.md")
433 (include "xgene1.md")
436 ;;---------------------------------------------------------------------------
441 ;; Note: For DImode insns, there is normally no reason why operands should
442 ;; not be in the same register, what we don't want is for something being
443 ;; written to partially overlap something that is an input.
445 (define_expand "adddi3"
447 [(set (match_operand:DI 0 "s_register_operand" "")
448 (plus:DI (match_operand:DI 1 "s_register_operand" "")
449 (match_operand:DI 2 "arm_adddi_operand" "")))
450 (clobber (reg:CC CC_REGNUM))])]
455 if (!REG_P (operands[1]))
456 operands[1] = force_reg (DImode, operands[1]);
457 if (!REG_P (operands[2]))
458 operands[2] = force_reg (DImode, operands[2]);
463 (define_insn_and_split "*arm_adddi3"
464 [(set (match_operand:DI 0 "arm_general_register_operand" "=&r,&r,&r,&r,&r")
465 (plus:DI (match_operand:DI 1 "arm_general_register_operand" "%0, 0, r, 0, r")
466 (match_operand:DI 2 "arm_general_adddi_operand" "r, 0, r, Dd, Dd")))
467 (clobber (reg:CC CC_REGNUM))]
468 "TARGET_32BIT && !TARGET_NEON"
470 "TARGET_32BIT && ((!TARGET_NEON && !TARGET_IWMMXT) || reload_completed)"
471 [(parallel [(set (reg:CC_C CC_REGNUM)
472 (compare:CC_C (plus:SI (match_dup 1) (match_dup 2))
474 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))])
475 (set (match_dup 3) (plus:SI (plus:SI (match_dup 4) (match_dup 5))
476 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
479 operands[3] = gen_highpart (SImode, operands[0]);
480 operands[0] = gen_lowpart (SImode, operands[0]);
481 operands[4] = gen_highpart (SImode, operands[1]);
482 operands[1] = gen_lowpart (SImode, operands[1]);
483 operands[5] = gen_highpart_mode (SImode, DImode, operands[2]);
484 operands[2] = gen_lowpart (SImode, operands[2]);
486 [(set_attr "conds" "clob")
487 (set_attr "length" "8")
488 (set_attr "type" "multiple")]
491 (define_insn_and_split "*adddi_sesidi_di"
492 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
493 (plus:DI (sign_extend:DI
494 (match_operand:SI 2 "s_register_operand" "r,r"))
495 (match_operand:DI 1 "s_register_operand" "0,r")))
496 (clobber (reg:CC CC_REGNUM))]
499 "TARGET_32BIT && reload_completed"
500 [(parallel [(set (reg:CC_C CC_REGNUM)
501 (compare:CC_C (plus:SI (match_dup 1) (match_dup 2))
503 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))])
504 (set (match_dup 3) (plus:SI (plus:SI (ashiftrt:SI (match_dup 2)
507 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
510 operands[3] = gen_highpart (SImode, operands[0]);
511 operands[0] = gen_lowpart (SImode, operands[0]);
512 operands[4] = gen_highpart (SImode, operands[1]);
513 operands[1] = gen_lowpart (SImode, operands[1]);
514 operands[2] = gen_lowpart (SImode, operands[2]);
516 [(set_attr "conds" "clob")
517 (set_attr "length" "8")
518 (set_attr "type" "multiple")]
521 (define_insn_and_split "*adddi_zesidi_di"
522 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
523 (plus:DI (zero_extend:DI
524 (match_operand:SI 2 "s_register_operand" "r,r"))
525 (match_operand:DI 1 "s_register_operand" "0,r")))
526 (clobber (reg:CC CC_REGNUM))]
529 "TARGET_32BIT && reload_completed"
530 [(parallel [(set (reg:CC_C CC_REGNUM)
531 (compare:CC_C (plus:SI (match_dup 1) (match_dup 2))
533 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))])
534 (set (match_dup 3) (plus:SI (plus:SI (match_dup 4) (const_int 0))
535 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
538 operands[3] = gen_highpart (SImode, operands[0]);
539 operands[0] = gen_lowpart (SImode, operands[0]);
540 operands[4] = gen_highpart (SImode, operands[1]);
541 operands[1] = gen_lowpart (SImode, operands[1]);
542 operands[2] = gen_lowpart (SImode, operands[2]);
544 [(set_attr "conds" "clob")
545 (set_attr "length" "8")
546 (set_attr "type" "multiple")]
549 (define_expand "addv<mode>4"
550 [(match_operand:SIDI 0 "register_operand")
551 (match_operand:SIDI 1 "register_operand")
552 (match_operand:SIDI 2 "register_operand")
553 (match_operand 3 "")]
556 emit_insn (gen_add<mode>3_compareV (operands[0], operands[1], operands[2]));
557 arm_gen_unlikely_cbranch (NE, CC_Vmode, operands[3]);
562 (define_expand "uaddv<mode>4"
563 [(match_operand:SIDI 0 "register_operand")
564 (match_operand:SIDI 1 "register_operand")
565 (match_operand:SIDI 2 "register_operand")
566 (match_operand 3 "")]
569 emit_insn (gen_add<mode>3_compareC (operands[0], operands[1], operands[2]));
570 arm_gen_unlikely_cbranch (NE, CC_Cmode, operands[3]);
575 (define_expand "addsi3"
576 [(set (match_operand:SI 0 "s_register_operand" "")
577 (plus:SI (match_operand:SI 1 "s_register_operand" "")
578 (match_operand:SI 2 "reg_or_int_operand" "")))]
581 if (TARGET_32BIT && CONST_INT_P (operands[2]))
583 arm_split_constant (PLUS, SImode, NULL_RTX,
584 INTVAL (operands[2]), operands[0], operands[1],
585 optimize && can_create_pseudo_p ());
591 ; If there is a scratch available, this will be faster than synthesizing the
594 [(match_scratch:SI 3 "r")
595 (set (match_operand:SI 0 "arm_general_register_operand" "")
596 (plus:SI (match_operand:SI 1 "arm_general_register_operand" "")
597 (match_operand:SI 2 "const_int_operand" "")))]
599 !(const_ok_for_arm (INTVAL (operands[2]))
600 || const_ok_for_arm (-INTVAL (operands[2])))
601 && const_ok_for_arm (~INTVAL (operands[2]))"
602 [(set (match_dup 3) (match_dup 2))
603 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))]
607 ;; The r/r/k alternative is required when reloading the address
608 ;; (plus (reg rN) (reg sp)) into (reg rN). In this case reload will
609 ;; put the duplicated register first, and not try the commutative version.
610 (define_insn_and_split "*arm_addsi3"
611 [(set (match_operand:SI 0 "s_register_operand" "=rk,l,l ,l ,r ,k ,r,k ,r ,k ,r ,k,k,r ,k ,r")
612 (plus:SI (match_operand:SI 1 "s_register_operand" "%0 ,l,0 ,l ,rk,k ,r,r ,rk,k ,rk,k,r,rk,k ,rk")
613 (match_operand:SI 2 "reg_or_int_operand" "rk ,l,Py,Pd,rI,rI,k,rI,Pj,Pj,L ,L,L,PJ,PJ,?n")))]
629 subw%?\\t%0, %1, #%n2
630 subw%?\\t%0, %1, #%n2
633 && CONST_INT_P (operands[2])
634 && !const_ok_for_op (INTVAL (operands[2]), PLUS)
635 && (reload_completed || !arm_eliminable_register (operands[1]))"
636 [(clobber (const_int 0))]
638 arm_split_constant (PLUS, SImode, curr_insn,
639 INTVAL (operands[2]), operands[0],
643 [(set_attr "length" "2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,16")
644 (set_attr "predicable" "yes")
645 (set_attr "predicable_short_it" "yes,yes,yes,yes,no,no,no,no,no,no,no,no,no,no,no,no")
646 (set_attr "arch" "t2,t2,t2,t2,*,*,*,a,t2,t2,*,*,a,t2,t2,*")
647 (set (attr "type") (if_then_else (match_operand 2 "const_int_operand" "")
648 (const_string "alu_imm")
649 (const_string "alu_sreg")))
653 (define_insn_and_split "adddi3_compareV"
654 [(set (reg:CC_V CC_REGNUM)
657 (sign_extend:TI (match_operand:DI 1 "register_operand" "r"))
658 (sign_extend:TI (match_operand:DI 2 "register_operand" "r")))
659 (sign_extend:TI (plus:DI (match_dup 1) (match_dup 2)))))
660 (set (match_operand:DI 0 "register_operand" "=&r")
661 (plus:DI (match_dup 1) (match_dup 2)))]
664 "&& reload_completed"
665 [(parallel [(set (reg:CC_C CC_REGNUM)
666 (compare:CC_C (plus:SI (match_dup 1) (match_dup 2))
668 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))])
669 (parallel [(set (reg:CC_V CC_REGNUM)
672 (sign_extend:DI (match_dup 4))
673 (sign_extend:DI (match_dup 5)))
674 (ltu:DI (reg:CC_C CC_REGNUM) (const_int 0)))
675 (plus:DI (sign_extend:DI
676 (plus:SI (match_dup 4) (match_dup 5)))
677 (ltu:DI (reg:CC_C CC_REGNUM) (const_int 0)))))
678 (set (match_dup 3) (plus:SI (plus:SI
679 (match_dup 4) (match_dup 5))
680 (ltu:SI (reg:CC_C CC_REGNUM)
684 operands[3] = gen_highpart (SImode, operands[0]);
685 operands[0] = gen_lowpart (SImode, operands[0]);
686 operands[4] = gen_highpart (SImode, operands[1]);
687 operands[1] = gen_lowpart (SImode, operands[1]);
688 operands[5] = gen_highpart (SImode, operands[2]);
689 operands[2] = gen_lowpart (SImode, operands[2]);
691 [(set_attr "conds" "set")
692 (set_attr "length" "8")
693 (set_attr "type" "multiple")]
696 (define_insn "addsi3_compareV"
697 [(set (reg:CC_V CC_REGNUM)
700 (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
701 (sign_extend:DI (match_operand:SI 2 "register_operand" "r")))
702 (sign_extend:DI (plus:SI (match_dup 1) (match_dup 2)))))
703 (set (match_operand:SI 0 "register_operand" "=r")
704 (plus:SI (match_dup 1) (match_dup 2)))]
706 "adds%?\\t%0, %1, %2"
707 [(set_attr "conds" "set")
708 (set_attr "type" "alus_sreg")]
711 (define_insn "*addsi3_compareV_upper"
712 [(set (reg:CC_V CC_REGNUM)
716 (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
717 (sign_extend:DI (match_operand:SI 2 "register_operand" "r")))
718 (ltu:DI (reg:CC_C CC_REGNUM) (const_int 0)))
719 (plus:DI (sign_extend:DI
720 (plus:SI (match_dup 1) (match_dup 2)))
721 (ltu:DI (reg:CC_C CC_REGNUM) (const_int 0)))))
722 (set (match_operand:SI 0 "register_operand" "=r")
724 (plus:SI (match_dup 1) (match_dup 2))
725 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
727 "adcs%?\\t%0, %1, %2"
728 [(set_attr "conds" "set")
729 (set_attr "type" "adcs_reg")]
732 (define_insn_and_split "adddi3_compareC"
733 [(set (reg:CC_C CC_REGNUM)
736 (zero_extend:TI (match_operand:DI 1 "register_operand" "r"))
737 (zero_extend:TI (match_operand:DI 2 "register_operand" "r")))
738 (zero_extend:TI (plus:DI (match_dup 1) (match_dup 2)))))
739 (set (match_operand:DI 0 "register_operand" "=&r")
740 (plus:DI (match_dup 1) (match_dup 2)))]
743 "&& reload_completed"
744 [(parallel [(set (reg:CC_C CC_REGNUM)
745 (compare:CC_C (plus:SI (match_dup 1) (match_dup 2))
747 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))])
748 (parallel [(set (reg:CC_C CC_REGNUM)
751 (zero_extend:DI (match_dup 4))
752 (zero_extend:DI (match_dup 5)))
753 (ltu:DI (reg:CC_C CC_REGNUM) (const_int 0)))
754 (plus:DI (zero_extend:DI
755 (plus:SI (match_dup 4) (match_dup 5)))
756 (ltu:DI (reg:CC_C CC_REGNUM) (const_int 0)))))
757 (set (match_dup 3) (plus:SI
758 (plus:SI (match_dup 4) (match_dup 5))
759 (ltu:SI (reg:CC_C CC_REGNUM)
763 operands[3] = gen_highpart (SImode, operands[0]);
764 operands[0] = gen_lowpart (SImode, operands[0]);
765 operands[4] = gen_highpart (SImode, operands[1]);
766 operands[5] = gen_highpart (SImode, operands[2]);
767 operands[1] = gen_lowpart (SImode, operands[1]);
768 operands[2] = gen_lowpart (SImode, operands[2]);
770 [(set_attr "conds" "set")
771 (set_attr "length" "8")
772 (set_attr "type" "multiple")]
775 (define_insn "*addsi3_compareC_upper"
776 [(set (reg:CC_C CC_REGNUM)
780 (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
781 (zero_extend:DI (match_operand:SI 2 "register_operand" "r")))
782 (ltu:DI (reg:CC_C CC_REGNUM) (const_int 0)))
783 (plus:DI (zero_extend:DI
784 (plus:SI (match_dup 1) (match_dup 2)))
785 (ltu:DI (reg:CC_C CC_REGNUM) (const_int 0)))))
786 (set (match_operand:SI 0 "register_operand" "=r")
788 (plus:SI (match_dup 1) (match_dup 2))
789 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
791 "adcs%?\\t%0, %1, %2"
792 [(set_attr "conds" "set")
793 (set_attr "type" "adcs_reg")]
796 (define_insn "addsi3_compareC"
797 [(set (reg:CC_C CC_REGNUM)
800 (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
801 (zero_extend:DI (match_operand:SI 2 "register_operand" "r")))
803 (plus:SI (match_dup 1) (match_dup 2)))))
804 (set (match_operand:SI 0 "register_operand" "=r")
805 (plus:SI (match_dup 1) (match_dup 2)))]
807 "adds%?\\t%0, %1, %2"
808 [(set_attr "conds" "set")
809 (set_attr "type" "alus_sreg")]
812 (define_insn "addsi3_compare0"
813 [(set (reg:CC_NOOV CC_REGNUM)
815 (plus:SI (match_operand:SI 1 "s_register_operand" "r, r,r")
816 (match_operand:SI 2 "arm_add_operand" "I,L,r"))
818 (set (match_operand:SI 0 "s_register_operand" "=r,r,r")
819 (plus:SI (match_dup 1) (match_dup 2)))]
823 subs%?\\t%0, %1, #%n2
825 [(set_attr "conds" "set")
826 (set_attr "type" "alus_imm,alus_imm,alus_sreg")]
829 (define_insn "*addsi3_compare0_scratch"
830 [(set (reg:CC_NOOV CC_REGNUM)
832 (plus:SI (match_operand:SI 0 "s_register_operand" "r, r, r")
833 (match_operand:SI 1 "arm_add_operand" "I,L, r"))
840 [(set_attr "conds" "set")
841 (set_attr "predicable" "yes")
842 (set_attr "type" "alus_imm,alus_imm,alus_sreg")]
845 (define_insn "*compare_negsi_si"
846 [(set (reg:CC_Z CC_REGNUM)
848 (neg:SI (match_operand:SI 0 "s_register_operand" "l,r"))
849 (match_operand:SI 1 "s_register_operand" "l,r")))]
852 [(set_attr "conds" "set")
853 (set_attr "predicable" "yes")
854 (set_attr "arch" "t2,*")
855 (set_attr "length" "2,4")
856 (set_attr "predicable_short_it" "yes,no")
857 (set_attr "type" "alus_sreg")]
860 ;; This is the canonicalization of addsi3_compare0_for_combiner when the
861 ;; addend is a constant.
862 (define_insn "cmpsi2_addneg"
863 [(set (reg:CC CC_REGNUM)
865 (match_operand:SI 1 "s_register_operand" "r,r")
866 (match_operand:SI 2 "arm_addimm_operand" "L,I")))
867 (set (match_operand:SI 0 "s_register_operand" "=r,r")
868 (plus:SI (match_dup 1)
869 (match_operand:SI 3 "arm_addimm_operand" "I,L")))]
870 "TARGET_32BIT && INTVAL (operands[2]) == -INTVAL (operands[3])"
873 subs%?\\t%0, %1, #%n3"
874 [(set_attr "conds" "set")
875 (set_attr "type" "alus_sreg")]
878 ;; Convert the sequence
880 ;; cmn rd, #1 (equivalent to cmp rd, #-1)
884 ;; bcs dest ((unsigned)rn >= 1)
885 ;; similarly for the beq variant using bcc.
886 ;; This is a common looping idiom (while (n--))
888 [(set (match_operand:SI 0 "arm_general_register_operand" "")
889 (plus:SI (match_operand:SI 1 "arm_general_register_operand" "")
891 (set (match_operand 2 "cc_register" "")
892 (compare (match_dup 0) (const_int -1)))
894 (if_then_else (match_operator 3 "equality_operator"
895 [(match_dup 2) (const_int 0)])
896 (match_operand 4 "" "")
897 (match_operand 5 "" "")))]
898 "TARGET_32BIT && peep2_reg_dead_p (3, operands[2])"
902 (match_dup 1) (const_int 1)))
903 (set (match_dup 0) (plus:SI (match_dup 1) (const_int -1)))])
905 (if_then_else (match_op_dup 3 [(match_dup 2) (const_int 0)])
908 "operands[2] = gen_rtx_REG (CCmode, CC_REGNUM);
909 operands[3] = gen_rtx_fmt_ee ((GET_CODE (operands[3]) == NE
912 operands[2], const0_rtx);"
915 ;; The next four insns work because they compare the result with one of
916 ;; the operands, and we know that the use of the condition code is
917 ;; either GEU or LTU, so we can use the carry flag from the addition
918 ;; instead of doing the compare a second time.
919 (define_insn "*addsi3_compare_op1"
920 [(set (reg:CC_C CC_REGNUM)
922 (plus:SI (match_operand:SI 1 "s_register_operand" "r,r,r")
923 (match_operand:SI 2 "arm_add_operand" "I,L,r"))
925 (set (match_operand:SI 0 "s_register_operand" "=r,r,r")
926 (plus:SI (match_dup 1) (match_dup 2)))]
930 subs%?\\t%0, %1, #%n2
932 [(set_attr "conds" "set")
933 (set_attr "type" "alus_imm,alus_imm,alus_sreg")]
936 (define_insn "*addsi3_compare_op2"
937 [(set (reg:CC_C CC_REGNUM)
939 (plus:SI (match_operand:SI 1 "s_register_operand" "r,r,r")
940 (match_operand:SI 2 "arm_add_operand" "I,L,r"))
942 (set (match_operand:SI 0 "s_register_operand" "=r,r,r")
943 (plus:SI (match_dup 1) (match_dup 2)))]
947 subs%?\\t%0, %1, #%n2
949 [(set_attr "conds" "set")
950 (set_attr "type" "alus_imm,alus_imm,alus_sreg")]
953 (define_insn "*compare_addsi2_op0"
954 [(set (reg:CC_C CC_REGNUM)
956 (plus:SI (match_operand:SI 0 "s_register_operand" "l,l,r,r,r")
957 (match_operand:SI 1 "arm_add_operand" "Pv,l,I,L,r"))
966 [(set_attr "conds" "set")
967 (set_attr "predicable" "yes")
968 (set_attr "arch" "t2,t2,*,*,*")
969 (set_attr "predicable_short_it" "yes,yes,no,no,no")
970 (set_attr "length" "2,2,4,4,4")
971 (set_attr "type" "alus_imm,alus_sreg,alus_imm,alus_imm,alus_sreg")]
974 (define_insn "*compare_addsi2_op1"
975 [(set (reg:CC_C CC_REGNUM)
977 (plus:SI (match_operand:SI 0 "s_register_operand" "l,l,r,r,r")
978 (match_operand:SI 1 "arm_add_operand" "Pv,l,I,L,r"))
987 [(set_attr "conds" "set")
988 (set_attr "predicable" "yes")
989 (set_attr "arch" "t2,t2,*,*,*")
990 (set_attr "predicable_short_it" "yes,yes,no,no,no")
991 (set_attr "length" "2,2,4,4,4")
992 (set_attr "type" "alus_imm,alus_sreg,alus_imm,alus_imm,alus_sreg")]
995 (define_insn "*addsi3_carryin_<optab>"
996 [(set (match_operand:SI 0 "s_register_operand" "=l,r,r")
997 (plus:SI (plus:SI (match_operand:SI 1 "s_register_operand" "%l,r,r")
998 (match_operand:SI 2 "arm_not_operand" "0,rI,K"))
999 (LTUGEU:SI (reg:<cnb> CC_REGNUM) (const_int 0))))]
1004 sbc%?\\t%0, %1, #%B2"
1005 [(set_attr "conds" "use")
1006 (set_attr "predicable" "yes")
1007 (set_attr "arch" "t2,*,*")
1008 (set_attr "length" "4")
1009 (set_attr "predicable_short_it" "yes,no,no")
1010 (set_attr "type" "adc_reg,adc_reg,adc_imm")]
1013 (define_insn "*addsi3_carryin_alt2_<optab>"
1014 [(set (match_operand:SI 0 "s_register_operand" "=l,r,r")
1015 (plus:SI (plus:SI (LTUGEU:SI (reg:<cnb> CC_REGNUM) (const_int 0))
1016 (match_operand:SI 1 "s_register_operand" "%l,r,r"))
1017 (match_operand:SI 2 "arm_rhs_operand" "l,rI,K")))]
1022 sbc%?\\t%0, %1, #%B2"
1023 [(set_attr "conds" "use")
1024 (set_attr "predicable" "yes")
1025 (set_attr "arch" "t2,*,*")
1026 (set_attr "length" "4")
1027 (set_attr "predicable_short_it" "yes,no,no")
1028 (set_attr "type" "adc_reg,adc_reg,adc_imm")]
1031 (define_insn "*addsi3_carryin_shift_<optab>"
1032 [(set (match_operand:SI 0 "s_register_operand" "=r")
1034 (match_operator:SI 2 "shift_operator"
1035 [(match_operand:SI 3 "s_register_operand" "r")
1036 (match_operand:SI 4 "reg_or_int_operand" "rM")])
1037 (match_operand:SI 1 "s_register_operand" "r"))
1038 (LTUGEU:SI (reg:<cnb> CC_REGNUM) (const_int 0))))]
1040 "adc%?\\t%0, %1, %3%S2"
1041 [(set_attr "conds" "use")
1042 (set_attr "predicable" "yes")
1043 (set (attr "type") (if_then_else (match_operand 4 "const_int_operand" "")
1044 (const_string "alu_shift_imm")
1045 (const_string "alu_shift_reg")))]
1048 (define_insn "*addsi3_carryin_clobercc_<optab>"
1049 [(set (match_operand:SI 0 "s_register_operand" "=r")
1050 (plus:SI (plus:SI (match_operand:SI 1 "s_register_operand" "%r")
1051 (match_operand:SI 2 "arm_rhs_operand" "rI"))
1052 (LTUGEU:SI (reg:<cnb> CC_REGNUM) (const_int 0))))
1053 (clobber (reg:CC CC_REGNUM))]
1055 "adcs%?\\t%0, %1, %2"
1056 [(set_attr "conds" "set")
1057 (set_attr "type" "adcs_reg")]
1060 (define_expand "subv<mode>4"
1061 [(match_operand:SIDI 0 "register_operand")
1062 (match_operand:SIDI 1 "register_operand")
1063 (match_operand:SIDI 2 "register_operand")
1064 (match_operand 3 "")]
1067 emit_insn (gen_sub<mode>3_compare1 (operands[0], operands[1], operands[2]));
1068 arm_gen_unlikely_cbranch (NE, CC_Vmode, operands[3]);
1073 (define_expand "usubv<mode>4"
1074 [(match_operand:SIDI 0 "register_operand")
1075 (match_operand:SIDI 1 "register_operand")
1076 (match_operand:SIDI 2 "register_operand")
1077 (match_operand 3 "")]
1080 emit_insn (gen_sub<mode>3_compare1 (operands[0], operands[1], operands[2]));
1081 arm_gen_unlikely_cbranch (LTU, CCmode, operands[3]);
1086 (define_insn_and_split "subdi3_compare1"
1087 [(set (reg:CC CC_REGNUM)
1089 (match_operand:DI 1 "register_operand" "r")
1090 (match_operand:DI 2 "register_operand" "r")))
1091 (set (match_operand:DI 0 "register_operand" "=&r")
1092 (minus:DI (match_dup 1) (match_dup 2)))]
1095 "&& reload_completed"
1096 [(parallel [(set (reg:CC CC_REGNUM)
1097 (compare:CC (match_dup 1) (match_dup 2)))
1098 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))])
1099 (parallel [(set (reg:CC CC_REGNUM)
1100 (compare:CC (match_dup 4) (match_dup 5)))
1101 (set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
1102 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))])]
1104 operands[3] = gen_highpart (SImode, operands[0]);
1105 operands[0] = gen_lowpart (SImode, operands[0]);
1106 operands[4] = gen_highpart (SImode, operands[1]);
1107 operands[1] = gen_lowpart (SImode, operands[1]);
1108 operands[5] = gen_highpart (SImode, operands[2]);
1109 operands[2] = gen_lowpart (SImode, operands[2]);
1111 [(set_attr "conds" "set")
1112 (set_attr "length" "8")
1113 (set_attr "type" "multiple")]
1116 (define_insn "subsi3_compare1"
1117 [(set (reg:CC CC_REGNUM)
1119 (match_operand:SI 1 "register_operand" "r")
1120 (match_operand:SI 2 "register_operand" "r")))
1121 (set (match_operand:SI 0 "register_operand" "=r")
1122 (minus:SI (match_dup 1) (match_dup 2)))]
1124 "subs%?\\t%0, %1, %2"
1125 [(set_attr "conds" "set")
1126 (set_attr "type" "alus_sreg")]
1129 (define_insn "*subsi3_carryin"
1130 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
1131 (minus:SI (minus:SI (match_operand:SI 1 "reg_or_int_operand" "r,I,Pz")
1132 (match_operand:SI 2 "s_register_operand" "r,r,r"))
1133 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
1138 sbc%?\\t%0, %2, %2, lsl #1"
1139 [(set_attr "conds" "use")
1140 (set_attr "arch" "*,a,t2")
1141 (set_attr "predicable" "yes")
1142 (set_attr "type" "adc_reg,adc_imm,alu_shift_imm")]
1145 (define_insn "*subsi3_carryin_const"
1146 [(set (match_operand:SI 0 "s_register_operand" "=r")
1147 (minus:SI (plus:SI (match_operand:SI 1 "s_register_operand" "r")
1148 (match_operand:SI 2 "arm_neg_immediate_operand" "L"))
1149 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
1151 "sbc\\t%0, %1, #%n2"
1152 [(set_attr "conds" "use")
1153 (set_attr "type" "adc_imm")]
1156 (define_insn "*subsi3_carryin_const0"
1157 [(set (match_operand:SI 0 "s_register_operand" "=r")
1158 (minus:SI (match_operand:SI 1 "s_register_operand" "r")
1159 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
1162 [(set_attr "conds" "use")
1163 (set_attr "type" "adc_imm")]
1166 (define_insn "*subsi3_carryin_compare"
1167 [(set (reg:CC CC_REGNUM)
1168 (compare:CC (match_operand:SI 1 "s_register_operand" "r")
1169 (match_operand:SI 2 "s_register_operand" "r")))
1170 (set (match_operand:SI 0 "s_register_operand" "=r")
1171 (minus:SI (minus:SI (match_dup 1)
1173 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
1176 [(set_attr "conds" "set")
1177 (set_attr "type" "adcs_reg")]
1180 (define_insn "*subsi3_carryin_compare_const"
1181 [(set (reg:CC CC_REGNUM)
1182 (compare:CC (match_operand:SI 1 "reg_or_int_operand" "r")
1183 (match_operand:SI 2 "const_int_I_operand" "I")))
1184 (set (match_operand:SI 0 "s_register_operand" "=r")
1185 (minus:SI (plus:SI (match_dup 1)
1186 (match_operand:SI 3 "arm_neg_immediate_operand" "L"))
1187 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
1189 && (INTVAL (operands[2])
1190 == trunc_int_for_mode (-INTVAL (operands[3]), SImode))"
1191 "sbcs\\t%0, %1, #%n3"
1192 [(set_attr "conds" "set")
1193 (set_attr "type" "adcs_imm")]
1196 (define_insn "*subsi3_carryin_compare_const0"
1197 [(set (reg:CC CC_REGNUM)
1198 (compare:CC (match_operand:SI 1 "reg_or_int_operand" "r")
1200 (set (match_operand:SI 0 "s_register_operand" "=r")
1201 (minus:SI (match_dup 1)
1202 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
1205 [(set_attr "conds" "set")
1206 (set_attr "type" "adcs_imm")]
1209 (define_insn "*subsi3_carryin_shift"
1210 [(set (match_operand:SI 0 "s_register_operand" "=r")
1212 (match_operand:SI 1 "s_register_operand" "r")
1213 (match_operator:SI 2 "shift_operator"
1214 [(match_operand:SI 3 "s_register_operand" "r")
1215 (match_operand:SI 4 "reg_or_int_operand" "rM")]))
1216 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
1218 "sbc%?\\t%0, %1, %3%S2"
1219 [(set_attr "conds" "use")
1220 (set_attr "predicable" "yes")
1221 (set (attr "type") (if_then_else (match_operand 4 "const_int_operand" "")
1222 (const_string "alu_shift_imm")
1223 (const_string "alu_shift_reg")))]
1226 (define_insn "*rsbsi3_carryin_shift"
1227 [(set (match_operand:SI 0 "s_register_operand" "=r")
1229 (match_operator:SI 2 "shift_operator"
1230 [(match_operand:SI 3 "s_register_operand" "r")
1231 (match_operand:SI 4 "reg_or_int_operand" "rM")])
1232 (match_operand:SI 1 "s_register_operand" "r"))
1233 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
1235 "rsc%?\\t%0, %1, %3%S2"
1236 [(set_attr "conds" "use")
1237 (set_attr "predicable" "yes")
1238 (set (attr "type") (if_then_else (match_operand 4 "const_int_operand" "")
1239 (const_string "alu_shift_imm")
1240 (const_string "alu_shift_reg")))]
1243 ; transform ((x << y) - 1) to ~(~(x-1) << y) Where X is a constant.
1245 [(set (match_operand:SI 0 "s_register_operand" "")
1246 (plus:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
1247 (match_operand:SI 2 "s_register_operand" ""))
1249 (clobber (match_operand:SI 3 "s_register_operand" ""))]
1251 [(set (match_dup 3) (match_dup 1))
1252 (set (match_dup 0) (not:SI (ashift:SI (match_dup 3) (match_dup 2))))]
1254 operands[1] = GEN_INT (~(INTVAL (operands[1]) - 1));
1257 (define_expand "addsf3"
1258 [(set (match_operand:SF 0 "s_register_operand" "")
1259 (plus:SF (match_operand:SF 1 "s_register_operand" "")
1260 (match_operand:SF 2 "s_register_operand" "")))]
1261 "TARGET_32BIT && TARGET_HARD_FLOAT"
1265 (define_expand "adddf3"
1266 [(set (match_operand:DF 0 "s_register_operand" "")
1267 (plus:DF (match_operand:DF 1 "s_register_operand" "")
1268 (match_operand:DF 2 "s_register_operand" "")))]
1269 "TARGET_32BIT && TARGET_HARD_FLOAT && !TARGET_VFP_SINGLE"
1273 (define_expand "subdi3"
1275 [(set (match_operand:DI 0 "s_register_operand" "")
1276 (minus:DI (match_operand:DI 1 "s_register_operand" "")
1277 (match_operand:DI 2 "s_register_operand" "")))
1278 (clobber (reg:CC CC_REGNUM))])]
1283 if (!REG_P (operands[1]))
1284 operands[1] = force_reg (DImode, operands[1]);
1285 if (!REG_P (operands[2]))
1286 operands[2] = force_reg (DImode, operands[2]);
1291 (define_insn_and_split "*arm_subdi3"
1292 [(set (match_operand:DI 0 "arm_general_register_operand" "=&r,&r,&r")
1293 (minus:DI (match_operand:DI 1 "arm_general_register_operand" "0,r,0")
1294 (match_operand:DI 2 "arm_general_register_operand" "r,0,0")))
1295 (clobber (reg:CC CC_REGNUM))]
1296 "TARGET_32BIT && !TARGET_NEON"
1297 "#" ; "subs\\t%Q0, %Q1, %Q2\;sbc\\t%R0, %R1, %R2"
1298 "&& (!TARGET_IWMMXT || reload_completed)"
1299 [(parallel [(set (reg:CC CC_REGNUM)
1300 (compare:CC (match_dup 1) (match_dup 2)))
1301 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))])
1302 (set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
1303 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
1305 operands[3] = gen_highpart (SImode, operands[0]);
1306 operands[0] = gen_lowpart (SImode, operands[0]);
1307 operands[4] = gen_highpart (SImode, operands[1]);
1308 operands[1] = gen_lowpart (SImode, operands[1]);
1309 operands[5] = gen_highpart (SImode, operands[2]);
1310 operands[2] = gen_lowpart (SImode, operands[2]);
1312 [(set_attr "conds" "clob")
1313 (set_attr "length" "8")
1314 (set_attr "type" "multiple")]
1317 (define_insn_and_split "*subdi_di_zesidi"
1318 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
1319 (minus:DI (match_operand:DI 1 "s_register_operand" "0,r")
1321 (match_operand:SI 2 "s_register_operand" "r,r"))))
1322 (clobber (reg:CC CC_REGNUM))]
1324 "#" ; "subs\\t%Q0, %Q1, %2\;sbc\\t%R0, %R1, #0"
1325 "&& reload_completed"
1326 [(parallel [(set (reg:CC CC_REGNUM)
1327 (compare:CC (match_dup 1) (match_dup 2)))
1328 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))])
1329 (set (match_dup 3) (minus:SI (match_dup 4)
1330 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
1332 operands[3] = gen_highpart (SImode, operands[0]);
1333 operands[0] = gen_lowpart (SImode, operands[0]);
1334 operands[4] = gen_highpart (SImode, operands[1]);
1335 operands[1] = gen_lowpart (SImode, operands[1]);
1337 [(set_attr "conds" "clob")
1338 (set_attr "length" "8")
1339 (set_attr "type" "multiple")]
1342 (define_insn_and_split "*subdi_di_sesidi"
1343 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
1344 (minus:DI (match_operand:DI 1 "s_register_operand" "0,r")
1346 (match_operand:SI 2 "s_register_operand" "r,r"))))
1347 (clobber (reg:CC CC_REGNUM))]
1349 "#" ; "subs\\t%Q0, %Q1, %2\;sbc\\t%R0, %R1, %2, asr #31"
1350 "&& reload_completed"
1351 [(parallel [(set (reg:CC CC_REGNUM)
1352 (compare:CC (match_dup 1) (match_dup 2)))
1353 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))])
1354 (set (match_dup 3) (minus:SI (minus:SI (match_dup 4)
1355 (ashiftrt:SI (match_dup 2)
1357 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
1359 operands[3] = gen_highpart (SImode, operands[0]);
1360 operands[0] = gen_lowpart (SImode, operands[0]);
1361 operands[4] = gen_highpart (SImode, operands[1]);
1362 operands[1] = gen_lowpart (SImode, operands[1]);
1364 [(set_attr "conds" "clob")
1365 (set_attr "length" "8")
1366 (set_attr "type" "multiple")]
1369 (define_insn_and_split "*subdi_zesidi_di"
1370 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
1371 (minus:DI (zero_extend:DI
1372 (match_operand:SI 2 "s_register_operand" "r,r"))
1373 (match_operand:DI 1 "s_register_operand" "0,r")))
1374 (clobber (reg:CC CC_REGNUM))]
1376 "#" ; "rsbs\\t%Q0, %Q1, %2\;rsc\\t%R0, %R1, #0"
1378 ; "subs\\t%Q0, %2, %Q1\;rsc\\t%R0, %R1, #0"
1379 "&& reload_completed"
1380 [(parallel [(set (reg:CC CC_REGNUM)
1381 (compare:CC (match_dup 2) (match_dup 1)))
1382 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 1)))])
1383 (set (match_dup 3) (minus:SI (minus:SI (const_int 0) (match_dup 4))
1384 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
1386 operands[3] = gen_highpart (SImode, operands[0]);
1387 operands[0] = gen_lowpart (SImode, operands[0]);
1388 operands[4] = gen_highpart (SImode, operands[1]);
1389 operands[1] = gen_lowpart (SImode, operands[1]);
1391 [(set_attr "conds" "clob")
1392 (set_attr "length" "8")
1393 (set_attr "type" "multiple")]
1396 (define_insn_and_split "*subdi_sesidi_di"
1397 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
1398 (minus:DI (sign_extend:DI
1399 (match_operand:SI 2 "s_register_operand" "r,r"))
1400 (match_operand:DI 1 "s_register_operand" "0,r")))
1401 (clobber (reg:CC CC_REGNUM))]
1403 "#" ; "rsbs\\t%Q0, %Q1, %2\;rsc\\t%R0, %R1, %2, asr #31"
1405 ; "subs\\t%Q0, %2, %Q1\;rsc\\t%R0, %R1, %2, asr #31"
1406 "&& reload_completed"
1407 [(parallel [(set (reg:CC CC_REGNUM)
1408 (compare:CC (match_dup 2) (match_dup 1)))
1409 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 1)))])
1410 (set (match_dup 3) (minus:SI (minus:SI
1411 (ashiftrt:SI (match_dup 2)
1414 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
1416 operands[3] = gen_highpart (SImode, operands[0]);
1417 operands[0] = gen_lowpart (SImode, operands[0]);
1418 operands[4] = gen_highpart (SImode, operands[1]);
1419 operands[1] = gen_lowpart (SImode, operands[1]);
1421 [(set_attr "conds" "clob")
1422 (set_attr "length" "8")
1423 (set_attr "type" "multiple")]
1426 (define_insn_and_split "*subdi_zesidi_zesidi"
1427 [(set (match_operand:DI 0 "s_register_operand" "=r")
1428 (minus:DI (zero_extend:DI
1429 (match_operand:SI 1 "s_register_operand" "r"))
1431 (match_operand:SI 2 "s_register_operand" "r"))))
1432 (clobber (reg:CC CC_REGNUM))]
1434 "#" ; "subs\\t%Q0, %1, %2\;sbc\\t%R0, %1, %1"
1435 "&& reload_completed"
1436 [(parallel [(set (reg:CC CC_REGNUM)
1437 (compare:CC (match_dup 1) (match_dup 2)))
1438 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))])
1439 (set (match_dup 3) (minus:SI (minus:SI (match_dup 1) (match_dup 1))
1440 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
1442 operands[3] = gen_highpart (SImode, operands[0]);
1443 operands[0] = gen_lowpart (SImode, operands[0]);
1445 [(set_attr "conds" "clob")
1446 (set_attr "length" "8")
1447 (set_attr "type" "multiple")]
1450 (define_expand "subsi3"
1451 [(set (match_operand:SI 0 "s_register_operand" "")
1452 (minus:SI (match_operand:SI 1 "reg_or_int_operand" "")
1453 (match_operand:SI 2 "s_register_operand" "")))]
1456 if (CONST_INT_P (operands[1]))
1460 if (DONT_EARLY_SPLIT_CONSTANT (INTVAL (operands[1]), MINUS))
1461 operands[1] = force_reg (SImode, operands[1]);
1464 arm_split_constant (MINUS, SImode, NULL_RTX,
1465 INTVAL (operands[1]), operands[0],
1467 optimize && can_create_pseudo_p ());
1471 else /* TARGET_THUMB1 */
1472 operands[1] = force_reg (SImode, operands[1]);
1477 ; ??? Check Thumb-2 split length
1478 (define_insn_and_split "*arm_subsi3_insn"
1479 [(set (match_operand:SI 0 "s_register_operand" "=l,l ,l ,l ,r,r,r,rk,r")
1480 (minus:SI (match_operand:SI 1 "reg_or_int_operand" "l ,0 ,l ,Pz,I,r,r,k ,?n")
1481 (match_operand:SI 2 "reg_or_int_operand" "l ,Py,Pd,l ,r,I,r,r ,r")))]
1493 "&& (CONST_INT_P (operands[1])
1494 && !const_ok_for_arm (INTVAL (operands[1])))"
1495 [(clobber (const_int 0))]
1497 arm_split_constant (MINUS, SImode, curr_insn,
1498 INTVAL (operands[1]), operands[0], operands[2], 0);
1501 [(set_attr "length" "4,4,4,4,4,4,4,4,16")
1502 (set_attr "arch" "t2,t2,t2,t2,*,*,*,*,*")
1503 (set_attr "predicable" "yes")
1504 (set_attr "predicable_short_it" "yes,yes,yes,yes,no,no,no,no,no")
1505 (set_attr "type" "alu_sreg,alu_sreg,alu_sreg,alu_sreg,alu_imm,alu_imm,alu_sreg,alu_sreg,multiple")]
1509 [(match_scratch:SI 3 "r")
1510 (set (match_operand:SI 0 "arm_general_register_operand" "")
1511 (minus:SI (match_operand:SI 1 "const_int_operand" "")
1512 (match_operand:SI 2 "arm_general_register_operand" "")))]
1514 && !const_ok_for_arm (INTVAL (operands[1]))
1515 && const_ok_for_arm (~INTVAL (operands[1]))"
1516 [(set (match_dup 3) (match_dup 1))
1517 (set (match_dup 0) (minus:SI (match_dup 3) (match_dup 2)))]
1521 (define_insn "subsi3_compare0"
1522 [(set (reg:CC_NOOV CC_REGNUM)
1524 (minus:SI (match_operand:SI 1 "arm_rhs_operand" "r,r,I")
1525 (match_operand:SI 2 "arm_rhs_operand" "I,r,r"))
1527 (set (match_operand:SI 0 "s_register_operand" "=r,r,r")
1528 (minus:SI (match_dup 1) (match_dup 2)))]
1533 rsbs%?\\t%0, %2, %1"
1534 [(set_attr "conds" "set")
1535 (set_attr "type" "alus_imm,alus_sreg,alus_sreg")]
1538 (define_insn "subsi3_compare"
1539 [(set (reg:CC CC_REGNUM)
1540 (compare:CC (match_operand:SI 1 "arm_rhs_operand" "r,r,I")
1541 (match_operand:SI 2 "arm_rhs_operand" "I,r,r")))
1542 (set (match_operand:SI 0 "s_register_operand" "=r,r,r")
1543 (minus:SI (match_dup 1) (match_dup 2)))]
1548 rsbs%?\\t%0, %2, %1"
1549 [(set_attr "conds" "set")
1550 (set_attr "type" "alus_imm,alus_sreg,alus_sreg")]
1553 (define_expand "subsf3"
1554 [(set (match_operand:SF 0 "s_register_operand" "")
1555 (minus:SF (match_operand:SF 1 "s_register_operand" "")
1556 (match_operand:SF 2 "s_register_operand" "")))]
1557 "TARGET_32BIT && TARGET_HARD_FLOAT"
1561 (define_expand "subdf3"
1562 [(set (match_operand:DF 0 "s_register_operand" "")
1563 (minus:DF (match_operand:DF 1 "s_register_operand" "")
1564 (match_operand:DF 2 "s_register_operand" "")))]
1565 "TARGET_32BIT && TARGET_HARD_FLOAT && !TARGET_VFP_SINGLE"
1570 ;; Multiplication insns
1572 (define_expand "mulhi3"
1573 [(set (match_operand:HI 0 "s_register_operand" "")
1574 (mult:HI (match_operand:HI 1 "s_register_operand" "")
1575 (match_operand:HI 2 "s_register_operand" "")))]
1576 "TARGET_DSP_MULTIPLY"
1579 rtx result = gen_reg_rtx (SImode);
1580 emit_insn (gen_mulhisi3 (result, operands[1], operands[2]));
1581 emit_move_insn (operands[0], gen_lowpart (HImode, result));
1586 (define_expand "mulsi3"
1587 [(set (match_operand:SI 0 "s_register_operand" "")
1588 (mult:SI (match_operand:SI 2 "s_register_operand" "")
1589 (match_operand:SI 1 "s_register_operand" "")))]
1594 ;; Use `&' and then `0' to prevent the operands 0 and 1 being the same
1595 (define_insn "*arm_mulsi3"
1596 [(set (match_operand:SI 0 "s_register_operand" "=&r,&r")
1597 (mult:SI (match_operand:SI 2 "s_register_operand" "r,r")
1598 (match_operand:SI 1 "s_register_operand" "%0,r")))]
1599 "TARGET_32BIT && !arm_arch6"
1600 "mul%?\\t%0, %2, %1"
1601 [(set_attr "type" "mul")
1602 (set_attr "predicable" "yes")]
1605 (define_insn "*arm_mulsi3_v6"
1606 [(set (match_operand:SI 0 "s_register_operand" "=l,l,r")
1607 (mult:SI (match_operand:SI 1 "s_register_operand" "0,l,r")
1608 (match_operand:SI 2 "s_register_operand" "l,0,r")))]
1609 "TARGET_32BIT && arm_arch6"
1610 "mul%?\\t%0, %1, %2"
1611 [(set_attr "type" "mul")
1612 (set_attr "predicable" "yes")
1613 (set_attr "arch" "t2,t2,*")
1614 (set_attr "length" "4")
1615 (set_attr "predicable_short_it" "yes,yes,no")]
1618 (define_insn "*mulsi3_compare0"
1619 [(set (reg:CC_NOOV CC_REGNUM)
1620 (compare:CC_NOOV (mult:SI
1621 (match_operand:SI 2 "s_register_operand" "r,r")
1622 (match_operand:SI 1 "s_register_operand" "%0,r"))
1624 (set (match_operand:SI 0 "s_register_operand" "=&r,&r")
1625 (mult:SI (match_dup 2) (match_dup 1)))]
1626 "TARGET_ARM && !arm_arch6"
1627 "muls%?\\t%0, %2, %1"
1628 [(set_attr "conds" "set")
1629 (set_attr "type" "muls")]
1632 (define_insn "*mulsi3_compare0_v6"
1633 [(set (reg:CC_NOOV CC_REGNUM)
1634 (compare:CC_NOOV (mult:SI
1635 (match_operand:SI 2 "s_register_operand" "r")
1636 (match_operand:SI 1 "s_register_operand" "r"))
1638 (set (match_operand:SI 0 "s_register_operand" "=r")
1639 (mult:SI (match_dup 2) (match_dup 1)))]
1640 "TARGET_ARM && arm_arch6 && optimize_size"
1641 "muls%?\\t%0, %2, %1"
1642 [(set_attr "conds" "set")
1643 (set_attr "type" "muls")]
1646 (define_insn "*mulsi_compare0_scratch"
1647 [(set (reg:CC_NOOV CC_REGNUM)
1648 (compare:CC_NOOV (mult:SI
1649 (match_operand:SI 2 "s_register_operand" "r,r")
1650 (match_operand:SI 1 "s_register_operand" "%0,r"))
1652 (clobber (match_scratch:SI 0 "=&r,&r"))]
1653 "TARGET_ARM && !arm_arch6"
1654 "muls%?\\t%0, %2, %1"
1655 [(set_attr "conds" "set")
1656 (set_attr "type" "muls")]
1659 (define_insn "*mulsi_compare0_scratch_v6"
1660 [(set (reg:CC_NOOV CC_REGNUM)
1661 (compare:CC_NOOV (mult:SI
1662 (match_operand:SI 2 "s_register_operand" "r")
1663 (match_operand:SI 1 "s_register_operand" "r"))
1665 (clobber (match_scratch:SI 0 "=r"))]
1666 "TARGET_ARM && arm_arch6 && optimize_size"
1667 "muls%?\\t%0, %2, %1"
1668 [(set_attr "conds" "set")
1669 (set_attr "type" "muls")]
1672 ;; Unnamed templates to match MLA instruction.
1674 (define_insn "*mulsi3addsi"
1675 [(set (match_operand:SI 0 "s_register_operand" "=&r,&r,&r,&r")
1677 (mult:SI (match_operand:SI 2 "s_register_operand" "r,r,r,r")
1678 (match_operand:SI 1 "s_register_operand" "%0,r,0,r"))
1679 (match_operand:SI 3 "s_register_operand" "r,r,0,0")))]
1680 "TARGET_32BIT && !arm_arch6"
1681 "mla%?\\t%0, %2, %1, %3"
1682 [(set_attr "type" "mla")
1683 (set_attr "predicable" "yes")]
1686 (define_insn "*mulsi3addsi_v6"
1687 [(set (match_operand:SI 0 "s_register_operand" "=r")
1689 (mult:SI (match_operand:SI 2 "s_register_operand" "r")
1690 (match_operand:SI 1 "s_register_operand" "r"))
1691 (match_operand:SI 3 "s_register_operand" "r")))]
1692 "TARGET_32BIT && arm_arch6"
1693 "mla%?\\t%0, %2, %1, %3"
1694 [(set_attr "type" "mla")
1695 (set_attr "predicable" "yes")]
1698 (define_insn "*mulsi3addsi_compare0"
1699 [(set (reg:CC_NOOV CC_REGNUM)
1702 (match_operand:SI 2 "s_register_operand" "r,r,r,r")
1703 (match_operand:SI 1 "s_register_operand" "%0,r,0,r"))
1704 (match_operand:SI 3 "s_register_operand" "r,r,0,0"))
1706 (set (match_operand:SI 0 "s_register_operand" "=&r,&r,&r,&r")
1707 (plus:SI (mult:SI (match_dup 2) (match_dup 1))
1709 "TARGET_ARM && arm_arch6"
1710 "mlas%?\\t%0, %2, %1, %3"
1711 [(set_attr "conds" "set")
1712 (set_attr "type" "mlas")]
1715 (define_insn "*mulsi3addsi_compare0_v6"
1716 [(set (reg:CC_NOOV CC_REGNUM)
1719 (match_operand:SI 2 "s_register_operand" "r")
1720 (match_operand:SI 1 "s_register_operand" "r"))
1721 (match_operand:SI 3 "s_register_operand" "r"))
1723 (set (match_operand:SI 0 "s_register_operand" "=r")
1724 (plus:SI (mult:SI (match_dup 2) (match_dup 1))
1726 "TARGET_ARM && arm_arch6 && optimize_size"
1727 "mlas%?\\t%0, %2, %1, %3"
1728 [(set_attr "conds" "set")
1729 (set_attr "type" "mlas")]
1732 (define_insn "*mulsi3addsi_compare0_scratch"
1733 [(set (reg:CC_NOOV CC_REGNUM)
1736 (match_operand:SI 2 "s_register_operand" "r,r,r,r")
1737 (match_operand:SI 1 "s_register_operand" "%0,r,0,r"))
1738 (match_operand:SI 3 "s_register_operand" "?r,r,0,0"))
1740 (clobber (match_scratch:SI 0 "=&r,&r,&r,&r"))]
1741 "TARGET_ARM && !arm_arch6"
1742 "mlas%?\\t%0, %2, %1, %3"
1743 [(set_attr "conds" "set")
1744 (set_attr "type" "mlas")]
1747 (define_insn "*mulsi3addsi_compare0_scratch_v6"
1748 [(set (reg:CC_NOOV CC_REGNUM)
1751 (match_operand:SI 2 "s_register_operand" "r")
1752 (match_operand:SI 1 "s_register_operand" "r"))
1753 (match_operand:SI 3 "s_register_operand" "r"))
1755 (clobber (match_scratch:SI 0 "=r"))]
1756 "TARGET_ARM && arm_arch6 && optimize_size"
1757 "mlas%?\\t%0, %2, %1, %3"
1758 [(set_attr "conds" "set")
1759 (set_attr "type" "mlas")]
1762 (define_insn "*mulsi3subsi"
1763 [(set (match_operand:SI 0 "s_register_operand" "=r")
1765 (match_operand:SI 3 "s_register_operand" "r")
1766 (mult:SI (match_operand:SI 2 "s_register_operand" "r")
1767 (match_operand:SI 1 "s_register_operand" "r"))))]
1768 "TARGET_32BIT && arm_arch_thumb2"
1769 "mls%?\\t%0, %2, %1, %3"
1770 [(set_attr "type" "mla")
1771 (set_attr "predicable" "yes")]
1774 (define_expand "maddsidi4"
1775 [(set (match_operand:DI 0 "s_register_operand" "")
1778 (sign_extend:DI (match_operand:SI 1 "s_register_operand" ""))
1779 (sign_extend:DI (match_operand:SI 2 "s_register_operand" "")))
1780 (match_operand:DI 3 "s_register_operand" "")))]
1784 (define_insn "*mulsidi3adddi"
1785 [(set (match_operand:DI 0 "s_register_operand" "=&r")
1788 (sign_extend:DI (match_operand:SI 2 "s_register_operand" "%r"))
1789 (sign_extend:DI (match_operand:SI 3 "s_register_operand" "r")))
1790 (match_operand:DI 1 "s_register_operand" "0")))]
1791 "TARGET_32BIT && !arm_arch6"
1792 "smlal%?\\t%Q0, %R0, %3, %2"
1793 [(set_attr "type" "smlal")
1794 (set_attr "predicable" "yes")]
1797 (define_insn "*mulsidi3adddi_v6"
1798 [(set (match_operand:DI 0 "s_register_operand" "=r")
1801 (sign_extend:DI (match_operand:SI 2 "s_register_operand" "r"))
1802 (sign_extend:DI (match_operand:SI 3 "s_register_operand" "r")))
1803 (match_operand:DI 1 "s_register_operand" "0")))]
1804 "TARGET_32BIT && arm_arch6"
1805 "smlal%?\\t%Q0, %R0, %3, %2"
1806 [(set_attr "type" "smlal")
1807 (set_attr "predicable" "yes")]
1810 ;; 32x32->64 widening multiply.
1811 ;; As with mulsi3, the only difference between the v3-5 and v6+
1812 ;; versions of these patterns is the requirement that the output not
1813 ;; overlap the inputs, but that still means we have to have a named
1814 ;; expander and two different starred insns.
1816 (define_expand "mulsidi3"
1817 [(set (match_operand:DI 0 "s_register_operand" "")
1819 (sign_extend:DI (match_operand:SI 1 "s_register_operand" ""))
1820 (sign_extend:DI (match_operand:SI 2 "s_register_operand" ""))))]
1825 (define_insn "*mulsidi3_nov6"
1826 [(set (match_operand:DI 0 "s_register_operand" "=&r")
1828 (sign_extend:DI (match_operand:SI 1 "s_register_operand" "%r"))
1829 (sign_extend:DI (match_operand:SI 2 "s_register_operand" "r"))))]
1830 "TARGET_32BIT && !arm_arch6"
1831 "smull%?\\t%Q0, %R0, %1, %2"
1832 [(set_attr "type" "smull")
1833 (set_attr "predicable" "yes")]
1836 (define_insn "*mulsidi3_v6"
1837 [(set (match_operand:DI 0 "s_register_operand" "=r")
1839 (sign_extend:DI (match_operand:SI 1 "s_register_operand" "r"))
1840 (sign_extend:DI (match_operand:SI 2 "s_register_operand" "r"))))]
1841 "TARGET_32BIT && arm_arch6"
1842 "smull%?\\t%Q0, %R0, %1, %2"
1843 [(set_attr "type" "smull")
1844 (set_attr "predicable" "yes")]
1847 (define_expand "umulsidi3"
1848 [(set (match_operand:DI 0 "s_register_operand" "")
1850 (zero_extend:DI (match_operand:SI 1 "s_register_operand" ""))
1851 (zero_extend:DI (match_operand:SI 2 "s_register_operand" ""))))]
1856 (define_insn "*umulsidi3_nov6"
1857 [(set (match_operand:DI 0 "s_register_operand" "=&r")
1859 (zero_extend:DI (match_operand:SI 1 "s_register_operand" "%r"))
1860 (zero_extend:DI (match_operand:SI 2 "s_register_operand" "r"))))]
1861 "TARGET_32BIT && !arm_arch6"
1862 "umull%?\\t%Q0, %R0, %1, %2"
1863 [(set_attr "type" "umull")
1864 (set_attr "predicable" "yes")]
1867 (define_insn "*umulsidi3_v6"
1868 [(set (match_operand:DI 0 "s_register_operand" "=r")
1870 (zero_extend:DI (match_operand:SI 1 "s_register_operand" "r"))
1871 (zero_extend:DI (match_operand:SI 2 "s_register_operand" "r"))))]
1872 "TARGET_32BIT && arm_arch6"
1873 "umull%?\\t%Q0, %R0, %1, %2"
1874 [(set_attr "type" "umull")
1875 (set_attr "predicable" "yes")]
1878 (define_expand "umaddsidi4"
1879 [(set (match_operand:DI 0 "s_register_operand" "")
1882 (zero_extend:DI (match_operand:SI 1 "s_register_operand" ""))
1883 (zero_extend:DI (match_operand:SI 2 "s_register_operand" "")))
1884 (match_operand:DI 3 "s_register_operand" "")))]
1888 (define_insn "*umulsidi3adddi"
1889 [(set (match_operand:DI 0 "s_register_operand" "=&r")
1892 (zero_extend:DI (match_operand:SI 2 "s_register_operand" "%r"))
1893 (zero_extend:DI (match_operand:SI 3 "s_register_operand" "r")))
1894 (match_operand:DI 1 "s_register_operand" "0")))]
1895 "TARGET_32BIT && !arm_arch6"
1896 "umlal%?\\t%Q0, %R0, %3, %2"
1897 [(set_attr "type" "umlal")
1898 (set_attr "predicable" "yes")]
1901 (define_insn "*umulsidi3adddi_v6"
1902 [(set (match_operand:DI 0 "s_register_operand" "=r")
1905 (zero_extend:DI (match_operand:SI 2 "s_register_operand" "r"))
1906 (zero_extend:DI (match_operand:SI 3 "s_register_operand" "r")))
1907 (match_operand:DI 1 "s_register_operand" "0")))]
1908 "TARGET_32BIT && arm_arch6"
1909 "umlal%?\\t%Q0, %R0, %3, %2"
1910 [(set_attr "type" "umlal")
1911 (set_attr "predicable" "yes")]
1914 (define_expand "smulsi3_highpart"
1916 [(set (match_operand:SI 0 "s_register_operand" "")
1920 (sign_extend:DI (match_operand:SI 1 "s_register_operand" ""))
1921 (sign_extend:DI (match_operand:SI 2 "s_register_operand" "")))
1923 (clobber (match_scratch:SI 3 ""))])]
1928 (define_insn "*smulsi3_highpart_nov6"
1929 [(set (match_operand:SI 0 "s_register_operand" "=&r,&r")
1933 (sign_extend:DI (match_operand:SI 1 "s_register_operand" "%0,r"))
1934 (sign_extend:DI (match_operand:SI 2 "s_register_operand" "r,r")))
1936 (clobber (match_scratch:SI 3 "=&r,&r"))]
1937 "TARGET_32BIT && !arm_arch6"
1938 "smull%?\\t%3, %0, %2, %1"
1939 [(set_attr "type" "smull")
1940 (set_attr "predicable" "yes")]
1943 (define_insn "*smulsi3_highpart_v6"
1944 [(set (match_operand:SI 0 "s_register_operand" "=r")
1948 (sign_extend:DI (match_operand:SI 1 "s_register_operand" "r"))
1949 (sign_extend:DI (match_operand:SI 2 "s_register_operand" "r")))
1951 (clobber (match_scratch:SI 3 "=r"))]
1952 "TARGET_32BIT && arm_arch6"
1953 "smull%?\\t%3, %0, %2, %1"
1954 [(set_attr "type" "smull")
1955 (set_attr "predicable" "yes")]
1958 (define_expand "umulsi3_highpart"
1960 [(set (match_operand:SI 0 "s_register_operand" "")
1964 (zero_extend:DI (match_operand:SI 1 "s_register_operand" ""))
1965 (zero_extend:DI (match_operand:SI 2 "s_register_operand" "")))
1967 (clobber (match_scratch:SI 3 ""))])]
1972 (define_insn "*umulsi3_highpart_nov6"
1973 [(set (match_operand:SI 0 "s_register_operand" "=&r,&r")
1977 (zero_extend:DI (match_operand:SI 1 "s_register_operand" "%0,r"))
1978 (zero_extend:DI (match_operand:SI 2 "s_register_operand" "r,r")))
1980 (clobber (match_scratch:SI 3 "=&r,&r"))]
1981 "TARGET_32BIT && !arm_arch6"
1982 "umull%?\\t%3, %0, %2, %1"
1983 [(set_attr "type" "umull")
1984 (set_attr "predicable" "yes")]
1987 (define_insn "*umulsi3_highpart_v6"
1988 [(set (match_operand:SI 0 "s_register_operand" "=r")
1992 (zero_extend:DI (match_operand:SI 1 "s_register_operand" "r"))
1993 (zero_extend:DI (match_operand:SI 2 "s_register_operand" "r")))
1995 (clobber (match_scratch:SI 3 "=r"))]
1996 "TARGET_32BIT && arm_arch6"
1997 "umull%?\\t%3, %0, %2, %1"
1998 [(set_attr "type" "umull")
1999 (set_attr "predicable" "yes")]
2002 (define_insn "mulhisi3"
2003 [(set (match_operand:SI 0 "s_register_operand" "=r")
2004 (mult:SI (sign_extend:SI
2005 (match_operand:HI 1 "s_register_operand" "%r"))
2007 (match_operand:HI 2 "s_register_operand" "r"))))]
2008 "TARGET_DSP_MULTIPLY"
2009 "smulbb%?\\t%0, %1, %2"
2010 [(set_attr "type" "smulxy")
2011 (set_attr "predicable" "yes")]
2014 (define_insn "*mulhisi3tb"
2015 [(set (match_operand:SI 0 "s_register_operand" "=r")
2016 (mult:SI (ashiftrt:SI
2017 (match_operand:SI 1 "s_register_operand" "r")
2020 (match_operand:HI 2 "s_register_operand" "r"))))]
2021 "TARGET_DSP_MULTIPLY"
2022 "smultb%?\\t%0, %1, %2"
2023 [(set_attr "type" "smulxy")
2024 (set_attr "predicable" "yes")]
2027 (define_insn "*mulhisi3bt"
2028 [(set (match_operand:SI 0 "s_register_operand" "=r")
2029 (mult:SI (sign_extend:SI
2030 (match_operand:HI 1 "s_register_operand" "r"))
2032 (match_operand:SI 2 "s_register_operand" "r")
2034 "TARGET_DSP_MULTIPLY"
2035 "smulbt%?\\t%0, %1, %2"
2036 [(set_attr "type" "smulxy")
2037 (set_attr "predicable" "yes")]
2040 (define_insn "*mulhisi3tt"
2041 [(set (match_operand:SI 0 "s_register_operand" "=r")
2042 (mult:SI (ashiftrt:SI
2043 (match_operand:SI 1 "s_register_operand" "r")
2046 (match_operand:SI 2 "s_register_operand" "r")
2048 "TARGET_DSP_MULTIPLY"
2049 "smultt%?\\t%0, %1, %2"
2050 [(set_attr "type" "smulxy")
2051 (set_attr "predicable" "yes")]
2054 (define_insn "maddhisi4"
2055 [(set (match_operand:SI 0 "s_register_operand" "=r")
2056 (plus:SI (mult:SI (sign_extend:SI
2057 (match_operand:HI 1 "s_register_operand" "r"))
2059 (match_operand:HI 2 "s_register_operand" "r")))
2060 (match_operand:SI 3 "s_register_operand" "r")))]
2061 "TARGET_DSP_MULTIPLY"
2062 "smlabb%?\\t%0, %1, %2, %3"
2063 [(set_attr "type" "smlaxy")
2064 (set_attr "predicable" "yes")]
2067 ;; Note: there is no maddhisi4ibt because this one is canonical form
2068 (define_insn "*maddhisi4tb"
2069 [(set (match_operand:SI 0 "s_register_operand" "=r")
2070 (plus:SI (mult:SI (ashiftrt:SI
2071 (match_operand:SI 1 "s_register_operand" "r")
2074 (match_operand:HI 2 "s_register_operand" "r")))
2075 (match_operand:SI 3 "s_register_operand" "r")))]
2076 "TARGET_DSP_MULTIPLY"
2077 "smlatb%?\\t%0, %1, %2, %3"
2078 [(set_attr "type" "smlaxy")
2079 (set_attr "predicable" "yes")]
2082 (define_insn "*maddhisi4tt"
2083 [(set (match_operand:SI 0 "s_register_operand" "=r")
2084 (plus:SI (mult:SI (ashiftrt:SI
2085 (match_operand:SI 1 "s_register_operand" "r")
2088 (match_operand:SI 2 "s_register_operand" "r")
2090 (match_operand:SI 3 "s_register_operand" "r")))]
2091 "TARGET_DSP_MULTIPLY"
2092 "smlatt%?\\t%0, %1, %2, %3"
2093 [(set_attr "type" "smlaxy")
2094 (set_attr "predicable" "yes")]
2097 (define_insn "maddhidi4"
2098 [(set (match_operand:DI 0 "s_register_operand" "=r")
2100 (mult:DI (sign_extend:DI
2101 (match_operand:HI 1 "s_register_operand" "r"))
2103 (match_operand:HI 2 "s_register_operand" "r")))
2104 (match_operand:DI 3 "s_register_operand" "0")))]
2105 "TARGET_DSP_MULTIPLY"
2106 "smlalbb%?\\t%Q0, %R0, %1, %2"
2107 [(set_attr "type" "smlalxy")
2108 (set_attr "predicable" "yes")])
2110 ;; Note: there is no maddhidi4ibt because this one is canonical form
2111 (define_insn "*maddhidi4tb"
2112 [(set (match_operand:DI 0 "s_register_operand" "=r")
2114 (mult:DI (sign_extend:DI
2116 (match_operand:SI 1 "s_register_operand" "r")
2119 (match_operand:HI 2 "s_register_operand" "r")))
2120 (match_operand:DI 3 "s_register_operand" "0")))]
2121 "TARGET_DSP_MULTIPLY"
2122 "smlaltb%?\\t%Q0, %R0, %1, %2"
2123 [(set_attr "type" "smlalxy")
2124 (set_attr "predicable" "yes")])
2126 (define_insn "*maddhidi4tt"
2127 [(set (match_operand:DI 0 "s_register_operand" "=r")
2129 (mult:DI (sign_extend:DI
2131 (match_operand:SI 1 "s_register_operand" "r")
2135 (match_operand:SI 2 "s_register_operand" "r")
2137 (match_operand:DI 3 "s_register_operand" "0")))]
2138 "TARGET_DSP_MULTIPLY"
2139 "smlaltt%?\\t%Q0, %R0, %1, %2"
2140 [(set_attr "type" "smlalxy")
2141 (set_attr "predicable" "yes")])
2143 (define_expand "mulsf3"
2144 [(set (match_operand:SF 0 "s_register_operand" "")
2145 (mult:SF (match_operand:SF 1 "s_register_operand" "")
2146 (match_operand:SF 2 "s_register_operand" "")))]
2147 "TARGET_32BIT && TARGET_HARD_FLOAT"
2151 (define_expand "muldf3"
2152 [(set (match_operand:DF 0 "s_register_operand" "")
2153 (mult:DF (match_operand:DF 1 "s_register_operand" "")
2154 (match_operand:DF 2 "s_register_operand" "")))]
2155 "TARGET_32BIT && TARGET_HARD_FLOAT && !TARGET_VFP_SINGLE"
2161 (define_expand "divsf3"
2162 [(set (match_operand:SF 0 "s_register_operand" "")
2163 (div:SF (match_operand:SF 1 "s_register_operand" "")
2164 (match_operand:SF 2 "s_register_operand" "")))]
2165 "TARGET_32BIT && TARGET_HARD_FLOAT"
2168 (define_expand "divdf3"
2169 [(set (match_operand:DF 0 "s_register_operand" "")
2170 (div:DF (match_operand:DF 1 "s_register_operand" "")
2171 (match_operand:DF 2 "s_register_operand" "")))]
2172 "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_VFP_DOUBLE"
2175 ;; Boolean and,ior,xor insns
2177 ;; Split up double word logical operations
2179 ;; Split up simple DImode logical operations. Simply perform the logical
2180 ;; operation on the upper and lower halves of the registers.
2182 [(set (match_operand:DI 0 "s_register_operand" "")
2183 (match_operator:DI 6 "logical_binary_operator"
2184 [(match_operand:DI 1 "s_register_operand" "")
2185 (match_operand:DI 2 "s_register_operand" "")]))]
2186 "TARGET_32BIT && reload_completed
2187 && ! (TARGET_NEON && IS_VFP_REGNUM (REGNO (operands[0])))
2188 && ! IS_IWMMXT_REGNUM (REGNO (operands[0]))"
2189 [(set (match_dup 0) (match_op_dup:SI 6 [(match_dup 1) (match_dup 2)]))
2190 (set (match_dup 3) (match_op_dup:SI 6 [(match_dup 4) (match_dup 5)]))]
2193 operands[3] = gen_highpart (SImode, operands[0]);
2194 operands[0] = gen_lowpart (SImode, operands[0]);
2195 operands[4] = gen_highpart (SImode, operands[1]);
2196 operands[1] = gen_lowpart (SImode, operands[1]);
2197 operands[5] = gen_highpart (SImode, operands[2]);
2198 operands[2] = gen_lowpart (SImode, operands[2]);
2203 [(set (match_operand:DI 0 "s_register_operand" "")
2204 (match_operator:DI 6 "logical_binary_operator"
2205 [(sign_extend:DI (match_operand:SI 2 "s_register_operand" ""))
2206 (match_operand:DI 1 "s_register_operand" "")]))]
2207 "TARGET_32BIT && reload_completed"
2208 [(set (match_dup 0) (match_op_dup:SI 6 [(match_dup 1) (match_dup 2)]))
2209 (set (match_dup 3) (match_op_dup:SI 6
2210 [(ashiftrt:SI (match_dup 2) (const_int 31))
2214 operands[3] = gen_highpart (SImode, operands[0]);
2215 operands[0] = gen_lowpart (SImode, operands[0]);
2216 operands[4] = gen_highpart (SImode, operands[1]);
2217 operands[1] = gen_lowpart (SImode, operands[1]);
2218 operands[5] = gen_highpart (SImode, operands[2]);
2219 operands[2] = gen_lowpart (SImode, operands[2]);
2223 ;; The zero extend of operand 2 means we can just copy the high part of
2224 ;; operand1 into operand0.
2226 [(set (match_operand:DI 0 "s_register_operand" "")
2228 (zero_extend:DI (match_operand:SI 2 "s_register_operand" ""))
2229 (match_operand:DI 1 "s_register_operand" "")))]
2230 "TARGET_32BIT && operands[0] != operands[1] && reload_completed"
2231 [(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 2)))
2232 (set (match_dup 3) (match_dup 4))]
2235 operands[4] = gen_highpart (SImode, operands[1]);
2236 operands[3] = gen_highpart (SImode, operands[0]);
2237 operands[0] = gen_lowpart (SImode, operands[0]);
2238 operands[1] = gen_lowpart (SImode, operands[1]);
2242 ;; The zero extend of operand 2 means we can just copy the high part of
2243 ;; operand1 into operand0.
2245 [(set (match_operand:DI 0 "s_register_operand" "")
2247 (zero_extend:DI (match_operand:SI 2 "s_register_operand" ""))
2248 (match_operand:DI 1 "s_register_operand" "")))]
2249 "TARGET_32BIT && operands[0] != operands[1] && reload_completed"
2250 [(set (match_dup 0) (xor:SI (match_dup 1) (match_dup 2)))
2251 (set (match_dup 3) (match_dup 4))]
2254 operands[4] = gen_highpart (SImode, operands[1]);
2255 operands[3] = gen_highpart (SImode, operands[0]);
2256 operands[0] = gen_lowpart (SImode, operands[0]);
2257 operands[1] = gen_lowpart (SImode, operands[1]);
2261 (define_expand "anddi3"
2262 [(set (match_operand:DI 0 "s_register_operand" "")
2263 (and:DI (match_operand:DI 1 "s_register_operand" "")
2264 (match_operand:DI 2 "neon_inv_logic_op2" "")))]
2267 if (!TARGET_NEON && !TARGET_IWMMXT)
2269 rtx low = simplify_gen_binary (AND, SImode,
2270 gen_lowpart (SImode, operands[1]),
2271 gen_lowpart (SImode, operands[2]));
2272 rtx high = simplify_gen_binary (AND, SImode,
2273 gen_highpart (SImode, operands[1]),
2274 gen_highpart_mode (SImode, DImode,
2277 emit_insn (gen_rtx_SET (gen_lowpart (SImode, operands[0]), low));
2278 emit_insn (gen_rtx_SET (gen_highpart (SImode, operands[0]), high));
2282 /* Otherwise expand pattern as above. */
2286 (define_insn_and_split "*anddi3_insn"
2287 [(set (match_operand:DI 0 "s_register_operand" "=w,w ,&r,&r,&r,&r,?w,?w")
2288 (and:DI (match_operand:DI 1 "s_register_operand" "%w,0 ,0 ,r ,0 ,r ,w ,0")
2289 (match_operand:DI 2 "arm_anddi_operand_neon" "w ,DL,r ,r ,De,De,w ,DL")))]
2290 "TARGET_32BIT && !TARGET_IWMMXT"
2292 switch (which_alternative)
2294 case 0: /* fall through */
2295 case 6: return "vand\t%P0, %P1, %P2";
2296 case 1: /* fall through */
2297 case 7: return neon_output_logic_immediate ("vand", &operands[2],
2298 DImode, 1, VALID_NEON_QREG_MODE (DImode));
2302 case 5: /* fall through */
2304 default: gcc_unreachable ();
2307 "TARGET_32BIT && !TARGET_IWMMXT && reload_completed
2308 && !(IS_VFP_REGNUM (REGNO (operands[0])))"
2309 [(set (match_dup 3) (match_dup 4))
2310 (set (match_dup 5) (match_dup 6))]
2313 operands[3] = gen_lowpart (SImode, operands[0]);
2314 operands[5] = gen_highpart (SImode, operands[0]);
2316 operands[4] = simplify_gen_binary (AND, SImode,
2317 gen_lowpart (SImode, operands[1]),
2318 gen_lowpart (SImode, operands[2]));
2319 operands[6] = simplify_gen_binary (AND, SImode,
2320 gen_highpart (SImode, operands[1]),
2321 gen_highpart_mode (SImode, DImode, operands[2]));
2324 [(set_attr "type" "neon_logic,neon_logic,multiple,multiple,\
2325 multiple,multiple,neon_logic,neon_logic")
2326 (set_attr "arch" "neon_for_64bits,neon_for_64bits,*,*,*,*,
2327 avoid_neon_for_64bits,avoid_neon_for_64bits")
2328 (set_attr "length" "*,*,8,8,8,8,*,*")
2332 (define_insn_and_split "*anddi_zesidi_di"
2333 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
2334 (and:DI (zero_extend:DI
2335 (match_operand:SI 2 "s_register_operand" "r,r"))
2336 (match_operand:DI 1 "s_register_operand" "0,r")))]
2339 "TARGET_32BIT && reload_completed"
2340 ; The zero extend of operand 2 clears the high word of the output
2342 [(set (match_dup 0) (and:SI (match_dup 1) (match_dup 2)))
2343 (set (match_dup 3) (const_int 0))]
2346 operands[3] = gen_highpart (SImode, operands[0]);
2347 operands[0] = gen_lowpart (SImode, operands[0]);
2348 operands[1] = gen_lowpart (SImode, operands[1]);
2350 [(set_attr "length" "8")
2351 (set_attr "type" "multiple")]
2354 (define_insn "*anddi_sesdi_di"
2355 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
2356 (and:DI (sign_extend:DI
2357 (match_operand:SI 2 "s_register_operand" "r,r"))
2358 (match_operand:DI 1 "s_register_operand" "0,r")))]
2361 [(set_attr "length" "8")
2362 (set_attr "type" "multiple")]
2365 (define_expand "andsi3"
2366 [(set (match_operand:SI 0 "s_register_operand" "")
2367 (and:SI (match_operand:SI 1 "s_register_operand" "")
2368 (match_operand:SI 2 "reg_or_int_operand" "")))]
2373 if (CONST_INT_P (operands[2]))
2375 if (INTVAL (operands[2]) == 255 && arm_arch6)
2377 operands[1] = convert_to_mode (QImode, operands[1], 1);
2378 emit_insn (gen_thumb2_zero_extendqisi2_v6 (operands[0],
2382 else if (DONT_EARLY_SPLIT_CONSTANT (INTVAL (operands[2]), AND))
2383 operands[2] = force_reg (SImode, operands[2]);
2386 arm_split_constant (AND, SImode, NULL_RTX,
2387 INTVAL (operands[2]), operands[0],
2389 optimize && can_create_pseudo_p ());
2395 else /* TARGET_THUMB1 */
2397 if (!CONST_INT_P (operands[2]))
2399 rtx tmp = force_reg (SImode, operands[2]);
2400 if (rtx_equal_p (operands[0], operands[1]))
2404 operands[2] = operands[1];
2412 if (((unsigned HOST_WIDE_INT) ~INTVAL (operands[2])) < 256)
2414 operands[2] = force_reg (SImode,
2415 GEN_INT (~INTVAL (operands[2])));
2417 emit_insn (gen_thumb1_bicsi3 (operands[0], operands[2], operands[1]));
2422 for (i = 9; i <= 31; i++)
2424 if ((HOST_WIDE_INT_1 << i) - 1 == INTVAL (operands[2]))
2426 emit_insn (gen_extzv (operands[0], operands[1], GEN_INT (i),
2430 else if ((HOST_WIDE_INT_1 << i) - 1
2431 == ~INTVAL (operands[2]))
2433 rtx shift = GEN_INT (i);
2434 rtx reg = gen_reg_rtx (SImode);
2436 emit_insn (gen_lshrsi3 (reg, operands[1], shift));
2437 emit_insn (gen_ashlsi3 (operands[0], reg, shift));
2443 operands[2] = force_reg (SImode, operands[2]);
2449 ; ??? Check split length for Thumb-2
2450 (define_insn_and_split "*arm_andsi3_insn"
2451 [(set (match_operand:SI 0 "s_register_operand" "=r,l,r,r,r")
2452 (and:SI (match_operand:SI 1 "s_register_operand" "%r,0,r,r,r")
2453 (match_operand:SI 2 "reg_or_int_operand" "I,l,K,r,?n")))]
2458 bic%?\\t%0, %1, #%B2
2462 && CONST_INT_P (operands[2])
2463 && !(const_ok_for_arm (INTVAL (operands[2]))
2464 || const_ok_for_arm (~INTVAL (operands[2])))"
2465 [(clobber (const_int 0))]
2467 arm_split_constant (AND, SImode, curr_insn,
2468 INTVAL (operands[2]), operands[0], operands[1], 0);
2471 [(set_attr "length" "4,4,4,4,16")
2472 (set_attr "predicable" "yes")
2473 (set_attr "predicable_short_it" "no,yes,no,no,no")
2474 (set_attr "type" "logic_imm,logic_imm,logic_reg,logic_reg,logic_imm")]
2477 (define_insn "*andsi3_compare0"
2478 [(set (reg:CC_NOOV CC_REGNUM)
2480 (and:SI (match_operand:SI 1 "s_register_operand" "r,r,r")
2481 (match_operand:SI 2 "arm_not_operand" "I,K,r"))
2483 (set (match_operand:SI 0 "s_register_operand" "=r,r,r")
2484 (and:SI (match_dup 1) (match_dup 2)))]
2488 bics%?\\t%0, %1, #%B2
2489 ands%?\\t%0, %1, %2"
2490 [(set_attr "conds" "set")
2491 (set_attr "type" "logics_imm,logics_imm,logics_reg")]
2494 (define_insn "*andsi3_compare0_scratch"
2495 [(set (reg:CC_NOOV CC_REGNUM)
2497 (and:SI (match_operand:SI 0 "s_register_operand" "r,r,r")
2498 (match_operand:SI 1 "arm_not_operand" "I,K,r"))
2500 (clobber (match_scratch:SI 2 "=X,r,X"))]
2504 bics%?\\t%2, %0, #%B1
2506 [(set_attr "conds" "set")
2507 (set_attr "type" "logics_imm,logics_imm,logics_reg")]
2510 (define_insn "*zeroextractsi_compare0_scratch"
2511 [(set (reg:CC_NOOV CC_REGNUM)
2512 (compare:CC_NOOV (zero_extract:SI
2513 (match_operand:SI 0 "s_register_operand" "r")
2514 (match_operand 1 "const_int_operand" "n")
2515 (match_operand 2 "const_int_operand" "n"))
2518 && (INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) < 32
2519 && INTVAL (operands[1]) > 0
2520 && INTVAL (operands[1]) + (INTVAL (operands[2]) & 1) <= 8
2521 && INTVAL (operands[1]) + INTVAL (operands[2]) <= 32)"
2523 operands[1] = GEN_INT (((1 << INTVAL (operands[1])) - 1)
2524 << INTVAL (operands[2]));
2525 output_asm_insn (\"tst%?\\t%0, %1\", operands);
2528 [(set_attr "conds" "set")
2529 (set_attr "predicable" "yes")
2530 (set_attr "type" "logics_imm")]
2533 (define_insn_and_split "*ne_zeroextractsi"
2534 [(set (match_operand:SI 0 "s_register_operand" "=r")
2535 (ne:SI (zero_extract:SI
2536 (match_operand:SI 1 "s_register_operand" "r")
2537 (match_operand:SI 2 "const_int_operand" "n")
2538 (match_operand:SI 3 "const_int_operand" "n"))
2540 (clobber (reg:CC CC_REGNUM))]
2542 && (INTVAL (operands[3]) >= 0 && INTVAL (operands[3]) < 32
2543 && INTVAL (operands[2]) > 0
2544 && INTVAL (operands[2]) + (INTVAL (operands[3]) & 1) <= 8
2545 && INTVAL (operands[2]) + INTVAL (operands[3]) <= 32)"
2548 && (INTVAL (operands[3]) >= 0 && INTVAL (operands[3]) < 32
2549 && INTVAL (operands[2]) > 0
2550 && INTVAL (operands[2]) + (INTVAL (operands[3]) & 1) <= 8
2551 && INTVAL (operands[2]) + INTVAL (operands[3]) <= 32)"
2552 [(parallel [(set (reg:CC_NOOV CC_REGNUM)
2553 (compare:CC_NOOV (and:SI (match_dup 1) (match_dup 2))
2555 (set (match_dup 0) (and:SI (match_dup 1) (match_dup 2)))])
2557 (if_then_else:SI (eq (reg:CC_NOOV CC_REGNUM) (const_int 0))
2558 (match_dup 0) (const_int 1)))]
2560 operands[2] = GEN_INT (((1 << INTVAL (operands[2])) - 1)
2561 << INTVAL (operands[3]));
2563 [(set_attr "conds" "clob")
2564 (set (attr "length")
2565 (if_then_else (eq_attr "is_thumb" "yes")
2568 (set_attr "type" "multiple")]
2571 (define_insn_and_split "*ne_zeroextractsi_shifted"
2572 [(set (match_operand:SI 0 "s_register_operand" "=r")
2573 (ne:SI (zero_extract:SI
2574 (match_operand:SI 1 "s_register_operand" "r")
2575 (match_operand:SI 2 "const_int_operand" "n")
2578 (clobber (reg:CC CC_REGNUM))]
2582 [(parallel [(set (reg:CC_NOOV CC_REGNUM)
2583 (compare:CC_NOOV (ashift:SI (match_dup 1) (match_dup 2))
2585 (set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 2)))])
2587 (if_then_else:SI (eq (reg:CC_NOOV CC_REGNUM) (const_int 0))
2588 (match_dup 0) (const_int 1)))]
2590 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
2592 [(set_attr "conds" "clob")
2593 (set_attr "length" "8")
2594 (set_attr "type" "multiple")]
2597 (define_insn_and_split "*ite_ne_zeroextractsi"
2598 [(set (match_operand:SI 0 "s_register_operand" "=r")
2599 (if_then_else:SI (ne (zero_extract:SI
2600 (match_operand:SI 1 "s_register_operand" "r")
2601 (match_operand:SI 2 "const_int_operand" "n")
2602 (match_operand:SI 3 "const_int_operand" "n"))
2604 (match_operand:SI 4 "arm_not_operand" "rIK")
2606 (clobber (reg:CC CC_REGNUM))]
2608 && (INTVAL (operands[3]) >= 0 && INTVAL (operands[3]) < 32
2609 && INTVAL (operands[2]) > 0
2610 && INTVAL (operands[2]) + (INTVAL (operands[3]) & 1) <= 8
2611 && INTVAL (operands[2]) + INTVAL (operands[3]) <= 32)
2612 && !reg_overlap_mentioned_p (operands[0], operands[4])"
2615 && (INTVAL (operands[3]) >= 0 && INTVAL (operands[3]) < 32
2616 && INTVAL (operands[2]) > 0
2617 && INTVAL (operands[2]) + (INTVAL (operands[3]) & 1) <= 8
2618 && INTVAL (operands[2]) + INTVAL (operands[3]) <= 32)
2619 && !reg_overlap_mentioned_p (operands[0], operands[4])"
2620 [(parallel [(set (reg:CC_NOOV CC_REGNUM)
2621 (compare:CC_NOOV (and:SI (match_dup 1) (match_dup 2))
2623 (set (match_dup 0) (and:SI (match_dup 1) (match_dup 2)))])
2625 (if_then_else:SI (eq (reg:CC_NOOV CC_REGNUM) (const_int 0))
2626 (match_dup 0) (match_dup 4)))]
2628 operands[2] = GEN_INT (((1 << INTVAL (operands[2])) - 1)
2629 << INTVAL (operands[3]));
2631 [(set_attr "conds" "clob")
2632 (set_attr "length" "8")
2633 (set_attr "type" "multiple")]
2636 (define_insn_and_split "*ite_ne_zeroextractsi_shifted"
2637 [(set (match_operand:SI 0 "s_register_operand" "=r")
2638 (if_then_else:SI (ne (zero_extract:SI
2639 (match_operand:SI 1 "s_register_operand" "r")
2640 (match_operand:SI 2 "const_int_operand" "n")
2643 (match_operand:SI 3 "arm_not_operand" "rIK")
2645 (clobber (reg:CC CC_REGNUM))]
2646 "TARGET_ARM && !reg_overlap_mentioned_p (operands[0], operands[3])"
2648 "TARGET_ARM && !reg_overlap_mentioned_p (operands[0], operands[3])"
2649 [(parallel [(set (reg:CC_NOOV CC_REGNUM)
2650 (compare:CC_NOOV (ashift:SI (match_dup 1) (match_dup 2))
2652 (set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 2)))])
2654 (if_then_else:SI (eq (reg:CC_NOOV CC_REGNUM) (const_int 0))
2655 (match_dup 0) (match_dup 3)))]
2657 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
2659 [(set_attr "conds" "clob")
2660 (set_attr "length" "8")
2661 (set_attr "type" "multiple")]
2664 ;; ??? Use Thumb-2 has bitfield insert/extract instructions.
2666 [(set (match_operand:SI 0 "s_register_operand" "")
2667 (match_operator:SI 1 "shiftable_operator"
2668 [(zero_extract:SI (match_operand:SI 2 "s_register_operand" "")
2669 (match_operand:SI 3 "const_int_operand" "")
2670 (match_operand:SI 4 "const_int_operand" ""))
2671 (match_operand:SI 5 "s_register_operand" "")]))
2672 (clobber (match_operand:SI 6 "s_register_operand" ""))]
2674 [(set (match_dup 6) (ashift:SI (match_dup 2) (match_dup 3)))
2677 [(lshiftrt:SI (match_dup 6) (match_dup 4))
2680 HOST_WIDE_INT temp = INTVAL (operands[3]);
2682 operands[3] = GEN_INT (32 - temp - INTVAL (operands[4]));
2683 operands[4] = GEN_INT (32 - temp);
2688 [(set (match_operand:SI 0 "s_register_operand" "")
2689 (match_operator:SI 1 "shiftable_operator"
2690 [(sign_extract:SI (match_operand:SI 2 "s_register_operand" "")
2691 (match_operand:SI 3 "const_int_operand" "")
2692 (match_operand:SI 4 "const_int_operand" ""))
2693 (match_operand:SI 5 "s_register_operand" "")]))
2694 (clobber (match_operand:SI 6 "s_register_operand" ""))]
2696 [(set (match_dup 6) (ashift:SI (match_dup 2) (match_dup 3)))
2699 [(ashiftrt:SI (match_dup 6) (match_dup 4))
2702 HOST_WIDE_INT temp = INTVAL (operands[3]);
2704 operands[3] = GEN_INT (32 - temp - INTVAL (operands[4]));
2705 operands[4] = GEN_INT (32 - temp);
2709 ;;; ??? This pattern is bogus. If operand3 has bits outside the range
2710 ;;; represented by the bitfield, then this will produce incorrect results.
2711 ;;; Somewhere, the value needs to be truncated. On targets like the m68k,
2712 ;;; which have a real bit-field insert instruction, the truncation happens
2713 ;;; in the bit-field insert instruction itself. Since arm does not have a
2714 ;;; bit-field insert instruction, we would have to emit code here to truncate
2715 ;;; the value before we insert. This loses some of the advantage of having
2716 ;;; this insv pattern, so this pattern needs to be reevalutated.
2718 (define_expand "insv"
2719 [(set (zero_extract (match_operand 0 "nonimmediate_operand" "")
2720 (match_operand 1 "general_operand" "")
2721 (match_operand 2 "general_operand" ""))
2722 (match_operand 3 "reg_or_int_operand" ""))]
2723 "TARGET_ARM || arm_arch_thumb2"
2726 int start_bit = INTVAL (operands[2]);
2727 int width = INTVAL (operands[1]);
2728 HOST_WIDE_INT mask = (HOST_WIDE_INT_1 << width) - 1;
2729 rtx target, subtarget;
2731 if (arm_arch_thumb2)
2733 if (unaligned_access && MEM_P (operands[0])
2734 && s_register_operand (operands[3], GET_MODE (operands[3]))
2735 && (width == 16 || width == 32) && (start_bit % BITS_PER_UNIT) == 0)
2739 if (BYTES_BIG_ENDIAN)
2740 start_bit = GET_MODE_BITSIZE (GET_MODE (operands[3])) - width
2745 base_addr = adjust_address (operands[0], SImode,
2746 start_bit / BITS_PER_UNIT);
2747 emit_insn (gen_unaligned_storesi (base_addr, operands[3]));
2751 rtx tmp = gen_reg_rtx (HImode);
2753 base_addr = adjust_address (operands[0], HImode,
2754 start_bit / BITS_PER_UNIT);
2755 emit_move_insn (tmp, gen_lowpart (HImode, operands[3]));
2756 emit_insn (gen_unaligned_storehi (base_addr, tmp));
2760 else if (s_register_operand (operands[0], GET_MODE (operands[0])))
2762 bool use_bfi = TRUE;
2764 if (CONST_INT_P (operands[3]))
2766 HOST_WIDE_INT val = INTVAL (operands[3]) & mask;
2770 emit_insn (gen_insv_zero (operands[0], operands[1],
2775 /* See if the set can be done with a single orr instruction. */
2776 if (val == mask && const_ok_for_arm (val << start_bit))
2782 if (!REG_P (operands[3]))
2783 operands[3] = force_reg (SImode, operands[3]);
2785 emit_insn (gen_insv_t2 (operands[0], operands[1], operands[2],
2794 if (!s_register_operand (operands[0], GET_MODE (operands[0])))
2797 target = copy_rtx (operands[0]);
2798 /* Avoid using a subreg as a subtarget, and avoid writing a paradoxical
2799 subreg as the final target. */
2800 if (GET_CODE (target) == SUBREG)
2802 subtarget = gen_reg_rtx (SImode);
2803 if (GET_MODE_SIZE (GET_MODE (SUBREG_REG (target)))
2804 < GET_MODE_SIZE (SImode))
2805 target = SUBREG_REG (target);
2810 if (CONST_INT_P (operands[3]))
2812 /* Since we are inserting a known constant, we may be able to
2813 reduce the number of bits that we have to clear so that
2814 the mask becomes simple. */
2815 /* ??? This code does not check to see if the new mask is actually
2816 simpler. It may not be. */
2817 rtx op1 = gen_reg_rtx (SImode);
2818 /* ??? Truncate operand3 to fit in the bitfield. See comment before
2819 start of this pattern. */
2820 HOST_WIDE_INT op3_value = mask & INTVAL (operands[3]);
2821 HOST_WIDE_INT mask2 = ((mask & ~op3_value) << start_bit);
2823 emit_insn (gen_andsi3 (op1, operands[0],
2824 gen_int_mode (~mask2, SImode)));
2825 emit_insn (gen_iorsi3 (subtarget, op1,
2826 gen_int_mode (op3_value << start_bit, SImode)));
2828 else if (start_bit == 0
2829 && !(const_ok_for_arm (mask)
2830 || const_ok_for_arm (~mask)))
2832 /* A Trick, since we are setting the bottom bits in the word,
2833 we can shift operand[3] up, operand[0] down, OR them together
2834 and rotate the result back again. This takes 3 insns, and
2835 the third might be mergeable into another op. */
2836 /* The shift up copes with the possibility that operand[3] is
2837 wider than the bitfield. */
2838 rtx op0 = gen_reg_rtx (SImode);
2839 rtx op1 = gen_reg_rtx (SImode);
2841 emit_insn (gen_ashlsi3 (op0, operands[3], GEN_INT (32 - width)));
2842 emit_insn (gen_lshrsi3 (op1, operands[0], operands[1]));
2843 emit_insn (gen_iorsi3 (op1, op1, op0));
2844 emit_insn (gen_rotlsi3 (subtarget, op1, operands[1]));
2846 else if ((width + start_bit == 32)
2847 && !(const_ok_for_arm (mask)
2848 || const_ok_for_arm (~mask)))
2850 /* Similar trick, but slightly less efficient. */
2852 rtx op0 = gen_reg_rtx (SImode);
2853 rtx op1 = gen_reg_rtx (SImode);
2855 emit_insn (gen_ashlsi3 (op0, operands[3], GEN_INT (32 - width)));
2856 emit_insn (gen_ashlsi3 (op1, operands[0], operands[1]));
2857 emit_insn (gen_lshrsi3 (op1, op1, operands[1]));
2858 emit_insn (gen_iorsi3 (subtarget, op1, op0));
2862 rtx op0 = gen_int_mode (mask, SImode);
2863 rtx op1 = gen_reg_rtx (SImode);
2864 rtx op2 = gen_reg_rtx (SImode);
2866 if (!(const_ok_for_arm (mask) || const_ok_for_arm (~mask)))
2868 rtx tmp = gen_reg_rtx (SImode);
2870 emit_insn (gen_movsi (tmp, op0));
2874 /* Mask out any bits in operand[3] that are not needed. */
2875 emit_insn (gen_andsi3 (op1, operands[3], op0));
2877 if (CONST_INT_P (op0)
2878 && (const_ok_for_arm (mask << start_bit)
2879 || const_ok_for_arm (~(mask << start_bit))))
2881 op0 = gen_int_mode (~(mask << start_bit), SImode);
2882 emit_insn (gen_andsi3 (op2, operands[0], op0));
2886 if (CONST_INT_P (op0))
2888 rtx tmp = gen_reg_rtx (SImode);
2890 emit_insn (gen_movsi (tmp, op0));
2895 emit_insn (gen_ashlsi3 (op0, op0, operands[2]));
2897 emit_insn (gen_andsi_notsi_si (op2, operands[0], op0));
2901 emit_insn (gen_ashlsi3 (op1, op1, operands[2]));
2903 emit_insn (gen_iorsi3 (subtarget, op1, op2));
2906 if (subtarget != target)
2908 /* If TARGET is still a SUBREG, then it must be wider than a word,
2909 so we must be careful only to set the subword we were asked to. */
2910 if (GET_CODE (target) == SUBREG)
2911 emit_move_insn (target, subtarget);
2913 emit_move_insn (target, gen_lowpart (GET_MODE (target), subtarget));
2920 (define_insn "insv_zero"
2921 [(set (zero_extract:SI (match_operand:SI 0 "s_register_operand" "+r")
2922 (match_operand:SI 1 "const_int_M_operand" "M")
2923 (match_operand:SI 2 "const_int_M_operand" "M"))
2927 [(set_attr "length" "4")
2928 (set_attr "predicable" "yes")
2929 (set_attr "type" "bfm")]
2932 (define_insn "insv_t2"
2933 [(set (zero_extract:SI (match_operand:SI 0 "s_register_operand" "+r")
2934 (match_operand:SI 1 "const_int_M_operand" "M")
2935 (match_operand:SI 2 "const_int_M_operand" "M"))
2936 (match_operand:SI 3 "s_register_operand" "r"))]
2938 "bfi%?\t%0, %3, %2, %1"
2939 [(set_attr "length" "4")
2940 (set_attr "predicable" "yes")
2941 (set_attr "type" "bfm")]
2944 ; constants for op 2 will never be given to these patterns.
2945 (define_insn_and_split "*anddi_notdi_di"
2946 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
2947 (and:DI (not:DI (match_operand:DI 1 "s_register_operand" "0,r"))
2948 (match_operand:DI 2 "s_register_operand" "r,0")))]
2951 "TARGET_32BIT && reload_completed
2952 && ! (TARGET_NEON && IS_VFP_REGNUM (REGNO (operands[0])))
2953 && ! IS_IWMMXT_REGNUM (REGNO (operands[0]))"
2954 [(set (match_dup 0) (and:SI (not:SI (match_dup 1)) (match_dup 2)))
2955 (set (match_dup 3) (and:SI (not:SI (match_dup 4)) (match_dup 5)))]
2958 operands[3] = gen_highpart (SImode, operands[0]);
2959 operands[0] = gen_lowpart (SImode, operands[0]);
2960 operands[4] = gen_highpart (SImode, operands[1]);
2961 operands[1] = gen_lowpart (SImode, operands[1]);
2962 operands[5] = gen_highpart (SImode, operands[2]);
2963 operands[2] = gen_lowpart (SImode, operands[2]);
2965 [(set_attr "length" "8")
2966 (set_attr "predicable" "yes")
2967 (set_attr "type" "multiple")]
2970 (define_insn_and_split "*anddi_notzesidi_di"
2971 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
2972 (and:DI (not:DI (zero_extend:DI
2973 (match_operand:SI 2 "s_register_operand" "r,r")))
2974 (match_operand:DI 1 "s_register_operand" "0,?r")))]
2977 bic%?\\t%Q0, %Q1, %2
2979 ; (not (zero_extend ...)) allows us to just copy the high word from
2980 ; operand1 to operand0.
2983 && operands[0] != operands[1]"
2984 [(set (match_dup 0) (and:SI (not:SI (match_dup 2)) (match_dup 1)))
2985 (set (match_dup 3) (match_dup 4))]
2988 operands[3] = gen_highpart (SImode, operands[0]);
2989 operands[0] = gen_lowpart (SImode, operands[0]);
2990 operands[4] = gen_highpart (SImode, operands[1]);
2991 operands[1] = gen_lowpart (SImode, operands[1]);
2993 [(set_attr "length" "4,8")
2994 (set_attr "predicable" "yes")
2995 (set_attr "type" "multiple")]
2998 (define_insn_and_split "*anddi_notdi_zesidi"
2999 [(set (match_operand:DI 0 "s_register_operand" "=r")
3000 (and:DI (not:DI (match_operand:DI 2 "s_register_operand" "r"))
3002 (match_operand:SI 1 "s_register_operand" "r"))))]
3005 "TARGET_32BIT && reload_completed"
3006 [(set (match_dup 0) (and:SI (not:SI (match_dup 2)) (match_dup 1)))
3007 (set (match_dup 3) (const_int 0))]
3010 operands[3] = gen_highpart (SImode, operands[0]);
3011 operands[0] = gen_lowpart (SImode, operands[0]);
3012 operands[2] = gen_lowpart (SImode, operands[2]);
3014 [(set_attr "length" "8")
3015 (set_attr "predicable" "yes")
3016 (set_attr "type" "multiple")]
3019 (define_insn_and_split "*anddi_notsesidi_di"
3020 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
3021 (and:DI (not:DI (sign_extend:DI
3022 (match_operand:SI 2 "s_register_operand" "r,r")))
3023 (match_operand:DI 1 "s_register_operand" "0,r")))]
3026 "TARGET_32BIT && reload_completed"
3027 [(set (match_dup 0) (and:SI (not:SI (match_dup 2)) (match_dup 1)))
3028 (set (match_dup 3) (and:SI (not:SI
3029 (ashiftrt:SI (match_dup 2) (const_int 31)))
3033 operands[3] = gen_highpart (SImode, operands[0]);
3034 operands[0] = gen_lowpart (SImode, operands[0]);
3035 operands[4] = gen_highpart (SImode, operands[1]);
3036 operands[1] = gen_lowpart (SImode, operands[1]);
3038 [(set_attr "length" "8")
3039 (set_attr "predicable" "yes")
3040 (set_attr "type" "multiple")]
3043 (define_insn "andsi_notsi_si"
3044 [(set (match_operand:SI 0 "s_register_operand" "=r")
3045 (and:SI (not:SI (match_operand:SI 2 "s_register_operand" "r"))
3046 (match_operand:SI 1 "s_register_operand" "r")))]
3048 "bic%?\\t%0, %1, %2"
3049 [(set_attr "predicable" "yes")
3050 (set_attr "type" "logic_reg")]
3053 (define_insn "andsi_not_shiftsi_si"
3054 [(set (match_operand:SI 0 "s_register_operand" "=r")
3055 (and:SI (not:SI (match_operator:SI 4 "shift_operator"
3056 [(match_operand:SI 2 "s_register_operand" "r")
3057 (match_operand:SI 3 "arm_rhs_operand" "rM")]))
3058 (match_operand:SI 1 "s_register_operand" "r")))]
3060 "bic%?\\t%0, %1, %2%S4"
3061 [(set_attr "predicable" "yes")
3062 (set_attr "shift" "2")
3063 (set (attr "type") (if_then_else (match_operand 3 "const_int_operand" "")
3064 (const_string "logic_shift_imm")
3065 (const_string "logic_shift_reg")))]
3068 ;; Shifted bics pattern used to set up CC status register and not reusing
3069 ;; bics output. Pattern restricts Thumb2 shift operand as bics for Thumb2
3070 ;; does not support shift by register.
3071 (define_insn "andsi_not_shiftsi_si_scc_no_reuse"
3072 [(set (reg:CC_NOOV CC_REGNUM)
3074 (and:SI (not:SI (match_operator:SI 0 "shift_operator"
3075 [(match_operand:SI 1 "s_register_operand" "r")
3076 (match_operand:SI 2 "arm_rhs_operand" "rM")]))
3077 (match_operand:SI 3 "s_register_operand" "r"))
3079 (clobber (match_scratch:SI 4 "=r"))]
3080 "TARGET_ARM || (TARGET_THUMB2 && CONST_INT_P (operands[2]))"
3081 "bics%?\\t%4, %3, %1%S0"
3082 [(set_attr "predicable" "yes")
3083 (set_attr "conds" "set")
3084 (set_attr "shift" "1")
3085 (set (attr "type") (if_then_else (match_operand 2 "const_int_operand" "")
3086 (const_string "logic_shift_imm")
3087 (const_string "logic_shift_reg")))]
3090 ;; Same as andsi_not_shiftsi_si_scc_no_reuse, but the bics result is also
3091 ;; getting reused later.
3092 (define_insn "andsi_not_shiftsi_si_scc"
3093 [(parallel [(set (reg:CC_NOOV CC_REGNUM)
3095 (and:SI (not:SI (match_operator:SI 0 "shift_operator"
3096 [(match_operand:SI 1 "s_register_operand" "r")
3097 (match_operand:SI 2 "arm_rhs_operand" "rM")]))
3098 (match_operand:SI 3 "s_register_operand" "r"))
3100 (set (match_operand:SI 4 "s_register_operand" "=r")
3101 (and:SI (not:SI (match_op_dup 0
3105 "TARGET_ARM || (TARGET_THUMB2 && CONST_INT_P (operands[2]))"
3106 "bics%?\\t%4, %3, %1%S0"
3107 [(set_attr "predicable" "yes")
3108 (set_attr "conds" "set")
3109 (set_attr "shift" "1")
3110 (set (attr "type") (if_then_else (match_operand 2 "const_int_operand" "")
3111 (const_string "logic_shift_imm")
3112 (const_string "logic_shift_reg")))]
3115 (define_insn "*andsi_notsi_si_compare0"
3116 [(set (reg:CC_NOOV CC_REGNUM)
3118 (and:SI (not:SI (match_operand:SI 2 "s_register_operand" "r"))
3119 (match_operand:SI 1 "s_register_operand" "r"))
3121 (set (match_operand:SI 0 "s_register_operand" "=r")
3122 (and:SI (not:SI (match_dup 2)) (match_dup 1)))]
3125 [(set_attr "conds" "set")
3126 (set_attr "type" "logics_shift_reg")]
3129 (define_insn "*andsi_notsi_si_compare0_scratch"
3130 [(set (reg:CC_NOOV CC_REGNUM)
3132 (and:SI (not:SI (match_operand:SI 2 "s_register_operand" "r"))
3133 (match_operand:SI 1 "s_register_operand" "r"))
3135 (clobber (match_scratch:SI 0 "=r"))]
3138 [(set_attr "conds" "set")
3139 (set_attr "type" "logics_shift_reg")]
3142 (define_expand "iordi3"
3143 [(set (match_operand:DI 0 "s_register_operand" "")
3144 (ior:DI (match_operand:DI 1 "s_register_operand" "")
3145 (match_operand:DI 2 "neon_logic_op2" "")))]
3148 if (!TARGET_NEON && !TARGET_IWMMXT)
3150 rtx low = simplify_gen_binary (IOR, SImode,
3151 gen_lowpart (SImode, operands[1]),
3152 gen_lowpart (SImode, operands[2]));
3153 rtx high = simplify_gen_binary (IOR, SImode,
3154 gen_highpart (SImode, operands[1]),
3155 gen_highpart_mode (SImode, DImode,
3158 emit_insn (gen_rtx_SET (gen_lowpart (SImode, operands[0]), low));
3159 emit_insn (gen_rtx_SET (gen_highpart (SImode, operands[0]), high));
3163 /* Otherwise expand pattern as above. */
3167 (define_insn_and_split "*iordi3_insn"
3168 [(set (match_operand:DI 0 "s_register_operand" "=w,w ,&r,&r,&r,&r,?w,?w")
3169 (ior:DI (match_operand:DI 1 "s_register_operand" "%w,0 ,0 ,r ,0 ,r ,w ,0")
3170 (match_operand:DI 2 "arm_iordi_operand_neon" "w ,Dl,r ,r ,Df,Df,w ,Dl")))]
3171 "TARGET_32BIT && !TARGET_IWMMXT"
3173 switch (which_alternative)
3175 case 0: /* fall through */
3176 case 6: return "vorr\t%P0, %P1, %P2";
3177 case 1: /* fall through */
3178 case 7: return neon_output_logic_immediate ("vorr", &operands[2],
3179 DImode, 0, VALID_NEON_QREG_MODE (DImode));
3185 default: gcc_unreachable ();
3188 "TARGET_32BIT && !TARGET_IWMMXT && reload_completed
3189 && !(IS_VFP_REGNUM (REGNO (operands[0])))"
3190 [(set (match_dup 3) (match_dup 4))
3191 (set (match_dup 5) (match_dup 6))]
3194 operands[3] = gen_lowpart (SImode, operands[0]);
3195 operands[5] = gen_highpart (SImode, operands[0]);
3197 operands[4] = simplify_gen_binary (IOR, SImode,
3198 gen_lowpart (SImode, operands[1]),
3199 gen_lowpart (SImode, operands[2]));
3200 operands[6] = simplify_gen_binary (IOR, SImode,
3201 gen_highpart (SImode, operands[1]),
3202 gen_highpart_mode (SImode, DImode, operands[2]));
3205 [(set_attr "type" "neon_logic,neon_logic,multiple,multiple,multiple,\
3206 multiple,neon_logic,neon_logic")
3207 (set_attr "length" "*,*,8,8,8,8,*,*")
3208 (set_attr "arch" "neon_for_64bits,neon_for_64bits,*,*,*,*,avoid_neon_for_64bits,avoid_neon_for_64bits")]
3211 (define_insn "*iordi_zesidi_di"
3212 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
3213 (ior:DI (zero_extend:DI
3214 (match_operand:SI 2 "s_register_operand" "r,r"))
3215 (match_operand:DI 1 "s_register_operand" "0,?r")))]
3218 orr%?\\t%Q0, %Q1, %2
3220 [(set_attr "length" "4,8")
3221 (set_attr "predicable" "yes")
3222 (set_attr "type" "logic_reg,multiple")]
3225 (define_insn "*iordi_sesidi_di"
3226 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
3227 (ior:DI (sign_extend:DI
3228 (match_operand:SI 2 "s_register_operand" "r,r"))
3229 (match_operand:DI 1 "s_register_operand" "0,r")))]
3232 [(set_attr "length" "8")
3233 (set_attr "predicable" "yes")
3234 (set_attr "type" "multiple")]
3237 (define_expand "iorsi3"
3238 [(set (match_operand:SI 0 "s_register_operand" "")
3239 (ior:SI (match_operand:SI 1 "s_register_operand" "")
3240 (match_operand:SI 2 "reg_or_int_operand" "")))]
3243 if (CONST_INT_P (operands[2]))
3247 if (DONT_EARLY_SPLIT_CONSTANT (INTVAL (operands[2]), IOR))
3248 operands[2] = force_reg (SImode, operands[2]);
3251 arm_split_constant (IOR, SImode, NULL_RTX,
3252 INTVAL (operands[2]), operands[0],
3254 optimize && can_create_pseudo_p ());
3258 else /* TARGET_THUMB1 */
3260 rtx tmp = force_reg (SImode, operands[2]);
3261 if (rtx_equal_p (operands[0], operands[1]))
3265 operands[2] = operands[1];
3273 (define_insn_and_split "*iorsi3_insn"
3274 [(set (match_operand:SI 0 "s_register_operand" "=r,l,r,r,r")
3275 (ior:SI (match_operand:SI 1 "s_register_operand" "%r,0,r,r,r")
3276 (match_operand:SI 2 "reg_or_int_operand" "I,l,K,r,?n")))]
3281 orn%?\\t%0, %1, #%B2
3285 && CONST_INT_P (operands[2])
3286 && !(const_ok_for_arm (INTVAL (operands[2]))
3287 || (TARGET_THUMB2 && const_ok_for_arm (~INTVAL (operands[2]))))"
3288 [(clobber (const_int 0))]
3290 arm_split_constant (IOR, SImode, curr_insn,
3291 INTVAL (operands[2]), operands[0], operands[1], 0);
3294 [(set_attr "length" "4,4,4,4,16")
3295 (set_attr "arch" "32,t2,t2,32,32")
3296 (set_attr "predicable" "yes")
3297 (set_attr "predicable_short_it" "no,yes,no,no,no")
3298 (set_attr "type" "logic_imm,logic_reg,logic_imm,logic_reg,logic_reg")]
3302 [(match_scratch:SI 3 "r")
3303 (set (match_operand:SI 0 "arm_general_register_operand" "")
3304 (ior:SI (match_operand:SI 1 "arm_general_register_operand" "")
3305 (match_operand:SI 2 "const_int_operand" "")))]
3307 && !const_ok_for_arm (INTVAL (operands[2]))
3308 && const_ok_for_arm (~INTVAL (operands[2]))"
3309 [(set (match_dup 3) (match_dup 2))
3310 (set (match_dup 0) (ior:SI (match_dup 1) (match_dup 3)))]
3314 (define_insn "*iorsi3_compare0"
3315 [(set (reg:CC_NOOV CC_REGNUM)
3316 (compare:CC_NOOV (ior:SI (match_operand:SI 1 "s_register_operand" "%r,r")
3317 (match_operand:SI 2 "arm_rhs_operand" "I,r"))
3319 (set (match_operand:SI 0 "s_register_operand" "=r,r")
3320 (ior:SI (match_dup 1) (match_dup 2)))]
3322 "orrs%?\\t%0, %1, %2"
3323 [(set_attr "conds" "set")
3324 (set_attr "type" "logics_imm,logics_reg")]
3327 (define_insn "*iorsi3_compare0_scratch"
3328 [(set (reg:CC_NOOV CC_REGNUM)
3329 (compare:CC_NOOV (ior:SI (match_operand:SI 1 "s_register_operand" "%r,r")
3330 (match_operand:SI 2 "arm_rhs_operand" "I,r"))
3332 (clobber (match_scratch:SI 0 "=r,r"))]
3334 "orrs%?\\t%0, %1, %2"
3335 [(set_attr "conds" "set")
3336 (set_attr "type" "logics_imm,logics_reg")]
3339 (define_expand "xordi3"
3340 [(set (match_operand:DI 0 "s_register_operand" "")
3341 (xor:DI (match_operand:DI 1 "s_register_operand" "")
3342 (match_operand:DI 2 "arm_xordi_operand" "")))]
3345 /* The iWMMXt pattern for xordi3 accepts only register operands but we want
3346 to reuse this expander for all TARGET_32BIT targets so just force the
3347 constants into a register. Unlike for the anddi3 and iordi3 there are
3348 no NEON instructions that take an immediate. */
3349 if (TARGET_IWMMXT && !REG_P (operands[2]))
3350 operands[2] = force_reg (DImode, operands[2]);
3351 if (!TARGET_NEON && !TARGET_IWMMXT)
3353 rtx low = simplify_gen_binary (XOR, SImode,
3354 gen_lowpart (SImode, operands[1]),
3355 gen_lowpart (SImode, operands[2]));
3356 rtx high = simplify_gen_binary (XOR, SImode,
3357 gen_highpart (SImode, operands[1]),
3358 gen_highpart_mode (SImode, DImode,
3361 emit_insn (gen_rtx_SET (gen_lowpart (SImode, operands[0]), low));
3362 emit_insn (gen_rtx_SET (gen_highpart (SImode, operands[0]), high));
3366 /* Otherwise expand pattern as above. */
3370 (define_insn_and_split "*xordi3_insn"
3371 [(set (match_operand:DI 0 "s_register_operand" "=w,&r,&r,&r,&r,?w")
3372 (xor:DI (match_operand:DI 1 "s_register_operand" "%w ,0,r ,0 ,r ,w")
3373 (match_operand:DI 2 "arm_xordi_operand" "w ,r ,r ,Dg,Dg,w")))]
3374 "TARGET_32BIT && !TARGET_IWMMXT"
3376 switch (which_alternative)
3381 case 4: /* fall through */
3383 case 0: /* fall through */
3384 case 5: return "veor\t%P0, %P1, %P2";
3385 default: gcc_unreachable ();
3388 "TARGET_32BIT && !TARGET_IWMMXT && reload_completed
3389 && !(IS_VFP_REGNUM (REGNO (operands[0])))"
3390 [(set (match_dup 3) (match_dup 4))
3391 (set (match_dup 5) (match_dup 6))]
3394 operands[3] = gen_lowpart (SImode, operands[0]);
3395 operands[5] = gen_highpart (SImode, operands[0]);
3397 operands[4] = simplify_gen_binary (XOR, SImode,
3398 gen_lowpart (SImode, operands[1]),
3399 gen_lowpart (SImode, operands[2]));
3400 operands[6] = simplify_gen_binary (XOR, SImode,
3401 gen_highpart (SImode, operands[1]),
3402 gen_highpart_mode (SImode, DImode, operands[2]));
3405 [(set_attr "length" "*,8,8,8,8,*")
3406 (set_attr "type" "neon_logic,multiple,multiple,multiple,multiple,neon_logic")
3407 (set_attr "arch" "neon_for_64bits,*,*,*,*,avoid_neon_for_64bits")]
3410 (define_insn "*xordi_zesidi_di"
3411 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
3412 (xor:DI (zero_extend:DI
3413 (match_operand:SI 2 "s_register_operand" "r,r"))
3414 (match_operand:DI 1 "s_register_operand" "0,?r")))]
3417 eor%?\\t%Q0, %Q1, %2
3419 [(set_attr "length" "4,8")
3420 (set_attr "predicable" "yes")
3421 (set_attr "type" "logic_reg")]
3424 (define_insn "*xordi_sesidi_di"
3425 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
3426 (xor:DI (sign_extend:DI
3427 (match_operand:SI 2 "s_register_operand" "r,r"))
3428 (match_operand:DI 1 "s_register_operand" "0,r")))]
3431 [(set_attr "length" "8")
3432 (set_attr "predicable" "yes")
3433 (set_attr "type" "multiple")]
3436 (define_expand "xorsi3"
3437 [(set (match_operand:SI 0 "s_register_operand" "")
3438 (xor:SI (match_operand:SI 1 "s_register_operand" "")
3439 (match_operand:SI 2 "reg_or_int_operand" "")))]
3441 "if (CONST_INT_P (operands[2]))
3445 if (DONT_EARLY_SPLIT_CONSTANT (INTVAL (operands[2]), XOR))
3446 operands[2] = force_reg (SImode, operands[2]);
3449 arm_split_constant (XOR, SImode, NULL_RTX,
3450 INTVAL (operands[2]), operands[0],
3452 optimize && can_create_pseudo_p ());
3456 else /* TARGET_THUMB1 */
3458 rtx tmp = force_reg (SImode, operands[2]);
3459 if (rtx_equal_p (operands[0], operands[1]))
3463 operands[2] = operands[1];
3470 (define_insn_and_split "*arm_xorsi3"
3471 [(set (match_operand:SI 0 "s_register_operand" "=r,l,r,r")
3472 (xor:SI (match_operand:SI 1 "s_register_operand" "%r,0,r,r")
3473 (match_operand:SI 2 "reg_or_int_operand" "I,l,r,?n")))]
3481 && CONST_INT_P (operands[2])
3482 && !const_ok_for_arm (INTVAL (operands[2]))"
3483 [(clobber (const_int 0))]
3485 arm_split_constant (XOR, SImode, curr_insn,
3486 INTVAL (operands[2]), operands[0], operands[1], 0);
3489 [(set_attr "length" "4,4,4,16")
3490 (set_attr "predicable" "yes")
3491 (set_attr "predicable_short_it" "no,yes,no,no")
3492 (set_attr "type" "logic_imm,logic_reg,logic_reg,multiple")]
3495 (define_insn "*xorsi3_compare0"
3496 [(set (reg:CC_NOOV CC_REGNUM)
3497 (compare:CC_NOOV (xor:SI (match_operand:SI 1 "s_register_operand" "r,r")
3498 (match_operand:SI 2 "arm_rhs_operand" "I,r"))
3500 (set (match_operand:SI 0 "s_register_operand" "=r,r")
3501 (xor:SI (match_dup 1) (match_dup 2)))]
3503 "eors%?\\t%0, %1, %2"
3504 [(set_attr "conds" "set")
3505 (set_attr "type" "logics_imm,logics_reg")]
3508 (define_insn "*xorsi3_compare0_scratch"
3509 [(set (reg:CC_NOOV CC_REGNUM)
3510 (compare:CC_NOOV (xor:SI (match_operand:SI 0 "s_register_operand" "r,r")
3511 (match_operand:SI 1 "arm_rhs_operand" "I,r"))
3515 [(set_attr "conds" "set")
3516 (set_attr "type" "logics_imm,logics_reg")]
3519 ; By splitting (IOR (AND (NOT A) (NOT B)) C) as D = AND (IOR A B) (NOT C),
3520 ; (NOT D) we can sometimes merge the final NOT into one of the following
3524 [(set (match_operand:SI 0 "s_register_operand" "")
3525 (ior:SI (and:SI (not:SI (match_operand:SI 1 "s_register_operand" ""))
3526 (not:SI (match_operand:SI 2 "arm_rhs_operand" "")))
3527 (match_operand:SI 3 "arm_rhs_operand" "")))
3528 (clobber (match_operand:SI 4 "s_register_operand" ""))]
3530 [(set (match_dup 4) (and:SI (ior:SI (match_dup 1) (match_dup 2))
3531 (not:SI (match_dup 3))))
3532 (set (match_dup 0) (not:SI (match_dup 4)))]
3536 (define_insn_and_split "*andsi_iorsi3_notsi"
3537 [(set (match_operand:SI 0 "s_register_operand" "=&r,&r,&r")
3538 (and:SI (ior:SI (match_operand:SI 1 "s_register_operand" "%0,r,r")
3539 (match_operand:SI 2 "arm_rhs_operand" "rI,0,rI"))
3540 (not:SI (match_operand:SI 3 "arm_rhs_operand" "rI,rI,rI"))))]
3542 "#" ; "orr%?\\t%0, %1, %2\;bic%?\\t%0, %0, %3"
3543 "&& reload_completed"
3544 [(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 2)))
3545 (set (match_dup 0) (and:SI (match_dup 4) (match_dup 5)))]
3547 /* If operands[3] is a constant make sure to fold the NOT into it
3548 to avoid creating a NOT of a CONST_INT. */
3549 rtx not_rtx = simplify_gen_unary (NOT, SImode, operands[3], SImode);
3550 if (CONST_INT_P (not_rtx))
3552 operands[4] = operands[0];
3553 operands[5] = not_rtx;
3557 operands[5] = operands[0];
3558 operands[4] = not_rtx;
3561 [(set_attr "length" "8")
3562 (set_attr "ce_count" "2")
3563 (set_attr "predicable" "yes")
3564 (set_attr "type" "multiple")]
3567 ; ??? Are these four splitters still beneficial when the Thumb-2 bitfield
3568 ; insns are available?
3570 [(set (match_operand:SI 0 "s_register_operand" "")
3571 (match_operator:SI 1 "logical_binary_operator"
3572 [(zero_extract:SI (match_operand:SI 2 "s_register_operand" "")
3573 (match_operand:SI 3 "const_int_operand" "")
3574 (match_operand:SI 4 "const_int_operand" ""))
3575 (match_operator:SI 9 "logical_binary_operator"
3576 [(lshiftrt:SI (match_operand:SI 5 "s_register_operand" "")
3577 (match_operand:SI 6 "const_int_operand" ""))
3578 (match_operand:SI 7 "s_register_operand" "")])]))
3579 (clobber (match_operand:SI 8 "s_register_operand" ""))]
3581 && GET_CODE (operands[1]) == GET_CODE (operands[9])
3582 && INTVAL (operands[3]) == 32 - INTVAL (operands[6])"
3585 [(ashift:SI (match_dup 2) (match_dup 4))
3589 [(lshiftrt:SI (match_dup 8) (match_dup 6))
3592 operands[4] = GEN_INT (32 - (INTVAL (operands[3]) + INTVAL (operands[4])));
3596 [(set (match_operand:SI 0 "s_register_operand" "")
3597 (match_operator:SI 1 "logical_binary_operator"
3598 [(match_operator:SI 9 "logical_binary_operator"
3599 [(lshiftrt:SI (match_operand:SI 5 "s_register_operand" "")
3600 (match_operand:SI 6 "const_int_operand" ""))
3601 (match_operand:SI 7 "s_register_operand" "")])
3602 (zero_extract:SI (match_operand:SI 2 "s_register_operand" "")
3603 (match_operand:SI 3 "const_int_operand" "")
3604 (match_operand:SI 4 "const_int_operand" ""))]))
3605 (clobber (match_operand:SI 8 "s_register_operand" ""))]
3607 && GET_CODE (operands[1]) == GET_CODE (operands[9])
3608 && INTVAL (operands[3]) == 32 - INTVAL (operands[6])"
3611 [(ashift:SI (match_dup 2) (match_dup 4))
3615 [(lshiftrt:SI (match_dup 8) (match_dup 6))
3618 operands[4] = GEN_INT (32 - (INTVAL (operands[3]) + INTVAL (operands[4])));
3622 [(set (match_operand:SI 0 "s_register_operand" "")
3623 (match_operator:SI 1 "logical_binary_operator"
3624 [(sign_extract:SI (match_operand:SI 2 "s_register_operand" "")
3625 (match_operand:SI 3 "const_int_operand" "")
3626 (match_operand:SI 4 "const_int_operand" ""))
3627 (match_operator:SI 9 "logical_binary_operator"
3628 [(ashiftrt:SI (match_operand:SI 5 "s_register_operand" "")
3629 (match_operand:SI 6 "const_int_operand" ""))
3630 (match_operand:SI 7 "s_register_operand" "")])]))
3631 (clobber (match_operand:SI 8 "s_register_operand" ""))]
3633 && GET_CODE (operands[1]) == GET_CODE (operands[9])
3634 && INTVAL (operands[3]) == 32 - INTVAL (operands[6])"
3637 [(ashift:SI (match_dup 2) (match_dup 4))
3641 [(ashiftrt:SI (match_dup 8) (match_dup 6))
3644 operands[4] = GEN_INT (32 - (INTVAL (operands[3]) + INTVAL (operands[4])));
3648 [(set (match_operand:SI 0 "s_register_operand" "")
3649 (match_operator:SI 1 "logical_binary_operator"
3650 [(match_operator:SI 9 "logical_binary_operator"
3651 [(ashiftrt:SI (match_operand:SI 5 "s_register_operand" "")
3652 (match_operand:SI 6 "const_int_operand" ""))
3653 (match_operand:SI 7 "s_register_operand" "")])
3654 (sign_extract:SI (match_operand:SI 2 "s_register_operand" "")
3655 (match_operand:SI 3 "const_int_operand" "")
3656 (match_operand:SI 4 "const_int_operand" ""))]))
3657 (clobber (match_operand:SI 8 "s_register_operand" ""))]
3659 && GET_CODE (operands[1]) == GET_CODE (operands[9])
3660 && INTVAL (operands[3]) == 32 - INTVAL (operands[6])"
3663 [(ashift:SI (match_dup 2) (match_dup 4))
3667 [(ashiftrt:SI (match_dup 8) (match_dup 6))
3670 operands[4] = GEN_INT (32 - (INTVAL (operands[3]) + INTVAL (operands[4])));
3674 ;; Minimum and maximum insns
3676 (define_expand "smaxsi3"
3678 (set (match_operand:SI 0 "s_register_operand" "")
3679 (smax:SI (match_operand:SI 1 "s_register_operand" "")
3680 (match_operand:SI 2 "arm_rhs_operand" "")))
3681 (clobber (reg:CC CC_REGNUM))])]
3684 if (operands[2] == const0_rtx || operands[2] == constm1_rtx)
3686 /* No need for a clobber of the condition code register here. */
3687 emit_insn (gen_rtx_SET (operands[0],
3688 gen_rtx_SMAX (SImode, operands[1],
3694 (define_insn "*smax_0"
3695 [(set (match_operand:SI 0 "s_register_operand" "=r")
3696 (smax:SI (match_operand:SI 1 "s_register_operand" "r")
3699 "bic%?\\t%0, %1, %1, asr #31"
3700 [(set_attr "predicable" "yes")
3701 (set_attr "type" "logic_shift_reg")]
3704 (define_insn "*smax_m1"
3705 [(set (match_operand:SI 0 "s_register_operand" "=r")
3706 (smax:SI (match_operand:SI 1 "s_register_operand" "r")
3709 "orr%?\\t%0, %1, %1, asr #31"
3710 [(set_attr "predicable" "yes")
3711 (set_attr "type" "logic_shift_reg")]
3714 (define_insn_and_split "*arm_smax_insn"
3715 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
3716 (smax:SI (match_operand:SI 1 "s_register_operand" "%0,?r")
3717 (match_operand:SI 2 "arm_rhs_operand" "rI,rI")))
3718 (clobber (reg:CC CC_REGNUM))]
3721 ; cmp\\t%1, %2\;movlt\\t%0, %2
3722 ; cmp\\t%1, %2\;movge\\t%0, %1\;movlt\\t%0, %2"
3724 [(set (reg:CC CC_REGNUM)
3725 (compare:CC (match_dup 1) (match_dup 2)))
3727 (if_then_else:SI (ge:SI (reg:CC CC_REGNUM) (const_int 0))
3731 [(set_attr "conds" "clob")
3732 (set_attr "length" "8,12")
3733 (set_attr "type" "multiple")]
3736 (define_expand "sminsi3"
3738 (set (match_operand:SI 0 "s_register_operand" "")
3739 (smin:SI (match_operand:SI 1 "s_register_operand" "")
3740 (match_operand:SI 2 "arm_rhs_operand" "")))
3741 (clobber (reg:CC CC_REGNUM))])]
3744 if (operands[2] == const0_rtx)
3746 /* No need for a clobber of the condition code register here. */
3747 emit_insn (gen_rtx_SET (operands[0],
3748 gen_rtx_SMIN (SImode, operands[1],
3754 (define_insn "*smin_0"
3755 [(set (match_operand:SI 0 "s_register_operand" "=r")
3756 (smin:SI (match_operand:SI 1 "s_register_operand" "r")
3759 "and%?\\t%0, %1, %1, asr #31"
3760 [(set_attr "predicable" "yes")
3761 (set_attr "type" "logic_shift_reg")]
3764 (define_insn_and_split "*arm_smin_insn"
3765 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
3766 (smin:SI (match_operand:SI 1 "s_register_operand" "%0,?r")
3767 (match_operand:SI 2 "arm_rhs_operand" "rI,rI")))
3768 (clobber (reg:CC CC_REGNUM))]
3771 ; cmp\\t%1, %2\;movge\\t%0, %2
3772 ; cmp\\t%1, %2\;movlt\\t%0, %1\;movge\\t%0, %2"
3774 [(set (reg:CC CC_REGNUM)
3775 (compare:CC (match_dup 1) (match_dup 2)))
3777 (if_then_else:SI (lt:SI (reg:CC CC_REGNUM) (const_int 0))
3781 [(set_attr "conds" "clob")
3782 (set_attr "length" "8,12")
3783 (set_attr "type" "multiple,multiple")]
3786 (define_expand "umaxsi3"
3788 (set (match_operand:SI 0 "s_register_operand" "")
3789 (umax:SI (match_operand:SI 1 "s_register_operand" "")
3790 (match_operand:SI 2 "arm_rhs_operand" "")))
3791 (clobber (reg:CC CC_REGNUM))])]
3796 (define_insn_and_split "*arm_umaxsi3"
3797 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
3798 (umax:SI (match_operand:SI 1 "s_register_operand" "0,r,?r")
3799 (match_operand:SI 2 "arm_rhs_operand" "rI,0,rI")))
3800 (clobber (reg:CC CC_REGNUM))]
3803 ; cmp\\t%1, %2\;movcc\\t%0, %2
3804 ; cmp\\t%1, %2\;movcs\\t%0, %1
3805 ; cmp\\t%1, %2\;movcs\\t%0, %1\;movcc\\t%0, %2"
3807 [(set (reg:CC CC_REGNUM)
3808 (compare:CC (match_dup 1) (match_dup 2)))
3810 (if_then_else:SI (geu:SI (reg:CC CC_REGNUM) (const_int 0))
3814 [(set_attr "conds" "clob")
3815 (set_attr "length" "8,8,12")
3816 (set_attr "type" "store_4")]
3819 (define_expand "uminsi3"
3821 (set (match_operand:SI 0 "s_register_operand" "")
3822 (umin:SI (match_operand:SI 1 "s_register_operand" "")
3823 (match_operand:SI 2 "arm_rhs_operand" "")))
3824 (clobber (reg:CC CC_REGNUM))])]
3829 (define_insn_and_split "*arm_uminsi3"
3830 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
3831 (umin:SI (match_operand:SI 1 "s_register_operand" "0,r,?r")
3832 (match_operand:SI 2 "arm_rhs_operand" "rI,0,rI")))
3833 (clobber (reg:CC CC_REGNUM))]
3836 ; cmp\\t%1, %2\;movcs\\t%0, %2
3837 ; cmp\\t%1, %2\;movcc\\t%0, %1
3838 ; cmp\\t%1, %2\;movcc\\t%0, %1\;movcs\\t%0, %2"
3840 [(set (reg:CC CC_REGNUM)
3841 (compare:CC (match_dup 1) (match_dup 2)))
3843 (if_then_else:SI (ltu:SI (reg:CC CC_REGNUM) (const_int 0))
3847 [(set_attr "conds" "clob")
3848 (set_attr "length" "8,8,12")
3849 (set_attr "type" "store_4")]
3852 (define_insn "*store_minmaxsi"
3853 [(set (match_operand:SI 0 "memory_operand" "=m")
3854 (match_operator:SI 3 "minmax_operator"
3855 [(match_operand:SI 1 "s_register_operand" "r")
3856 (match_operand:SI 2 "s_register_operand" "r")]))
3857 (clobber (reg:CC CC_REGNUM))]
3858 "TARGET_32BIT && optimize_function_for_size_p (cfun) && !arm_restrict_it"
3860 operands[3] = gen_rtx_fmt_ee (minmax_code (operands[3]), SImode,
3861 operands[1], operands[2]);
3862 output_asm_insn (\"cmp\\t%1, %2\", operands);
3864 output_asm_insn (\"ite\t%d3\", operands);
3865 output_asm_insn (\"str%d3\\t%1, %0\", operands);
3866 output_asm_insn (\"str%D3\\t%2, %0\", operands);
3869 [(set_attr "conds" "clob")
3870 (set (attr "length")
3871 (if_then_else (eq_attr "is_thumb" "yes")
3874 (set_attr "type" "store_4")]
3877 ; Reject the frame pointer in operand[1], since reloading this after
3878 ; it has been eliminated can cause carnage.
3879 (define_insn "*minmax_arithsi"
3880 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
3881 (match_operator:SI 4 "shiftable_operator"
3882 [(match_operator:SI 5 "minmax_operator"
3883 [(match_operand:SI 2 "s_register_operand" "r,r")
3884 (match_operand:SI 3 "arm_rhs_operand" "rI,rI")])
3885 (match_operand:SI 1 "s_register_operand" "0,?r")]))
3886 (clobber (reg:CC CC_REGNUM))]
3887 "TARGET_32BIT && !arm_eliminable_register (operands[1]) && !arm_restrict_it"
3890 enum rtx_code code = GET_CODE (operands[4]);
3893 if (which_alternative != 0 || operands[3] != const0_rtx
3894 || (code != PLUS && code != IOR && code != XOR))
3899 operands[5] = gen_rtx_fmt_ee (minmax_code (operands[5]), SImode,
3900 operands[2], operands[3]);
3901 output_asm_insn (\"cmp\\t%2, %3\", operands);
3905 output_asm_insn (\"ite\\t%d5\", operands);
3907 output_asm_insn (\"it\\t%d5\", operands);
3909 output_asm_insn (\"%i4%d5\\t%0, %1, %2\", operands);
3911 output_asm_insn (\"%i4%D5\\t%0, %1, %3\", operands);
3914 [(set_attr "conds" "clob")
3915 (set (attr "length")
3916 (if_then_else (eq_attr "is_thumb" "yes")
3919 (set_attr "type" "multiple")]
3922 ; Reject the frame pointer in operand[1], since reloading this after
3923 ; it has been eliminated can cause carnage.
3924 (define_insn_and_split "*minmax_arithsi_non_canon"
3925 [(set (match_operand:SI 0 "s_register_operand" "=Ts,Ts")
3927 (match_operand:SI 1 "s_register_operand" "0,?Ts")
3928 (match_operator:SI 4 "minmax_operator"
3929 [(match_operand:SI 2 "s_register_operand" "Ts,Ts")
3930 (match_operand:SI 3 "arm_rhs_operand" "TsI,TsI")])))
3931 (clobber (reg:CC CC_REGNUM))]
3932 "TARGET_32BIT && !arm_eliminable_register (operands[1])
3933 && !(arm_restrict_it && CONST_INT_P (operands[3]))"
3935 "TARGET_32BIT && !arm_eliminable_register (operands[1]) && reload_completed"
3936 [(set (reg:CC CC_REGNUM)
3937 (compare:CC (match_dup 2) (match_dup 3)))
3939 (cond_exec (match_op_dup 4 [(reg:CC CC_REGNUM) (const_int 0)])
3941 (minus:SI (match_dup 1)
3943 (cond_exec (match_op_dup 5 [(reg:CC CC_REGNUM) (const_int 0)])
3947 machine_mode mode = SELECT_CC_MODE (GET_CODE (operands[1]),
3948 operands[2], operands[3]);
3949 enum rtx_code rc = minmax_code (operands[4]);
3950 operands[4] = gen_rtx_fmt_ee (rc, VOIDmode,
3951 operands[2], operands[3]);
3953 if (mode == CCFPmode || mode == CCFPEmode)
3954 rc = reverse_condition_maybe_unordered (rc);
3956 rc = reverse_condition (rc);
3957 operands[5] = gen_rtx_fmt_ee (rc, SImode, operands[2], operands[3]);
3958 if (CONST_INT_P (operands[3]))
3959 operands[6] = plus_constant (SImode, operands[1], -INTVAL (operands[3]));
3961 operands[6] = gen_rtx_MINUS (SImode, operands[1], operands[3]);
3963 [(set_attr "conds" "clob")
3964 (set (attr "length")
3965 (if_then_else (eq_attr "is_thumb" "yes")
3968 (set_attr "type" "multiple")]
3971 (define_code_iterator SAT [smin smax])
3972 (define_code_iterator SATrev [smin smax])
3973 (define_code_attr SATlo [(smin "1") (smax "2")])
3974 (define_code_attr SAThi [(smin "2") (smax "1")])
3976 (define_insn "*satsi_<SAT:code>"
3977 [(set (match_operand:SI 0 "s_register_operand" "=r")
3978 (SAT:SI (SATrev:SI (match_operand:SI 3 "s_register_operand" "r")
3979 (match_operand:SI 1 "const_int_operand" "i"))
3980 (match_operand:SI 2 "const_int_operand" "i")))]
3981 "TARGET_32BIT && arm_arch6 && <SAT:CODE> != <SATrev:CODE>
3982 && arm_sat_operator_match (operands[<SAT:SATlo>], operands[<SAT:SAThi>], NULL, NULL)"
3986 if (!arm_sat_operator_match (operands[<SAT:SATlo>], operands[<SAT:SAThi>],
3987 &mask, &signed_sat))
3990 operands[1] = GEN_INT (mask);
3992 return "ssat%?\t%0, %1, %3";
3994 return "usat%?\t%0, %1, %3";
3996 [(set_attr "predicable" "yes")
3997 (set_attr "type" "alus_imm")]
4000 (define_insn "*satsi_<SAT:code>_shift"
4001 [(set (match_operand:SI 0 "s_register_operand" "=r")
4002 (SAT:SI (SATrev:SI (match_operator:SI 3 "sat_shift_operator"
4003 [(match_operand:SI 4 "s_register_operand" "r")
4004 (match_operand:SI 5 "const_int_operand" "i")])
4005 (match_operand:SI 1 "const_int_operand" "i"))
4006 (match_operand:SI 2 "const_int_operand" "i")))]
4007 "TARGET_32BIT && arm_arch6 && <SAT:CODE> != <SATrev:CODE>
4008 && arm_sat_operator_match (operands[<SAT:SATlo>], operands[<SAT:SAThi>], NULL, NULL)"
4012 if (!arm_sat_operator_match (operands[<SAT:SATlo>], operands[<SAT:SAThi>],
4013 &mask, &signed_sat))
4016 operands[1] = GEN_INT (mask);
4018 return "ssat%?\t%0, %1, %4%S3";
4020 return "usat%?\t%0, %1, %4%S3";
4022 [(set_attr "predicable" "yes")
4023 (set_attr "shift" "3")
4024 (set_attr "type" "logic_shift_reg")])
4026 ;; Shift and rotation insns
4028 (define_expand "ashldi3"
4029 [(set (match_operand:DI 0 "s_register_operand" "")
4030 (ashift:DI (match_operand:DI 1 "s_register_operand" "")
4031 (match_operand:SI 2 "general_operand" "")))]
4036 /* Delay the decision whether to use NEON or core-regs until
4037 register allocation. */
4038 emit_insn (gen_ashldi3_neon (operands[0], operands[1], operands[2]));
4043 /* Only the NEON case can handle in-memory shift counts. */
4044 if (!reg_or_int_operand (operands[2], SImode))
4045 operands[2] = force_reg (SImode, operands[2]);
4048 if (!CONST_INT_P (operands[2]) && TARGET_REALLY_IWMMXT)
4049 ; /* No special preparation statements; expand pattern as above. */
4052 rtx scratch1, scratch2;
4054 /* Ideally we should use iwmmxt here if we could know that operands[1]
4055 ends up already living in an iwmmxt register. Otherwise it's
4056 cheaper to have the alternate code being generated than moving
4057 values to iwmmxt regs and back. */
4059 /* Expand operation using core-registers.
4060 'FAIL' would achieve the same thing, but this is a bit smarter. */
4061 scratch1 = gen_reg_rtx (SImode);
4062 scratch2 = gen_reg_rtx (SImode);
4063 arm_emit_coreregs_64bit_shift (ASHIFT, operands[0], operands[1],
4064 operands[2], scratch1, scratch2);
4070 (define_expand "ashlsi3"
4071 [(set (match_operand:SI 0 "s_register_operand" "")
4072 (ashift:SI (match_operand:SI 1 "s_register_operand" "")
4073 (match_operand:SI 2 "arm_rhs_operand" "")))]
4076 if (CONST_INT_P (operands[2])
4077 && (UINTVAL (operands[2])) > 31)
4079 emit_insn (gen_movsi (operands[0], const0_rtx));
4085 (define_expand "ashrdi3"
4086 [(set (match_operand:DI 0 "s_register_operand" "")
4087 (ashiftrt:DI (match_operand:DI 1 "s_register_operand" "")
4088 (match_operand:SI 2 "reg_or_int_operand" "")))]
4093 /* Delay the decision whether to use NEON or core-regs until
4094 register allocation. */
4095 emit_insn (gen_ashrdi3_neon (operands[0], operands[1], operands[2]));
4099 if (!CONST_INT_P (operands[2]) && TARGET_REALLY_IWMMXT)
4100 ; /* No special preparation statements; expand pattern as above. */
4103 rtx scratch1, scratch2;
4105 /* Ideally we should use iwmmxt here if we could know that operands[1]
4106 ends up already living in an iwmmxt register. Otherwise it's
4107 cheaper to have the alternate code being generated than moving
4108 values to iwmmxt regs and back. */
4110 /* Expand operation using core-registers.
4111 'FAIL' would achieve the same thing, but this is a bit smarter. */
4112 scratch1 = gen_reg_rtx (SImode);
4113 scratch2 = gen_reg_rtx (SImode);
4114 arm_emit_coreregs_64bit_shift (ASHIFTRT, operands[0], operands[1],
4115 operands[2], scratch1, scratch2);
4121 (define_expand "ashrsi3"
4122 [(set (match_operand:SI 0 "s_register_operand" "")
4123 (ashiftrt:SI (match_operand:SI 1 "s_register_operand" "")
4124 (match_operand:SI 2 "arm_rhs_operand" "")))]
4127 if (CONST_INT_P (operands[2])
4128 && UINTVAL (operands[2]) > 31)
4129 operands[2] = GEN_INT (31);
4133 (define_expand "lshrdi3"
4134 [(set (match_operand:DI 0 "s_register_operand" "")
4135 (lshiftrt:DI (match_operand:DI 1 "s_register_operand" "")
4136 (match_operand:SI 2 "reg_or_int_operand" "")))]
4141 /* Delay the decision whether to use NEON or core-regs until
4142 register allocation. */
4143 emit_insn (gen_lshrdi3_neon (operands[0], operands[1], operands[2]));
4147 if (!CONST_INT_P (operands[2]) && TARGET_REALLY_IWMMXT)
4148 ; /* No special preparation statements; expand pattern as above. */
4151 rtx scratch1, scratch2;
4153 /* Ideally we should use iwmmxt here if we could know that operands[1]
4154 ends up already living in an iwmmxt register. Otherwise it's
4155 cheaper to have the alternate code being generated than moving
4156 values to iwmmxt regs and back. */
4158 /* Expand operation using core-registers.
4159 'FAIL' would achieve the same thing, but this is a bit smarter. */
4160 scratch1 = gen_reg_rtx (SImode);
4161 scratch2 = gen_reg_rtx (SImode);
4162 arm_emit_coreregs_64bit_shift (LSHIFTRT, operands[0], operands[1],
4163 operands[2], scratch1, scratch2);
4169 (define_expand "lshrsi3"
4170 [(set (match_operand:SI 0 "s_register_operand" "")
4171 (lshiftrt:SI (match_operand:SI 1 "s_register_operand" "")
4172 (match_operand:SI 2 "arm_rhs_operand" "")))]
4175 if (CONST_INT_P (operands[2])
4176 && (UINTVAL (operands[2])) > 31)
4178 emit_insn (gen_movsi (operands[0], const0_rtx));
4184 (define_expand "rotlsi3"
4185 [(set (match_operand:SI 0 "s_register_operand" "")
4186 (rotatert:SI (match_operand:SI 1 "s_register_operand" "")
4187 (match_operand:SI 2 "reg_or_int_operand" "")))]
4190 if (CONST_INT_P (operands[2]))
4191 operands[2] = GEN_INT ((32 - INTVAL (operands[2])) % 32);
4194 rtx reg = gen_reg_rtx (SImode);
4195 emit_insn (gen_subsi3 (reg, GEN_INT (32), operands[2]));
4201 (define_expand "rotrsi3"
4202 [(set (match_operand:SI 0 "s_register_operand" "")
4203 (rotatert:SI (match_operand:SI 1 "s_register_operand" "")
4204 (match_operand:SI 2 "arm_rhs_operand" "")))]
4209 if (CONST_INT_P (operands[2])
4210 && UINTVAL (operands[2]) > 31)
4211 operands[2] = GEN_INT (INTVAL (operands[2]) % 32);
4213 else /* TARGET_THUMB1 */
4215 if (CONST_INT_P (operands [2]))
4216 operands [2] = force_reg (SImode, operands[2]);
4221 (define_insn "*arm_shiftsi3"
4222 [(set (match_operand:SI 0 "s_register_operand" "=l,l,r,r")
4223 (match_operator:SI 3 "shift_operator"
4224 [(match_operand:SI 1 "s_register_operand" "0,l,r,r")
4225 (match_operand:SI 2 "reg_or_int_operand" "l,M,M,r")]))]
4227 "* return arm_output_shift(operands, 0);"
4228 [(set_attr "predicable" "yes")
4229 (set_attr "arch" "t2,t2,*,*")
4230 (set_attr "predicable_short_it" "yes,yes,no,no")
4231 (set_attr "length" "4")
4232 (set_attr "shift" "1")
4233 (set_attr "type" "alu_shift_reg,alu_shift_imm,alu_shift_imm,alu_shift_reg")]
4236 (define_insn "*shiftsi3_compare0"
4237 [(set (reg:CC_NOOV CC_REGNUM)
4238 (compare:CC_NOOV (match_operator:SI 3 "shift_operator"
4239 [(match_operand:SI 1 "s_register_operand" "r,r")
4240 (match_operand:SI 2 "arm_rhs_operand" "M,r")])
4242 (set (match_operand:SI 0 "s_register_operand" "=r,r")
4243 (match_op_dup 3 [(match_dup 1) (match_dup 2)]))]
4245 "* return arm_output_shift(operands, 1);"
4246 [(set_attr "conds" "set")
4247 (set_attr "shift" "1")
4248 (set_attr "type" "alus_shift_imm,alus_shift_reg")]
4251 (define_insn "*shiftsi3_compare0_scratch"
4252 [(set (reg:CC_NOOV CC_REGNUM)
4253 (compare:CC_NOOV (match_operator:SI 3 "shift_operator"
4254 [(match_operand:SI 1 "s_register_operand" "r,r")
4255 (match_operand:SI 2 "arm_rhs_operand" "M,r")])
4257 (clobber (match_scratch:SI 0 "=r,r"))]
4259 "* return arm_output_shift(operands, 1);"
4260 [(set_attr "conds" "set")
4261 (set_attr "shift" "1")
4262 (set_attr "type" "shift_imm,shift_reg")]
4265 (define_insn "*not_shiftsi"
4266 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
4267 (not:SI (match_operator:SI 3 "shift_operator"
4268 [(match_operand:SI 1 "s_register_operand" "r,r")
4269 (match_operand:SI 2 "shift_amount_operand" "M,rM")])))]
4272 [(set_attr "predicable" "yes")
4273 (set_attr "shift" "1")
4274 (set_attr "arch" "32,a")
4275 (set_attr "type" "mvn_shift,mvn_shift_reg")])
4277 (define_insn "*not_shiftsi_compare0"
4278 [(set (reg:CC_NOOV CC_REGNUM)
4280 (not:SI (match_operator:SI 3 "shift_operator"
4281 [(match_operand:SI 1 "s_register_operand" "r,r")
4282 (match_operand:SI 2 "shift_amount_operand" "M,rM")]))
4284 (set (match_operand:SI 0 "s_register_operand" "=r,r")
4285 (not:SI (match_op_dup 3 [(match_dup 1) (match_dup 2)])))]
4287 "mvns%?\\t%0, %1%S3"
4288 [(set_attr "conds" "set")
4289 (set_attr "shift" "1")
4290 (set_attr "arch" "32,a")
4291 (set_attr "type" "mvn_shift,mvn_shift_reg")])
4293 (define_insn "*not_shiftsi_compare0_scratch"
4294 [(set (reg:CC_NOOV CC_REGNUM)
4296 (not:SI (match_operator:SI 3 "shift_operator"
4297 [(match_operand:SI 1 "s_register_operand" "r,r")
4298 (match_operand:SI 2 "shift_amount_operand" "M,rM")]))
4300 (clobber (match_scratch:SI 0 "=r,r"))]
4302 "mvns%?\\t%0, %1%S3"
4303 [(set_attr "conds" "set")
4304 (set_attr "shift" "1")
4305 (set_attr "arch" "32,a")
4306 (set_attr "type" "mvn_shift,mvn_shift_reg")])
4308 ;; We don't really have extzv, but defining this using shifts helps
4309 ;; to reduce register pressure later on.
4311 (define_expand "extzv"
4312 [(set (match_operand 0 "s_register_operand" "")
4313 (zero_extract (match_operand 1 "nonimmediate_operand" "")
4314 (match_operand 2 "const_int_operand" "")
4315 (match_operand 3 "const_int_operand" "")))]
4316 "TARGET_THUMB1 || arm_arch_thumb2"
4319 HOST_WIDE_INT lshift = 32 - INTVAL (operands[2]) - INTVAL (operands[3]);
4320 HOST_WIDE_INT rshift = 32 - INTVAL (operands[2]);
4322 if (arm_arch_thumb2)
4324 HOST_WIDE_INT width = INTVAL (operands[2]);
4325 HOST_WIDE_INT bitpos = INTVAL (operands[3]);
4327 if (unaligned_access && MEM_P (operands[1])
4328 && (width == 16 || width == 32) && (bitpos % BITS_PER_UNIT) == 0)
4332 if (BYTES_BIG_ENDIAN)
4333 bitpos = GET_MODE_BITSIZE (GET_MODE (operands[0])) - width
4338 base_addr = adjust_address (operands[1], SImode,
4339 bitpos / BITS_PER_UNIT);
4340 emit_insn (gen_unaligned_loadsi (operands[0], base_addr));
4344 rtx dest = operands[0];
4345 rtx tmp = gen_reg_rtx (SImode);
4347 /* We may get a paradoxical subreg here. Strip it off. */
4348 if (GET_CODE (dest) == SUBREG
4349 && GET_MODE (dest) == SImode
4350 && GET_MODE (SUBREG_REG (dest)) == HImode)
4351 dest = SUBREG_REG (dest);
4353 if (GET_MODE_BITSIZE (GET_MODE (dest)) != width)
4356 base_addr = adjust_address (operands[1], HImode,
4357 bitpos / BITS_PER_UNIT);
4358 emit_insn (gen_unaligned_loadhiu (tmp, base_addr));
4359 emit_move_insn (gen_lowpart (SImode, dest), tmp);
4363 else if (s_register_operand (operands[1], GET_MODE (operands[1])))
4365 emit_insn (gen_extzv_t2 (operands[0], operands[1], operands[2],
4373 if (!s_register_operand (operands[1], GET_MODE (operands[1])))
4376 operands[3] = GEN_INT (rshift);
4380 emit_insn (gen_lshrsi3 (operands[0], operands[1], operands[3]));
4384 emit_insn (gen_extzv_t1 (operands[0], operands[1], GEN_INT (lshift),
4385 operands[3], gen_reg_rtx (SImode)));
4390 ;; Helper for extzv, for the Thumb-1 register-shifts case.
4392 (define_expand "extzv_t1"
4393 [(set (match_operand:SI 4 "s_register_operand" "")
4394 (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "")
4395 (match_operand:SI 2 "const_int_operand" "")))
4396 (set (match_operand:SI 0 "s_register_operand" "")
4397 (lshiftrt:SI (match_dup 4)
4398 (match_operand:SI 3 "const_int_operand" "")))]
4402 (define_expand "extv"
4403 [(set (match_operand 0 "s_register_operand" "")
4404 (sign_extract (match_operand 1 "nonimmediate_operand" "")
4405 (match_operand 2 "const_int_operand" "")
4406 (match_operand 3 "const_int_operand" "")))]
4409 HOST_WIDE_INT width = INTVAL (operands[2]);
4410 HOST_WIDE_INT bitpos = INTVAL (operands[3]);
4412 if (unaligned_access && MEM_P (operands[1]) && (width == 16 || width == 32)
4413 && (bitpos % BITS_PER_UNIT) == 0)
4417 if (BYTES_BIG_ENDIAN)
4418 bitpos = GET_MODE_BITSIZE (GET_MODE (operands[0])) - width - bitpos;
4422 base_addr = adjust_address (operands[1], SImode,
4423 bitpos / BITS_PER_UNIT);
4424 emit_insn (gen_unaligned_loadsi (operands[0], base_addr));
4428 rtx dest = operands[0];
4429 rtx tmp = gen_reg_rtx (SImode);
4431 /* We may get a paradoxical subreg here. Strip it off. */
4432 if (GET_CODE (dest) == SUBREG
4433 && GET_MODE (dest) == SImode
4434 && GET_MODE (SUBREG_REG (dest)) == HImode)
4435 dest = SUBREG_REG (dest);
4437 if (GET_MODE_BITSIZE (GET_MODE (dest)) != width)
4440 base_addr = adjust_address (operands[1], HImode,
4441 bitpos / BITS_PER_UNIT);
4442 emit_insn (gen_unaligned_loadhis (tmp, base_addr));
4443 emit_move_insn (gen_lowpart (SImode, dest), tmp);
4448 else if (!s_register_operand (operands[1], GET_MODE (operands[1])))
4450 else if (GET_MODE (operands[0]) == SImode
4451 && GET_MODE (operands[1]) == SImode)
4453 emit_insn (gen_extv_regsi (operands[0], operands[1], operands[2],
4461 ; Helper to expand register forms of extv with the proper modes.
4463 (define_expand "extv_regsi"
4464 [(set (match_operand:SI 0 "s_register_operand" "")
4465 (sign_extract:SI (match_operand:SI 1 "s_register_operand" "")
4466 (match_operand 2 "const_int_operand" "")
4467 (match_operand 3 "const_int_operand" "")))]
4472 ; ARMv6+ unaligned load/store instructions (used for packed structure accesses).
4474 (define_insn "unaligned_loadsi"
4475 [(set (match_operand:SI 0 "s_register_operand" "=l,r")
4476 (unspec:SI [(match_operand:SI 1 "memory_operand" "Uw,m")]
4477 UNSPEC_UNALIGNED_LOAD))]
4479 "ldr%?\t%0, %1\t@ unaligned"
4480 [(set_attr "arch" "t2,any")
4481 (set_attr "length" "2,4")
4482 (set_attr "predicable" "yes")
4483 (set_attr "predicable_short_it" "yes,no")
4484 (set_attr "type" "load_4")])
4486 (define_insn "unaligned_loadhis"
4487 [(set (match_operand:SI 0 "s_register_operand" "=r")
4489 (unspec:HI [(match_operand:HI 1 "memory_operand" "Uh")]
4490 UNSPEC_UNALIGNED_LOAD)))]
4492 "ldrsh%?\t%0, %1\t@ unaligned"
4493 [(set_attr "predicable" "yes")
4494 (set_attr "type" "load_byte")])
4496 (define_insn "unaligned_loadhiu"
4497 [(set (match_operand:SI 0 "s_register_operand" "=l,r")
4499 (unspec:HI [(match_operand:HI 1 "memory_operand" "Uw,m")]
4500 UNSPEC_UNALIGNED_LOAD)))]
4502 "ldrh%?\t%0, %1\t@ unaligned"
4503 [(set_attr "arch" "t2,any")
4504 (set_attr "length" "2,4")
4505 (set_attr "predicable" "yes")
4506 (set_attr "predicable_short_it" "yes,no")
4507 (set_attr "type" "load_byte")])
4509 (define_insn "unaligned_storesi"
4510 [(set (match_operand:SI 0 "memory_operand" "=Uw,m")
4511 (unspec:SI [(match_operand:SI 1 "s_register_operand" "l,r")]
4512 UNSPEC_UNALIGNED_STORE))]
4514 "str%?\t%1, %0\t@ unaligned"
4515 [(set_attr "arch" "t2,any")
4516 (set_attr "length" "2,4")
4517 (set_attr "predicable" "yes")
4518 (set_attr "predicable_short_it" "yes,no")
4519 (set_attr "type" "store_4")])
4521 (define_insn "unaligned_storehi"
4522 [(set (match_operand:HI 0 "memory_operand" "=Uw,m")
4523 (unspec:HI [(match_operand:HI 1 "s_register_operand" "l,r")]
4524 UNSPEC_UNALIGNED_STORE))]
4526 "strh%?\t%1, %0\t@ unaligned"
4527 [(set_attr "arch" "t2,any")
4528 (set_attr "length" "2,4")
4529 (set_attr "predicable" "yes")
4530 (set_attr "predicable_short_it" "yes,no")
4531 (set_attr "type" "store_4")])
4534 (define_insn "*extv_reg"
4535 [(set (match_operand:SI 0 "s_register_operand" "=r")
4536 (sign_extract:SI (match_operand:SI 1 "s_register_operand" "r")
4537 (match_operand:SI 2 "const_int_operand" "n")
4538 (match_operand:SI 3 "const_int_operand" "n")))]
4540 && IN_RANGE (INTVAL (operands[3]), 0, 31)
4541 && IN_RANGE (INTVAL (operands[2]), 1, 32 - INTVAL (operands[3]))"
4542 "sbfx%?\t%0, %1, %3, %2"
4543 [(set_attr "length" "4")
4544 (set_attr "predicable" "yes")
4545 (set_attr "type" "bfm")]
4548 (define_insn "extzv_t2"
4549 [(set (match_operand:SI 0 "s_register_operand" "=r")
4550 (zero_extract:SI (match_operand:SI 1 "s_register_operand" "r")
4551 (match_operand:SI 2 "const_int_operand" "n")
4552 (match_operand:SI 3 "const_int_operand" "n")))]
4554 && IN_RANGE (INTVAL (operands[3]), 0, 31)
4555 && IN_RANGE (INTVAL (operands[2]), 1, 32 - INTVAL (operands[3]))"
4556 "ubfx%?\t%0, %1, %3, %2"
4557 [(set_attr "length" "4")
4558 (set_attr "predicable" "yes")
4559 (set_attr "type" "bfm")]
4563 ;; Division instructions
4564 (define_insn "divsi3"
4565 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
4566 (div:SI (match_operand:SI 1 "s_register_operand" "r,r")
4567 (match_operand:SI 2 "s_register_operand" "r,r")))]
4572 [(set_attr "arch" "32,v8mb")
4573 (set_attr "predicable" "yes")
4574 (set_attr "type" "sdiv")]
4577 (define_insn "udivsi3"
4578 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
4579 (udiv:SI (match_operand:SI 1 "s_register_operand" "r,r")
4580 (match_operand:SI 2 "s_register_operand" "r,r")))]
4585 [(set_attr "arch" "32,v8mb")
4586 (set_attr "predicable" "yes")
4587 (set_attr "type" "udiv")]
4591 ;; Unary arithmetic insns
4593 (define_expand "negvsi3"
4594 [(match_operand:SI 0 "register_operand")
4595 (match_operand:SI 1 "register_operand")
4596 (match_operand 2 "")]
4599 emit_insn (gen_subsi3_compare (operands[0], const0_rtx, operands[1]));
4600 arm_gen_unlikely_cbranch (NE, CC_Vmode, operands[2]);
4605 (define_expand "negvdi3"
4606 [(match_operand:DI 0 "register_operand")
4607 (match_operand:DI 1 "register_operand")
4608 (match_operand 2 "")]
4611 emit_insn (gen_negdi2_compare (operands[0], operands[1]));
4612 arm_gen_unlikely_cbranch (NE, CC_Vmode, operands[2]);
4618 (define_insn_and_split "negdi2_compare"
4619 [(set (reg:CC CC_REGNUM)
4622 (match_operand:DI 1 "register_operand" "0,r")))
4623 (set (match_operand:DI 0 "register_operand" "=r,&r")
4624 (minus:DI (const_int 0) (match_dup 1)))]
4627 "&& reload_completed"
4628 [(parallel [(set (reg:CC CC_REGNUM)
4629 (compare:CC (const_int 0) (match_dup 1)))
4630 (set (match_dup 0) (minus:SI (const_int 0)
4632 (parallel [(set (reg:CC CC_REGNUM)
4633 (compare:CC (const_int 0) (match_dup 3)))
4636 (minus:SI (const_int 0) (match_dup 3))
4637 (ltu:SI (reg:CC_C CC_REGNUM)
4640 operands[2] = gen_highpart (SImode, operands[0]);
4641 operands[0] = gen_lowpart (SImode, operands[0]);
4642 operands[3] = gen_highpart (SImode, operands[1]);
4643 operands[1] = gen_lowpart (SImode, operands[1]);
4645 [(set_attr "conds" "set")
4646 (set_attr "length" "8")
4647 (set_attr "type" "multiple")]
4650 (define_expand "negdi2"
4652 [(set (match_operand:DI 0 "s_register_operand" "")
4653 (neg:DI (match_operand:DI 1 "s_register_operand" "")))
4654 (clobber (reg:CC CC_REGNUM))])]
4659 emit_insn (gen_negdi2_neon (operands[0], operands[1]));
4665 ;; The constraints here are to prevent a *partial* overlap (where %Q0 == %R1).
4666 ;; The first alternative allows the common case of a *full* overlap.
4667 (define_insn_and_split "*negdi2_insn"
4668 [(set (match_operand:DI 0 "s_register_operand" "=r,&r")
4669 (neg:DI (match_operand:DI 1 "s_register_operand" "0,r")))
4670 (clobber (reg:CC CC_REGNUM))]
4672 "#" ; rsbs %Q0, %Q1, #0; rsc %R0, %R1, #0 (ARM)
4673 ; negs %Q0, %Q1 ; sbc %R0, %R1, %R1, lsl #1 (Thumb-2)
4674 "&& reload_completed"
4675 [(parallel [(set (reg:CC CC_REGNUM)
4676 (compare:CC (const_int 0) (match_dup 1)))
4677 (set (match_dup 0) (minus:SI (const_int 0) (match_dup 1)))])
4678 (set (match_dup 2) (minus:SI (minus:SI (const_int 0) (match_dup 3))
4679 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
4681 operands[2] = gen_highpart (SImode, operands[0]);
4682 operands[0] = gen_lowpart (SImode, operands[0]);
4683 operands[3] = gen_highpart (SImode, operands[1]);
4684 operands[1] = gen_lowpart (SImode, operands[1]);
4686 [(set_attr "conds" "clob")
4687 (set_attr "length" "8")
4688 (set_attr "type" "multiple")]
4691 (define_insn "*negsi2_carryin_compare"
4692 [(set (reg:CC CC_REGNUM)
4693 (compare:CC (const_int 0)
4694 (match_operand:SI 1 "s_register_operand" "r")))
4695 (set (match_operand:SI 0 "s_register_operand" "=r")
4696 (minus:SI (minus:SI (const_int 0)
4698 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
4701 [(set_attr "conds" "set")
4702 (set_attr "type" "alus_imm")]
4705 (define_expand "negsi2"
4706 [(set (match_operand:SI 0 "s_register_operand" "")
4707 (neg:SI (match_operand:SI 1 "s_register_operand" "")))]
4712 (define_insn "*arm_negsi2"
4713 [(set (match_operand:SI 0 "s_register_operand" "=l,r")
4714 (neg:SI (match_operand:SI 1 "s_register_operand" "l,r")))]
4716 "rsb%?\\t%0, %1, #0"
4717 [(set_attr "predicable" "yes")
4718 (set_attr "predicable_short_it" "yes,no")
4719 (set_attr "arch" "t2,*")
4720 (set_attr "length" "4")
4721 (set_attr "type" "alu_sreg")]
4724 (define_expand "negsf2"
4725 [(set (match_operand:SF 0 "s_register_operand" "")
4726 (neg:SF (match_operand:SF 1 "s_register_operand" "")))]
4727 "TARGET_32BIT && TARGET_HARD_FLOAT"
4731 (define_expand "negdf2"
4732 [(set (match_operand:DF 0 "s_register_operand" "")
4733 (neg:DF (match_operand:DF 1 "s_register_operand" "")))]
4734 "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_VFP_DOUBLE"
4737 (define_insn_and_split "*zextendsidi_negsi"
4738 [(set (match_operand:DI 0 "s_register_operand" "=r")
4739 (zero_extend:DI (neg:SI (match_operand:SI 1 "s_register_operand" "r"))))]
4744 (neg:SI (match_dup 1)))
4748 operands[2] = gen_lowpart (SImode, operands[0]);
4749 operands[3] = gen_highpart (SImode, operands[0]);
4751 [(set_attr "length" "8")
4752 (set_attr "type" "multiple")]
4755 ;; Negate an extended 32-bit value.
4756 (define_insn_and_split "*negdi_extendsidi"
4757 [(set (match_operand:DI 0 "s_register_operand" "=l,r")
4758 (neg:DI (sign_extend:DI
4759 (match_operand:SI 1 "s_register_operand" "l,r"))))
4760 (clobber (reg:CC CC_REGNUM))]
4763 "&& reload_completed"
4766 rtx low = gen_lowpart (SImode, operands[0]);
4767 rtx high = gen_highpart (SImode, operands[0]);
4769 if (reg_overlap_mentioned_p (low, operands[1]))
4771 /* Input overlaps the low word of the output. Use:
4774 rsc Rhi, Rhi, #0 (thumb2: sbc Rhi, Rhi, Rhi, lsl #1). */
4775 rtx cc_reg = gen_rtx_REG (CC_Cmode, CC_REGNUM);
4777 emit_insn (gen_rtx_SET (high,
4778 gen_rtx_ASHIFTRT (SImode, operands[1],
4781 emit_insn (gen_subsi3_compare (low, const0_rtx, operands[1]));
4783 emit_insn (gen_rtx_SET (high,
4784 gen_rtx_MINUS (SImode,
4785 gen_rtx_MINUS (SImode,
4788 gen_rtx_LTU (SImode,
4793 rtx two_x = gen_rtx_ASHIFT (SImode, high, GEN_INT (1));
4794 emit_insn (gen_rtx_SET (high,
4795 gen_rtx_MINUS (SImode,
4796 gen_rtx_MINUS (SImode,
4799 gen_rtx_LTU (SImode,
4806 /* No overlap, or overlap on high word. Use:
4810 Flags not needed for this sequence. */
4811 emit_insn (gen_rtx_SET (low, gen_rtx_NEG (SImode, operands[1])));
4812 emit_insn (gen_rtx_SET (high,
4813 gen_rtx_AND (SImode,
4814 gen_rtx_NOT (SImode, operands[1]),
4816 emit_insn (gen_rtx_SET (high,
4817 gen_rtx_ASHIFTRT (SImode, high,
4822 [(set_attr "length" "12")
4823 (set_attr "arch" "t2,*")
4824 (set_attr "type" "multiple")]
4827 (define_insn_and_split "*negdi_zero_extendsidi"
4828 [(set (match_operand:DI 0 "s_register_operand" "=r,&r")
4829 (neg:DI (zero_extend:DI (match_operand:SI 1 "s_register_operand" "0,r"))))
4830 (clobber (reg:CC CC_REGNUM))]
4832 "#" ; "rsbs\\t%Q0, %1, #0\;sbc\\t%R0,%R0,%R0"
4833 ;; Don't care what register is input to sbc,
4834 ;; since we just need to propagate the carry.
4835 "&& reload_completed"
4836 [(parallel [(set (reg:CC CC_REGNUM)
4837 (compare:CC (const_int 0) (match_dup 1)))
4838 (set (match_dup 0) (minus:SI (const_int 0) (match_dup 1)))])
4839 (set (match_dup 2) (minus:SI (minus:SI (match_dup 2) (match_dup 2))
4840 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
4842 operands[2] = gen_highpart (SImode, operands[0]);
4843 operands[0] = gen_lowpart (SImode, operands[0]);
4845 [(set_attr "conds" "clob")
4846 (set_attr "length" "8")
4847 (set_attr "type" "multiple")] ;; length in thumb is 4
4850 ;; abssi2 doesn't really clobber the condition codes if a different register
4851 ;; is being set. To keep things simple, assume during rtl manipulations that
4852 ;; it does, but tell the final scan operator the truth. Similarly for
4855 (define_expand "abssi2"
4857 [(set (match_operand:SI 0 "s_register_operand" "")
4858 (abs:SI (match_operand:SI 1 "s_register_operand" "")))
4859 (clobber (match_dup 2))])]
4863 operands[2] = gen_rtx_SCRATCH (SImode);
4865 operands[2] = gen_rtx_REG (CCmode, CC_REGNUM);
4868 (define_insn_and_split "*arm_abssi2"
4869 [(set (match_operand:SI 0 "s_register_operand" "=r,&r")
4870 (abs:SI (match_operand:SI 1 "s_register_operand" "0,r")))
4871 (clobber (reg:CC CC_REGNUM))]
4874 "&& reload_completed"
4877 /* if (which_alternative == 0) */
4878 if (REGNO(operands[0]) == REGNO(operands[1]))
4880 /* Emit the pattern:
4881 cmp\\t%0, #0\;rsblt\\t%0, %0, #0
4882 [(set (reg:CC CC_REGNUM)
4883 (compare:CC (match_dup 0) (const_int 0)))
4884 (cond_exec (lt:CC (reg:CC CC_REGNUM) (const_int 0))
4885 (set (match_dup 0) (minus:SI (const_int 0) (match_dup 1))))]
4887 emit_insn (gen_rtx_SET (gen_rtx_REG (CCmode, CC_REGNUM),
4888 gen_rtx_COMPARE (CCmode, operands[0], const0_rtx)));
4889 emit_insn (gen_rtx_COND_EXEC (VOIDmode,
4890 (gen_rtx_LT (SImode,
4891 gen_rtx_REG (CCmode, CC_REGNUM),
4893 (gen_rtx_SET (operands[0],
4894 (gen_rtx_MINUS (SImode,
4901 /* Emit the pattern:
4902 alt1: eor%?\\t%0, %1, %1, asr #31\;sub%?\\t%0, %0, %1, asr #31
4904 (xor:SI (match_dup 1)
4905 (ashiftrt:SI (match_dup 1) (const_int 31))))
4907 (minus:SI (match_dup 0)
4908 (ashiftrt:SI (match_dup 1) (const_int 31))))]
4910 emit_insn (gen_rtx_SET (operands[0],
4911 gen_rtx_XOR (SImode,
4912 gen_rtx_ASHIFTRT (SImode,
4916 emit_insn (gen_rtx_SET (operands[0],
4917 gen_rtx_MINUS (SImode,
4919 gen_rtx_ASHIFTRT (SImode,
4925 [(set_attr "conds" "clob,*")
4926 (set_attr "shift" "1")
4927 (set_attr "predicable" "no, yes")
4928 (set_attr "length" "8")
4929 (set_attr "type" "multiple")]
4932 (define_insn_and_split "*arm_neg_abssi2"
4933 [(set (match_operand:SI 0 "s_register_operand" "=r,&r")
4934 (neg:SI (abs:SI (match_operand:SI 1 "s_register_operand" "0,r"))))
4935 (clobber (reg:CC CC_REGNUM))]
4938 "&& reload_completed"
4941 /* if (which_alternative == 0) */
4942 if (REGNO (operands[0]) == REGNO (operands[1]))
4944 /* Emit the pattern:
4945 cmp\\t%0, #0\;rsbgt\\t%0, %0, #0
4947 emit_insn (gen_rtx_SET (gen_rtx_REG (CCmode, CC_REGNUM),
4948 gen_rtx_COMPARE (CCmode, operands[0], const0_rtx)));
4949 emit_insn (gen_rtx_COND_EXEC (VOIDmode,
4951 gen_rtx_REG (CCmode, CC_REGNUM),
4953 gen_rtx_SET (operands[0],
4954 (gen_rtx_MINUS (SImode,
4960 /* Emit the pattern:
4961 eor%?\\t%0, %1, %1, asr #31\;rsb%?\\t%0, %0, %1, asr #31
4963 emit_insn (gen_rtx_SET (operands[0],
4964 gen_rtx_XOR (SImode,
4965 gen_rtx_ASHIFTRT (SImode,
4969 emit_insn (gen_rtx_SET (operands[0],
4970 gen_rtx_MINUS (SImode,
4971 gen_rtx_ASHIFTRT (SImode,
4978 [(set_attr "conds" "clob,*")
4979 (set_attr "shift" "1")
4980 (set_attr "predicable" "no, yes")
4981 (set_attr "length" "8")
4982 (set_attr "type" "multiple")]
4985 (define_expand "abssf2"
4986 [(set (match_operand:SF 0 "s_register_operand" "")
4987 (abs:SF (match_operand:SF 1 "s_register_operand" "")))]
4988 "TARGET_32BIT && TARGET_HARD_FLOAT"
4991 (define_expand "absdf2"
4992 [(set (match_operand:DF 0 "s_register_operand" "")
4993 (abs:DF (match_operand:DF 1 "s_register_operand" "")))]
4994 "TARGET_32BIT && TARGET_HARD_FLOAT && !TARGET_VFP_SINGLE"
4997 (define_expand "sqrtsf2"
4998 [(set (match_operand:SF 0 "s_register_operand" "")
4999 (sqrt:SF (match_operand:SF 1 "s_register_operand" "")))]
5000 "TARGET_32BIT && TARGET_HARD_FLOAT"
5003 (define_expand "sqrtdf2"
5004 [(set (match_operand:DF 0 "s_register_operand" "")
5005 (sqrt:DF (match_operand:DF 1 "s_register_operand" "")))]
5006 "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_VFP_DOUBLE"
5009 (define_expand "one_cmpldi2"
5010 [(set (match_operand:DI 0 "s_register_operand" "")
5011 (not:DI (match_operand:DI 1 "s_register_operand" "")))]
5014 if (!TARGET_NEON && !TARGET_IWMMXT)
5016 rtx low = simplify_gen_unary (NOT, SImode,
5017 gen_lowpart (SImode, operands[1]),
5019 rtx high = simplify_gen_unary (NOT, SImode,
5020 gen_highpart_mode (SImode, DImode,
5024 emit_insn (gen_rtx_SET (gen_lowpart (SImode, operands[0]), low));
5025 emit_insn (gen_rtx_SET (gen_highpart (SImode, operands[0]), high));
5029 /* Otherwise expand pattern as above. */
5033 (define_insn_and_split "*one_cmpldi2_insn"
5034 [(set (match_operand:DI 0 "s_register_operand" "=w,&r,&r,?w")
5035 (not:DI (match_operand:DI 1 "s_register_operand" " w, 0, r, w")))]
5042 "TARGET_32BIT && reload_completed
5043 && arm_general_register_operand (operands[0], DImode)"
5044 [(set (match_dup 0) (not:SI (match_dup 1)))
5045 (set (match_dup 2) (not:SI (match_dup 3)))]
5048 operands[2] = gen_highpart (SImode, operands[0]);
5049 operands[0] = gen_lowpart (SImode, operands[0]);
5050 operands[3] = gen_highpart (SImode, operands[1]);
5051 operands[1] = gen_lowpart (SImode, operands[1]);
5053 [(set_attr "length" "*,8,8,*")
5054 (set_attr "predicable" "no,yes,yes,no")
5055 (set_attr "type" "neon_move,multiple,multiple,neon_move")
5056 (set_attr "arch" "neon_for_64bits,*,*,avoid_neon_for_64bits")]
5059 (define_expand "one_cmplsi2"
5060 [(set (match_operand:SI 0 "s_register_operand" "")
5061 (not:SI (match_operand:SI 1 "s_register_operand" "")))]
5066 (define_insn "*arm_one_cmplsi2"
5067 [(set (match_operand:SI 0 "s_register_operand" "=l,r")
5068 (not:SI (match_operand:SI 1 "s_register_operand" "l,r")))]
5071 [(set_attr "predicable" "yes")
5072 (set_attr "predicable_short_it" "yes,no")
5073 (set_attr "arch" "t2,*")
5074 (set_attr "length" "4")
5075 (set_attr "type" "mvn_reg")]
5078 (define_insn "*notsi_compare0"
5079 [(set (reg:CC_NOOV CC_REGNUM)
5080 (compare:CC_NOOV (not:SI (match_operand:SI 1 "s_register_operand" "r"))
5082 (set (match_operand:SI 0 "s_register_operand" "=r")
5083 (not:SI (match_dup 1)))]
5086 [(set_attr "conds" "set")
5087 (set_attr "type" "mvn_reg")]
5090 (define_insn "*notsi_compare0_scratch"
5091 [(set (reg:CC_NOOV CC_REGNUM)
5092 (compare:CC_NOOV (not:SI (match_operand:SI 1 "s_register_operand" "r"))
5094 (clobber (match_scratch:SI 0 "=r"))]
5097 [(set_attr "conds" "set")
5098 (set_attr "type" "mvn_reg")]
5101 ;; Fixed <--> Floating conversion insns
5103 (define_expand "floatsihf2"
5104 [(set (match_operand:HF 0 "general_operand" "")
5105 (float:HF (match_operand:SI 1 "general_operand" "")))]
5109 rtx op1 = gen_reg_rtx (SFmode);
5110 expand_float (op1, operands[1], 0);
5111 op1 = convert_to_mode (HFmode, op1, 0);
5112 emit_move_insn (operands[0], op1);
5117 (define_expand "floatdihf2"
5118 [(set (match_operand:HF 0 "general_operand" "")
5119 (float:HF (match_operand:DI 1 "general_operand" "")))]
5123 rtx op1 = gen_reg_rtx (SFmode);
5124 expand_float (op1, operands[1], 0);
5125 op1 = convert_to_mode (HFmode, op1, 0);
5126 emit_move_insn (operands[0], op1);
5131 (define_expand "floatsisf2"
5132 [(set (match_operand:SF 0 "s_register_operand" "")
5133 (float:SF (match_operand:SI 1 "s_register_operand" "")))]
5134 "TARGET_32BIT && TARGET_HARD_FLOAT"
5138 (define_expand "floatsidf2"
5139 [(set (match_operand:DF 0 "s_register_operand" "")
5140 (float:DF (match_operand:SI 1 "s_register_operand" "")))]
5141 "TARGET_32BIT && TARGET_HARD_FLOAT && !TARGET_VFP_SINGLE"
5145 (define_expand "fix_trunchfsi2"
5146 [(set (match_operand:SI 0 "general_operand" "")
5147 (fix:SI (fix:HF (match_operand:HF 1 "general_operand" ""))))]
5151 rtx op1 = convert_to_mode (SFmode, operands[1], 0);
5152 expand_fix (operands[0], op1, 0);
5157 (define_expand "fix_trunchfdi2"
5158 [(set (match_operand:DI 0 "general_operand" "")
5159 (fix:DI (fix:HF (match_operand:HF 1 "general_operand" ""))))]
5163 rtx op1 = convert_to_mode (SFmode, operands[1], 0);
5164 expand_fix (operands[0], op1, 0);
5169 (define_expand "fix_truncsfsi2"
5170 [(set (match_operand:SI 0 "s_register_operand" "")
5171 (fix:SI (fix:SF (match_operand:SF 1 "s_register_operand" ""))))]
5172 "TARGET_32BIT && TARGET_HARD_FLOAT"
5176 (define_expand "fix_truncdfsi2"
5177 [(set (match_operand:SI 0 "s_register_operand" "")
5178 (fix:SI (fix:DF (match_operand:DF 1 "s_register_operand" ""))))]
5179 "TARGET_32BIT && TARGET_HARD_FLOAT && !TARGET_VFP_SINGLE"
5185 (define_expand "truncdfsf2"
5186 [(set (match_operand:SF 0 "s_register_operand" "")
5188 (match_operand:DF 1 "s_register_operand" "")))]
5189 "TARGET_32BIT && TARGET_HARD_FLOAT && !TARGET_VFP_SINGLE"
5193 ;; DFmode to HFmode conversions on targets without a single-step hardware
5194 ;; instruction for it would have to go through SFmode. This is dangerous
5195 ;; as it introduces double rounding.
5197 ;; Disable this pattern unless we are in an unsafe math mode, or we have
5198 ;; a single-step instruction.
5200 (define_expand "truncdfhf2"
5201 [(set (match_operand:HF 0 "s_register_operand" "")
5203 (match_operand:DF 1 "s_register_operand" "")))]
5204 "(TARGET_EITHER && flag_unsafe_math_optimizations)
5205 || (TARGET_32BIT && TARGET_FP16_TO_DOUBLE)"
5207 /* We don't have a direct instruction for this, so we must be in
5208 an unsafe math mode, and going via SFmode. */
5210 if (!(TARGET_32BIT && TARGET_FP16_TO_DOUBLE))
5213 op1 = convert_to_mode (SFmode, operands[1], 0);
5214 op1 = convert_to_mode (HFmode, op1, 0);
5215 emit_move_insn (operands[0], op1);
5218 /* Otherwise, we will pick this up as a single instruction with
5219 no intermediary rounding. */
5223 ;; Zero and sign extension instructions.
5225 (define_insn "zero_extend<mode>di2"
5226 [(set (match_operand:DI 0 "s_register_operand" "=w,r,?r,w")
5227 (zero_extend:DI (match_operand:QHSI 1 "<qhs_zextenddi_op>"
5228 "<qhs_zextenddi_cstr>")))]
5229 "TARGET_32BIT <qhs_zextenddi_cond>"
5231 [(set_attr "length" "8,4,8,8")
5232 (set_attr "arch" "neon_for_64bits,*,*,avoid_neon_for_64bits")
5233 (set_attr "ce_count" "2")
5234 (set_attr "predicable" "yes")
5235 (set_attr "type" "multiple,mov_reg,multiple,multiple")]
5238 (define_insn "extend<mode>di2"
5239 [(set (match_operand:DI 0 "s_register_operand" "=w,r,?r,?r,w")
5240 (sign_extend:DI (match_operand:QHSI 1 "<qhs_extenddi_op>"
5241 "<qhs_extenddi_cstr>")))]
5242 "TARGET_32BIT <qhs_sextenddi_cond>"
5244 [(set_attr "length" "8,4,8,8,8")
5245 (set_attr "ce_count" "2")
5246 (set_attr "shift" "1")
5247 (set_attr "predicable" "yes")
5248 (set_attr "arch" "neon_for_64bits,*,a,t,avoid_neon_for_64bits")
5249 (set_attr "type" "multiple,mov_reg,multiple,multiple,multiple")]
5252 ;; Splits for all extensions to DImode
5254 [(set (match_operand:DI 0 "s_register_operand" "")
5255 (zero_extend:DI (match_operand 1 "nonimmediate_operand" "")))]
5256 "TARGET_32BIT && reload_completed && !IS_VFP_REGNUM (REGNO (operands[0]))"
5257 [(set (match_dup 0) (match_dup 1))]
5259 rtx lo_part = gen_lowpart (SImode, operands[0]);
5260 machine_mode src_mode = GET_MODE (operands[1]);
5262 if (REG_P (operands[0])
5263 && !reg_overlap_mentioned_p (operands[0], operands[1]))
5264 emit_clobber (operands[0]);
5265 if (!REG_P (lo_part) || src_mode != SImode
5266 || !rtx_equal_p (lo_part, operands[1]))
5268 if (src_mode == SImode)
5269 emit_move_insn (lo_part, operands[1]);
5271 emit_insn (gen_rtx_SET (lo_part,
5272 gen_rtx_ZERO_EXTEND (SImode, operands[1])));
5273 operands[1] = lo_part;
5275 operands[0] = gen_highpart (SImode, operands[0]);
5276 operands[1] = const0_rtx;
5280 [(set (match_operand:DI 0 "s_register_operand" "")
5281 (sign_extend:DI (match_operand 1 "nonimmediate_operand" "")))]
5282 "TARGET_32BIT && reload_completed && !IS_VFP_REGNUM (REGNO (operands[0]))"
5283 [(set (match_dup 0) (ashiftrt:SI (match_dup 1) (const_int 31)))]
5285 rtx lo_part = gen_lowpart (SImode, operands[0]);
5286 machine_mode src_mode = GET_MODE (operands[1]);
5288 if (REG_P (operands[0])
5289 && !reg_overlap_mentioned_p (operands[0], operands[1]))
5290 emit_clobber (operands[0]);
5292 if (!REG_P (lo_part) || src_mode != SImode
5293 || !rtx_equal_p (lo_part, operands[1]))
5295 if (src_mode == SImode)
5296 emit_move_insn (lo_part, operands[1]);
5298 emit_insn (gen_rtx_SET (lo_part,
5299 gen_rtx_SIGN_EXTEND (SImode, operands[1])));
5300 operands[1] = lo_part;
5302 operands[0] = gen_highpart (SImode, operands[0]);
5305 (define_expand "zero_extendhisi2"
5306 [(set (match_operand:SI 0 "s_register_operand" "")
5307 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
5310 if (TARGET_ARM && !arm_arch4 && MEM_P (operands[1]))
5312 emit_insn (gen_movhi_bytes (operands[0], operands[1]));
5315 if (!arm_arch6 && !MEM_P (operands[1]))
5317 rtx t = gen_lowpart (SImode, operands[1]);
5318 rtx tmp = gen_reg_rtx (SImode);
5319 emit_insn (gen_ashlsi3 (tmp, t, GEN_INT (16)));
5320 emit_insn (gen_lshrsi3 (operands[0], tmp, GEN_INT (16)));
5326 [(set (match_operand:SI 0 "s_register_operand" "")
5327 (zero_extend:SI (match_operand:HI 1 "s_register_operand" "")))]
5328 "!TARGET_THUMB2 && !arm_arch6"
5329 [(set (match_dup 0) (ashift:SI (match_dup 2) (const_int 16)))
5330 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 16)))]
5332 operands[2] = gen_lowpart (SImode, operands[1]);
5335 (define_insn "*arm_zero_extendhisi2"
5336 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
5337 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
5338 "TARGET_ARM && arm_arch4 && !arm_arch6"
5342 [(set_attr "type" "alu_shift_reg,load_byte")
5343 (set_attr "predicable" "yes")]
5346 (define_insn "*arm_zero_extendhisi2_v6"
5347 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
5348 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,Uh")))]
5349 "TARGET_ARM && arm_arch6"
5353 [(set_attr "predicable" "yes")
5354 (set_attr "type" "extend,load_byte")]
5357 (define_insn "*arm_zero_extendhisi2addsi"
5358 [(set (match_operand:SI 0 "s_register_operand" "=r")
5359 (plus:SI (zero_extend:SI (match_operand:HI 1 "s_register_operand" "r"))
5360 (match_operand:SI 2 "s_register_operand" "r")))]
5362 "uxtah%?\\t%0, %2, %1"
5363 [(set_attr "type" "alu_shift_reg")
5364 (set_attr "predicable" "yes")]
5367 (define_expand "zero_extendqisi2"
5368 [(set (match_operand:SI 0 "s_register_operand" "")
5369 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
5372 if (TARGET_ARM && !arm_arch6 && !MEM_P (operands[1]))
5374 emit_insn (gen_andsi3 (operands[0],
5375 gen_lowpart (SImode, operands[1]),
5379 if (!arm_arch6 && !MEM_P (operands[1]))
5381 rtx t = gen_lowpart (SImode, operands[1]);
5382 rtx tmp = gen_reg_rtx (SImode);
5383 emit_insn (gen_ashlsi3 (tmp, t, GEN_INT (24)));
5384 emit_insn (gen_lshrsi3 (operands[0], tmp, GEN_INT (24)));
5390 [(set (match_operand:SI 0 "s_register_operand" "")
5391 (zero_extend:SI (match_operand:QI 1 "s_register_operand" "")))]
5393 [(set (match_dup 0) (ashift:SI (match_dup 2) (const_int 24)))
5394 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 24)))]
5396 operands[2] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
5399 emit_insn (gen_andsi3 (operands[0], operands[2], GEN_INT (255)));
5404 (define_insn "*arm_zero_extendqisi2"
5405 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
5406 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
5407 "TARGET_ARM && !arm_arch6"
5410 ldrb%?\\t%0, %1\\t%@ zero_extendqisi2"
5411 [(set_attr "length" "8,4")
5412 (set_attr "type" "alu_shift_reg,load_byte")
5413 (set_attr "predicable" "yes")]
5416 (define_insn "*arm_zero_extendqisi2_v6"
5417 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
5418 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,Uh")))]
5419 "TARGET_ARM && arm_arch6"
5422 ldrb%?\\t%0, %1\\t%@ zero_extendqisi2"
5423 [(set_attr "type" "extend,load_byte")
5424 (set_attr "predicable" "yes")]
5427 (define_insn "*arm_zero_extendqisi2addsi"
5428 [(set (match_operand:SI 0 "s_register_operand" "=r")
5429 (plus:SI (zero_extend:SI (match_operand:QI 1 "s_register_operand" "r"))
5430 (match_operand:SI 2 "s_register_operand" "r")))]
5432 "uxtab%?\\t%0, %2, %1"
5433 [(set_attr "predicable" "yes")
5434 (set_attr "type" "alu_shift_reg")]
5438 [(set (match_operand:SI 0 "s_register_operand" "")
5439 (zero_extend:SI (subreg:QI (match_operand:SI 1 "" "") 0)))
5440 (clobber (match_operand:SI 2 "s_register_operand" ""))]
5441 "TARGET_32BIT && (!MEM_P (operands[1])) && ! BYTES_BIG_ENDIAN"
5442 [(set (match_dup 2) (match_dup 1))
5443 (set (match_dup 0) (and:SI (match_dup 2) (const_int 255)))]
5448 [(set (match_operand:SI 0 "s_register_operand" "")
5449 (zero_extend:SI (subreg:QI (match_operand:SI 1 "" "") 3)))
5450 (clobber (match_operand:SI 2 "s_register_operand" ""))]
5451 "TARGET_32BIT && (!MEM_P (operands[1])) && BYTES_BIG_ENDIAN"
5452 [(set (match_dup 2) (match_dup 1))
5453 (set (match_dup 0) (and:SI (match_dup 2) (const_int 255)))]
5459 [(set (match_operand:SI 0 "s_register_operand" "")
5460 (IOR_XOR:SI (and:SI (ashift:SI
5461 (match_operand:SI 1 "s_register_operand" "")
5462 (match_operand:SI 2 "const_int_operand" ""))
5463 (match_operand:SI 3 "const_int_operand" ""))
5465 (match_operator 5 "subreg_lowpart_operator"
5466 [(match_operand:SI 4 "s_register_operand" "")]))))]
5468 && (UINTVAL (operands[3])
5469 == (GET_MODE_MASK (GET_MODE (operands[5]))
5470 & (GET_MODE_MASK (GET_MODE (operands[5]))
5471 << (INTVAL (operands[2])))))"
5472 [(set (match_dup 0) (IOR_XOR:SI (ashift:SI (match_dup 1) (match_dup 2))
5474 (set (match_dup 0) (zero_extend:SI (match_dup 5)))]
5475 "operands[5] = gen_lowpart (GET_MODE (operands[5]), operands[0]);"
5478 (define_insn "*compareqi_eq0"
5479 [(set (reg:CC_Z CC_REGNUM)
5480 (compare:CC_Z (match_operand:QI 0 "s_register_operand" "r")
5484 [(set_attr "conds" "set")
5485 (set_attr "predicable" "yes")
5486 (set_attr "type" "logic_imm")]
5489 (define_expand "extendhisi2"
5490 [(set (match_operand:SI 0 "s_register_operand" "")
5491 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
5496 emit_insn (gen_thumb1_extendhisi2 (operands[0], operands[1]));
5499 if (MEM_P (operands[1]) && TARGET_ARM && !arm_arch4)
5501 emit_insn (gen_extendhisi2_mem (operands[0], operands[1]));
5505 if (!arm_arch6 && !MEM_P (operands[1]))
5507 rtx t = gen_lowpart (SImode, operands[1]);
5508 rtx tmp = gen_reg_rtx (SImode);
5509 emit_insn (gen_ashlsi3 (tmp, t, GEN_INT (16)));
5510 emit_insn (gen_ashrsi3 (operands[0], tmp, GEN_INT (16)));
5517 [(set (match_operand:SI 0 "register_operand" "")
5518 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))
5519 (clobber (match_scratch:SI 2 ""))])]
5521 [(set (match_dup 0) (ashift:SI (match_dup 2) (const_int 16)))
5522 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 16)))]
5524 operands[2] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
5527 ;; This pattern will only be used when ldsh is not available
5528 (define_expand "extendhisi2_mem"
5529 [(set (match_dup 2) (zero_extend:SI (match_operand:HI 1 "" "")))
5531 (zero_extend:SI (match_dup 7)))
5532 (set (match_dup 6) (ashift:SI (match_dup 4) (const_int 24)))
5533 (set (match_operand:SI 0 "" "")
5534 (ior:SI (ashiftrt:SI (match_dup 6) (const_int 16)) (match_dup 5)))]
5539 rtx addr = copy_to_mode_reg (SImode, XEXP (operands[1], 0));
5541 mem1 = change_address (operands[1], QImode, addr);
5542 mem2 = change_address (operands[1], QImode,
5543 plus_constant (Pmode, addr, 1));
5544 operands[0] = gen_lowpart (SImode, operands[0]);
5546 operands[2] = gen_reg_rtx (SImode);
5547 operands[3] = gen_reg_rtx (SImode);
5548 operands[6] = gen_reg_rtx (SImode);
5551 if (BYTES_BIG_ENDIAN)
5553 operands[4] = operands[2];
5554 operands[5] = operands[3];
5558 operands[4] = operands[3];
5559 operands[5] = operands[2];
5565 [(set (match_operand:SI 0 "register_operand" "")
5566 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
5568 [(set (match_dup 0) (ashift:SI (match_dup 2) (const_int 16)))
5569 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 16)))]
5571 operands[2] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
5574 (define_insn "*arm_extendhisi2"
5575 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
5576 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,Uh")))]
5577 "TARGET_ARM && arm_arch4 && !arm_arch6"
5581 [(set_attr "length" "8,4")
5582 (set_attr "type" "alu_shift_reg,load_byte")
5583 (set_attr "predicable" "yes")]
5586 ;; ??? Check Thumb-2 pool range
5587 (define_insn "*arm_extendhisi2_v6"
5588 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
5589 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,Uh")))]
5590 "TARGET_32BIT && arm_arch6"
5594 [(set_attr "type" "extend,load_byte")
5595 (set_attr "predicable" "yes")]
5598 (define_insn "*arm_extendhisi2addsi"
5599 [(set (match_operand:SI 0 "s_register_operand" "=r")
5600 (plus:SI (sign_extend:SI (match_operand:HI 1 "s_register_operand" "r"))
5601 (match_operand:SI 2 "s_register_operand" "r")))]
5603 "sxtah%?\\t%0, %2, %1"
5604 [(set_attr "type" "alu_shift_reg")]
5607 (define_expand "extendqihi2"
5609 (ashift:SI (match_operand:QI 1 "arm_reg_or_extendqisi_mem_op" "")
5611 (set (match_operand:HI 0 "s_register_operand" "")
5612 (ashiftrt:SI (match_dup 2)
5617 if (arm_arch4 && MEM_P (operands[1]))
5619 emit_insn (gen_rtx_SET (operands[0],
5620 gen_rtx_SIGN_EXTEND (HImode, operands[1])));
5623 if (!s_register_operand (operands[1], QImode))
5624 operands[1] = copy_to_mode_reg (QImode, operands[1]);
5625 operands[0] = gen_lowpart (SImode, operands[0]);
5626 operands[1] = gen_lowpart (SImode, operands[1]);
5627 operands[2] = gen_reg_rtx (SImode);
5631 (define_insn "*arm_extendqihi_insn"
5632 [(set (match_operand:HI 0 "s_register_operand" "=r")
5633 (sign_extend:HI (match_operand:QI 1 "arm_extendqisi_mem_op" "Uq")))]
5634 "TARGET_ARM && arm_arch4"
5636 [(set_attr "type" "load_byte")
5637 (set_attr "predicable" "yes")]
5640 (define_expand "extendqisi2"
5641 [(set (match_operand:SI 0 "s_register_operand" "")
5642 (sign_extend:SI (match_operand:QI 1 "arm_reg_or_extendqisi_mem_op" "")))]
5645 if (!arm_arch4 && MEM_P (operands[1]))
5646 operands[1] = copy_to_mode_reg (QImode, operands[1]);
5648 if (!arm_arch6 && !MEM_P (operands[1]))
5650 rtx t = gen_lowpart (SImode, operands[1]);
5651 rtx tmp = gen_reg_rtx (SImode);
5652 emit_insn (gen_ashlsi3 (tmp, t, GEN_INT (24)));
5653 emit_insn (gen_ashrsi3 (operands[0], tmp, GEN_INT (24)));
5659 [(set (match_operand:SI 0 "register_operand" "")
5660 (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
5662 [(set (match_dup 0) (ashift:SI (match_dup 2) (const_int 24)))
5663 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 24)))]
5665 operands[2] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
5668 (define_insn "*arm_extendqisi"
5669 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
5670 (sign_extend:SI (match_operand:QI 1 "arm_reg_or_extendqisi_mem_op" "r,Uq")))]
5671 "TARGET_ARM && arm_arch4 && !arm_arch6"
5675 [(set_attr "length" "8,4")
5676 (set_attr "type" "alu_shift_reg,load_byte")
5677 (set_attr "predicable" "yes")]
5680 (define_insn "*arm_extendqisi_v6"
5681 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
5683 (match_operand:QI 1 "arm_reg_or_extendqisi_mem_op" "r,Uq")))]
5684 "TARGET_ARM && arm_arch6"
5688 [(set_attr "type" "extend,load_byte")
5689 (set_attr "predicable" "yes")]
5692 (define_insn "*arm_extendqisi2addsi"
5693 [(set (match_operand:SI 0 "s_register_operand" "=r")
5694 (plus:SI (sign_extend:SI (match_operand:QI 1 "s_register_operand" "r"))
5695 (match_operand:SI 2 "s_register_operand" "r")))]
5697 "sxtab%?\\t%0, %2, %1"
5698 [(set_attr "type" "alu_shift_reg")
5699 (set_attr "predicable" "yes")]
5702 (define_expand "extendsfdf2"
5703 [(set (match_operand:DF 0 "s_register_operand" "")
5704 (float_extend:DF (match_operand:SF 1 "s_register_operand" "")))]
5705 "TARGET_32BIT && TARGET_HARD_FLOAT && !TARGET_VFP_SINGLE"
5709 ;; HFmode -> DFmode conversions where we don't have an instruction for it
5710 ;; must go through SFmode.
5712 ;; This is always safe for an extend.
5714 (define_expand "extendhfdf2"
5715 [(set (match_operand:DF 0 "s_register_operand" "")
5716 (float_extend:DF (match_operand:HF 1 "s_register_operand" "")))]
5719 /* We don't have a direct instruction for this, so go via SFmode. */
5720 if (!(TARGET_32BIT && TARGET_FP16_TO_DOUBLE))
5723 op1 = convert_to_mode (SFmode, operands[1], 0);
5724 op1 = convert_to_mode (DFmode, op1, 0);
5725 emit_insn (gen_movdf (operands[0], op1));
5728 /* Otherwise, we're done producing RTL and will pick up the correct
5729 pattern to do this with one rounding-step in a single instruction. */
5733 ;; Move insns (including loads and stores)
5735 ;; XXX Just some ideas about movti.
5736 ;; I don't think these are a good idea on the arm, there just aren't enough
5738 ;;(define_expand "loadti"
5739 ;; [(set (match_operand:TI 0 "s_register_operand" "")
5740 ;; (mem:TI (match_operand:SI 1 "address_operand" "")))]
5743 ;;(define_expand "storeti"
5744 ;; [(set (mem:TI (match_operand:TI 0 "address_operand" ""))
5745 ;; (match_operand:TI 1 "s_register_operand" ""))]
5748 ;;(define_expand "movti"
5749 ;; [(set (match_operand:TI 0 "general_operand" "")
5750 ;; (match_operand:TI 1 "general_operand" ""))]
5756 ;; if (MEM_P (operands[0]) && MEM_P (operands[1]))
5757 ;; operands[1] = copy_to_reg (operands[1]);
5758 ;; if (MEM_P (operands[0]))
5759 ;; insn = gen_storeti (XEXP (operands[0], 0), operands[1]);
5760 ;; else if (MEM_P (operands[1]))
5761 ;; insn = gen_loadti (operands[0], XEXP (operands[1], 0));
5765 ;; emit_insn (insn);
5769 ;; Recognize garbage generated above.
5772 ;; [(set (match_operand:TI 0 "general_operand" "=r,r,r,<,>,m")
5773 ;; (match_operand:TI 1 "general_operand" "<,>,m,r,r,r"))]
5777 ;; register mem = (which_alternative < 3);
5778 ;; register const char *template;
5780 ;; operands[mem] = XEXP (operands[mem], 0);
5781 ;; switch (which_alternative)
5783 ;; case 0: template = \"ldmdb\\t%1!, %M0\"; break;
5784 ;; case 1: template = \"ldmia\\t%1!, %M0\"; break;
5785 ;; case 2: template = \"ldmia\\t%1, %M0\"; break;
5786 ;; case 3: template = \"stmdb\\t%0!, %M1\"; break;
5787 ;; case 4: template = \"stmia\\t%0!, %M1\"; break;
5788 ;; case 5: template = \"stmia\\t%0, %M1\"; break;
5790 ;; output_asm_insn (template, operands);
5794 (define_expand "movdi"
5795 [(set (match_operand:DI 0 "general_operand" "")
5796 (match_operand:DI 1 "general_operand" ""))]
5799 if (can_create_pseudo_p ())
5801 if (!REG_P (operands[0]))
5802 operands[1] = force_reg (DImode, operands[1]);
5804 if (REG_P (operands[0]) && REGNO (operands[0]) <= LAST_ARM_REGNUM
5805 && !targetm.hard_regno_mode_ok (REGNO (operands[0]), DImode))
5807 /* Avoid LDRD's into an odd-numbered register pair in ARM state
5808 when expanding function calls. */
5809 gcc_assert (can_create_pseudo_p ());
5810 if (MEM_P (operands[1]) && MEM_VOLATILE_P (operands[1]))
5812 /* Perform load into legal reg pair first, then move. */
5813 rtx reg = gen_reg_rtx (DImode);
5814 emit_insn (gen_movdi (reg, operands[1]));
5817 emit_move_insn (gen_lowpart (SImode, operands[0]),
5818 gen_lowpart (SImode, operands[1]));
5819 emit_move_insn (gen_highpart (SImode, operands[0]),
5820 gen_highpart (SImode, operands[1]));
5823 else if (REG_P (operands[1]) && REGNO (operands[1]) <= LAST_ARM_REGNUM
5824 && !targetm.hard_regno_mode_ok (REGNO (operands[1]), DImode))
5826 /* Avoid STRD's from an odd-numbered register pair in ARM state
5827 when expanding function prologue. */
5828 gcc_assert (can_create_pseudo_p ());
5829 rtx split_dest = (MEM_P (operands[0]) && MEM_VOLATILE_P (operands[0]))
5830 ? gen_reg_rtx (DImode)
5832 emit_move_insn (gen_lowpart (SImode, split_dest),
5833 gen_lowpart (SImode, operands[1]));
5834 emit_move_insn (gen_highpart (SImode, split_dest),
5835 gen_highpart (SImode, operands[1]));
5836 if (split_dest != operands[0])
5837 emit_insn (gen_movdi (operands[0], split_dest));
5843 (define_insn "*arm_movdi"
5844 [(set (match_operand:DI 0 "nonimmediate_di_operand" "=r, r, r, r, m")
5845 (match_operand:DI 1 "di_operand" "rDa,Db,Dc,mi,r"))]
5847 && !(TARGET_HARD_FLOAT)
5849 && ( register_operand (operands[0], DImode)
5850 || register_operand (operands[1], DImode))"
5852 switch (which_alternative)
5859 /* Cannot load it directly, split to load it via MOV / MOVT. */
5860 if (!MEM_P (operands[1]) && arm_disable_literal_pool)
5864 return output_move_double (operands, true, NULL);
5867 [(set_attr "length" "8,12,16,8,8")
5868 (set_attr "type" "multiple,multiple,multiple,load_8,store_8")
5869 (set_attr "arm_pool_range" "*,*,*,1020,*")
5870 (set_attr "arm_neg_pool_range" "*,*,*,1004,*")
5871 (set_attr "thumb2_pool_range" "*,*,*,4094,*")
5872 (set_attr "thumb2_neg_pool_range" "*,*,*,0,*")]
5876 [(set (match_operand:ANY64 0 "arm_general_register_operand" "")
5877 (match_operand:ANY64 1 "immediate_operand" ""))]
5880 && (arm_disable_literal_pool
5881 || (arm_const_double_inline_cost (operands[1])
5882 <= arm_max_const_double_inline_cost ()))"
5885 arm_split_constant (SET, SImode, curr_insn,
5886 INTVAL (gen_lowpart (SImode, operands[1])),
5887 gen_lowpart (SImode, operands[0]), NULL_RTX, 0);
5888 arm_split_constant (SET, SImode, curr_insn,
5889 INTVAL (gen_highpart_mode (SImode,
5890 GET_MODE (operands[0]),
5892 gen_highpart (SImode, operands[0]), NULL_RTX, 0);
5897 ; If optimizing for size, or if we have load delay slots, then
5898 ; we want to split the constant into two separate operations.
5899 ; In both cases this may split a trivial part into a single data op
5900 ; leaving a single complex constant to load. We can also get longer
5901 ; offsets in a LDR which means we get better chances of sharing the pool
5902 ; entries. Finally, we can normally do a better job of scheduling
5903 ; LDR instructions than we can with LDM.
5904 ; This pattern will only match if the one above did not.
5906 [(set (match_operand:ANY64 0 "arm_general_register_operand" "")
5907 (match_operand:ANY64 1 "const_double_operand" ""))]
5908 "TARGET_ARM && reload_completed
5909 && arm_const_double_by_parts (operands[1])"
5910 [(set (match_dup 0) (match_dup 1))
5911 (set (match_dup 2) (match_dup 3))]
5913 operands[2] = gen_highpart (SImode, operands[0]);
5914 operands[3] = gen_highpart_mode (SImode, GET_MODE (operands[0]),
5916 operands[0] = gen_lowpart (SImode, operands[0]);
5917 operands[1] = gen_lowpart (SImode, operands[1]);
5922 [(set (match_operand:ANY64 0 "arm_general_register_operand" "")
5923 (match_operand:ANY64 1 "arm_general_register_operand" ""))]
5924 "TARGET_EITHER && reload_completed"
5925 [(set (match_dup 0) (match_dup 1))
5926 (set (match_dup 2) (match_dup 3))]
5928 operands[2] = gen_highpart (SImode, operands[0]);
5929 operands[3] = gen_highpart (SImode, operands[1]);
5930 operands[0] = gen_lowpart (SImode, operands[0]);
5931 operands[1] = gen_lowpart (SImode, operands[1]);
5933 /* Handle a partial overlap. */
5934 if (rtx_equal_p (operands[0], operands[3]))
5936 rtx tmp0 = operands[0];
5937 rtx tmp1 = operands[1];
5939 operands[0] = operands[2];
5940 operands[1] = operands[3];
5947 ;; We can't actually do base+index doubleword loads if the index and
5948 ;; destination overlap. Split here so that we at least have chance to
5951 [(set (match_operand:DI 0 "s_register_operand" "")
5952 (mem:DI (plus:SI (match_operand:SI 1 "s_register_operand" "")
5953 (match_operand:SI 2 "s_register_operand" ""))))]
5955 && reg_overlap_mentioned_p (operands[0], operands[1])
5956 && reg_overlap_mentioned_p (operands[0], operands[2])"
5958 (plus:SI (match_dup 1)
5961 (mem:DI (match_dup 4)))]
5963 operands[4] = gen_rtx_REG (SImode, REGNO(operands[0]));
5967 (define_expand "movsi"
5968 [(set (match_operand:SI 0 "general_operand" "")
5969 (match_operand:SI 1 "general_operand" ""))]
5973 rtx base, offset, tmp;
5975 if (TARGET_32BIT || TARGET_HAVE_MOVT)
5977 /* Everything except mem = const or mem = mem can be done easily. */
5978 if (MEM_P (operands[0]))
5979 operands[1] = force_reg (SImode, operands[1]);
5980 if (arm_general_register_operand (operands[0], SImode)
5981 && CONST_INT_P (operands[1])
5982 && !(const_ok_for_arm (INTVAL (operands[1]))
5983 || const_ok_for_arm (~INTVAL (operands[1]))))
5985 if (DONT_EARLY_SPLIT_CONSTANT (INTVAL (operands[1]), SET))
5987 emit_insn (gen_rtx_SET (operands[0], operands[1]));
5992 arm_split_constant (SET, SImode, NULL_RTX,
5993 INTVAL (operands[1]), operands[0], NULL_RTX,
5994 optimize && can_create_pseudo_p ());
5999 else /* Target doesn't have MOVT... */
6001 if (can_create_pseudo_p ())
6003 if (!REG_P (operands[0]))
6004 operands[1] = force_reg (SImode, operands[1]);
6008 if (ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P)
6010 split_const (operands[1], &base, &offset);
6011 if (GET_CODE (base) == SYMBOL_REF
6012 && !offset_within_block_p (base, INTVAL (offset)))
6014 tmp = can_create_pseudo_p () ? gen_reg_rtx (SImode) : operands[0];
6015 emit_move_insn (tmp, base);
6016 emit_insn (gen_addsi3 (operands[0], tmp, offset));
6021 /* Recognize the case where operand[1] is a reference to thread-local
6022 data and load its address to a register. */
6023 if (arm_tls_referenced_p (operands[1]))
6025 rtx tmp = operands[1];
6028 if (GET_CODE (tmp) == CONST && GET_CODE (XEXP (tmp, 0)) == PLUS)
6030 addend = XEXP (XEXP (tmp, 0), 1);
6031 tmp = XEXP (XEXP (tmp, 0), 0);
6034 gcc_assert (GET_CODE (tmp) == SYMBOL_REF);
6035 gcc_assert (SYMBOL_REF_TLS_MODEL (tmp) != 0);
6037 tmp = legitimize_tls_address (tmp,
6038 !can_create_pseudo_p () ? operands[0] : 0);
6041 tmp = gen_rtx_PLUS (SImode, tmp, addend);
6042 tmp = force_operand (tmp, operands[0]);
6047 && (CONSTANT_P (operands[1])
6048 || symbol_mentioned_p (operands[1])
6049 || label_mentioned_p (operands[1])))
6050 operands[1] = legitimize_pic_address (operands[1], SImode,
6051 (!can_create_pseudo_p ()
6053 : NULL_RTX), NULL_RTX,
6054 false /*compute_now*/);
6059 ;; The ARM LO_SUM and HIGH are backwards - HIGH sets the low bits, and
6060 ;; LO_SUM adds in the high bits. Fortunately these are opaque operations
6061 ;; so this does not matter.
6062 (define_insn "*arm_movt"
6063 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r")
6064 (lo_sum:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
6065 (match_operand:SI 2 "general_operand" "i,i")))]
6066 "TARGET_HAVE_MOVT && arm_valid_symbolic_address_p (operands[2])"
6068 movt%?\t%0, #:upper16:%c2
6069 movt\t%0, #:upper16:%c2"
6070 [(set_attr "arch" "32,v8mb")
6071 (set_attr "predicable" "yes")
6072 (set_attr "length" "4")
6073 (set_attr "type" "alu_sreg")]
6076 (define_insn "*arm_movsi_insn"
6077 [(set (match_operand:SI 0 "nonimmediate_operand" "=rk,r,r,r,rk,m")
6078 (match_operand:SI 1 "general_operand" "rk, I,K,j,mi,rk"))]
6079 "TARGET_ARM && !TARGET_IWMMXT && !TARGET_HARD_FLOAT
6080 && ( register_operand (operands[0], SImode)
6081 || register_operand (operands[1], SImode))"
6089 [(set_attr "type" "mov_reg,mov_imm,mvn_imm,mov_imm,load_4,store_4")
6090 (set_attr "predicable" "yes")
6091 (set_attr "arch" "*,*,*,v6t2,*,*")
6092 (set_attr "pool_range" "*,*,*,*,4096,*")
6093 (set_attr "neg_pool_range" "*,*,*,*,4084,*")]
6097 [(set (match_operand:SI 0 "arm_general_register_operand" "")
6098 (match_operand:SI 1 "const_int_operand" ""))]
6099 "(TARGET_32BIT || TARGET_HAVE_MOVT)
6100 && (!(const_ok_for_arm (INTVAL (operands[1]))
6101 || const_ok_for_arm (~INTVAL (operands[1]))))"
6102 [(clobber (const_int 0))]
6104 arm_split_constant (SET, SImode, NULL_RTX,
6105 INTVAL (operands[1]), operands[0], NULL_RTX, 0);
6110 ;; A normal way to do (symbol + offset) requires three instructions at least
6111 ;; (depends on how big the offset is) as below:
6112 ;; movw r0, #:lower16:g
6113 ;; movw r0, #:upper16:g
6116 ;; A better way would be:
6117 ;; movw r0, #:lower16:g+4
6118 ;; movw r0, #:upper16:g+4
6120 ;; The limitation of this way is that the length of offset should be a 16-bit
6121 ;; signed value, because current assembler only supports REL type relocation for
6122 ;; such case. If the more powerful RELA type is supported in future, we should
6123 ;; update this pattern to go with better way.
6125 [(set (match_operand:SI 0 "arm_general_register_operand" "")
6126 (const:SI (plus:SI (match_operand:SI 1 "general_operand" "")
6127 (match_operand:SI 2 "const_int_operand" ""))))]
6130 && arm_disable_literal_pool
6132 && GET_CODE (operands[1]) == SYMBOL_REF"
6133 [(clobber (const_int 0))]
6135 int offset = INTVAL (operands[2]);
6137 if (offset < -0x8000 || offset > 0x7fff)
6139 arm_emit_movpair (operands[0], operands[1]);
6140 emit_insn (gen_rtx_SET (operands[0],
6141 gen_rtx_PLUS (SImode, operands[0], operands[2])));
6145 rtx op = gen_rtx_CONST (SImode,
6146 gen_rtx_PLUS (SImode, operands[1], operands[2]));
6147 arm_emit_movpair (operands[0], op);
6152 ;; Split symbol_refs at the later stage (after cprop), instead of generating
6153 ;; movt/movw pair directly at expand. Otherwise corresponding high_sum
6154 ;; and lo_sum would be merged back into memory load at cprop. However,
6155 ;; if the default is to prefer movt/movw rather than a load from the constant
6156 ;; pool, the performance is better.
6158 [(set (match_operand:SI 0 "arm_general_register_operand" "")
6159 (match_operand:SI 1 "general_operand" ""))]
6160 "TARGET_USE_MOVT && GET_CODE (operands[1]) == SYMBOL_REF
6161 && !target_word_relocations
6162 && !arm_tls_referenced_p (operands[1])"
6163 [(clobber (const_int 0))]
6165 arm_emit_movpair (operands[0], operands[1]);
6169 ;; When generating pic, we need to load the symbol offset into a register.
6170 ;; So that the optimizer does not confuse this with a normal symbol load
6171 ;; we use an unspec. The offset will be loaded from a constant pool entry,
6172 ;; since that is the only type of relocation we can use.
6174 ;; Wrap calculation of the whole PIC address in a single pattern for the
6175 ;; benefit of optimizers, particularly, PRE and HOIST. Calculation of
6176 ;; a PIC address involves two loads from memory, so we want to CSE it
6177 ;; as often as possible.
6178 ;; This pattern will be split into one of the pic_load_addr_* patterns
6179 ;; and a move after GCSE optimizations.
6181 ;; Note: Update arm.c: legitimize_pic_address() when changing this pattern.
6182 (define_expand "calculate_pic_address"
6183 [(set (match_operand:SI 0 "register_operand" "")
6184 (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "")
6185 (unspec:SI [(match_operand:SI 2 "" "")]
6190 ;; Split calculate_pic_address into pic_load_addr_* and a move.
6192 [(set (match_operand:SI 0 "register_operand" "")
6193 (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "")
6194 (unspec:SI [(match_operand:SI 2 "" "")]
6197 [(set (match_dup 3) (unspec:SI [(match_dup 2)] UNSPEC_PIC_SYM))
6198 (set (match_dup 0) (mem:SI (plus:SI (match_dup 1) (match_dup 3))))]
6199 "operands[3] = can_create_pseudo_p () ? gen_reg_rtx (SImode) : operands[0];"
6202 ;; operand1 is the memory address to go into
6203 ;; pic_load_addr_32bit.
6204 ;; operand2 is the PIC label to be emitted
6205 ;; from pic_add_dot_plus_eight.
6206 ;; We do this to allow hoisting of the entire insn.
6207 (define_insn_and_split "pic_load_addr_unified"
6208 [(set (match_operand:SI 0 "s_register_operand" "=r,r,l")
6209 (unspec:SI [(match_operand:SI 1 "" "mX,mX,mX")
6210 (match_operand:SI 2 "" "")]
6211 UNSPEC_PIC_UNIFIED))]
6214 "&& reload_completed"
6215 [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_PIC_SYM))
6216 (set (match_dup 0) (unspec:SI [(match_dup 0) (match_dup 3)
6217 (match_dup 2)] UNSPEC_PIC_BASE))]
6218 "operands[3] = TARGET_THUMB ? GEN_INT (4) : GEN_INT (8);"
6219 [(set_attr "type" "load_4,load_4,load_4")
6220 (set_attr "pool_range" "4096,4094,1022")
6221 (set_attr "neg_pool_range" "4084,0,0")
6222 (set_attr "arch" "a,t2,t1")
6223 (set_attr "length" "8,6,4")]
6226 ;; The rather odd constraints on the following are to force reload to leave
6227 ;; the insn alone, and to force the minipool generation pass to then move
6228 ;; the GOT symbol to memory.
6230 (define_insn "pic_load_addr_32bit"
6231 [(set (match_operand:SI 0 "s_register_operand" "=r")
6232 (unspec:SI [(match_operand:SI 1 "" "mX")] UNSPEC_PIC_SYM))]
6233 "TARGET_32BIT && flag_pic"
6235 [(set_attr "type" "load_4")
6236 (set (attr "pool_range")
6237 (if_then_else (eq_attr "is_thumb" "no")
6240 (set (attr "neg_pool_range")
6241 (if_then_else (eq_attr "is_thumb" "no")
6246 (define_insn "pic_load_addr_thumb1"
6247 [(set (match_operand:SI 0 "s_register_operand" "=l")
6248 (unspec:SI [(match_operand:SI 1 "" "mX")] UNSPEC_PIC_SYM))]
6249 "TARGET_THUMB1 && flag_pic"
6251 [(set_attr "type" "load_4")
6252 (set (attr "pool_range") (const_int 1018))]
6255 (define_insn "pic_add_dot_plus_four"
6256 [(set (match_operand:SI 0 "register_operand" "=r")
6257 (unspec:SI [(match_operand:SI 1 "register_operand" "0")
6259 (match_operand 2 "" "")]
6263 (*targetm.asm_out.internal_label) (asm_out_file, \"LPIC\",
6264 INTVAL (operands[2]));
6265 return \"add\\t%0, %|pc\";
6267 [(set_attr "length" "2")
6268 (set_attr "type" "alu_sreg")]
6271 (define_insn "pic_add_dot_plus_eight"
6272 [(set (match_operand:SI 0 "register_operand" "=r")
6273 (unspec:SI [(match_operand:SI 1 "register_operand" "r")
6275 (match_operand 2 "" "")]
6279 (*targetm.asm_out.internal_label) (asm_out_file, \"LPIC\",
6280 INTVAL (operands[2]));
6281 return \"add%?\\t%0, %|pc, %1\";
6283 [(set_attr "predicable" "yes")
6284 (set_attr "type" "alu_sreg")]
6287 (define_insn "tls_load_dot_plus_eight"
6288 [(set (match_operand:SI 0 "register_operand" "=r")
6289 (mem:SI (unspec:SI [(match_operand:SI 1 "register_operand" "r")
6291 (match_operand 2 "" "")]
6295 (*targetm.asm_out.internal_label) (asm_out_file, \"LPIC\",
6296 INTVAL (operands[2]));
6297 return \"ldr%?\\t%0, [%|pc, %1]\t\t@ tls_load_dot_plus_eight\";
6299 [(set_attr "predicable" "yes")
6300 (set_attr "type" "load_4")]
6303 ;; PIC references to local variables can generate pic_add_dot_plus_eight
6304 ;; followed by a load. These sequences can be crunched down to
6305 ;; tls_load_dot_plus_eight by a peephole.
6308 [(set (match_operand:SI 0 "register_operand" "")
6309 (unspec:SI [(match_operand:SI 3 "register_operand" "")
6311 (match_operand 1 "" "")]
6313 (set (match_operand:SI 2 "arm_general_register_operand" "")
6314 (mem:SI (match_dup 0)))]
6315 "TARGET_ARM && peep2_reg_dead_p (2, operands[0])"
6317 (mem:SI (unspec:SI [(match_dup 3)
6324 (define_insn "pic_offset_arm"
6325 [(set (match_operand:SI 0 "register_operand" "=r")
6326 (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "r")
6327 (unspec:SI [(match_operand:SI 2 "" "X")]
6328 UNSPEC_PIC_OFFSET))))]
6329 "TARGET_VXWORKS_RTP && TARGET_ARM && flag_pic"
6330 "ldr%?\\t%0, [%1,%2]"
6331 [(set_attr "type" "load_4")]
6334 (define_expand "builtin_setjmp_receiver"
6335 [(label_ref (match_operand 0 "" ""))]
6339 /* r3 is clobbered by set/longjmp, so we can use it as a scratch
6341 if (arm_pic_register != INVALID_REGNUM)
6342 arm_load_pic_register (1UL << 3, NULL_RTX);
6346 ;; If copying one reg to another we can set the condition codes according to
6347 ;; its value. Such a move is common after a return from subroutine and the
6348 ;; result is being tested against zero.
6350 (define_insn "*movsi_compare0"
6351 [(set (reg:CC CC_REGNUM)
6352 (compare:CC (match_operand:SI 1 "s_register_operand" "0,r")
6354 (set (match_operand:SI 0 "s_register_operand" "=r,r")
6359 subs%?\\t%0, %1, #0"
6360 [(set_attr "conds" "set")
6361 (set_attr "type" "alus_imm,alus_imm")]
6364 ;; Subroutine to store a half word from a register into memory.
6365 ;; Operand 0 is the source register (HImode)
6366 ;; Operand 1 is the destination address in a register (SImode)
6368 ;; In both this routine and the next, we must be careful not to spill
6369 ;; a memory address of reg+large_const into a separate PLUS insn, since this
6370 ;; can generate unrecognizable rtl.
6372 (define_expand "storehi"
6373 [;; store the low byte
6374 (set (match_operand 1 "" "") (match_dup 3))
6375 ;; extract the high byte
6377 (ashiftrt:SI (match_operand 0 "" "") (const_int 8)))
6378 ;; store the high byte
6379 (set (match_dup 4) (match_dup 5))]
6383 rtx op1 = operands[1];
6384 rtx addr = XEXP (op1, 0);
6385 enum rtx_code code = GET_CODE (addr);
6387 if ((code == PLUS && !CONST_INT_P (XEXP (addr, 1)))
6389 op1 = replace_equiv_address (operands[1], force_reg (SImode, addr));
6391 operands[4] = adjust_address (op1, QImode, 1);
6392 operands[1] = adjust_address (operands[1], QImode, 0);
6393 operands[3] = gen_lowpart (QImode, operands[0]);
6394 operands[0] = gen_lowpart (SImode, operands[0]);
6395 operands[2] = gen_reg_rtx (SImode);
6396 operands[5] = gen_lowpart (QImode, operands[2]);
6400 (define_expand "storehi_bigend"
6401 [(set (match_dup 4) (match_dup 3))
6403 (ashiftrt:SI (match_operand 0 "" "") (const_int 8)))
6404 (set (match_operand 1 "" "") (match_dup 5))]
6408 rtx op1 = operands[1];
6409 rtx addr = XEXP (op1, 0);
6410 enum rtx_code code = GET_CODE (addr);
6412 if ((code == PLUS && !CONST_INT_P (XEXP (addr, 1)))
6414 op1 = replace_equiv_address (op1, force_reg (SImode, addr));
6416 operands[4] = adjust_address (op1, QImode, 1);
6417 operands[1] = adjust_address (operands[1], QImode, 0);
6418 operands[3] = gen_lowpart (QImode, operands[0]);
6419 operands[0] = gen_lowpart (SImode, operands[0]);
6420 operands[2] = gen_reg_rtx (SImode);
6421 operands[5] = gen_lowpart (QImode, operands[2]);
6425 ;; Subroutine to store a half word integer constant into memory.
6426 (define_expand "storeinthi"
6427 [(set (match_operand 0 "" "")
6428 (match_operand 1 "" ""))
6429 (set (match_dup 3) (match_dup 2))]
6433 HOST_WIDE_INT value = INTVAL (operands[1]);
6434 rtx addr = XEXP (operands[0], 0);
6435 rtx op0 = operands[0];
6436 enum rtx_code code = GET_CODE (addr);
6438 if ((code == PLUS && !CONST_INT_P (XEXP (addr, 1)))
6440 op0 = replace_equiv_address (op0, force_reg (SImode, addr));
6442 operands[1] = gen_reg_rtx (SImode);
6443 if (BYTES_BIG_ENDIAN)
6445 emit_insn (gen_movsi (operands[1], GEN_INT ((value >> 8) & 255)));
6446 if ((value & 255) == ((value >> 8) & 255))
6447 operands[2] = operands[1];
6450 operands[2] = gen_reg_rtx (SImode);
6451 emit_insn (gen_movsi (operands[2], GEN_INT (value & 255)));
6456 emit_insn (gen_movsi (operands[1], GEN_INT (value & 255)));
6457 if ((value & 255) == ((value >> 8) & 255))
6458 operands[2] = operands[1];
6461 operands[2] = gen_reg_rtx (SImode);
6462 emit_insn (gen_movsi (operands[2], GEN_INT ((value >> 8) & 255)));
6466 operands[3] = adjust_address (op0, QImode, 1);
6467 operands[0] = adjust_address (operands[0], QImode, 0);
6468 operands[2] = gen_lowpart (QImode, operands[2]);
6469 operands[1] = gen_lowpart (QImode, operands[1]);
6473 (define_expand "storehi_single_op"
6474 [(set (match_operand:HI 0 "memory_operand" "")
6475 (match_operand:HI 1 "general_operand" ""))]
6476 "TARGET_32BIT && arm_arch4"
6478 if (!s_register_operand (operands[1], HImode))
6479 operands[1] = copy_to_mode_reg (HImode, operands[1]);
6483 (define_expand "movhi"
6484 [(set (match_operand:HI 0 "general_operand" "")
6485 (match_operand:HI 1 "general_operand" ""))]
6490 if (can_create_pseudo_p ())
6492 if (MEM_P (operands[0]))
6496 emit_insn (gen_storehi_single_op (operands[0], operands[1]));
6499 if (CONST_INT_P (operands[1]))
6500 emit_insn (gen_storeinthi (operands[0], operands[1]));
6503 if (MEM_P (operands[1]))
6504 operands[1] = force_reg (HImode, operands[1]);
6505 if (BYTES_BIG_ENDIAN)
6506 emit_insn (gen_storehi_bigend (operands[1], operands[0]));
6508 emit_insn (gen_storehi (operands[1], operands[0]));
6512 /* Sign extend a constant, and keep it in an SImode reg. */
6513 else if (CONST_INT_P (operands[1]))
6515 rtx reg = gen_reg_rtx (SImode);
6516 HOST_WIDE_INT val = INTVAL (operands[1]) & 0xffff;
6518 /* If the constant is already valid, leave it alone. */
6519 if (!const_ok_for_arm (val))
6521 /* If setting all the top bits will make the constant
6522 loadable in a single instruction, then set them.
6523 Otherwise, sign extend the number. */
6525 if (const_ok_for_arm (~(val | ~0xffff)))
6527 else if (val & 0x8000)
6531 emit_insn (gen_movsi (reg, GEN_INT (val)));
6532 operands[1] = gen_lowpart (HImode, reg);
6534 else if (arm_arch4 && optimize && can_create_pseudo_p ()
6535 && MEM_P (operands[1]))
6537 rtx reg = gen_reg_rtx (SImode);
6539 emit_insn (gen_zero_extendhisi2 (reg, operands[1]));
6540 operands[1] = gen_lowpart (HImode, reg);
6542 else if (!arm_arch4)
6544 if (MEM_P (operands[1]))
6547 rtx offset = const0_rtx;
6548 rtx reg = gen_reg_rtx (SImode);
6550 if ((REG_P (base = XEXP (operands[1], 0))
6551 || (GET_CODE (base) == PLUS
6552 && (CONST_INT_P (offset = XEXP (base, 1)))
6553 && ((INTVAL(offset) & 1) != 1)
6554 && REG_P (base = XEXP (base, 0))))
6555 && REGNO_POINTER_ALIGN (REGNO (base)) >= 32)
6559 new_rtx = widen_memory_access (operands[1], SImode,
6560 ((INTVAL (offset) & ~3)
6561 - INTVAL (offset)));
6562 emit_insn (gen_movsi (reg, new_rtx));
6563 if (((INTVAL (offset) & 2) != 0)
6564 ^ (BYTES_BIG_ENDIAN ? 1 : 0))
6566 rtx reg2 = gen_reg_rtx (SImode);
6568 emit_insn (gen_lshrsi3 (reg2, reg, GEN_INT (16)));
6573 emit_insn (gen_movhi_bytes (reg, operands[1]));
6575 operands[1] = gen_lowpart (HImode, reg);
6579 /* Handle loading a large integer during reload. */
6580 else if (CONST_INT_P (operands[1])
6581 && !const_ok_for_arm (INTVAL (operands[1]))
6582 && !const_ok_for_arm (~INTVAL (operands[1])))
6584 /* Writing a constant to memory needs a scratch, which should
6585 be handled with SECONDARY_RELOADs. */
6586 gcc_assert (REG_P (operands[0]));
6588 operands[0] = gen_rtx_SUBREG (SImode, operands[0], 0);
6589 emit_insn (gen_movsi (operands[0], operands[1]));
6593 else if (TARGET_THUMB2)
6595 /* Thumb-2 can do everything except mem=mem and mem=const easily. */
6596 if (can_create_pseudo_p ())
6598 if (!REG_P (operands[0]))
6599 operands[1] = force_reg (HImode, operands[1]);
6600 /* Zero extend a constant, and keep it in an SImode reg. */
6601 else if (CONST_INT_P (operands[1]))
6603 rtx reg = gen_reg_rtx (SImode);
6604 HOST_WIDE_INT val = INTVAL (operands[1]) & 0xffff;
6606 emit_insn (gen_movsi (reg, GEN_INT (val)));
6607 operands[1] = gen_lowpart (HImode, reg);
6611 else /* TARGET_THUMB1 */
6613 if (can_create_pseudo_p ())
6615 if (CONST_INT_P (operands[1]))
6617 rtx reg = gen_reg_rtx (SImode);
6619 emit_insn (gen_movsi (reg, operands[1]));
6620 operands[1] = gen_lowpart (HImode, reg);
6623 /* ??? We shouldn't really get invalid addresses here, but this can
6624 happen if we are passed a SP (never OK for HImode/QImode) or
6625 virtual register (also rejected as illegitimate for HImode/QImode)
6626 relative address. */
6627 /* ??? This should perhaps be fixed elsewhere, for instance, in
6628 fixup_stack_1, by checking for other kinds of invalid addresses,
6629 e.g. a bare reference to a virtual register. This may confuse the
6630 alpha though, which must handle this case differently. */
6631 if (MEM_P (operands[0])
6632 && !memory_address_p (GET_MODE (operands[0]),
6633 XEXP (operands[0], 0)))
6635 = replace_equiv_address (operands[0],
6636 copy_to_reg (XEXP (operands[0], 0)));
6638 if (MEM_P (operands[1])
6639 && !memory_address_p (GET_MODE (operands[1]),
6640 XEXP (operands[1], 0)))
6642 = replace_equiv_address (operands[1],
6643 copy_to_reg (XEXP (operands[1], 0)));
6645 if (MEM_P (operands[1]) && optimize > 0)
6647 rtx reg = gen_reg_rtx (SImode);
6649 emit_insn (gen_zero_extendhisi2 (reg, operands[1]));
6650 operands[1] = gen_lowpart (HImode, reg);
6653 if (MEM_P (operands[0]))
6654 operands[1] = force_reg (HImode, operands[1]);
6656 else if (CONST_INT_P (operands[1])
6657 && !satisfies_constraint_I (operands[1]))
6659 /* Handle loading a large integer during reload. */
6661 /* Writing a constant to memory needs a scratch, which should
6662 be handled with SECONDARY_RELOADs. */
6663 gcc_assert (REG_P (operands[0]));
6665 operands[0] = gen_rtx_SUBREG (SImode, operands[0], 0);
6666 emit_insn (gen_movsi (operands[0], operands[1]));
6673 (define_expand "movhi_bytes"
6674 [(set (match_dup 2) (zero_extend:SI (match_operand:HI 1 "" "")))
6676 (zero_extend:SI (match_dup 6)))
6677 (set (match_operand:SI 0 "" "")
6678 (ior:SI (ashift:SI (match_dup 4) (const_int 8)) (match_dup 5)))]
6683 rtx addr = copy_to_mode_reg (SImode, XEXP (operands[1], 0));
6685 mem1 = change_address (operands[1], QImode, addr);
6686 mem2 = change_address (operands[1], QImode,
6687 plus_constant (Pmode, addr, 1));
6688 operands[0] = gen_lowpart (SImode, operands[0]);
6690 operands[2] = gen_reg_rtx (SImode);
6691 operands[3] = gen_reg_rtx (SImode);
6694 if (BYTES_BIG_ENDIAN)
6696 operands[4] = operands[2];
6697 operands[5] = operands[3];
6701 operands[4] = operands[3];
6702 operands[5] = operands[2];
6707 (define_expand "movhi_bigend"
6709 (rotate:SI (subreg:SI (match_operand:HI 1 "memory_operand" "") 0)
6712 (ashiftrt:SI (match_dup 2) (const_int 16)))
6713 (set (match_operand:HI 0 "s_register_operand" "")
6717 operands[2] = gen_reg_rtx (SImode);
6718 operands[3] = gen_reg_rtx (SImode);
6719 operands[4] = gen_lowpart (HImode, operands[3]);
6723 ;; Pattern to recognize insn generated default case above
6724 (define_insn "*movhi_insn_arch4"
6725 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m,r")
6726 (match_operand:HI 1 "general_operand" "rIk,K,n,r,mi"))]
6728 && arm_arch4 && !TARGET_HARD_FLOAT
6729 && (register_operand (operands[0], HImode)
6730 || register_operand (operands[1], HImode))"
6732 mov%?\\t%0, %1\\t%@ movhi
6733 mvn%?\\t%0, #%B1\\t%@ movhi
6734 movw%?\\t%0, %L1\\t%@ movhi
6735 strh%?\\t%1, %0\\t%@ movhi
6736 ldrh%?\\t%0, %1\\t%@ movhi"
6737 [(set_attr "predicable" "yes")
6738 (set_attr "pool_range" "*,*,*,*,256")
6739 (set_attr "neg_pool_range" "*,*,*,*,244")
6740 (set_attr "arch" "*,*,v6t2,*,*")
6741 (set_attr_alternative "type"
6742 [(if_then_else (match_operand 1 "const_int_operand" "")
6743 (const_string "mov_imm" )
6744 (const_string "mov_reg"))
6745 (const_string "mvn_imm")
6746 (const_string "mov_imm")
6747 (const_string "store_4")
6748 (const_string "load_4")])]
6751 (define_insn "*movhi_bytes"
6752 [(set (match_operand:HI 0 "s_register_operand" "=r,r,r")
6753 (match_operand:HI 1 "arm_rhs_operand" "I,rk,K"))]
6754 "TARGET_ARM && !TARGET_HARD_FLOAT"
6756 mov%?\\t%0, %1\\t%@ movhi
6757 mov%?\\t%0, %1\\t%@ movhi
6758 mvn%?\\t%0, #%B1\\t%@ movhi"
6759 [(set_attr "predicable" "yes")
6760 (set_attr "type" "mov_imm,mov_reg,mvn_imm")]
6763 ;; We use a DImode scratch because we may occasionally need an additional
6764 ;; temporary if the address isn't offsettable -- push_reload doesn't seem
6765 ;; to take any notice of the "o" constraints on reload_memory_operand operand.
6766 (define_expand "reload_outhi"
6767 [(parallel [(match_operand:HI 0 "arm_reload_memory_operand" "=o")
6768 (match_operand:HI 1 "s_register_operand" "r")
6769 (match_operand:DI 2 "s_register_operand" "=&l")])]
6772 arm_reload_out_hi (operands);
6774 thumb_reload_out_hi (operands);
6779 (define_expand "reload_inhi"
6780 [(parallel [(match_operand:HI 0 "s_register_operand" "=r")
6781 (match_operand:HI 1 "arm_reload_memory_operand" "o")
6782 (match_operand:DI 2 "s_register_operand" "=&r")])]
6786 arm_reload_in_hi (operands);
6788 thumb_reload_out_hi (operands);
6792 (define_expand "movqi"
6793 [(set (match_operand:QI 0 "general_operand" "")
6794 (match_operand:QI 1 "general_operand" ""))]
6797 /* Everything except mem = const or mem = mem can be done easily */
6799 if (can_create_pseudo_p ())
6801 if (CONST_INT_P (operands[1]))
6803 rtx reg = gen_reg_rtx (SImode);
6805 /* For thumb we want an unsigned immediate, then we are more likely
6806 to be able to use a movs insn. */
6808 operands[1] = GEN_INT (INTVAL (operands[1]) & 255);
6810 emit_insn (gen_movsi (reg, operands[1]));
6811 operands[1] = gen_lowpart (QImode, reg);
6816 /* ??? We shouldn't really get invalid addresses here, but this can
6817 happen if we are passed a SP (never OK for HImode/QImode) or
6818 virtual register (also rejected as illegitimate for HImode/QImode)
6819 relative address. */
6820 /* ??? This should perhaps be fixed elsewhere, for instance, in
6821 fixup_stack_1, by checking for other kinds of invalid addresses,
6822 e.g. a bare reference to a virtual register. This may confuse the
6823 alpha though, which must handle this case differently. */
6824 if (MEM_P (operands[0])
6825 && !memory_address_p (GET_MODE (operands[0]),
6826 XEXP (operands[0], 0)))
6828 = replace_equiv_address (operands[0],
6829 copy_to_reg (XEXP (operands[0], 0)));
6830 if (MEM_P (operands[1])
6831 && !memory_address_p (GET_MODE (operands[1]),
6832 XEXP (operands[1], 0)))
6834 = replace_equiv_address (operands[1],
6835 copy_to_reg (XEXP (operands[1], 0)));
6838 if (MEM_P (operands[1]) && optimize > 0)
6840 rtx reg = gen_reg_rtx (SImode);
6842 emit_insn (gen_zero_extendqisi2 (reg, operands[1]));
6843 operands[1] = gen_lowpart (QImode, reg);
6846 if (MEM_P (operands[0]))
6847 operands[1] = force_reg (QImode, operands[1]);
6849 else if (TARGET_THUMB
6850 && CONST_INT_P (operands[1])
6851 && !satisfies_constraint_I (operands[1]))
6853 /* Handle loading a large integer during reload. */
6855 /* Writing a constant to memory needs a scratch, which should
6856 be handled with SECONDARY_RELOADs. */
6857 gcc_assert (REG_P (operands[0]));
6859 operands[0] = gen_rtx_SUBREG (SImode, operands[0], 0);
6860 emit_insn (gen_movsi (operands[0], operands[1]));
6866 (define_insn "*arm_movqi_insn"
6867 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,r,l,r,l,Uu,r,m")
6868 (match_operand:QI 1 "general_operand" "rk,rk,I,Py,K,Uu,l,Uh,r"))]
6870 && ( register_operand (operands[0], QImode)
6871 || register_operand (operands[1], QImode))"
6882 [(set_attr "type" "mov_reg,mov_reg,mov_imm,mov_imm,mvn_imm,load_4,store_4,load_4,store_4")
6883 (set_attr "predicable" "yes")
6884 (set_attr "predicable_short_it" "yes,yes,no,yes,no,no,no,no,no")
6885 (set_attr "arch" "t2,any,any,t2,any,t2,t2,any,any")
6886 (set_attr "length" "2,4,4,2,4,2,2,4,4")]
6890 (define_expand "movhf"
6891 [(set (match_operand:HF 0 "general_operand" "")
6892 (match_operand:HF 1 "general_operand" ""))]
6897 if (MEM_P (operands[0]))
6898 operands[1] = force_reg (HFmode, operands[1]);
6900 else /* TARGET_THUMB1 */
6902 if (can_create_pseudo_p ())
6904 if (!REG_P (operands[0]))
6905 operands[1] = force_reg (HFmode, operands[1]);
6911 (define_insn "*arm32_movhf"
6912 [(set (match_operand:HF 0 "nonimmediate_operand" "=r,m,r,r")
6913 (match_operand:HF 1 "general_operand" " m,r,r,F"))]
6914 "TARGET_32BIT && !TARGET_HARD_FLOAT
6915 && ( s_register_operand (operands[0], HFmode)
6916 || s_register_operand (operands[1], HFmode))"
6918 switch (which_alternative)
6920 case 0: /* ARM register from memory */
6921 return \"ldrh%?\\t%0, %1\\t%@ __fp16\";
6922 case 1: /* memory from ARM register */
6923 return \"strh%?\\t%1, %0\\t%@ __fp16\";
6924 case 2: /* ARM register from ARM register */
6925 return \"mov%?\\t%0, %1\\t%@ __fp16\";
6926 case 3: /* ARM register from constant */
6931 bits = real_to_target (NULL, CONST_DOUBLE_REAL_VALUE (operands[1]),
6933 ops[0] = operands[0];
6934 ops[1] = GEN_INT (bits);
6935 ops[2] = GEN_INT (bits & 0xff00);
6936 ops[3] = GEN_INT (bits & 0x00ff);
6938 if (arm_arch_thumb2)
6939 output_asm_insn (\"movw%?\\t%0, %1\", ops);
6941 output_asm_insn (\"mov%?\\t%0, %2\;orr%?\\t%0, %0, %3\", ops);
6948 [(set_attr "conds" "unconditional")
6949 (set_attr "type" "load_4,store_4,mov_reg,multiple")
6950 (set_attr "length" "4,4,4,8")
6951 (set_attr "predicable" "yes")]
6954 (define_expand "movsf"
6955 [(set (match_operand:SF 0 "general_operand" "")
6956 (match_operand:SF 1 "general_operand" ""))]
6961 if (MEM_P (operands[0]))
6962 operands[1] = force_reg (SFmode, operands[1]);
6964 else /* TARGET_THUMB1 */
6966 if (can_create_pseudo_p ())
6968 if (!REG_P (operands[0]))
6969 operands[1] = force_reg (SFmode, operands[1]);
6973 /* Cannot load it directly, generate a load with clobber so that it can be
6974 loaded via GPR with MOV / MOVT. */
6975 if (arm_disable_literal_pool
6976 && (REG_P (operands[0]) || SUBREG_P (operands[0]))
6977 && CONST_DOUBLE_P (operands[1])
6978 && TARGET_HARD_FLOAT
6979 && !vfp3_const_double_rtx (operands[1]))
6981 rtx clobreg = gen_reg_rtx (SFmode);
6982 emit_insn (gen_no_literal_pool_sf_immediate (operands[0], operands[1],
6989 ;; Transform a floating-point move of a constant into a core register into
6990 ;; an SImode operation.
6992 [(set (match_operand:SF 0 "arm_general_register_operand" "")
6993 (match_operand:SF 1 "immediate_operand" ""))]
6996 && CONST_DOUBLE_P (operands[1])"
6997 [(set (match_dup 2) (match_dup 3))]
6999 operands[2] = gen_lowpart (SImode, operands[0]);
7000 operands[3] = gen_lowpart (SImode, operands[1]);
7001 if (operands[2] == 0 || operands[3] == 0)
7006 (define_insn "*arm_movsf_soft_insn"
7007 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m")
7008 (match_operand:SF 1 "general_operand" "r,mE,r"))]
7010 && TARGET_SOFT_FLOAT
7011 && (!MEM_P (operands[0])
7012 || register_operand (operands[1], SFmode))"
7014 switch (which_alternative)
7016 case 0: return \"mov%?\\t%0, %1\";
7018 /* Cannot load it directly, split to load it via MOV / MOVT. */
7019 if (!MEM_P (operands[1]) && arm_disable_literal_pool)
7021 return \"ldr%?\\t%0, %1\\t%@ float\";
7022 case 2: return \"str%?\\t%1, %0\\t%@ float\";
7023 default: gcc_unreachable ();
7026 [(set_attr "predicable" "yes")
7027 (set_attr "type" "mov_reg,load_4,store_4")
7028 (set_attr "arm_pool_range" "*,4096,*")
7029 (set_attr "thumb2_pool_range" "*,4094,*")
7030 (set_attr "arm_neg_pool_range" "*,4084,*")
7031 (set_attr "thumb2_neg_pool_range" "*,0,*")]
7034 ;; Splitter for the above.
7036 [(set (match_operand:SF 0 "s_register_operand")
7037 (match_operand:SF 1 "const_double_operand"))]
7038 "arm_disable_literal_pool && TARGET_SOFT_FLOAT"
7042 real_to_target (&buf, CONST_DOUBLE_REAL_VALUE (operands[1]), SFmode);
7043 rtx cst = gen_int_mode (buf, SImode);
7044 emit_move_insn (simplify_gen_subreg (SImode, operands[0], SFmode, 0), cst);
7049 (define_expand "movdf"
7050 [(set (match_operand:DF 0 "general_operand" "")
7051 (match_operand:DF 1 "general_operand" ""))]
7056 if (MEM_P (operands[0]))
7057 operands[1] = force_reg (DFmode, operands[1]);
7059 else /* TARGET_THUMB */
7061 if (can_create_pseudo_p ())
7063 if (!REG_P (operands[0]))
7064 operands[1] = force_reg (DFmode, operands[1]);
7068 /* Cannot load it directly, generate a load with clobber so that it can be
7069 loaded via GPR with MOV / MOVT. */
7070 if (arm_disable_literal_pool
7071 && (REG_P (operands[0]) || SUBREG_P (operands[0]))
7072 && CONSTANT_P (operands[1])
7073 && TARGET_HARD_FLOAT
7074 && !arm_const_double_rtx (operands[1])
7075 && !(TARGET_VFP_DOUBLE && vfp3_const_double_rtx (operands[1])))
7077 rtx clobreg = gen_reg_rtx (DFmode);
7078 emit_insn (gen_no_literal_pool_df_immediate (operands[0], operands[1],
7085 ;; Reloading a df mode value stored in integer regs to memory can require a
7087 (define_expand "reload_outdf"
7088 [(match_operand:DF 0 "arm_reload_memory_operand" "=o")
7089 (match_operand:DF 1 "s_register_operand" "r")
7090 (match_operand:SI 2 "s_register_operand" "=&r")]
7094 enum rtx_code code = GET_CODE (XEXP (operands[0], 0));
7097 operands[2] = XEXP (operands[0], 0);
7098 else if (code == POST_INC || code == PRE_DEC)
7100 operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
7101 operands[1] = gen_rtx_SUBREG (DImode, operands[1], 0);
7102 emit_insn (gen_movdi (operands[0], operands[1]));
7105 else if (code == PRE_INC)
7107 rtx reg = XEXP (XEXP (operands[0], 0), 0);
7109 emit_insn (gen_addsi3 (reg, reg, GEN_INT (8)));
7112 else if (code == POST_DEC)
7113 operands[2] = XEXP (XEXP (operands[0], 0), 0);
7115 emit_insn (gen_addsi3 (operands[2], XEXP (XEXP (operands[0], 0), 0),
7116 XEXP (XEXP (operands[0], 0), 1)));
7118 emit_insn (gen_rtx_SET (replace_equiv_address (operands[0], operands[2]),
7121 if (code == POST_DEC)
7122 emit_insn (gen_addsi3 (operands[2], operands[2], GEN_INT (-8)));
7128 (define_insn "*movdf_soft_insn"
7129 [(set (match_operand:DF 0 "nonimmediate_soft_df_operand" "=r,r,r,r,m")
7130 (match_operand:DF 1 "soft_df_operand" "rDa,Db,Dc,mF,r"))]
7131 "TARGET_32BIT && TARGET_SOFT_FLOAT
7132 && ( register_operand (operands[0], DFmode)
7133 || register_operand (operands[1], DFmode))"
7135 switch (which_alternative)
7142 /* Cannot load it directly, split to load it via MOV / MOVT. */
7143 if (!MEM_P (operands[1]) && arm_disable_literal_pool)
7147 return output_move_double (operands, true, NULL);
7150 [(set_attr "length" "8,12,16,8,8")
7151 (set_attr "type" "multiple,multiple,multiple,load_8,store_8")
7152 (set_attr "arm_pool_range" "*,*,*,1020,*")
7153 (set_attr "thumb2_pool_range" "*,*,*,1018,*")
7154 (set_attr "arm_neg_pool_range" "*,*,*,1004,*")
7155 (set_attr "thumb2_neg_pool_range" "*,*,*,0,*")]
7158 ;; Splitter for the above.
7160 [(set (match_operand:DF 0 "s_register_operand")
7161 (match_operand:DF 1 "const_double_operand"))]
7162 "arm_disable_literal_pool && TARGET_SOFT_FLOAT"
7166 int order = BYTES_BIG_ENDIAN ? 1 : 0;
7167 real_to_target (buf, CONST_DOUBLE_REAL_VALUE (operands[1]), DFmode);
7168 unsigned HOST_WIDE_INT ival = zext_hwi (buf[order], 32);
7169 ival |= (zext_hwi (buf[1 - order], 32) << 32);
7170 rtx cst = gen_int_mode (ival, DImode);
7171 emit_move_insn (simplify_gen_subreg (DImode, operands[0], DFmode, 0), cst);
7177 ;; load- and store-multiple insns
7178 ;; The arm can load/store any set of registers, provided that they are in
7179 ;; ascending order, but these expanders assume a contiguous set.
7181 (define_expand "load_multiple"
7182 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
7183 (match_operand:SI 1 "" ""))
7184 (use (match_operand:SI 2 "" ""))])]
7187 HOST_WIDE_INT offset = 0;
7189 /* Support only fixed point registers. */
7190 if (!CONST_INT_P (operands[2])
7191 || INTVAL (operands[2]) > MAX_LDM_STM_OPS
7192 || INTVAL (operands[2]) < 2
7193 || !MEM_P (operands[1])
7194 || !REG_P (operands[0])
7195 || REGNO (operands[0]) > (LAST_ARM_REGNUM - 1)
7196 || REGNO (operands[0]) + INTVAL (operands[2]) > LAST_ARM_REGNUM)
7200 = arm_gen_load_multiple (arm_regs_in_sequence + REGNO (operands[0]),
7201 INTVAL (operands[2]),
7202 force_reg (SImode, XEXP (operands[1], 0)),
7203 FALSE, operands[1], &offset);
7206 (define_expand "store_multiple"
7207 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
7208 (match_operand:SI 1 "" ""))
7209 (use (match_operand:SI 2 "" ""))])]
7212 HOST_WIDE_INT offset = 0;
7214 /* Support only fixed point registers. */
7215 if (!CONST_INT_P (operands[2])
7216 || INTVAL (operands[2]) > MAX_LDM_STM_OPS
7217 || INTVAL (operands[2]) < 2
7218 || !REG_P (operands[1])
7219 || !MEM_P (operands[0])
7220 || REGNO (operands[1]) > (LAST_ARM_REGNUM - 1)
7221 || REGNO (operands[1]) + INTVAL (operands[2]) > LAST_ARM_REGNUM)
7225 = arm_gen_store_multiple (arm_regs_in_sequence + REGNO (operands[1]),
7226 INTVAL (operands[2]),
7227 force_reg (SImode, XEXP (operands[0], 0)),
7228 FALSE, operands[0], &offset);
7232 (define_expand "setmemsi"
7233 [(match_operand:BLK 0 "general_operand" "")
7234 (match_operand:SI 1 "const_int_operand" "")
7235 (match_operand:SI 2 "const_int_operand" "")
7236 (match_operand:SI 3 "const_int_operand" "")]
7239 if (arm_gen_setmem (operands))
7246 ;; Move a block of memory if it is word aligned and MORE than 2 words long.
7247 ;; We could let this apply for blocks of less than this, but it clobbers so
7248 ;; many registers that there is then probably a better way.
7250 (define_expand "movmemqi"
7251 [(match_operand:BLK 0 "general_operand" "")
7252 (match_operand:BLK 1 "general_operand" "")
7253 (match_operand:SI 2 "const_int_operand" "")
7254 (match_operand:SI 3 "const_int_operand" "")]
7259 if (TARGET_LDRD && current_tune->prefer_ldrd_strd
7260 && !optimize_function_for_size_p (cfun))
7262 if (gen_movmem_ldrd_strd (operands))
7267 if (arm_gen_movmemqi (operands))
7271 else /* TARGET_THUMB1 */
7273 if ( INTVAL (operands[3]) != 4
7274 || INTVAL (operands[2]) > 48)
7277 thumb_expand_movmemqi (operands);
7284 ;; Compare & branch insns
7285 ;; The range calculations are based as follows:
7286 ;; For forward branches, the address calculation returns the address of
7287 ;; the next instruction. This is 2 beyond the branch instruction.
7288 ;; For backward branches, the address calculation returns the address of
7289 ;; the first instruction in this pattern (cmp). This is 2 before the branch
7290 ;; instruction for the shortest sequence, and 4 before the branch instruction
7291 ;; if we have to jump around an unconditional branch.
7292 ;; To the basic branch range the PC offset must be added (this is +4).
7293 ;; So for forward branches we have
7294 ;; (pos_range - pos_base_offs + pc_offs) = (pos_range - 2 + 4).
7295 ;; And for backward branches we have
7296 ;; (neg_range - neg_base_offs + pc_offs) = (neg_range - (-2 or -4) + 4).
7298 ;; For a 'b' pos_range = 2046, neg_range = -2048 giving (-2040->2048).
7299 ;; For a 'b<cond>' pos_range = 254, neg_range = -256 giving (-250 ->256).
7301 (define_expand "cbranchsi4"
7302 [(set (pc) (if_then_else
7303 (match_operator 0 "expandable_comparison_operator"
7304 [(match_operand:SI 1 "s_register_operand" "")
7305 (match_operand:SI 2 "nonmemory_operand" "")])
7306 (label_ref (match_operand 3 "" ""))
7312 if (!arm_validize_comparison (&operands[0], &operands[1], &operands[2]))
7314 emit_jump_insn (gen_cbranch_cc (operands[0], operands[1], operands[2],
7318 if (thumb1_cmpneg_operand (operands[2], SImode))
7320 emit_jump_insn (gen_cbranchsi4_scratch (NULL, operands[1], operands[2],
7321 operands[3], operands[0]));
7324 if (!thumb1_cmp_operand (operands[2], SImode))
7325 operands[2] = force_reg (SImode, operands[2]);
7328 (define_expand "cbranchsf4"
7329 [(set (pc) (if_then_else
7330 (match_operator 0 "expandable_comparison_operator"
7331 [(match_operand:SF 1 "s_register_operand" "")
7332 (match_operand:SF 2 "vfp_compare_operand" "")])
7333 (label_ref (match_operand 3 "" ""))
7335 "TARGET_32BIT && TARGET_HARD_FLOAT"
7336 "emit_jump_insn (gen_cbranch_cc (operands[0], operands[1], operands[2],
7337 operands[3])); DONE;"
7340 (define_expand "cbranchdf4"
7341 [(set (pc) (if_then_else
7342 (match_operator 0 "expandable_comparison_operator"
7343 [(match_operand:DF 1 "s_register_operand" "")
7344 (match_operand:DF 2 "vfp_compare_operand" "")])
7345 (label_ref (match_operand 3 "" ""))
7347 "TARGET_32BIT && TARGET_HARD_FLOAT && !TARGET_VFP_SINGLE"
7348 "emit_jump_insn (gen_cbranch_cc (operands[0], operands[1], operands[2],
7349 operands[3])); DONE;"
7352 (define_expand "cbranchdi4"
7353 [(set (pc) (if_then_else
7354 (match_operator 0 "expandable_comparison_operator"
7355 [(match_operand:DI 1 "s_register_operand" "")
7356 (match_operand:DI 2 "cmpdi_operand" "")])
7357 (label_ref (match_operand 3 "" ""))
7361 if (!arm_validize_comparison (&operands[0], &operands[1], &operands[2]))
7363 emit_jump_insn (gen_cbranch_cc (operands[0], operands[1], operands[2],
7369 ;; Comparison and test insns
7371 (define_insn "*arm_cmpsi_insn"
7372 [(set (reg:CC CC_REGNUM)
7373 (compare:CC (match_operand:SI 0 "s_register_operand" "l,r,r,r,r")
7374 (match_operand:SI 1 "arm_add_operand" "Py,r,r,I,L")))]
7382 [(set_attr "conds" "set")
7383 (set_attr "arch" "t2,t2,any,any,any")
7384 (set_attr "length" "2,2,4,4,4")
7385 (set_attr "predicable" "yes")
7386 (set_attr "predicable_short_it" "yes,yes,yes,no,no")
7387 (set_attr "type" "alus_imm,alus_sreg,alus_sreg,alus_imm,alus_imm")]
7390 (define_insn "*cmpsi_shiftsi"
7391 [(set (reg:CC CC_REGNUM)
7392 (compare:CC (match_operand:SI 0 "s_register_operand" "r,r,r")
7393 (match_operator:SI 3 "shift_operator"
7394 [(match_operand:SI 1 "s_register_operand" "r,r,r")
7395 (match_operand:SI 2 "shift_amount_operand" "M,r,M")])))]
7398 [(set_attr "conds" "set")
7399 (set_attr "shift" "1")
7400 (set_attr "arch" "32,a,a")
7401 (set_attr "type" "alus_shift_imm,alus_shift_reg,alus_shift_imm")])
7403 (define_insn "*cmpsi_shiftsi_swp"
7404 [(set (reg:CC_SWP CC_REGNUM)
7405 (compare:CC_SWP (match_operator:SI 3 "shift_operator"
7406 [(match_operand:SI 1 "s_register_operand" "r,r,r")
7407 (match_operand:SI 2 "shift_amount_operand" "M,r,M")])
7408 (match_operand:SI 0 "s_register_operand" "r,r,r")))]
7411 [(set_attr "conds" "set")
7412 (set_attr "shift" "1")
7413 (set_attr "arch" "32,a,a")
7414 (set_attr "type" "alus_shift_imm,alus_shift_reg,alus_shift_imm")])
7416 (define_insn "*arm_cmpsi_negshiftsi_si"
7417 [(set (reg:CC_Z CC_REGNUM)
7419 (neg:SI (match_operator:SI 1 "shift_operator"
7420 [(match_operand:SI 2 "s_register_operand" "r")
7421 (match_operand:SI 3 "reg_or_int_operand" "rM")]))
7422 (match_operand:SI 0 "s_register_operand" "r")))]
7425 [(set_attr "conds" "set")
7426 (set (attr "type") (if_then_else (match_operand 3 "const_int_operand" "")
7427 (const_string "alus_shift_imm")
7428 (const_string "alus_shift_reg")))
7429 (set_attr "predicable" "yes")]
7432 ;; DImode comparisons. The generic code generates branches that
7433 ;; if-conversion cannot reduce to a conditional compare, so we do
7436 (define_insn_and_split "*arm_cmpdi_insn"
7437 [(set (reg:CC_NCV CC_REGNUM)
7438 (compare:CC_NCV (match_operand:DI 0 "s_register_operand" "r")
7439 (match_operand:DI 1 "arm_di_operand" "rDi")))
7440 (clobber (match_scratch:SI 2 "=r"))]
7442 "#" ; "cmp\\t%Q0, %Q1\;sbcs\\t%2, %R0, %R1"
7443 "&& reload_completed"
7444 [(set (reg:CC CC_REGNUM)
7445 (compare:CC (match_dup 0) (match_dup 1)))
7446 (parallel [(set (reg:CC CC_REGNUM)
7447 (compare:CC (match_dup 3) (match_dup 4)))
7449 (minus:SI (match_dup 5)
7450 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))])]
7452 operands[3] = gen_highpart (SImode, operands[0]);
7453 operands[0] = gen_lowpart (SImode, operands[0]);
7454 if (CONST_INT_P (operands[1]))
7456 operands[4] = gen_highpart_mode (SImode, DImode, operands[1]);
7457 if (operands[4] == const0_rtx)
7458 operands[5] = operands[3];
7460 operands[5] = gen_rtx_PLUS (SImode, operands[3],
7461 gen_int_mode (-UINTVAL (operands[4]),
7466 operands[4] = gen_highpart (SImode, operands[1]);
7467 operands[5] = gen_rtx_MINUS (SImode, operands[3], operands[4]);
7469 operands[1] = gen_lowpart (SImode, operands[1]);
7470 operands[2] = gen_lowpart (SImode, operands[2]);
7472 [(set_attr "conds" "set")
7473 (set_attr "length" "8")
7474 (set_attr "type" "multiple")]
7477 (define_insn_and_split "*arm_cmpdi_unsigned"
7478 [(set (reg:CC_CZ CC_REGNUM)
7479 (compare:CC_CZ (match_operand:DI 0 "s_register_operand" "l,r,r,r")
7480 (match_operand:DI 1 "arm_di_operand" "Py,r,Di,rDi")))]
7483 "#" ; "cmp\\t%R0, %R1\;it eq\;cmpeq\\t%Q0, %Q1"
7484 "&& reload_completed"
7485 [(set (reg:CC CC_REGNUM)
7486 (compare:CC (match_dup 2) (match_dup 3)))
7487 (cond_exec (eq:SI (reg:CC CC_REGNUM) (const_int 0))
7488 (set (reg:CC CC_REGNUM)
7489 (compare:CC (match_dup 0) (match_dup 1))))]
7491 operands[2] = gen_highpart (SImode, operands[0]);
7492 operands[0] = gen_lowpart (SImode, operands[0]);
7493 if (CONST_INT_P (operands[1]))
7494 operands[3] = gen_highpart_mode (SImode, DImode, operands[1]);
7496 operands[3] = gen_highpart (SImode, operands[1]);
7497 operands[1] = gen_lowpart (SImode, operands[1]);
7499 [(set_attr "conds" "set")
7500 (set_attr "enabled_for_short_it" "yes,yes,no,*")
7501 (set_attr "arch" "t2,t2,t2,a")
7502 (set_attr "length" "6,6,10,8")
7503 (set_attr "type" "multiple")]
7506 (define_insn "*arm_cmpdi_zero"
7507 [(set (reg:CC_Z CC_REGNUM)
7508 (compare:CC_Z (match_operand:DI 0 "s_register_operand" "r")
7510 (clobber (match_scratch:SI 1 "=r"))]
7512 "orrs%?\\t%1, %Q0, %R0"
7513 [(set_attr "conds" "set")
7514 (set_attr "type" "logics_reg")]
7517 ; This insn allows redundant compares to be removed by cse, nothing should
7518 ; ever appear in the output file since (set (reg x) (reg x)) is a no-op that
7519 ; is deleted later on. The match_dup will match the mode here, so that
7520 ; mode changes of the condition codes aren't lost by this even though we don't
7521 ; specify what they are.
7523 (define_insn "*deleted_compare"
7524 [(set (match_operand 0 "cc_register" "") (match_dup 0))]
7526 "\\t%@ deleted compare"
7527 [(set_attr "conds" "set")
7528 (set_attr "length" "0")
7529 (set_attr "type" "no_insn")]
7533 ;; Conditional branch insns
7535 (define_expand "cbranch_cc"
7537 (if_then_else (match_operator 0 "" [(match_operand 1 "" "")
7538 (match_operand 2 "" "")])
7539 (label_ref (match_operand 3 "" ""))
7542 "operands[1] = arm_gen_compare_reg (GET_CODE (operands[0]),
7543 operands[1], operands[2], NULL_RTX);
7544 operands[2] = const0_rtx;"
7548 ;; Patterns to match conditional branch insns.
7551 (define_insn "arm_cond_branch"
7553 (if_then_else (match_operator 1 "arm_comparison_operator"
7554 [(match_operand 2 "cc_register" "") (const_int 0)])
7555 (label_ref (match_operand 0 "" ""))
7559 if (arm_ccfsm_state == 1 || arm_ccfsm_state == 2)
7561 arm_ccfsm_state += 2;
7564 return \"b%d1\\t%l0\";
7566 [(set_attr "conds" "use")
7567 (set_attr "type" "branch")
7568 (set (attr "length")
7570 (and (match_test "TARGET_THUMB2")
7571 (and (ge (minus (match_dup 0) (pc)) (const_int -250))
7572 (le (minus (match_dup 0) (pc)) (const_int 256))))
7577 (define_insn "*arm_cond_branch_reversed"
7579 (if_then_else (match_operator 1 "arm_comparison_operator"
7580 [(match_operand 2 "cc_register" "") (const_int 0)])
7582 (label_ref (match_operand 0 "" ""))))]
7585 if (arm_ccfsm_state == 1 || arm_ccfsm_state == 2)
7587 arm_ccfsm_state += 2;
7590 return \"b%D1\\t%l0\";
7592 [(set_attr "conds" "use")
7593 (set_attr "type" "branch")
7594 (set (attr "length")
7596 (and (match_test "TARGET_THUMB2")
7597 (and (ge (minus (match_dup 0) (pc)) (const_int -250))
7598 (le (minus (match_dup 0) (pc)) (const_int 256))))
7607 (define_expand "cstore_cc"
7608 [(set (match_operand:SI 0 "s_register_operand" "")
7609 (match_operator:SI 1 "" [(match_operand 2 "" "")
7610 (match_operand 3 "" "")]))]
7612 "operands[2] = arm_gen_compare_reg (GET_CODE (operands[1]),
7613 operands[2], operands[3], NULL_RTX);
7614 operands[3] = const0_rtx;"
7617 (define_insn_and_split "*mov_scc"
7618 [(set (match_operand:SI 0 "s_register_operand" "=r")
7619 (match_operator:SI 1 "arm_comparison_operator_mode"
7620 [(match_operand 2 "cc_register" "") (const_int 0)]))]
7622 "#" ; "mov%D1\\t%0, #0\;mov%d1\\t%0, #1"
7625 (if_then_else:SI (match_dup 1)
7629 [(set_attr "conds" "use")
7630 (set_attr "length" "8")
7631 (set_attr "type" "multiple")]
7634 (define_insn_and_split "*mov_negscc"
7635 [(set (match_operand:SI 0 "s_register_operand" "=r")
7636 (neg:SI (match_operator:SI 1 "arm_comparison_operator_mode"
7637 [(match_operand 2 "cc_register" "") (const_int 0)])))]
7639 "#" ; "mov%D1\\t%0, #0\;mvn%d1\\t%0, #0"
7642 (if_then_else:SI (match_dup 1)
7646 operands[3] = GEN_INT (~0);
7648 [(set_attr "conds" "use")
7649 (set_attr "length" "8")
7650 (set_attr "type" "multiple")]
7653 (define_insn_and_split "*mov_notscc"
7654 [(set (match_operand:SI 0 "s_register_operand" "=r")
7655 (not:SI (match_operator:SI 1 "arm_comparison_operator"
7656 [(match_operand 2 "cc_register" "") (const_int 0)])))]
7658 "#" ; "mvn%D1\\t%0, #0\;mvn%d1\\t%0, #1"
7661 (if_then_else:SI (match_dup 1)
7665 operands[3] = GEN_INT (~1);
7666 operands[4] = GEN_INT (~0);
7668 [(set_attr "conds" "use")
7669 (set_attr "length" "8")
7670 (set_attr "type" "multiple")]
7673 (define_expand "cstoresi4"
7674 [(set (match_operand:SI 0 "s_register_operand" "")
7675 (match_operator:SI 1 "expandable_comparison_operator"
7676 [(match_operand:SI 2 "s_register_operand" "")
7677 (match_operand:SI 3 "reg_or_int_operand" "")]))]
7678 "TARGET_32BIT || TARGET_THUMB1"
7680 rtx op3, scratch, scratch2;
7684 if (!arm_add_operand (operands[3], SImode))
7685 operands[3] = force_reg (SImode, operands[3]);
7686 emit_insn (gen_cstore_cc (operands[0], operands[1],
7687 operands[2], operands[3]));
7691 if (operands[3] == const0_rtx)
7693 switch (GET_CODE (operands[1]))
7696 emit_insn (gen_cstoresi_eq0_thumb1 (operands[0], operands[2]));
7700 emit_insn (gen_cstoresi_ne0_thumb1 (operands[0], operands[2]));
7704 scratch = expand_binop (SImode, add_optab, operands[2], constm1_rtx,
7705 NULL_RTX, 0, OPTAB_WIDEN);
7706 scratch = expand_binop (SImode, ior_optab, operands[2], scratch,
7707 NULL_RTX, 0, OPTAB_WIDEN);
7708 expand_binop (SImode, lshr_optab, scratch, GEN_INT (31),
7709 operands[0], 1, OPTAB_WIDEN);
7713 scratch = expand_unop (SImode, one_cmpl_optab, operands[2],
7715 expand_binop (SImode, lshr_optab, scratch, GEN_INT (31),
7716 NULL_RTX, 1, OPTAB_WIDEN);
7720 scratch = expand_binop (SImode, ashr_optab, operands[2],
7721 GEN_INT (31), NULL_RTX, 0, OPTAB_WIDEN);
7722 scratch = expand_binop (SImode, sub_optab, scratch, operands[2],
7723 NULL_RTX, 0, OPTAB_WIDEN);
7724 expand_binop (SImode, lshr_optab, scratch, GEN_INT (31), operands[0],
7728 /* LT is handled by generic code. No need for unsigned with 0. */
7735 switch (GET_CODE (operands[1]))
7738 scratch = expand_binop (SImode, sub_optab, operands[2], operands[3],
7739 NULL_RTX, 0, OPTAB_WIDEN);
7740 emit_insn (gen_cstoresi_eq0_thumb1 (operands[0], scratch));
7744 scratch = expand_binop (SImode, sub_optab, operands[2], operands[3],
7745 NULL_RTX, 0, OPTAB_WIDEN);
7746 emit_insn (gen_cstoresi_ne0_thumb1 (operands[0], scratch));
7750 op3 = force_reg (SImode, operands[3]);
7752 scratch = expand_binop (SImode, lshr_optab, operands[2], GEN_INT (31),
7753 NULL_RTX, 1, OPTAB_WIDEN);
7754 scratch2 = expand_binop (SImode, ashr_optab, op3, GEN_INT (31),
7755 NULL_RTX, 0, OPTAB_WIDEN);
7756 emit_insn (gen_thumb1_addsi3_addgeu (operands[0], scratch, scratch2,
7762 if (!thumb1_cmp_operand (op3, SImode))
7763 op3 = force_reg (SImode, op3);
7764 scratch = expand_binop (SImode, ashr_optab, operands[2], GEN_INT (31),
7765 NULL_RTX, 0, OPTAB_WIDEN);
7766 scratch2 = expand_binop (SImode, lshr_optab, op3, GEN_INT (31),
7767 NULL_RTX, 1, OPTAB_WIDEN);
7768 emit_insn (gen_thumb1_addsi3_addgeu (operands[0], scratch, scratch2,
7773 op3 = force_reg (SImode, operands[3]);
7774 scratch = force_reg (SImode, const0_rtx);
7775 emit_insn (gen_thumb1_addsi3_addgeu (operands[0], scratch, scratch,
7781 if (!thumb1_cmp_operand (op3, SImode))
7782 op3 = force_reg (SImode, op3);
7783 scratch = force_reg (SImode, const0_rtx);
7784 emit_insn (gen_thumb1_addsi3_addgeu (operands[0], scratch, scratch,
7790 if (!thumb1_cmp_operand (op3, SImode))
7791 op3 = force_reg (SImode, op3);
7792 scratch = gen_reg_rtx (SImode);
7793 emit_insn (gen_cstoresi_ltu_thumb1 (operands[0], operands[2], op3));
7797 op3 = force_reg (SImode, operands[3]);
7798 scratch = gen_reg_rtx (SImode);
7799 emit_insn (gen_cstoresi_ltu_thumb1 (operands[0], op3, operands[2]));
7802 /* No good sequences for GT, LT. */
7809 (define_expand "cstorehf4"
7810 [(set (match_operand:SI 0 "s_register_operand")
7811 (match_operator:SI 1 "expandable_comparison_operator"
7812 [(match_operand:HF 2 "s_register_operand")
7813 (match_operand:HF 3 "vfp_compare_operand")]))]
7814 "TARGET_VFP_FP16INST"
7816 if (!arm_validize_comparison (&operands[1],
7821 emit_insn (gen_cstore_cc (operands[0], operands[1],
7822 operands[2], operands[3]));
7827 (define_expand "cstoresf4"
7828 [(set (match_operand:SI 0 "s_register_operand" "")
7829 (match_operator:SI 1 "expandable_comparison_operator"
7830 [(match_operand:SF 2 "s_register_operand" "")
7831 (match_operand:SF 3 "vfp_compare_operand" "")]))]
7832 "TARGET_32BIT && TARGET_HARD_FLOAT"
7833 "emit_insn (gen_cstore_cc (operands[0], operands[1],
7834 operands[2], operands[3])); DONE;"
7837 (define_expand "cstoredf4"
7838 [(set (match_operand:SI 0 "s_register_operand" "")
7839 (match_operator:SI 1 "expandable_comparison_operator"
7840 [(match_operand:DF 2 "s_register_operand" "")
7841 (match_operand:DF 3 "vfp_compare_operand" "")]))]
7842 "TARGET_32BIT && TARGET_HARD_FLOAT && !TARGET_VFP_SINGLE"
7843 "emit_insn (gen_cstore_cc (operands[0], operands[1],
7844 operands[2], operands[3])); DONE;"
7847 (define_expand "cstoredi4"
7848 [(set (match_operand:SI 0 "s_register_operand" "")
7849 (match_operator:SI 1 "expandable_comparison_operator"
7850 [(match_operand:DI 2 "s_register_operand" "")
7851 (match_operand:DI 3 "cmpdi_operand" "")]))]
7854 if (!arm_validize_comparison (&operands[1],
7858 emit_insn (gen_cstore_cc (operands[0], operands[1], operands[2],
7865 ;; Conditional move insns
7867 (define_expand "movsicc"
7868 [(set (match_operand:SI 0 "s_register_operand" "")
7869 (if_then_else:SI (match_operand 1 "expandable_comparison_operator" "")
7870 (match_operand:SI 2 "arm_not_operand" "")
7871 (match_operand:SI 3 "arm_not_operand" "")))]
7878 if (!arm_validize_comparison (&operands[1], &XEXP (operands[1], 0),
7879 &XEXP (operands[1], 1)))
7882 code = GET_CODE (operands[1]);
7883 ccreg = arm_gen_compare_reg (code, XEXP (operands[1], 0),
7884 XEXP (operands[1], 1), NULL_RTX);
7885 operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx);
7889 (define_expand "movhfcc"
7890 [(set (match_operand:HF 0 "s_register_operand")
7891 (if_then_else:HF (match_operand 1 "arm_cond_move_operator")
7892 (match_operand:HF 2 "s_register_operand")
7893 (match_operand:HF 3 "s_register_operand")))]
7894 "TARGET_VFP_FP16INST"
7897 enum rtx_code code = GET_CODE (operands[1]);
7900 if (!arm_validize_comparison (&operands[1], &XEXP (operands[1], 0),
7901 &XEXP (operands[1], 1)))
7904 code = GET_CODE (operands[1]);
7905 ccreg = arm_gen_compare_reg (code, XEXP (operands[1], 0),
7906 XEXP (operands[1], 1), NULL_RTX);
7907 operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx);
7911 (define_expand "movsfcc"
7912 [(set (match_operand:SF 0 "s_register_operand" "")
7913 (if_then_else:SF (match_operand 1 "arm_cond_move_operator" "")
7914 (match_operand:SF 2 "s_register_operand" "")
7915 (match_operand:SF 3 "s_register_operand" "")))]
7916 "TARGET_32BIT && TARGET_HARD_FLOAT"
7919 enum rtx_code code = GET_CODE (operands[1]);
7922 if (!arm_validize_comparison (&operands[1], &XEXP (operands[1], 0),
7923 &XEXP (operands[1], 1)))
7926 code = GET_CODE (operands[1]);
7927 ccreg = arm_gen_compare_reg (code, XEXP (operands[1], 0),
7928 XEXP (operands[1], 1), NULL_RTX);
7929 operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx);
7933 (define_expand "movdfcc"
7934 [(set (match_operand:DF 0 "s_register_operand" "")
7935 (if_then_else:DF (match_operand 1 "arm_cond_move_operator" "")
7936 (match_operand:DF 2 "s_register_operand" "")
7937 (match_operand:DF 3 "s_register_operand" "")))]
7938 "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_VFP_DOUBLE"
7941 enum rtx_code code = GET_CODE (operands[1]);
7944 if (!arm_validize_comparison (&operands[1], &XEXP (operands[1], 0),
7945 &XEXP (operands[1], 1)))
7947 code = GET_CODE (operands[1]);
7948 ccreg = arm_gen_compare_reg (code, XEXP (operands[1], 0),
7949 XEXP (operands[1], 1), NULL_RTX);
7950 operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx);
7954 (define_insn "*cmov<mode>"
7955 [(set (match_operand:SDF 0 "s_register_operand" "=<F_constraint>")
7956 (if_then_else:SDF (match_operator 1 "arm_vsel_comparison_operator"
7957 [(match_operand 2 "cc_register" "") (const_int 0)])
7958 (match_operand:SDF 3 "s_register_operand"
7960 (match_operand:SDF 4 "s_register_operand"
7961 "<F_constraint>")))]
7962 "TARGET_HARD_FLOAT && TARGET_VFP5 <vfp_double_cond>"
7965 enum arm_cond_code code = maybe_get_arm_condition_code (operands[1]);
7972 return \"vsel%d1.<V_if_elem>\\t%<V_reg>0, %<V_reg>3, %<V_reg>4\";
7977 return \"vsel%D1.<V_if_elem>\\t%<V_reg>0, %<V_reg>4, %<V_reg>3\";
7983 [(set_attr "conds" "use")
7984 (set_attr "type" "fcsel")]
7987 (define_insn "*cmovhf"
7988 [(set (match_operand:HF 0 "s_register_operand" "=t")
7989 (if_then_else:HF (match_operator 1 "arm_vsel_comparison_operator"
7990 [(match_operand 2 "cc_register" "") (const_int 0)])
7991 (match_operand:HF 3 "s_register_operand" "t")
7992 (match_operand:HF 4 "s_register_operand" "t")))]
7993 "TARGET_VFP_FP16INST"
7996 enum arm_cond_code code = maybe_get_arm_condition_code (operands[1]);
8003 return \"vsel%d1.f16\\t%0, %3, %4\";
8008 return \"vsel%D1.f16\\t%0, %4, %3\";
8014 [(set_attr "conds" "use")
8015 (set_attr "type" "fcsel")]
8018 (define_insn_and_split "*movsicc_insn"
8019 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r,r,r,r,r,r")
8021 (match_operator 3 "arm_comparison_operator"
8022 [(match_operand 4 "cc_register" "") (const_int 0)])
8023 (match_operand:SI 1 "arm_not_operand" "0,0,rI,K,rI,rI,K,K")
8024 (match_operand:SI 2 "arm_not_operand" "rI,K,0,0,rI,K,rI,K")))]
8035 ; alt4: mov%d3\\t%0, %1\;mov%D3\\t%0, %2
8036 ; alt5: mov%d3\\t%0, %1\;mvn%D3\\t%0, #%B2
8037 ; alt6: mvn%d3\\t%0, #%B1\;mov%D3\\t%0, %2
8038 ; alt7: mvn%d3\\t%0, #%B1\;mvn%D3\\t%0, #%B2"
8039 "&& reload_completed"
8042 enum rtx_code rev_code;
8046 emit_insn (gen_rtx_COND_EXEC (VOIDmode,
8048 gen_rtx_SET (operands[0], operands[1])));
8050 rev_code = GET_CODE (operands[3]);
8051 mode = GET_MODE (operands[4]);
8052 if (mode == CCFPmode || mode == CCFPEmode)
8053 rev_code = reverse_condition_maybe_unordered (rev_code);
8055 rev_code = reverse_condition (rev_code);
8057 rev_cond = gen_rtx_fmt_ee (rev_code,
8061 emit_insn (gen_rtx_COND_EXEC (VOIDmode,
8063 gen_rtx_SET (operands[0], operands[2])));
8066 [(set_attr "length" "4,4,4,4,8,8,8,8")
8067 (set_attr "conds" "use")
8068 (set_attr_alternative "type"
8069 [(if_then_else (match_operand 2 "const_int_operand" "")
8070 (const_string "mov_imm")
8071 (const_string "mov_reg"))
8072 (const_string "mvn_imm")
8073 (if_then_else (match_operand 1 "const_int_operand" "")
8074 (const_string "mov_imm")
8075 (const_string "mov_reg"))
8076 (const_string "mvn_imm")
8077 (const_string "multiple")
8078 (const_string "multiple")
8079 (const_string "multiple")
8080 (const_string "multiple")])]
8083 (define_insn "*movsfcc_soft_insn"
8084 [(set (match_operand:SF 0 "s_register_operand" "=r,r")
8085 (if_then_else:SF (match_operator 3 "arm_comparison_operator"
8086 [(match_operand 4 "cc_register" "") (const_int 0)])
8087 (match_operand:SF 1 "s_register_operand" "0,r")
8088 (match_operand:SF 2 "s_register_operand" "r,0")))]
8089 "TARGET_ARM && TARGET_SOFT_FLOAT"
8093 [(set_attr "conds" "use")
8094 (set_attr "type" "mov_reg")]
8098 ;; Jump and linkage insns
8100 (define_expand "jump"
8102 (label_ref (match_operand 0 "" "")))]
8107 (define_insn "*arm_jump"
8109 (label_ref (match_operand 0 "" "")))]
8113 if (arm_ccfsm_state == 1 || arm_ccfsm_state == 2)
8115 arm_ccfsm_state += 2;
8118 return \"b%?\\t%l0\";
8121 [(set_attr "predicable" "yes")
8122 (set (attr "length")
8124 (and (match_test "TARGET_THUMB2")
8125 (and (ge (minus (match_dup 0) (pc)) (const_int -2044))
8126 (le (minus (match_dup 0) (pc)) (const_int 2048))))
8129 (set_attr "type" "branch")]
8132 (define_expand "call"
8133 [(parallel [(call (match_operand 0 "memory_operand" "")
8134 (match_operand 1 "general_operand" ""))
8135 (use (match_operand 2 "" ""))
8136 (clobber (reg:SI LR_REGNUM))])]
8141 tree addr = MEM_EXPR (operands[0]);
8143 /* In an untyped call, we can get NULL for operand 2. */
8144 if (operands[2] == NULL_RTX)
8145 operands[2] = const0_rtx;
8147 /* Decide if we should generate indirect calls by loading the
8148 32-bit address of the callee into a register before performing the
8150 callee = XEXP (operands[0], 0);
8151 if (GET_CODE (callee) == SYMBOL_REF
8152 ? arm_is_long_call_p (SYMBOL_REF_DECL (callee))
8154 XEXP (operands[0], 0) = force_reg (Pmode, callee);
8156 if (detect_cmse_nonsecure_call (addr))
8158 pat = gen_nonsecure_call_internal (operands[0], operands[1],
8160 emit_call_insn (pat);
8164 pat = gen_call_internal (operands[0], operands[1], operands[2]);
8165 arm_emit_call_insn (pat, XEXP (operands[0], 0), false);
8171 (define_expand "call_internal"
8172 [(parallel [(call (match_operand 0 "memory_operand" "")
8173 (match_operand 1 "general_operand" ""))
8174 (use (match_operand 2 "" ""))
8175 (clobber (reg:SI LR_REGNUM))])])
8177 (define_expand "nonsecure_call_internal"
8178 [(parallel [(call (unspec:SI [(match_operand 0 "memory_operand" "")]
8179 UNSPEC_NONSECURE_MEM)
8180 (match_operand 1 "general_operand" ""))
8181 (use (match_operand 2 "" ""))
8182 (clobber (reg:SI LR_REGNUM))])]
8187 tmp = copy_to_suggested_reg (XEXP (operands[0], 0),
8188 gen_rtx_REG (SImode, R4_REGNUM),
8191 operands[0] = replace_equiv_address (operands[0], tmp);
8194 (define_insn "*call_reg_armv5"
8195 [(call (mem:SI (match_operand:SI 0 "s_register_operand" "r"))
8196 (match_operand 1 "" ""))
8197 (use (match_operand 2 "" ""))
8198 (clobber (reg:SI LR_REGNUM))]
8199 "TARGET_ARM && arm_arch5t && !SIBLING_CALL_P (insn)"
8201 [(set_attr "type" "call")]
8204 (define_insn "*call_reg_arm"
8205 [(call (mem:SI (match_operand:SI 0 "s_register_operand" "r"))
8206 (match_operand 1 "" ""))
8207 (use (match_operand 2 "" ""))
8208 (clobber (reg:SI LR_REGNUM))]
8209 "TARGET_ARM && !arm_arch5t && !SIBLING_CALL_P (insn)"
8211 return output_call (operands);
8213 ;; length is worst case, normally it is only two
8214 [(set_attr "length" "12")
8215 (set_attr "type" "call")]
8219 (define_expand "call_value"
8220 [(parallel [(set (match_operand 0 "" "")
8221 (call (match_operand 1 "memory_operand" "")
8222 (match_operand 2 "general_operand" "")))
8223 (use (match_operand 3 "" ""))
8224 (clobber (reg:SI LR_REGNUM))])]
8229 tree addr = MEM_EXPR (operands[1]);
8231 /* In an untyped call, we can get NULL for operand 2. */
8232 if (operands[3] == 0)
8233 operands[3] = const0_rtx;
8235 /* Decide if we should generate indirect calls by loading the
8236 32-bit address of the callee into a register before performing the
8238 callee = XEXP (operands[1], 0);
8239 if (GET_CODE (callee) == SYMBOL_REF
8240 ? arm_is_long_call_p (SYMBOL_REF_DECL (callee))
8242 XEXP (operands[1], 0) = force_reg (Pmode, callee);
8244 if (detect_cmse_nonsecure_call (addr))
8246 pat = gen_nonsecure_call_value_internal (operands[0], operands[1],
8247 operands[2], operands[3]);
8248 emit_call_insn (pat);
8252 pat = gen_call_value_internal (operands[0], operands[1],
8253 operands[2], operands[3]);
8254 arm_emit_call_insn (pat, XEXP (operands[1], 0), false);
8260 (define_expand "call_value_internal"
8261 [(parallel [(set (match_operand 0 "" "")
8262 (call (match_operand 1 "memory_operand" "")
8263 (match_operand 2 "general_operand" "")))
8264 (use (match_operand 3 "" ""))
8265 (clobber (reg:SI LR_REGNUM))])])
8267 (define_expand "nonsecure_call_value_internal"
8268 [(parallel [(set (match_operand 0 "" "")
8269 (call (unspec:SI [(match_operand 1 "memory_operand" "")]
8270 UNSPEC_NONSECURE_MEM)
8271 (match_operand 2 "general_operand" "")))
8272 (use (match_operand 3 "" ""))
8273 (clobber (reg:SI LR_REGNUM))])]
8278 tmp = copy_to_suggested_reg (XEXP (operands[1], 0),
8279 gen_rtx_REG (SImode, R4_REGNUM),
8282 operands[1] = replace_equiv_address (operands[1], tmp);
8285 (define_insn "*call_value_reg_armv5"
8286 [(set (match_operand 0 "" "")
8287 (call (mem:SI (match_operand:SI 1 "s_register_operand" "r"))
8288 (match_operand 2 "" "")))
8289 (use (match_operand 3 "" ""))
8290 (clobber (reg:SI LR_REGNUM))]
8291 "TARGET_ARM && arm_arch5t && !SIBLING_CALL_P (insn)"
8293 [(set_attr "type" "call")]
8296 (define_insn "*call_value_reg_arm"
8297 [(set (match_operand 0 "" "")
8298 (call (mem:SI (match_operand:SI 1 "s_register_operand" "r"))
8299 (match_operand 2 "" "")))
8300 (use (match_operand 3 "" ""))
8301 (clobber (reg:SI LR_REGNUM))]
8302 "TARGET_ARM && !arm_arch5t && !SIBLING_CALL_P (insn)"
8304 return output_call (&operands[1]);
8306 [(set_attr "length" "12")
8307 (set_attr "type" "call")]
8310 ;; Allow calls to SYMBOL_REFs specially as they are not valid general addresses
8311 ;; The 'a' causes the operand to be treated as an address, i.e. no '#' output.
8313 (define_insn "*call_symbol"
8314 [(call (mem:SI (match_operand:SI 0 "" ""))
8315 (match_operand 1 "" ""))
8316 (use (match_operand 2 "" ""))
8317 (clobber (reg:SI LR_REGNUM))]
8319 && !SIBLING_CALL_P (insn)
8320 && (GET_CODE (operands[0]) == SYMBOL_REF)
8321 && !arm_is_long_call_p (SYMBOL_REF_DECL (operands[0]))"
8324 rtx op = operands[0];
8326 /* Switch mode now when possible. */
8327 if (SYMBOL_REF_DECL (op) && !TREE_PUBLIC (SYMBOL_REF_DECL (op))
8328 && arm_arch5t && arm_change_mode_p (SYMBOL_REF_DECL (op)))
8329 return NEED_PLT_RELOC ? \"blx%?\\t%a0(PLT)\" : \"blx%?\\t(%a0)\";
8331 return NEED_PLT_RELOC ? \"bl%?\\t%a0(PLT)\" : \"bl%?\\t%a0\";
8333 [(set_attr "type" "call")]
8336 (define_insn "*call_value_symbol"
8337 [(set (match_operand 0 "" "")
8338 (call (mem:SI (match_operand:SI 1 "" ""))
8339 (match_operand:SI 2 "" "")))
8340 (use (match_operand 3 "" ""))
8341 (clobber (reg:SI LR_REGNUM))]
8343 && !SIBLING_CALL_P (insn)
8344 && (GET_CODE (operands[1]) == SYMBOL_REF)
8345 && !arm_is_long_call_p (SYMBOL_REF_DECL (operands[1]))"
8348 rtx op = operands[1];
8350 /* Switch mode now when possible. */
8351 if (SYMBOL_REF_DECL (op) && !TREE_PUBLIC (SYMBOL_REF_DECL (op))
8352 && arm_arch5t && arm_change_mode_p (SYMBOL_REF_DECL (op)))
8353 return NEED_PLT_RELOC ? \"blx%?\\t%a1(PLT)\" : \"blx%?\\t(%a1)\";
8355 return NEED_PLT_RELOC ? \"bl%?\\t%a1(PLT)\" : \"bl%?\\t%a1\";
8357 [(set_attr "type" "call")]
8360 (define_expand "sibcall_internal"
8361 [(parallel [(call (match_operand 0 "memory_operand" "")
8362 (match_operand 1 "general_operand" ""))
8364 (use (match_operand 2 "" ""))])])
8366 ;; We may also be able to do sibcalls for Thumb, but it's much harder...
8367 (define_expand "sibcall"
8368 [(parallel [(call (match_operand 0 "memory_operand" "")
8369 (match_operand 1 "general_operand" ""))
8371 (use (match_operand 2 "" ""))])]
8377 if ((!REG_P (XEXP (operands[0], 0))
8378 && GET_CODE (XEXP (operands[0], 0)) != SYMBOL_REF)
8379 || (GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
8380 && arm_is_long_call_p (SYMBOL_REF_DECL (XEXP (operands[0], 0)))))
8381 XEXP (operands[0], 0) = force_reg (SImode, XEXP (operands[0], 0));
8383 if (operands[2] == NULL_RTX)
8384 operands[2] = const0_rtx;
8386 pat = gen_sibcall_internal (operands[0], operands[1], operands[2]);
8387 arm_emit_call_insn (pat, operands[0], true);
8392 (define_expand "sibcall_value_internal"
8393 [(parallel [(set (match_operand 0 "" "")
8394 (call (match_operand 1 "memory_operand" "")
8395 (match_operand 2 "general_operand" "")))
8397 (use (match_operand 3 "" ""))])])
8399 (define_expand "sibcall_value"
8400 [(parallel [(set (match_operand 0 "" "")
8401 (call (match_operand 1 "memory_operand" "")
8402 (match_operand 2 "general_operand" "")))
8404 (use (match_operand 3 "" ""))])]
8410 if ((!REG_P (XEXP (operands[1], 0))
8411 && GET_CODE (XEXP (operands[1], 0)) != SYMBOL_REF)
8412 || (GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
8413 && arm_is_long_call_p (SYMBOL_REF_DECL (XEXP (operands[1], 0)))))
8414 XEXP (operands[1], 0) = force_reg (SImode, XEXP (operands[1], 0));
8416 if (operands[3] == NULL_RTX)
8417 operands[3] = const0_rtx;
8419 pat = gen_sibcall_value_internal (operands[0], operands[1],
8420 operands[2], operands[3]);
8421 arm_emit_call_insn (pat, operands[1], true);
8426 (define_insn "*sibcall_insn"
8427 [(call (mem:SI (match_operand:SI 0 "call_insn_operand" "Cs, US"))
8428 (match_operand 1 "" ""))
8430 (use (match_operand 2 "" ""))]
8431 "TARGET_32BIT && SIBLING_CALL_P (insn)"
8433 if (which_alternative == 1)
8434 return NEED_PLT_RELOC ? \"b%?\\t%a0(PLT)\" : \"b%?\\t%a0\";
8437 if (arm_arch5t || arm_arch4t)
8438 return \"bx%?\\t%0\\t%@ indirect register sibling call\";
8440 return \"mov%?\\t%|pc, %0\\t%@ indirect register sibling call\";
8443 [(set_attr "type" "call")]
8446 (define_insn "*sibcall_value_insn"
8447 [(set (match_operand 0 "" "")
8448 (call (mem:SI (match_operand:SI 1 "call_insn_operand" "Cs,US"))
8449 (match_operand 2 "" "")))
8451 (use (match_operand 3 "" ""))]
8452 "TARGET_32BIT && SIBLING_CALL_P (insn)"
8454 if (which_alternative == 1)
8455 return NEED_PLT_RELOC ? \"b%?\\t%a1(PLT)\" : \"b%?\\t%a1\";
8458 if (arm_arch5t || arm_arch4t)
8459 return \"bx%?\\t%1\";
8461 return \"mov%?\\t%|pc, %1\\t@ indirect sibling call \";
8464 [(set_attr "type" "call")]
8467 (define_expand "<return_str>return"
8469 "(TARGET_ARM || (TARGET_THUMB2
8470 && ARM_FUNC_TYPE (arm_current_func_type ()) == ARM_FT_NORMAL
8471 && !IS_STACKALIGN (arm_current_func_type ())))
8472 <return_cond_false>"
8477 thumb2_expand_return (<return_simple_p>);
8484 ;; Often the return insn will be the same as loading from memory, so set attr
8485 (define_insn "*arm_return"
8487 "TARGET_ARM && USE_RETURN_INSN (FALSE)"
8490 if (arm_ccfsm_state == 2)
8492 arm_ccfsm_state += 2;
8495 return output_return_instruction (const_true_rtx, true, false, false);
8497 [(set_attr "type" "load_4")
8498 (set_attr "length" "12")
8499 (set_attr "predicable" "yes")]
8502 (define_insn "*cond_<return_str>return"
8504 (if_then_else (match_operator 0 "arm_comparison_operator"
8505 [(match_operand 1 "cc_register" "") (const_int 0)])
8508 "TARGET_ARM <return_cond_true>"
8511 if (arm_ccfsm_state == 2)
8513 arm_ccfsm_state += 2;
8516 return output_return_instruction (operands[0], true, false,
8519 [(set_attr "conds" "use")
8520 (set_attr "length" "12")
8521 (set_attr "type" "load_4")]
8524 (define_insn "*cond_<return_str>return_inverted"
8526 (if_then_else (match_operator 0 "arm_comparison_operator"
8527 [(match_operand 1 "cc_register" "") (const_int 0)])
8530 "TARGET_ARM <return_cond_true>"
8533 if (arm_ccfsm_state == 2)
8535 arm_ccfsm_state += 2;
8538 return output_return_instruction (operands[0], true, true,
8541 [(set_attr "conds" "use")
8542 (set_attr "length" "12")
8543 (set_attr "type" "load_4")]
8546 (define_insn "*arm_simple_return"
8551 if (arm_ccfsm_state == 2)
8553 arm_ccfsm_state += 2;
8556 return output_return_instruction (const_true_rtx, true, false, true);
8558 [(set_attr "type" "branch")
8559 (set_attr "length" "4")
8560 (set_attr "predicable" "yes")]
8563 ;; Generate a sequence of instructions to determine if the processor is
8564 ;; in 26-bit or 32-bit mode, and return the appropriate return address
8567 (define_expand "return_addr_mask"
8569 (compare:CC_NOOV (unspec [(const_int 0)] UNSPEC_CHECK_ARCH)
8571 (set (match_operand:SI 0 "s_register_operand" "")
8572 (if_then_else:SI (eq (match_dup 1) (const_int 0))
8574 (const_int 67108860)))] ; 0x03fffffc
8577 operands[1] = gen_rtx_REG (CC_NOOVmode, CC_REGNUM);
8580 (define_insn "*check_arch2"
8581 [(set (match_operand:CC_NOOV 0 "cc_register" "")
8582 (compare:CC_NOOV (unspec [(const_int 0)] UNSPEC_CHECK_ARCH)
8585 "teq\\t%|r0, %|r0\;teq\\t%|pc, %|pc"
8586 [(set_attr "length" "8")
8587 (set_attr "conds" "set")
8588 (set_attr "type" "multiple")]
8591 ;; Call subroutine returning any type.
8593 (define_expand "untyped_call"
8594 [(parallel [(call (match_operand 0 "" "")
8596 (match_operand 1 "" "")
8597 (match_operand 2 "" "")])]
8602 rtx par = gen_rtx_PARALLEL (VOIDmode,
8603 rtvec_alloc (XVECLEN (operands[2], 0)));
8604 rtx addr = gen_reg_rtx (Pmode);
8608 emit_move_insn (addr, XEXP (operands[1], 0));
8609 mem = change_address (operands[1], BLKmode, addr);
8611 for (i = 0; i < XVECLEN (operands[2], 0); i++)
8613 rtx src = SET_SRC (XVECEXP (operands[2], 0, i));
8615 /* Default code only uses r0 as a return value, but we could
8616 be using anything up to 4 registers. */
8617 if (REGNO (src) == R0_REGNUM)
8618 src = gen_rtx_REG (TImode, R0_REGNUM);
8620 XVECEXP (par, 0, i) = gen_rtx_EXPR_LIST (VOIDmode, src,
8622 size += GET_MODE_SIZE (GET_MODE (src));
8625 emit_call_insn (gen_call_value (par, operands[0], const0_rtx, NULL));
8629 for (i = 0; i < XVECLEN (par, 0); i++)
8631 HOST_WIDE_INT offset = 0;
8632 rtx reg = XEXP (XVECEXP (par, 0, i), 0);
8635 emit_move_insn (addr, plus_constant (Pmode, addr, size));
8637 mem = change_address (mem, GET_MODE (reg), NULL);
8638 if (REGNO (reg) == R0_REGNUM)
8640 /* On thumb we have to use a write-back instruction. */
8641 emit_insn (arm_gen_store_multiple (arm_regs_in_sequence, 4, addr,
8642 TARGET_THUMB ? TRUE : FALSE, mem, &offset));
8643 size = TARGET_ARM ? 16 : 0;
8647 emit_move_insn (mem, reg);
8648 size = GET_MODE_SIZE (GET_MODE (reg));
8652 /* The optimizer does not know that the call sets the function value
8653 registers we stored in the result block. We avoid problems by
8654 claiming that all hard registers are used and clobbered at this
8656 emit_insn (gen_blockage ());
8662 (define_expand "untyped_return"
8663 [(match_operand:BLK 0 "memory_operand" "")
8664 (match_operand 1 "" "")]
8669 rtx addr = gen_reg_rtx (Pmode);
8673 emit_move_insn (addr, XEXP (operands[0], 0));
8674 mem = change_address (operands[0], BLKmode, addr);
8676 for (i = 0; i < XVECLEN (operands[1], 0); i++)
8678 HOST_WIDE_INT offset = 0;
8679 rtx reg = SET_DEST (XVECEXP (operands[1], 0, i));
8682 emit_move_insn (addr, plus_constant (Pmode, addr, size));
8684 mem = change_address (mem, GET_MODE (reg), NULL);
8685 if (REGNO (reg) == R0_REGNUM)
8687 /* On thumb we have to use a write-back instruction. */
8688 emit_insn (arm_gen_load_multiple (arm_regs_in_sequence, 4, addr,
8689 TARGET_THUMB ? TRUE : FALSE, mem, &offset));
8690 size = TARGET_ARM ? 16 : 0;
8694 emit_move_insn (reg, mem);
8695 size = GET_MODE_SIZE (GET_MODE (reg));
8699 /* Emit USE insns before the return. */
8700 for (i = 0; i < XVECLEN (operands[1], 0); i++)
8701 emit_use (SET_DEST (XVECEXP (operands[1], 0, i)));
8703 /* Construct the return. */
8704 expand_naked_return ();
8710 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
8711 ;; all of memory. This blocks insns from being moved across this point.
8713 (define_insn "blockage"
8714 [(unspec_volatile [(const_int 0)] VUNSPEC_BLOCKAGE)]
8717 [(set_attr "length" "0")
8718 (set_attr "type" "block")]
8721 ;; Since we hard code r0 here use the 'o' constraint to prevent
8722 ;; provoking undefined behaviour in the hardware with putting out
8723 ;; auto-increment operations with potentially r0 as the base register.
8724 (define_insn "probe_stack"
8725 [(set (match_operand:SI 0 "memory_operand" "=o")
8726 (unspec:SI [(const_int 0)] UNSPEC_PROBE_STACK))]
8729 [(set_attr "type" "store_4")
8730 (set_attr "predicable" "yes")]
8733 (define_insn "probe_stack_range"
8734 [(set (match_operand:SI 0 "register_operand" "=r")
8735 (unspec_volatile:SI [(match_operand:SI 1 "register_operand" "0")
8736 (match_operand:SI 2 "register_operand" "r")]
8737 VUNSPEC_PROBE_STACK_RANGE))]
8740 return output_probe_stack_range (operands[0], operands[2]);
8742 [(set_attr "type" "multiple")
8743 (set_attr "conds" "clob")]
8746 ;; Named patterns for stack smashing protection.
8747 (define_expand "stack_protect_combined_set"
8749 [(set (match_operand:SI 0 "memory_operand" "")
8750 (unspec:SI [(match_operand:SI 1 "guard_operand" "")]
8752 (clobber (match_scratch:SI 2 ""))
8753 (clobber (match_scratch:SI 3 ""))])]
8758 ;; Use a separate insn from the above expand to be able to have the mem outside
8759 ;; the operand #1 when register allocation comes. This is needed to avoid LRA
8760 ;; try to reload the guard since we need to control how PIC access is done in
8761 ;; the -fpic/-fPIC case (see COMPUTE_NOW parameter when calling
8762 ;; legitimize_pic_address ()).
8763 (define_insn_and_split "*stack_protect_combined_set_insn"
8764 [(set (match_operand:SI 0 "memory_operand" "=m,m")
8765 (unspec:SI [(mem:SI (match_operand:SI 1 "guard_addr_operand" "X,X"))]
8767 (clobber (match_scratch:SI 2 "=&l,&r"))
8768 (clobber (match_scratch:SI 3 "=&l,&r"))]
8772 [(parallel [(set (match_dup 0) (unspec:SI [(mem:SI (match_dup 2))]
8774 (clobber (match_dup 2))])]
8779 /* Forces recomputing of GOT base now. */
8780 legitimize_pic_address (operands[1], SImode, operands[2], operands[3],
8781 true /*compute_now*/);
8785 if (address_operand (operands[1], SImode))
8786 operands[2] = operands[1];
8789 rtx mem = XEXP (force_const_mem (SImode, operands[1]), 0);
8790 emit_move_insn (operands[2], mem);
8794 [(set_attr "arch" "t1,32")]
8797 (define_insn "*stack_protect_set_insn"
8798 [(set (match_operand:SI 0 "memory_operand" "=m,m")
8799 (unspec:SI [(mem:SI (match_operand:SI 1 "register_operand" "+&l,&r"))]
8801 (clobber (match_dup 1))]
8804 ldr\\t%1, [%1]\;str\\t%1, %0\;movs\t%1,#0
8805 ldr\\t%1, [%1]\;str\\t%1, %0\;mov\t%1,#0"
8806 [(set_attr "length" "8,12")
8807 (set_attr "conds" "clob,nocond")
8808 (set_attr "type" "multiple")
8809 (set_attr "arch" "t1,32")]
8812 (define_expand "stack_protect_combined_test"
8816 (eq (match_operand:SI 0 "memory_operand" "")
8817 (unspec:SI [(match_operand:SI 1 "guard_operand" "")]
8819 (label_ref (match_operand 2))
8821 (clobber (match_scratch:SI 3 ""))
8822 (clobber (match_scratch:SI 4 ""))
8823 (clobber (reg:CC CC_REGNUM))])]
8828 ;; Use a separate insn from the above expand to be able to have the mem outside
8829 ;; the operand #1 when register allocation comes. This is needed to avoid LRA
8830 ;; try to reload the guard since we need to control how PIC access is done in
8831 ;; the -fpic/-fPIC case (see COMPUTE_NOW parameter when calling
8832 ;; legitimize_pic_address ()).
8833 (define_insn_and_split "*stack_protect_combined_test_insn"
8836 (eq (match_operand:SI 0 "memory_operand" "m,m")
8837 (unspec:SI [(mem:SI (match_operand:SI 1 "guard_addr_operand" "X,X"))]
8839 (label_ref (match_operand 2))
8841 (clobber (match_scratch:SI 3 "=&l,&r"))
8842 (clobber (match_scratch:SI 4 "=&l,&r"))
8843 (clobber (reg:CC CC_REGNUM))]
8853 /* Forces recomputing of GOT base now. */
8854 legitimize_pic_address (operands[1], SImode, operands[3], operands[4],
8855 true /*compute_now*/);
8859 if (address_operand (operands[1], SImode))
8860 operands[3] = operands[1];
8863 rtx mem = XEXP (force_const_mem (SImode, operands[1]), 0);
8864 emit_move_insn (operands[3], mem);
8869 emit_insn (gen_arm_stack_protect_test_insn (operands[4], operands[0],
8871 rtx cc_reg = gen_rtx_REG (CC_Zmode, CC_REGNUM);
8872 eq = gen_rtx_EQ (CC_Zmode, cc_reg, const0_rtx);
8873 emit_jump_insn (gen_arm_cond_branch (operands[2], eq, cc_reg));
8877 emit_insn (gen_thumb1_stack_protect_test_insn (operands[4], operands[0],
8879 eq = gen_rtx_EQ (VOIDmode, operands[4], const0_rtx);
8880 emit_jump_insn (gen_cbranchsi4 (eq, operands[4], const0_rtx,
8885 [(set_attr "arch" "t1,32")]
8888 (define_insn "arm_stack_protect_test_insn"
8889 [(set (reg:CC_Z CC_REGNUM)
8890 (compare:CC_Z (unspec:SI [(match_operand:SI 1 "memory_operand" "m,m")
8891 (mem:SI (match_operand:SI 2 "register_operand" "+l,r"))]
8894 (clobber (match_operand:SI 0 "register_operand" "=&l,&r"))
8895 (clobber (match_dup 2))]
8897 "ldr\t%0, [%2]\;ldr\t%2, %1\;eors\t%0, %2, %0"
8898 [(set_attr "length" "8,12")
8899 (set_attr "conds" "set")
8900 (set_attr "type" "multiple")
8901 (set_attr "arch" "t,32")]
8904 (define_expand "casesi"
8905 [(match_operand:SI 0 "s_register_operand" "") ; index to jump on
8906 (match_operand:SI 1 "const_int_operand" "") ; lower bound
8907 (match_operand:SI 2 "const_int_operand" "") ; total range
8908 (match_operand:SI 3 "" "") ; table label
8909 (match_operand:SI 4 "" "")] ; Out of range label
8910 "(TARGET_32BIT || optimize_size || flag_pic) && !target_pure_code"
8913 enum insn_code code;
8914 if (operands[1] != const0_rtx)
8916 rtx reg = gen_reg_rtx (SImode);
8918 emit_insn (gen_addsi3 (reg, operands[0],
8919 gen_int_mode (-INTVAL (operands[1]),
8925 code = CODE_FOR_arm_casesi_internal;
8926 else if (TARGET_THUMB1)
8927 code = CODE_FOR_thumb1_casesi_internal_pic;
8929 code = CODE_FOR_thumb2_casesi_internal_pic;
8931 code = CODE_FOR_thumb2_casesi_internal;
8933 if (!insn_data[(int) code].operand[1].predicate(operands[2], SImode))
8934 operands[2] = force_reg (SImode, operands[2]);
8936 emit_jump_insn (GEN_FCN ((int) code) (operands[0], operands[2],
8937 operands[3], operands[4]));
8942 ;; The USE in this pattern is needed to tell flow analysis that this is
8943 ;; a CASESI insn. It has no other purpose.
8944 (define_expand "arm_casesi_internal"
8945 [(parallel [(set (pc)
8947 (leu (match_operand:SI 0 "s_register_operand")
8948 (match_operand:SI 1 "arm_rhs_operand"))
8950 (label_ref:SI (match_operand 3 ""))))
8951 (clobber (reg:CC CC_REGNUM))
8952 (use (label_ref:SI (match_operand 2 "")))])]
8955 operands[4] = gen_rtx_MULT (SImode, operands[0], GEN_INT (4));
8956 operands[4] = gen_rtx_PLUS (SImode, operands[4],
8957 gen_rtx_LABEL_REF (SImode, operands[2]));
8958 operands[4] = gen_rtx_MEM (SImode, operands[4]);
8959 MEM_READONLY_P (operands[4]) = 1;
8960 MEM_NOTRAP_P (operands[4]) = 1;
8963 (define_insn "*arm_casesi_internal"
8964 [(parallel [(set (pc)
8966 (leu (match_operand:SI 0 "s_register_operand" "r")
8967 (match_operand:SI 1 "arm_rhs_operand" "rI"))
8968 (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
8969 (label_ref:SI (match_operand 2 "" ""))))
8970 (label_ref:SI (match_operand 3 "" ""))))
8971 (clobber (reg:CC CC_REGNUM))
8972 (use (label_ref:SI (match_dup 2)))])]
8976 return \"cmp\\t%0, %1\;addls\\t%|pc, %|pc, %0, asl #2\;b\\t%l3\";
8977 return \"cmp\\t%0, %1\;ldrls\\t%|pc, [%|pc, %0, asl #2]\;b\\t%l3\";
8979 [(set_attr "conds" "clob")
8980 (set_attr "length" "12")
8981 (set_attr "type" "multiple")]
8984 (define_expand "indirect_jump"
8986 (match_operand:SI 0 "s_register_operand" ""))]
8989 /* Thumb-2 doesn't have mov pc, reg. Explicitly set the low bit of the
8990 address and use bx. */
8994 tmp = gen_reg_rtx (SImode);
8995 emit_insn (gen_iorsi3 (tmp, operands[0], GEN_INT(1)));
9001 ;; NB Never uses BX.
9002 (define_insn "*arm_indirect_jump"
9004 (match_operand:SI 0 "s_register_operand" "r"))]
9006 "mov%?\\t%|pc, %0\\t%@ indirect register jump"
9007 [(set_attr "predicable" "yes")
9008 (set_attr "type" "branch")]
9011 (define_insn "*load_indirect_jump"
9013 (match_operand:SI 0 "memory_operand" "m"))]
9015 "ldr%?\\t%|pc, %0\\t%@ indirect memory jump"
9016 [(set_attr "type" "load_4")
9017 (set_attr "pool_range" "4096")
9018 (set_attr "neg_pool_range" "4084")
9019 (set_attr "predicable" "yes")]
9029 [(set (attr "length")
9030 (if_then_else (eq_attr "is_thumb" "yes")
9033 (set_attr "type" "mov_reg")]
9037 [(trap_if (const_int 1) (const_int 0))]
9041 return \".inst\\t0xe7f000f0\";
9043 return \".inst\\t0xdeff\";
9045 [(set (attr "length")
9046 (if_then_else (eq_attr "is_thumb" "yes")
9049 (set_attr "type" "trap")
9050 (set_attr "conds" "unconditional")]
9054 ;; Patterns to allow combination of arithmetic, cond code and shifts
9056 (define_insn "*<arith_shift_insn>_multsi"
9057 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
9059 (mult:SI (match_operand:SI 2 "s_register_operand" "r,r")
9060 (match_operand:SI 3 "power_of_two_operand" ""))
9061 (match_operand:SI 1 "s_register_operand" "rk,<t2_binop0>")))]
9063 "<arith_shift_insn>%?\\t%0, %1, %2, lsl %b3"
9064 [(set_attr "predicable" "yes")
9065 (set_attr "shift" "2")
9066 (set_attr "arch" "a,t2")
9067 (set_attr "type" "alu_shift_imm")])
9069 (define_insn "*<arith_shift_insn>_shiftsi"
9070 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
9072 (match_operator:SI 2 "shift_nomul_operator"
9073 [(match_operand:SI 3 "s_register_operand" "r,r,r")
9074 (match_operand:SI 4 "shift_amount_operand" "M,M,r")])
9075 (match_operand:SI 1 "s_register_operand" "rk,<t2_binop0>,rk")))]
9076 "TARGET_32BIT && GET_CODE (operands[2]) != MULT"
9077 "<arith_shift_insn>%?\\t%0, %1, %3%S2"
9078 [(set_attr "predicable" "yes")
9079 (set_attr "shift" "3")
9080 (set_attr "arch" "a,t2,a")
9081 (set_attr "type" "alu_shift_imm,alu_shift_imm,alu_shift_reg")])
9084 [(set (match_operand:SI 0 "s_register_operand" "")
9085 (match_operator:SI 1 "shiftable_operator"
9086 [(match_operator:SI 2 "shiftable_operator"
9087 [(match_operator:SI 3 "shift_operator"
9088 [(match_operand:SI 4 "s_register_operand" "")
9089 (match_operand:SI 5 "reg_or_int_operand" "")])
9090 (match_operand:SI 6 "s_register_operand" "")])
9091 (match_operand:SI 7 "arm_rhs_operand" "")]))
9092 (clobber (match_operand:SI 8 "s_register_operand" ""))]
9095 (match_op_dup 2 [(match_op_dup 3 [(match_dup 4) (match_dup 5)])
9098 (match_op_dup 1 [(match_dup 8) (match_dup 7)]))]
9101 (define_insn "*arith_shiftsi_compare0"
9102 [(set (reg:CC_NOOV CC_REGNUM)
9104 (match_operator:SI 1 "shiftable_operator"
9105 [(match_operator:SI 3 "shift_operator"
9106 [(match_operand:SI 4 "s_register_operand" "r,r")
9107 (match_operand:SI 5 "shift_amount_operand" "M,r")])
9108 (match_operand:SI 2 "s_register_operand" "r,r")])
9110 (set (match_operand:SI 0 "s_register_operand" "=r,r")
9111 (match_op_dup 1 [(match_op_dup 3 [(match_dup 4) (match_dup 5)])
9114 "%i1s%?\\t%0, %2, %4%S3"
9115 [(set_attr "conds" "set")
9116 (set_attr "shift" "4")
9117 (set_attr "arch" "32,a")
9118 (set_attr "type" "alus_shift_imm,alus_shift_reg")])
9120 (define_insn "*arith_shiftsi_compare0_scratch"
9121 [(set (reg:CC_NOOV CC_REGNUM)
9123 (match_operator:SI 1 "shiftable_operator"
9124 [(match_operator:SI 3 "shift_operator"
9125 [(match_operand:SI 4 "s_register_operand" "r,r")
9126 (match_operand:SI 5 "shift_amount_operand" "M,r")])
9127 (match_operand:SI 2 "s_register_operand" "r,r")])
9129 (clobber (match_scratch:SI 0 "=r,r"))]
9131 "%i1s%?\\t%0, %2, %4%S3"
9132 [(set_attr "conds" "set")
9133 (set_attr "shift" "4")
9134 (set_attr "arch" "32,a")
9135 (set_attr "type" "alus_shift_imm,alus_shift_reg")])
9137 (define_insn "*sub_shiftsi"
9138 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
9139 (minus:SI (match_operand:SI 1 "s_register_operand" "r,r")
9140 (match_operator:SI 2 "shift_operator"
9141 [(match_operand:SI 3 "s_register_operand" "r,r")
9142 (match_operand:SI 4 "shift_amount_operand" "M,r")])))]
9144 "sub%?\\t%0, %1, %3%S2"
9145 [(set_attr "predicable" "yes")
9146 (set_attr "predicable_short_it" "no")
9147 (set_attr "shift" "3")
9148 (set_attr "arch" "32,a")
9149 (set_attr "type" "alus_shift_imm,alus_shift_reg")])
9151 (define_insn "*sub_shiftsi_compare0"
9152 [(set (reg:CC_NOOV CC_REGNUM)
9154 (minus:SI (match_operand:SI 1 "s_register_operand" "r,r,r")
9155 (match_operator:SI 2 "shift_operator"
9156 [(match_operand:SI 3 "s_register_operand" "r,r,r")
9157 (match_operand:SI 4 "shift_amount_operand" "M,r,M")]))
9159 (set (match_operand:SI 0 "s_register_operand" "=r,r,r")
9160 (minus:SI (match_dup 1)
9161 (match_op_dup 2 [(match_dup 3) (match_dup 4)])))]
9163 "subs%?\\t%0, %1, %3%S2"
9164 [(set_attr "conds" "set")
9165 (set_attr "shift" "3")
9166 (set_attr "arch" "32,a,a")
9167 (set_attr "type" "alus_shift_imm,alus_shift_reg,alus_shift_imm")])
9169 (define_insn "*sub_shiftsi_compare0_scratch"
9170 [(set (reg:CC_NOOV CC_REGNUM)
9172 (minus:SI (match_operand:SI 1 "s_register_operand" "r,r,r")
9173 (match_operator:SI 2 "shift_operator"
9174 [(match_operand:SI 3 "s_register_operand" "r,r,r")
9175 (match_operand:SI 4 "shift_amount_operand" "M,r,M")]))
9177 (clobber (match_scratch:SI 0 "=r,r,r"))]
9179 "subs%?\\t%0, %1, %3%S2"
9180 [(set_attr "conds" "set")
9181 (set_attr "shift" "3")
9182 (set_attr "arch" "32,a,a")
9183 (set_attr "type" "alus_shift_imm,alus_shift_reg,alus_shift_imm")])
9186 (define_insn_and_split "*and_scc"
9187 [(set (match_operand:SI 0 "s_register_operand" "=r")
9188 (and:SI (match_operator:SI 1 "arm_comparison_operator"
9189 [(match_operand 2 "cc_register" "") (const_int 0)])
9190 (match_operand:SI 3 "s_register_operand" "r")))]
9192 "#" ; "mov%D1\\t%0, #0\;and%d1\\t%0, %3, #1"
9193 "&& reload_completed"
9194 [(cond_exec (match_dup 5) (set (match_dup 0) (const_int 0)))
9195 (cond_exec (match_dup 4) (set (match_dup 0)
9196 (and:SI (match_dup 3) (const_int 1))))]
9198 machine_mode mode = GET_MODE (operands[2]);
9199 enum rtx_code rc = GET_CODE (operands[1]);
9201 /* Note that operands[4] is the same as operands[1],
9202 but with VOIDmode as the result. */
9203 operands[4] = gen_rtx_fmt_ee (rc, VOIDmode, operands[2], const0_rtx);
9204 if (mode == CCFPmode || mode == CCFPEmode)
9205 rc = reverse_condition_maybe_unordered (rc);
9207 rc = reverse_condition (rc);
9208 operands[5] = gen_rtx_fmt_ee (rc, VOIDmode, operands[2], const0_rtx);
9210 [(set_attr "conds" "use")
9211 (set_attr "type" "multiple")
9212 (set_attr "length" "8")]
9215 (define_insn_and_split "*ior_scc"
9216 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
9217 (ior:SI (match_operator:SI 1 "arm_comparison_operator"
9218 [(match_operand 2 "cc_register" "") (const_int 0)])
9219 (match_operand:SI 3 "s_register_operand" "0,?r")))]
9224 "&& reload_completed
9225 && REGNO (operands [0]) != REGNO (operands[3])"
9226 ;; && which_alternative == 1
9227 ; mov%D1\\t%0, %3\;orr%d1\\t%0, %3, #1
9228 [(cond_exec (match_dup 5) (set (match_dup 0) (match_dup 3)))
9229 (cond_exec (match_dup 4) (set (match_dup 0)
9230 (ior:SI (match_dup 3) (const_int 1))))]
9232 machine_mode mode = GET_MODE (operands[2]);
9233 enum rtx_code rc = GET_CODE (operands[1]);
9235 /* Note that operands[4] is the same as operands[1],
9236 but with VOIDmode as the result. */
9237 operands[4] = gen_rtx_fmt_ee (rc, VOIDmode, operands[2], const0_rtx);
9238 if (mode == CCFPmode || mode == CCFPEmode)
9239 rc = reverse_condition_maybe_unordered (rc);
9241 rc = reverse_condition (rc);
9242 operands[5] = gen_rtx_fmt_ee (rc, VOIDmode, operands[2], const0_rtx);
9244 [(set_attr "conds" "use")
9245 (set_attr "length" "4,8")
9246 (set_attr "type" "logic_imm,multiple")]
9249 ; A series of splitters for the compare_scc pattern below. Note that
9250 ; order is important.
9252 [(set (match_operand:SI 0 "s_register_operand" "")
9253 (lt:SI (match_operand:SI 1 "s_register_operand" "")
9255 (clobber (reg:CC CC_REGNUM))]
9256 "TARGET_32BIT && reload_completed"
9257 [(set (match_dup 0) (lshiftrt:SI (match_dup 1) (const_int 31)))])
9260 [(set (match_operand:SI 0 "s_register_operand" "")
9261 (ge:SI (match_operand:SI 1 "s_register_operand" "")
9263 (clobber (reg:CC CC_REGNUM))]
9264 "TARGET_32BIT && reload_completed"
9265 [(set (match_dup 0) (not:SI (match_dup 1)))
9266 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 31)))])
9269 [(set (match_operand:SI 0 "s_register_operand" "")
9270 (eq:SI (match_operand:SI 1 "s_register_operand" "")
9272 (clobber (reg:CC CC_REGNUM))]
9273 "arm_arch5t && TARGET_32BIT"
9274 [(set (match_dup 0) (clz:SI (match_dup 1)))
9275 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 5)))]
9279 [(set (match_operand:SI 0 "s_register_operand" "")
9280 (eq:SI (match_operand:SI 1 "s_register_operand" "")
9282 (clobber (reg:CC CC_REGNUM))]
9283 "TARGET_32BIT && reload_completed"
9285 [(set (reg:CC CC_REGNUM)
9286 (compare:CC (const_int 1) (match_dup 1)))
9288 (minus:SI (const_int 1) (match_dup 1)))])
9289 (cond_exec (ltu:CC (reg:CC CC_REGNUM) (const_int 0))
9290 (set (match_dup 0) (const_int 0)))])
9293 [(set (match_operand:SI 0 "s_register_operand" "")
9294 (ne:SI (match_operand:SI 1 "s_register_operand" "")
9295 (match_operand:SI 2 "const_int_operand" "")))
9296 (clobber (reg:CC CC_REGNUM))]
9297 "TARGET_32BIT && reload_completed"
9299 [(set (reg:CC CC_REGNUM)
9300 (compare:CC (match_dup 1) (match_dup 2)))
9301 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))])
9302 (cond_exec (ne:CC (reg:CC CC_REGNUM) (const_int 0))
9303 (set (match_dup 0) (const_int 1)))]
9305 operands[3] = GEN_INT (-INTVAL (operands[2]));
9309 [(set (match_operand:SI 0 "s_register_operand" "")
9310 (ne:SI (match_operand:SI 1 "s_register_operand" "")
9311 (match_operand:SI 2 "arm_add_operand" "")))
9312 (clobber (reg:CC CC_REGNUM))]
9313 "TARGET_32BIT && reload_completed"
9315 [(set (reg:CC_NOOV CC_REGNUM)
9316 (compare:CC_NOOV (minus:SI (match_dup 1) (match_dup 2))
9318 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))])
9319 (cond_exec (ne:CC_NOOV (reg:CC_NOOV CC_REGNUM) (const_int 0))
9320 (set (match_dup 0) (const_int 1)))])
9322 (define_insn_and_split "*compare_scc"
9323 [(set (match_operand:SI 0 "s_register_operand" "=Ts,Ts")
9324 (match_operator:SI 1 "arm_comparison_operator"
9325 [(match_operand:SI 2 "s_register_operand" "r,r")
9326 (match_operand:SI 3 "arm_add_operand" "rI,L")]))
9327 (clobber (reg:CC CC_REGNUM))]
9330 "&& reload_completed"
9331 [(set (reg:CC CC_REGNUM) (compare:CC (match_dup 2) (match_dup 3)))
9332 (cond_exec (match_dup 4) (set (match_dup 0) (const_int 0)))
9333 (cond_exec (match_dup 5) (set (match_dup 0) (const_int 1)))]
9336 machine_mode mode = SELECT_CC_MODE (GET_CODE (operands[1]),
9337 operands[2], operands[3]);
9338 enum rtx_code rc = GET_CODE (operands[1]);
9340 tmp1 = gen_rtx_REG (mode, CC_REGNUM);
9342 operands[5] = gen_rtx_fmt_ee (rc, VOIDmode, tmp1, const0_rtx);
9343 if (mode == CCFPmode || mode == CCFPEmode)
9344 rc = reverse_condition_maybe_unordered (rc);
9346 rc = reverse_condition (rc);
9347 operands[4] = gen_rtx_fmt_ee (rc, VOIDmode, tmp1, const0_rtx);
9349 [(set_attr "type" "multiple")]
9352 ;; Attempt to improve the sequence generated by the compare_scc splitters
9353 ;; not to use conditional execution.
9355 ;; Rd = (eq (reg1) (const_int0)) // ARMv5
9359 [(set (reg:CC CC_REGNUM)
9360 (compare:CC (match_operand:SI 1 "register_operand" "")
9362 (cond_exec (ne (reg:CC CC_REGNUM) (const_int 0))
9363 (set (match_operand:SI 0 "register_operand" "") (const_int 0)))
9364 (cond_exec (eq (reg:CC CC_REGNUM) (const_int 0))
9365 (set (match_dup 0) (const_int 1)))]
9366 "arm_arch5t && TARGET_32BIT && peep2_regno_dead_p (3, CC_REGNUM)"
9367 [(set (match_dup 0) (clz:SI (match_dup 1)))
9368 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 5)))]
9371 ;; Rd = (eq (reg1) (const_int0)) // !ARMv5
9375 [(set (reg:CC CC_REGNUM)
9376 (compare:CC (match_operand:SI 1 "register_operand" "")
9378 (cond_exec (ne (reg:CC CC_REGNUM) (const_int 0))
9379 (set (match_operand:SI 0 "register_operand" "") (const_int 0)))
9380 (cond_exec (eq (reg:CC CC_REGNUM) (const_int 0))
9381 (set (match_dup 0) (const_int 1)))
9382 (match_scratch:SI 2 "r")]
9383 "TARGET_32BIT && peep2_regno_dead_p (3, CC_REGNUM)"
9385 [(set (reg:CC CC_REGNUM)
9386 (compare:CC (const_int 0) (match_dup 1)))
9387 (set (match_dup 2) (minus:SI (const_int 0) (match_dup 1)))])
9389 (plus:SI (plus:SI (match_dup 1) (match_dup 2))
9390 (geu:SI (reg:CC CC_REGNUM) (const_int 0))))]
9393 ;; Rd = (eq (reg1) (reg2/imm)) // ARMv5 and optimising for speed.
9394 ;; sub Rd, Reg1, reg2
9398 [(set (reg:CC CC_REGNUM)
9399 (compare:CC (match_operand:SI 1 "register_operand" "")
9400 (match_operand:SI 2 "arm_rhs_operand" "")))
9401 (cond_exec (ne (reg:CC CC_REGNUM) (const_int 0))
9402 (set (match_operand:SI 0 "register_operand" "") (const_int 0)))
9403 (cond_exec (eq (reg:CC CC_REGNUM) (const_int 0))
9404 (set (match_dup 0) (const_int 1)))]
9405 "arm_arch5t && TARGET_32BIT && peep2_regno_dead_p (3, CC_REGNUM)
9406 && !(TARGET_THUMB2 && optimize_insn_for_size_p ())"
9407 [(set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))
9408 (set (match_dup 0) (clz:SI (match_dup 0)))
9409 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 5)))]
9413 ;; Rd = (eq (reg1) (reg2)) // ! ARMv5 or optimising for size.
9414 ;; sub T1, Reg1, reg2
9418 [(set (reg:CC CC_REGNUM)
9419 (compare:CC (match_operand:SI 1 "register_operand" "")
9420 (match_operand:SI 2 "arm_rhs_operand" "")))
9421 (cond_exec (ne (reg:CC CC_REGNUM) (const_int 0))
9422 (set (match_operand:SI 0 "register_operand" "") (const_int 0)))
9423 (cond_exec (eq (reg:CC CC_REGNUM) (const_int 0))
9424 (set (match_dup 0) (const_int 1)))
9425 (match_scratch:SI 3 "r")]
9426 "TARGET_32BIT && peep2_regno_dead_p (3, CC_REGNUM)"
9427 [(set (match_dup 3) (match_dup 4))
9429 [(set (reg:CC CC_REGNUM)
9430 (compare:CC (const_int 0) (match_dup 3)))
9431 (set (match_dup 0) (minus:SI (const_int 0) (match_dup 3)))])
9433 (plus:SI (plus:SI (match_dup 0) (match_dup 3))
9434 (geu:SI (reg:CC CC_REGNUM) (const_int 0))))]
9436 if (CONST_INT_P (operands[2]))
9437 operands[4] = plus_constant (SImode, operands[1], -INTVAL (operands[2]));
9439 operands[4] = gen_rtx_MINUS (SImode, operands[1], operands[2]);
9442 (define_insn "*cond_move"
9443 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
9444 (if_then_else:SI (match_operator 3 "equality_operator"
9445 [(match_operator 4 "arm_comparison_operator"
9446 [(match_operand 5 "cc_register" "") (const_int 0)])
9448 (match_operand:SI 1 "arm_rhs_operand" "0,rI,?rI")
9449 (match_operand:SI 2 "arm_rhs_operand" "rI,0,rI")))]
9452 if (GET_CODE (operands[3]) == NE)
9454 if (which_alternative != 1)
9455 output_asm_insn (\"mov%D4\\t%0, %2\", operands);
9456 if (which_alternative != 0)
9457 output_asm_insn (\"mov%d4\\t%0, %1\", operands);
9460 if (which_alternative != 0)
9461 output_asm_insn (\"mov%D4\\t%0, %1\", operands);
9462 if (which_alternative != 1)
9463 output_asm_insn (\"mov%d4\\t%0, %2\", operands);
9466 [(set_attr "conds" "use")
9467 (set_attr_alternative "type"
9468 [(if_then_else (match_operand 2 "const_int_operand" "")
9469 (const_string "mov_imm")
9470 (const_string "mov_reg"))
9471 (if_then_else (match_operand 1 "const_int_operand" "")
9472 (const_string "mov_imm")
9473 (const_string "mov_reg"))
9474 (const_string "multiple")])
9475 (set_attr "length" "4,4,8")]
9478 (define_insn "*cond_arith"
9479 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
9480 (match_operator:SI 5 "shiftable_operator"
9481 [(match_operator:SI 4 "arm_comparison_operator"
9482 [(match_operand:SI 2 "s_register_operand" "r,r")
9483 (match_operand:SI 3 "arm_rhs_operand" "rI,rI")])
9484 (match_operand:SI 1 "s_register_operand" "0,?r")]))
9485 (clobber (reg:CC CC_REGNUM))]
9488 if (GET_CODE (operands[4]) == LT && operands[3] == const0_rtx)
9489 return \"%i5\\t%0, %1, %2, lsr #31\";
9491 output_asm_insn (\"cmp\\t%2, %3\", operands);
9492 if (GET_CODE (operands[5]) == AND)
9493 output_asm_insn (\"mov%D4\\t%0, #0\", operands);
9494 else if (GET_CODE (operands[5]) == MINUS)
9495 output_asm_insn (\"rsb%D4\\t%0, %1, #0\", operands);
9496 else if (which_alternative != 0)
9497 output_asm_insn (\"mov%D4\\t%0, %1\", operands);
9498 return \"%i5%d4\\t%0, %1, #1\";
9500 [(set_attr "conds" "clob")
9501 (set_attr "length" "12")
9502 (set_attr "type" "multiple")]
9505 (define_insn "*cond_sub"
9506 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
9507 (minus:SI (match_operand:SI 1 "s_register_operand" "0,?r")
9508 (match_operator:SI 4 "arm_comparison_operator"
9509 [(match_operand:SI 2 "s_register_operand" "r,r")
9510 (match_operand:SI 3 "arm_rhs_operand" "rI,rI")])))
9511 (clobber (reg:CC CC_REGNUM))]
9514 output_asm_insn (\"cmp\\t%2, %3\", operands);
9515 if (which_alternative != 0)
9516 output_asm_insn (\"mov%D4\\t%0, %1\", operands);
9517 return \"sub%d4\\t%0, %1, #1\";
9519 [(set_attr "conds" "clob")
9520 (set_attr "length" "8,12")
9521 (set_attr "type" "multiple")]
9524 (define_insn "*cmp_ite0"
9525 [(set (match_operand 6 "dominant_cc_register" "")
9528 (match_operator 4 "arm_comparison_operator"
9529 [(match_operand:SI 0 "s_register_operand"
9530 "l,l,l,r,r,r,r,r,r")
9531 (match_operand:SI 1 "arm_add_operand"
9532 "lPy,lPy,lPy,rI,L,rI,L,rI,L")])
9533 (match_operator:SI 5 "arm_comparison_operator"
9534 [(match_operand:SI 2 "s_register_operand"
9535 "l,r,r,l,l,r,r,r,r")
9536 (match_operand:SI 3 "arm_add_operand"
9537 "lPy,rI,L,lPy,lPy,rI,rI,L,L")])
9543 static const char * const cmp1[NUM_OF_COND_CMP][2] =
9545 {\"cmp%d5\\t%0, %1\",
9546 \"cmp%d4\\t%2, %3\"},
9547 {\"cmn%d5\\t%0, #%n1\",
9548 \"cmp%d4\\t%2, %3\"},
9549 {\"cmp%d5\\t%0, %1\",
9550 \"cmn%d4\\t%2, #%n3\"},
9551 {\"cmn%d5\\t%0, #%n1\",
9552 \"cmn%d4\\t%2, #%n3\"}
9554 static const char * const cmp2[NUM_OF_COND_CMP][2] =
9559 \"cmn\\t%0, #%n1\"},
9560 {\"cmn\\t%2, #%n3\",
9562 {\"cmn\\t%2, #%n3\",
9565 static const char * const ite[2] =
9570 static const int cmp_idx[9] = {CMP_CMP, CMP_CMP, CMP_CMN,
9571 CMP_CMP, CMN_CMP, CMP_CMP,
9572 CMN_CMP, CMP_CMN, CMN_CMN};
9574 comparison_dominates_p (GET_CODE (operands[5]), GET_CODE (operands[4]));
9576 output_asm_insn (cmp2[cmp_idx[which_alternative]][swap], operands);
9577 if (TARGET_THUMB2) {
9578 output_asm_insn (ite[swap], operands);
9580 output_asm_insn (cmp1[cmp_idx[which_alternative]][swap], operands);
9583 [(set_attr "conds" "set")
9584 (set_attr "arch" "t2,t2,t2,t2,t2,any,any,any,any")
9585 (set_attr "enabled_for_short_it" "yes,no,no,no,no,no,no,no,no")
9586 (set_attr "type" "multiple")
9587 (set_attr_alternative "length"
9593 (if_then_else (eq_attr "is_thumb" "no")
9596 (if_then_else (eq_attr "is_thumb" "no")
9599 (if_then_else (eq_attr "is_thumb" "no")
9602 (if_then_else (eq_attr "is_thumb" "no")
9607 (define_insn "*cmp_ite1"
9608 [(set (match_operand 6 "dominant_cc_register" "")
9611 (match_operator 4 "arm_comparison_operator"
9612 [(match_operand:SI 0 "s_register_operand"
9613 "l,l,l,r,r,r,r,r,r")
9614 (match_operand:SI 1 "arm_add_operand"
9615 "lPy,lPy,lPy,rI,L,rI,L,rI,L")])
9616 (match_operator:SI 5 "arm_comparison_operator"
9617 [(match_operand:SI 2 "s_register_operand"
9618 "l,r,r,l,l,r,r,r,r")
9619 (match_operand:SI 3 "arm_add_operand"
9620 "lPy,rI,L,lPy,lPy,rI,rI,L,L")])
9626 static const char * const cmp1[NUM_OF_COND_CMP][2] =
9630 {\"cmn\\t%0, #%n1\",
9633 \"cmn\\t%2, #%n3\"},
9634 {\"cmn\\t%0, #%n1\",
9637 static const char * const cmp2[NUM_OF_COND_CMP][2] =
9639 {\"cmp%d4\\t%2, %3\",
9640 \"cmp%D5\\t%0, %1\"},
9641 {\"cmp%d4\\t%2, %3\",
9642 \"cmn%D5\\t%0, #%n1\"},
9643 {\"cmn%d4\\t%2, #%n3\",
9644 \"cmp%D5\\t%0, %1\"},
9645 {\"cmn%d4\\t%2, #%n3\",
9646 \"cmn%D5\\t%0, #%n1\"}
9648 static const char * const ite[2] =
9653 static const int cmp_idx[9] = {CMP_CMP, CMP_CMP, CMP_CMN,
9654 CMP_CMP, CMN_CMP, CMP_CMP,
9655 CMN_CMP, CMP_CMN, CMN_CMN};
9657 comparison_dominates_p (GET_CODE (operands[5]),
9658 reverse_condition (GET_CODE (operands[4])));
9660 output_asm_insn (cmp1[cmp_idx[which_alternative]][swap], operands);
9661 if (TARGET_THUMB2) {
9662 output_asm_insn (ite[swap], operands);
9664 output_asm_insn (cmp2[cmp_idx[which_alternative]][swap], operands);
9667 [(set_attr "conds" "set")
9668 (set_attr "arch" "t2,t2,t2,t2,t2,any,any,any,any")
9669 (set_attr "enabled_for_short_it" "yes,no,no,no,no,no,no,no,no")
9670 (set_attr_alternative "length"
9676 (if_then_else (eq_attr "is_thumb" "no")
9679 (if_then_else (eq_attr "is_thumb" "no")
9682 (if_then_else (eq_attr "is_thumb" "no")
9685 (if_then_else (eq_attr "is_thumb" "no")
9688 (set_attr "type" "multiple")]
9691 (define_insn "*cmp_and"
9692 [(set (match_operand 6 "dominant_cc_register" "")
9695 (match_operator 4 "arm_comparison_operator"
9696 [(match_operand:SI 0 "s_register_operand"
9697 "l,l,l,r,r,r,r,r,r")
9698 (match_operand:SI 1 "arm_add_operand"
9699 "lPy,lPy,lPy,rI,L,rI,L,rI,L")])
9700 (match_operator:SI 5 "arm_comparison_operator"
9701 [(match_operand:SI 2 "s_register_operand"
9702 "l,r,r,l,l,r,r,r,r")
9703 (match_operand:SI 3 "arm_add_operand"
9704 "lPy,rI,L,lPy,lPy,rI,rI,L,L")]))
9709 static const char *const cmp1[NUM_OF_COND_CMP][2] =
9711 {\"cmp%d5\\t%0, %1\",
9712 \"cmp%d4\\t%2, %3\"},
9713 {\"cmn%d5\\t%0, #%n1\",
9714 \"cmp%d4\\t%2, %3\"},
9715 {\"cmp%d5\\t%0, %1\",
9716 \"cmn%d4\\t%2, #%n3\"},
9717 {\"cmn%d5\\t%0, #%n1\",
9718 \"cmn%d4\\t%2, #%n3\"}
9720 static const char *const cmp2[NUM_OF_COND_CMP][2] =
9725 \"cmn\\t%0, #%n1\"},
9726 {\"cmn\\t%2, #%n3\",
9728 {\"cmn\\t%2, #%n3\",
9731 static const char *const ite[2] =
9736 static const int cmp_idx[9] = {CMP_CMP, CMP_CMP, CMP_CMN,
9737 CMP_CMP, CMN_CMP, CMP_CMP,
9738 CMN_CMP, CMP_CMN, CMN_CMN};
9740 comparison_dominates_p (GET_CODE (operands[5]), GET_CODE (operands[4]));
9742 output_asm_insn (cmp2[cmp_idx[which_alternative]][swap], operands);
9743 if (TARGET_THUMB2) {
9744 output_asm_insn (ite[swap], operands);
9746 output_asm_insn (cmp1[cmp_idx[which_alternative]][swap], operands);
9749 [(set_attr "conds" "set")
9750 (set_attr "predicable" "no")
9751 (set_attr "arch" "t2,t2,t2,t2,t2,any,any,any,any")
9752 (set_attr "enabled_for_short_it" "yes,no,no,no,no,no,no,no,no")
9753 (set_attr_alternative "length"
9759 (if_then_else (eq_attr "is_thumb" "no")
9762 (if_then_else (eq_attr "is_thumb" "no")
9765 (if_then_else (eq_attr "is_thumb" "no")
9768 (if_then_else (eq_attr "is_thumb" "no")
9771 (set_attr "type" "multiple")]
9774 (define_insn "*cmp_ior"
9775 [(set (match_operand 6 "dominant_cc_register" "")
9778 (match_operator 4 "arm_comparison_operator"
9779 [(match_operand:SI 0 "s_register_operand"
9780 "l,l,l,r,r,r,r,r,r")
9781 (match_operand:SI 1 "arm_add_operand"
9782 "lPy,lPy,lPy,rI,L,rI,L,rI,L")])
9783 (match_operator:SI 5 "arm_comparison_operator"
9784 [(match_operand:SI 2 "s_register_operand"
9785 "l,r,r,l,l,r,r,r,r")
9786 (match_operand:SI 3 "arm_add_operand"
9787 "lPy,rI,L,lPy,lPy,rI,rI,L,L")]))
9792 static const char *const cmp1[NUM_OF_COND_CMP][2] =
9796 {\"cmn\\t%0, #%n1\",
9799 \"cmn\\t%2, #%n3\"},
9800 {\"cmn\\t%0, #%n1\",
9803 static const char *const cmp2[NUM_OF_COND_CMP][2] =
9805 {\"cmp%D4\\t%2, %3\",
9806 \"cmp%D5\\t%0, %1\"},
9807 {\"cmp%D4\\t%2, %3\",
9808 \"cmn%D5\\t%0, #%n1\"},
9809 {\"cmn%D4\\t%2, #%n3\",
9810 \"cmp%D5\\t%0, %1\"},
9811 {\"cmn%D4\\t%2, #%n3\",
9812 \"cmn%D5\\t%0, #%n1\"}
9814 static const char *const ite[2] =
9819 static const int cmp_idx[9] = {CMP_CMP, CMP_CMP, CMP_CMN,
9820 CMP_CMP, CMN_CMP, CMP_CMP,
9821 CMN_CMP, CMP_CMN, CMN_CMN};
9823 comparison_dominates_p (GET_CODE (operands[5]), GET_CODE (operands[4]));
9825 output_asm_insn (cmp1[cmp_idx[which_alternative]][swap], operands);
9826 if (TARGET_THUMB2) {
9827 output_asm_insn (ite[swap], operands);
9829 output_asm_insn (cmp2[cmp_idx[which_alternative]][swap], operands);
9833 [(set_attr "conds" "set")
9834 (set_attr "arch" "t2,t2,t2,t2,t2,any,any,any,any")
9835 (set_attr "enabled_for_short_it" "yes,no,no,no,no,no,no,no,no")
9836 (set_attr_alternative "length"
9842 (if_then_else (eq_attr "is_thumb" "no")
9845 (if_then_else (eq_attr "is_thumb" "no")
9848 (if_then_else (eq_attr "is_thumb" "no")
9851 (if_then_else (eq_attr "is_thumb" "no")
9854 (set_attr "type" "multiple")]
9857 (define_insn_and_split "*ior_scc_scc"
9858 [(set (match_operand:SI 0 "s_register_operand" "=Ts,Ts")
9859 (ior:SI (match_operator:SI 3 "arm_comparison_operator"
9860 [(match_operand:SI 1 "s_register_operand" "l,r")
9861 (match_operand:SI 2 "arm_add_operand" "lPy,rIL")])
9862 (match_operator:SI 6 "arm_comparison_operator"
9863 [(match_operand:SI 4 "s_register_operand" "l,r")
9864 (match_operand:SI 5 "arm_add_operand" "lPy,rIL")])))
9865 (clobber (reg:CC CC_REGNUM))]
9867 && (arm_select_dominance_cc_mode (operands[3], operands[6], DOM_CC_X_OR_Y)
9870 "TARGET_32BIT && reload_completed"
9874 (match_op_dup 3 [(match_dup 1) (match_dup 2)])
9875 (match_op_dup 6 [(match_dup 4) (match_dup 5)]))
9877 (set (match_dup 0) (ne:SI (match_dup 7) (const_int 0)))]
9879 = gen_rtx_REG (arm_select_dominance_cc_mode (operands[3], operands[6],
9882 [(set_attr "conds" "clob")
9883 (set_attr "enabled_for_short_it" "yes,no")
9884 (set_attr "length" "16")
9885 (set_attr "type" "multiple")]
9888 ; If the above pattern is followed by a CMP insn, then the compare is
9889 ; redundant, since we can rework the conditional instruction that follows.
9890 (define_insn_and_split "*ior_scc_scc_cmp"
9891 [(set (match_operand 0 "dominant_cc_register" "")
9892 (compare (ior:SI (match_operator:SI 3 "arm_comparison_operator"
9893 [(match_operand:SI 1 "s_register_operand" "l,r")
9894 (match_operand:SI 2 "arm_add_operand" "lPy,rIL")])
9895 (match_operator:SI 6 "arm_comparison_operator"
9896 [(match_operand:SI 4 "s_register_operand" "l,r")
9897 (match_operand:SI 5 "arm_add_operand" "lPy,rIL")]))
9899 (set (match_operand:SI 7 "s_register_operand" "=Ts,Ts")
9900 (ior:SI (match_op_dup 3 [(match_dup 1) (match_dup 2)])
9901 (match_op_dup 6 [(match_dup 4) (match_dup 5)])))]
9904 "TARGET_32BIT && reload_completed"
9908 (match_op_dup 3 [(match_dup 1) (match_dup 2)])
9909 (match_op_dup 6 [(match_dup 4) (match_dup 5)]))
9911 (set (match_dup 7) (ne:SI (match_dup 0) (const_int 0)))]
9913 [(set_attr "conds" "set")
9914 (set_attr "enabled_for_short_it" "yes,no")
9915 (set_attr "length" "16")
9916 (set_attr "type" "multiple")]
9919 (define_insn_and_split "*and_scc_scc"
9920 [(set (match_operand:SI 0 "s_register_operand" "=Ts,Ts")
9921 (and:SI (match_operator:SI 3 "arm_comparison_operator"
9922 [(match_operand:SI 1 "s_register_operand" "l,r")
9923 (match_operand:SI 2 "arm_add_operand" "lPy,rIL")])
9924 (match_operator:SI 6 "arm_comparison_operator"
9925 [(match_operand:SI 4 "s_register_operand" "l,r")
9926 (match_operand:SI 5 "arm_add_operand" "lPy,rIL")])))
9927 (clobber (reg:CC CC_REGNUM))]
9929 && (arm_select_dominance_cc_mode (operands[3], operands[6], DOM_CC_X_AND_Y)
9932 "TARGET_32BIT && reload_completed
9933 && (arm_select_dominance_cc_mode (operands[3], operands[6], DOM_CC_X_AND_Y)
9938 (match_op_dup 3 [(match_dup 1) (match_dup 2)])
9939 (match_op_dup 6 [(match_dup 4) (match_dup 5)]))
9941 (set (match_dup 0) (ne:SI (match_dup 7) (const_int 0)))]
9943 = gen_rtx_REG (arm_select_dominance_cc_mode (operands[3], operands[6],
9946 [(set_attr "conds" "clob")
9947 (set_attr "enabled_for_short_it" "yes,no")
9948 (set_attr "length" "16")
9949 (set_attr "type" "multiple")]
9952 ; If the above pattern is followed by a CMP insn, then the compare is
9953 ; redundant, since we can rework the conditional instruction that follows.
9954 (define_insn_and_split "*and_scc_scc_cmp"
9955 [(set (match_operand 0 "dominant_cc_register" "")
9956 (compare (and:SI (match_operator:SI 3 "arm_comparison_operator"
9957 [(match_operand:SI 1 "s_register_operand" "l,r")
9958 (match_operand:SI 2 "arm_add_operand" "lPy,rIL")])
9959 (match_operator:SI 6 "arm_comparison_operator"
9960 [(match_operand:SI 4 "s_register_operand" "l,r")
9961 (match_operand:SI 5 "arm_add_operand" "lPy,rIL")]))
9963 (set (match_operand:SI 7 "s_register_operand" "=Ts,Ts")
9964 (and:SI (match_op_dup 3 [(match_dup 1) (match_dup 2)])
9965 (match_op_dup 6 [(match_dup 4) (match_dup 5)])))]
9968 "TARGET_32BIT && reload_completed"
9972 (match_op_dup 3 [(match_dup 1) (match_dup 2)])
9973 (match_op_dup 6 [(match_dup 4) (match_dup 5)]))
9975 (set (match_dup 7) (ne:SI (match_dup 0) (const_int 0)))]
9977 [(set_attr "conds" "set")
9978 (set_attr "enabled_for_short_it" "yes,no")
9979 (set_attr "length" "16")
9980 (set_attr "type" "multiple")]
9983 ;; If there is no dominance in the comparison, then we can still save an
9984 ;; instruction in the AND case, since we can know that the second compare
9985 ;; need only zero the value if false (if true, then the value is already
9987 (define_insn_and_split "*and_scc_scc_nodom"
9988 [(set (match_operand:SI 0 "s_register_operand" "=&Ts,&Ts,&Ts")
9989 (and:SI (match_operator:SI 3 "arm_comparison_operator"
9990 [(match_operand:SI 1 "s_register_operand" "r,r,0")
9991 (match_operand:SI 2 "arm_add_operand" "rIL,0,rIL")])
9992 (match_operator:SI 6 "arm_comparison_operator"
9993 [(match_operand:SI 4 "s_register_operand" "r,r,r")
9994 (match_operand:SI 5 "arm_add_operand" "rIL,rIL,rIL")])))
9995 (clobber (reg:CC CC_REGNUM))]
9997 && (arm_select_dominance_cc_mode (operands[3], operands[6], DOM_CC_X_AND_Y)
10000 "TARGET_32BIT && reload_completed"
10001 [(parallel [(set (match_dup 0)
10002 (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
10003 (clobber (reg:CC CC_REGNUM))])
10004 (set (match_dup 7) (match_op_dup 8 [(match_dup 4) (match_dup 5)]))
10006 (if_then_else:SI (match_op_dup 6 [(match_dup 7) (const_int 0)])
10009 "operands[7] = gen_rtx_REG (SELECT_CC_MODE (GET_CODE (operands[6]),
10010 operands[4], operands[5]),
10012 operands[8] = gen_rtx_COMPARE (GET_MODE (operands[7]), operands[4],
10014 [(set_attr "conds" "clob")
10015 (set_attr "length" "20")
10016 (set_attr "type" "multiple")]
10020 [(set (reg:CC_NOOV CC_REGNUM)
10021 (compare:CC_NOOV (ior:SI
10022 (and:SI (match_operand:SI 0 "s_register_operand" "")
10024 (match_operator:SI 1 "arm_comparison_operator"
10025 [(match_operand:SI 2 "s_register_operand" "")
10026 (match_operand:SI 3 "arm_add_operand" "")]))
10028 (clobber (match_operand:SI 4 "s_register_operand" ""))]
10030 [(set (match_dup 4)
10031 (ior:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
10033 (set (reg:CC_NOOV CC_REGNUM)
10034 (compare:CC_NOOV (and:SI (match_dup 4) (const_int 1))
10039 [(set (reg:CC_NOOV CC_REGNUM)
10040 (compare:CC_NOOV (ior:SI
10041 (match_operator:SI 1 "arm_comparison_operator"
10042 [(match_operand:SI 2 "s_register_operand" "")
10043 (match_operand:SI 3 "arm_add_operand" "")])
10044 (and:SI (match_operand:SI 0 "s_register_operand" "")
10047 (clobber (match_operand:SI 4 "s_register_operand" ""))]
10049 [(set (match_dup 4)
10050 (ior:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
10052 (set (reg:CC_NOOV CC_REGNUM)
10053 (compare:CC_NOOV (and:SI (match_dup 4) (const_int 1))
10056 ;; ??? The conditional patterns above need checking for Thumb-2 usefulness
10058 (define_insn_and_split "*negscc"
10059 [(set (match_operand:SI 0 "s_register_operand" "=r")
10060 (neg:SI (match_operator 3 "arm_comparison_operator"
10061 [(match_operand:SI 1 "s_register_operand" "r")
10062 (match_operand:SI 2 "arm_rhs_operand" "rI")])))
10063 (clobber (reg:CC CC_REGNUM))]
10066 "&& reload_completed"
10069 rtx cc_reg = gen_rtx_REG (CCmode, CC_REGNUM);
10071 if (GET_CODE (operands[3]) == LT && operands[2] == const0_rtx)
10073 /* Emit mov\\t%0, %1, asr #31 */
10074 emit_insn (gen_rtx_SET (operands[0],
10075 gen_rtx_ASHIFTRT (SImode,
10080 else if (GET_CODE (operands[3]) == NE)
10082 /* Emit subs\\t%0, %1, %2\;mvnne\\t%0, #0 */
10083 if (CONST_INT_P (operands[2]))
10084 emit_insn (gen_cmpsi2_addneg (operands[0], operands[1], operands[2],
10085 GEN_INT (- INTVAL (operands[2]))));
10087 emit_insn (gen_subsi3_compare (operands[0], operands[1], operands[2]));
10089 emit_insn (gen_rtx_COND_EXEC (VOIDmode,
10090 gen_rtx_NE (SImode,
10093 gen_rtx_SET (operands[0],
10099 /* Emit: cmp\\t%1, %2\;mov%D3\\t%0, #0\;mvn%d3\\t%0, #0 */
10100 emit_insn (gen_rtx_SET (cc_reg,
10101 gen_rtx_COMPARE (CCmode, operands[1], operands[2])));
10102 enum rtx_code rc = GET_CODE (operands[3]);
10104 rc = reverse_condition (rc);
10105 emit_insn (gen_rtx_COND_EXEC (VOIDmode,
10106 gen_rtx_fmt_ee (rc,
10110 gen_rtx_SET (operands[0], const0_rtx)));
10111 rc = GET_CODE (operands[3]);
10112 emit_insn (gen_rtx_COND_EXEC (VOIDmode,
10113 gen_rtx_fmt_ee (rc,
10117 gen_rtx_SET (operands[0],
10123 [(set_attr "conds" "clob")
10124 (set_attr "length" "12")
10125 (set_attr "type" "multiple")]
10128 (define_insn_and_split "movcond_addsi"
10129 [(set (match_operand:SI 0 "s_register_operand" "=r,l,r")
10131 (match_operator 5 "comparison_operator"
10132 [(plus:SI (match_operand:SI 3 "s_register_operand" "r,r,r")
10133 (match_operand:SI 4 "arm_add_operand" "rIL,rIL,rIL"))
10135 (match_operand:SI 1 "arm_rhs_operand" "rI,rPy,r")
10136 (match_operand:SI 2 "arm_rhs_operand" "rI,rPy,r")))
10137 (clobber (reg:CC CC_REGNUM))]
10140 "&& reload_completed"
10141 [(set (reg:CC_NOOV CC_REGNUM)
10143 (plus:SI (match_dup 3)
10146 (set (match_dup 0) (match_dup 1))
10147 (cond_exec (match_dup 6)
10148 (set (match_dup 0) (match_dup 2)))]
10151 machine_mode mode = SELECT_CC_MODE (GET_CODE (operands[5]),
10152 operands[3], operands[4]);
10153 enum rtx_code rc = GET_CODE (operands[5]);
10154 operands[6] = gen_rtx_REG (mode, CC_REGNUM);
10155 gcc_assert (!(mode == CCFPmode || mode == CCFPEmode));
10156 if (!REG_P (operands[2]) || REGNO (operands[2]) != REGNO (operands[0]))
10157 rc = reverse_condition (rc);
10159 std::swap (operands[1], operands[2]);
10161 operands[6] = gen_rtx_fmt_ee (rc, VOIDmode, operands[6], const0_rtx);
10164 [(set_attr "conds" "clob")
10165 (set_attr "enabled_for_short_it" "no,yes,yes")
10166 (set_attr "type" "multiple")]
10169 (define_insn "movcond"
10170 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
10172 (match_operator 5 "arm_comparison_operator"
10173 [(match_operand:SI 3 "s_register_operand" "r,r,r")
10174 (match_operand:SI 4 "arm_add_operand" "rIL,rIL,rIL")])
10175 (match_operand:SI 1 "arm_rhs_operand" "0,rI,?rI")
10176 (match_operand:SI 2 "arm_rhs_operand" "rI,0,rI")))
10177 (clobber (reg:CC CC_REGNUM))]
10180 if (GET_CODE (operands[5]) == LT
10181 && (operands[4] == const0_rtx))
10183 if (which_alternative != 1 && REG_P (operands[1]))
10185 if (operands[2] == const0_rtx)
10186 return \"and\\t%0, %1, %3, asr #31\";
10187 return \"ands\\t%0, %1, %3, asr #32\;movcc\\t%0, %2\";
10189 else if (which_alternative != 0 && REG_P (operands[2]))
10191 if (operands[1] == const0_rtx)
10192 return \"bic\\t%0, %2, %3, asr #31\";
10193 return \"bics\\t%0, %2, %3, asr #32\;movcs\\t%0, %1\";
10195 /* The only case that falls through to here is when both ops 1 & 2
10199 if (GET_CODE (operands[5]) == GE
10200 && (operands[4] == const0_rtx))
10202 if (which_alternative != 1 && REG_P (operands[1]))
10204 if (operands[2] == const0_rtx)
10205 return \"bic\\t%0, %1, %3, asr #31\";
10206 return \"bics\\t%0, %1, %3, asr #32\;movcs\\t%0, %2\";
10208 else if (which_alternative != 0 && REG_P (operands[2]))
10210 if (operands[1] == const0_rtx)
10211 return \"and\\t%0, %2, %3, asr #31\";
10212 return \"ands\\t%0, %2, %3, asr #32\;movcc\\t%0, %1\";
10214 /* The only case that falls through to here is when both ops 1 & 2
10217 if (CONST_INT_P (operands[4])
10218 && !const_ok_for_arm (INTVAL (operands[4])))
10219 output_asm_insn (\"cmn\\t%3, #%n4\", operands);
10221 output_asm_insn (\"cmp\\t%3, %4\", operands);
10222 if (which_alternative != 0)
10223 output_asm_insn (\"mov%d5\\t%0, %1\", operands);
10224 if (which_alternative != 1)
10225 output_asm_insn (\"mov%D5\\t%0, %2\", operands);
10228 [(set_attr "conds" "clob")
10229 (set_attr "length" "8,8,12")
10230 (set_attr "type" "multiple")]
10233 ;; ??? The patterns below need checking for Thumb-2 usefulness.
10235 (define_insn "*ifcompare_plus_move"
10236 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
10237 (if_then_else:SI (match_operator 6 "arm_comparison_operator"
10238 [(match_operand:SI 4 "s_register_operand" "r,r")
10239 (match_operand:SI 5 "arm_add_operand" "rIL,rIL")])
10241 (match_operand:SI 2 "s_register_operand" "r,r")
10242 (match_operand:SI 3 "arm_add_operand" "rIL,rIL"))
10243 (match_operand:SI 1 "arm_rhs_operand" "0,?rI")))
10244 (clobber (reg:CC CC_REGNUM))]
10247 [(set_attr "conds" "clob")
10248 (set_attr "length" "8,12")
10249 (set_attr "type" "multiple")]
10252 (define_insn "*if_plus_move"
10253 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r,r")
10255 (match_operator 4 "arm_comparison_operator"
10256 [(match_operand 5 "cc_register" "") (const_int 0)])
10258 (match_operand:SI 2 "s_register_operand" "r,r,r,r")
10259 (match_operand:SI 3 "arm_add_operand" "rI,L,rI,L"))
10260 (match_operand:SI 1 "arm_rhs_operand" "0,0,?rI,?rI")))]
10263 add%d4\\t%0, %2, %3
10264 sub%d4\\t%0, %2, #%n3
10265 add%d4\\t%0, %2, %3\;mov%D4\\t%0, %1
10266 sub%d4\\t%0, %2, #%n3\;mov%D4\\t%0, %1"
10267 [(set_attr "conds" "use")
10268 (set_attr "length" "4,4,8,8")
10269 (set_attr_alternative "type"
10270 [(if_then_else (match_operand 3 "const_int_operand" "")
10271 (const_string "alu_imm" )
10272 (const_string "alu_sreg"))
10273 (const_string "alu_imm")
10274 (const_string "multiple")
10275 (const_string "multiple")])]
10278 (define_insn "*ifcompare_move_plus"
10279 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
10280 (if_then_else:SI (match_operator 6 "arm_comparison_operator"
10281 [(match_operand:SI 4 "s_register_operand" "r,r")
10282 (match_operand:SI 5 "arm_add_operand" "rIL,rIL")])
10283 (match_operand:SI 1 "arm_rhs_operand" "0,?rI")
10285 (match_operand:SI 2 "s_register_operand" "r,r")
10286 (match_operand:SI 3 "arm_add_operand" "rIL,rIL"))))
10287 (clobber (reg:CC CC_REGNUM))]
10290 [(set_attr "conds" "clob")
10291 (set_attr "length" "8,12")
10292 (set_attr "type" "multiple")]
10295 (define_insn "*if_move_plus"
10296 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r,r")
10298 (match_operator 4 "arm_comparison_operator"
10299 [(match_operand 5 "cc_register" "") (const_int 0)])
10300 (match_operand:SI 1 "arm_rhs_operand" "0,0,?rI,?rI")
10302 (match_operand:SI 2 "s_register_operand" "r,r,r,r")
10303 (match_operand:SI 3 "arm_add_operand" "rI,L,rI,L"))))]
10306 add%D4\\t%0, %2, %3
10307 sub%D4\\t%0, %2, #%n3
10308 add%D4\\t%0, %2, %3\;mov%d4\\t%0, %1
10309 sub%D4\\t%0, %2, #%n3\;mov%d4\\t%0, %1"
10310 [(set_attr "conds" "use")
10311 (set_attr "length" "4,4,8,8")
10312 (set_attr_alternative "type"
10313 [(if_then_else (match_operand 3 "const_int_operand" "")
10314 (const_string "alu_imm" )
10315 (const_string "alu_sreg"))
10316 (const_string "alu_imm")
10317 (const_string "multiple")
10318 (const_string "multiple")])]
10321 (define_insn "*ifcompare_arith_arith"
10322 [(set (match_operand:SI 0 "s_register_operand" "=r")
10323 (if_then_else:SI (match_operator 9 "arm_comparison_operator"
10324 [(match_operand:SI 5 "s_register_operand" "r")
10325 (match_operand:SI 6 "arm_add_operand" "rIL")])
10326 (match_operator:SI 8 "shiftable_operator"
10327 [(match_operand:SI 1 "s_register_operand" "r")
10328 (match_operand:SI 2 "arm_rhs_operand" "rI")])
10329 (match_operator:SI 7 "shiftable_operator"
10330 [(match_operand:SI 3 "s_register_operand" "r")
10331 (match_operand:SI 4 "arm_rhs_operand" "rI")])))
10332 (clobber (reg:CC CC_REGNUM))]
10335 [(set_attr "conds" "clob")
10336 (set_attr "length" "12")
10337 (set_attr "type" "multiple")]
10340 (define_insn "*if_arith_arith"
10341 [(set (match_operand:SI 0 "s_register_operand" "=r")
10342 (if_then_else:SI (match_operator 5 "arm_comparison_operator"
10343 [(match_operand 8 "cc_register" "") (const_int 0)])
10344 (match_operator:SI 6 "shiftable_operator"
10345 [(match_operand:SI 1 "s_register_operand" "r")
10346 (match_operand:SI 2 "arm_rhs_operand" "rI")])
10347 (match_operator:SI 7 "shiftable_operator"
10348 [(match_operand:SI 3 "s_register_operand" "r")
10349 (match_operand:SI 4 "arm_rhs_operand" "rI")])))]
10351 "%I6%d5\\t%0, %1, %2\;%I7%D5\\t%0, %3, %4"
10352 [(set_attr "conds" "use")
10353 (set_attr "length" "8")
10354 (set_attr "type" "multiple")]
10357 (define_insn "*ifcompare_arith_move"
10358 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
10359 (if_then_else:SI (match_operator 6 "arm_comparison_operator"
10360 [(match_operand:SI 2 "s_register_operand" "r,r")
10361 (match_operand:SI 3 "arm_add_operand" "rIL,rIL")])
10362 (match_operator:SI 7 "shiftable_operator"
10363 [(match_operand:SI 4 "s_register_operand" "r,r")
10364 (match_operand:SI 5 "arm_rhs_operand" "rI,rI")])
10365 (match_operand:SI 1 "arm_rhs_operand" "0,?rI")))
10366 (clobber (reg:CC CC_REGNUM))]
10369 /* If we have an operation where (op x 0) is the identity operation and
10370 the conditional operator is LT or GE and we are comparing against zero and
10371 everything is in registers then we can do this in two instructions. */
10372 if (operands[3] == const0_rtx
10373 && GET_CODE (operands[7]) != AND
10374 && REG_P (operands[5])
10375 && REG_P (operands[1])
10376 && REGNO (operands[1]) == REGNO (operands[4])
10377 && REGNO (operands[4]) != REGNO (operands[0]))
10379 if (GET_CODE (operands[6]) == LT)
10380 return \"and\\t%0, %5, %2, asr #31\;%I7\\t%0, %4, %0\";
10381 else if (GET_CODE (operands[6]) == GE)
10382 return \"bic\\t%0, %5, %2, asr #31\;%I7\\t%0, %4, %0\";
10384 if (CONST_INT_P (operands[3])
10385 && !const_ok_for_arm (INTVAL (operands[3])))
10386 output_asm_insn (\"cmn\\t%2, #%n3\", operands);
10388 output_asm_insn (\"cmp\\t%2, %3\", operands);
10389 output_asm_insn (\"%I7%d6\\t%0, %4, %5\", operands);
10390 if (which_alternative != 0)
10391 return \"mov%D6\\t%0, %1\";
10394 [(set_attr "conds" "clob")
10395 (set_attr "length" "8,12")
10396 (set_attr "type" "multiple")]
10399 (define_insn "*if_arith_move"
10400 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
10401 (if_then_else:SI (match_operator 4 "arm_comparison_operator"
10402 [(match_operand 6 "cc_register" "") (const_int 0)])
10403 (match_operator:SI 5 "shiftable_operator"
10404 [(match_operand:SI 2 "s_register_operand" "r,r")
10405 (match_operand:SI 3 "arm_rhs_operand" "rI,rI")])
10406 (match_operand:SI 1 "arm_rhs_operand" "0,?rI")))]
10409 %I5%d4\\t%0, %2, %3
10410 %I5%d4\\t%0, %2, %3\;mov%D4\\t%0, %1"
10411 [(set_attr "conds" "use")
10412 (set_attr "length" "4,8")
10413 (set_attr_alternative "type"
10414 [(if_then_else (match_operand 3 "const_int_operand" "")
10415 (const_string "alu_shift_imm" )
10416 (const_string "alu_shift_reg"))
10417 (const_string "multiple")])]
10420 (define_insn "*ifcompare_move_arith"
10421 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
10422 (if_then_else:SI (match_operator 6 "arm_comparison_operator"
10423 [(match_operand:SI 4 "s_register_operand" "r,r")
10424 (match_operand:SI 5 "arm_add_operand" "rIL,rIL")])
10425 (match_operand:SI 1 "arm_rhs_operand" "0,?rI")
10426 (match_operator:SI 7 "shiftable_operator"
10427 [(match_operand:SI 2 "s_register_operand" "r,r")
10428 (match_operand:SI 3 "arm_rhs_operand" "rI,rI")])))
10429 (clobber (reg:CC CC_REGNUM))]
10432 /* If we have an operation where (op x 0) is the identity operation and
10433 the conditional operator is LT or GE and we are comparing against zero and
10434 everything is in registers then we can do this in two instructions */
10435 if (operands[5] == const0_rtx
10436 && GET_CODE (operands[7]) != AND
10437 && REG_P (operands[3])
10438 && REG_P (operands[1])
10439 && REGNO (operands[1]) == REGNO (operands[2])
10440 && REGNO (operands[2]) != REGNO (operands[0]))
10442 if (GET_CODE (operands[6]) == GE)
10443 return \"and\\t%0, %3, %4, asr #31\;%I7\\t%0, %2, %0\";
10444 else if (GET_CODE (operands[6]) == LT)
10445 return \"bic\\t%0, %3, %4, asr #31\;%I7\\t%0, %2, %0\";
10448 if (CONST_INT_P (operands[5])
10449 && !const_ok_for_arm (INTVAL (operands[5])))
10450 output_asm_insn (\"cmn\\t%4, #%n5\", operands);
10452 output_asm_insn (\"cmp\\t%4, %5\", operands);
10454 if (which_alternative != 0)
10455 output_asm_insn (\"mov%d6\\t%0, %1\", operands);
10456 return \"%I7%D6\\t%0, %2, %3\";
10458 [(set_attr "conds" "clob")
10459 (set_attr "length" "8,12")
10460 (set_attr "type" "multiple")]
10463 (define_insn "*if_move_arith"
10464 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
10466 (match_operator 4 "arm_comparison_operator"
10467 [(match_operand 6 "cc_register" "") (const_int 0)])
10468 (match_operand:SI 1 "arm_rhs_operand" "0,?rI")
10469 (match_operator:SI 5 "shiftable_operator"
10470 [(match_operand:SI 2 "s_register_operand" "r,r")
10471 (match_operand:SI 3 "arm_rhs_operand" "rI,rI")])))]
10474 %I5%D4\\t%0, %2, %3
10475 %I5%D4\\t%0, %2, %3\;mov%d4\\t%0, %1"
10476 [(set_attr "conds" "use")
10477 (set_attr "length" "4,8")
10478 (set_attr_alternative "type"
10479 [(if_then_else (match_operand 3 "const_int_operand" "")
10480 (const_string "alu_shift_imm" )
10481 (const_string "alu_shift_reg"))
10482 (const_string "multiple")])]
10485 (define_insn "*ifcompare_move_not"
10486 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
10488 (match_operator 5 "arm_comparison_operator"
10489 [(match_operand:SI 3 "s_register_operand" "r,r")
10490 (match_operand:SI 4 "arm_add_operand" "rIL,rIL")])
10491 (match_operand:SI 1 "arm_not_operand" "0,?rIK")
10493 (match_operand:SI 2 "s_register_operand" "r,r"))))
10494 (clobber (reg:CC CC_REGNUM))]
10497 [(set_attr "conds" "clob")
10498 (set_attr "length" "8,12")
10499 (set_attr "type" "multiple")]
10502 (define_insn "*if_move_not"
10503 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
10505 (match_operator 4 "arm_comparison_operator"
10506 [(match_operand 3 "cc_register" "") (const_int 0)])
10507 (match_operand:SI 1 "arm_not_operand" "0,?rI,K")
10508 (not:SI (match_operand:SI 2 "s_register_operand" "r,r,r"))))]
10512 mov%d4\\t%0, %1\;mvn%D4\\t%0, %2
10513 mvn%d4\\t%0, #%B1\;mvn%D4\\t%0, %2"
10514 [(set_attr "conds" "use")
10515 (set_attr "type" "mvn_reg")
10516 (set_attr "length" "4,8,8")
10517 (set_attr "type" "mvn_reg,multiple,multiple")]
10520 (define_insn "*ifcompare_not_move"
10521 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
10523 (match_operator 5 "arm_comparison_operator"
10524 [(match_operand:SI 3 "s_register_operand" "r,r")
10525 (match_operand:SI 4 "arm_add_operand" "rIL,rIL")])
10527 (match_operand:SI 2 "s_register_operand" "r,r"))
10528 (match_operand:SI 1 "arm_not_operand" "0,?rIK")))
10529 (clobber (reg:CC CC_REGNUM))]
10532 [(set_attr "conds" "clob")
10533 (set_attr "length" "8,12")
10534 (set_attr "type" "multiple")]
10537 (define_insn "*if_not_move"
10538 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
10540 (match_operator 4 "arm_comparison_operator"
10541 [(match_operand 3 "cc_register" "") (const_int 0)])
10542 (not:SI (match_operand:SI 2 "s_register_operand" "r,r,r"))
10543 (match_operand:SI 1 "arm_not_operand" "0,?rI,K")))]
10547 mov%D4\\t%0, %1\;mvn%d4\\t%0, %2
10548 mvn%D4\\t%0, #%B1\;mvn%d4\\t%0, %2"
10549 [(set_attr "conds" "use")
10550 (set_attr "type" "mvn_reg,multiple,multiple")
10551 (set_attr "length" "4,8,8")]
10554 (define_insn "*ifcompare_shift_move"
10555 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
10557 (match_operator 6 "arm_comparison_operator"
10558 [(match_operand:SI 4 "s_register_operand" "r,r")
10559 (match_operand:SI 5 "arm_add_operand" "rIL,rIL")])
10560 (match_operator:SI 7 "shift_operator"
10561 [(match_operand:SI 2 "s_register_operand" "r,r")
10562 (match_operand:SI 3 "arm_rhs_operand" "rM,rM")])
10563 (match_operand:SI 1 "arm_not_operand" "0,?rIK")))
10564 (clobber (reg:CC CC_REGNUM))]
10567 [(set_attr "conds" "clob")
10568 (set_attr "length" "8,12")
10569 (set_attr "type" "multiple")]
10572 (define_insn "*if_shift_move"
10573 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
10575 (match_operator 5 "arm_comparison_operator"
10576 [(match_operand 6 "cc_register" "") (const_int 0)])
10577 (match_operator:SI 4 "shift_operator"
10578 [(match_operand:SI 2 "s_register_operand" "r,r,r")
10579 (match_operand:SI 3 "arm_rhs_operand" "rM,rM,rM")])
10580 (match_operand:SI 1 "arm_not_operand" "0,?rI,K")))]
10584 mov%D5\\t%0, %1\;mov%d5\\t%0, %2%S4
10585 mvn%D5\\t%0, #%B1\;mov%d5\\t%0, %2%S4"
10586 [(set_attr "conds" "use")
10587 (set_attr "shift" "2")
10588 (set_attr "length" "4,8,8")
10589 (set_attr_alternative "type"
10590 [(if_then_else (match_operand 3 "const_int_operand" "")
10591 (const_string "mov_shift" )
10592 (const_string "mov_shift_reg"))
10593 (const_string "multiple")
10594 (const_string "multiple")])]
10597 (define_insn "*ifcompare_move_shift"
10598 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
10600 (match_operator 6 "arm_comparison_operator"
10601 [(match_operand:SI 4 "s_register_operand" "r,r")
10602 (match_operand:SI 5 "arm_add_operand" "rIL,rIL")])
10603 (match_operand:SI 1 "arm_not_operand" "0,?rIK")
10604 (match_operator:SI 7 "shift_operator"
10605 [(match_operand:SI 2 "s_register_operand" "r,r")
10606 (match_operand:SI 3 "arm_rhs_operand" "rM,rM")])))
10607 (clobber (reg:CC CC_REGNUM))]
10610 [(set_attr "conds" "clob")
10611 (set_attr "length" "8,12")
10612 (set_attr "type" "multiple")]
10615 (define_insn "*if_move_shift"
10616 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
10618 (match_operator 5 "arm_comparison_operator"
10619 [(match_operand 6 "cc_register" "") (const_int 0)])
10620 (match_operand:SI 1 "arm_not_operand" "0,?rI,K")
10621 (match_operator:SI 4 "shift_operator"
10622 [(match_operand:SI 2 "s_register_operand" "r,r,r")
10623 (match_operand:SI 3 "arm_rhs_operand" "rM,rM,rM")])))]
10627 mov%d5\\t%0, %1\;mov%D5\\t%0, %2%S4
10628 mvn%d5\\t%0, #%B1\;mov%D5\\t%0, %2%S4"
10629 [(set_attr "conds" "use")
10630 (set_attr "shift" "2")
10631 (set_attr "length" "4,8,8")
10632 (set_attr_alternative "type"
10633 [(if_then_else (match_operand 3 "const_int_operand" "")
10634 (const_string "mov_shift" )
10635 (const_string "mov_shift_reg"))
10636 (const_string "multiple")
10637 (const_string "multiple")])]
10640 (define_insn "*ifcompare_shift_shift"
10641 [(set (match_operand:SI 0 "s_register_operand" "=r")
10643 (match_operator 7 "arm_comparison_operator"
10644 [(match_operand:SI 5 "s_register_operand" "r")
10645 (match_operand:SI 6 "arm_add_operand" "rIL")])
10646 (match_operator:SI 8 "shift_operator"
10647 [(match_operand:SI 1 "s_register_operand" "r")
10648 (match_operand:SI 2 "arm_rhs_operand" "rM")])
10649 (match_operator:SI 9 "shift_operator"
10650 [(match_operand:SI 3 "s_register_operand" "r")
10651 (match_operand:SI 4 "arm_rhs_operand" "rM")])))
10652 (clobber (reg:CC CC_REGNUM))]
10655 [(set_attr "conds" "clob")
10656 (set_attr "length" "12")
10657 (set_attr "type" "multiple")]
10660 (define_insn "*if_shift_shift"
10661 [(set (match_operand:SI 0 "s_register_operand" "=r")
10663 (match_operator 5 "arm_comparison_operator"
10664 [(match_operand 8 "cc_register" "") (const_int 0)])
10665 (match_operator:SI 6 "shift_operator"
10666 [(match_operand:SI 1 "s_register_operand" "r")
10667 (match_operand:SI 2 "arm_rhs_operand" "rM")])
10668 (match_operator:SI 7 "shift_operator"
10669 [(match_operand:SI 3 "s_register_operand" "r")
10670 (match_operand:SI 4 "arm_rhs_operand" "rM")])))]
10672 "mov%d5\\t%0, %1%S6\;mov%D5\\t%0, %3%S7"
10673 [(set_attr "conds" "use")
10674 (set_attr "shift" "1")
10675 (set_attr "length" "8")
10676 (set (attr "type") (if_then_else
10677 (and (match_operand 2 "const_int_operand" "")
10678 (match_operand 4 "const_int_operand" ""))
10679 (const_string "mov_shift")
10680 (const_string "mov_shift_reg")))]
10683 (define_insn "*ifcompare_not_arith"
10684 [(set (match_operand:SI 0 "s_register_operand" "=r")
10686 (match_operator 6 "arm_comparison_operator"
10687 [(match_operand:SI 4 "s_register_operand" "r")
10688 (match_operand:SI 5 "arm_add_operand" "rIL")])
10689 (not:SI (match_operand:SI 1 "s_register_operand" "r"))
10690 (match_operator:SI 7 "shiftable_operator"
10691 [(match_operand:SI 2 "s_register_operand" "r")
10692 (match_operand:SI 3 "arm_rhs_operand" "rI")])))
10693 (clobber (reg:CC CC_REGNUM))]
10696 [(set_attr "conds" "clob")
10697 (set_attr "length" "12")
10698 (set_attr "type" "multiple")]
10701 (define_insn "*if_not_arith"
10702 [(set (match_operand:SI 0 "s_register_operand" "=r")
10704 (match_operator 5 "arm_comparison_operator"
10705 [(match_operand 4 "cc_register" "") (const_int 0)])
10706 (not:SI (match_operand:SI 1 "s_register_operand" "r"))
10707 (match_operator:SI 6 "shiftable_operator"
10708 [(match_operand:SI 2 "s_register_operand" "r")
10709 (match_operand:SI 3 "arm_rhs_operand" "rI")])))]
10711 "mvn%d5\\t%0, %1\;%I6%D5\\t%0, %2, %3"
10712 [(set_attr "conds" "use")
10713 (set_attr "type" "mvn_reg")
10714 (set_attr "length" "8")]
10717 (define_insn "*ifcompare_arith_not"
10718 [(set (match_operand:SI 0 "s_register_operand" "=r")
10720 (match_operator 6 "arm_comparison_operator"
10721 [(match_operand:SI 4 "s_register_operand" "r")
10722 (match_operand:SI 5 "arm_add_operand" "rIL")])
10723 (match_operator:SI 7 "shiftable_operator"
10724 [(match_operand:SI 2 "s_register_operand" "r")
10725 (match_operand:SI 3 "arm_rhs_operand" "rI")])
10726 (not:SI (match_operand:SI 1 "s_register_operand" "r"))))
10727 (clobber (reg:CC CC_REGNUM))]
10730 [(set_attr "conds" "clob")
10731 (set_attr "length" "12")
10732 (set_attr "type" "multiple")]
10735 (define_insn "*if_arith_not"
10736 [(set (match_operand:SI 0 "s_register_operand" "=r")
10738 (match_operator 5 "arm_comparison_operator"
10739 [(match_operand 4 "cc_register" "") (const_int 0)])
10740 (match_operator:SI 6 "shiftable_operator"
10741 [(match_operand:SI 2 "s_register_operand" "r")
10742 (match_operand:SI 3 "arm_rhs_operand" "rI")])
10743 (not:SI (match_operand:SI 1 "s_register_operand" "r"))))]
10745 "mvn%D5\\t%0, %1\;%I6%d5\\t%0, %2, %3"
10746 [(set_attr "conds" "use")
10747 (set_attr "type" "multiple")
10748 (set_attr "length" "8")]
10751 (define_insn "*ifcompare_neg_move"
10752 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
10754 (match_operator 5 "arm_comparison_operator"
10755 [(match_operand:SI 3 "s_register_operand" "r,r")
10756 (match_operand:SI 4 "arm_add_operand" "rIL,rIL")])
10757 (neg:SI (match_operand:SI 2 "s_register_operand" "r,r"))
10758 (match_operand:SI 1 "arm_not_operand" "0,?rIK")))
10759 (clobber (reg:CC CC_REGNUM))]
10762 [(set_attr "conds" "clob")
10763 (set_attr "length" "8,12")
10764 (set_attr "type" "multiple")]
10767 (define_insn_and_split "*if_neg_move"
10768 [(set (match_operand:SI 0 "s_register_operand" "=l,r")
10770 (match_operator 4 "arm_comparison_operator"
10771 [(match_operand 3 "cc_register" "") (const_int 0)])
10772 (neg:SI (match_operand:SI 2 "s_register_operand" "l,r"))
10773 (match_operand:SI 1 "s_register_operand" "0,0")))]
10776 "&& reload_completed"
10777 [(cond_exec (match_op_dup 4 [(match_dup 3) (const_int 0)])
10778 (set (match_dup 0) (neg:SI (match_dup 2))))]
10780 [(set_attr "conds" "use")
10781 (set_attr "length" "4")
10782 (set_attr "arch" "t2,32")
10783 (set_attr "enabled_for_short_it" "yes,no")
10784 (set_attr "type" "logic_shift_imm")]
10787 (define_insn "*ifcompare_move_neg"
10788 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
10790 (match_operator 5 "arm_comparison_operator"
10791 [(match_operand:SI 3 "s_register_operand" "r,r")
10792 (match_operand:SI 4 "arm_add_operand" "rIL,rIL")])
10793 (match_operand:SI 1 "arm_not_operand" "0,?rIK")
10794 (neg:SI (match_operand:SI 2 "s_register_operand" "r,r"))))
10795 (clobber (reg:CC CC_REGNUM))]
10798 [(set_attr "conds" "clob")
10799 (set_attr "length" "8,12")
10800 (set_attr "type" "multiple")]
10803 (define_insn_and_split "*if_move_neg"
10804 [(set (match_operand:SI 0 "s_register_operand" "=l,r")
10806 (match_operator 4 "arm_comparison_operator"
10807 [(match_operand 3 "cc_register" "") (const_int 0)])
10808 (match_operand:SI 1 "s_register_operand" "0,0")
10809 (neg:SI (match_operand:SI 2 "s_register_operand" "l,r"))))]
10812 "&& reload_completed"
10813 [(cond_exec (match_dup 5)
10814 (set (match_dup 0) (neg:SI (match_dup 2))))]
10816 machine_mode mode = GET_MODE (operands[3]);
10817 rtx_code rc = GET_CODE (operands[4]);
10819 if (mode == CCFPmode || mode == CCFPEmode)
10820 rc = reverse_condition_maybe_unordered (rc);
10822 rc = reverse_condition (rc);
10824 operands[5] = gen_rtx_fmt_ee (rc, VOIDmode, operands[3], const0_rtx);
10826 [(set_attr "conds" "use")
10827 (set_attr "length" "4")
10828 (set_attr "arch" "t2,32")
10829 (set_attr "enabled_for_short_it" "yes,no")
10830 (set_attr "type" "logic_shift_imm")]
10833 (define_insn "*arith_adjacentmem"
10834 [(set (match_operand:SI 0 "s_register_operand" "=r")
10835 (match_operator:SI 1 "shiftable_operator"
10836 [(match_operand:SI 2 "memory_operand" "m")
10837 (match_operand:SI 3 "memory_operand" "m")]))
10838 (clobber (match_scratch:SI 4 "=r"))]
10839 "TARGET_ARM && adjacent_mem_locations (operands[2], operands[3])"
10845 HOST_WIDE_INT val1 = 0, val2 = 0;
10847 if (REGNO (operands[0]) > REGNO (operands[4]))
10849 ldm[1] = operands[4];
10850 ldm[2] = operands[0];
10854 ldm[1] = operands[0];
10855 ldm[2] = operands[4];
10858 base_reg = XEXP (operands[2], 0);
10860 if (!REG_P (base_reg))
10862 val1 = INTVAL (XEXP (base_reg, 1));
10863 base_reg = XEXP (base_reg, 0);
10866 if (!REG_P (XEXP (operands[3], 0)))
10867 val2 = INTVAL (XEXP (XEXP (operands[3], 0), 1));
10869 arith[0] = operands[0];
10870 arith[3] = operands[1];
10884 if (val1 !=0 && val2 != 0)
10888 if (val1 == 4 || val2 == 4)
10889 /* Other val must be 8, since we know they are adjacent and neither
10891 output_asm_insn (\"ldmib%?\\t%0, {%1, %2}\", ldm);
10892 else if (const_ok_for_arm (val1) || const_ok_for_arm (-val1))
10894 ldm[0] = ops[0] = operands[4];
10896 ops[2] = GEN_INT (val1);
10897 output_add_immediate (ops);
10899 output_asm_insn (\"ldmia%?\\t%0, {%1, %2}\", ldm);
10901 output_asm_insn (\"ldmda%?\\t%0, {%1, %2}\", ldm);
10905 /* Offset is out of range for a single add, so use two ldr. */
10908 ops[2] = GEN_INT (val1);
10909 output_asm_insn (\"ldr%?\\t%0, [%1, %2]\", ops);
10911 ops[2] = GEN_INT (val2);
10912 output_asm_insn (\"ldr%?\\t%0, [%1, %2]\", ops);
10915 else if (val1 != 0)
10918 output_asm_insn (\"ldmda%?\\t%0, {%1, %2}\", ldm);
10920 output_asm_insn (\"ldmia%?\\t%0, {%1, %2}\", ldm);
10925 output_asm_insn (\"ldmia%?\\t%0, {%1, %2}\", ldm);
10927 output_asm_insn (\"ldmda%?\\t%0, {%1, %2}\", ldm);
10929 output_asm_insn (\"%I3%?\\t%0, %1, %2\", arith);
10932 [(set_attr "length" "12")
10933 (set_attr "predicable" "yes")
10934 (set_attr "type" "load_4")]
10937 ; This pattern is never tried by combine, so do it as a peephole
10940 [(set (match_operand:SI 0 "arm_general_register_operand" "")
10941 (match_operand:SI 1 "arm_general_register_operand" ""))
10942 (set (reg:CC CC_REGNUM)
10943 (compare:CC (match_dup 1) (const_int 0)))]
10945 [(parallel [(set (reg:CC CC_REGNUM) (compare:CC (match_dup 1) (const_int 0)))
10946 (set (match_dup 0) (match_dup 1))])]
10951 [(set (match_operand:SI 0 "s_register_operand" "")
10952 (and:SI (ge:SI (match_operand:SI 1 "s_register_operand" "")
10954 (neg:SI (match_operator:SI 2 "arm_comparison_operator"
10955 [(match_operand:SI 3 "s_register_operand" "")
10956 (match_operand:SI 4 "arm_rhs_operand" "")]))))
10957 (clobber (match_operand:SI 5 "s_register_operand" ""))]
10959 [(set (match_dup 5) (not:SI (ashiftrt:SI (match_dup 1) (const_int 31))))
10960 (set (match_dup 0) (and:SI (match_op_dup 2 [(match_dup 3) (match_dup 4)])
10965 ;; This split can be used because CC_Z mode implies that the following
10966 ;; branch will be an equality, or an unsigned inequality, so the sign
10967 ;; extension is not needed.
10970 [(set (reg:CC_Z CC_REGNUM)
10972 (ashift:SI (subreg:SI (match_operand:QI 0 "memory_operand" "") 0)
10974 (match_operand 1 "const_int_operand" "")))
10975 (clobber (match_scratch:SI 2 ""))]
10977 && ((UINTVAL (operands[1]))
10978 == ((UINTVAL (operands[1])) >> 24) << 24)"
10979 [(set (match_dup 2) (zero_extend:SI (match_dup 0)))
10980 (set (reg:CC CC_REGNUM) (compare:CC (match_dup 2) (match_dup 1)))]
10982 operands[1] = GEN_INT (((unsigned long) INTVAL (operands[1])) >> 24);
10985 ;; ??? Check the patterns above for Thumb-2 usefulness
10987 (define_expand "prologue"
10988 [(clobber (const_int 0))]
10991 arm_expand_prologue ();
10993 thumb1_expand_prologue ();
10998 (define_expand "epilogue"
10999 [(clobber (const_int 0))]
11002 if (crtl->calls_eh_return)
11003 emit_insn (gen_force_register_use (gen_rtx_REG (Pmode, 2)));
11006 thumb1_expand_epilogue ();
11007 emit_jump_insn (gen_rtx_UNSPEC_VOLATILE (VOIDmode,
11008 gen_rtvec (1, ret_rtx), VUNSPEC_EPILOGUE));
11010 else if (HAVE_return)
11012 /* HAVE_return is testing for USE_RETURN_INSN (FALSE). Hence,
11013 no need for explicit testing again. */
11014 emit_jump_insn (gen_return ());
11016 else if (TARGET_32BIT)
11018 arm_expand_epilogue (true);
11024 ;; Note - although unspec_volatile's USE all hard registers,
11025 ;; USEs are ignored after relaod has completed. Thus we need
11026 ;; to add an unspec of the link register to ensure that flow
11027 ;; does not think that it is unused by the sibcall branch that
11028 ;; will replace the standard function epilogue.
11029 (define_expand "sibcall_epilogue"
11030 [(parallel [(unspec:SI [(reg:SI LR_REGNUM)] UNSPEC_REGISTER_USE)
11031 (unspec_volatile [(return)] VUNSPEC_EPILOGUE)])]
11034 arm_expand_epilogue (false);
11039 (define_expand "eh_epilogue"
11040 [(use (match_operand:SI 0 "register_operand" ""))
11041 (use (match_operand:SI 1 "register_operand" ""))
11042 (use (match_operand:SI 2 "register_operand" ""))]
11046 cfun->machine->eh_epilogue_sp_ofs = operands[1];
11047 if (!REG_P (operands[2]) || REGNO (operands[2]) != 2)
11049 rtx ra = gen_rtx_REG (Pmode, 2);
11051 emit_move_insn (ra, operands[2]);
11054 /* This is a hack -- we may have crystalized the function type too
11056 cfun->machine->func_type = 0;
11060 ;; This split is only used during output to reduce the number of patterns
11061 ;; that need assembler instructions adding to them. We allowed the setting
11062 ;; of the conditions to be implicit during rtl generation so that
11063 ;; the conditional compare patterns would work. However this conflicts to
11064 ;; some extent with the conditional data operations, so we have to split them
11067 ;; ??? Need to audit these splitters for Thumb-2. Why isn't normal
11068 ;; conditional execution sufficient?
11071 [(set (match_operand:SI 0 "s_register_operand" "")
11072 (if_then_else:SI (match_operator 1 "arm_comparison_operator"
11073 [(match_operand 2 "" "") (match_operand 3 "" "")])
11075 (match_operand 4 "" "")))
11076 (clobber (reg:CC CC_REGNUM))]
11077 "TARGET_ARM && reload_completed"
11078 [(set (match_dup 5) (match_dup 6))
11079 (cond_exec (match_dup 7)
11080 (set (match_dup 0) (match_dup 4)))]
11083 machine_mode mode = SELECT_CC_MODE (GET_CODE (operands[1]),
11084 operands[2], operands[3]);
11085 enum rtx_code rc = GET_CODE (operands[1]);
11087 operands[5] = gen_rtx_REG (mode, CC_REGNUM);
11088 operands[6] = gen_rtx_COMPARE (mode, operands[2], operands[3]);
11089 if (mode == CCFPmode || mode == CCFPEmode)
11090 rc = reverse_condition_maybe_unordered (rc);
11092 rc = reverse_condition (rc);
11094 operands[7] = gen_rtx_fmt_ee (rc, VOIDmode, operands[5], const0_rtx);
11099 [(set (match_operand:SI 0 "s_register_operand" "")
11100 (if_then_else:SI (match_operator 1 "arm_comparison_operator"
11101 [(match_operand 2 "" "") (match_operand 3 "" "")])
11102 (match_operand 4 "" "")
11104 (clobber (reg:CC CC_REGNUM))]
11105 "TARGET_ARM && reload_completed"
11106 [(set (match_dup 5) (match_dup 6))
11107 (cond_exec (match_op_dup 1 [(match_dup 5) (const_int 0)])
11108 (set (match_dup 0) (match_dup 4)))]
11111 machine_mode mode = SELECT_CC_MODE (GET_CODE (operands[1]),
11112 operands[2], operands[3]);
11114 operands[5] = gen_rtx_REG (mode, CC_REGNUM);
11115 operands[6] = gen_rtx_COMPARE (mode, operands[2], operands[3]);
11120 [(set (match_operand:SI 0 "s_register_operand" "")
11121 (if_then_else:SI (match_operator 1 "arm_comparison_operator"
11122 [(match_operand 2 "" "") (match_operand 3 "" "")])
11123 (match_operand 4 "" "")
11124 (match_operand 5 "" "")))
11125 (clobber (reg:CC CC_REGNUM))]
11126 "TARGET_ARM && reload_completed"
11127 [(set (match_dup 6) (match_dup 7))
11128 (cond_exec (match_op_dup 1 [(match_dup 6) (const_int 0)])
11129 (set (match_dup 0) (match_dup 4)))
11130 (cond_exec (match_dup 8)
11131 (set (match_dup 0) (match_dup 5)))]
11134 machine_mode mode = SELECT_CC_MODE (GET_CODE (operands[1]),
11135 operands[2], operands[3]);
11136 enum rtx_code rc = GET_CODE (operands[1]);
11138 operands[6] = gen_rtx_REG (mode, CC_REGNUM);
11139 operands[7] = gen_rtx_COMPARE (mode, operands[2], operands[3]);
11140 if (mode == CCFPmode || mode == CCFPEmode)
11141 rc = reverse_condition_maybe_unordered (rc);
11143 rc = reverse_condition (rc);
11145 operands[8] = gen_rtx_fmt_ee (rc, VOIDmode, operands[6], const0_rtx);
11150 [(set (match_operand:SI 0 "s_register_operand" "")
11151 (if_then_else:SI (match_operator 1 "arm_comparison_operator"
11152 [(match_operand:SI 2 "s_register_operand" "")
11153 (match_operand:SI 3 "arm_add_operand" "")])
11154 (match_operand:SI 4 "arm_rhs_operand" "")
11156 (match_operand:SI 5 "s_register_operand" ""))))
11157 (clobber (reg:CC CC_REGNUM))]
11158 "TARGET_ARM && reload_completed"
11159 [(set (match_dup 6) (match_dup 7))
11160 (cond_exec (match_op_dup 1 [(match_dup 6) (const_int 0)])
11161 (set (match_dup 0) (match_dup 4)))
11162 (cond_exec (match_dup 8)
11163 (set (match_dup 0) (not:SI (match_dup 5))))]
11166 machine_mode mode = SELECT_CC_MODE (GET_CODE (operands[1]),
11167 operands[2], operands[3]);
11168 enum rtx_code rc = GET_CODE (operands[1]);
11170 operands[6] = gen_rtx_REG (mode, CC_REGNUM);
11171 operands[7] = gen_rtx_COMPARE (mode, operands[2], operands[3]);
11172 if (mode == CCFPmode || mode == CCFPEmode)
11173 rc = reverse_condition_maybe_unordered (rc);
11175 rc = reverse_condition (rc);
11177 operands[8] = gen_rtx_fmt_ee (rc, VOIDmode, operands[6], const0_rtx);
11181 (define_insn "*cond_move_not"
11182 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
11183 (if_then_else:SI (match_operator 4 "arm_comparison_operator"
11184 [(match_operand 3 "cc_register" "") (const_int 0)])
11185 (match_operand:SI 1 "arm_rhs_operand" "0,?rI")
11187 (match_operand:SI 2 "s_register_operand" "r,r"))))]
11191 mov%d4\\t%0, %1\;mvn%D4\\t%0, %2"
11192 [(set_attr "conds" "use")
11193 (set_attr "type" "mvn_reg,multiple")
11194 (set_attr "length" "4,8")]
11197 ;; The next two patterns occur when an AND operation is followed by a
11198 ;; scc insn sequence
11200 (define_insn "*sign_extract_onebit"
11201 [(set (match_operand:SI 0 "s_register_operand" "=r")
11202 (sign_extract:SI (match_operand:SI 1 "s_register_operand" "r")
11204 (match_operand:SI 2 "const_int_operand" "n")))
11205 (clobber (reg:CC CC_REGNUM))]
11208 operands[2] = GEN_INT (1 << INTVAL (operands[2]));
11209 output_asm_insn (\"ands\\t%0, %1, %2\", operands);
11210 return \"mvnne\\t%0, #0\";
11212 [(set_attr "conds" "clob")
11213 (set_attr "length" "8")
11214 (set_attr "type" "multiple")]
11217 (define_insn "*not_signextract_onebit"
11218 [(set (match_operand:SI 0 "s_register_operand" "=r")
11220 (sign_extract:SI (match_operand:SI 1 "s_register_operand" "r")
11222 (match_operand:SI 2 "const_int_operand" "n"))))
11223 (clobber (reg:CC CC_REGNUM))]
11226 operands[2] = GEN_INT (1 << INTVAL (operands[2]));
11227 output_asm_insn (\"tst\\t%1, %2\", operands);
11228 output_asm_insn (\"mvneq\\t%0, #0\", operands);
11229 return \"movne\\t%0, #0\";
11231 [(set_attr "conds" "clob")
11232 (set_attr "length" "12")
11233 (set_attr "type" "multiple")]
11235 ;; ??? The above patterns need auditing for Thumb-2
11237 ;; Push multiple registers to the stack. Registers are in parallel (use ...)
11238 ;; expressions. For simplicity, the first register is also in the unspec
11240 ;; To avoid the usage of GNU extension, the length attribute is computed
11241 ;; in a C function arm_attr_length_push_multi.
11242 (define_insn "*push_multi"
11243 [(match_parallel 2 "multi_register_push"
11244 [(set (match_operand:BLK 0 "push_mult_memory_operand" "")
11245 (unspec:BLK [(match_operand:SI 1 "s_register_operand" "")]
11246 UNSPEC_PUSH_MULT))])]
11250 int num_saves = XVECLEN (operands[2], 0);
11252 /* For the StrongARM at least it is faster to
11253 use STR to store only a single register.
11254 In Thumb mode always use push, and the assembler will pick
11255 something appropriate. */
11256 if (num_saves == 1 && TARGET_ARM)
11257 output_asm_insn (\"str%?\\t%1, [%m0, #-4]!\", operands);
11264 strcpy (pattern, \"push%?\\t{%1\");
11266 strcpy (pattern, \"push\\t{%1\");
11268 for (i = 1; i < num_saves; i++)
11270 strcat (pattern, \", %|\");
11272 reg_names[REGNO (XEXP (XVECEXP (operands[2], 0, i), 0))]);
11275 strcat (pattern, \"}\");
11276 output_asm_insn (pattern, operands);
11281 [(set_attr "type" "store_16")
11282 (set (attr "length")
11283 (symbol_ref "arm_attr_length_push_multi (operands[2], operands[1])"))]
11286 (define_insn "stack_tie"
11287 [(set (mem:BLK (scratch))
11288 (unspec:BLK [(match_operand:SI 0 "s_register_operand" "rk")
11289 (match_operand:SI 1 "s_register_operand" "rk")]
11293 [(set_attr "length" "0")
11294 (set_attr "type" "block")]
11297 ;; Pop (as used in epilogue RTL)
11299 (define_insn "*load_multiple_with_writeback"
11300 [(match_parallel 0 "load_multiple_operation"
11301 [(set (match_operand:SI 1 "s_register_operand" "+rk")
11302 (plus:SI (match_dup 1)
11303 (match_operand:SI 2 "const_int_I_operand" "I")))
11304 (set (match_operand:SI 3 "s_register_operand" "=rk")
11305 (mem:SI (match_dup 1)))
11307 "TARGET_32BIT && (reload_in_progress || reload_completed)"
11310 arm_output_multireg_pop (operands, /*return_pc=*/false,
11311 /*cond=*/const_true_rtx,
11317 [(set_attr "type" "load_16")
11318 (set_attr "predicable" "yes")
11319 (set (attr "length")
11320 (symbol_ref "arm_attr_length_pop_multi (operands,
11321 /*return_pc=*/false,
11322 /*write_back_p=*/true)"))]
11325 ;; Pop with return (as used in epilogue RTL)
11327 ;; This instruction is generated when the registers are popped at the end of
11328 ;; epilogue. Here, instead of popping the value into LR and then generating
11329 ;; jump to LR, value is popped into PC directly. Hence, the pattern is combined
11331 (define_insn "*pop_multiple_with_writeback_and_return"
11332 [(match_parallel 0 "pop_multiple_return"
11334 (set (match_operand:SI 1 "s_register_operand" "+rk")
11335 (plus:SI (match_dup 1)
11336 (match_operand:SI 2 "const_int_I_operand" "I")))
11337 (set (match_operand:SI 3 "s_register_operand" "=rk")
11338 (mem:SI (match_dup 1)))
11340 "TARGET_32BIT && (reload_in_progress || reload_completed)"
11343 arm_output_multireg_pop (operands, /*return_pc=*/true,
11344 /*cond=*/const_true_rtx,
11350 [(set_attr "type" "load_16")
11351 (set_attr "predicable" "yes")
11352 (set (attr "length")
11353 (symbol_ref "arm_attr_length_pop_multi (operands, /*return_pc=*/true,
11354 /*write_back_p=*/true)"))]
11357 (define_insn "*pop_multiple_with_return"
11358 [(match_parallel 0 "pop_multiple_return"
11360 (set (match_operand:SI 2 "s_register_operand" "=rk")
11361 (mem:SI (match_operand:SI 1 "s_register_operand" "rk")))
11363 "TARGET_32BIT && (reload_in_progress || reload_completed)"
11366 arm_output_multireg_pop (operands, /*return_pc=*/true,
11367 /*cond=*/const_true_rtx,
11373 [(set_attr "type" "load_16")
11374 (set_attr "predicable" "yes")
11375 (set (attr "length")
11376 (symbol_ref "arm_attr_length_pop_multi (operands, /*return_pc=*/true,
11377 /*write_back_p=*/false)"))]
11380 ;; Load into PC and return
11381 (define_insn "*ldr_with_return"
11383 (set (reg:SI PC_REGNUM)
11384 (mem:SI (post_inc:SI (match_operand:SI 0 "s_register_operand" "+rk"))))]
11385 "TARGET_32BIT && (reload_in_progress || reload_completed)"
11386 "ldr%?\t%|pc, [%0], #4"
11387 [(set_attr "type" "load_4")
11388 (set_attr "predicable" "yes")]
11390 ;; Pop for floating point registers (as used in epilogue RTL)
11391 (define_insn "*vfp_pop_multiple_with_writeback"
11392 [(match_parallel 0 "pop_multiple_fp"
11393 [(set (match_operand:SI 1 "s_register_operand" "+rk")
11394 (plus:SI (match_dup 1)
11395 (match_operand:SI 2 "const_int_I_operand" "I")))
11396 (set (match_operand:DF 3 "vfp_hard_register_operand" "")
11397 (mem:DF (match_dup 1)))])]
11398 "TARGET_32BIT && TARGET_HARD_FLOAT"
11401 int num_regs = XVECLEN (operands[0], 0);
11404 strcpy (pattern, \"vldm\\t\");
11405 strcat (pattern, reg_names[REGNO (SET_DEST (XVECEXP (operands[0], 0, 0)))]);
11406 strcat (pattern, \"!, {\");
11407 op_list[0] = XEXP (XVECEXP (operands[0], 0, 1), 0);
11408 strcat (pattern, \"%P0\");
11409 if ((num_regs - 1) > 1)
11411 strcat (pattern, \"-%P1\");
11412 op_list [1] = XEXP (XVECEXP (operands[0], 0, num_regs - 1), 0);
11415 strcat (pattern, \"}\");
11416 output_asm_insn (pattern, op_list);
11420 [(set_attr "type" "load_16")
11421 (set_attr "conds" "unconditional")
11422 (set_attr "predicable" "no")]
11425 ;; Special patterns for dealing with the constant pool
11427 (define_insn "align_4"
11428 [(unspec_volatile [(const_int 0)] VUNSPEC_ALIGN)]
11431 assemble_align (32);
11434 [(set_attr "type" "no_insn")]
11437 (define_insn "align_8"
11438 [(unspec_volatile [(const_int 0)] VUNSPEC_ALIGN8)]
11441 assemble_align (64);
11444 [(set_attr "type" "no_insn")]
11447 (define_insn "consttable_end"
11448 [(unspec_volatile [(const_int 0)] VUNSPEC_POOL_END)]
11451 making_const_table = FALSE;
11454 [(set_attr "type" "no_insn")]
11457 (define_insn "consttable_1"
11458 [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_1)]
11461 making_const_table = TRUE;
11462 assemble_integer (operands[0], 1, BITS_PER_WORD, 1);
11463 assemble_zeros (3);
11466 [(set_attr "length" "4")
11467 (set_attr "type" "no_insn")]
11470 (define_insn "consttable_2"
11471 [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_2)]
11475 rtx x = operands[0];
11476 making_const_table = TRUE;
11477 switch (GET_MODE_CLASS (GET_MODE (x)))
11480 arm_emit_fp16_const (x);
11483 assemble_integer (operands[0], 2, BITS_PER_WORD, 1);
11484 assemble_zeros (2);
11489 [(set_attr "length" "4")
11490 (set_attr "type" "no_insn")]
11493 (define_insn "consttable_4"
11494 [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_4)]
11498 rtx x = operands[0];
11499 making_const_table = TRUE;
11500 scalar_float_mode float_mode;
11501 if (is_a <scalar_float_mode> (GET_MODE (x), &float_mode))
11502 assemble_real (*CONST_DOUBLE_REAL_VALUE (x), float_mode, BITS_PER_WORD);
11505 /* XXX: Sometimes gcc does something really dumb and ends up with
11506 a HIGH in a constant pool entry, usually because it's trying to
11507 load into a VFP register. We know this will always be used in
11508 combination with a LO_SUM which ignores the high bits, so just
11509 strip off the HIGH. */
11510 if (GET_CODE (x) == HIGH)
11512 assemble_integer (x, 4, BITS_PER_WORD, 1);
11513 mark_symbol_refs_as_used (x);
11517 [(set_attr "length" "4")
11518 (set_attr "type" "no_insn")]
11521 (define_insn "consttable_8"
11522 [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_8)]
11526 making_const_table = TRUE;
11527 scalar_float_mode float_mode;
11528 if (is_a <scalar_float_mode> (GET_MODE (operands[0]), &float_mode))
11529 assemble_real (*CONST_DOUBLE_REAL_VALUE (operands[0]),
11530 float_mode, BITS_PER_WORD);
11532 assemble_integer (operands[0], 8, BITS_PER_WORD, 1);
11535 [(set_attr "length" "8")
11536 (set_attr "type" "no_insn")]
11539 (define_insn "consttable_16"
11540 [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_16)]
11544 making_const_table = TRUE;
11545 scalar_float_mode float_mode;
11546 if (is_a <scalar_float_mode> (GET_MODE (operands[0]), &float_mode))
11547 assemble_real (*CONST_DOUBLE_REAL_VALUE (operands[0]),
11548 float_mode, BITS_PER_WORD);
11550 assemble_integer (operands[0], 16, BITS_PER_WORD, 1);
11553 [(set_attr "length" "16")
11554 (set_attr "type" "no_insn")]
11557 ;; V5 Instructions,
11559 (define_insn "clzsi2"
11560 [(set (match_operand:SI 0 "s_register_operand" "=r")
11561 (clz:SI (match_operand:SI 1 "s_register_operand" "r")))]
11562 "TARGET_32BIT && arm_arch5t"
11564 [(set_attr "predicable" "yes")
11565 (set_attr "type" "clz")])
11567 (define_insn "rbitsi2"
11568 [(set (match_operand:SI 0 "s_register_operand" "=r")
11569 (unspec:SI [(match_operand:SI 1 "s_register_operand" "r")] UNSPEC_RBIT))]
11570 "TARGET_32BIT && arm_arch_thumb2"
11572 [(set_attr "predicable" "yes")
11573 (set_attr "type" "clz")])
11575 ;; Keep this as a CTZ expression until after reload and then split
11576 ;; into RBIT + CLZ. Since RBIT is represented as an UNSPEC it is unlikely
11577 ;; to fold with any other expression.
11579 (define_insn_and_split "ctzsi2"
11580 [(set (match_operand:SI 0 "s_register_operand" "=r")
11581 (ctz:SI (match_operand:SI 1 "s_register_operand" "r")))]
11582 "TARGET_32BIT && arm_arch_thumb2"
11584 "&& reload_completed"
11587 emit_insn (gen_rbitsi2 (operands[0], operands[1]));
11588 emit_insn (gen_clzsi2 (operands[0], operands[0]));
11592 ;; V5E instructions.
11594 (define_insn "prefetch"
11595 [(prefetch (match_operand:SI 0 "address_operand" "p")
11596 (match_operand:SI 1 "" "")
11597 (match_operand:SI 2 "" ""))]
11598 "TARGET_32BIT && arm_arch5te"
11600 [(set_attr "type" "load_4")]
11603 ;; General predication pattern
11606 [(match_operator 0 "arm_comparison_operator"
11607 [(match_operand 1 "cc_register" "")
11610 && (!TARGET_NO_VOLATILE_CE || !volatile_refs_p (PATTERN (insn)))"
11612 [(set_attr "predicated" "yes")]
11615 (define_insn "force_register_use"
11616 [(unspec:SI [(match_operand:SI 0 "register_operand" "")] UNSPEC_REGISTER_USE)]
11619 [(set_attr "length" "0")
11620 (set_attr "type" "no_insn")]
11624 ;; Patterns for exception handling
11626 (define_expand "eh_return"
11627 [(use (match_operand 0 "general_operand" ""))]
11632 emit_insn (gen_arm_eh_return (operands[0]));
11634 emit_insn (gen_thumb_eh_return (operands[0]));
11639 ;; We can't expand this before we know where the link register is stored.
11640 (define_insn_and_split "arm_eh_return"
11641 [(unspec_volatile [(match_operand:SI 0 "s_register_operand" "r")]
11643 (clobber (match_scratch:SI 1 "=&r"))]
11646 "&& reload_completed"
11650 arm_set_return_address (operands[0], operands[1]);
11658 (define_insn "load_tp_hard"
11659 [(set (match_operand:SI 0 "register_operand" "=r")
11660 (unspec:SI [(const_int 0)] UNSPEC_TLS))]
11662 "mrc%?\\tp15, 0, %0, c13, c0, 3\\t@ load_tp_hard"
11663 [(set_attr "predicable" "yes")
11664 (set_attr "type" "mrs")]
11667 ;; Doesn't clobber R1-R3. Must use r0 for the first operand.
11668 (define_insn "load_tp_soft"
11669 [(set (reg:SI 0) (unspec:SI [(const_int 0)] UNSPEC_TLS))
11670 (clobber (reg:SI LR_REGNUM))
11671 (clobber (reg:SI IP_REGNUM))
11672 (clobber (reg:CC CC_REGNUM))]
11674 "bl\\t__aeabi_read_tp\\t@ load_tp_soft"
11675 [(set_attr "conds" "clob")
11676 (set_attr "type" "branch")]
11679 ;; tls descriptor call
11680 (define_insn "tlscall"
11681 [(set (reg:SI R0_REGNUM)
11682 (unspec:SI [(reg:SI R0_REGNUM)
11683 (match_operand:SI 0 "" "X")
11684 (match_operand 1 "" "")] UNSPEC_TLS))
11685 (clobber (reg:SI R1_REGNUM))
11686 (clobber (reg:SI LR_REGNUM))
11687 (clobber (reg:SI CC_REGNUM))]
11690 targetm.asm_out.internal_label (asm_out_file, "LPIC",
11691 INTVAL (operands[1]));
11692 return "bl\\t%c0(tlscall)";
11694 [(set_attr "conds" "clob")
11695 (set_attr "length" "4")
11696 (set_attr "type" "branch")]
11699 ;; For thread pointer builtin
11700 (define_expand "get_thread_pointersi"
11701 [(match_operand:SI 0 "s_register_operand" "=r")]
11705 arm_load_tp (operands[0]);
11711 ;; We only care about the lower 16 bits of the constant
11712 ;; being inserted into the upper 16 bits of the register.
11713 (define_insn "*arm_movtas_ze"
11714 [(set (zero_extract:SI (match_operand:SI 0 "s_register_operand" "+r,r")
11717 (match_operand:SI 1 "const_int_operand" ""))]
11722 [(set_attr "arch" "32,v8mb")
11723 (set_attr "predicable" "yes")
11724 (set_attr "length" "4")
11725 (set_attr "type" "alu_sreg")]
11728 (define_insn "*arm_rev"
11729 [(set (match_operand:SI 0 "s_register_operand" "=l,l,r")
11730 (bswap:SI (match_operand:SI 1 "s_register_operand" "l,l,r")))]
11736 [(set_attr "arch" "t1,t2,32")
11737 (set_attr "length" "2,2,4")
11738 (set_attr "predicable" "no,yes,yes")
11739 (set_attr "type" "rev")]
11742 (define_expand "arm_legacy_rev"
11743 [(set (match_operand:SI 2 "s_register_operand" "")
11744 (xor:SI (rotatert:SI (match_operand:SI 1 "s_register_operand" "")
11748 (lshiftrt:SI (match_dup 2)
11750 (set (match_operand:SI 3 "s_register_operand" "")
11751 (rotatert:SI (match_dup 1)
11754 (and:SI (match_dup 2)
11755 (const_int -65281)))
11756 (set (match_operand:SI 0 "s_register_operand" "")
11757 (xor:SI (match_dup 3)
11763 ;; Reuse temporaries to keep register pressure down.
11764 (define_expand "thumb_legacy_rev"
11765 [(set (match_operand:SI 2 "s_register_operand" "")
11766 (ashift:SI (match_operand:SI 1 "s_register_operand" "")
11768 (set (match_operand:SI 3 "s_register_operand" "")
11769 (lshiftrt:SI (match_dup 1)
11772 (ior:SI (match_dup 3)
11774 (set (match_operand:SI 4 "s_register_operand" "")
11776 (set (match_operand:SI 5 "s_register_operand" "")
11777 (rotatert:SI (match_dup 1)
11780 (ashift:SI (match_dup 5)
11783 (lshiftrt:SI (match_dup 5)
11786 (ior:SI (match_dup 5)
11789 (rotatert:SI (match_dup 5)
11791 (set (match_operand:SI 0 "s_register_operand" "")
11792 (ior:SI (match_dup 5)
11798 ;; ARM-specific expansion of signed mod by power of 2
11799 ;; using conditional negate.
11800 ;; For r0 % n where n is a power of 2 produce:
11802 ;; and r0, r0, #(n - 1)
11803 ;; and r1, r1, #(n - 1)
11804 ;; rsbpl r0, r1, #0
11806 (define_expand "modsi3"
11807 [(match_operand:SI 0 "register_operand" "")
11808 (match_operand:SI 1 "register_operand" "")
11809 (match_operand:SI 2 "const_int_operand" "")]
11812 HOST_WIDE_INT val = INTVAL (operands[2]);
11815 || exact_log2 (val) <= 0)
11818 rtx mask = GEN_INT (val - 1);
11820 /* In the special case of x0 % 2 we can do the even shorter:
11823 rsblt r0, r0, #0. */
11827 rtx cc_reg = arm_gen_compare_reg (LT,
11828 operands[1], const0_rtx, NULL_RTX);
11829 rtx cond = gen_rtx_LT (SImode, cc_reg, const0_rtx);
11830 rtx masked = gen_reg_rtx (SImode);
11832 emit_insn (gen_andsi3 (masked, operands[1], mask));
11833 emit_move_insn (operands[0],
11834 gen_rtx_IF_THEN_ELSE (SImode, cond,
11835 gen_rtx_NEG (SImode,
11841 rtx neg_op = gen_reg_rtx (SImode);
11842 rtx_insn *insn = emit_insn (gen_subsi3_compare0 (neg_op, const0_rtx,
11845 /* Extract the condition register and mode. */
11846 rtx cmp = XVECEXP (PATTERN (insn), 0, 0);
11847 rtx cc_reg = SET_DEST (cmp);
11848 rtx cond = gen_rtx_GE (SImode, cc_reg, const0_rtx);
11850 emit_insn (gen_andsi3 (operands[0], operands[1], mask));
11852 rtx masked_neg = gen_reg_rtx (SImode);
11853 emit_insn (gen_andsi3 (masked_neg, neg_op, mask));
11855 /* We want a conditional negate here, but emitting COND_EXEC rtxes
11856 during expand does not always work. Do an IF_THEN_ELSE instead. */
11857 emit_move_insn (operands[0],
11858 gen_rtx_IF_THEN_ELSE (SImode, cond,
11859 gen_rtx_NEG (SImode, masked_neg),
11867 (define_expand "bswapsi2"
11868 [(set (match_operand:SI 0 "s_register_operand" "=r")
11869 (bswap:SI (match_operand:SI 1 "s_register_operand" "r")))]
11870 "TARGET_EITHER && (arm_arch6 || !optimize_size)"
11874 rtx op2 = gen_reg_rtx (SImode);
11875 rtx op3 = gen_reg_rtx (SImode);
11879 rtx op4 = gen_reg_rtx (SImode);
11880 rtx op5 = gen_reg_rtx (SImode);
11882 emit_insn (gen_thumb_legacy_rev (operands[0], operands[1],
11883 op2, op3, op4, op5));
11887 emit_insn (gen_arm_legacy_rev (operands[0], operands[1],
11896 ;; bswap16 patterns: use revsh and rev16 instructions for the signed
11897 ;; and unsigned variants, respectively. For rev16, expose
11898 ;; byte-swapping in the lower 16 bits only.
11899 (define_insn "*arm_revsh"
11900 [(set (match_operand:SI 0 "s_register_operand" "=l,l,r")
11901 (sign_extend:SI (bswap:HI (match_operand:HI 1 "s_register_operand" "l,l,r"))))]
11907 [(set_attr "arch" "t1,t2,32")
11908 (set_attr "length" "2,2,4")
11909 (set_attr "type" "rev")]
11912 (define_insn "*arm_rev16"
11913 [(set (match_operand:HI 0 "s_register_operand" "=l,l,r")
11914 (bswap:HI (match_operand:HI 1 "s_register_operand" "l,l,r")))]
11920 [(set_attr "arch" "t1,t2,32")
11921 (set_attr "length" "2,2,4")
11922 (set_attr "type" "rev")]
11925 ;; There are no canonicalisation rules for the position of the lshiftrt, ashift
11926 ;; operations within an IOR/AND RTX, therefore we have two patterns matching
11927 ;; each valid permutation.
11929 (define_insn "arm_rev16si2"
11930 [(set (match_operand:SI 0 "register_operand" "=l,l,r")
11931 (ior:SI (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "l,l,r")
11933 (match_operand:SI 3 "const_int_operand" "n,n,n"))
11934 (and:SI (lshiftrt:SI (match_dup 1)
11936 (match_operand:SI 2 "const_int_operand" "n,n,n"))))]
11938 && aarch_rev16_shleft_mask_imm_p (operands[3], SImode)
11939 && aarch_rev16_shright_mask_imm_p (operands[2], SImode)"
11941 [(set_attr "arch" "t1,t2,32")
11942 (set_attr "length" "2,2,4")
11943 (set_attr "type" "rev")]
11946 (define_insn "arm_rev16si2_alt"
11947 [(set (match_operand:SI 0 "register_operand" "=l,l,r")
11948 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "l,l,r")
11950 (match_operand:SI 2 "const_int_operand" "n,n,n"))
11951 (and:SI (ashift:SI (match_dup 1)
11953 (match_operand:SI 3 "const_int_operand" "n,n,n"))))]
11955 && aarch_rev16_shleft_mask_imm_p (operands[3], SImode)
11956 && aarch_rev16_shright_mask_imm_p (operands[2], SImode)"
11958 [(set_attr "arch" "t1,t2,32")
11959 (set_attr "length" "2,2,4")
11960 (set_attr "type" "rev")]
11963 (define_expand "bswaphi2"
11964 [(set (match_operand:HI 0 "s_register_operand" "=r")
11965 (bswap:HI (match_operand:HI 1 "s_register_operand" "r")))]
11970 ;; Patterns for LDRD/STRD in Thumb2 mode
11972 (define_insn "*thumb2_ldrd"
11973 [(set (match_operand:SI 0 "s_register_operand" "=r")
11974 (mem:SI (plus:SI (match_operand:SI 1 "s_register_operand" "rk")
11975 (match_operand:SI 2 "ldrd_strd_offset_operand" "Do"))))
11976 (set (match_operand:SI 3 "s_register_operand" "=r")
11977 (mem:SI (plus:SI (match_dup 1)
11978 (match_operand:SI 4 "const_int_operand" ""))))]
11979 "TARGET_LDRD && TARGET_THUMB2 && reload_completed
11980 && ((INTVAL (operands[2]) + 4) == INTVAL (operands[4]))
11981 && (operands_ok_ldrd_strd (operands[0], operands[3],
11982 operands[1], INTVAL (operands[2]),
11984 "ldrd%?\t%0, %3, [%1, %2]"
11985 [(set_attr "type" "load_8")
11986 (set_attr "predicable" "yes")])
11988 (define_insn "*thumb2_ldrd_base"
11989 [(set (match_operand:SI 0 "s_register_operand" "=r")
11990 (mem:SI (match_operand:SI 1 "s_register_operand" "rk")))
11991 (set (match_operand:SI 2 "s_register_operand" "=r")
11992 (mem:SI (plus:SI (match_dup 1)
11994 "TARGET_LDRD && TARGET_THUMB2 && reload_completed
11995 && (operands_ok_ldrd_strd (operands[0], operands[2],
11996 operands[1], 0, false, true))"
11997 "ldrd%?\t%0, %2, [%1]"
11998 [(set_attr "type" "load_8")
11999 (set_attr "predicable" "yes")])
12001 (define_insn "*thumb2_ldrd_base_neg"
12002 [(set (match_operand:SI 0 "s_register_operand" "=r")
12003 (mem:SI (plus:SI (match_operand:SI 1 "s_register_operand" "rk")
12005 (set (match_operand:SI 2 "s_register_operand" "=r")
12006 (mem:SI (match_dup 1)))]
12007 "TARGET_LDRD && TARGET_THUMB2 && reload_completed
12008 && (operands_ok_ldrd_strd (operands[0], operands[2],
12009 operands[1], -4, false, true))"
12010 "ldrd%?\t%0, %2, [%1, #-4]"
12011 [(set_attr "type" "load_8")
12012 (set_attr "predicable" "yes")])
12014 (define_insn "*thumb2_strd"
12015 [(set (mem:SI (plus:SI (match_operand:SI 0 "s_register_operand" "rk")
12016 (match_operand:SI 1 "ldrd_strd_offset_operand" "Do")))
12017 (match_operand:SI 2 "s_register_operand" "r"))
12018 (set (mem:SI (plus:SI (match_dup 0)
12019 (match_operand:SI 3 "const_int_operand" "")))
12020 (match_operand:SI 4 "s_register_operand" "r"))]
12021 "TARGET_LDRD && TARGET_THUMB2 && reload_completed
12022 && ((INTVAL (operands[1]) + 4) == INTVAL (operands[3]))
12023 && (operands_ok_ldrd_strd (operands[2], operands[4],
12024 operands[0], INTVAL (operands[1]),
12026 "strd%?\t%2, %4, [%0, %1]"
12027 [(set_attr "type" "store_8")
12028 (set_attr "predicable" "yes")])
12030 (define_insn "*thumb2_strd_base"
12031 [(set (mem:SI (match_operand:SI 0 "s_register_operand" "rk"))
12032 (match_operand:SI 1 "s_register_operand" "r"))
12033 (set (mem:SI (plus:SI (match_dup 0)
12035 (match_operand:SI 2 "s_register_operand" "r"))]
12036 "TARGET_LDRD && TARGET_THUMB2 && reload_completed
12037 && (operands_ok_ldrd_strd (operands[1], operands[2],
12038 operands[0], 0, false, false))"
12039 "strd%?\t%1, %2, [%0]"
12040 [(set_attr "type" "store_8")
12041 (set_attr "predicable" "yes")])
12043 (define_insn "*thumb2_strd_base_neg"
12044 [(set (mem:SI (plus:SI (match_operand:SI 0 "s_register_operand" "rk")
12046 (match_operand:SI 1 "s_register_operand" "r"))
12047 (set (mem:SI (match_dup 0))
12048 (match_operand:SI 2 "s_register_operand" "r"))]
12049 "TARGET_LDRD && TARGET_THUMB2 && reload_completed
12050 && (operands_ok_ldrd_strd (operands[1], operands[2],
12051 operands[0], -4, false, false))"
12052 "strd%?\t%1, %2, [%0, #-4]"
12053 [(set_attr "type" "store_8")
12054 (set_attr "predicable" "yes")])
12056 ;; ARMv8 CRC32 instructions.
12057 (define_insn "<crc_variant>"
12058 [(set (match_operand:SI 0 "s_register_operand" "=r")
12059 (unspec:SI [(match_operand:SI 1 "s_register_operand" "r")
12060 (match_operand:<crc_mode> 2 "s_register_operand" "r")]
12063 "<crc_variant>\\t%0, %1, %2"
12064 [(set_attr "type" "crc")
12065 (set_attr "conds" "unconditional")]
12068 ;; Load the load/store double peephole optimizations.
12069 (include "ldrdstrd.md")
12071 ;; Load the load/store multiple patterns
12072 (include "ldmstm.md")
12074 ;; Patterns in ldmstm.md don't cover more than 4 registers. This pattern covers
12075 ;; large lists without explicit writeback generated for APCS_FRAME epilogue.
12076 ;; The operands are validated through the load_multiple_operation
12077 ;; match_parallel predicate rather than through constraints so enable it only
12079 (define_insn "*load_multiple"
12080 [(match_parallel 0 "load_multiple_operation"
12081 [(set (match_operand:SI 2 "s_register_operand" "=rk")
12082 (mem:SI (match_operand:SI 1 "s_register_operand" "rk")))
12084 "TARGET_32BIT && reload_completed"
12087 arm_output_multireg_pop (operands, /*return_pc=*/false,
12088 /*cond=*/const_true_rtx,
12094 [(set_attr "predicable" "yes")]
12097 (define_expand "copysignsf3"
12098 [(match_operand:SF 0 "register_operand")
12099 (match_operand:SF 1 "register_operand")
12100 (match_operand:SF 2 "register_operand")]
12101 "TARGET_SOFT_FLOAT && arm_arch_thumb2"
12103 emit_move_insn (operands[0], operands[2]);
12104 emit_insn (gen_insv_t2 (simplify_gen_subreg (SImode, operands[0], SFmode, 0),
12105 GEN_INT (31), GEN_INT (0),
12106 simplify_gen_subreg (SImode, operands[1], SFmode, 0)));
12111 (define_expand "copysigndf3"
12112 [(match_operand:DF 0 "register_operand")
12113 (match_operand:DF 1 "register_operand")
12114 (match_operand:DF 2 "register_operand")]
12115 "TARGET_SOFT_FLOAT && arm_arch_thumb2"
12117 rtx op0_low = gen_lowpart (SImode, operands[0]);
12118 rtx op0_high = gen_highpart (SImode, operands[0]);
12119 rtx op1_low = gen_lowpart (SImode, operands[1]);
12120 rtx op1_high = gen_highpart (SImode, operands[1]);
12121 rtx op2_high = gen_highpart (SImode, operands[2]);
12123 rtx scratch1 = gen_reg_rtx (SImode);
12124 rtx scratch2 = gen_reg_rtx (SImode);
12125 emit_move_insn (scratch1, op2_high);
12126 emit_move_insn (scratch2, op1_high);
12128 emit_insn(gen_rtx_SET(scratch1,
12129 gen_rtx_LSHIFTRT (SImode, op2_high, GEN_INT(31))));
12130 emit_insn(gen_insv_t2(scratch2, GEN_INT(1), GEN_INT(31), scratch1));
12131 emit_move_insn (op0_low, op1_low);
12132 emit_move_insn (op0_high, scratch2);
12138 ;; movmisalign patterns for HImode and SImode.
12139 (define_expand "movmisalign<mode>"
12140 [(match_operand:HSI 0 "general_operand")
12141 (match_operand:HSI 1 "general_operand")]
12144 /* This pattern is not permitted to fail during expansion: if both arguments
12145 are non-registers (e.g. memory := constant), force operand 1 into a
12147 rtx (* gen_unaligned_load)(rtx, rtx);
12148 rtx tmp_dest = operands[0];
12149 if (!s_register_operand (operands[0], <MODE>mode)
12150 && !s_register_operand (operands[1], <MODE>mode))
12151 operands[1] = force_reg (<MODE>mode, operands[1]);
12153 if (<MODE>mode == HImode)
12155 gen_unaligned_load = gen_unaligned_loadhiu;
12156 tmp_dest = gen_reg_rtx (SImode);
12159 gen_unaligned_load = gen_unaligned_loadsi;
12161 if (MEM_P (operands[1]))
12163 emit_insn (gen_unaligned_load (tmp_dest, operands[1]));
12164 if (<MODE>mode == HImode)
12165 emit_move_insn (operands[0], gen_lowpart (HImode, tmp_dest));
12168 emit_insn (gen_unaligned_store<mode> (operands[0], operands[1]));
12173 (define_insn "<cdp>"
12174 [(unspec_volatile [(match_operand:SI 0 "immediate_operand" "n")
12175 (match_operand:SI 1 "immediate_operand" "n")
12176 (match_operand:SI 2 "immediate_operand" "n")
12177 (match_operand:SI 3 "immediate_operand" "n")
12178 (match_operand:SI 4 "immediate_operand" "n")
12179 (match_operand:SI 5 "immediate_operand" "n")] CDPI)]
12180 "arm_coproc_builtin_available (VUNSPEC_<CDP>)"
12182 arm_const_bounds (operands[0], 0, 16);
12183 arm_const_bounds (operands[1], 0, 16);
12184 arm_const_bounds (operands[2], 0, (1 << 5));
12185 arm_const_bounds (operands[3], 0, (1 << 5));
12186 arm_const_bounds (operands[4], 0, (1 << 5));
12187 arm_const_bounds (operands[5], 0, 8);
12188 return "<cdp>\\tp%c0, %1, CR%c2, CR%c3, CR%c4, %5";
12190 [(set_attr "length" "4")
12191 (set_attr "type" "coproc")])
12193 (define_insn "*ldc"
12194 [(unspec_volatile [(match_operand:SI 0 "immediate_operand" "n")
12195 (match_operand:SI 1 "immediate_operand" "n")
12196 (match_operand:SI 2 "memory_operand" "Uz")] LDCI)]
12197 "arm_coproc_builtin_available (VUNSPEC_<LDC>)"
12199 arm_const_bounds (operands[0], 0, 16);
12200 arm_const_bounds (operands[1], 0, (1 << 5));
12201 return "<ldc>\\tp%c0, CR%c1, %2";
12203 [(set_attr "length" "4")
12204 (set_attr "type" "coproc")])
12206 (define_insn "*stc"
12207 [(unspec_volatile [(match_operand:SI 0 "immediate_operand" "n")
12208 (match_operand:SI 1 "immediate_operand" "n")
12209 (match_operand:SI 2 "memory_operand" "=Uz")] STCI)]
12210 "arm_coproc_builtin_available (VUNSPEC_<STC>)"
12212 arm_const_bounds (operands[0], 0, 16);
12213 arm_const_bounds (operands[1], 0, (1 << 5));
12214 return "<stc>\\tp%c0, CR%c1, %2";
12216 [(set_attr "length" "4")
12217 (set_attr "type" "coproc")])
12219 (define_expand "<ldc>"
12220 [(unspec_volatile [(match_operand:SI 0 "immediate_operand")
12221 (match_operand:SI 1 "immediate_operand")
12222 (mem:SI (match_operand:SI 2 "s_register_operand"))] LDCI)]
12223 "arm_coproc_builtin_available (VUNSPEC_<LDC>)")
12225 (define_expand "<stc>"
12226 [(unspec_volatile [(match_operand:SI 0 "immediate_operand")
12227 (match_operand:SI 1 "immediate_operand")
12228 (mem:SI (match_operand:SI 2 "s_register_operand"))] STCI)]
12229 "arm_coproc_builtin_available (VUNSPEC_<STC>)")
12231 (define_insn "<mcr>"
12232 [(unspec_volatile [(match_operand:SI 0 "immediate_operand" "n")
12233 (match_operand:SI 1 "immediate_operand" "n")
12234 (match_operand:SI 2 "s_register_operand" "r")
12235 (match_operand:SI 3 "immediate_operand" "n")
12236 (match_operand:SI 4 "immediate_operand" "n")
12237 (match_operand:SI 5 "immediate_operand" "n")] MCRI)
12238 (use (match_dup 2))]
12239 "arm_coproc_builtin_available (VUNSPEC_<MCR>)"
12241 arm_const_bounds (operands[0], 0, 16);
12242 arm_const_bounds (operands[1], 0, 8);
12243 arm_const_bounds (operands[3], 0, (1 << 5));
12244 arm_const_bounds (operands[4], 0, (1 << 5));
12245 arm_const_bounds (operands[5], 0, 8);
12246 return "<mcr>\\tp%c0, %1, %2, CR%c3, CR%c4, %5";
12248 [(set_attr "length" "4")
12249 (set_attr "type" "coproc")])
12251 (define_insn "<mrc>"
12252 [(set (match_operand:SI 0 "s_register_operand" "=r")
12253 (unspec_volatile:SI [(match_operand:SI 1 "immediate_operand" "n")
12254 (match_operand:SI 2 "immediate_operand" "n")
12255 (match_operand:SI 3 "immediate_operand" "n")
12256 (match_operand:SI 4 "immediate_operand" "n")
12257 (match_operand:SI 5 "immediate_operand" "n")] MRCI))]
12258 "arm_coproc_builtin_available (VUNSPEC_<MRC>)"
12260 arm_const_bounds (operands[1], 0, 16);
12261 arm_const_bounds (operands[2], 0, 8);
12262 arm_const_bounds (operands[3], 0, (1 << 5));
12263 arm_const_bounds (operands[4], 0, (1 << 5));
12264 arm_const_bounds (operands[5], 0, 8);
12265 return "<mrc>\\tp%c1, %2, %0, CR%c3, CR%c4, %5";
12267 [(set_attr "length" "4")
12268 (set_attr "type" "coproc")])
12270 (define_insn "<mcrr>"
12271 [(unspec_volatile [(match_operand:SI 0 "immediate_operand" "n")
12272 (match_operand:SI 1 "immediate_operand" "n")
12273 (match_operand:DI 2 "s_register_operand" "r")
12274 (match_operand:SI 3 "immediate_operand" "n")] MCRRI)
12275 (use (match_dup 2))]
12276 "arm_coproc_builtin_available (VUNSPEC_<MCRR>)"
12278 arm_const_bounds (operands[0], 0, 16);
12279 arm_const_bounds (operands[1], 0, 8);
12280 arm_const_bounds (operands[3], 0, (1 << 5));
12281 return "<mcrr>\\tp%c0, %1, %Q2, %R2, CR%c3";
12283 [(set_attr "length" "4")
12284 (set_attr "type" "coproc")])
12286 (define_insn "<mrrc>"
12287 [(set (match_operand:DI 0 "s_register_operand" "=r")
12288 (unspec_volatile:DI [(match_operand:SI 1 "immediate_operand" "n")
12289 (match_operand:SI 2 "immediate_operand" "n")
12290 (match_operand:SI 3 "immediate_operand" "n")] MRRCI))]
12291 "arm_coproc_builtin_available (VUNSPEC_<MRRC>)"
12293 arm_const_bounds (operands[1], 0, 16);
12294 arm_const_bounds (operands[2], 0, 8);
12295 arm_const_bounds (operands[3], 0, (1 << 5));
12296 return "<mrrc>\\tp%c1, %2, %Q0, %R0, CR%c3";
12298 [(set_attr "length" "4")
12299 (set_attr "type" "coproc")])
12301 (define_expand "speculation_barrier"
12302 [(unspec_volatile [(const_int 0)] VUNSPEC_SPECULATION_BARRIER)]
12305 /* For thumb1 (except Armv8 derivatives), and for pre-Armv7 we don't
12306 have a usable barrier (and probably don't need one in practice).
12307 But to be safe if such code is run on later architectures, call a
12308 helper function in libgcc that will do the thing for the active
12310 if (!(arm_arch7 || arm_arch8))
12312 arm_emit_speculation_barrier_function ();
12318 ;; Generate a hard speculation barrier when we have not enabled speculation
12320 (define_insn "*speculation_barrier_insn"
12321 [(unspec_volatile [(const_int 0)] VUNSPEC_SPECULATION_BARRIER)]
12322 "arm_arch7 || arm_arch8"
12324 [(set_attr "type" "block")
12325 (set_attr "length" "8")]
12328 ;; Vector bits common to IWMMXT and Neon
12329 (include "vec-common.md")
12330 ;; Load the Intel Wireless Multimedia Extension patterns
12331 (include "iwmmxt.md")
12332 ;; Load the VFP co-processor patterns
12334 ;; Thumb-1 patterns
12335 (include "thumb1.md")
12336 ;; Thumb-2 patterns
12337 (include "thumb2.md")
12339 (include "neon.md")
12341 (include "crypto.md")
12342 ;; Synchronization Primitives
12343 (include "sync.md")
12344 ;; Fixed-point patterns
12345 (include "arm-fixed.md")