1 ;;- Machine description for ARM for GNU compiler
2 ;; Copyright 1991, 1993, 1994, 1995, 1996, 1996, 1997, 1998, 1999, 2000,
3 ;; 2001, 2002, 2003 Free Software Foundation, Inc.
4 ;; Contributed by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl)
5 ;; and Martin Simmons (@harleqn.co.uk).
6 ;; More major hacks by Richard Earnshaw (rearnsha@arm.com).
8 ;; This file is part of GCC.
10 ;; GCC is free software; you can redistribute it and/or modify it
11 ;; under the terms of the GNU General Public License as published
12 ;; by the Free Software Foundation; either version 2, or (at your
13 ;; option) any later version.
15 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
16 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18 ;; License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GCC; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
28 ;;---------------------------------------------------------------------------
33 [(IP_REGNUM 12) ; Scratch register
34 (SP_REGNUM 13) ; Stack pointer
35 (LR_REGNUM 14) ; Return address register
36 (PC_REGNUM 15) ; Program counter
37 (CC_REGNUM 24) ; Condition code pseudo register
41 ;; 3rd operand to select_dominance_cc_mode
50 ;; Note: sin and cos are no-longer used.
53 [(UNSPEC_SIN 0) ; `sin' operation (MODE_FLOAT):
54 ; operand 0 is the result,
55 ; operand 1 the parameter.
56 (UNPSEC_COS 1) ; `cos' operation (MODE_FLOAT):
57 ; operand 0 is the result,
58 ; operand 1 the parameter.
59 (UNSPEC_PUSH_MULT 2) ; `push multiple' operation:
60 ; operand 0 is the first register,
61 ; subsequent registers are in parallel (use ...)
63 (UNSPEC_PIC_SYM 3) ; A symbol that has been treated properly for pic
64 ; usage, that is, we will add the pic_register
65 ; value to it before trying to dereference it.
66 (UNSPEC_PIC_BASE 4) ; Adding the PC value to the offset to the
67 ; GLOBAL_OFFSET_TABLE. The operation is fully
68 ; described by the RTL but must be wrapped to
69 ; prevent combine from trying to rip it apart.
70 (UNSPEC_PRLG_STK 5) ; A special barrier that prevents frame accesses
71 ; being scheduled before the stack adjustment insn.
72 (UNSPEC_PROLOGUE_USE 6) ; As USE insns are not meaningful after reload,
73 ; this unspec is used to prevent the deletion of
74 ; instructions setting registers for EH handling
75 ; and stack frame generation. Operand 0 is the
77 (UNSPEC_CHECK_ARCH 7); Set CCs to indicate 26-bit or 32-bit mode.
78 (UNSPEC_WSHUFH 8) ; Used by the intrinsic form of the iWMMXt WSHUFH instruction.
79 (UNSPEC_WACC 9) ; Used by the intrinsic form of the iWMMXt WACC instruction.
80 (UNSPEC_TMOVMSK 10) ; Used by the intrinsic form of the iWMMXt TMOVMSK instruction.
81 (UNSPEC_WSAD 11) ; Used by the intrinsic form of the iWMMXt WSAD instruction.
82 (UNSPEC_WSADZ 12) ; Used by the intrinsic form of the iWMMXt WSADZ instruction.
83 (UNSPEC_WMACS 13) ; Used by the intrinsic form of the iWMMXt WMACS instruction.
84 (UNSPEC_WMACU 14) ; Used by the intrinsic form of the iWMMXt WMACU instruction.
85 (UNSPEC_WMACSZ 15) ; Used by the intrinsic form of the iWMMXt WMACSZ instruction.
86 (UNSPEC_WMACUZ 16) ; Used by the intrinsic form of the iWMMXt WMACUZ instruction.
87 (UNSPEC_CLRDI 17) ; Used by the intrinsic form of the iWMMXt CLRDI instruction.
88 (UNSPEC_WMADDS 18) ; Used by the intrinsic form of the iWMMXt WMADDS instruction.
89 (UNSPEC_WMADDU 19) ; Used by the intrinsic form of the iWMMXt WMADDU instruction.
93 ;; UNSPEC_VOLATILE Usage:
96 [(VUNSPEC_BLOCKAGE 0) ; `blockage' insn to prevent scheduling across an
98 (VUNSPEC_EPILOGUE 1) ; `epilogue' insn, used to represent any part of the
99 ; instruction epilogue sequence that isn't expanded
100 ; into normal RTL. Used for both normal and sibcall
102 (VUNSPEC_ALIGN 2) ; `align' insn. Used at the head of a minipool table
103 ; for inlined constants.
104 (VUNSPEC_POOL_END 3) ; `end-of-table'. Used to mark the end of a minipool
106 (VUNSPEC_POOL_1 4) ; `pool-entry(1)'. An entry in the constant pool for
108 (VUNSPEC_POOL_2 5) ; `pool-entry(2)'. An entry in the constant pool for
110 (VUNSPEC_POOL_4 6) ; `pool-entry(4)'. An entry in the constant pool for
112 (VUNSPEC_POOL_8 7) ; `pool-entry(8)'. An entry in the constant pool for
114 (VUNSPEC_TMRC 8) ; Used by the iWMMXt TMRC instruction.
115 (VUNSPEC_TMCR 9) ; Used by the iWMMXt TMCR instruction.
116 (VUNSPEC_ALIGN8 10) ; 8-byte alignment version of VUNSPEC_ALIGN
117 (VUNSPEC_WCMP_EQ 11) ; Used by the iWMMXt WCMPEQ instructions
118 (VUNSPEC_WCMP_GTU 12) ; Used by the iWMMXt WCMPGTU instructions
119 (VUNSPEC_WCMP_GT 13) ; Used by the iwMMXT WCMPGT instructions
123 ;;---------------------------------------------------------------------------
126 ; IS_THUMB is set to 'yes' when we are generating Thumb code, and 'no' when
127 ; generating ARM code. This is used to control the length of some insn
128 ; patterns that share the same RTL in both ARM and Thumb code.
129 (define_attr "is_thumb" "no,yes" (const (symbol_ref "thumb_code")))
131 ; PROG_MODE attribute is used to determine whether condition codes are
132 ; clobbered by a call insn: they are if in prog32 mode. This is controlled
133 ; by the -mapcs-{32,26} flag, and possibly the -mcpu=... option.
134 (define_attr "prog_mode" "prog26,prog32" (const (symbol_ref "arm_prog_mode")))
136 ; IS_STRONGARM is set to 'yes' when compiling for StrongARM, it affects
137 ; scheduling decisions for the load unit and the multiplier.
138 (define_attr "is_strongarm" "no,yes" (const (symbol_ref "arm_is_strong")))
140 ;; Operand number of an input operand that is shifted. Zero if the
141 ;; given instruction does not shift one of its input operands.
142 (define_attr "is_xscale" "no,yes" (const (symbol_ref "arm_tune_xscale")))
143 (define_attr "shift" "" (const_int 0))
145 ; Floating Point Unit. If we only have floating point emulation, then there
146 ; is no point in scheduling the floating point insns. (Well, for best
147 ; performance we should try and group them together).
148 (define_attr "fpu" "softfpa,fpa,fpe2,fpe3,maverick"
149 (const (symbol_ref "arm_fpu_attr")))
151 ; LENGTH of an instruction (in bytes)
152 (define_attr "length" "" (const_int 4))
154 ; POOL_RANGE is how far away from a constant pool entry that this insn
155 ; can be placed. If the distance is zero, then this insn will never
156 ; reference the pool.
157 ; NEG_POOL_RANGE is nonzero for insns that can reference a constant pool entry
158 ; before its address.
159 (define_attr "pool_range" "" (const_int 0))
160 (define_attr "neg_pool_range" "" (const_int 0))
162 ; An assembler sequence may clobber the condition codes without us knowing.
163 ; If such an insn references the pool, then we have no way of knowing how,
164 ; so use the most conservative value for pool_range.
165 (define_asm_attributes
166 [(set_attr "conds" "clob")
167 (set_attr "length" "4")
168 (set_attr "pool_range" "250")])
170 ; TYPE attribute is used to detect floating point instructions which, if
171 ; running on a co-processor can run in parallel with other, basic instructions
172 ; If write-buffer scheduling is enabled then it can also be used in the
173 ; scheduling of writes.
175 ; Classification of each insn
176 ; normal any data instruction that doesn't hit memory or fp regs
177 ; mult a multiply instruction
178 ; block blockage insn, this blocks all functional units
179 ; float a floating point arithmetic operation (subject to expansion)
180 ; fdivd DFmode floating point division
181 ; fdivs SFmode floating point division
182 ; fmul Floating point multiply
183 ; ffmul Fast floating point multiply
184 ; farith Floating point arithmetic (4 cycle)
185 ; ffarith Fast floating point arithmetic (2 cycle)
186 ; float_em a floating point arithmetic operation that is normally emulated
187 ; even on a machine with an fpa.
188 ; f_load a floating point load from memory
189 ; f_store a floating point store to memory
190 ; f_mem_r a transfer of a floating point register to a real reg via mem
191 ; r_mem_f the reverse of f_mem_r
192 ; f_2_r fast transfer float to arm (no memory needed)
193 ; r_2_f fast transfer arm to float
194 ; call a subroutine call
195 ; load any load from memory
196 ; store1 store 1 word to memory from arm registers
197 ; store2 store 2 words
198 ; store3 store 3 words
199 ; store4 store 4 words
200 ; Additions for Cirrus Maverick co-processor:
201 ; mav_farith Floating point arithmetic (4 cycle)
202 ; mav_dmult Double multiplies (7 cycle)
205 "normal,mult,block,float,fdivx,fdivd,fdivs,fmul,ffmul,farith,ffarith,float_em,f_load,f_store,f_mem_r,r_mem_f,f_2_r,r_2_f,call,load,store1,store2,store3,store4,mav_farith,mav_dmult"
206 (const_string "normal"))
208 ; Load scheduling, set from the arm_ld_sched variable
209 ; initialized by arm_override_options()
210 (define_attr "ldsched" "no,yes" (const (symbol_ref "arm_ld_sched")))
212 ; condition codes: this one is used by final_prescan_insn to speed up
213 ; conditionalizing instructions. It saves having to scan the rtl to see if
214 ; it uses or alters the condition codes.
216 ; USE means that the condition codes are used by the insn in the process of
217 ; outputting code, this means (at present) that we can't use the insn in
220 ; SET means that the purpose of the insn is to set the condition codes in a
221 ; well defined manner.
223 ; CLOB means that the condition codes are altered in an undefined manner, if
224 ; they are altered at all
226 ; JUMP_CLOB is used when the condition cannot be represented by a single
227 ; instruction (UNEQ and LTGT). These cannot be predicated.
229 ; NOCOND means that the condition codes are neither altered nor affect the
230 ; output of this insn
232 (define_attr "conds" "use,set,clob,jump_clob,nocond"
233 (if_then_else (eq_attr "type" "call")
234 (if_then_else (eq_attr "prog_mode" "prog32")
235 (const_string "clob") (const_string "nocond"))
236 (const_string "nocond")))
238 ; Predicable means that the insn can be conditionally executed based on
239 ; an automatically added predicate (additional patterns are generated by
240 ; gen...). We default to 'no' because no Thumb patterns match this rule
241 ; and not all ARM patterns do.
242 (define_attr "predicable" "no,yes" (const_string "no"))
244 ; Only model the write buffer for ARM6 and ARM7. Earlier processors don't
245 ; have one. Later ones, such as StrongARM, have write-back caches, so don't
246 ; suffer blockages enough to warrant modelling this (and it can adversely
247 ; affect the schedule).
248 (define_attr "model_wbuf" "no,yes" (const (symbol_ref "arm_is_6_or_7")))
250 ; WRITE_CONFLICT implies that a read following an unrelated write is likely
251 ; to stall the processor. Used with model_wbuf above.
252 (define_attr "write_conflict" "no,yes"
253 (if_then_else (eq_attr "type"
254 "block,float_em,f_load,f_store,f_mem_r,r_mem_f,call,load")
256 (const_string "no")))
258 ; Classify the insns into those that take one cycle and those that take more
259 ; than one on the main cpu execution unit.
260 (define_attr "core_cycles" "single,multi"
261 (if_then_else (eq_attr "type"
262 "normal,float,fdivx,fdivd,fdivs,fmul,ffmul,farith,ffarith")
263 (const_string "single")
264 (const_string "multi")))
266 ;; FAR_JUMP is "yes" if a BL instruction is used to generate a branch to a
267 ;; distant label. Only applicable to Thumb code.
268 (define_attr "far_jump" "yes,no" (const_string "no"))
270 (define_automaton "arm")
274 ; Strictly, we should model a 4-deep write buffer for ARM7xx based chips
276 ; The write buffer on some of the arm6 processors is hard to model exactly.
277 ; There is room in the buffer for up to two addresses and up to eight words
278 ; of memory, but the two needn't be split evenly. When writing the two
279 ; addresses are fully pipelined. However, a read from memory that is not
280 ; currently in the cache will block until the writes have completed.
281 ; It is normally the case that FCLK and MCLK will be in the ratio 2:1, so
282 ; writes will take 2 FCLK cycles per word, if FCLK and MCLK are asynchronous
283 ; (they aren't allowed to be at present) then there is a startup cost of 1MCLK
284 ; cycle to add as well.
285 (define_cpu_unit "write_buf" "arm")
287 ;; Write blockage unit
289 ; The write_blockage unit models (partially), the fact that reads will stall
290 ; until the write buffer empties.
291 ; The f_mem_r and r_mem_f could also block, but they are to the stack,
292 ; so we don't model them here
293 (define_cpu_unit "write_blockage" "arm")
297 (define_cpu_unit "core" "arm")
299 (define_insn_reservation "r_mem_f_wbuf" 5
300 (and (eq_attr "model_wbuf" "yes")
301 (eq_attr "type" "r_mem_f"))
304 (define_insn_reservation "store1_wbuf" 5
305 (and (eq_attr "model_wbuf" "yes")
306 (eq_attr "type" "store1"))
307 "core+write_buf*3+write_blockage*5")
309 (define_insn_reservation "store2_wbuf" 7
310 (and (eq_attr "model_wbuf" "yes")
311 (eq_attr "type" "store2"))
312 "core+write_buf*4+write_blockage*7")
314 (define_insn_reservation "store3_wbuf" 9
315 (and (eq_attr "model_wbuf" "yes")
316 (eq_attr "type" "store3"))
317 "core+write_buf*5+write_blockage*9")
319 (define_insn_reservation "store4_wbuf" 11
320 (and (eq_attr "model_wbuf" "yes")
321 (eq_attr "type" "store4"))
322 "core+write_buf*6+write_blockage*11")
324 (define_insn_reservation "store2" 3
325 (and (eq_attr "model_wbuf" "no")
326 (eq_attr "type" "store2"))
329 (define_insn_reservation "store3" 4
330 (and (eq_attr "model_wbuf" "no")
331 (eq_attr "type" "store3"))
334 (define_insn_reservation "store4" 5
335 (and (eq_attr "model_wbuf" "no")
336 (eq_attr "type" "store4"))
339 (define_insn_reservation "store1_ldsched" 1
340 (and (eq_attr "ldsched" "yes") (eq_attr "type" "store1"))
343 (define_insn_reservation "load_ldsched_xscale" 3
344 (and (and (eq_attr "ldsched" "yes") (eq_attr "type" "load"))
345 (eq_attr "is_xscale" "yes"))
348 (define_insn_reservation "load_ldsched" 2
349 (and (and (eq_attr "ldsched" "yes") (eq_attr "type" "load"))
350 (eq_attr "is_xscale" "no"))
353 (define_insn_reservation "load_or_store" 2
354 (and (eq_attr "ldsched" "!yes") (eq_attr "type" "load,store1"))
357 (define_insn_reservation "mult" 16
358 (and (eq_attr "ldsched" "no") (eq_attr "type" "mult"))
361 (define_insn_reservation "mult_ldsched_strongarm" 3
362 (and (and (eq_attr "ldsched" "yes") (eq_attr "is_strongarm" "yes"))
363 (eq_attr "type" "mult"))
366 (define_insn_reservation "mult_ldsched" 4
367 (and (and (eq_attr "ldsched" "yes") (eq_attr "is_strongarm" "no"))
368 (eq_attr "type" "mult"))
371 (define_insn_reservation "multi_cycle" 32
372 (and (eq_attr "core_cycles" "multi")
373 (eq_attr "type" "!mult,load,store1,store2,store3,store4"))
376 (define_insn_reservation "single_cycle" 1
377 (eq_attr "core_cycles" "single")
381 ;;---------------------------------------------------------------------------
386 ;; Note: For DImode insns, there is normally no reason why operands should
387 ;; not be in the same register, what we don't want is for something being
388 ;; written to partially overlap something that is an input.
389 ;; Cirrus 64bit additions should not be split because we have a native
390 ;; 64bit addition instructions.
392 (define_expand "adddi3"
394 [(set (match_operand:DI 0 "s_register_operand" "")
395 (plus:DI (match_operand:DI 1 "s_register_operand" "")
396 (match_operand:DI 2 "s_register_operand" "")))
397 (clobber (reg:CC CC_REGNUM))])]
402 if (!cirrus_fp_register (operands[0], DImode))
403 operands[0] = force_reg (DImode, operands[0]);
404 if (!cirrus_fp_register (operands[1], DImode))
405 operands[1] = force_reg (DImode, operands[1]);
406 emit_insn (gen_cirrus_adddi3 (operands[0], operands[1], operands[2]));
412 if (GET_CODE (operands[1]) != REG)
413 operands[1] = force_reg (SImode, operands[1]);
414 if (GET_CODE (operands[2]) != REG)
415 operands[2] = force_reg (SImode, operands[2]);
420 (define_insn "*thumb_adddi3"
421 [(set (match_operand:DI 0 "register_operand" "=l")
422 (plus:DI (match_operand:DI 1 "register_operand" "%0")
423 (match_operand:DI 2 "register_operand" "l")))
424 (clobber (reg:CC CC_REGNUM))
427 "add\\t%Q0, %Q0, %Q2\;adc\\t%R0, %R0, %R2"
428 [(set_attr "length" "4")]
431 (define_insn_and_split "*arm_adddi3"
432 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
433 (plus:DI (match_operand:DI 1 "s_register_operand" "%0, 0")
434 (match_operand:DI 2 "s_register_operand" "r, 0")))
435 (clobber (reg:CC CC_REGNUM))]
436 "TARGET_ARM && !TARGET_CIRRUS"
438 "TARGET_ARM && reload_completed"
439 [(parallel [(set (reg:CC_C CC_REGNUM)
440 (compare:CC_C (plus:SI (match_dup 1) (match_dup 2))
442 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))])
443 (set (match_dup 3) (plus:SI (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))
444 (plus:SI (match_dup 4) (match_dup 5))))]
447 operands[3] = gen_highpart (SImode, operands[0]);
448 operands[0] = gen_lowpart (SImode, operands[0]);
449 operands[4] = gen_highpart (SImode, operands[1]);
450 operands[1] = gen_lowpart (SImode, operands[1]);
451 operands[5] = gen_highpart (SImode, operands[2]);
452 operands[2] = gen_lowpart (SImode, operands[2]);
454 [(set_attr "conds" "clob")
455 (set_attr "length" "8")]
458 (define_insn_and_split "*adddi_sesidi_di"
459 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
460 (plus:DI (sign_extend:DI
461 (match_operand:SI 2 "s_register_operand" "r,r"))
462 (match_operand:DI 1 "s_register_operand" "r,0")))
463 (clobber (reg:CC CC_REGNUM))]
464 "TARGET_ARM && !TARGET_CIRRUS"
466 "TARGET_ARM && reload_completed"
467 [(parallel [(set (reg:CC_C CC_REGNUM)
468 (compare:CC_C (plus:SI (match_dup 1) (match_dup 2))
470 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))])
471 (set (match_dup 3) (plus:SI (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))
472 (plus:SI (ashiftrt:SI (match_dup 2)
477 operands[3] = gen_highpart (SImode, operands[0]);
478 operands[0] = gen_lowpart (SImode, operands[0]);
479 operands[4] = gen_highpart (SImode, operands[1]);
480 operands[1] = gen_lowpart (SImode, operands[1]);
481 operands[2] = gen_lowpart (SImode, operands[2]);
483 [(set_attr "conds" "clob")
484 (set_attr "length" "8")]
487 (define_insn_and_split "*adddi_zesidi_di"
488 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
489 (plus:DI (zero_extend:DI
490 (match_operand:SI 2 "s_register_operand" "r,r"))
491 (match_operand:DI 1 "s_register_operand" "r,0")))
492 (clobber (reg:CC CC_REGNUM))]
493 "TARGET_ARM && !TARGET_CIRRUS"
495 "TARGET_ARM && reload_completed"
496 [(parallel [(set (reg:CC_C CC_REGNUM)
497 (compare:CC_C (plus:SI (match_dup 1) (match_dup 2))
499 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))])
500 (set (match_dup 3) (plus:SI (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))
501 (plus:SI (match_dup 4) (const_int 0))))]
504 operands[3] = gen_highpart (SImode, operands[0]);
505 operands[0] = gen_lowpart (SImode, operands[0]);
506 operands[4] = gen_highpart (SImode, operands[1]);
507 operands[1] = gen_lowpart (SImode, operands[1]);
508 operands[2] = gen_lowpart (SImode, operands[2]);
510 [(set_attr "conds" "clob")
511 (set_attr "length" "8")]
514 (define_expand "addsi3"
515 [(set (match_operand:SI 0 "s_register_operand" "")
516 (plus:SI (match_operand:SI 1 "s_register_operand" "")
517 (match_operand:SI 2 "reg_or_int_operand" "")))]
520 if (TARGET_ARM && GET_CODE (operands[2]) == CONST_INT)
522 arm_split_constant (PLUS, SImode, INTVAL (operands[2]), operands[0],
524 (no_new_pseudos ? 0 : preserve_subexpressions_p ()));
530 ; If there is a scratch available, this will be faster than synthesizing the
533 [(match_scratch:SI 3 "r")
534 (set (match_operand:SI 0 "s_register_operand" "")
535 (plus:SI (match_operand:SI 1 "s_register_operand" "")
536 (match_operand:SI 2 "const_int_operand" "")))]
538 !(const_ok_for_arm (INTVAL (operands[2]))
539 || const_ok_for_arm (-INTVAL (operands[2])))
540 && const_ok_for_arm (~INTVAL (operands[2]))"
541 [(set (match_dup 3) (match_dup 2))
542 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))]
546 (define_insn_and_split "*arm_addsi3"
547 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
548 (plus:SI (match_operand:SI 1 "s_register_operand" "%r,r,r")
549 (match_operand:SI 2 "reg_or_int_operand" "rI,L,?n")))]
556 GET_CODE (operands[2]) == CONST_INT
557 && !(const_ok_for_arm (INTVAL (operands[2]))
558 || const_ok_for_arm (-INTVAL (operands[2])))"
559 [(clobber (const_int 0))]
561 arm_split_constant (PLUS, SImode, INTVAL (operands[2]), operands[0],
565 [(set_attr "length" "4,4,16")
566 (set_attr "predicable" "yes")]
569 ;; Register group 'k' is a single register group containing only the stack
570 ;; register. Trying to reload it will always fail catastrophically,
571 ;; so never allow those alternatives to match if reloading is needed.
573 (define_insn "*thumb_addsi3"
574 [(set (match_operand:SI 0 "register_operand" "=l,l,l,*r,*h,l,!k")
575 (plus:SI (match_operand:SI 1 "register_operand" "%0,0,l,*0,*0,!k,!k")
576 (match_operand:SI 2 "nonmemory_operand" "I,J,lL,*h,*r,!M,!O")))]
579 static const char * const asms[] =
581 \"add\\t%0, %0, %2\",
582 \"sub\\t%0, %0, #%n2\",
583 \"add\\t%0, %1, %2\",
584 \"add\\t%0, %0, %2\",
585 \"add\\t%0, %0, %2\",
586 \"add\\t%0, %1, %2\",
589 if ((which_alternative == 2 || which_alternative == 6)
590 && GET_CODE (operands[2]) == CONST_INT
591 && INTVAL (operands[2]) < 0)
592 return \"sub\\t%0, %1, #%n2\";
593 return asms[which_alternative];
595 [(set_attr "length" "2")]
598 ;; Reloading and elimination of the frame pointer can
599 ;; sometimes cause this optimization to be missed.
601 [(set (match_operand:SI 0 "register_operand" "")
602 (match_operand:SI 1 "const_int_operand" ""))
604 (plus:SI (match_dup 0) (match_operand:SI 2 "register_operand" "")))]
606 && REGNO (operands[2]) == STACK_POINTER_REGNUM
607 && (unsigned HOST_WIDE_INT) (INTVAL (operands[1])) < 1024
608 && (INTVAL (operands[1]) & 3) == 0"
609 [(set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
613 (define_insn "*addsi3_compare0"
614 [(set (reg:CC_NOOV CC_REGNUM)
616 (plus:SI (match_operand:SI 1 "s_register_operand" "r, r")
617 (match_operand:SI 2 "arm_add_operand" "rI,L"))
619 (set (match_operand:SI 0 "s_register_operand" "=r,r")
620 (plus:SI (match_dup 1) (match_dup 2)))]
624 sub%?s\\t%0, %1, #%n2"
625 [(set_attr "conds" "set")]
628 (define_insn "*addsi3_compare0_scratch"
629 [(set (reg:CC_NOOV CC_REGNUM)
631 (plus:SI (match_operand:SI 0 "s_register_operand" "r, r")
632 (match_operand:SI 1 "arm_add_operand" "rI,L"))
638 [(set_attr "conds" "set")]
641 ;; These patterns are the same ones as the two regular addsi3_compare0
642 ;; patterns, except we write them slightly different - the combiner
643 ;; tends to generate them this way.
644 (define_insn "*addsi3_compare0_for_combiner"
645 [(set (reg:CC CC_REGNUM)
647 (match_operand:SI 1 "s_register_operand" "r,r")
648 (neg:SI (match_operand:SI 2 "arm_add_operand" "rI,L"))))
649 (set (match_operand:SI 0 "s_register_operand" "=r,r")
650 (plus:SI (match_dup 1) (match_dup 2)))]
654 sub%?s\\t%0, %1, #%n2"
655 [(set_attr "conds" "set")]
658 (define_insn "*addsi3_compare0_scratch_for_combiner"
659 [(set (reg:CC CC_REGNUM)
661 (match_operand:SI 0 "s_register_operand" "r,r")
662 (neg:SI (match_operand:SI 1 "arm_add_operand" "rI,L"))))]
667 [(set_attr "conds" "set")]
670 ;; This is the canonicalization of addsi3_compare0_for_combiner when the
671 ;; addend is a constant.
672 (define_insn "*cmpsi2_addneg"
673 [(set (reg:CC CC_REGNUM)
675 (match_operand:SI 1 "s_register_operand" "r,r")
676 (match_operand:SI 2 "arm_addimm_operand" "I,L")))
677 (set (match_operand:SI 0 "s_register_operand" "=r,r")
678 (plus:SI (match_dup 1)
679 (match_operand:SI 3 "arm_addimm_operand" "L,I")))]
680 "TARGET_ARM && INTVAL (operands[2]) == -INTVAL (operands[3])"
683 add%?s\\t%0, %1, #%n2"
684 [(set_attr "conds" "set")]
687 ;; Convert the sequence
689 ;; cmn rd, #1 (equivalent to cmp rd, #-1)
693 ;; bcs dest ((unsigned)rn >= 1)
694 ;; similarly for the beq variant using bcc.
695 ;; This is a common looping idiom (while (n--))
697 [(set (match_operand:SI 0 "s_register_operand" "")
698 (plus:SI (match_operand:SI 1 "s_register_operand" "")
700 (set (match_operand 2 "cc_register" "")
701 (compare (match_dup 0) (const_int -1)))
703 (if_then_else (match_operator 3 "equality_operator"
704 [(match_dup 2) (const_int 0)])
705 (match_operand 4 "" "")
706 (match_operand 5 "" "")))]
707 "TARGET_ARM && peep2_reg_dead_p (3, operands[2])"
711 (match_dup 1) (const_int 1)))
712 (set (match_dup 0) (plus:SI (match_dup 1) (const_int -1)))])
714 (if_then_else (match_op_dup 3 [(match_dup 2) (const_int 0)])
717 "operands[2] = gen_rtx_REG (CCmode, CC_REGNUM);
718 operands[3] = gen_rtx_fmt_ee ((GET_CODE (operands[3]) == NE
721 operands[2], const0_rtx);"
724 ;; The next four insns work because they compare the result with one of
725 ;; the operands, and we know that the use of the condition code is
726 ;; either GEU or LTU, so we can use the carry flag from the addition
727 ;; instead of doing the compare a second time.
728 (define_insn "*addsi3_compare_op1"
729 [(set (reg:CC_C CC_REGNUM)
731 (plus:SI (match_operand:SI 1 "s_register_operand" "r,r")
732 (match_operand:SI 2 "arm_add_operand" "rI,L"))
734 (set (match_operand:SI 0 "s_register_operand" "=r,r")
735 (plus:SI (match_dup 1) (match_dup 2)))]
739 sub%?s\\t%0, %1, #%n2"
740 [(set_attr "conds" "set")]
743 (define_insn "*addsi3_compare_op2"
744 [(set (reg:CC_C CC_REGNUM)
746 (plus:SI (match_operand:SI 1 "s_register_operand" "r,r")
747 (match_operand:SI 2 "arm_add_operand" "rI,L"))
749 (set (match_operand:SI 0 "s_register_operand" "=r,r")
750 (plus:SI (match_dup 1) (match_dup 2)))]
754 sub%?s\\t%0, %1, #%n2"
755 [(set_attr "conds" "set")]
758 (define_insn "*compare_addsi2_op0"
759 [(set (reg:CC_C CC_REGNUM)
761 (plus:SI (match_operand:SI 0 "s_register_operand" "r,r")
762 (match_operand:SI 1 "arm_add_operand" "rI,L"))
768 [(set_attr "conds" "set")]
771 (define_insn "*compare_addsi2_op1"
772 [(set (reg:CC_C CC_REGNUM)
774 (plus:SI (match_operand:SI 0 "s_register_operand" "r,r")
775 (match_operand:SI 1 "arm_add_operand" "rI,L"))
781 [(set_attr "conds" "set")]
784 (define_insn "*addsi3_carryin"
785 [(set (match_operand:SI 0 "s_register_operand" "=r")
786 (plus:SI (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))
787 (plus:SI (match_operand:SI 1 "s_register_operand" "r")
788 (match_operand:SI 2 "arm_rhs_operand" "rI"))))]
791 [(set_attr "conds" "use")]
794 (define_insn "*addsi3_carryin_shift"
795 [(set (match_operand:SI 0 "s_register_operand" "")
796 (plus:SI (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))
798 (match_operator:SI 2 "shift_operator"
799 [(match_operand:SI 3 "s_register_operand" "")
800 (match_operand:SI 4 "reg_or_int_operand" "")])
801 (match_operand:SI 1 "s_register_operand" ""))))]
803 "adc%?\\t%0, %1, %3%S2"
804 [(set_attr "conds" "use")]
807 (define_insn "*addsi3_carryin_alt1"
808 [(set (match_operand:SI 0 "s_register_operand" "=r")
809 (plus:SI (plus:SI (match_operand:SI 1 "s_register_operand" "r")
810 (match_operand:SI 2 "arm_rhs_operand" "rI"))
811 (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))))]
814 [(set_attr "conds" "use")]
817 (define_insn "*addsi3_carryin_alt2"
818 [(set (match_operand:SI 0 "s_register_operand" "=r")
819 (plus:SI (plus:SI (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))
820 (match_operand:SI 1 "s_register_operand" "r"))
821 (match_operand:SI 2 "arm_rhs_operand" "rI")))]
824 [(set_attr "conds" "use")]
827 (define_insn "*addsi3_carryin_alt3"
828 [(set (match_operand:SI 0 "s_register_operand" "=r")
829 (plus:SI (plus:SI (ltu:SI (reg:CC_C CC_REGNUM) (const_int 0))
830 (match_operand:SI 2 "arm_rhs_operand" "rI"))
831 (match_operand:SI 1 "s_register_operand" "r")))]
834 [(set_attr "conds" "use")]
837 (define_insn "incscc"
838 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
839 (plus:SI (match_operator:SI 2 "arm_comparison_operator"
840 [(match_operand:CC 3 "cc_register" "") (const_int 0)])
841 (match_operand:SI 1 "s_register_operand" "0,?r")))]
845 mov%D2\\t%0, %1\;add%d2\\t%0, %1, #1"
846 [(set_attr "conds" "use")
847 (set_attr "length" "4,8")]
850 (define_expand "addsf3"
851 [(set (match_operand:SF 0 "s_register_operand" "")
852 (plus:SF (match_operand:SF 1 "s_register_operand" "")
853 (match_operand:SF 2 "fpa_add_operand" "")))]
854 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
857 && !cirrus_fp_register (operands[2], SFmode))
858 operands[2] = force_reg (SFmode, operands[2]);
861 (define_expand "adddf3"
862 [(set (match_operand:DF 0 "s_register_operand" "")
863 (plus:DF (match_operand:DF 1 "s_register_operand" "")
864 (match_operand:DF 2 "fpa_add_operand" "")))]
865 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
868 && !cirrus_fp_register (operands[2], DFmode))
869 operands[2] = force_reg (DFmode, operands[2]);
872 (define_expand "subdi3"
874 [(set (match_operand:DI 0 "s_register_operand" "")
875 (minus:DI (match_operand:DI 1 "s_register_operand" "")
876 (match_operand:DI 2 "s_register_operand" "")))
877 (clobber (reg:CC CC_REGNUM))])]
882 && cirrus_fp_register (operands[0], DImode)
883 && cirrus_fp_register (operands[1], DImode))
885 emit_insn (gen_cirrus_subdi3 (operands[0], operands[1], operands[2]));
891 if (GET_CODE (operands[1]) != REG)
892 operands[1] = force_reg (SImode, operands[1]);
893 if (GET_CODE (operands[2]) != REG)
894 operands[2] = force_reg (SImode, operands[2]);
899 (define_insn "*arm_subdi3"
900 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r,&r")
901 (minus:DI (match_operand:DI 1 "s_register_operand" "0,r,0")
902 (match_operand:DI 2 "s_register_operand" "r,0,0")))
903 (clobber (reg:CC CC_REGNUM))]
905 "subs\\t%Q0, %Q1, %Q2\;sbc\\t%R0, %R1, %R2"
906 [(set_attr "conds" "clob")
907 (set_attr "length" "8")]
910 (define_insn "*thumb_subdi3"
911 [(set (match_operand:DI 0 "register_operand" "=l")
912 (minus:DI (match_operand:DI 1 "register_operand" "0")
913 (match_operand:DI 2 "register_operand" "l")))
914 (clobber (reg:CC CC_REGNUM))]
916 "sub\\t%Q0, %Q0, %Q2\;sbc\\t%R0, %R0, %R2"
917 [(set_attr "length" "4")]
920 (define_insn "*subdi_di_zesidi"
921 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
922 (minus:DI (match_operand:DI 1 "s_register_operand" "?r,0")
924 (match_operand:SI 2 "s_register_operand" "r,r"))))
925 (clobber (reg:CC CC_REGNUM))]
927 "subs\\t%Q0, %Q1, %2\;sbc\\t%R0, %R1, #0"
928 [(set_attr "conds" "clob")
929 (set_attr "length" "8")]
932 (define_insn "*subdi_di_sesidi"
933 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
934 (minus:DI (match_operand:DI 1 "s_register_operand" "r,0")
936 (match_operand:SI 2 "s_register_operand" "r,r"))))
937 (clobber (reg:CC CC_REGNUM))]
939 "subs\\t%Q0, %Q1, %2\;sbc\\t%R0, %R1, %2, asr #31"
940 [(set_attr "conds" "clob")
941 (set_attr "length" "8")]
944 (define_insn "*subdi_zesidi_di"
945 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
946 (minus:DI (zero_extend:DI
947 (match_operand:SI 2 "s_register_operand" "r,r"))
948 (match_operand:DI 1 "s_register_operand" "?r,0")))
949 (clobber (reg:CC CC_REGNUM))]
951 "rsbs\\t%Q0, %Q1, %2\;rsc\\t%R0, %R1, #0"
952 [(set_attr "conds" "clob")
953 (set_attr "length" "8")]
956 (define_insn "*subdi_sesidi_di"
957 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
958 (minus:DI (sign_extend:DI
959 (match_operand:SI 2 "s_register_operand" "r,r"))
960 (match_operand:DI 1 "s_register_operand" "?r,0")))
961 (clobber (reg:CC CC_REGNUM))]
963 "rsbs\\t%Q0, %Q1, %2\;rsc\\t%R0, %R1, %2, asr #31"
964 [(set_attr "conds" "clob")
965 (set_attr "length" "8")]
968 (define_insn "*subdi_zesidi_zesidi"
969 [(set (match_operand:DI 0 "s_register_operand" "=r")
970 (minus:DI (zero_extend:DI
971 (match_operand:SI 1 "s_register_operand" "r"))
973 (match_operand:SI 2 "s_register_operand" "r"))))
974 (clobber (reg:CC CC_REGNUM))]
976 "subs\\t%Q0, %1, %2\;rsc\\t%R0, %1, %1"
977 [(set_attr "conds" "clob")
978 (set_attr "length" "8")]
981 (define_expand "subsi3"
982 [(set (match_operand:SI 0 "s_register_operand" "")
983 (minus:SI (match_operand:SI 1 "reg_or_int_operand" "")
984 (match_operand:SI 2 "s_register_operand" "")))]
987 if (GET_CODE (operands[1]) == CONST_INT)
991 arm_split_constant (MINUS, SImode, INTVAL (operands[1]), operands[0],
994 : preserve_subexpressions_p ()));
997 else /* TARGET_THUMB */
998 operands[1] = force_reg (SImode, operands[1]);
1003 (define_insn "*thumb_subsi3_insn"
1004 [(set (match_operand:SI 0 "register_operand" "=l")
1005 (minus:SI (match_operand:SI 1 "register_operand" "l")
1006 (match_operand:SI 2 "register_operand" "l")))]
1009 [(set_attr "length" "2")]
1012 (define_insn_and_split "*arm_subsi3_insn"
1013 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
1014 (minus:SI (match_operand:SI 1 "reg_or_int_operand" "rI,?n")
1015 (match_operand:SI 2 "s_register_operand" "r,r")))]
1021 && GET_CODE (operands[1]) == CONST_INT
1022 && !const_ok_for_arm (INTVAL (operands[1]))"
1023 [(clobber (const_int 0))]
1025 arm_split_constant (MINUS, SImode, INTVAL (operands[1]), operands[0],
1029 [(set_attr "length" "4,16")
1030 (set_attr "predicable" "yes")]
1034 [(match_scratch:SI 3 "r")
1035 (set (match_operand:SI 0 "s_register_operand" "")
1036 (minus:SI (match_operand:SI 1 "const_int_operand" "")
1037 (match_operand:SI 2 "s_register_operand" "")))]
1039 && !const_ok_for_arm (INTVAL (operands[1]))
1040 && const_ok_for_arm (~INTVAL (operands[1]))"
1041 [(set (match_dup 3) (match_dup 1))
1042 (set (match_dup 0) (minus:SI (match_dup 3) (match_dup 2)))]
1046 (define_insn "*subsi3_compare0"
1047 [(set (reg:CC_NOOV CC_REGNUM)
1049 (minus:SI (match_operand:SI 1 "arm_rhs_operand" "r,I")
1050 (match_operand:SI 2 "arm_rhs_operand" "rI,r"))
1052 (set (match_operand:SI 0 "s_register_operand" "=r,r")
1053 (minus:SI (match_dup 1) (match_dup 2)))]
1057 rsb%?s\\t%0, %2, %1"
1058 [(set_attr "conds" "set")]
1061 (define_insn "decscc"
1062 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
1063 (minus:SI (match_operand:SI 1 "s_register_operand" "0,?r")
1064 (match_operator:SI 2 "arm_comparison_operator"
1065 [(match_operand 3 "cc_register" "") (const_int 0)])))]
1069 mov%D2\\t%0, %1\;sub%d2\\t%0, %1, #1"
1070 [(set_attr "conds" "use")
1071 (set_attr "length" "*,8")]
1074 (define_expand "subsf3"
1075 [(set (match_operand:SF 0 "s_register_operand" "")
1076 (minus:SF (match_operand:SF 1 "fpa_rhs_operand" "")
1077 (match_operand:SF 2 "fpa_rhs_operand" "")))]
1078 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
1082 if (!cirrus_fp_register (operands[1], SFmode))
1083 operands[1] = force_reg (SFmode, operands[1]);
1084 if (!cirrus_fp_register (operands[2], SFmode))
1085 operands[2] = force_reg (SFmode, operands[2]);
1089 (define_expand "subdf3"
1090 [(set (match_operand:DF 0 "s_register_operand" "")
1091 (minus:DF (match_operand:DF 1 "fpa_rhs_operand" "")
1092 (match_operand:DF 2 "fpa_rhs_operand" "")))]
1093 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
1097 if (!cirrus_fp_register (operands[1], DFmode))
1098 operands[1] = force_reg (DFmode, operands[1]);
1099 if (!cirrus_fp_register (operands[2], DFmode))
1100 operands[2] = force_reg (DFmode, operands[2]);
1105 ;; Multiplication insns
1107 (define_expand "mulsi3"
1108 [(set (match_operand:SI 0 "s_register_operand" "")
1109 (mult:SI (match_operand:SI 2 "s_register_operand" "")
1110 (match_operand:SI 1 "s_register_operand" "")))]
1115 ;; Use `&' and then `0' to prevent the operands 0 and 1 being the same
1116 (define_insn "*arm_mulsi3"
1117 [(set (match_operand:SI 0 "s_register_operand" "=&r,&r")
1118 (mult:SI (match_operand:SI 2 "s_register_operand" "r,r")
1119 (match_operand:SI 1 "s_register_operand" "%?r,0")))]
1121 "mul%?\\t%0, %2, %1"
1122 [(set_attr "type" "mult")
1123 (set_attr "predicable" "yes")]
1126 ; Unfortunately with the Thumb the '&'/'0' trick can fails when operands
1127 ; 1 and 2; are the same, because reload will make operand 0 match
1128 ; operand 1 without realizing that this conflicts with operand 2. We fix
1129 ; this by adding another alternative to match this case, and then `reload'
1130 ; it ourselves. This alternative must come first.
1131 (define_insn "*thumb_mulsi3"
1132 [(set (match_operand:SI 0 "register_operand" "=&l,&l,&l")
1133 (mult:SI (match_operand:SI 1 "register_operand" "%l,*h,0")
1134 (match_operand:SI 2 "register_operand" "l,l,l")))]
1137 if (which_alternative < 2)
1138 return \"mov\\t%0, %1\;mul\\t%0, %0, %2\";
1140 return \"mul\\t%0, %0, %2\";
1142 [(set_attr "length" "4,4,2")
1143 (set_attr "type" "mult")]
1146 (define_insn "*mulsi3_compare0"
1147 [(set (reg:CC_NOOV CC_REGNUM)
1148 (compare:CC_NOOV (mult:SI
1149 (match_operand:SI 2 "s_register_operand" "r,r")
1150 (match_operand:SI 1 "s_register_operand" "%?r,0"))
1152 (set (match_operand:SI 0 "s_register_operand" "=&r,&r")
1153 (mult:SI (match_dup 2) (match_dup 1)))]
1154 "TARGET_ARM && !arm_arch_xscale"
1155 "mul%?s\\t%0, %2, %1"
1156 [(set_attr "conds" "set")
1157 (set_attr "type" "mult")]
1160 (define_insn "*mulsi_compare0_scratch"
1161 [(set (reg:CC_NOOV CC_REGNUM)
1162 (compare:CC_NOOV (mult:SI
1163 (match_operand:SI 2 "s_register_operand" "r,r")
1164 (match_operand:SI 1 "s_register_operand" "%?r,0"))
1166 (clobber (match_scratch:SI 0 "=&r,&r"))]
1167 "TARGET_ARM && !arm_arch_xscale"
1168 "mul%?s\\t%0, %2, %1"
1169 [(set_attr "conds" "set")
1170 (set_attr "type" "mult")]
1173 ;; Unnamed templates to match MLA instruction.
1175 (define_insn "*mulsi3addsi"
1176 [(set (match_operand:SI 0 "s_register_operand" "=&r,&r,&r,&r")
1178 (mult:SI (match_operand:SI 2 "s_register_operand" "r,r,r,r")
1179 (match_operand:SI 1 "s_register_operand" "%r,0,r,0"))
1180 (match_operand:SI 3 "s_register_operand" "?r,r,0,0")))]
1182 "mla%?\\t%0, %2, %1, %3"
1183 [(set_attr "type" "mult")
1184 (set_attr "predicable" "yes")]
1187 (define_insn "*mulsi3addsi_compare0"
1188 [(set (reg:CC_NOOV CC_REGNUM)
1191 (match_operand:SI 2 "s_register_operand" "r,r,r,r")
1192 (match_operand:SI 1 "s_register_operand" "%r,0,r,0"))
1193 (match_operand:SI 3 "s_register_operand" "?r,r,0,0"))
1195 (set (match_operand:SI 0 "s_register_operand" "=&r,&r,&r,&r")
1196 (plus:SI (mult:SI (match_dup 2) (match_dup 1))
1198 "TARGET_ARM && !arm_arch_xscale"
1199 "mla%?s\\t%0, %2, %1, %3"
1200 [(set_attr "conds" "set")
1201 (set_attr "type" "mult")]
1204 (define_insn "*mulsi3addsi_compare0_scratch"
1205 [(set (reg:CC_NOOV CC_REGNUM)
1208 (match_operand:SI 2 "s_register_operand" "r,r,r,r")
1209 (match_operand:SI 1 "s_register_operand" "%r,0,r,0"))
1210 (match_operand:SI 3 "s_register_operand" "?r,r,0,0"))
1212 (clobber (match_scratch:SI 0 "=&r,&r,&r,&r"))]
1213 "TARGET_ARM && !arm_arch_xscale"
1214 "mla%?s\\t%0, %2, %1, %3"
1215 [(set_attr "conds" "set")
1216 (set_attr "type" "mult")]
1219 ;; Unnamed template to match long long multiply-accumlate (smlal)
1221 (define_insn "*mulsidi3adddi"
1222 [(set (match_operand:DI 0 "s_register_operand" "=&r")
1225 (sign_extend:DI (match_operand:SI 2 "s_register_operand" "%r"))
1226 (sign_extend:DI (match_operand:SI 3 "s_register_operand" "r")))
1227 (match_operand:DI 1 "s_register_operand" "0")))]
1228 "TARGET_ARM && arm_fast_multiply"
1229 "smlal%?\\t%Q0, %R0, %3, %2"
1230 [(set_attr "type" "mult")
1231 (set_attr "predicable" "yes")]
1234 (define_insn "mulsidi3"
1235 [(set (match_operand:DI 0 "s_register_operand" "=&r")
1237 (sign_extend:DI (match_operand:SI 1 "s_register_operand" "%r"))
1238 (sign_extend:DI (match_operand:SI 2 "s_register_operand" "r"))))]
1239 "TARGET_ARM && arm_fast_multiply"
1240 "smull%?\\t%Q0, %R0, %1, %2"
1241 [(set_attr "type" "mult")
1242 (set_attr "predicable" "yes")]
1245 (define_insn "umulsidi3"
1246 [(set (match_operand:DI 0 "s_register_operand" "=&r")
1248 (zero_extend:DI (match_operand:SI 1 "s_register_operand" "%r"))
1249 (zero_extend:DI (match_operand:SI 2 "s_register_operand" "r"))))]
1250 "TARGET_ARM && arm_fast_multiply"
1251 "umull%?\\t%Q0, %R0, %1, %2"
1252 [(set_attr "type" "mult")
1253 (set_attr "predicable" "yes")]
1256 ;; Unnamed template to match long long unsigned multiply-accumlate (umlal)
1258 (define_insn "*umulsidi3adddi"
1259 [(set (match_operand:DI 0 "s_register_operand" "=&r")
1262 (zero_extend:DI (match_operand:SI 2 "s_register_operand" "%r"))
1263 (zero_extend:DI (match_operand:SI 3 "s_register_operand" "r")))
1264 (match_operand:DI 1 "s_register_operand" "0")))]
1265 "TARGET_ARM && arm_fast_multiply"
1266 "umlal%?\\t%Q0, %R0, %3, %2"
1267 [(set_attr "type" "mult")
1268 (set_attr "predicable" "yes")]
1271 (define_insn "smulsi3_highpart"
1272 [(set (match_operand:SI 0 "s_register_operand" "=&r,&r")
1276 (sign_extend:DI (match_operand:SI 1 "s_register_operand" "%r,0"))
1277 (sign_extend:DI (match_operand:SI 2 "s_register_operand" "r,r")))
1279 (clobber (match_scratch:SI 3 "=&r,&r"))]
1280 "TARGET_ARM && arm_fast_multiply"
1281 "smull%?\\t%3, %0, %2, %1"
1282 [(set_attr "type" "mult")
1283 (set_attr "predicable" "yes")]
1286 (define_insn "umulsi3_highpart"
1287 [(set (match_operand:SI 0 "s_register_operand" "=&r,&r")
1291 (zero_extend:DI (match_operand:SI 1 "s_register_operand" "%r,0"))
1292 (zero_extend:DI (match_operand:SI 2 "s_register_operand" "r,r")))
1294 (clobber (match_scratch:SI 3 "=&r,&r"))]
1295 "TARGET_ARM && arm_fast_multiply"
1296 "umull%?\\t%3, %0, %2, %1"
1297 [(set_attr "type" "mult")
1298 (set_attr "predicable" "yes")]
1301 (define_insn "mulhisi3"
1302 [(set (match_operand:SI 0 "s_register_operand" "=r")
1303 (mult:SI (sign_extend:SI
1304 (match_operand:HI 1 "s_register_operand" "%r"))
1306 (match_operand:HI 2 "s_register_operand" "r"))))]
1307 "TARGET_ARM && arm_arch5e"
1308 "smulbb%?\\t%0, %1, %2"
1309 [(set_attr "type" "mult")
1310 (set_attr "predicable" "yes")]
1313 (define_insn "*mulhisi3tb"
1314 [(set (match_operand:SI 0 "s_register_operand" "=r")
1315 (mult:SI (ashiftrt:SI
1316 (match_operand:SI 1 "s_register_operand" "r")
1319 (match_operand:HI 2 "s_register_operand" "r"))))]
1320 "TARGET_ARM && arm_arch5e"
1321 "smultb%?\\t%0, %1, %2"
1322 [(set_attr "type" "mult")
1323 (set_attr "predicable" "yes")]
1326 (define_insn "*mulhisi3bt"
1327 [(set (match_operand:SI 0 "s_register_operand" "=r")
1328 (mult:SI (sign_extend:SI
1329 (match_operand:HI 1 "s_register_operand" "r"))
1331 (match_operand:SI 2 "s_register_operand" "r")
1333 "TARGET_ARM && arm_arch5e"
1334 "smulbt%?\\t%0, %1, %2"
1335 [(set_attr "type" "mult")
1336 (set_attr "predicable" "yes")]
1339 (define_insn "*mulhisi3tt"
1340 [(set (match_operand:SI 0 "s_register_operand" "=r")
1341 (mult:SI (ashiftrt:SI
1342 (match_operand:SI 1 "s_register_operand" "r")
1345 (match_operand:SI 2 "s_register_operand" "r")
1347 "TARGET_ARM && arm_arch5e"
1348 "smultt%?\\t%0, %1, %2"
1349 [(set_attr "type" "mult")
1350 (set_attr "predicable" "yes")]
1353 (define_insn "*mulhisi3addsi"
1354 [(set (match_operand:SI 0 "s_register_operand" "=r")
1355 (plus:SI (match_operand:SI 1 "s_register_operand" "r")
1356 (mult:SI (sign_extend:SI
1357 (match_operand:HI 2 "s_register_operand" "%r"))
1359 (match_operand:HI 3 "s_register_operand" "r")))))]
1360 "TARGET_ARM && arm_arch5e"
1361 "smlabb%?\\t%0, %2, %3, %1"
1362 [(set_attr "type" "mult")
1363 (set_attr "predicable" "yes")]
1366 (define_insn "*mulhidi3adddi"
1367 [(set (match_operand:DI 0 "s_register_operand" "=r")
1369 (match_operand:DI 1 "s_register_operand" "0")
1370 (mult:DI (sign_extend:DI
1371 (match_operand:HI 2 "s_register_operand" "%r"))
1373 (match_operand:HI 3 "s_register_operand" "r")))))]
1374 "TARGET_ARM && arm_arch5e"
1375 "smlalbb%?\\t%Q0, %R0, %2, %3"
1376 [(set_attr "type" "mult")
1377 (set_attr "predicable" "yes")])
1379 (define_expand "mulsf3"
1380 [(set (match_operand:SF 0 "s_register_operand" "")
1381 (mult:SF (match_operand:SF 1 "s_register_operand" "")
1382 (match_operand:SF 2 "fpa_rhs_operand" "")))]
1383 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
1386 && !cirrus_fp_register (operands[2], SFmode))
1387 operands[2] = force_reg (SFmode, operands[2]);
1390 (define_expand "muldf3"
1391 [(set (match_operand:DF 0 "s_register_operand" "")
1392 (mult:DF (match_operand:DF 1 "s_register_operand" "")
1393 (match_operand:DF 2 "fpa_rhs_operand" "")))]
1394 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
1397 && !cirrus_fp_register (operands[2], DFmode))
1398 operands[2] = force_reg (DFmode, operands[2]);
1403 (define_expand "divsf3"
1404 [(set (match_operand:SF 0 "s_register_operand" "")
1405 (div:SF (match_operand:SF 1 "fpa_rhs_operand" "")
1406 (match_operand:SF 2 "fpa_rhs_operand" "")))]
1407 "TARGET_ARM && TARGET_HARD_FLOAT"
1410 (define_expand "divdf3"
1411 [(set (match_operand:DF 0 "s_register_operand" "")
1412 (div:DF (match_operand:DF 1 "fpa_rhs_operand" "")
1413 (match_operand:DF 2 "fpa_rhs_operand" "")))]
1414 "TARGET_ARM && TARGET_HARD_FLOAT"
1419 (define_expand "modsf3"
1420 [(set (match_operand:SF 0 "s_register_operand" "")
1421 (mod:SF (match_operand:SF 1 "s_register_operand" "")
1422 (match_operand:SF 2 "fpa_rhs_operand" "")))]
1423 "TARGET_ARM && TARGET_HARD_FLOAT"
1426 (define_expand "moddf3"
1427 [(set (match_operand:DF 0 "s_register_operand" "")
1428 (mod:DF (match_operand:DF 1 "s_register_operand" "")
1429 (match_operand:DF 2 "fpa_rhs_operand" "")))]
1430 "TARGET_ARM && TARGET_HARD_FLOAT"
1433 ;; Boolean and,ior,xor insns
1435 ;; Split up double word logical operations
1437 ;; Split up simple DImode logical operations. Simply perform the logical
1438 ;; operation on the upper and lower halves of the registers.
1440 [(set (match_operand:DI 0 "s_register_operand" "")
1441 (match_operator:DI 6 "logical_binary_operator"
1442 [(match_operand:DI 1 "s_register_operand" "")
1443 (match_operand:DI 2 "s_register_operand" "")]))]
1444 "TARGET_ARM && reload_completed && ! IS_IWMMXT_REGNUM (REGNO (operands[0]))"
1445 [(set (match_dup 0) (match_op_dup:SI 6 [(match_dup 1) (match_dup 2)]))
1446 (set (match_dup 3) (match_op_dup:SI 6 [(match_dup 4) (match_dup 5)]))]
1449 operands[3] = gen_highpart (SImode, operands[0]);
1450 operands[0] = gen_lowpart (SImode, operands[0]);
1451 operands[4] = gen_highpart (SImode, operands[1]);
1452 operands[1] = gen_lowpart (SImode, operands[1]);
1453 operands[5] = gen_highpart (SImode, operands[2]);
1454 operands[2] = gen_lowpart (SImode, operands[2]);
1459 [(set (match_operand:DI 0 "s_register_operand" "")
1460 (match_operator:DI 6 "logical_binary_operator"
1461 [(sign_extend:DI (match_operand:SI 2 "s_register_operand" ""))
1462 (match_operand:DI 1 "s_register_operand" "")]))]
1463 "TARGET_ARM && reload_completed"
1464 [(set (match_dup 0) (match_op_dup:SI 6 [(match_dup 1) (match_dup 2)]))
1465 (set (match_dup 3) (match_op_dup:SI 6
1466 [(ashiftrt:SI (match_dup 2) (const_int 31))
1470 operands[3] = gen_highpart (SImode, operands[0]);
1471 operands[0] = gen_lowpart (SImode, operands[0]);
1472 operands[4] = gen_highpart (SImode, operands[1]);
1473 operands[1] = gen_lowpart (SImode, operands[1]);
1474 operands[5] = gen_highpart (SImode, operands[2]);
1475 operands[2] = gen_lowpart (SImode, operands[2]);
1479 ;; The zero extend of operand 2 means we can just copy the high part of
1480 ;; operand1 into operand0.
1482 [(set (match_operand:DI 0 "s_register_operand" "")
1484 (zero_extend:DI (match_operand:SI 2 "s_register_operand" ""))
1485 (match_operand:DI 1 "s_register_operand" "")))]
1486 "TARGET_ARM && operands[0] != operands[1] && reload_completed"
1487 [(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 2)))
1488 (set (match_dup 3) (match_dup 4))]
1491 operands[4] = gen_highpart (SImode, operands[1]);
1492 operands[3] = gen_highpart (SImode, operands[0]);
1493 operands[0] = gen_lowpart (SImode, operands[0]);
1494 operands[1] = gen_lowpart (SImode, operands[1]);
1498 ;; The zero extend of operand 2 means we can just copy the high part of
1499 ;; operand1 into operand0.
1501 [(set (match_operand:DI 0 "s_register_operand" "")
1503 (zero_extend:DI (match_operand:SI 2 "s_register_operand" ""))
1504 (match_operand:DI 1 "s_register_operand" "")))]
1505 "TARGET_ARM && operands[0] != operands[1] && reload_completed"
1506 [(set (match_dup 0) (xor:SI (match_dup 1) (match_dup 2)))
1507 (set (match_dup 3) (match_dup 4))]
1510 operands[4] = gen_highpart (SImode, operands[1]);
1511 operands[3] = gen_highpart (SImode, operands[0]);
1512 operands[0] = gen_lowpart (SImode, operands[0]);
1513 operands[1] = gen_lowpart (SImode, operands[1]);
1517 (define_insn "anddi3"
1518 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
1519 (and:DI (match_operand:DI 1 "s_register_operand" "%0,r")
1520 (match_operand:DI 2 "s_register_operand" "r,r")))]
1521 "TARGET_ARM && ! TARGET_IWMMXT"
1523 [(set_attr "length" "8")]
1526 (define_insn_and_split "*anddi_zesidi_di"
1527 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
1528 (and:DI (zero_extend:DI
1529 (match_operand:SI 2 "s_register_operand" "r,r"))
1530 (match_operand:DI 1 "s_register_operand" "?r,0")))]
1533 "TARGET_ARM && reload_completed"
1534 ; The zero extend of operand 2 clears the high word of the output
1536 [(set (match_dup 0) (and:SI (match_dup 1) (match_dup 2)))
1537 (set (match_dup 3) (const_int 0))]
1540 operands[3] = gen_highpart (SImode, operands[0]);
1541 operands[0] = gen_lowpart (SImode, operands[0]);
1542 operands[1] = gen_lowpart (SImode, operands[1]);
1544 [(set_attr "length" "8")]
1547 (define_insn "*anddi_sesdi_di"
1548 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
1549 (and:DI (sign_extend:DI
1550 (match_operand:SI 2 "s_register_operand" "r,r"))
1551 (match_operand:DI 1 "s_register_operand" "?r,0")))]
1554 [(set_attr "length" "8")]
1557 (define_expand "andsi3"
1558 [(set (match_operand:SI 0 "s_register_operand" "")
1559 (and:SI (match_operand:SI 1 "s_register_operand" "")
1560 (match_operand:SI 2 "reg_or_int_operand" "")))]
1565 if (GET_CODE (operands[2]) == CONST_INT)
1567 arm_split_constant (AND, SImode, INTVAL (operands[2]), operands[0],
1570 ? 0 : preserve_subexpressions_p ()));
1574 else /* TARGET_THUMB */
1576 if (GET_CODE (operands[2]) != CONST_INT)
1577 operands[2] = force_reg (SImode, operands[2]);
1582 if (((unsigned HOST_WIDE_INT) ~INTVAL (operands[2])) < 256)
1584 operands[2] = force_reg (SImode,
1585 GEN_INT (~INTVAL (operands[2])));
1587 emit_insn (gen_bicsi3 (operands[0], operands[2], operands[1]));
1592 for (i = 9; i <= 31; i++)
1594 if ((((HOST_WIDE_INT) 1) << i) - 1 == INTVAL (operands[2]))
1596 emit_insn (gen_extzv (operands[0], operands[1], GEN_INT (i),
1600 else if ((((HOST_WIDE_INT) 1) << i) - 1
1601 == ~INTVAL (operands[2]))
1603 rtx shift = GEN_INT (i);
1604 rtx reg = gen_reg_rtx (SImode);
1606 emit_insn (gen_lshrsi3 (reg, operands[1], shift));
1607 emit_insn (gen_ashlsi3 (operands[0], reg, shift));
1613 operands[2] = force_reg (SImode, operands[2]);
1619 (define_insn_and_split "*arm_andsi3_insn"
1620 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
1621 (and:SI (match_operand:SI 1 "s_register_operand" "r,r,r")
1622 (match_operand:SI 2 "reg_or_int_operand" "rI,K,?n")))]
1626 bic%?\\t%0, %1, #%B2
1629 && GET_CODE (operands[2]) == CONST_INT
1630 && !(const_ok_for_arm (INTVAL (operands[2]))
1631 || const_ok_for_arm (~INTVAL (operands[2])))"
1632 [(clobber (const_int 0))]
1634 arm_split_constant (AND, SImode, INTVAL (operands[2]), operands[0],
1638 [(set_attr "length" "4,4,16")
1639 (set_attr "predicable" "yes")]
1642 (define_insn "*thumb_andsi3_insn"
1643 [(set (match_operand:SI 0 "register_operand" "=l")
1644 (and:SI (match_operand:SI 1 "register_operand" "%0")
1645 (match_operand:SI 2 "register_operand" "l")))]
1648 [(set_attr "length" "2")]
1651 (define_insn "*andsi3_compare0"
1652 [(set (reg:CC_NOOV CC_REGNUM)
1654 (and:SI (match_operand:SI 1 "s_register_operand" "r,r")
1655 (match_operand:SI 2 "arm_not_operand" "rI,K"))
1657 (set (match_operand:SI 0 "s_register_operand" "=r,r")
1658 (and:SI (match_dup 1) (match_dup 2)))]
1662 bic%?s\\t%0, %1, #%B2"
1663 [(set_attr "conds" "set")]
1666 (define_insn "*andsi3_compare0_scratch"
1667 [(set (reg:CC_NOOV CC_REGNUM)
1669 (and:SI (match_operand:SI 0 "s_register_operand" "r,r")
1670 (match_operand:SI 1 "arm_not_operand" "rI,K"))
1672 (clobber (match_scratch:SI 2 "=X,r"))]
1676 bic%?s\\t%2, %0, #%B1"
1677 [(set_attr "conds" "set")]
1680 (define_insn "*zeroextractsi_compare0_scratch"
1681 [(set (reg:CC_NOOV CC_REGNUM)
1682 (compare:CC_NOOV (zero_extract:SI
1683 (match_operand:SI 0 "s_register_operand" "r")
1684 (match_operand 1 "const_int_operand" "n")
1685 (match_operand 2 "const_int_operand" "n"))
1688 && (INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) < 32
1689 && INTVAL (operands[1]) > 0
1690 && INTVAL (operands[1]) + (INTVAL (operands[2]) & 1) <= 8
1691 && INTVAL (operands[1]) + INTVAL (operands[2]) <= 32)"
1693 operands[1] = GEN_INT (((1 << INTVAL (operands[1])) - 1)
1694 << INTVAL (operands[2]));
1695 output_asm_insn (\"tst%?\\t%0, %1\", operands);
1698 [(set_attr "conds" "set")]
1701 (define_insn "*ne_zeroextractsi"
1702 [(set (match_operand:SI 0 "s_register_operand" "=r")
1703 (ne:SI (zero_extract:SI
1704 (match_operand:SI 1 "s_register_operand" "r")
1705 (match_operand:SI 2 "const_int_operand" "n")
1706 (match_operand:SI 3 "const_int_operand" "n"))
1708 (clobber (reg:CC CC_REGNUM))]
1710 && (INTVAL (operands[3]) >= 0 && INTVAL (operands[3]) < 32
1711 && INTVAL (operands[2]) > 0
1712 && INTVAL (operands[2]) + (INTVAL (operands[3]) & 1) <= 8
1713 && INTVAL (operands[2]) + INTVAL (operands[3]) <= 32)"
1715 operands[2] = GEN_INT (((1 << INTVAL (operands[2])) - 1)
1716 << INTVAL (operands[3]));
1717 output_asm_insn (\"ands\\t%0, %1, %2\", operands);
1718 return \"movne\\t%0, #1\";
1720 [(set_attr "conds" "clob")
1721 (set_attr "length" "8")]
1725 [(set (match_operand:SI 0 "s_register_operand" "")
1726 (zero_extract:SI (match_operand:SI 1 "s_register_operand" "")
1727 (match_operand:SI 2 "const_int_operand" "")
1728 (match_operand:SI 3 "const_int_operand" "")))
1729 (clobber (match_operand:SI 4 "s_register_operand" ""))]
1731 [(set (match_dup 4) (ashift:SI (match_dup 1) (match_dup 2)))
1732 (set (match_dup 0) (lshiftrt:SI (match_dup 4) (match_dup 3)))]
1734 HOST_WIDE_INT temp = INTVAL (operands[2]);
1736 operands[2] = GEN_INT (32 - temp - INTVAL (operands[3]));
1737 operands[3] = GEN_INT (32 - temp);
1742 [(set (match_operand:SI 0 "s_register_operand" "")
1743 (sign_extract:SI (match_operand:SI 1 "s_register_operand" "")
1744 (match_operand:SI 2 "const_int_operand" "")
1745 (match_operand:SI 3 "const_int_operand" "")))]
1747 [(set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 2)))
1748 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (match_dup 3)))]
1750 HOST_WIDE_INT temp = INTVAL (operands[2]);
1752 operands[2] = GEN_INT (32 - temp - INTVAL (operands[3]));
1753 operands[3] = GEN_INT (32 - temp);
1757 ;;; ??? This pattern is bogus. If operand3 has bits outside the range
1758 ;;; represented by the bitfield, then this will produce incorrect results.
1759 ;;; Somewhere, the value needs to be truncated. On targets like the m68k,
1760 ;;; which have a real bit-field insert instruction, the truncation happens
1761 ;;; in the bit-field insert instruction itself. Since arm does not have a
1762 ;;; bit-field insert instruction, we would have to emit code here to truncate
1763 ;;; the value before we insert. This loses some of the advantage of having
1764 ;;; this insv pattern, so this pattern needs to be reevalutated.
1766 (define_expand "insv"
1767 [(set (zero_extract:SI (match_operand:SI 0 "s_register_operand" "")
1768 (match_operand:SI 1 "general_operand" "")
1769 (match_operand:SI 2 "general_operand" ""))
1770 (match_operand:SI 3 "reg_or_int_operand" ""))]
1774 int start_bit = INTVAL (operands[2]);
1775 int width = INTVAL (operands[1]);
1776 HOST_WIDE_INT mask = (((HOST_WIDE_INT)1) << width) - 1;
1777 rtx target, subtarget;
1779 target = operands[0];
1780 /* Avoid using a subreg as a subtarget, and avoid writing a paradoxical
1781 subreg as the final target. */
1782 if (GET_CODE (target) == SUBREG)
1784 subtarget = gen_reg_rtx (SImode);
1785 if (GET_MODE_SIZE (GET_MODE (SUBREG_REG (target)))
1786 < GET_MODE_SIZE (SImode))
1787 target = SUBREG_REG (target);
1792 if (GET_CODE (operands[3]) == CONST_INT)
1794 /* Since we are inserting a known constant, we may be able to
1795 reduce the number of bits that we have to clear so that
1796 the mask becomes simple. */
1797 /* ??? This code does not check to see if the new mask is actually
1798 simpler. It may not be. */
1799 rtx op1 = gen_reg_rtx (SImode);
1800 /* ??? Truncate operand3 to fit in the bitfield. See comment before
1801 start of this pattern. */
1802 HOST_WIDE_INT op3_value = mask & INTVAL (operands[3]);
1803 HOST_WIDE_INT mask2 = ((mask & ~op3_value) << start_bit);
1805 emit_insn (gen_andsi3 (op1, operands[0], GEN_INT (~mask2)));
1806 emit_insn (gen_iorsi3 (subtarget, op1,
1807 GEN_INT (op3_value << start_bit)));
1809 else if (start_bit == 0
1810 && !(const_ok_for_arm (mask)
1811 || const_ok_for_arm (~mask)))
1813 /* A Trick, since we are setting the bottom bits in the word,
1814 we can shift operand[3] up, operand[0] down, OR them together
1815 and rotate the result back again. This takes 3 insns, and
1816 the third might be mergeable into another op. */
1817 /* The shift up copes with the possibility that operand[3] is
1818 wider than the bitfield. */
1819 rtx op0 = gen_reg_rtx (SImode);
1820 rtx op1 = gen_reg_rtx (SImode);
1822 emit_insn (gen_ashlsi3 (op0, operands[3], GEN_INT (32 - width)));
1823 emit_insn (gen_lshrsi3 (op1, operands[0], operands[1]));
1824 emit_insn (gen_iorsi3 (op1, op1, op0));
1825 emit_insn (gen_rotlsi3 (subtarget, op1, operands[1]));
1827 else if ((width + start_bit == 32)
1828 && !(const_ok_for_arm (mask)
1829 || const_ok_for_arm (~mask)))
1831 /* Similar trick, but slightly less efficient. */
1833 rtx op0 = gen_reg_rtx (SImode);
1834 rtx op1 = gen_reg_rtx (SImode);
1836 emit_insn (gen_ashlsi3 (op0, operands[3], GEN_INT (32 - width)));
1837 emit_insn (gen_ashlsi3 (op1, operands[0], operands[1]));
1838 emit_insn (gen_lshrsi3 (op1, op1, operands[1]));
1839 emit_insn (gen_iorsi3 (subtarget, op1, op0));
1843 rtx op0 = GEN_INT (mask);
1844 rtx op1 = gen_reg_rtx (SImode);
1845 rtx op2 = gen_reg_rtx (SImode);
1847 if (!(const_ok_for_arm (mask) || const_ok_for_arm (~mask)))
1849 rtx tmp = gen_reg_rtx (SImode);
1851 emit_insn (gen_movsi (tmp, op0));
1855 /* Mask out any bits in operand[3] that are not needed. */
1856 emit_insn (gen_andsi3 (op1, operands[3], op0));
1858 if (GET_CODE (op0) == CONST_INT
1859 && (const_ok_for_arm (mask << start_bit)
1860 || const_ok_for_arm (~(mask << start_bit))))
1862 op0 = GEN_INT (~(mask << start_bit));
1863 emit_insn (gen_andsi3 (op2, operands[0], op0));
1867 if (GET_CODE (op0) == CONST_INT)
1869 rtx tmp = gen_reg_rtx (SImode);
1871 emit_insn (gen_movsi (tmp, op0));
1876 emit_insn (gen_ashlsi3 (op0, op0, operands[2]));
1878 emit_insn (gen_andsi_notsi_si (op2, operands[0], op0));
1882 emit_insn (gen_ashlsi3 (op1, op1, operands[2]));
1884 emit_insn (gen_iorsi3 (subtarget, op1, op2));
1887 if (subtarget != target)
1889 /* If TARGET is still a SUBREG, then it must be wider than a word,
1890 so we must be careful only to set the subword we were asked to. */
1891 if (GET_CODE (target) == SUBREG)
1892 emit_move_insn (target, subtarget);
1894 emit_move_insn (target, gen_lowpart (GET_MODE (target), subtarget));
1901 ; constants for op 2 will never be given to these patterns.
1902 (define_insn_and_split "*anddi_notdi_di"
1903 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
1904 (and:DI (not:DI (match_operand:DI 1 "s_register_operand" "r,0"))
1905 (match_operand:DI 2 "s_register_operand" "0,r")))]
1908 "TARGET_ARM && reload_completed && ! IS_IWMMXT_REGNUM (REGNO (operands[0]))"
1909 [(set (match_dup 0) (and:SI (not:SI (match_dup 1)) (match_dup 2)))
1910 (set (match_dup 3) (and:SI (not:SI (match_dup 4)) (match_dup 5)))]
1913 operands[3] = gen_highpart (SImode, operands[0]);
1914 operands[0] = gen_lowpart (SImode, operands[0]);
1915 operands[4] = gen_highpart (SImode, operands[1]);
1916 operands[1] = gen_lowpart (SImode, operands[1]);
1917 operands[5] = gen_highpart (SImode, operands[2]);
1918 operands[2] = gen_lowpart (SImode, operands[2]);
1920 [(set_attr "length" "8")
1921 (set_attr "predicable" "yes")]
1924 (define_insn_and_split "*anddi_notzesidi_di"
1925 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
1926 (and:DI (not:DI (zero_extend:DI
1927 (match_operand:SI 2 "s_register_operand" "r,r")))
1928 (match_operand:DI 1 "s_register_operand" "0,?r")))]
1931 bic%?\\t%Q0, %Q1, %2
1933 ; (not (zero_extend ...)) allows us to just copy the high word from
1934 ; operand1 to operand0.
1937 && operands[0] != operands[1]"
1938 [(set (match_dup 0) (and:SI (not:SI (match_dup 2)) (match_dup 1)))
1939 (set (match_dup 3) (match_dup 4))]
1942 operands[3] = gen_highpart (SImode, operands[0]);
1943 operands[0] = gen_lowpart (SImode, operands[0]);
1944 operands[4] = gen_highpart (SImode, operands[1]);
1945 operands[1] = gen_lowpart (SImode, operands[1]);
1947 [(set_attr "length" "4,8")
1948 (set_attr "predicable" "yes")]
1951 (define_insn_and_split "*anddi_notsesidi_di"
1952 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
1953 (and:DI (not:DI (sign_extend:DI
1954 (match_operand:SI 2 "s_register_operand" "r,r")))
1955 (match_operand:DI 1 "s_register_operand" "0,r")))]
1958 "TARGET_ARM && reload_completed"
1959 [(set (match_dup 0) (and:SI (not:SI (match_dup 2)) (match_dup 1)))
1960 (set (match_dup 3) (and:SI (not:SI
1961 (ashiftrt:SI (match_dup 2) (const_int 31)))
1965 operands[3] = gen_highpart (SImode, operands[0]);
1966 operands[0] = gen_lowpart (SImode, operands[0]);
1967 operands[4] = gen_highpart (SImode, operands[1]);
1968 operands[1] = gen_lowpart (SImode, operands[1]);
1970 [(set_attr "length" "8")
1971 (set_attr "predicable" "yes")]
1974 (define_insn "andsi_notsi_si"
1975 [(set (match_operand:SI 0 "s_register_operand" "=r")
1976 (and:SI (not:SI (match_operand:SI 2 "s_register_operand" "r"))
1977 (match_operand:SI 1 "s_register_operand" "r")))]
1979 "bic%?\\t%0, %1, %2"
1980 [(set_attr "predicable" "yes")]
1983 (define_insn "bicsi3"
1984 [(set (match_operand:SI 0 "register_operand" "=l")
1985 (and:SI (not:SI (match_operand:SI 1 "register_operand" "l"))
1986 (match_operand:SI 2 "register_operand" "0")))]
1989 [(set_attr "length" "2")]
1992 (define_insn "andsi_not_shiftsi_si"
1993 [(set (match_operand:SI 0 "s_register_operand" "=r")
1994 (and:SI (not:SI (match_operator:SI 4 "shift_operator"
1995 [(match_operand:SI 2 "s_register_operand" "r")
1996 (match_operand:SI 3 "arm_rhs_operand" "rM")]))
1997 (match_operand:SI 1 "s_register_operand" "r")))]
1999 "bic%?\\t%0, %1, %2%S4"
2000 [(set_attr "predicable" "yes")
2001 (set_attr "shift" "2")
2005 (define_insn "*andsi_notsi_si_compare0"
2006 [(set (reg:CC_NOOV CC_REGNUM)
2008 (and:SI (not:SI (match_operand:SI 2 "s_register_operand" "r"))
2009 (match_operand:SI 1 "s_register_operand" "r"))
2011 (set (match_operand:SI 0 "s_register_operand" "=r")
2012 (and:SI (not:SI (match_dup 2)) (match_dup 1)))]
2014 "bic%?s\\t%0, %1, %2"
2015 [(set_attr "conds" "set")]
2018 (define_insn "*andsi_notsi_si_compare0_scratch"
2019 [(set (reg:CC_NOOV CC_REGNUM)
2021 (and:SI (not:SI (match_operand:SI 2 "s_register_operand" "r"))
2022 (match_operand:SI 1 "s_register_operand" "r"))
2024 (clobber (match_scratch:SI 0 "=r"))]
2026 "bic%?s\\t%0, %1, %2"
2027 [(set_attr "conds" "set")]
2030 (define_insn "iordi3"
2031 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
2032 (ior:DI (match_operand:DI 1 "s_register_operand" "%0,r")
2033 (match_operand:DI 2 "s_register_operand" "r,r")))]
2034 "TARGET_ARM && ! TARGET_IWMMXT"
2036 [(set_attr "length" "8")
2037 (set_attr "predicable" "yes")]
2040 (define_insn "*iordi_zesidi_di"
2041 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
2042 (ior:DI (zero_extend:DI
2043 (match_operand:SI 2 "s_register_operand" "r,r"))
2044 (match_operand:DI 1 "s_register_operand" "0,?r")))]
2047 orr%?\\t%Q0, %Q1, %2
2049 [(set_attr "length" "4,8")
2050 (set_attr "predicable" "yes")]
2053 (define_insn "*iordi_sesidi_di"
2054 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
2055 (ior:DI (sign_extend:DI
2056 (match_operand:SI 2 "s_register_operand" "r,r"))
2057 (match_operand:DI 1 "s_register_operand" "?r,0")))]
2060 [(set_attr "length" "8")
2061 (set_attr "predicable" "yes")]
2064 (define_expand "iorsi3"
2065 [(set (match_operand:SI 0 "s_register_operand" "")
2066 (ior:SI (match_operand:SI 1 "s_register_operand" "")
2067 (match_operand:SI 2 "reg_or_int_operand" "")))]
2070 if (GET_CODE (operands[2]) == CONST_INT)
2074 arm_split_constant (IOR, SImode, INTVAL (operands[2]), operands[0],
2077 ? 0 : preserve_subexpressions_p ()));
2080 else /* TARGET_THUMB */
2081 operands [2] = force_reg (SImode, operands [2]);
2086 (define_insn_and_split "*arm_iorsi3"
2087 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
2088 (ior:SI (match_operand:SI 1 "s_register_operand" "r,r")
2089 (match_operand:SI 2 "reg_or_int_operand" "rI,?n")))]
2095 && GET_CODE (operands[2]) == CONST_INT
2096 && !const_ok_for_arm (INTVAL (operands[2]))"
2097 [(clobber (const_int 0))]
2099 arm_split_constant (IOR, SImode, INTVAL (operands[2]), operands[0],
2103 [(set_attr "length" "4,16")
2104 (set_attr "predicable" "yes")]
2107 (define_insn "*thumb_iorsi3"
2108 [(set (match_operand:SI 0 "register_operand" "=l")
2109 (ior:SI (match_operand:SI 1 "register_operand" "%0")
2110 (match_operand:SI 2 "register_operand" "l")))]
2113 [(set_attr "length" "2")]
2117 [(match_scratch:SI 3 "r")
2118 (set (match_operand:SI 0 "s_register_operand" "")
2119 (ior:SI (match_operand:SI 1 "s_register_operand" "")
2120 (match_operand:SI 2 "const_int_operand" "")))]
2122 && !const_ok_for_arm (INTVAL (operands[2]))
2123 && const_ok_for_arm (~INTVAL (operands[2]))"
2124 [(set (match_dup 3) (match_dup 2))
2125 (set (match_dup 0) (ior:SI (match_dup 1) (match_dup 3)))]
2129 (define_insn "*iorsi3_compare0"
2130 [(set (reg:CC_NOOV CC_REGNUM)
2131 (compare:CC_NOOV (ior:SI (match_operand:SI 1 "s_register_operand" "%r")
2132 (match_operand:SI 2 "arm_rhs_operand" "rI"))
2134 (set (match_operand:SI 0 "s_register_operand" "=r")
2135 (ior:SI (match_dup 1) (match_dup 2)))]
2137 "orr%?s\\t%0, %1, %2"
2138 [(set_attr "conds" "set")]
2141 (define_insn "*iorsi3_compare0_scratch"
2142 [(set (reg:CC_NOOV CC_REGNUM)
2143 (compare:CC_NOOV (ior:SI (match_operand:SI 1 "s_register_operand" "%r")
2144 (match_operand:SI 2 "arm_rhs_operand" "rI"))
2146 (clobber (match_scratch:SI 0 "=r"))]
2148 "orr%?s\\t%0, %1, %2"
2149 [(set_attr "conds" "set")]
2152 (define_insn "xordi3"
2153 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
2154 (xor:DI (match_operand:DI 1 "s_register_operand" "%0,r")
2155 (match_operand:DI 2 "s_register_operand" "r,r")))]
2156 "TARGET_ARM && !TARGET_IWMMXT"
2158 [(set_attr "length" "8")
2159 (set_attr "predicable" "yes")]
2162 (define_insn "*xordi_zesidi_di"
2163 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
2164 (xor:DI (zero_extend:DI
2165 (match_operand:SI 2 "s_register_operand" "r,r"))
2166 (match_operand:DI 1 "s_register_operand" "0,?r")))]
2169 eor%?\\t%Q0, %Q1, %2
2171 [(set_attr "length" "4,8")
2172 (set_attr "predicable" "yes")]
2175 (define_insn "*xordi_sesidi_di"
2176 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
2177 (xor:DI (sign_extend:DI
2178 (match_operand:SI 2 "s_register_operand" "r,r"))
2179 (match_operand:DI 1 "s_register_operand" "?r,0")))]
2182 [(set_attr "length" "8")
2183 (set_attr "predicable" "yes")]
2186 (define_expand "xorsi3"
2187 [(set (match_operand:SI 0 "s_register_operand" "")
2188 (xor:SI (match_operand:SI 1 "s_register_operand" "")
2189 (match_operand:SI 2 "arm_rhs_operand" "")))]
2192 if (GET_CODE (operands[2]) == CONST_INT)
2193 operands[2] = force_reg (SImode, operands[2]);
2197 (define_insn "*arm_xorsi3"
2198 [(set (match_operand:SI 0 "s_register_operand" "=r")
2199 (xor:SI (match_operand:SI 1 "s_register_operand" "r")
2200 (match_operand:SI 2 "arm_rhs_operand" "rI")))]
2202 "eor%?\\t%0, %1, %2"
2203 [(set_attr "predicable" "yes")]
2206 (define_insn "*thumb_xorsi3"
2207 [(set (match_operand:SI 0 "register_operand" "=l")
2208 (xor:SI (match_operand:SI 1 "register_operand" "%0")
2209 (match_operand:SI 2 "register_operand" "l")))]
2212 [(set_attr "length" "2")]
2215 (define_insn "*xorsi3_compare0"
2216 [(set (reg:CC_NOOV CC_REGNUM)
2217 (compare:CC_NOOV (xor:SI (match_operand:SI 1 "s_register_operand" "r")
2218 (match_operand:SI 2 "arm_rhs_operand" "rI"))
2220 (set (match_operand:SI 0 "s_register_operand" "=r")
2221 (xor:SI (match_dup 1) (match_dup 2)))]
2223 "eor%?s\\t%0, %1, %2"
2224 [(set_attr "conds" "set")]
2227 (define_insn "*xorsi3_compare0_scratch"
2228 [(set (reg:CC_NOOV CC_REGNUM)
2229 (compare:CC_NOOV (xor:SI (match_operand:SI 0 "s_register_operand" "r")
2230 (match_operand:SI 1 "arm_rhs_operand" "rI"))
2234 [(set_attr "conds" "set")]
2237 ; By splitting (IOR (AND (NOT A) (NOT B)) C) as D = AND (IOR A B) (NOT C),
2238 ; (NOT D) we can sometimes merge the final NOT into one of the following
2242 [(set (match_operand:SI 0 "s_register_operand" "")
2243 (ior:SI (and:SI (not:SI (match_operand:SI 1 "s_register_operand" ""))
2244 (not:SI (match_operand:SI 2 "arm_rhs_operand" "")))
2245 (match_operand:SI 3 "arm_rhs_operand" "")))
2246 (clobber (match_operand:SI 4 "s_register_operand" ""))]
2248 [(set (match_dup 4) (and:SI (ior:SI (match_dup 1) (match_dup 2))
2249 (not:SI (match_dup 3))))
2250 (set (match_dup 0) (not:SI (match_dup 4)))]
2254 (define_insn "*andsi_iorsi3_notsi"
2255 [(set (match_operand:SI 0 "s_register_operand" "=&r,&r,&r")
2256 (and:SI (ior:SI (match_operand:SI 1 "s_register_operand" "r,r,0")
2257 (match_operand:SI 2 "arm_rhs_operand" "rI,0,rI"))
2258 (not:SI (match_operand:SI 3 "arm_rhs_operand" "rI,rI,rI"))))]
2260 "orr%?\\t%0, %1, %2\;bic%?\\t%0, %0, %3"
2261 [(set_attr "length" "8")
2262 (set_attr "predicable" "yes")]
2267 ;; Minimum and maximum insns
2269 (define_insn "smaxsi3"
2270 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
2271 (smax:SI (match_operand:SI 1 "s_register_operand" "0,r,?r")
2272 (match_operand:SI 2 "arm_rhs_operand" "rI,0,rI")))
2273 (clobber (reg:CC CC_REGNUM))]
2276 cmp\\t%1, %2\;movlt\\t%0, %2
2277 cmp\\t%1, %2\;movge\\t%0, %1
2278 cmp\\t%1, %2\;movge\\t%0, %1\;movlt\\t%0, %2"
2279 [(set_attr "conds" "clob")
2280 (set_attr "length" "8,8,12")]
2283 (define_insn "sminsi3"
2284 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
2285 (smin:SI (match_operand:SI 1 "s_register_operand" "0,r,?r")
2286 (match_operand:SI 2 "arm_rhs_operand" "rI,0,rI")))
2287 (clobber (reg:CC CC_REGNUM))]
2290 cmp\\t%1, %2\;movge\\t%0, %2
2291 cmp\\t%1, %2\;movlt\\t%0, %1
2292 cmp\\t%1, %2\;movlt\\t%0, %1\;movge\\t%0, %2"
2293 [(set_attr "conds" "clob")
2294 (set_attr "length" "8,8,12")]
2297 (define_insn "umaxsi3"
2298 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
2299 (umax:SI (match_operand:SI 1 "s_register_operand" "0,r,?r")
2300 (match_operand:SI 2 "arm_rhs_operand" "rI,0,rI")))
2301 (clobber (reg:CC CC_REGNUM))]
2304 cmp\\t%1, %2\;movcc\\t%0, %2
2305 cmp\\t%1, %2\;movcs\\t%0, %1
2306 cmp\\t%1, %2\;movcs\\t%0, %1\;movcc\\t%0, %2"
2307 [(set_attr "conds" "clob")
2308 (set_attr "length" "8,8,12")]
2311 (define_insn "uminsi3"
2312 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
2313 (umin:SI (match_operand:SI 1 "s_register_operand" "0,r,?r")
2314 (match_operand:SI 2 "arm_rhs_operand" "rI,0,rI")))
2315 (clobber (reg:CC CC_REGNUM))]
2318 cmp\\t%1, %2\;movcs\\t%0, %2
2319 cmp\\t%1, %2\;movcc\\t%0, %1
2320 cmp\\t%1, %2\;movcc\\t%0, %1\;movcs\\t%0, %2"
2321 [(set_attr "conds" "clob")
2322 (set_attr "length" "8,8,12")]
2325 (define_insn "*store_minmaxsi"
2326 [(set (match_operand:SI 0 "memory_operand" "=m")
2327 (match_operator:SI 3 "minmax_operator"
2328 [(match_operand:SI 1 "s_register_operand" "r")
2329 (match_operand:SI 2 "s_register_operand" "r")]))
2330 (clobber (reg:CC CC_REGNUM))]
2333 operands[3] = gen_rtx (minmax_code (operands[3]), SImode, operands[1],
2335 output_asm_insn (\"cmp\\t%1, %2\", operands);
2336 output_asm_insn (\"str%d3\\t%1, %0\", operands);
2337 output_asm_insn (\"str%D3\\t%2, %0\", operands);
2340 [(set_attr "conds" "clob")
2341 (set_attr "length" "12")
2342 (set_attr "type" "store1")]
2345 ; Reject the frame pointer in operand[1], since reloading this after
2346 ; it has been eliminated can cause carnage.
2347 (define_insn "*minmax_arithsi"
2348 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
2349 (match_operator:SI 4 "shiftable_operator"
2350 [(match_operator:SI 5 "minmax_operator"
2351 [(match_operand:SI 2 "s_register_operand" "r,r")
2352 (match_operand:SI 3 "arm_rhs_operand" "rI,rI")])
2353 (match_operand:SI 1 "s_register_operand" "0,?r")]))
2354 (clobber (reg:CC CC_REGNUM))]
2356 && (GET_CODE (operands[1]) != REG
2357 || (REGNO(operands[1]) != FRAME_POINTER_REGNUM
2358 && REGNO(operands[1]) != ARG_POINTER_REGNUM))"
2361 enum rtx_code code = GET_CODE (operands[4]);
2363 operands[5] = gen_rtx (minmax_code (operands[5]), SImode, operands[2],
2365 output_asm_insn (\"cmp\\t%2, %3\", operands);
2366 output_asm_insn (\"%i4%d5\\t%0, %1, %2\", operands);
2367 if (which_alternative != 0 || operands[3] != const0_rtx
2368 || (code != PLUS && code != MINUS && code != IOR && code != XOR))
2369 output_asm_insn (\"%i4%D5\\t%0, %1, %3\", operands);
2372 [(set_attr "conds" "clob")
2373 (set_attr "length" "12")]
2377 ;; Shift and rotation insns
2379 (define_expand "ashlsi3"
2380 [(set (match_operand:SI 0 "s_register_operand" "")
2381 (ashift:SI (match_operand:SI 1 "s_register_operand" "")
2382 (match_operand:SI 2 "arm_rhs_operand" "")))]
2385 if (GET_CODE (operands[2]) == CONST_INT
2386 && ((unsigned HOST_WIDE_INT) INTVAL (operands[2])) > 31)
2388 emit_insn (gen_movsi (operands[0], const0_rtx));
2394 (define_insn "*thumb_ashlsi3"
2395 [(set (match_operand:SI 0 "register_operand" "=l,l")
2396 (ashift:SI (match_operand:SI 1 "register_operand" "l,0")
2397 (match_operand:SI 2 "nonmemory_operand" "N,l")))]
2400 [(set_attr "length" "2")]
2403 (define_expand "ashrsi3"
2404 [(set (match_operand:SI 0 "s_register_operand" "")
2405 (ashiftrt:SI (match_operand:SI 1 "s_register_operand" "")
2406 (match_operand:SI 2 "arm_rhs_operand" "")))]
2409 if (GET_CODE (operands[2]) == CONST_INT
2410 && ((unsigned HOST_WIDE_INT) INTVAL (operands[2])) > 31)
2411 operands[2] = GEN_INT (31);
2415 (define_insn "*thumb_ashrsi3"
2416 [(set (match_operand:SI 0 "register_operand" "=l,l")
2417 (ashiftrt:SI (match_operand:SI 1 "register_operand" "l,0")
2418 (match_operand:SI 2 "nonmemory_operand" "N,l")))]
2421 [(set_attr "length" "2")]
2424 (define_expand "lshrsi3"
2425 [(set (match_operand:SI 0 "s_register_operand" "")
2426 (lshiftrt:SI (match_operand:SI 1 "s_register_operand" "")
2427 (match_operand:SI 2 "arm_rhs_operand" "")))]
2430 if (GET_CODE (operands[2]) == CONST_INT
2431 && ((unsigned HOST_WIDE_INT) INTVAL (operands[2])) > 31)
2433 emit_insn (gen_movsi (operands[0], const0_rtx));
2439 (define_insn "*thumb_lshrsi3"
2440 [(set (match_operand:SI 0 "register_operand" "=l,l")
2441 (lshiftrt:SI (match_operand:SI 1 "register_operand" "l,0")
2442 (match_operand:SI 2 "nonmemory_operand" "N,l")))]
2445 [(set_attr "length" "2")]
2448 (define_expand "rotlsi3"
2449 [(set (match_operand:SI 0 "s_register_operand" "")
2450 (rotatert:SI (match_operand:SI 1 "s_register_operand" "")
2451 (match_operand:SI 2 "reg_or_int_operand" "")))]
2454 if (GET_CODE (operands[2]) == CONST_INT)
2455 operands[2] = GEN_INT ((32 - INTVAL (operands[2])) % 32);
2458 rtx reg = gen_reg_rtx (SImode);
2459 emit_insn (gen_subsi3 (reg, GEN_INT (32), operands[2]));
2465 (define_expand "rotrsi3"
2466 [(set (match_operand:SI 0 "s_register_operand" "")
2467 (rotatert:SI (match_operand:SI 1 "s_register_operand" "")
2468 (match_operand:SI 2 "arm_rhs_operand" "")))]
2473 if (GET_CODE (operands[2]) == CONST_INT
2474 && ((unsigned HOST_WIDE_INT) INTVAL (operands[2])) > 31)
2475 operands[2] = GEN_INT (INTVAL (operands[2]) % 32);
2477 else /* TARGET_THUMB */
2479 if (GET_CODE (operands [2]) == CONST_INT)
2480 operands [2] = force_reg (SImode, operands[2]);
2485 (define_insn "*thumb_rotrsi3"
2486 [(set (match_operand:SI 0 "register_operand" "=l")
2487 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
2488 (match_operand:SI 2 "register_operand" "l")))]
2491 [(set_attr "length" "2")]
2494 (define_expand "ashldi3"
2495 [(set (match_operand:DI 0 "s_register_operand" "")
2496 (ashift:DI (match_operand:DI 1 "general_operand" "")
2497 (match_operand:SI 2 "general_operand" "")))]
2498 "TARGET_ARM && (TARGET_IWMMXT || TARGET_CIRRUS)"
2500 if (! s_register_operand (operands[1], DImode))
2501 operands[1] = copy_to_mode_reg (DImode, operands[1]);
2502 if (! s_register_operand (operands[2], SImode))
2503 operands[2] = copy_to_mode_reg (SImode, operands[2]);
2507 (define_insn "*arm_shiftsi3"
2508 [(set (match_operand:SI 0 "s_register_operand" "=r")
2509 (match_operator:SI 3 "shift_operator"
2510 [(match_operand:SI 1 "s_register_operand" "r")
2511 (match_operand:SI 2 "reg_or_int_operand" "rM")]))]
2514 [(set_attr "predicable" "yes")
2515 (set_attr "shift" "1")
2519 (define_insn "*shiftsi3_compare0"
2520 [(set (reg:CC_NOOV CC_REGNUM)
2521 (compare:CC_NOOV (match_operator:SI 3 "shift_operator"
2522 [(match_operand:SI 1 "s_register_operand" "r")
2523 (match_operand:SI 2 "arm_rhs_operand" "rM")])
2525 (set (match_operand:SI 0 "s_register_operand" "=r")
2526 (match_op_dup 3 [(match_dup 1) (match_dup 2)]))]
2528 "mov%?s\\t%0, %1%S3"
2529 [(set_attr "conds" "set")
2530 (set_attr "shift" "1")
2534 (define_insn "*shiftsi3_compare0_scratch"
2535 [(set (reg:CC_NOOV CC_REGNUM)
2536 (compare:CC_NOOV (match_operator:SI 3 "shift_operator"
2537 [(match_operand:SI 1 "s_register_operand" "r")
2538 (match_operand:SI 2 "arm_rhs_operand" "rM")])
2540 (clobber (match_scratch:SI 0 "=r"))]
2542 "mov%?s\\t%0, %1%S3"
2543 [(set_attr "conds" "set")
2544 (set_attr "shift" "1")
2548 (define_insn "*notsi_shiftsi"
2549 [(set (match_operand:SI 0 "s_register_operand" "=r")
2550 (not:SI (match_operator:SI 3 "shift_operator"
2551 [(match_operand:SI 1 "s_register_operand" "r")
2552 (match_operand:SI 2 "arm_rhs_operand" "rM")])))]
2555 [(set_attr "predicable" "yes")
2556 (set_attr "shift" "1")
2560 (define_insn "*notsi_shiftsi_compare0"
2561 [(set (reg:CC_NOOV CC_REGNUM)
2562 (compare:CC_NOOV (not:SI (match_operator:SI 3 "shift_operator"
2563 [(match_operand:SI 1 "s_register_operand" "r")
2564 (match_operand:SI 2 "arm_rhs_operand" "rM")]))
2566 (set (match_operand:SI 0 "s_register_operand" "=r")
2567 (not:SI (match_op_dup 3 [(match_dup 1) (match_dup 2)])))]
2569 "mvn%?s\\t%0, %1%S3"
2570 [(set_attr "conds" "set")
2571 (set_attr "shift" "1")
2575 (define_insn "*not_shiftsi_compare0_scratch"
2576 [(set (reg:CC_NOOV CC_REGNUM)
2577 (compare:CC_NOOV (not:SI (match_operator:SI 3 "shift_operator"
2578 [(match_operand:SI 1 "s_register_operand" "r")
2579 (match_operand:SI 2 "arm_rhs_operand" "rM")]))
2581 (clobber (match_scratch:SI 0 "=r"))]
2583 "mvn%?s\\t%0, %1%S3"
2584 [(set_attr "conds" "set")
2585 (set_attr "shift" "1")
2589 ;; We don't really have extzv, but defining this using shifts helps
2590 ;; to reduce register pressure later on.
2592 (define_expand "extzv"
2594 (ashift:SI (match_operand:SI 1 "register_operand" "")
2595 (match_operand:SI 2 "const_int_operand" "")))
2596 (set (match_operand:SI 0 "register_operand" "")
2597 (lshiftrt:SI (match_dup 4)
2598 (match_operand:SI 3 "const_int_operand" "")))]
2602 HOST_WIDE_INT lshift = 32 - INTVAL (operands[2]) - INTVAL (operands[3]);
2603 HOST_WIDE_INT rshift = 32 - INTVAL (operands[2]);
2605 operands[3] = GEN_INT (rshift);
2609 emit_insn (gen_lshrsi3 (operands[0], operands[1], operands[3]));
2613 operands[2] = GEN_INT (lshift);
2614 operands[4] = gen_reg_rtx (SImode);
2619 ;; Unary arithmetic insns
2621 (define_expand "negdi2"
2623 [(set (match_operand:DI 0 "s_register_operand" "")
2624 (neg:DI (match_operand:DI 1 "s_register_operand" "")))
2625 (clobber (reg:CC CC_REGNUM))])]
2630 if (GET_CODE (operands[1]) != REG)
2631 operands[1] = force_reg (SImode, operands[1]);
2636 ;; The constraints here are to prevent a *partial* overlap (where %Q0 == %R1).
2637 ;; The second alternative is to allow the common case of a *full* overlap.
2638 (define_insn "*arm_negdi2"
2639 [(set (match_operand:DI 0 "s_register_operand" "=&r,r")
2640 (neg:DI (match_operand:DI 1 "s_register_operand" "?r,0")))
2641 (clobber (reg:CC CC_REGNUM))]
2643 "rsbs\\t%Q0, %Q1, #0\;rsc\\t%R0, %R1, #0"
2644 [(set_attr "conds" "clob")
2645 (set_attr "length" "8")]
2648 (define_insn "*thumb_negdi2"
2649 [(set (match_operand:DI 0 "register_operand" "=&l")
2650 (neg:DI (match_operand:DI 1 "register_operand" "l")))
2651 (clobber (reg:CC CC_REGNUM))]
2653 "mov\\t%R0, #0\;neg\\t%Q0, %Q1\;sbc\\t%R0, %R1"
2654 [(set_attr "length" "6")]
2657 (define_expand "negsi2"
2658 [(set (match_operand:SI 0 "s_register_operand" "")
2659 (neg:SI (match_operand:SI 1 "s_register_operand" "")))]
2664 (define_insn "*arm_negsi2"
2665 [(set (match_operand:SI 0 "s_register_operand" "=r")
2666 (neg:SI (match_operand:SI 1 "s_register_operand" "r")))]
2668 "rsb%?\\t%0, %1, #0"
2669 [(set_attr "predicable" "yes")]
2672 (define_insn "*thumb_negsi2"
2673 [(set (match_operand:SI 0 "register_operand" "=l")
2674 (neg:SI (match_operand:SI 1 "register_operand" "l")))]
2677 [(set_attr "length" "2")]
2680 (define_expand "negsf2"
2681 [(set (match_operand:SF 0 "s_register_operand" "")
2682 (neg:SF (match_operand:SF 1 "s_register_operand" "")))]
2683 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
2687 (define_expand "negdf2"
2688 [(set (match_operand:DF 0 "s_register_operand" "")
2689 (neg:DF (match_operand:DF 1 "s_register_operand" "")))]
2690 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
2693 ;; abssi2 doesn't really clobber the condition codes if a different register
2694 ;; is being set. To keep things simple, assume during rtl manipulations that
2695 ;; it does, but tell the final scan operator the truth. Similarly for
2698 (define_expand "abssi2"
2700 [(set (match_operand:SI 0 "s_register_operand" "")
2701 (abs:SI (match_operand:SI 1 "s_register_operand" "")))
2702 (clobber (reg:CC CC_REGNUM))])]
2706 (define_insn "*arm_abssi2"
2707 [(set (match_operand:SI 0 "s_register_operand" "=r,&r")
2708 (abs:SI (match_operand:SI 1 "s_register_operand" "0,r")))
2709 (clobber (reg:CC CC_REGNUM))]
2712 cmp\\t%0, #0\;rsblt\\t%0, %0, #0
2713 eor%?\\t%0, %1, %1, asr #31\;sub%?\\t%0, %0, %1, asr #31"
2714 [(set_attr "conds" "clob,*")
2715 (set_attr "shift" "1")
2716 ;; predicable can't be set based on the variant, so left as no
2717 (set_attr "length" "8")]
2720 (define_insn "*neg_abssi2"
2721 [(set (match_operand:SI 0 "s_register_operand" "=r,&r")
2722 (neg:SI (abs:SI (match_operand:SI 1 "s_register_operand" "0,r"))))
2723 (clobber (reg:CC CC_REGNUM))]
2726 cmp\\t%0, #0\;rsbgt\\t%0, %0, #0
2727 eor%?\\t%0, %1, %1, asr #31\;rsb%?\\t%0, %0, %1, asr #31"
2728 [(set_attr "conds" "clob,*")
2729 (set_attr "shift" "1")
2730 ;; predicable can't be set based on the variant, so left as no
2731 (set_attr "length" "8")]
2734 (define_expand "abssf2"
2735 [(set (match_operand:SF 0 "s_register_operand" "")
2736 (abs:SF (match_operand:SF 1 "s_register_operand" "")))]
2737 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
2740 (define_expand "absdf2"
2741 [(set (match_operand:DF 0 "s_register_operand" "")
2742 (abs:DF (match_operand:DF 1 "s_register_operand" "")))]
2743 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
2746 (define_expand "sqrtsf2"
2747 [(set (match_operand:SF 0 "s_register_operand" "")
2748 (sqrt:SF (match_operand:SF 1 "s_register_operand" "")))]
2749 "TARGET_ARM && TARGET_HARD_FLOAT"
2752 (define_expand "sqrtdf2"
2753 [(set (match_operand:DF 0 "s_register_operand" "")
2754 (sqrt:DF (match_operand:DF 1 "s_register_operand" "")))]
2755 "TARGET_ARM && TARGET_HARD_FLOAT"
2758 (define_insn_and_split "one_cmpldi2"
2759 [(set (match_operand:DI 0 "s_register_operand" "=&r,&r")
2760 (not:DI (match_operand:DI 1 "s_register_operand" "?r,0")))]
2763 "TARGET_ARM && reload_completed"
2764 [(set (match_dup 0) (not:SI (match_dup 1)))
2765 (set (match_dup 2) (not:SI (match_dup 3)))]
2768 operands[2] = gen_highpart (SImode, operands[0]);
2769 operands[0] = gen_lowpart (SImode, operands[0]);
2770 operands[3] = gen_highpart (SImode, operands[1]);
2771 operands[1] = gen_lowpart (SImode, operands[1]);
2773 [(set_attr "length" "8")
2774 (set_attr "predicable" "yes")]
2777 (define_expand "one_cmplsi2"
2778 [(set (match_operand:SI 0 "s_register_operand" "")
2779 (not:SI (match_operand:SI 1 "s_register_operand" "")))]
2784 (define_insn "*arm_one_cmplsi2"
2785 [(set (match_operand:SI 0 "s_register_operand" "=r")
2786 (not:SI (match_operand:SI 1 "s_register_operand" "r")))]
2789 [(set_attr "predicable" "yes")]
2792 (define_insn "*thumb_one_cmplsi2"
2793 [(set (match_operand:SI 0 "register_operand" "=l")
2794 (not:SI (match_operand:SI 1 "register_operand" "l")))]
2797 [(set_attr "length" "2")]
2800 (define_insn "*notsi_compare0"
2801 [(set (reg:CC_NOOV CC_REGNUM)
2802 (compare:CC_NOOV (not:SI (match_operand:SI 1 "s_register_operand" "r"))
2804 (set (match_operand:SI 0 "s_register_operand" "=r")
2805 (not:SI (match_dup 1)))]
2808 [(set_attr "conds" "set")]
2811 (define_insn "*notsi_compare0_scratch"
2812 [(set (reg:CC_NOOV CC_REGNUM)
2813 (compare:CC_NOOV (not:SI (match_operand:SI 1 "s_register_operand" "r"))
2815 (clobber (match_scratch:SI 0 "=r"))]
2818 [(set_attr "conds" "set")]
2821 ;; Fixed <--> Floating conversion insns
2823 (define_expand "floatsisf2"
2824 [(set (match_operand:SF 0 "s_register_operand" "")
2825 (float:SF (match_operand:SI 1 "s_register_operand" "")))]
2826 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
2830 emit_insn (gen_cirrus_floatsisf2 (operands[0], operands[1]));
2835 (define_expand "floatsidf2"
2836 [(set (match_operand:DF 0 "s_register_operand" "")
2837 (float:DF (match_operand:SI 1 "s_register_operand" "")))]
2838 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
2842 emit_insn (gen_cirrus_floatsidf2 (operands[0], operands[1]));
2847 (define_expand "fix_truncsfsi2"
2848 [(set (match_operand:SI 0 "s_register_operand" "")
2849 (fix:SI (fix:SF (match_operand:SF 1 "s_register_operand" ""))))]
2850 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
2854 if (!cirrus_fp_register (operands[0], SImode))
2855 operands[0] = force_reg (SImode, operands[0]);
2856 if (!cirrus_fp_register (operands[1], SFmode))
2857 operands[1] = force_reg (SFmode, operands[0]);
2858 emit_insn (gen_cirrus_truncsfsi2 (operands[0], operands[1]));
2863 (define_expand "fix_truncdfsi2"
2864 [(set (match_operand:SI 0 "s_register_operand" "")
2865 (fix:SI (fix:DF (match_operand:DF 1 "s_register_operand" ""))))]
2866 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
2870 if (!cirrus_fp_register (operands[1], DFmode))
2871 operands[1] = force_reg (DFmode, operands[0]);
2872 emit_insn (gen_cirrus_truncdfsi2 (operands[0], operands[1]));
2879 (define_expand "truncdfsf2"
2880 [(set (match_operand:SF 0 "s_register_operand" "")
2882 (match_operand:DF 1 "s_register_operand" "")))]
2883 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
2887 ;; Zero and sign extension instructions.
2889 (define_insn "zero_extendsidi2"
2890 [(set (match_operand:DI 0 "s_register_operand" "=r")
2891 (zero_extend:DI (match_operand:SI 1 "s_register_operand" "r")))]
2894 if (REGNO (operands[1])
2895 != REGNO (operands[0]) + (WORDS_BIG_ENDIAN ? 1 : 0))
2896 output_asm_insn (\"mov%?\\t%Q0, %1\", operands);
2897 return \"mov%?\\t%R0, #0\";
2899 [(set_attr "length" "8")
2900 (set_attr "predicable" "yes")]
2903 (define_insn "zero_extendqidi2"
2904 [(set (match_operand:DI 0 "s_register_operand" "=r,r")
2905 (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
2908 and%?\\t%Q0, %1, #255\;mov%?\\t%R0, #0
2909 ldr%?b\\t%Q0, %1\;mov%?\\t%R0, #0"
2910 [(set_attr "length" "8")
2911 (set_attr "predicable" "yes")
2912 (set_attr "type" "*,load")
2913 (set_attr "pool_range" "*,4092")
2914 (set_attr "neg_pool_range" "*,4084")]
2917 (define_insn "extendsidi2"
2918 [(set (match_operand:DI 0 "s_register_operand" "=r")
2919 (sign_extend:DI (match_operand:SI 1 "s_register_operand" "r")))]
2922 if (REGNO (operands[1])
2923 != REGNO (operands[0]) + (WORDS_BIG_ENDIAN ? 1 : 0))
2924 output_asm_insn (\"mov%?\\t%Q0, %1\", operands);
2925 return \"mov%?\\t%R0, %Q0, asr #31\";
2927 [(set_attr "length" "8")
2928 (set_attr "shift" "1")
2929 (set_attr "predicable" "yes")]
2932 (define_expand "zero_extendhisi2"
2934 (ashift:SI (match_operand:HI 1 "nonimmediate_operand" "")
2936 (set (match_operand:SI 0 "s_register_operand" "")
2937 (lshiftrt:SI (match_dup 2) (const_int 16)))]
2943 if (arm_arch4 && GET_CODE (operands[1]) == MEM)
2945 /* Note: We do not have to worry about TARGET_MMU_TRAPS
2946 here because the insn below will generate an LDRH instruction
2947 rather than an LDR instruction, so we cannot get an unaligned
2949 emit_insn (gen_rtx_SET (VOIDmode, operands[0],
2950 gen_rtx_ZERO_EXTEND (SImode,
2954 if (TARGET_MMU_TRAPS && GET_CODE (operands[1]) == MEM)
2956 emit_insn (gen_movhi_bytes (operands[0], operands[1]));
2959 if (!s_register_operand (operands[1], HImode))
2960 operands[1] = copy_to_mode_reg (HImode, operands[1]);
2961 operands[1] = gen_lowpart (SImode, operands[1]);
2962 operands[2] = gen_reg_rtx (SImode);
2964 else /* TARGET_THUMB */
2966 if (GET_CODE (operands[1]) == MEM)
2970 tmp = gen_rtx_ZERO_EXTEND (SImode, operands[1]);
2971 tmp = gen_rtx_SET (VOIDmode, operands[0], tmp);
2978 if (!s_register_operand (operands[1], HImode))
2979 operands[1] = copy_to_mode_reg (HImode, operands[1]);
2980 operands[1] = gen_lowpart (SImode, operands[1]);
2981 operands[2] = gen_reg_rtx (SImode);
2983 ops[0] = operands[2];
2984 ops[1] = operands[1];
2985 ops[2] = GEN_INT (16);
2987 emit_insn (gen_rtx_SET (VOIDmode, ops[0],
2988 gen_rtx_ASHIFT (SImode, ops[1], ops[2])));
2990 ops[0] = operands[0];
2991 ops[1] = operands[2];
2992 ops[2] = GEN_INT (16);
2994 emit_insn (gen_rtx_SET (VOIDmode, ops[0],
2995 gen_rtx_LSHIFTRT (SImode, ops[1],
3003 (define_insn "*thumb_zero_extendhisi2"
3004 [(set (match_operand:SI 0 "register_operand" "=l")
3005 (zero_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
3008 rtx mem = XEXP (operands[1], 0);
3010 if (GET_CODE (mem) == CONST)
3011 mem = XEXP (mem, 0);
3013 if (GET_CODE (mem) == LABEL_REF)
3014 return \"ldr\\t%0, %1\";
3016 if (GET_CODE (mem) == PLUS)
3018 rtx a = XEXP (mem, 0);
3019 rtx b = XEXP (mem, 1);
3021 /* This can happen due to bugs in reload. */
3022 if (GET_CODE (a) == REG && REGNO (a) == SP_REGNUM)
3025 ops[0] = operands[0];
3028 output_asm_insn (\"mov %0, %1\", ops);
3030 XEXP (mem, 0) = operands[0];
3033 else if ( GET_CODE (a) == LABEL_REF
3034 && GET_CODE (b) == CONST_INT)
3035 return \"ldr\\t%0, %1\";
3038 return \"ldrh\\t%0, %1\";
3040 [(set_attr "length" "4")
3041 (set_attr "type" "load")
3042 (set_attr "pool_range" "60")]
3045 (define_insn "*arm_zero_extendhisi2"
3046 [(set (match_operand:SI 0 "s_register_operand" "=r")
3047 (zero_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
3048 "TARGET_ARM && arm_arch4"
3050 [(set_attr "type" "load")
3051 (set_attr "predicable" "yes")
3052 (set_attr "pool_range" "256")
3053 (set_attr "neg_pool_range" "244")]
3057 [(set (match_operand:SI 0 "s_register_operand" "")
3058 (zero_extend:SI (match_operand:HI 1 "alignable_memory_operand" "")))
3059 (clobber (match_operand:SI 2 "s_register_operand" ""))]
3060 "TARGET_ARM && (!arm_arch4)"
3061 [(set (match_dup 2) (match_dup 1))
3062 (set (match_dup 0) (lshiftrt:SI (match_dup 2) (const_int 16)))]
3064 if ((operands[1] = arm_gen_rotated_half_load (operands[1])) == NULL)
3070 [(set (match_operand:SI 0 "s_register_operand" "")
3071 (match_operator:SI 3 "shiftable_operator"
3072 [(zero_extend:SI (match_operand:HI 1 "alignable_memory_operand" ""))
3073 (match_operand:SI 4 "s_register_operand" "")]))
3074 (clobber (match_operand:SI 2 "s_register_operand" ""))]
3075 "TARGET_ARM && (!arm_arch4)"
3076 [(set (match_dup 2) (match_dup 1))
3079 [(lshiftrt:SI (match_dup 2) (const_int 16)) (match_dup 4)]))]
3081 if ((operands[1] = arm_gen_rotated_half_load (operands[1])) == NULL)
3086 (define_expand "zero_extendqisi2"
3087 [(set (match_operand:SI 0 "s_register_operand" "")
3088 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
3091 if (GET_CODE (operands[1]) != MEM)
3095 emit_insn (gen_andsi3 (operands[0],
3096 gen_lowpart (SImode, operands[1]),
3099 else /* TARGET_THUMB */
3101 rtx temp = gen_reg_rtx (SImode);
3104 operands[1] = copy_to_mode_reg (QImode, operands[1]);
3105 operands[1] = gen_lowpart (SImode, operands[1]);
3108 ops[1] = operands[1];
3109 ops[2] = GEN_INT (24);
3111 emit_insn (gen_rtx_SET (VOIDmode, ops[0],
3112 gen_rtx_ASHIFT (SImode, ops[1], ops[2])));
3114 ops[0] = operands[0];
3116 ops[2] = GEN_INT (24);
3118 emit_insn (gen_rtx_SET (VOIDmode, ops[0],
3119 gen_rtx_LSHIFTRT (SImode, ops[1], ops[2])));
3126 (define_insn "*thumb_zero_extendqisi2"
3127 [(set (match_operand:SI 0 "register_operand" "=l")
3128 (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
3131 [(set_attr "length" "2")
3132 (set_attr "type" "load")
3133 (set_attr "pool_range" "32")]
3136 (define_insn "*arm_zero_extendqisi2"
3137 [(set (match_operand:SI 0 "s_register_operand" "=r")
3138 (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
3140 "ldr%?b\\t%0, %1\\t%@ zero_extendqisi2"
3141 [(set_attr "type" "load")
3142 (set_attr "predicable" "yes")
3143 (set_attr "pool_range" "4096")
3144 (set_attr "neg_pool_range" "4084")]
3148 [(set (match_operand:SI 0 "s_register_operand" "")
3149 (zero_extend:SI (subreg:QI (match_operand:SI 1 "" "") 0)))
3150 (clobber (match_operand:SI 2 "s_register_operand" ""))]
3151 "TARGET_ARM && (GET_CODE (operands[1]) != MEM) && ! BYTES_BIG_ENDIAN"
3152 [(set (match_dup 2) (match_dup 1))
3153 (set (match_dup 0) (and:SI (match_dup 2) (const_int 255)))]
3157 (define_insn "*compareqi_eq0"
3158 [(set (reg:CC_Z CC_REGNUM)
3159 (compare:CC_Z (match_operand:QI 0 "s_register_operand" "r")
3163 [(set_attr "conds" "set")]
3166 (define_expand "extendhisi2"
3168 (ashift:SI (match_operand:HI 1 "nonimmediate_operand" "")
3170 (set (match_operand:SI 0 "s_register_operand" "")
3171 (ashiftrt:SI (match_dup 2)
3176 if (TARGET_ARM && arm_arch4 && GET_CODE (operands[1]) == MEM)
3178 /* Note: We do not have to worry about TARGET_MMU_TRAPS
3179 here because the insn below will generate an LDRH instruction
3180 rather than an LDR instruction, so we cannot get an unaligned
3182 emit_insn (gen_rtx_SET (VOIDmode, operands[0],
3183 gen_rtx_SIGN_EXTEND (SImode, operands[1])));
3187 if (TARGET_ARM && TARGET_MMU_TRAPS && GET_CODE (operands[1]) == MEM)
3189 emit_insn (gen_extendhisi2_mem (operands[0], operands[1]));
3192 if (!s_register_operand (operands[1], HImode))
3193 operands[1] = copy_to_mode_reg (HImode, operands[1]);
3194 operands[1] = gen_lowpart (SImode, operands[1]);
3195 operands[2] = gen_reg_rtx (SImode);
3201 ops[0] = operands[2];
3202 ops[1] = operands[1];
3203 ops[2] = GEN_INT (16);
3205 emit_insn (gen_rtx_SET (VOIDmode, ops[0],
3206 gen_rtx_ASHIFT (SImode, ops[1], ops[2])));
3208 ops[0] = operands[0];
3209 ops[1] = operands[2];
3210 ops[2] = GEN_INT (16);
3212 emit_insn (gen_rtx_SET (VOIDmode, ops[0],
3213 gen_rtx_ASHIFTRT (SImode, ops[1], ops[2])));
3220 (define_insn "*thumb_extendhisi2_insn"
3221 [(set (match_operand:SI 0 "register_operand" "=l")
3222 (sign_extend:SI (match_operand:HI 1 "memory_operand" "m")))
3223 (clobber (match_scratch:SI 2 "=&l"))]
3228 rtx mem = XEXP (operands[1], 0);
3230 /* This code used to try to use 'V', and fix the address only if it was
3231 offsettable, but this fails for e.g. REG+48 because 48 is outside the
3232 range of QImode offsets, and offsettable_address_p does a QImode
3235 if (GET_CODE (mem) == CONST)
3236 mem = XEXP (mem, 0);
3238 if (GET_CODE (mem) == LABEL_REF)
3239 return \"ldr\\t%0, %1\";
3241 if (GET_CODE (mem) == PLUS)
3243 rtx a = XEXP (mem, 0);
3244 rtx b = XEXP (mem, 1);
3246 if (GET_CODE (a) == LABEL_REF
3247 && GET_CODE (b) == CONST_INT)
3248 return \"ldr\\t%0, %1\";
3250 if (GET_CODE (b) == REG)
3251 return \"ldrsh\\t%0, %1\";
3259 ops[2] = const0_rtx;
3262 if (GET_CODE (ops[1]) != REG)
3268 ops[0] = operands[0];
3269 ops[3] = operands[2];
3270 output_asm_insn (\"mov\\t%3, %2\;ldrsh\\t%0, [%1, %3]\", ops);
3273 [(set_attr "length" "4")
3274 (set_attr "type" "load")
3275 (set_attr "pool_range" "1020")]
3278 (define_expand "extendhisi2_mem"
3279 [(set (match_dup 2) (zero_extend:SI (match_operand:HI 1 "" "")))
3281 (zero_extend:SI (match_dup 7)))
3282 (set (match_dup 6) (ashift:SI (match_dup 4) (const_int 24)))
3283 (set (match_operand:SI 0 "" "")
3284 (ior:SI (ashiftrt:SI (match_dup 6) (const_int 16)) (match_dup 5)))]
3289 rtx addr = copy_to_mode_reg (SImode, XEXP (operands[1], 0));
3291 mem1 = gen_rtx_MEM (QImode, addr);
3292 MEM_COPY_ATTRIBUTES (mem1, operands[1]);
3293 mem2 = gen_rtx_MEM (QImode, plus_constant (addr, 1));
3294 MEM_COPY_ATTRIBUTES (mem2, operands[1]);
3295 operands[0] = gen_lowpart (SImode, operands[0]);
3297 operands[2] = gen_reg_rtx (SImode);
3298 operands[3] = gen_reg_rtx (SImode);
3299 operands[6] = gen_reg_rtx (SImode);
3302 if (BYTES_BIG_ENDIAN)
3304 operands[4] = operands[2];
3305 operands[5] = operands[3];
3309 operands[4] = operands[3];
3310 operands[5] = operands[2];
3315 (define_insn "*arm_extendhisi_insn"
3316 [(set (match_operand:SI 0 "s_register_operand" "=r")
3317 (sign_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
3318 "TARGET_ARM && arm_arch4"
3320 [(set_attr "type" "load")
3321 (set_attr "predicable" "yes")
3322 (set_attr "pool_range" "256")
3323 (set_attr "neg_pool_range" "244")]
3327 [(set (match_operand:SI 0 "s_register_operand" "")
3328 (sign_extend:SI (match_operand:HI 1 "alignable_memory_operand" "")))
3329 (clobber (match_operand:SI 2 "s_register_operand" ""))]
3330 "TARGET_ARM && (!arm_arch4)"
3331 [(set (match_dup 2) (match_dup 1))
3332 (set (match_dup 0) (ashiftrt:SI (match_dup 2) (const_int 16)))]
3334 if ((operands[1] = arm_gen_rotated_half_load (operands[1])) == NULL)
3340 [(set (match_operand:SI 0 "s_register_operand" "")
3341 (match_operator:SI 3 "shiftable_operator"
3342 [(sign_extend:SI (match_operand:HI 1 "alignable_memory_operand" ""))
3343 (match_operand:SI 4 "s_register_operand" "")]))
3344 (clobber (match_operand:SI 2 "s_register_operand" ""))]
3345 "TARGET_ARM && (!arm_arch4)"
3346 [(set (match_dup 2) (match_dup 1))
3349 [(ashiftrt:SI (match_dup 2) (const_int 16)) (match_dup 4)]))]
3350 "if ((operands[1] = arm_gen_rotated_half_load (operands[1])) == NULL)
3355 (define_expand "extendqihi2"
3357 (ashift:SI (match_operand:QI 1 "general_operand" "")
3359 (set (match_operand:HI 0 "s_register_operand" "")
3360 (ashiftrt:SI (match_dup 2)
3365 if (arm_arch4 && GET_CODE (operands[1]) == MEM)
3367 emit_insn (gen_rtx_SET (VOIDmode,
3369 gen_rtx_SIGN_EXTEND (HImode, operands[1])));
3372 if (!s_register_operand (operands[1], QImode))
3373 operands[1] = copy_to_mode_reg (QImode, operands[1]);
3374 operands[0] = gen_lowpart (SImode, operands[0]);
3375 operands[1] = gen_lowpart (SImode, operands[1]);
3376 operands[2] = gen_reg_rtx (SImode);
3380 ; Rather than restricting all byte accesses to memory addresses that ldrsb
3381 ; can handle, we fix up the ones that ldrsb can't grok with a split.
3382 (define_insn "*extendqihi_insn"
3383 [(set (match_operand:HI 0 "s_register_operand" "=r")
3384 (sign_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
3385 "TARGET_ARM && arm_arch4"
3387 /* If the address is invalid, this will split the instruction into two. */
3388 if (bad_signed_byte_operand (operands[1], VOIDmode))
3390 return \"ldr%?sb\\t%0, %1\";
3392 [(set_attr "type" "load")
3393 (set_attr "predicable" "yes")
3394 (set_attr "length" "8")
3395 (set_attr "pool_range" "256")
3396 (set_attr "neg_pool_range" "244")]
3400 [(set (match_operand:HI 0 "s_register_operand" "")
3401 (sign_extend:HI (match_operand:QI 1 "bad_signed_byte_operand" "")))]
3402 "TARGET_ARM && arm_arch4 && reload_completed"
3403 [(set (match_dup 3) (match_dup 1))
3404 (set (match_dup 0) (sign_extend:HI (match_dup 2)))]
3407 HOST_WIDE_INT offset;
3409 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]));
3410 operands[2] = gen_rtx_MEM (QImode, operands[3]);
3411 MEM_COPY_ATTRIBUTES (operands[2], operands[1]);
3412 operands[1] = XEXP (operands[1], 0);
3413 if (GET_CODE (operands[1]) == PLUS
3414 && GET_CODE (XEXP (operands[1], 1)) == CONST_INT
3415 && !(const_ok_for_arm (offset = INTVAL (XEXP (operands[1], 1)))
3416 || const_ok_for_arm (-offset)))
3418 HOST_WIDE_INT low = (offset > 0
3419 ? (offset & 0xff) : -((-offset) & 0xff));
3420 XEXP (operands[2], 0) = plus_constant (operands[3], low);
3421 operands[1] = plus_constant (XEXP (operands[1], 0), offset - low);
3423 /* Ensure the sum is in correct canonical form */
3424 else if (GET_CODE (operands[1]) == PLUS
3425 && GET_CODE (XEXP (operands[1], 1)) != CONST_INT
3426 && !s_register_operand (XEXP (operands[1], 1), VOIDmode))
3427 operands[1] = gen_rtx_PLUS (GET_MODE (operands[1]),
3428 XEXP (operands[1], 1),
3429 XEXP (operands[1], 0));
3433 (define_expand "extendqisi2"
3435 (ashift:SI (match_operand:QI 1 "general_operand" "")
3437 (set (match_operand:SI 0 "s_register_operand" "")
3438 (ashiftrt:SI (match_dup 2)
3443 if (TARGET_ARM && arm_arch4 && GET_CODE (operands[1]) == MEM)
3445 emit_insn (gen_rtx_SET (VOIDmode,
3447 gen_rtx_SIGN_EXTEND (SImode, operands[1])));
3450 if (!s_register_operand (operands[1], QImode))
3451 operands[1] = copy_to_mode_reg (QImode, operands[1]);
3452 operands[1] = gen_lowpart (SImode, operands[1]);
3453 operands[2] = gen_reg_rtx (SImode);
3459 ops[0] = operands[2];
3460 ops[1] = operands[1];
3461 ops[2] = GEN_INT (24);
3463 emit_insn (gen_rtx_SET (VOIDmode, ops[0],
3464 gen_rtx_ASHIFT (SImode, ops[1], ops[2])));
3466 ops[0] = operands[0];
3467 ops[1] = operands[2];
3468 ops[2] = GEN_INT (24);
3470 emit_insn (gen_rtx_SET (VOIDmode, ops[0],
3471 gen_rtx_ASHIFTRT (SImode, ops[1], ops[2])));
3478 ; Rather than restricting all byte accesses to memory addresses that ldrsb
3479 ; can handle, we fix up the ones that ldrsb can't grok with a split.
3480 (define_insn "*arm_extendqisi_insn"
3481 [(set (match_operand:SI 0 "s_register_operand" "=r")
3482 (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
3483 "TARGET_ARM && arm_arch4"
3485 /* If the address is invalid, this will split the instruction into two. */
3486 if (bad_signed_byte_operand (operands[1], VOIDmode))
3488 return \"ldr%?sb\\t%0, %1\";
3490 [(set_attr "type" "load")
3491 (set_attr "predicable" "yes")
3492 (set_attr "length" "8")
3493 (set_attr "pool_range" "256")
3494 (set_attr "neg_pool_range" "244")]
3498 [(set (match_operand:SI 0 "s_register_operand" "")
3499 (sign_extend:SI (match_operand:QI 1 "bad_signed_byte_operand" "")))]
3500 "TARGET_ARM && arm_arch4 && reload_completed"
3501 [(set (match_dup 0) (match_dup 1))
3502 (set (match_dup 0) (sign_extend:SI (match_dup 2)))]
3505 HOST_WIDE_INT offset;
3507 operands[2] = gen_rtx_MEM (QImode, operands[0]);
3508 MEM_COPY_ATTRIBUTES (operands[2], operands[1]);
3509 operands[1] = XEXP (operands[1], 0);
3510 if (GET_CODE (operands[1]) == PLUS
3511 && GET_CODE (XEXP (operands[1], 1)) == CONST_INT
3512 && !(const_ok_for_arm (offset = INTVAL (XEXP (operands[1], 1)))
3513 || const_ok_for_arm (-offset)))
3515 HOST_WIDE_INT low = (offset > 0
3516 ? (offset & 0xff) : -((-offset) & 0xff));
3517 XEXP (operands[2], 0) = plus_constant (operands[0], low);
3518 operands[1] = plus_constant (XEXP (operands[1], 0), offset - low);
3520 /* Ensure the sum is in correct canonical form */
3521 else if (GET_CODE (operands[1]) == PLUS
3522 && GET_CODE (XEXP (operands[1], 1)) != CONST_INT
3523 && !s_register_operand (XEXP (operands[1], 1), VOIDmode))
3524 operands[1] = gen_rtx_PLUS (GET_MODE (operands[1]),
3525 XEXP (operands[1], 1),
3526 XEXP (operands[1], 0));
3530 (define_insn "*thumb_extendqisi2_insn"
3531 [(set (match_operand:SI 0 "register_operand" "=l,l")
3532 (sign_extend:SI (match_operand:QI 1 "memory_operand" "V,m")))]
3537 rtx mem = XEXP (operands[1], 0);
3539 if (GET_CODE (mem) == CONST)
3540 mem = XEXP (mem, 0);
3542 if (GET_CODE (mem) == LABEL_REF)
3543 return \"ldr\\t%0, %1\";
3545 if (GET_CODE (mem) == PLUS
3546 && GET_CODE (XEXP (mem, 0)) == LABEL_REF)
3547 return \"ldr\\t%0, %1\";
3549 if (which_alternative == 0)
3550 return \"ldrsb\\t%0, %1\";
3552 ops[0] = operands[0];
3554 if (GET_CODE (mem) == PLUS)
3556 rtx a = XEXP (mem, 0);
3557 rtx b = XEXP (mem, 1);
3562 if (GET_CODE (a) == REG)
3564 if (GET_CODE (b) == REG)
3565 output_asm_insn (\"ldrsb\\t%0, [%1, %2]\", ops);
3566 else if (REGNO (a) == REGNO (ops[0]))
3568 output_asm_insn (\"ldrb\\t%0, [%1, %2]\", ops);
3569 output_asm_insn (\"lsl\\t%0, %0, #24\", ops);
3570 output_asm_insn (\"asr\\t%0, %0, #24\", ops);
3573 output_asm_insn (\"mov\\t%0, %2\;ldrsb\\t%0, [%1, %0]\", ops);
3575 else if (GET_CODE (b) != REG)
3579 if (REGNO (b) == REGNO (ops[0]))
3581 output_asm_insn (\"ldrb\\t%0, [%2, %1]\", ops);
3582 output_asm_insn (\"lsl\\t%0, %0, #24\", ops);
3583 output_asm_insn (\"asr\\t%0, %0, #24\", ops);
3586 output_asm_insn (\"mov\\t%0, %2\;ldrsb\\t%0, [%1, %0]\", ops);
3589 else if (GET_CODE (mem) == REG && REGNO (ops[0]) == REGNO (mem))
3591 output_asm_insn (\"ldrb\\t%0, [%0, #0]\", ops);
3592 output_asm_insn (\"lsl\\t%0, %0, #24\", ops);
3593 output_asm_insn (\"asr\\t%0, %0, #24\", ops);
3598 ops[2] = const0_rtx;
3600 output_asm_insn (\"mov\\t%0, %2\;ldrsb\\t%0, [%1, %0]\", ops);
3604 [(set_attr "length" "2,6")
3605 (set_attr "type" "load,load")
3606 (set_attr "pool_range" "32,32")]
3609 (define_expand "extendsfdf2"
3610 [(set (match_operand:DF 0 "s_register_operand" "")
3611 (float_extend:DF (match_operand:SF 1 "s_register_operand" "")))]
3612 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
3616 ;; Move insns (including loads and stores)
3618 ;; XXX Just some ideas about movti.
3619 ;; I don't think these are a good idea on the arm, there just aren't enough
3621 ;;(define_expand "loadti"
3622 ;; [(set (match_operand:TI 0 "s_register_operand" "")
3623 ;; (mem:TI (match_operand:SI 1 "address_operand" "")))]
3626 ;;(define_expand "storeti"
3627 ;; [(set (mem:TI (match_operand:TI 0 "address_operand" ""))
3628 ;; (match_operand:TI 1 "s_register_operand" ""))]
3631 ;;(define_expand "movti"
3632 ;; [(set (match_operand:TI 0 "general_operand" "")
3633 ;; (match_operand:TI 1 "general_operand" ""))]
3639 ;; if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3640 ;; operands[1] = copy_to_reg (operands[1]);
3641 ;; if (GET_CODE (operands[0]) == MEM)
3642 ;; insn = gen_storeti (XEXP (operands[0], 0), operands[1]);
3643 ;; else if (GET_CODE (operands[1]) == MEM)
3644 ;; insn = gen_loadti (operands[0], XEXP (operands[1], 0));
3648 ;; emit_insn (insn);
3652 ;; Recognize garbage generated above.
3655 ;; [(set (match_operand:TI 0 "general_operand" "=r,r,r,<,>,m")
3656 ;; (match_operand:TI 1 "general_operand" "<,>,m,r,r,r"))]
3660 ;; register mem = (which_alternative < 3);
3661 ;; register const char *template;
3663 ;; operands[mem] = XEXP (operands[mem], 0);
3664 ;; switch (which_alternative)
3666 ;; case 0: template = \"ldmdb\\t%1!, %M0\"; break;
3667 ;; case 1: template = \"ldmia\\t%1!, %M0\"; break;
3668 ;; case 2: template = \"ldmia\\t%1, %M0\"; break;
3669 ;; case 3: template = \"stmdb\\t%0!, %M1\"; break;
3670 ;; case 4: template = \"stmia\\t%0!, %M1\"; break;
3671 ;; case 5: template = \"stmia\\t%0, %M1\"; break;
3673 ;; output_asm_insn (template, operands);
3677 (define_expand "movdi"
3678 [(set (match_operand:DI 0 "general_operand" "")
3679 (match_operand:DI 1 "general_operand" ""))]
3684 if (!no_new_pseudos)
3686 if (GET_CODE (operands[0]) != REG)
3687 operands[1] = force_reg (DImode, operands[1]);
3693 (define_insn "*arm_movdi"
3694 [(set (match_operand:DI 0 "nonimmediate_di_operand" "=r, r, o<>")
3695 (match_operand:DI 1 "di_operand" "rIK,mi,r"))]
3696 "TARGET_ARM && !TARGET_CIRRUS && ! TARGET_IWMMXT"
3698 return (output_move_double (operands));
3700 [(set_attr "length" "8")
3701 (set_attr "type" "*,load,store2")
3702 (set_attr "pool_range" "*,1020,*")
3703 (set_attr "neg_pool_range" "*,1008,*")]
3706 ;;; ??? This should have alternatives for constants.
3707 ;;; ??? This was originally identical to the movdf_insn pattern.
3708 ;;; ??? The 'i' constraint looks funny, but it should always be replaced by
3709 ;;; thumb_reorg with a memory reference.
3710 (define_insn "*thumb_movdi_insn"
3711 [(set (match_operand:DI 0 "nonimmediate_operand" "=l,l,l,l,>,l, m,*r")
3712 (match_operand:DI 1 "general_operand" "l, I,J,>,l,mi,l,*r"))]
3715 && ( register_operand (operands[0], DImode)
3716 || register_operand (operands[1], DImode))"
3719 switch (which_alternative)
3723 if (REGNO (operands[1]) == REGNO (operands[0]) + 1)
3724 return \"add\\t%0, %1, #0\;add\\t%H0, %H1, #0\";
3725 return \"add\\t%H0, %H1, #0\;add\\t%0, %1, #0\";
3727 return \"mov\\t%Q0, %1\;mov\\t%R0, #0\";
3729 operands[1] = GEN_INT (- INTVAL (operands[1]));
3730 return \"mov\\t%Q0, %1\;neg\\t%Q0, %Q0\;asr\\t%R0, %Q0, #31\";
3732 return \"ldmia\\t%1, {%0, %H0}\";
3734 return \"stmia\\t%0, {%1, %H1}\";
3736 return thumb_load_double_from_address (operands);
3738 operands[2] = gen_rtx (MEM, SImode,
3739 plus_constant (XEXP (operands[0], 0), 4));
3740 output_asm_insn (\"str\\t%1, %0\;str\\t%H1, %2\", operands);
3743 if (REGNO (operands[1]) == REGNO (operands[0]) + 1)
3744 return \"mov\\t%0, %1\;mov\\t%H0, %H1\";
3745 return \"mov\\t%H0, %H1\;mov\\t%0, %1\";
3748 [(set_attr "length" "4,4,6,2,2,6,4,4")
3749 (set_attr "type" "*,*,*,load,store2,load,store2,*")
3750 (set_attr "pool_range" "*,*,*,*,*,1020,*,*")]
3753 (define_expand "movsi"
3754 [(set (match_operand:SI 0 "general_operand" "")
3755 (match_operand:SI 1 "general_operand" ""))]
3760 /* Everything except mem = const or mem = mem can be done easily */
3761 if (GET_CODE (operands[0]) == MEM)
3762 operands[1] = force_reg (SImode, operands[1]);
3763 if (GET_CODE (operands[1]) == CONST_INT
3764 && !(const_ok_for_arm (INTVAL (operands[1]))
3765 || const_ok_for_arm (~INTVAL (operands[1]))))
3767 arm_split_constant (SET, SImode, INTVAL (operands[1]), operands[0],
3770 : preserve_subexpressions_p ()));
3774 else /* TARGET_THUMB.... */
3776 if (!no_new_pseudos)
3778 if (GET_CODE (operands[0]) != REG)
3779 operands[1] = force_reg (SImode, operands[1]);
3784 && (CONSTANT_P (operands[1])
3785 || symbol_mentioned_p (operands[1])
3786 || label_mentioned_p (operands[1])))
3787 operands[1] = legitimize_pic_address (operands[1], SImode,
3788 (no_new_pseudos ? operands[0] : 0));
3792 (define_insn "*arm_movsi_insn"
3793 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r, m")
3794 (match_operand:SI 1 "general_operand" "rI,K,mi,r"))]
3795 "TARGET_ARM && ! TARGET_IWMMXT
3796 && ( register_operand (operands[0], SImode)
3797 || register_operand (operands[1], SImode))"
3803 [(set_attr "type" "*,*,load,store1")
3804 (set_attr "predicable" "yes")
3805 (set_attr "pool_range" "*,*,4096,*")
3806 (set_attr "neg_pool_range" "*,*,4084,*")]
3810 [(set (match_operand:SI 0 "s_register_operand" "")
3811 (match_operand:SI 1 "const_int_operand" ""))]
3813 && (!(const_ok_for_arm (INTVAL (operands[1]))
3814 || const_ok_for_arm (~INTVAL (operands[1]))))"
3815 [(clobber (const_int 0))]
3817 arm_split_constant (SET, SImode, INTVAL (operands[1]), operands[0],
3823 (define_insn "*thumb_movsi_insn"
3824 [(set (match_operand:SI 0 "nonimmediate_operand" "=l,l,l,l,l,>,l, m,*lh")
3825 (match_operand:SI 1 "general_operand" "l, I,J,K,>,l,mi,l,*lh"))]
3827 && ( register_operand (operands[0], SImode)
3828 || register_operand (operands[1], SImode))"
3839 [(set_attr "length" "2,2,4,4,2,2,2,2,2")
3840 (set_attr "type" "*,*,*,*,load,store1,load,store1,*")
3841 (set_attr "pool_range" "*,*,*,*,*,*,1020,*,*")]
3845 [(set (match_operand:SI 0 "register_operand" "")
3846 (match_operand:SI 1 "const_int_operand" ""))]
3847 "TARGET_THUMB && CONST_OK_FOR_THUMB_LETTER (INTVAL (operands[1]), 'J')"
3848 [(set (match_dup 0) (match_dup 1))
3849 (set (match_dup 0) (neg:SI (match_dup 0)))]
3850 "operands[1] = GEN_INT (- INTVAL (operands[1]));"
3854 [(set (match_operand:SI 0 "register_operand" "")
3855 (match_operand:SI 1 "const_int_operand" ""))]
3856 "TARGET_THUMB && CONST_OK_FOR_THUMB_LETTER (INTVAL (operands[1]), 'K')"
3857 [(set (match_dup 0) (match_dup 1))
3858 (set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))]
3861 unsigned HOST_WIDE_INT val = INTVAL (operands[1]);
3862 unsigned HOST_WIDE_INT mask = 0xff;
3865 for (i = 0; i < 25; i++)
3866 if ((val & (mask << i)) == val)
3869 /* Shouldn't happen, but we don't want to split if the shift is zero. */
3873 operands[1] = GEN_INT (val >> i);
3874 operands[2] = GEN_INT (i);
3878 ;; When generating pic, we need to load the symbol offset into a register.
3879 ;; So that the optimizer does not confuse this with a normal symbol load
3880 ;; we use an unspec. The offset will be loaded from a constant pool entry,
3881 ;; since that is the only type of relocation we can use.
3883 ;; The rather odd constraints on the following are to force reload to leave
3884 ;; the insn alone, and to force the minipool generation pass to then move
3885 ;; the GOT symbol to memory.
3887 (define_insn "pic_load_addr_arm"
3888 [(set (match_operand:SI 0 "s_register_operand" "=r")
3889 (unspec:SI [(match_operand:SI 1 "" "mX")] UNSPEC_PIC_SYM))]
3890 "TARGET_ARM && flag_pic"
3892 [(set_attr "type" "load")
3893 (set (attr "pool_range") (const_int 4096))
3894 (set (attr "neg_pool_range") (const_int 4084))]
3897 (define_insn "pic_load_addr_thumb"
3898 [(set (match_operand:SI 0 "s_register_operand" "=l")
3899 (unspec:SI [(match_operand:SI 1 "" "mX")] UNSPEC_PIC_SYM))]
3900 "TARGET_THUMB && flag_pic"
3902 [(set_attr "type" "load")
3903 (set (attr "pool_range") (const_int 1024))]
3906 ;; This variant is used for AOF assembly, since it needs to mention the
3907 ;; pic register in the rtl.
3908 (define_expand "pic_load_addr_based"
3909 [(set (match_operand:SI 0 "s_register_operand" "")
3910 (unspec:SI [(match_operand 1 "" "") (match_dup 2)] UNSPEC_PIC_SYM))]
3911 "TARGET_ARM && flag_pic"
3912 "operands[2] = pic_offset_table_rtx;"
3915 (define_insn "*pic_load_addr_based_insn"
3916 [(set (match_operand:SI 0 "s_register_operand" "=r")
3917 (unspec:SI [(match_operand 1 "" "")
3918 (match_operand 2 "s_register_operand" "r")]
3920 "TARGET_EITHER && flag_pic && operands[2] == pic_offset_table_rtx"
3922 #ifdef AOF_ASSEMBLER
3923 operands[1] = aof_pic_entry (operands[1]);
3925 output_asm_insn (\"ldr%?\\t%0, %a1\", operands);
3928 [(set_attr "type" "load")
3929 (set (attr "pool_range")
3930 (if_then_else (eq_attr "is_thumb" "yes")
3933 (set (attr "neg_pool_range")
3934 (if_then_else (eq_attr "is_thumb" "yes")
3939 (define_insn "pic_add_dot_plus_four"
3940 [(set (match_operand:SI 0 "register_operand" "+r")
3941 (unspec:SI [(plus:SI (match_dup 0)
3942 (const (plus:SI (pc) (const_int 4))))]
3944 (use (label_ref (match_operand 1 "" "")))]
3945 "TARGET_THUMB && flag_pic"
3947 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
3948 CODE_LABEL_NUMBER (operands[1]));
3949 return \"add\\t%0, %|pc\";
3951 [(set_attr "length" "2")]
3954 (define_insn "pic_add_dot_plus_eight"
3955 [(set (match_operand:SI 0 "register_operand" "+r")
3956 (unspec:SI [(plus:SI (match_dup 0)
3957 (const (plus:SI (pc) (const_int 8))))]
3959 (use (label_ref (match_operand 1 "" "")))]
3960 "TARGET_ARM && flag_pic"
3962 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
3963 CODE_LABEL_NUMBER (operands[1]));
3964 return \"add%?\\t%0, %|pc, %0\";
3966 [(set_attr "predicable" "yes")]
3969 (define_expand "builtin_setjmp_receiver"
3970 [(label_ref (match_operand 0 "" ""))]
3974 arm_finalize_pic (0);
3978 ;; If copying one reg to another we can set the condition codes according to
3979 ;; its value. Such a move is common after a return from subroutine and the
3980 ;; result is being tested against zero.
3982 (define_insn "*movsi_compare0"
3983 [(set (reg:CC CC_REGNUM)
3984 (compare:CC (match_operand:SI 1 "s_register_operand" "0,r")
3986 (set (match_operand:SI 0 "s_register_operand" "=r,r")
3991 sub%?s\\t%0, %1, #0"
3992 [(set_attr "conds" "set")]
3995 ;; Subroutine to store a half word from a register into memory.
3996 ;; Operand 0 is the source register (HImode)
3997 ;; Operand 1 is the destination address in a register (SImode)
3999 ;; In both this routine and the next, we must be careful not to spill
4000 ;; a memory address of reg+large_const into a separate PLUS insn, since this
4001 ;; can generate unrecognizable rtl.
4003 (define_expand "storehi"
4004 [;; store the low byte
4005 (set (match_operand 1 "" "") (match_dup 3))
4006 ;; extract the high byte
4008 (ashiftrt:SI (match_operand 0 "" "") (const_int 8)))
4009 ;; store the high byte
4010 (set (match_dup 4) (subreg:QI (match_dup 2) 0))] ;explicit subreg safe
4014 rtx op1 = operands[1];
4015 rtx addr = XEXP (op1, 0);
4016 enum rtx_code code = GET_CODE (addr);
4018 if ((code == PLUS && GET_CODE (XEXP (addr, 1)) != CONST_INT)
4020 op1 = replace_equiv_address (operands[1], force_reg (SImode, addr));
4022 operands[4] = adjust_address (op1, QImode, 1);
4023 operands[1] = adjust_address (operands[1], QImode, 0);
4024 operands[3] = gen_lowpart (QImode, operands[0]);
4025 operands[0] = gen_lowpart (SImode, operands[0]);
4026 operands[2] = gen_reg_rtx (SImode);
4030 (define_expand "storehi_bigend"
4031 [(set (match_dup 4) (match_dup 3))
4033 (ashiftrt:SI (match_operand 0 "" "") (const_int 8)))
4034 (set (match_operand 1 "" "") (subreg:QI (match_dup 2) 3))]
4038 rtx op1 = operands[1];
4039 rtx addr = XEXP (op1, 0);
4040 enum rtx_code code = GET_CODE (addr);
4042 if ((code == PLUS && GET_CODE (XEXP (addr, 1)) != CONST_INT)
4044 op1 = replace_equiv_address (op1, force_reg (SImode, addr));
4046 operands[4] = adjust_address (op1, QImode, 1);
4047 operands[1] = adjust_address (operands[1], QImode, 0);
4048 operands[3] = gen_lowpart (QImode, operands[0]);
4049 operands[0] = gen_lowpart (SImode, operands[0]);
4050 operands[2] = gen_reg_rtx (SImode);
4054 ;; Subroutine to store a half word integer constant into memory.
4055 (define_expand "storeinthi"
4056 [(set (match_operand 0 "" "")
4057 (subreg:QI (match_operand 1 "" "") 0))
4058 (set (match_dup 3) (match_dup 2))]
4062 HOST_WIDE_INT value = INTVAL (operands[1]);
4063 rtx addr = XEXP (operands[0], 0);
4064 rtx op0 = operands[0];
4065 enum rtx_code code = GET_CODE (addr);
4067 if ((code == PLUS && GET_CODE (XEXP (addr, 1)) != CONST_INT)
4069 op0 = replace_equiv_address (op0, force_reg (SImode, addr));
4071 operands[1] = gen_reg_rtx (SImode);
4072 if (BYTES_BIG_ENDIAN)
4074 emit_insn (gen_movsi (operands[1], GEN_INT ((value >> 8) & 255)));
4075 if ((value & 255) == ((value >> 8) & 255))
4076 operands[2] = operands[1];
4079 operands[2] = gen_reg_rtx (SImode);
4080 emit_insn (gen_movsi (operands[2], GEN_INT (value & 255)));
4085 emit_insn (gen_movsi (operands[1], GEN_INT (value & 255)));
4086 if ((value & 255) == ((value >> 8) & 255))
4087 operands[2] = operands[1];
4090 operands[2] = gen_reg_rtx (SImode);
4091 emit_insn (gen_movsi (operands[2], GEN_INT ((value >> 8) & 255)));
4095 operands[3] = adjust_address (op0, QImode, 1);
4096 operands[0] = adjust_address (operands[0], QImode, 0);
4097 operands[2] = gen_lowpart (QImode, operands[2]);
4101 (define_expand "storehi_single_op"
4102 [(set (match_operand:HI 0 "memory_operand" "")
4103 (match_operand:HI 1 "general_operand" ""))]
4104 "TARGET_ARM && arm_arch4"
4106 if (!s_register_operand (operands[1], HImode))
4107 operands[1] = copy_to_mode_reg (HImode, operands[1]);
4111 (define_expand "movhi"
4112 [(set (match_operand:HI 0 "general_operand" "")
4113 (match_operand:HI 1 "general_operand" ""))]
4118 if (!no_new_pseudos)
4120 if (GET_CODE (operands[0]) == MEM)
4124 emit_insn (gen_storehi_single_op (operands[0], operands[1]));
4127 if (GET_CODE (operands[1]) == CONST_INT)
4128 emit_insn (gen_storeinthi (operands[0], operands[1]));
4131 if (GET_CODE (operands[1]) == MEM)
4132 operands[1] = force_reg (HImode, operands[1]);
4133 if (BYTES_BIG_ENDIAN)
4134 emit_insn (gen_storehi_bigend (operands[1], operands[0]));
4136 emit_insn (gen_storehi (operands[1], operands[0]));
4140 /* Sign extend a constant, and keep it in an SImode reg. */
4141 else if (GET_CODE (operands[1]) == CONST_INT)
4143 rtx reg = gen_reg_rtx (SImode);
4144 HOST_WIDE_INT val = INTVAL (operands[1]) & 0xffff;
4146 /* If the constant is already valid, leave it alone. */
4147 if (!const_ok_for_arm (val))
4149 /* If setting all the top bits will make the constant
4150 loadable in a single instruction, then set them.
4151 Otherwise, sign extend the number. */
4153 if (const_ok_for_arm (~(val | ~0xffff)))
4155 else if (val & 0x8000)
4159 emit_insn (gen_movsi (reg, GEN_INT (val)));
4160 operands[1] = gen_lowpart (HImode, reg);
4162 else if (arm_arch4 && !no_new_pseudos && optimize > 0
4163 && GET_CODE (operands[1]) == MEM)
4165 rtx reg = gen_reg_rtx (SImode);
4167 emit_insn (gen_zero_extendhisi2 (reg, operands[1]));
4168 operands[1] = gen_lowpart (HImode, reg);
4170 else if (!arm_arch4)
4172 /* Note: We do not have to worry about TARGET_MMU_TRAPS
4173 for v4 and up architectures because LDRH instructions will
4174 be used to access the HI values, and these cannot generate
4175 unaligned word access faults in the MMU. */
4176 if (GET_CODE (operands[1]) == MEM)
4178 if (TARGET_MMU_TRAPS)
4181 rtx offset = const0_rtx;
4182 rtx reg = gen_reg_rtx (SImode);
4184 if ((GET_CODE (base = XEXP (operands[1], 0)) == REG
4185 || (GET_CODE (base) == PLUS
4186 && (GET_CODE (offset = XEXP (base, 1))
4188 && ((INTVAL(offset) & 1) != 1)
4189 && GET_CODE (base = XEXP (base, 0)) == REG))
4190 && REGNO_POINTER_ALIGN (REGNO (base)) >= 32)
4192 HOST_WIDE_INT new_offset = INTVAL (offset) & ~3;
4195 new = gen_rtx_MEM (SImode,
4196 plus_constant (base, new_offset));
4197 MEM_COPY_ATTRIBUTES (new, operands[1]);
4198 emit_insn (gen_movsi (reg, new));
4199 if (((INTVAL (offset) & 2) != 0)
4200 ^ (BYTES_BIG_ENDIAN ? 1 : 0))
4202 rtx reg2 = gen_reg_rtx (SImode);
4204 emit_insn (gen_lshrsi3 (reg2, reg,
4210 emit_insn (gen_movhi_bytes (reg, operands[1]));
4212 operands[1] = gen_lowpart (HImode, reg);
4214 else if (BYTES_BIG_ENDIAN)
4217 rtx offset = const0_rtx;
4219 if ((GET_CODE (base = XEXP (operands[1], 0)) == REG
4220 || (GET_CODE (base) == PLUS
4221 && (GET_CODE (offset = XEXP (base, 1))
4223 && GET_CODE (base = XEXP (base, 0)) == REG))
4224 && REGNO_POINTER_ALIGN (REGNO (base)) >= 32)
4226 rtx reg = gen_reg_rtx (SImode);
4229 if ((INTVAL (offset) & 2) == 2)
4231 HOST_WIDE_INT new_offset = INTVAL (offset) ^ 2;
4232 new = gen_rtx_MEM (SImode,
4233 plus_constant (base,
4235 MEM_COPY_ATTRIBUTES (new, operands[1]);
4236 emit_insn (gen_movsi (reg, new));
4240 new = gen_rtx_MEM (SImode,
4241 XEXP (operands[1], 0));
4242 MEM_COPY_ATTRIBUTES (new, operands[1]);
4243 emit_insn (gen_rotated_loadsi (reg, new));
4246 operands[1] = gen_lowpart (HImode, reg);
4250 emit_insn (gen_movhi_bigend (operands[0],
4258 /* Handle loading a large integer during reload */
4259 else if (GET_CODE (operands[1]) == CONST_INT
4260 && !const_ok_for_arm (INTVAL (operands[1]))
4261 && !const_ok_for_arm (~INTVAL (operands[1])))
4263 /* Writing a constant to memory needs a scratch, which should
4264 be handled with SECONDARY_RELOADs. */
4265 if (GET_CODE (operands[0]) != REG)
4268 operands[0] = gen_rtx_SUBREG (SImode, operands[0], 0);
4269 emit_insn (gen_movsi (operands[0], operands[1]));
4273 else /* TARGET_THUMB */
4275 if (!no_new_pseudos)
4277 if (GET_CODE (operands[0]) != REG)
4278 operands[1] = force_reg (HImode, operands[1]);
4280 /* ??? We shouldn't really get invalid addresses here, but this can
4281 happen if we are passed a SP (never OK for HImode/QImode) or
4282 virtual register (rejected by GO_IF_LEGITIMATE_ADDRESS for
4283 HImode/QImode) relative address. */
4284 /* ??? This should perhaps be fixed elsewhere, for instance, in
4285 fixup_stack_1, by checking for other kinds of invalid addresses,
4286 e.g. a bare reference to a virtual register. This may confuse the
4287 alpha though, which must handle this case differently. */
4288 if (GET_CODE (operands[0]) == MEM
4289 && !memory_address_p (GET_MODE (operands[0]),
4290 XEXP (operands[0], 0)))
4292 = replace_equiv_address (operands[0],
4293 copy_to_reg (XEXP (operands[0], 0)));
4295 if (GET_CODE (operands[1]) == MEM
4296 && !memory_address_p (GET_MODE (operands[1]),
4297 XEXP (operands[1], 0)))
4299 = replace_equiv_address (operands[1],
4300 copy_to_reg (XEXP (operands[1], 0)));
4302 /* Handle loading a large integer during reload */
4303 else if (GET_CODE (operands[1]) == CONST_INT
4304 && !CONST_OK_FOR_THUMB_LETTER (INTVAL (operands[1]), 'I'))
4306 /* Writing a constant to memory needs a scratch, which should
4307 be handled with SECONDARY_RELOADs. */
4308 if (GET_CODE (operands[0]) != REG)
4311 operands[0] = gen_rtx (SUBREG, SImode, operands[0], 0);
4312 emit_insn (gen_movsi (operands[0], operands[1]));
4319 (define_insn "*thumb_movhi_insn"
4320 [(set (match_operand:HI 0 "nonimmediate_operand" "=l,l, m,*r,*h,l")
4321 (match_operand:HI 1 "general_operand" "l,mn,l,*h,*r,I"))]
4323 && ( register_operand (operands[0], HImode)
4324 || register_operand (operands[1], HImode))"
4326 switch (which_alternative)
4328 case 0: return \"add %0, %1, #0\";
4329 case 2: return \"strh %1, %0\";
4330 case 3: return \"mov %0, %1\";
4331 case 4: return \"mov %0, %1\";
4332 case 5: return \"mov %0, %1\";
4335 /* The stack pointer can end up being taken as an index register.
4336 Catch this case here and deal with it. */
4337 if (GET_CODE (XEXP (operands[1], 0)) == PLUS
4338 && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
4339 && REGNO (XEXP (XEXP (operands[1], 0), 0)) == SP_REGNUM)
4342 ops[0] = operands[0];
4343 ops[1] = XEXP (XEXP (operands[1], 0), 0);
4345 output_asm_insn (\"mov %0, %1\", ops);
4347 XEXP (XEXP (operands[1], 0), 0) = operands[0];
4350 return \"ldrh %0, %1\";
4352 [(set_attr "length" "2,4,2,2,2,2")
4353 (set_attr "type" "*,load,store1,*,*,*")
4354 (set_attr "pool_range" "*,64,*,*,*,*")]
4358 (define_insn "rotated_loadsi"
4359 [(set (match_operand:SI 0 "s_register_operand" "=r")
4360 (rotate:SI (match_operand:SI 1 "offsettable_memory_operand" "o")
4362 "TARGET_ARM && (!TARGET_MMU_TRAPS)"
4367 ops[0] = operands[0];
4368 ops[1] = gen_rtx_MEM (SImode, plus_constant (XEXP (operands[1], 0), 2));
4369 output_asm_insn (\"ldr%?\\t%0, %1\\t%@ load-rotate\", ops);
4372 [(set_attr "type" "load")
4373 (set_attr "predicable" "yes")]
4376 (define_expand "movhi_bytes"
4377 [(set (match_dup 2) (zero_extend:SI (match_operand:HI 1 "" "")))
4379 (zero_extend:SI (match_dup 6)))
4380 (set (match_operand:SI 0 "" "")
4381 (ior:SI (ashift:SI (match_dup 4) (const_int 8)) (match_dup 5)))]
4386 rtx addr = copy_to_mode_reg (SImode, XEXP (operands[1], 0));
4388 mem1 = gen_rtx_MEM (QImode, addr);
4389 MEM_COPY_ATTRIBUTES (mem1, operands[1]);
4390 mem2 = gen_rtx_MEM (QImode, plus_constant (addr, 1));
4391 MEM_COPY_ATTRIBUTES (mem2, operands[1]);
4392 operands[0] = gen_lowpart (SImode, operands[0]);
4394 operands[2] = gen_reg_rtx (SImode);
4395 operands[3] = gen_reg_rtx (SImode);
4398 if (BYTES_BIG_ENDIAN)
4400 operands[4] = operands[2];
4401 operands[5] = operands[3];
4405 operands[4] = operands[3];
4406 operands[5] = operands[2];
4411 (define_expand "movhi_bigend"
4413 (rotate:SI (subreg:SI (match_operand:HI 1 "memory_operand" "") 0)
4416 (ashiftrt:SI (match_dup 2) (const_int 16)))
4417 (set (match_operand:HI 0 "s_register_operand" "")
4418 (subreg:HI (match_dup 3) 0))]
4421 operands[2] = gen_reg_rtx (SImode);
4422 operands[3] = gen_reg_rtx (SImode);
4426 ;; Pattern to recognize insn generated default case above
4427 (define_insn "*movhi_insn_arch4"
4428 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r")
4429 (match_operand:HI 1 "general_operand" "rI,K,r,m"))]
4432 && (GET_CODE (operands[1]) != CONST_INT
4433 || const_ok_for_arm (INTVAL (operands[1]))
4434 || const_ok_for_arm (~INTVAL (operands[1])))"
4436 mov%?\\t%0, %1\\t%@ movhi
4437 mvn%?\\t%0, #%B1\\t%@ movhi
4438 str%?h\\t%1, %0\\t%@ movhi
4439 ldr%?h\\t%0, %1\\t%@ movhi"
4440 [(set_attr "type" "*,*,store1,load")
4441 (set_attr "predicable" "yes")
4442 (set_attr "pool_range" "*,*,*,256")
4443 (set_attr "neg_pool_range" "*,*,*,244")]
4446 (define_insn "*movhi_insn_littleend"
4447 [(set (match_operand:HI 0 "s_register_operand" "=r,r,r")
4448 (match_operand:HI 1 "general_operand" "rI,K,m"))]
4451 && !BYTES_BIG_ENDIAN
4452 && !TARGET_MMU_TRAPS
4453 && (GET_CODE (operands[1]) != CONST_INT
4454 || const_ok_for_arm (INTVAL (operands[1]))
4455 || const_ok_for_arm (~INTVAL (operands[1])))"
4457 mov%?\\t%0, %1\\t%@ movhi
4458 mvn%?\\t%0, #%B1\\t%@ movhi
4459 ldr%?\\t%0, %1\\t%@ movhi"
4460 [(set_attr "type" "*,*,load")
4461 (set_attr "predicable" "yes")
4462 (set_attr "pool_range" "4096")
4463 (set_attr "neg_pool_range" "4084")]
4466 (define_insn "*movhi_insn_bigend"
4467 [(set (match_operand:HI 0 "s_register_operand" "=r,r,r")
4468 (match_operand:HI 1 "general_operand" "rI,K,m"))]
4472 && !TARGET_MMU_TRAPS
4473 && (GET_CODE (operands[1]) != CONST_INT
4474 || const_ok_for_arm (INTVAL (operands[1]))
4475 || const_ok_for_arm (~INTVAL (operands[1])))"
4477 mov%?\\t%0, %1\\t%@ movhi
4478 mvn%?\\t%0, #%B1\\t%@ movhi
4479 ldr%?\\t%0, %1\\t%@ movhi_bigend\;mov%?\\t%0, %0, asr #16"
4480 [(set_attr "type" "*,*,load")
4481 (set_attr "predicable" "yes")
4482 (set_attr "length" "4,4,8")
4483 (set_attr "pool_range" "*,*,4092")
4484 (set_attr "neg_pool_range" "*,*,4084")]
4487 (define_insn "*loadhi_si_bigend"
4488 [(set (match_operand:SI 0 "s_register_operand" "=r")
4489 (rotate:SI (subreg:SI (match_operand:HI 1 "memory_operand" "m") 0)
4493 && !TARGET_MMU_TRAPS"
4494 "ldr%?\\t%0, %1\\t%@ movhi_bigend"
4495 [(set_attr "type" "load")
4496 (set_attr "predicable" "yes")
4497 (set_attr "pool_range" "4096")
4498 (set_attr "neg_pool_range" "4084")]
4501 (define_insn "*movhi_bytes"
4502 [(set (match_operand:HI 0 "s_register_operand" "=r,r")
4503 (match_operand:HI 1 "arm_rhs_operand" "rI,K"))]
4504 "TARGET_ARM && TARGET_MMU_TRAPS"
4506 mov%?\\t%0, %1\\t%@ movhi
4507 mvn%?\\t%0, #%B1\\t%@ movhi"
4508 [(set_attr "predicable" "yes")]
4511 (define_insn "thumb_movhi_clobber"
4512 [(set (match_operand:HI 0 "memory_operand" "=m")
4513 (match_operand:HI 1 "register_operand" "l"))
4514 (clobber (match_operand:SI 2 "register_operand" "=&l"))]
4520 ;; We use a DImode scratch because we may occasionally need an additional
4521 ;; temporary if the address isn't offsettable -- push_reload doesn't seem
4522 ;; to take any notice of the "o" constraints on reload_memory_operand operand.
4523 (define_expand "reload_outhi"
4524 [(parallel [(match_operand:HI 0 "arm_reload_memory_operand" "=o")
4525 (match_operand:HI 1 "s_register_operand" "r")
4526 (match_operand:DI 2 "s_register_operand" "=&l")])]
4529 arm_reload_out_hi (operands);
4531 thumb_reload_out_hi (operands);
4536 (define_expand "reload_inhi"
4537 [(parallel [(match_operand:HI 0 "s_register_operand" "=r")
4538 (match_operand:HI 1 "arm_reload_memory_operand" "o")
4539 (match_operand:DI 2 "s_register_operand" "=&r")])]
4540 "TARGET_THUMB || (TARGET_ARM && TARGET_MMU_TRAPS)"
4543 arm_reload_in_hi (operands);
4545 thumb_reload_out_hi (operands);
4549 (define_expand "movqi"
4550 [(set (match_operand:QI 0 "general_operand" "")
4551 (match_operand:QI 1 "general_operand" ""))]
4556 /* Everything except mem = const or mem = mem can be done easily */
4558 if (!no_new_pseudos)
4560 if (GET_CODE (operands[1]) == CONST_INT)
4562 rtx reg = gen_reg_rtx (SImode);
4564 emit_insn (gen_movsi (reg, operands[1]));
4565 operands[1] = gen_lowpart (QImode, reg);
4567 if (GET_CODE (operands[1]) == MEM && optimize > 0)
4569 rtx reg = gen_reg_rtx (SImode);
4571 emit_insn (gen_zero_extendqisi2 (reg, operands[1]));
4572 operands[1] = gen_lowpart (QImode, reg);
4574 if (GET_CODE (operands[0]) == MEM)
4575 operands[1] = force_reg (QImode, operands[1]);
4578 else /* TARGET_THUMB */
4580 if (!no_new_pseudos)
4582 if (GET_CODE (operands[0]) != REG)
4583 operands[1] = force_reg (QImode, operands[1]);
4585 /* ??? We shouldn't really get invalid addresses here, but this can
4586 happen if we are passed a SP (never OK for HImode/QImode) or
4587 virtual register (rejected by GO_IF_LEGITIMATE_ADDRESS for
4588 HImode/QImode) relative address. */
4589 /* ??? This should perhaps be fixed elsewhere, for instance, in
4590 fixup_stack_1, by checking for other kinds of invalid addresses,
4591 e.g. a bare reference to a virtual register. This may confuse the
4592 alpha though, which must handle this case differently. */
4593 if (GET_CODE (operands[0]) == MEM
4594 && !memory_address_p (GET_MODE (operands[0]),
4595 XEXP (operands[0], 0)))
4597 = replace_equiv_address (operands[0],
4598 copy_to_reg (XEXP (operands[0], 0)));
4599 if (GET_CODE (operands[1]) == MEM
4600 && !memory_address_p (GET_MODE (operands[1]),
4601 XEXP (operands[1], 0)))
4603 = replace_equiv_address (operands[1],
4604 copy_to_reg (XEXP (operands[1], 0)));
4606 /* Handle loading a large integer during reload */
4607 else if (GET_CODE (operands[1]) == CONST_INT
4608 && !CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'I'))
4610 /* Writing a constant to memory needs a scratch, which should
4611 be handled with SECONDARY_RELOADs. */
4612 if (GET_CODE (operands[0]) != REG)
4615 operands[0] = gen_rtx_SUBREG (SImode, operands[0], 0);
4616 emit_insn (gen_movsi (operands[0], operands[1]));
4624 (define_insn "*arm_movqi_insn"
4625 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,r,m")
4626 (match_operand:QI 1 "general_operand" "rI,K,m,r"))]
4628 && ( register_operand (operands[0], QImode)
4629 || register_operand (operands[1], QImode))"
4635 [(set_attr "type" "*,*,load,store1")
4636 (set_attr "predicable" "yes")]
4639 (define_insn "*thumb_movqi_insn"
4640 [(set (match_operand:QI 0 "nonimmediate_operand" "=l,l,m,*r,*h,l")
4641 (match_operand:QI 1 "general_operand" "l, m,l,*h,*r,I"))]
4643 && ( register_operand (operands[0], QImode)
4644 || register_operand (operands[1], QImode))"
4652 [(set_attr "length" "2")
4653 (set_attr "type" "*,load,store1,*,*,*")
4654 (set_attr "pool_range" "*,32,*,*,*,*")]
4657 (define_expand "movsf"
4658 [(set (match_operand:SF 0 "general_operand" "")
4659 (match_operand:SF 1 "general_operand" ""))]
4664 if (GET_CODE (operands[0]) == MEM)
4665 operands[1] = force_reg (SFmode, operands[1]);
4667 else /* TARGET_THUMB */
4669 if (!no_new_pseudos)
4671 if (GET_CODE (operands[0]) != REG)
4672 operands[1] = force_reg (SFmode, operands[1]);
4679 [(set (match_operand:SF 0 "nonimmediate_operand" "")
4680 (match_operand:SF 1 "immediate_operand" ""))]
4682 && !TARGET_HARD_FLOAT
4684 && GET_CODE (operands[1]) == CONST_DOUBLE"
4685 [(set (match_dup 2) (match_dup 3))]
4687 operands[2] = gen_lowpart (SImode, operands[0]);
4688 operands[3] = gen_lowpart (SImode, operands[1]);
4689 if (operands[2] == 0 || operands[3] == 0)
4694 (define_insn "*arm_movsf_soft_insn"
4695 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m")
4696 (match_operand:SF 1 "general_operand" "r,mE,r"))]
4699 && TARGET_SOFT_FLOAT
4700 && (GET_CODE (operands[0]) != MEM
4701 || register_operand (operands[1], SFmode))"
4704 ldr%?\\t%0, %1\\t%@ float
4705 str%?\\t%1, %0\\t%@ float"
4706 [(set_attr "length" "4,4,4")
4707 (set_attr "predicable" "yes")
4708 (set_attr "type" "*,load,store1")
4709 (set_attr "pool_range" "*,4096,*")
4710 (set_attr "neg_pool_range" "*,4084,*")]
4713 ;;; ??? This should have alternatives for constants.
4714 (define_insn "*thumb_movsf_insn"
4715 [(set (match_operand:SF 0 "nonimmediate_operand" "=l,l,>,l, m,*r,*h")
4716 (match_operand:SF 1 "general_operand" "l, >,l,mF,l,*h,*r"))]
4718 && ( register_operand (operands[0], SFmode)
4719 || register_operand (operands[1], SFmode))"
4728 [(set_attr "length" "2")
4729 (set_attr "type" "*,load,store1,load,store1,*,*")
4730 (set_attr "pool_range" "*,*,*,1020,*,*,*")]
4733 (define_expand "movdf"
4734 [(set (match_operand:DF 0 "general_operand" "")
4735 (match_operand:DF 1 "general_operand" ""))]
4740 if (GET_CODE (operands[0]) == MEM)
4741 operands[1] = force_reg (DFmode, operands[1]);
4743 else /* TARGET_THUMB */
4745 if (!no_new_pseudos)
4747 if (GET_CODE (operands[0]) != REG)
4748 operands[1] = force_reg (DFmode, operands[1]);
4754 ;; Reloading a df mode value stored in integer regs to memory can require a
4756 (define_expand "reload_outdf"
4757 [(match_operand:DF 0 "arm_reload_memory_operand" "=o")
4758 (match_operand:DF 1 "s_register_operand" "r")
4759 (match_operand:SI 2 "s_register_operand" "=&r")]
4763 enum rtx_code code = GET_CODE (XEXP (operands[0], 0));
4766 operands[2] = XEXP (operands[0], 0);
4767 else if (code == POST_INC || code == PRE_DEC)
4769 operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
4770 operands[1] = gen_rtx_SUBREG (DImode, operands[1], 0);
4771 emit_insn (gen_movdi (operands[0], operands[1]));
4774 else if (code == PRE_INC)
4776 rtx reg = XEXP (XEXP (operands[0], 0), 0);
4778 emit_insn (gen_addsi3 (reg, reg, GEN_INT (8)));
4781 else if (code == POST_DEC)
4782 operands[2] = XEXP (XEXP (operands[0], 0), 0);
4784 emit_insn (gen_addsi3 (operands[2], XEXP (XEXP (operands[0], 0), 0),
4785 XEXP (XEXP (operands[0], 0), 1)));
4787 emit_insn (gen_rtx_SET (VOIDmode, gen_rtx_MEM (DFmode, operands[2]),
4790 if (code == POST_DEC)
4791 emit_insn (gen_addsi3 (operands[2], operands[2], GEN_INT (-8)));
4797 (define_insn "*movdf_soft_insn"
4798 [(set (match_operand:DF 0 "nonimmediate_soft_df_operand" "=r,r,m")
4799 (match_operand:DF 1 "soft_df_operand" "r,mF,r"))]
4800 "TARGET_ARM && TARGET_SOFT_FLOAT
4803 "* return output_move_double (operands);"
4804 [(set_attr "length" "8,8,8")
4805 (set_attr "type" "*,load,store2")
4806 (set_attr "pool_range" "1020")
4807 (set_attr "neg_pool_range" "1008")]
4810 ;;; ??? This should have alternatives for constants.
4811 ;;; ??? This was originally identical to the movdi_insn pattern.
4812 ;;; ??? The 'F' constraint looks funny, but it should always be replaced by
4813 ;;; thumb_reorg with a memory reference.
4814 (define_insn "*thumb_movdf_insn"
4815 [(set (match_operand:DF 0 "nonimmediate_operand" "=l,l,>,l, m,*r")
4816 (match_operand:DF 1 "general_operand" "l, >,l,mF,l,*r"))]
4818 && ( register_operand (operands[0], DFmode)
4819 || register_operand (operands[1], DFmode))"
4821 switch (which_alternative)
4825 if (REGNO (operands[1]) == REGNO (operands[0]) + 1)
4826 return \"add\\t%0, %1, #0\;add\\t%H0, %H1, #0\";
4827 return \"add\\t%H0, %H1, #0\;add\\t%0, %1, #0\";
4829 return \"ldmia\\t%1, {%0, %H0}\";
4831 return \"stmia\\t%0, {%1, %H1}\";
4833 return thumb_load_double_from_address (operands);
4835 operands[2] = gen_rtx (MEM, SImode,
4836 plus_constant (XEXP (operands[0], 0), 4));
4837 output_asm_insn (\"str\\t%1, %0\;str\\t%H1, %2\", operands);
4840 if (REGNO (operands[1]) == REGNO (operands[0]) + 1)
4841 return \"mov\\t%0, %1\;mov\\t%H0, %H1\";
4842 return \"mov\\t%H0, %H1\;mov\\t%0, %1\";
4845 [(set_attr "length" "4,2,2,6,4,4")
4846 (set_attr "type" "*,load,store2,load,store2,*")
4847 (set_attr "pool_range" "*,*,*,1020,*,*")]
4851 (define_expand "movv2si"
4852 [(set (match_operand:V2SI 0 "nonimmediate_operand" "")
4853 (match_operand:V2SI 1 "general_operand" ""))]
4854 "TARGET_REALLY_IWMMXT"
4858 (define_expand "movv4hi"
4859 [(set (match_operand:V4HI 0 "nonimmediate_operand" "")
4860 (match_operand:V4HI 1 "general_operand" ""))]
4861 "TARGET_REALLY_IWMMXT"
4865 (define_expand "movv8qi"
4866 [(set (match_operand:V8QI 0 "nonimmediate_operand" "")
4867 (match_operand:V8QI 1 "general_operand" ""))]
4868 "TARGET_REALLY_IWMMXT"
4873 ;; load- and store-multiple insns
4874 ;; The arm can load/store any set of registers, provided that they are in
4875 ;; ascending order; but that is beyond GCC so stick with what it knows.
4877 (define_expand "load_multiple"
4878 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
4879 (match_operand:SI 1 "" ""))
4880 (use (match_operand:SI 2 "" ""))])]
4883 /* Support only fixed point registers. */
4884 if (GET_CODE (operands[2]) != CONST_INT
4885 || INTVAL (operands[2]) > 14
4886 || INTVAL (operands[2]) < 2
4887 || GET_CODE (operands[1]) != MEM
4888 || GET_CODE (operands[0]) != REG
4889 || REGNO (operands[0]) > (LAST_ARM_REGNUM - 1)
4890 || REGNO (operands[0]) + INTVAL (operands[2]) > LAST_ARM_REGNUM)
4894 = arm_gen_load_multiple (REGNO (operands[0]), INTVAL (operands[2]),
4895 force_reg (SImode, XEXP (operands[1], 0)),
4896 TRUE, FALSE, RTX_UNCHANGING_P(operands[1]),
4897 MEM_IN_STRUCT_P(operands[1]),
4898 MEM_SCALAR_P (operands[1]));
4902 ;; Load multiple with write-back
4904 (define_insn "*ldmsi_postinc4"
4905 [(match_parallel 0 "load_multiple_operation"
4906 [(set (match_operand:SI 1 "s_register_operand" "=r")
4907 (plus:SI (match_operand:SI 2 "s_register_operand" "1")
4909 (set (match_operand:SI 3 "arm_hard_register_operand" "")
4910 (mem:SI (match_dup 2)))
4911 (set (match_operand:SI 4 "arm_hard_register_operand" "")
4912 (mem:SI (plus:SI (match_dup 2) (const_int 4))))
4913 (set (match_operand:SI 5 "arm_hard_register_operand" "")
4914 (mem:SI (plus:SI (match_dup 2) (const_int 8))))
4915 (set (match_operand:SI 6 "arm_hard_register_operand" "")
4916 (mem:SI (plus:SI (match_dup 2) (const_int 12))))])]
4917 "TARGET_ARM && XVECLEN (operands[0], 0) == 5"
4918 "ldm%?ia\\t%1!, {%3, %4, %5, %6}"
4919 [(set_attr "type" "load")
4920 (set_attr "predicable" "yes")]
4923 (define_insn "*ldmsi_postinc3"
4924 [(match_parallel 0 "load_multiple_operation"
4925 [(set (match_operand:SI 1 "s_register_operand" "=r")
4926 (plus:SI (match_operand:SI 2 "s_register_operand" "1")
4928 (set (match_operand:SI 3 "arm_hard_register_operand" "")
4929 (mem:SI (match_dup 2)))
4930 (set (match_operand:SI 4 "arm_hard_register_operand" "")
4931 (mem:SI (plus:SI (match_dup 2) (const_int 4))))
4932 (set (match_operand:SI 5 "arm_hard_register_operand" "")
4933 (mem:SI (plus:SI (match_dup 2) (const_int 8))))])]
4934 "TARGET_ARM && XVECLEN (operands[0], 0) == 4"
4935 "ldm%?ia\\t%1!, {%3, %4, %5}"
4936 [(set_attr "type" "load")
4937 (set_attr "predicable" "yes")]
4940 (define_insn "*ldmsi_postinc2"
4941 [(match_parallel 0 "load_multiple_operation"
4942 [(set (match_operand:SI 1 "s_register_operand" "=r")
4943 (plus:SI (match_operand:SI 2 "s_register_operand" "1")
4945 (set (match_operand:SI 3 "arm_hard_register_operand" "")
4946 (mem:SI (match_dup 2)))
4947 (set (match_operand:SI 4 "arm_hard_register_operand" "")
4948 (mem:SI (plus:SI (match_dup 2) (const_int 4))))])]
4949 "TARGET_ARM && XVECLEN (operands[0], 0) == 3"
4950 "ldm%?ia\\t%1!, {%3, %4}"
4951 [(set_attr "type" "load")
4952 (set_attr "predicable" "yes")]
4955 ;; Ordinary load multiple
4957 (define_insn "*ldmsi4"
4958 [(match_parallel 0 "load_multiple_operation"
4959 [(set (match_operand:SI 2 "arm_hard_register_operand" "")
4960 (mem:SI (match_operand:SI 1 "s_register_operand" "r")))
4961 (set (match_operand:SI 3 "arm_hard_register_operand" "")
4962 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
4963 (set (match_operand:SI 4 "arm_hard_register_operand" "")
4964 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
4965 (set (match_operand:SI 5 "arm_hard_register_operand" "")
4966 (mem:SI (plus:SI (match_dup 1) (const_int 12))))])]
4967 "TARGET_ARM && XVECLEN (operands[0], 0) == 4"
4968 "ldm%?ia\\t%1, {%2, %3, %4, %5}"
4969 [(set_attr "type" "load")
4970 (set_attr "predicable" "yes")]
4973 (define_insn "*ldmsi3"
4974 [(match_parallel 0 "load_multiple_operation"
4975 [(set (match_operand:SI 2 "arm_hard_register_operand" "")
4976 (mem:SI (match_operand:SI 1 "s_register_operand" "r")))
4977 (set (match_operand:SI 3 "arm_hard_register_operand" "")
4978 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
4979 (set (match_operand:SI 4 "arm_hard_register_operand" "")
4980 (mem:SI (plus:SI (match_dup 1) (const_int 8))))])]
4981 "TARGET_ARM && XVECLEN (operands[0], 0) == 3"
4982 "ldm%?ia\\t%1, {%2, %3, %4}"
4983 [(set_attr "type" "load")
4984 (set_attr "predicable" "yes")]
4987 (define_insn "*ldmsi2"
4988 [(match_parallel 0 "load_multiple_operation"
4989 [(set (match_operand:SI 2 "arm_hard_register_operand" "")
4990 (mem:SI (match_operand:SI 1 "s_register_operand" "r")))
4991 (set (match_operand:SI 3 "arm_hard_register_operand" "")
4992 (mem:SI (plus:SI (match_dup 1) (const_int 4))))])]
4993 "TARGET_ARM && XVECLEN (operands[0], 0) == 2"
4994 "ldm%?ia\\t%1, {%2, %3}"
4995 [(set_attr "type" "load")
4996 (set_attr "predicable" "yes")]
4999 (define_expand "store_multiple"
5000 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
5001 (match_operand:SI 1 "" ""))
5002 (use (match_operand:SI 2 "" ""))])]
5005 /* Support only fixed point registers */
5006 if (GET_CODE (operands[2]) != CONST_INT
5007 || INTVAL (operands[2]) > 14
5008 || INTVAL (operands[2]) < 2
5009 || GET_CODE (operands[1]) != REG
5010 || GET_CODE (operands[0]) != MEM
5011 || REGNO (operands[1]) > (LAST_ARM_REGNUM - 1)
5012 || REGNO (operands[1]) + INTVAL (operands[2]) > LAST_ARM_REGNUM)
5016 = arm_gen_store_multiple (REGNO (operands[1]), INTVAL (operands[2]),
5017 force_reg (SImode, XEXP (operands[0], 0)),
5018 TRUE, FALSE, RTX_UNCHANGING_P (operands[0]),
5019 MEM_IN_STRUCT_P(operands[0]),
5020 MEM_SCALAR_P (operands[0]));
5024 ;; Store multiple with write-back
5026 (define_insn "*stmsi_postinc4"
5027 [(match_parallel 0 "store_multiple_operation"
5028 [(set (match_operand:SI 1 "s_register_operand" "=r")
5029 (plus:SI (match_operand:SI 2 "s_register_operand" "1")
5031 (set (mem:SI (match_dup 2))
5032 (match_operand:SI 3 "arm_hard_register_operand" ""))
5033 (set (mem:SI (plus:SI (match_dup 2) (const_int 4)))
5034 (match_operand:SI 4 "arm_hard_register_operand" ""))
5035 (set (mem:SI (plus:SI (match_dup 2) (const_int 8)))
5036 (match_operand:SI 5 "arm_hard_register_operand" ""))
5037 (set (mem:SI (plus:SI (match_dup 2) (const_int 12)))
5038 (match_operand:SI 6 "arm_hard_register_operand" ""))])]
5039 "TARGET_ARM && XVECLEN (operands[0], 0) == 5"
5040 "stm%?ia\\t%1!, {%3, %4, %5, %6}"
5041 [(set_attr "predicable" "yes")
5042 (set_attr "type" "store4")]
5045 (define_insn "*stmsi_postinc3"
5046 [(match_parallel 0 "store_multiple_operation"
5047 [(set (match_operand:SI 1 "s_register_operand" "=r")
5048 (plus:SI (match_operand:SI 2 "s_register_operand" "1")
5050 (set (mem:SI (match_dup 2))
5051 (match_operand:SI 3 "arm_hard_register_operand" ""))
5052 (set (mem:SI (plus:SI (match_dup 2) (const_int 4)))
5053 (match_operand:SI 4 "arm_hard_register_operand" ""))
5054 (set (mem:SI (plus:SI (match_dup 2) (const_int 8)))
5055 (match_operand:SI 5 "arm_hard_register_operand" ""))])]
5056 "TARGET_ARM && XVECLEN (operands[0], 0) == 4"
5057 "stm%?ia\\t%1!, {%3, %4, %5}"
5058 [(set_attr "predicable" "yes")
5059 (set_attr "type" "store3")]
5062 (define_insn "*stmsi_postinc2"
5063 [(match_parallel 0 "store_multiple_operation"
5064 [(set (match_operand:SI 1 "s_register_operand" "=r")
5065 (plus:SI (match_operand:SI 2 "s_register_operand" "1")
5067 (set (mem:SI (match_dup 2))
5068 (match_operand:SI 3 "arm_hard_register_operand" ""))
5069 (set (mem:SI (plus:SI (match_dup 2) (const_int 4)))
5070 (match_operand:SI 4 "arm_hard_register_operand" ""))])]
5071 "TARGET_ARM && XVECLEN (operands[0], 0) == 3"
5072 "stm%?ia\\t%1!, {%3, %4}"
5073 [(set_attr "predicable" "yes")
5074 (set_attr "type" "store2")]
5077 ;; Ordinary store multiple
5079 (define_insn "*stmsi4"
5080 [(match_parallel 0 "store_multiple_operation"
5081 [(set (mem:SI (match_operand:SI 1 "s_register_operand" "r"))
5082 (match_operand:SI 2 "arm_hard_register_operand" ""))
5083 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
5084 (match_operand:SI 3 "arm_hard_register_operand" ""))
5085 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
5086 (match_operand:SI 4 "arm_hard_register_operand" ""))
5087 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
5088 (match_operand:SI 5 "arm_hard_register_operand" ""))])]
5089 "TARGET_ARM && XVECLEN (operands[0], 0) == 4"
5090 "stm%?ia\\t%1, {%2, %3, %4, %5}"
5091 [(set_attr "predicable" "yes")
5092 (set_attr "type" "store4")]
5095 (define_insn "*stmsi3"
5096 [(match_parallel 0 "store_multiple_operation"
5097 [(set (mem:SI (match_operand:SI 1 "s_register_operand" "r"))
5098 (match_operand:SI 2 "arm_hard_register_operand" ""))
5099 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
5100 (match_operand:SI 3 "arm_hard_register_operand" ""))
5101 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
5102 (match_operand:SI 4 "arm_hard_register_operand" ""))])]
5103 "TARGET_ARM && XVECLEN (operands[0], 0) == 3"
5104 "stm%?ia\\t%1, {%2, %3, %4}"
5105 [(set_attr "predicable" "yes")
5106 (set_attr "type" "store3")]
5109 (define_insn "*stmsi2"
5110 [(match_parallel 0 "store_multiple_operation"
5111 [(set (mem:SI (match_operand:SI 1 "s_register_operand" "r"))
5112 (match_operand:SI 2 "arm_hard_register_operand" ""))
5113 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
5114 (match_operand:SI 3 "arm_hard_register_operand" ""))])]
5115 "TARGET_ARM && XVECLEN (operands[0], 0) == 2"
5116 "stm%?ia\\t%1, {%2, %3}"
5117 [(set_attr "predicable" "yes")
5118 (set_attr "type" "store2")]
5121 ;; Move a block of memory if it is word aligned and MORE than 2 words long.
5122 ;; We could let this apply for blocks of less than this, but it clobbers so
5123 ;; many registers that there is then probably a better way.
5125 (define_expand "movstrqi"
5126 [(match_operand:BLK 0 "general_operand" "")
5127 (match_operand:BLK 1 "general_operand" "")
5128 (match_operand:SI 2 "const_int_operand" "")
5129 (match_operand:SI 3 "const_int_operand" "")]
5134 if (arm_gen_movstrqi (operands))
5138 else /* TARGET_THUMB */
5140 if ( INTVAL (operands[3]) != 4
5141 || INTVAL (operands[2]) > 48)
5144 thumb_expand_movstrqi (operands);
5150 ;; Thumb block-move insns
5152 (define_insn "movmem12b"
5153 [(set (mem:SI (match_operand:SI 2 "register_operand" "0"))
5154 (mem:SI (match_operand:SI 3 "register_operand" "1")))
5155 (set (mem:SI (plus:SI (match_dup 2) (const_int 4)))
5156 (mem:SI (plus:SI (match_dup 3) (const_int 4))))
5157 (set (mem:SI (plus:SI (match_dup 2) (const_int 8)))
5158 (mem:SI (plus:SI (match_dup 3) (const_int 8))))
5159 (set (match_operand:SI 0 "register_operand" "=l")
5160 (plus:SI (match_dup 2) (const_int 12)))
5161 (set (match_operand:SI 1 "register_operand" "=l")
5162 (plus:SI (match_dup 3) (const_int 12)))
5163 (clobber (match_scratch:SI 4 "=&l"))
5164 (clobber (match_scratch:SI 5 "=&l"))
5165 (clobber (match_scratch:SI 6 "=&l"))]
5167 "* return thumb_output_move_mem_multiple (3, operands);"
5168 [(set_attr "length" "4")
5169 ; This isn't entirely accurate... It loads as well, but in terms of
5170 ; scheduling the following insn it is better to consider it as a store
5171 (set_attr "type" "store3")]
5174 (define_insn "movmem8b"
5175 [(set (mem:SI (match_operand:SI 2 "register_operand" "0"))
5176 (mem:SI (match_operand:SI 3 "register_operand" "1")))
5177 (set (mem:SI (plus:SI (match_dup 2) (const_int 4)))
5178 (mem:SI (plus:SI (match_dup 3) (const_int 4))))
5179 (set (match_operand:SI 0 "register_operand" "=l")
5180 (plus:SI (match_dup 2) (const_int 8)))
5181 (set (match_operand:SI 1 "register_operand" "=l")
5182 (plus:SI (match_dup 3) (const_int 8)))
5183 (clobber (match_scratch:SI 4 "=&l"))
5184 (clobber (match_scratch:SI 5 "=&l"))]
5186 "* return thumb_output_move_mem_multiple (2, operands);"
5187 [(set_attr "length" "4")
5188 ; This isn't entirely accurate... It loads as well, but in terms of
5189 ; scheduling the following insn it is better to consider it as a store
5190 (set_attr "type" "store2")]
5195 ;; Compare & branch insns
5196 ;; The range calculations are based as follows:
5197 ;; For forward branches, the address calculation returns the address of
5198 ;; the next instruction. This is 2 beyond the branch instruction.
5199 ;; For backward branches, the address calculation returns the address of
5200 ;; the first instruction in this pattern (cmp). This is 2 before the branch
5201 ;; instruction for the shortest sequence, and 4 before the branch instruction
5202 ;; if we have to jump around an unconditional branch.
5203 ;; To the basic branch range the PC offset must be added (this is +4).
5204 ;; So for forward branches we have
5205 ;; (pos_range - pos_base_offs + pc_offs) = (pos_range - 2 + 4).
5206 ;; And for backward branches we have
5207 ;; (neg_range - neg_base_offs + pc_offs) = (neg_range - (-2 or -4) + 4).
5209 ;; For a 'b' pos_range = 2046, neg_range = -2048 giving (-2040->2048).
5210 ;; For a 'b<cond>' pos_range = 254, neg_range = -256 giving (-250 ->256).
5212 (define_insn "cbranchsi4"
5215 (match_operator 0 "arm_comparison_operator"
5216 [(match_operand:SI 1 "register_operand" "l,r")
5217 (match_operand:SI 2 "nonmemory_operand" "rI,r")])
5218 (label_ref (match_operand 3 "" ""))
5222 output_asm_insn (\"cmp\\t%1, %2\", operands);
5223 switch (get_attr_length (insn))
5225 case 4: return \"b%d0\\t%l3\";
5226 case 6: return \"b%D0\\t.LCB%=\;b\\t%l3\\t%@long jump\\n.LCB%=:\";
5227 default: return \"b%D0\\t.LCB%=\;bl\\t%l3\\t%@far jump\\n.LCB%=:\";
5230 [(set (attr "far_jump")
5232 (eq_attr "length" "8")
5233 (const_string "yes")
5234 (const_string "no")))
5235 (set (attr "length")
5237 (and (ge (minus (match_dup 3) (pc)) (const_int -250))
5238 (le (minus (match_dup 3) (pc)) (const_int 256)))
5241 (and (ge (minus (match_dup 3) (pc)) (const_int -2040))
5242 (le (minus (match_dup 3) (pc)) (const_int 2048)))
5247 (define_insn "*negated_cbranchsi4"
5250 (match_operator 0 "arm_comparison_operator"
5251 [(match_operand:SI 1 "register_operand" "l")
5252 (neg:SI (match_operand:SI 2 "nonmemory_operand" "l"))])
5253 (label_ref (match_operand 3 "" ""))
5257 output_asm_insn (\"cmn\\t%1, %2\", operands);
5258 switch (get_attr_length (insn))
5260 case 4: return \"b%d0\\t%l3\";
5261 case 6: return \"b%D0\\t.LCB%=\;b\\t%l3\\t%@long jump\\n.LCB%=:\";
5262 default: return \"b%D0\\t.LCB%=\;bl\\t%l3\\t%@far jump\\n.LCB%=:\";
5265 [(set (attr "far_jump")
5267 (eq_attr "length" "8")
5268 (const_string "yes")
5269 (const_string "no")))
5270 (set (attr "length")
5272 (and (ge (minus (match_dup 3) (pc)) (const_int -250))
5273 (le (minus (match_dup 3) (pc)) (const_int 256)))
5276 (and (ge (minus (match_dup 3) (pc)) (const_int -2040))
5277 (le (minus (match_dup 3) (pc)) (const_int 2048)))
5282 (define_insn "*tbit_cbranch"
5285 (match_operator 0 "equality_operator"
5286 [(zero_extract:SI (match_operand:SI 1 "s_register_operand" "l")
5288 (match_operand:SI 2 "const_int_operand" "i"))
5290 (label_ref (match_operand 3 "" ""))
5292 (clobber (match_scratch:SI 4 "=l"))]
5297 op[0] = operands[4];
5298 op[1] = operands[1];
5299 op[2] = GEN_INT (32 - 1 - INTVAL (operands[2]));
5301 output_asm_insn (\"lsl\\t%0, %1, %2\", op);
5302 switch (get_attr_length (insn))
5304 case 4: return \"b%d0\\t%l3\";
5305 case 6: return \"b%D0\\t.LCB%=\;b\\t%l3\\t%@long jump\\n.LCB%=:\";
5306 default: return \"b%D0\\t.LCB%=\;bl\\t%l3\\t%@far jump\\n.LCB%=:\";
5309 [(set (attr "far_jump")
5311 (eq_attr "length" "8")
5312 (const_string "yes")
5313 (const_string "no")))
5314 (set (attr "length")
5316 (and (ge (minus (match_dup 3) (pc)) (const_int -250))
5317 (le (minus (match_dup 3) (pc)) (const_int 256)))
5320 (and (ge (minus (match_dup 3) (pc)) (const_int -2040))
5321 (le (minus (match_dup 3) (pc)) (const_int 2048)))
5326 (define_insn "*andsi3_cbranch_scratch"
5329 (match_operator 4 "equality_operator"
5330 [(and:SI (match_operand:SI 1 "s_register_operand" "%0")
5331 (match_operand:SI 2 "s_register_operand" "l"))
5333 (label_ref (match_operand 3 "" ""))
5335 (clobber (match_scratch:SI 0 "=l"))]
5339 output_asm_insn (\"and\\t%0, %2\", operands);
5340 switch (get_attr_length (insn))
5342 case 4: return \"b%d4\\t%l3\";
5343 case 6: return \"b%D4\\t.LCB%=\;b\\t%l3\\t%@long jump\\n.LCB%=:\";
5344 default: return \"b%D4\\t.LCB%=\;bl\\t%l3\\t%@far jump\\n.LCB%=:\";
5347 [(set (attr "far_jump")
5349 (eq_attr "length" "8")
5350 (const_string "yes")
5351 (const_string "no")))
5352 (set (attr "length")
5354 (and (ge (minus (match_dup 3) (pc)) (const_int -250))
5355 (le (minus (match_dup 3) (pc)) (const_int 256)))
5358 (and (ge (minus (match_dup 3) (pc)) (const_int -2040))
5359 (le (minus (match_dup 3) (pc)) (const_int 2048)))
5364 (define_insn "*andsi3_cbranch"
5367 (match_operator 5 "equality_operator"
5368 [(and:SI (match_operand:SI 2 "s_register_operand" "%0,1,1,1")
5369 (match_operand:SI 3 "s_register_operand" "l,l,l,l"))
5371 (label_ref (match_operand 4 "" ""))
5373 (set (match_operand:SI 0 "thumb_cbrch_target_operand" "=l,?h,?m,?m")
5374 (and:SI (match_dup 2) (match_dup 3)))
5375 (clobber (match_scratch:SI 1 "=X,l,&l,&l"))]
5379 if (which_alternative == 0)
5380 output_asm_insn (\"and\\t%0, %3\", operands);
5381 else if (which_alternative == 1)
5383 output_asm_insn (\"and\\t%1, %3\", operands);
5384 output_asm_insn (\"mov\\t%0, %1\", operands);
5388 output_asm_insn (\"and\\t%1, %3\", operands);
5389 output_asm_insn (\"str\\t%1, %0\", operands);
5392 switch (get_attr_length (insn) - (which_alternative ? 2 : 0))
5394 case 4: return \"b%d5\\t%l4\";
5395 case 6: return \"b%D5\\t.LCB%=\;b\\t%l4\\t%@long jump\\n.LCB%=:\";
5396 default: return \"b%D5\\t.LCB%=\;bl\\t%l4\\t%@far jump\\n.LCB%=:\";
5399 [(set (attr "far_jump")
5401 (ior (and (eq (symbol_ref ("which_alternative"))
5403 (eq_attr "length" "8"))
5404 (eq_attr "length" "10"))
5405 (const_string "yes")
5406 (const_string "no")))
5407 (set (attr "length")
5409 (eq (symbol_ref ("which_alternative"))
5412 (and (ge (minus (match_dup 4) (pc)) (const_int -250))
5413 (le (minus (match_dup 4) (pc)) (const_int 256)))
5416 (and (ge (minus (match_dup 4) (pc)) (const_int -2040))
5417 (le (minus (match_dup 4) (pc)) (const_int 2048)))
5421 (and (ge (minus (match_dup 4) (pc)) (const_int -248))
5422 (le (minus (match_dup 4) (pc)) (const_int 256)))
5425 (and (ge (minus (match_dup 4) (pc)) (const_int -2038))
5426 (le (minus (match_dup 4) (pc)) (const_int 2048)))
5431 (define_insn "*orrsi3_cbranch_scratch"
5434 (match_operator 4 "equality_operator"
5435 [(ior:SI (match_operand:SI 1 "s_register_operand" "%0")
5436 (match_operand:SI 2 "s_register_operand" "l"))
5438 (label_ref (match_operand 3 "" ""))
5440 (clobber (match_scratch:SI 0 "=l"))]
5444 output_asm_insn (\"orr\\t%0, %2\", operands);
5445 switch (get_attr_length (insn))
5447 case 4: return \"b%d4\\t%l3\";
5448 case 6: return \"b%D4\\t.LCB%=\;b\\t%l3\\t%@long jump\\n.LCB%=:\";
5449 default: return \"b%D4\\t.LCB%=\;bl\\t%l3\\t%@far jump\\n.LCB%=:\";
5452 [(set (attr "far_jump")
5454 (eq_attr "length" "8")
5455 (const_string "yes")
5456 (const_string "no")))
5457 (set (attr "length")
5459 (and (ge (minus (match_dup 3) (pc)) (const_int -250))
5460 (le (minus (match_dup 3) (pc)) (const_int 256)))
5463 (and (ge (minus (match_dup 3) (pc)) (const_int -2040))
5464 (le (minus (match_dup 3) (pc)) (const_int 2048)))
5469 (define_insn "*orrsi3_cbranch"
5472 (match_operator 5 "equality_operator"
5473 [(ior:SI (match_operand:SI 2 "s_register_operand" "%0,1,1,1")
5474 (match_operand:SI 3 "s_register_operand" "l,l,l,l"))
5476 (label_ref (match_operand 4 "" ""))
5478 (set (match_operand:SI 0 "thumb_cbrch_target_operand" "=l,?h,?m,?m")
5479 (ior:SI (match_dup 2) (match_dup 3)))
5480 (clobber (match_scratch:SI 1 "=X,l,&l,&l"))]
5484 if (which_alternative == 0)
5485 output_asm_insn (\"orr\\t%0, %3\", operands);
5486 else if (which_alternative == 1)
5488 output_asm_insn (\"orr\\t%1, %3\", operands);
5489 output_asm_insn (\"mov\\t%0, %1\", operands);
5493 output_asm_insn (\"orr\\t%1, %3\", operands);
5494 output_asm_insn (\"str\\t%1, %0\", operands);
5497 switch (get_attr_length (insn) - (which_alternative ? 2 : 0))
5499 case 4: return \"b%d5\\t%l4\";
5500 case 6: return \"b%D5\\t.LCB%=\;b\\t%l4\\t%@long jump\\n.LCB%=:\";
5501 default: return \"b%D5\\t.LCB%=\;bl\\t%l4\\t%@far jump\\n.LCB%=:\";
5504 [(set (attr "far_jump")
5506 (ior (and (eq (symbol_ref ("which_alternative"))
5508 (eq_attr "length" "8"))
5509 (eq_attr "length" "10"))
5510 (const_string "yes")
5511 (const_string "no")))
5512 (set (attr "length")
5514 (eq (symbol_ref ("which_alternative"))
5517 (and (ge (minus (match_dup 4) (pc)) (const_int -250))
5518 (le (minus (match_dup 4) (pc)) (const_int 256)))
5521 (and (ge (minus (match_dup 4) (pc)) (const_int -2040))
5522 (le (minus (match_dup 4) (pc)) (const_int 2048)))
5526 (and (ge (minus (match_dup 4) (pc)) (const_int -248))
5527 (le (minus (match_dup 4) (pc)) (const_int 256)))
5530 (and (ge (minus (match_dup 4) (pc)) (const_int -2038))
5531 (le (minus (match_dup 4) (pc)) (const_int 2048)))
5536 (define_insn "*xorsi3_cbranch_scratch"
5539 (match_operator 4 "equality_operator"
5540 [(xor:SI (match_operand:SI 1 "s_register_operand" "%0")
5541 (match_operand:SI 2 "s_register_operand" "l"))
5543 (label_ref (match_operand 3 "" ""))
5545 (clobber (match_scratch:SI 0 "=l"))]
5549 output_asm_insn (\"eor\\t%0, %2\", operands);
5550 switch (get_attr_length (insn))
5552 case 4: return \"b%d4\\t%l3\";
5553 case 6: return \"b%D4\\t.LCB%=\;b\\t%l3\\t%@long jump\\n.LCB%=:\";
5554 default: return \"b%D4\\t.LCB%=\;bl\\t%l3\\t%@far jump\\n.LCB%=:\";
5557 [(set (attr "far_jump")
5559 (eq_attr "length" "8")
5560 (const_string "yes")
5561 (const_string "no")))
5562 (set (attr "length")
5564 (and (ge (minus (match_dup 3) (pc)) (const_int -250))
5565 (le (minus (match_dup 3) (pc)) (const_int 256)))
5568 (and (ge (minus (match_dup 3) (pc)) (const_int -2040))
5569 (le (minus (match_dup 3) (pc)) (const_int 2048)))
5574 (define_insn "*xorsi3_cbranch"
5577 (match_operator 5 "equality_operator"
5578 [(xor:SI (match_operand:SI 2 "s_register_operand" "%0,1,1,1")
5579 (match_operand:SI 3 "s_register_operand" "l,l,l,l"))
5581 (label_ref (match_operand 4 "" ""))
5583 (set (match_operand:SI 0 "thumb_cbrch_target_operand" "=l,?h,?m,?m")
5584 (xor:SI (match_dup 2) (match_dup 3)))
5585 (clobber (match_scratch:SI 1 "=X,l,&l,&l"))]
5589 if (which_alternative == 0)
5590 output_asm_insn (\"eor\\t%0, %3\", operands);
5591 else if (which_alternative == 1)
5593 output_asm_insn (\"eor\\t%1, %3\", operands);
5594 output_asm_insn (\"mov\\t%0, %1\", operands);
5598 output_asm_insn (\"eor\\t%1, %3\", operands);
5599 output_asm_insn (\"str\\t%1, %0\", operands);
5602 switch (get_attr_length (insn) - (which_alternative ? 2 : 0))
5604 case 4: return \"b%d5\\t%l4\";
5605 case 6: return \"b%D5\\t.LCB%=\;b\\t%l4\\t%@long jump\\n.LCB%=:\";
5606 default: return \"b%D5\\t.LCB%=\;bl\\t%l4\\t%@far jump\\n.LCB%=:\";
5609 [(set (attr "far_jump")
5611 (ior (and (eq (symbol_ref ("which_alternative"))
5613 (eq_attr "length" "8"))
5614 (eq_attr "length" "10"))
5615 (const_string "yes")
5616 (const_string "no")))
5617 (set (attr "length")
5619 (eq (symbol_ref ("which_alternative"))
5622 (and (ge (minus (match_dup 4) (pc)) (const_int -250))
5623 (le (minus (match_dup 4) (pc)) (const_int 256)))
5626 (and (ge (minus (match_dup 4) (pc)) (const_int -2040))
5627 (le (minus (match_dup 4) (pc)) (const_int 2048)))
5631 (and (ge (minus (match_dup 4) (pc)) (const_int -248))
5632 (le (minus (match_dup 4) (pc)) (const_int 256)))
5635 (and (ge (minus (match_dup 4) (pc)) (const_int -2038))
5636 (le (minus (match_dup 4) (pc)) (const_int 2048)))
5641 (define_insn "*cbranchne_decr1"
5643 (if_then_else (match_operator 3 "equality_operator"
5644 [(match_operand:SI 2 "s_register_operand" "l,l,1,l")
5646 (label_ref (match_operand 4 "" ""))
5648 (set (match_operand:SI 0 "thumb_cbrch_target_operand" "=l,?h,?m,?m")
5649 (plus:SI (match_dup 2) (const_int -1)))
5650 (clobber (match_scratch:SI 1 "=X,l,&l,&l"))]
5655 cond[0] = gen_rtx_fmt_ee ((GET_CODE (operands[3]) == NE
5657 VOIDmode, operands[2], const1_rtx);
5658 cond[1] = operands[4];
5660 if (which_alternative == 0)
5661 output_asm_insn (\"sub\\t%0, %2, #1\", operands);
5662 else if (which_alternative == 1)
5664 /* We must provide an alternative for a hi reg because reload
5665 cannot handle output reloads on a jump instruction, but we
5666 can't subtract into that. Fortunately a mov from lo to hi
5667 does not clobber the condition codes. */
5668 output_asm_insn (\"sub\\t%1, %2, #1\", operands);
5669 output_asm_insn (\"mov\\t%0, %1\", operands);
5673 /* Similarly, but the target is memory. */
5674 output_asm_insn (\"sub\\t%1, %2, #1\", operands);
5675 output_asm_insn (\"str\\t%1, %0\", operands);
5678 switch (get_attr_length (insn) - (which_alternative ? 2 : 0))
5681 output_asm_insn (\"b%d0\\t%l1\", cond);
5684 output_asm_insn (\"b%D0\\t.LCB%=\", cond);
5685 return \"b\\t%l4\\t%@long jump\\n.LCB%=:\";
5687 output_asm_insn (\"b%D0\\t.LCB%=\", cond);
5688 return \"bl\\t%l4\\t%@far jump\\n.LCB%=:\";
5692 [(set (attr "far_jump")
5694 (ior (and (eq (symbol_ref ("which_alternative"))
5696 (eq_attr "length" "8"))
5697 (eq_attr "length" "10"))
5698 (const_string "yes")
5699 (const_string "no")))
5700 (set_attr_alternative "length"
5704 (and (ge (minus (match_dup 4) (pc)) (const_int -250))
5705 (le (minus (match_dup 4) (pc)) (const_int 256)))
5708 (and (ge (minus (match_dup 4) (pc)) (const_int -2040))
5709 (le (minus (match_dup 4) (pc)) (const_int 2048)))
5714 (and (ge (minus (match_dup 4) (pc)) (const_int -248))
5715 (le (minus (match_dup 4) (pc)) (const_int 256)))
5718 (and (ge (minus (match_dup 4) (pc)) (const_int -2038))
5719 (le (minus (match_dup 4) (pc)) (const_int 2048)))
5724 (and (ge (minus (match_dup 4) (pc)) (const_int -248))
5725 (le (minus (match_dup 4) (pc)) (const_int 256)))
5728 (and (ge (minus (match_dup 4) (pc)) (const_int -2038))
5729 (le (minus (match_dup 4) (pc)) (const_int 2048)))
5734 (and (ge (minus (match_dup 4) (pc)) (const_int -248))
5735 (le (minus (match_dup 4) (pc)) (const_int 256)))
5738 (and (ge (minus (match_dup 4) (pc)) (const_int -2038))
5739 (le (minus (match_dup 4) (pc)) (const_int 2048)))
5744 (define_insn "*addsi3_cbranch"
5747 (match_operator 4 "comparison_operator"
5749 (match_operand:SI 2 "s_register_operand" "%l,0,*0,1,1,1")
5750 (match_operand:SI 3 "reg_or_int_operand" "lL,IJ,*r,lIJ,lIJ,lIJ"))
5752 (label_ref (match_operand 5 "" ""))
5754 (set (match_operand:SI 0 "thumb_cbrch_target_operand" "=l,l,*!h,?h,?m,?m")
5755 (plus:SI (match_dup 2) (match_dup 3)))
5756 (clobber (match_scratch:SI 1 "=X,X,X,l,&l,&l"))]
5758 && (GET_CODE (operands[4]) == EQ
5759 || GET_CODE (operands[4]) == NE
5760 || GET_CODE (operands[4]) == GE
5761 || GET_CODE (operands[4]) == LT)"
5767 cond[0] = (which_alternative < 3) ? operands[0] : operands[1];
5768 cond[1] = operands[2];
5769 cond[2] = operands[3];
5771 if (GET_CODE (cond[2]) == CONST_INT && INTVAL (cond[2]) < 0)
5772 output_asm_insn (\"sub\\t%0, %1, #%n2\", cond);
5774 output_asm_insn (\"add\\t%0, %1, %2\", cond);
5776 if (which_alternative >= 3
5777 && which_alternative < 4)
5778 output_asm_insn (\"mov\\t%0, %1\", operands);
5779 else if (which_alternative >= 4)
5780 output_asm_insn (\"str\\t%1, %0\", operands);
5782 switch (get_attr_length (insn) - ((which_alternative >= 3) ? 2 : 0))
5785 return \"b%d4\\t%l5\";
5787 return \"b%D4\\t.LCB%=\;b\\t%l5\\t%@long jump\\n.LCB%=:\";
5789 return \"b%D4\\t.LCB%=\;bl\\t%l5\\t%@far jump\\n.LCB%=:\";
5793 [(set (attr "far_jump")
5795 (ior (and (lt (symbol_ref ("which_alternative"))
5797 (eq_attr "length" "8"))
5798 (eq_attr "length" "10"))
5799 (const_string "yes")
5800 (const_string "no")))
5801 (set (attr "length")
5803 (lt (symbol_ref ("which_alternative"))
5806 (and (ge (minus (match_dup 5) (pc)) (const_int -250))
5807 (le (minus (match_dup 5) (pc)) (const_int 256)))
5810 (and (ge (minus (match_dup 5) (pc)) (const_int -2040))
5811 (le (minus (match_dup 5) (pc)) (const_int 2048)))
5815 (and (ge (minus (match_dup 5) (pc)) (const_int -248))
5816 (le (minus (match_dup 5) (pc)) (const_int 256)))
5819 (and (ge (minus (match_dup 5) (pc)) (const_int -2038))
5820 (le (minus (match_dup 5) (pc)) (const_int 2048)))
5825 (define_insn "*addsi3_cbranch_scratch"
5828 (match_operator 3 "comparison_operator"
5830 (match_operand:SI 1 "s_register_operand" "%l,l,l,0")
5831 (match_operand:SI 2 "reg_or_int_operand" "J,l,I,L"))
5833 (label_ref (match_operand 4 "" ""))
5835 (clobber (match_scratch:SI 0 "=X,X,l,l"))]
5837 && (GET_CODE (operands[3]) == EQ
5838 || GET_CODE (operands[3]) == NE
5839 || GET_CODE (operands[3]) == GE
5840 || GET_CODE (operands[3]) == LT)"
5843 switch (which_alternative)
5846 output_asm_insn (\"cmp\t%1, #%n2\", operands);
5849 output_asm_insn (\"cmn\t%1, %2\", operands);
5852 output_asm_insn (\"add\t%0, %1, %2\", operands);
5855 output_asm_insn (\"add\t%0, %0, %2\", operands);
5859 switch (get_attr_length (insn))
5862 return \"b%d3\\t%l4\";
5864 return \"b%D3\\t.LCB%=\;b\\t%l4\\t%@long jump\\n.LCB%=:\";
5866 return \"b%D3\\t.LCB%=\;bl\\t%l4\\t%@far jump\\n.LCB%=:\";
5870 [(set (attr "far_jump")
5872 (eq_attr "length" "8")
5873 (const_string "yes")
5874 (const_string "no")))
5875 (set (attr "length")
5877 (and (ge (minus (match_dup 4) (pc)) (const_int -250))
5878 (le (minus (match_dup 4) (pc)) (const_int 256)))
5881 (and (ge (minus (match_dup 4) (pc)) (const_int -2040))
5882 (le (minus (match_dup 4) (pc)) (const_int 2048)))
5887 (define_insn "*subsi3_cbranch"
5890 (match_operator 4 "comparison_operator"
5892 (match_operand:SI 2 "s_register_operand" "l,l,1,l")
5893 (match_operand:SI 3 "s_register_operand" "l,l,l,l"))
5895 (label_ref (match_operand 5 "" ""))
5897 (set (match_operand:SI 0 "thumb_cbrch_target_operand" "=l,?h,?m,?m")
5898 (minus:SI (match_dup 2) (match_dup 3)))
5899 (clobber (match_scratch:SI 1 "=X,l,&l,&l"))]
5901 && (GET_CODE (operands[4]) == EQ
5902 || GET_CODE (operands[4]) == NE
5903 || GET_CODE (operands[4]) == GE
5904 || GET_CODE (operands[4]) == LT)"
5907 if (which_alternative == 0)
5908 output_asm_insn (\"sub\\t%0, %2, %3\", operands);
5909 else if (which_alternative == 1)
5911 /* We must provide an alternative for a hi reg because reload
5912 cannot handle output reloads on a jump instruction, but we
5913 can't subtract into that. Fortunately a mov from lo to hi
5914 does not clobber the condition codes. */
5915 output_asm_insn (\"sub\\t%1, %2, %3\", operands);
5916 output_asm_insn (\"mov\\t%0, %1\", operands);
5920 /* Similarly, but the target is memory. */
5921 output_asm_insn (\"sub\\t%1, %2, %3\", operands);
5922 output_asm_insn (\"str\\t%1, %0\", operands);
5925 switch (get_attr_length (insn) - ((which_alternative != 0) ? 2 : 0))
5928 return \"b%d4\\t%l5\";
5930 return \"b%D4\\t.LCB%=\;b\\t%l5\\t%@long jump\\n.LCB%=:\";
5932 return \"b%D4\\t.LCB%=\;bl\\t%l5\\t%@far jump\\n.LCB%=:\";
5936 [(set (attr "far_jump")
5938 (ior (and (eq (symbol_ref ("which_alternative"))
5940 (eq_attr "length" "8"))
5941 (eq_attr "length" "10"))
5942 (const_string "yes")
5943 (const_string "no")))
5944 (set (attr "length")
5946 (eq (symbol_ref ("which_alternative"))
5949 (and (ge (minus (match_dup 5) (pc)) (const_int -250))
5950 (le (minus (match_dup 5) (pc)) (const_int 256)))
5953 (and (ge (minus (match_dup 5) (pc)) (const_int -2040))
5954 (le (minus (match_dup 5) (pc)) (const_int 2048)))
5958 (and (ge (minus (match_dup 5) (pc)) (const_int -248))
5959 (le (minus (match_dup 5) (pc)) (const_int 256)))
5962 (and (ge (minus (match_dup 5) (pc)) (const_int -2038))
5963 (le (minus (match_dup 5) (pc)) (const_int 2048)))
5968 (define_insn "*subsi3_cbranch_scratch"
5971 (match_operator 0 "arm_comparison_operator"
5972 [(minus:SI (match_operand:SI 1 "register_operand" "l")
5973 (match_operand:SI 2 "nonmemory_operand" "l"))
5975 (label_ref (match_operand 3 "" ""))
5978 && (GET_CODE (operands[0]) == EQ
5979 || GET_CODE (operands[0]) == NE
5980 || GET_CODE (operands[0]) == GE
5981 || GET_CODE (operands[0]) == LT)"
5983 output_asm_insn (\"cmp\\t%1, %2\", operands);
5984 switch (get_attr_length (insn))
5986 case 4: return \"b%d0\\t%l3\";
5987 case 6: return \"b%D0\\t.LCB%=\;b\\t%l3\\t%@long jump\\n.LCB%=:\";
5988 default: return \"b%D0\\t.LCB%=\;bl\\t%l3\\t%@far jump\\n.LCB%=:\";
5991 [(set (attr "far_jump")
5993 (eq_attr "length" "8")
5994 (const_string "yes")
5995 (const_string "no")))
5996 (set (attr "length")
5998 (and (ge (minus (match_dup 3) (pc)) (const_int -250))
5999 (le (minus (match_dup 3) (pc)) (const_int 256)))
6002 (and (ge (minus (match_dup 3) (pc)) (const_int -2040))
6003 (le (minus (match_dup 3) (pc)) (const_int 2048)))
6008 ;; Comparison and test insns
6010 (define_expand "cmpsi"
6011 [(match_operand:SI 0 "s_register_operand" "")
6012 (match_operand:SI 1 "arm_add_operand" "")]
6015 arm_compare_op0 = operands[0];
6016 arm_compare_op1 = operands[1];
6021 (define_expand "cmpsf"
6022 [(match_operand:SF 0 "s_register_operand" "")
6023 (match_operand:SF 1 "fpa_rhs_operand" "")]
6024 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
6026 if (TARGET_CIRRUS && !cirrus_fp_register (operands[1], SFmode))
6027 operands[1] = force_reg (SFmode, operands[1]);
6029 arm_compare_op0 = operands[0];
6030 arm_compare_op1 = operands[1];
6035 (define_expand "cmpdf"
6036 [(match_operand:DF 0 "s_register_operand" "")
6037 (match_operand:DF 1 "fpa_rhs_operand" "")]
6038 "TARGET_ARM && TARGET_ANY_HARD_FLOAT"
6040 if (TARGET_CIRRUS && !cirrus_fp_register (operands[1], DFmode))
6041 operands[1] = force_reg (DFmode, operands[1]);
6043 arm_compare_op0 = operands[0];
6044 arm_compare_op1 = operands[1];
6049 (define_insn "*arm_cmpsi_insn"
6050 [(set (reg:CC CC_REGNUM)
6051 (compare:CC (match_operand:SI 0 "s_register_operand" "r,r")
6052 (match_operand:SI 1 "arm_add_operand" "rI,L")))]
6057 [(set_attr "conds" "set")]
6060 (define_insn "*cmpsi_shiftsi"
6061 [(set (reg:CC CC_REGNUM)
6062 (compare:CC (match_operand:SI 0 "s_register_operand" "r")
6063 (match_operator:SI 3 "shift_operator"
6064 [(match_operand:SI 1 "s_register_operand" "r")
6065 (match_operand:SI 2 "arm_rhs_operand" "rM")])))]
6068 [(set_attr "conds" "set")
6069 (set_attr "shift" "1")
6073 (define_insn "*cmpsi_shiftsi_swp"
6074 [(set (reg:CC_SWP CC_REGNUM)
6075 (compare:CC_SWP (match_operator:SI 3 "shift_operator"
6076 [(match_operand:SI 1 "s_register_operand" "r")
6077 (match_operand:SI 2 "reg_or_int_operand" "rM")])
6078 (match_operand:SI 0 "s_register_operand" "r")))]
6081 [(set_attr "conds" "set")
6082 (set_attr "shift" "1")
6086 (define_insn "*cmpsi_neg_shiftsi"
6087 [(set (reg:CC CC_REGNUM)
6088 (compare:CC (match_operand:SI 0 "s_register_operand" "r")
6089 (neg:SI (match_operator:SI 3 "shift_operator"
6090 [(match_operand:SI 1 "s_register_operand" "r")
6091 (match_operand:SI 2 "arm_rhs_operand" "rM")]))))]
6094 [(set_attr "conds" "set")
6095 (set_attr "shift" "1")
6099 ;; Cirrus SF compare instruction
6100 (define_insn "*cirrus_cmpsf"
6101 [(set (reg:CCFP CC_REGNUM)
6102 (compare:CCFP (match_operand:SF 0 "cirrus_fp_register" "v")
6103 (match_operand:SF 1 "cirrus_fp_register" "v")))]
6104 "TARGET_ARM && TARGET_CIRRUS"
6105 "cfcmps%?\\tr15, %V0, %V1"
6106 [(set_attr "type" "mav_farith")
6107 (set_attr "cirrus" "compare")]
6110 ;; Cirrus DF compare instruction
6111 (define_insn "*cirrus_cmpdf"
6112 [(set (reg:CCFP CC_REGNUM)
6113 (compare:CCFP (match_operand:DF 0 "cirrus_fp_register" "v")
6114 (match_operand:DF 1 "cirrus_fp_register" "v")))]
6115 "TARGET_ARM && TARGET_CIRRUS"
6116 "cfcmpd%?\\tr15, %V0, %V1"
6117 [(set_attr "type" "mav_farith")
6118 (set_attr "cirrus" "compare")]
6121 ;; Cirrus DI compare instruction
6122 (define_expand "cmpdi"
6123 [(match_operand:DI 0 "cirrus_fp_register" "")
6124 (match_operand:DI 1 "cirrus_fp_register" "")]
6125 "TARGET_ARM && TARGET_CIRRUS"
6127 arm_compare_op0 = operands[0];
6128 arm_compare_op1 = operands[1];
6132 (define_insn "*cirrus_cmpdi"
6133 [(set (reg:CC CC_REGNUM)
6134 (compare:CC (match_operand:DI 0 "cirrus_fp_register" "v")
6135 (match_operand:DI 1 "cirrus_fp_register" "v")))]
6136 "TARGET_ARM && TARGET_CIRRUS"
6137 "cfcmp64%?\\tr15, %V0, %V1"
6138 [(set_attr "type" "mav_farith")
6139 (set_attr "cirrus" "compare")]
6142 ; This insn allows redundant compares to be removed by cse, nothing should
6143 ; ever appear in the output file since (set (reg x) (reg x)) is a no-op that
6144 ; is deleted later on. The match_dup will match the mode here, so that
6145 ; mode changes of the condition codes aren't lost by this even though we don't
6146 ; specify what they are.
6148 (define_insn "*deleted_compare"
6149 [(set (match_operand 0 "cc_register" "") (match_dup 0))]
6151 "\\t%@ deleted compare"
6152 [(set_attr "conds" "set")
6153 (set_attr "length" "0")]
6157 ;; Conditional branch insns
6159 (define_expand "beq"
6161 (if_then_else (eq (match_dup 1) (const_int 0))
6162 (label_ref (match_operand 0 "" ""))
6165 "operands[1] = arm_gen_compare_reg (EQ, arm_compare_op0, arm_compare_op1);"
6168 (define_expand "bne"
6170 (if_then_else (ne (match_dup 1) (const_int 0))
6171 (label_ref (match_operand 0 "" ""))
6174 "operands[1] = arm_gen_compare_reg (NE, arm_compare_op0, arm_compare_op1);"
6177 (define_expand "bgt"
6179 (if_then_else (gt (match_dup 1) (const_int 0))
6180 (label_ref (match_operand 0 "" ""))
6183 "operands[1] = arm_gen_compare_reg (GT, arm_compare_op0, arm_compare_op1);"
6186 (define_expand "ble"
6188 (if_then_else (le (match_dup 1) (const_int 0))
6189 (label_ref (match_operand 0 "" ""))
6192 "operands[1] = arm_gen_compare_reg (LE, arm_compare_op0, arm_compare_op1);"
6195 (define_expand "bge"
6197 (if_then_else (ge (match_dup 1) (const_int 0))
6198 (label_ref (match_operand 0 "" ""))
6201 "operands[1] = arm_gen_compare_reg (GE, arm_compare_op0, arm_compare_op1);"
6204 (define_expand "blt"
6206 (if_then_else (lt (match_dup 1) (const_int 0))
6207 (label_ref (match_operand 0 "" ""))
6210 "operands[1] = arm_gen_compare_reg (LT, arm_compare_op0, arm_compare_op1);"
6213 (define_expand "bgtu"
6215 (if_then_else (gtu (match_dup 1) (const_int 0))
6216 (label_ref (match_operand 0 "" ""))
6219 "operands[1] = arm_gen_compare_reg (GTU, arm_compare_op0, arm_compare_op1);"
6222 (define_expand "bleu"
6224 (if_then_else (leu (match_dup 1) (const_int 0))
6225 (label_ref (match_operand 0 "" ""))
6228 "operands[1] = arm_gen_compare_reg (LEU, arm_compare_op0, arm_compare_op1);"
6231 (define_expand "bgeu"
6233 (if_then_else (geu (match_dup 1) (const_int 0))
6234 (label_ref (match_operand 0 "" ""))
6237 "operands[1] = arm_gen_compare_reg (GEU, arm_compare_op0, arm_compare_op1);"
6240 (define_expand "bltu"
6242 (if_then_else (ltu (match_dup 1) (const_int 0))
6243 (label_ref (match_operand 0 "" ""))
6246 "operands[1] = arm_gen_compare_reg (LTU, arm_compare_op0, arm_compare_op1);"
6249 (define_expand "bunordered"
6251 (if_then_else (unordered (match_dup 1) (const_int 0))
6252 (label_ref (match_operand 0 "" ""))
6254 "TARGET_ARM && TARGET_HARD_FLOAT"
6255 "operands[1] = arm_gen_compare_reg (UNORDERED, arm_compare_op0,
6259 (define_expand "bordered"
6261 (if_then_else (ordered (match_dup 1) (const_int 0))
6262 (label_ref (match_operand 0 "" ""))
6264 "TARGET_ARM && TARGET_HARD_FLOAT"
6265 "operands[1] = arm_gen_compare_reg (ORDERED, arm_compare_op0,
6269 (define_expand "bungt"
6271 (if_then_else (ungt (match_dup 1) (const_int 0))
6272 (label_ref (match_operand 0 "" ""))
6274 "TARGET_ARM && TARGET_HARD_FLOAT"
6275 "operands[1] = arm_gen_compare_reg (UNGT, arm_compare_op0, arm_compare_op1);"
6278 (define_expand "bunlt"
6280 (if_then_else (unlt (match_dup 1) (const_int 0))
6281 (label_ref (match_operand 0 "" ""))
6283 "TARGET_ARM && TARGET_HARD_FLOAT"
6284 "operands[1] = arm_gen_compare_reg (UNLT, arm_compare_op0, arm_compare_op1);"
6287 (define_expand "bunge"
6289 (if_then_else (unge (match_dup 1) (const_int 0))
6290 (label_ref (match_operand 0 "" ""))
6292 "TARGET_ARM && TARGET_HARD_FLOAT"
6293 "operands[1] = arm_gen_compare_reg (UNGE, arm_compare_op0, arm_compare_op1);"
6296 (define_expand "bunle"
6298 (if_then_else (unle (match_dup 1) (const_int 0))
6299 (label_ref (match_operand 0 "" ""))
6301 "TARGET_ARM && TARGET_HARD_FLOAT"
6302 "operands[1] = arm_gen_compare_reg (UNLE, arm_compare_op0, arm_compare_op1);"
6305 ;; The following two patterns need two branch instructions, since there is
6306 ;; no single instruction that will handle all cases.
6307 (define_expand "buneq"
6309 (if_then_else (uneq (match_dup 1) (const_int 0))
6310 (label_ref (match_operand 0 "" ""))
6312 "TARGET_ARM && TARGET_HARD_FLOAT"
6313 "operands[1] = arm_gen_compare_reg (UNEQ, arm_compare_op0, arm_compare_op1);"
6316 (define_expand "bltgt"
6318 (if_then_else (ltgt (match_dup 1) (const_int 0))
6319 (label_ref (match_operand 0 "" ""))
6321 "TARGET_ARM && TARGET_HARD_FLOAT"
6322 "operands[1] = arm_gen_compare_reg (LTGT, arm_compare_op0, arm_compare_op1);"
6326 ;; Patterns to match conditional branch insns.
6329 ; Special pattern to match UNEQ.
6330 (define_insn "*arm_buneq"
6332 (if_then_else (uneq (match_operand 1 "cc_register" "") (const_int 0))
6333 (label_ref (match_operand 0 "" ""))
6335 "TARGET_ARM && TARGET_HARD_FLOAT"
6337 if (arm_ccfsm_state != 0)
6340 return \"bvs\\t%l0\;beq\\t%l0\";
6342 [(set_attr "conds" "jump_clob")
6343 (set_attr "length" "8")]
6346 ; Special pattern to match LTGT.
6347 (define_insn "*arm_bltgt"
6349 (if_then_else (ltgt (match_operand 1 "cc_register" "") (const_int 0))
6350 (label_ref (match_operand 0 "" ""))
6352 "TARGET_ARM && TARGET_HARD_FLOAT"
6354 if (arm_ccfsm_state != 0)
6357 return \"bmi\\t%l0\;bgt\\t%l0\";
6359 [(set_attr "conds" "jump_clob")
6360 (set_attr "length" "8")]
6363 (define_insn "*arm_cond_branch"
6365 (if_then_else (match_operator 1 "arm_comparison_operator"
6366 [(match_operand 2 "cc_register" "") (const_int 0)])
6367 (label_ref (match_operand 0 "" ""))
6371 if (arm_ccfsm_state == 1 || arm_ccfsm_state == 2)
6373 arm_ccfsm_state += 2;
6376 return \"b%d1\\t%l0\";
6378 [(set_attr "conds" "use")]
6381 ; Special pattern to match reversed UNEQ.
6382 (define_insn "*arm_buneq_reversed"
6384 (if_then_else (uneq (match_operand 1 "cc_register" "") (const_int 0))
6386 (label_ref (match_operand 0 "" ""))))]
6387 "TARGET_ARM && TARGET_HARD_FLOAT"
6389 if (arm_ccfsm_state != 0)
6392 return \"bmi\\t%l0\;bgt\\t%l0\";
6394 [(set_attr "conds" "jump_clob")
6395 (set_attr "length" "8")]
6398 ; Special pattern to match reversed LTGT.
6399 (define_insn "*arm_bltgt_reversed"
6401 (if_then_else (ltgt (match_operand 1 "cc_register" "") (const_int 0))
6403 (label_ref (match_operand 0 "" ""))))]
6404 "TARGET_ARM && TARGET_HARD_FLOAT"
6406 if (arm_ccfsm_state != 0)
6409 return \"bvs\\t%l0\;beq\\t%l0\";
6411 [(set_attr "conds" "jump_clob")
6412 (set_attr "length" "8")]
6415 (define_insn "*arm_cond_branch_reversed"
6417 (if_then_else (match_operator 1 "arm_comparison_operator"
6418 [(match_operand 2 "cc_register" "") (const_int 0)])
6420 (label_ref (match_operand 0 "" ""))))]
6423 if (arm_ccfsm_state == 1 || arm_ccfsm_state == 2)
6425 arm_ccfsm_state += 2;
6428 return \"b%D1\\t%l0\";
6430 [(set_attr "conds" "use")]
6437 (define_expand "seq"
6438 [(set (match_operand:SI 0 "s_register_operand" "")
6439 (eq:SI (match_dup 1) (const_int 0)))]
6441 "operands[1] = arm_gen_compare_reg (EQ, arm_compare_op0, arm_compare_op1);"
6444 (define_expand "sne"
6445 [(set (match_operand:SI 0 "s_register_operand" "")
6446 (ne:SI (match_dup 1) (const_int 0)))]
6448 "operands[1] = arm_gen_compare_reg (NE, arm_compare_op0, arm_compare_op1);"
6451 (define_expand "sgt"
6452 [(set (match_operand:SI 0 "s_register_operand" "")
6453 (gt:SI (match_dup 1) (const_int 0)))]
6455 "operands[1] = arm_gen_compare_reg (GT, arm_compare_op0, arm_compare_op1);"
6458 (define_expand "sle"
6459 [(set (match_operand:SI 0 "s_register_operand" "")
6460 (le:SI (match_dup 1) (const_int 0)))]
6462 "operands[1] = arm_gen_compare_reg (LE, arm_compare_op0, arm_compare_op1);"
6465 (define_expand "sge"
6466 [(set (match_operand:SI 0 "s_register_operand" "")
6467 (ge:SI (match_dup 1) (const_int 0)))]
6469 "operands[1] = arm_gen_compare_reg (GE, arm_compare_op0, arm_compare_op1);"
6472 (define_expand "slt"
6473 [(set (match_operand:SI 0 "s_register_operand" "")
6474 (lt:SI (match_dup 1) (const_int 0)))]
6476 "operands[1] = arm_gen_compare_reg (LT, arm_compare_op0, arm_compare_op1);"
6479 (define_expand "sgtu"
6480 [(set (match_operand:SI 0 "s_register_operand" "")
6481 (gtu:SI (match_dup 1) (const_int 0)))]
6483 "operands[1] = arm_gen_compare_reg (GTU, arm_compare_op0, arm_compare_op1);"
6486 (define_expand "sleu"
6487 [(set (match_operand:SI 0 "s_register_operand" "")
6488 (leu:SI (match_dup 1) (const_int 0)))]
6490 "operands[1] = arm_gen_compare_reg (LEU, arm_compare_op0, arm_compare_op1);"
6493 (define_expand "sgeu"
6494 [(set (match_operand:SI 0 "s_register_operand" "")
6495 (geu:SI (match_dup 1) (const_int 0)))]
6497 "operands[1] = arm_gen_compare_reg (GEU, arm_compare_op0, arm_compare_op1);"
6500 (define_expand "sltu"
6501 [(set (match_operand:SI 0 "s_register_operand" "")
6502 (ltu:SI (match_dup 1) (const_int 0)))]
6504 "operands[1] = arm_gen_compare_reg (LTU, arm_compare_op0, arm_compare_op1);"
6507 (define_expand "sunordered"
6508 [(set (match_operand:SI 0 "s_register_operand" "")
6509 (unordered:SI (match_dup 1) (const_int 0)))]
6510 "TARGET_ARM && TARGET_HARD_FLOAT"
6511 "operands[1] = arm_gen_compare_reg (UNORDERED, arm_compare_op0,
6515 (define_expand "sordered"
6516 [(set (match_operand:SI 0 "s_register_operand" "")
6517 (ordered:SI (match_dup 1) (const_int 0)))]
6518 "TARGET_ARM && TARGET_HARD_FLOAT"
6519 "operands[1] = arm_gen_compare_reg (ORDERED, arm_compare_op0,
6523 (define_expand "sungt"
6524 [(set (match_operand:SI 0 "s_register_operand" "")
6525 (ungt:SI (match_dup 1) (const_int 0)))]
6526 "TARGET_ARM && TARGET_HARD_FLOAT"
6527 "operands[1] = arm_gen_compare_reg (UNGT, arm_compare_op0,
6531 (define_expand "sunge"
6532 [(set (match_operand:SI 0 "s_register_operand" "")
6533 (unge:SI (match_dup 1) (const_int 0)))]
6534 "TARGET_ARM && TARGET_HARD_FLOAT"
6535 "operands[1] = arm_gen_compare_reg (UNGE, arm_compare_op0,
6539 (define_expand "sunlt"
6540 [(set (match_operand:SI 0 "s_register_operand" "")
6541 (unlt:SI (match_dup 1) (const_int 0)))]
6542 "TARGET_ARM && TARGET_HARD_FLOAT"
6543 "operands[1] = arm_gen_compare_reg (UNLT, arm_compare_op0,
6547 (define_expand "sunle"
6548 [(set (match_operand:SI 0 "s_register_operand" "")
6549 (unle:SI (match_dup 1) (const_int 0)))]
6550 "TARGET_ARM && TARGET_HARD_FLOAT"
6551 "operands[1] = arm_gen_compare_reg (UNLE, arm_compare_op0,
6555 ;;; DO NOT add patterns for SUNEQ or SLTGT, these can't be represented with
6556 ;;; simple ARM instructions.
6558 ; (define_expand "suneq"
6559 ; [(set (match_operand:SI 0 "s_register_operand" "")
6560 ; (uneq:SI (match_dup 1) (const_int 0)))]
6561 ; "TARGET_ARM && TARGET_HARD_FLOAT"
6565 ; (define_expand "sltgt"
6566 ; [(set (match_operand:SI 0 "s_register_operand" "")
6567 ; (ltgt:SI (match_dup 1) (const_int 0)))]
6568 ; "TARGET_ARM && TARGET_HARD_FLOAT"
6572 (define_insn "*mov_scc"
6573 [(set (match_operand:SI 0 "s_register_operand" "=r")
6574 (match_operator:SI 1 "arm_comparison_operator"
6575 [(match_operand 2 "cc_register" "") (const_int 0)]))]
6577 "mov%D1\\t%0, #0\;mov%d1\\t%0, #1"
6578 [(set_attr "conds" "use")
6579 (set_attr "length" "8")]
6582 (define_insn "*mov_negscc"
6583 [(set (match_operand:SI 0 "s_register_operand" "=r")
6584 (neg:SI (match_operator:SI 1 "arm_comparison_operator"
6585 [(match_operand 2 "cc_register" "") (const_int 0)])))]
6587 "mov%D1\\t%0, #0\;mvn%d1\\t%0, #0"
6588 [(set_attr "conds" "use")
6589 (set_attr "length" "8")]
6592 (define_insn "*mov_notscc"
6593 [(set (match_operand:SI 0 "s_register_operand" "=r")
6594 (not:SI (match_operator:SI 1 "arm_comparison_operator"
6595 [(match_operand 2 "cc_register" "") (const_int 0)])))]
6597 "mov%D1\\t%0, #0\;mvn%d1\\t%0, #1"
6598 [(set_attr "conds" "use")
6599 (set_attr "length" "8")]
6603 ;; Conditional move insns
6605 (define_expand "movsicc"
6606 [(set (match_operand:SI 0 "s_register_operand" "")
6607 (if_then_else:SI (match_operand 1 "arm_comparison_operator" "")
6608 (match_operand:SI 2 "arm_not_operand" "")
6609 (match_operand:SI 3 "arm_not_operand" "")))]
6613 enum rtx_code code = GET_CODE (operands[1]);
6616 if (code == UNEQ || code == LTGT)
6619 ccreg = arm_gen_compare_reg (code, arm_compare_op0, arm_compare_op1);
6620 operands[1] = gen_rtx (code, VOIDmode, ccreg, const0_rtx);
6624 (define_expand "movsfcc"
6625 [(set (match_operand:SF 0 "s_register_operand" "")
6626 (if_then_else:SF (match_operand 1 "arm_comparison_operator" "")
6627 (match_operand:SF 2 "s_register_operand" "")
6628 (match_operand:SF 3 "nonmemory_operand" "")))]
6632 enum rtx_code code = GET_CODE (operands[1]);
6635 if (code == UNEQ || code == LTGT)
6638 /* When compiling for SOFT_FLOAT, ensure both arms are in registers.
6639 Otherwise, ensure it is a valid FP add operand */
6640 if ((!TARGET_HARD_FLOAT)
6641 || (!fpa_add_operand (operands[3], SFmode)))
6642 operands[3] = force_reg (SFmode, operands[3]);
6644 ccreg = arm_gen_compare_reg (code, arm_compare_op0, arm_compare_op1);
6645 operands[1] = gen_rtx (code, VOIDmode, ccreg, const0_rtx);
6649 (define_expand "movdfcc"
6650 [(set (match_operand:DF 0 "s_register_operand" "")
6651 (if_then_else:DF (match_operand 1 "arm_comparison_operator" "")
6652 (match_operand:DF 2 "s_register_operand" "")
6653 (match_operand:DF 3 "fpa_add_operand" "")))]
6654 "TARGET_ARM && TARGET_HARD_FLOAT"
6657 enum rtx_code code = GET_CODE (operands[1]);
6660 if (code == UNEQ || code == LTGT)
6663 ccreg = arm_gen_compare_reg (code, arm_compare_op0, arm_compare_op1);
6664 operands[1] = gen_rtx (code, VOIDmode, ccreg, const0_rtx);
6668 (define_insn "*movsicc_insn"
6669 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r,r,r,r,r,r")
6671 (match_operator 3 "arm_comparison_operator"
6672 [(match_operand 4 "cc_register" "") (const_int 0)])
6673 (match_operand:SI 1 "arm_not_operand" "0,0,rI,K,rI,rI,K,K")
6674 (match_operand:SI 2 "arm_not_operand" "rI,K,0,0,rI,K,rI,K")))]
6681 mov%d3\\t%0, %1\;mov%D3\\t%0, %2
6682 mov%d3\\t%0, %1\;mvn%D3\\t%0, #%B2
6683 mvn%d3\\t%0, #%B1\;mov%D3\\t%0, %2
6684 mvn%d3\\t%0, #%B1\;mvn%D3\\t%0, #%B2"
6685 [(set_attr "length" "4,4,4,4,8,8,8,8")
6686 (set_attr "conds" "use")]
6689 (define_insn "*movsfcc_soft_insn"
6690 [(set (match_operand:SF 0 "s_register_operand" "=r,r")
6691 (if_then_else:SF (match_operator 3 "arm_comparison_operator"
6692 [(match_operand 4 "cc_register" "") (const_int 0)])
6693 (match_operand:SF 1 "s_register_operand" "0,r")
6694 (match_operand:SF 2 "s_register_operand" "r,0")))]
6695 "TARGET_ARM && TARGET_SOFT_FLOAT"
6699 [(set_attr "conds" "use")]
6703 ;; Jump and linkage insns
6705 (define_expand "jump"
6707 (label_ref (match_operand 0 "" "")))]
6712 (define_insn "*arm_jump"
6714 (label_ref (match_operand 0 "" "")))]
6718 if (arm_ccfsm_state == 1 || arm_ccfsm_state == 2)
6720 arm_ccfsm_state += 2;
6723 return \"b%?\\t%l0\";
6726 [(set_attr "predicable" "yes")]
6729 (define_insn "*thumb_jump"
6731 (label_ref (match_operand 0 "" "")))]
6734 if (get_attr_length (insn) == 2)
6736 return \"bl\\t%l0\\t%@ far jump\";
6738 [(set (attr "far_jump")
6740 (eq_attr "length" "4")
6741 (const_string "yes")
6742 (const_string "no")))
6743 (set (attr "length")
6745 (and (ge (minus (match_dup 0) (pc)) (const_int -2048))
6746 (le (minus (match_dup 0) (pc)) (const_int 2044)))
6751 (define_expand "call"
6752 [(parallel [(call (match_operand 0 "memory_operand" "")
6753 (match_operand 1 "general_operand" ""))
6754 (use (match_operand 2 "" ""))
6755 (clobber (reg:SI LR_REGNUM))])]
6761 /* In an untyped call, we can get NULL for operand 2. */
6762 if (operands[2] == NULL_RTX)
6763 operands[2] = const0_rtx;
6765 /* This is to decide if we should generate indirect calls by loading the
6766 32 bit address of the callee into a register before performing the
6767 branch and link. operand[2] encodes the long_call/short_call
6768 attribute of the function being called. This attribute is set whenever
6769 __attribute__((long_call/short_call)) or #pragma long_call/no_long_call
6770 is used, and the short_call attribute can also be set if function is
6771 declared as static or if it has already been defined in the current
6772 compilation unit. See arm.c and arm.h for info about this. The third
6773 parameter to arm_is_longcall_p is used to tell it which pattern
6775 callee = XEXP (operands[0], 0);
6777 if (GET_CODE (callee) != REG
6778 && arm_is_longcall_p (operands[0], INTVAL (operands[2]), 0))
6779 XEXP (operands[0], 0) = force_reg (Pmode, callee);
6783 (define_insn "*call_reg"
6784 [(call (mem:SI (match_operand:SI 0 "s_register_operand" "r"))
6785 (match_operand 1 "" ""))
6786 (use (match_operand 2 "" ""))
6787 (clobber (reg:SI LR_REGNUM))]
6790 return output_call (operands);
6792 ;; length is worst case, normally it is only two
6793 [(set_attr "length" "12")
6794 (set_attr "type" "call")]
6797 (define_insn "*call_mem"
6798 [(call (mem:SI (match_operand:SI 0 "memory_operand" "m"))
6799 (match_operand 1 "" ""))
6800 (use (match_operand 2 "" ""))
6801 (clobber (reg:SI LR_REGNUM))]
6804 return output_call_mem (operands);
6806 [(set_attr "length" "12")
6807 (set_attr "type" "call")]
6810 (define_insn "*call_indirect"
6811 [(call (mem:SI (match_operand:SI 0 "register_operand" "l*r"))
6812 (match_operand 1 "" ""))
6813 (use (match_operand 2 "" ""))
6814 (clobber (reg:SI LR_REGNUM))]
6818 if (TARGET_CALLER_INTERWORKING)
6819 return \"bl\\t%__interwork_call_via_%0\";
6821 return \"bl\\t%__call_via_%0\";
6823 [(set_attr "type" "call")]
6826 (define_insn "*call_value_indirect"
6827 [(set (match_operand 0 "" "")
6828 (call (mem:SI (match_operand:SI 1 "register_operand" "l*r"))
6829 (match_operand 2 "" "")))
6830 (use (match_operand 3 "" ""))
6831 (clobber (reg:SI LR_REGNUM))]
6835 if (TARGET_CALLER_INTERWORKING)
6836 return \"bl\\t%__interwork_call_via_%1\";
6838 return \"bl\\t%__call_via_%1\";
6840 [(set_attr "type" "call")]
6843 (define_expand "call_value"
6844 [(parallel [(set (match_operand 0 "" "")
6845 (call (match_operand 1 "memory_operand" "")
6846 (match_operand 2 "general_operand" "")))
6847 (use (match_operand 3 "" ""))
6848 (clobber (reg:SI LR_REGNUM))])]
6852 rtx callee = XEXP (operands[1], 0);
6854 /* In an untyped call, we can get NULL for operand 2. */
6855 if (operands[3] == 0)
6856 operands[3] = const0_rtx;
6858 /* See the comment in define_expand \"call\". */
6859 if (GET_CODE (callee) != REG
6860 && arm_is_longcall_p (operands[1], INTVAL (operands[3]), 0))
6861 XEXP (operands[1], 0) = force_reg (Pmode, callee);
6865 (define_insn "*call_value_reg"
6866 [(set (match_operand 0 "" "")
6867 (call (mem:SI (match_operand:SI 1 "s_register_operand" "r"))
6868 (match_operand 2 "" "")))
6869 (use (match_operand 3 "" ""))
6870 (clobber (reg:SI LR_REGNUM))]
6873 return output_call (&operands[1]);
6875 [(set_attr "length" "12")
6876 (set_attr "type" "call")]
6879 (define_insn "*call_value_mem"
6880 [(set (match_operand 0 "" "")
6881 (call (mem:SI (match_operand:SI 1 "memory_operand" "m"))
6882 (match_operand 2 "" "")))
6883 (use (match_operand 3 "" ""))
6884 (clobber (reg:SI LR_REGNUM))]
6885 "TARGET_ARM && (!CONSTANT_ADDRESS_P (XEXP (operands[1], 0)))"
6887 return output_call_mem (&operands[1]);
6889 [(set_attr "length" "12")
6890 (set_attr "type" "call")]
6893 ;; Allow calls to SYMBOL_REFs specially as they are not valid general addresses
6894 ;; The 'a' causes the operand to be treated as an address, i.e. no '#' output.
6896 (define_insn "*call_symbol"
6897 [(call (mem:SI (match_operand:SI 0 "" ""))
6898 (match_operand 1 "" ""))
6899 (use (match_operand 2 "" ""))
6900 (clobber (reg:SI LR_REGNUM))]
6902 && (GET_CODE (operands[0]) == SYMBOL_REF)
6903 && !arm_is_longcall_p (operands[0], INTVAL (operands[2]), 1)"
6906 return NEED_PLT_RELOC ? \"bl%?\\t%a0(PLT)\" : \"bl%?\\t%a0\";
6908 [(set_attr "type" "call")]
6911 (define_insn "*call_value_symbol"
6912 [(set (match_operand 0 "s_register_operand" "")
6913 (call (mem:SI (match_operand:SI 1 "" ""))
6914 (match_operand:SI 2 "" "")))
6915 (use (match_operand 3 "" ""))
6916 (clobber (reg:SI LR_REGNUM))]
6918 && (GET_CODE (operands[1]) == SYMBOL_REF)
6919 && !arm_is_longcall_p (operands[1], INTVAL (operands[3]), 1)"
6922 return NEED_PLT_RELOC ? \"bl%?\\t%a1(PLT)\" : \"bl%?\\t%a1\";
6924 [(set_attr "type" "call")]
6927 (define_insn "*call_insn"
6928 [(call (mem:SI (match_operand:SI 0 "" ""))
6929 (match_operand:SI 1 "" ""))
6930 (use (match_operand 2 "" ""))
6931 (clobber (reg:SI LR_REGNUM))]
6933 && GET_CODE (operands[0]) == SYMBOL_REF
6934 && !arm_is_longcall_p (operands[0], INTVAL (operands[2]), 1)"
6936 [(set_attr "length" "4")
6937 (set_attr "type" "call")]
6940 (define_insn "*call_value_insn"
6941 [(set (match_operand 0 "register_operand" "")
6942 (call (mem:SI (match_operand 1 "" ""))
6943 (match_operand 2 "" "")))
6944 (use (match_operand 3 "" ""))
6945 (clobber (reg:SI LR_REGNUM))]
6947 && GET_CODE (operands[1]) == SYMBOL_REF
6948 && !arm_is_longcall_p (operands[1], INTVAL (operands[3]), 1)"
6950 [(set_attr "length" "4")
6951 (set_attr "type" "call")]
6954 ;; We may also be able to do sibcalls for Thumb, but it's much harder...
6955 (define_expand "sibcall"
6956 [(parallel [(call (match_operand 0 "memory_operand" "")
6957 (match_operand 1 "general_operand" ""))
6959 (use (match_operand 2 "" ""))])]
6963 if (operands[2] == NULL_RTX)
6964 operands[2] = const0_rtx;
6968 (define_expand "sibcall_value"
6969 [(parallel [(set (match_operand 0 "register_operand" "")
6970 (call (match_operand 1 "memory_operand" "")
6971 (match_operand 2 "general_operand" "")))
6973 (use (match_operand 3 "" ""))])]
6977 if (operands[3] == NULL_RTX)
6978 operands[3] = const0_rtx;
6982 (define_insn "*sibcall_insn"
6983 [(call (mem:SI (match_operand:SI 0 "" "X"))
6984 (match_operand 1 "" ""))
6986 (use (match_operand 2 "" ""))]
6987 "TARGET_ARM && GET_CODE (operands[0]) == SYMBOL_REF"
6989 return NEED_PLT_RELOC ? \"b%?\\t%a0(PLT)\" : \"b%?\\t%a0\";
6991 [(set_attr "type" "call")]
6994 (define_insn "*sibcall_value_insn"
6995 [(set (match_operand 0 "s_register_operand" "")
6996 (call (mem:SI (match_operand:SI 1 "" "X"))
6997 (match_operand 2 "" "")))
6999 (use (match_operand 3 "" ""))]
7000 "TARGET_ARM && GET_CODE (operands[1]) == SYMBOL_REF"
7002 return NEED_PLT_RELOC ? \"b%?\\t%a1(PLT)\" : \"b%?\\t%a1\";
7004 [(set_attr "type" "call")]
7007 ;; Often the return insn will be the same as loading from memory, so set attr
7008 (define_insn "return"
7010 "TARGET_ARM && USE_RETURN_INSN (FALSE)"
7013 if (arm_ccfsm_state == 2)
7015 arm_ccfsm_state += 2;
7018 return output_return_instruction (const_true_rtx, TRUE, FALSE);
7020 [(set_attr "type" "load")
7021 (set_attr "length" "12")
7022 (set_attr "predicable" "yes")]
7025 (define_insn "*cond_return"
7027 (if_then_else (match_operator 0 "arm_comparison_operator"
7028 [(match_operand 1 "cc_register" "") (const_int 0)])
7031 "TARGET_ARM && USE_RETURN_INSN (TRUE)"
7034 if (arm_ccfsm_state == 2)
7036 arm_ccfsm_state += 2;
7039 return output_return_instruction (operands[0], TRUE, FALSE);
7041 [(set_attr "conds" "use")
7042 (set_attr "length" "12")
7043 (set_attr "type" "load")]
7046 (define_insn "*cond_return_inverted"
7048 (if_then_else (match_operator 0 "arm_comparison_operator"
7049 [(match_operand 1 "cc_register" "") (const_int 0)])
7052 "TARGET_ARM && USE_RETURN_INSN (TRUE)"
7055 if (arm_ccfsm_state == 2)
7057 arm_ccfsm_state += 2;
7060 return output_return_instruction (operands[0], TRUE, TRUE);
7062 [(set_attr "conds" "use")
7063 (set_attr "type" "load")]
7066 ;; Generate a sequence of instructions to determine if the processor is
7067 ;; in 26-bit or 32-bit mode, and return the appropriate return address
7070 (define_expand "return_addr_mask"
7072 (compare:CC_NOOV (unspec [(const_int 0)] UNSPEC_CHECK_ARCH)
7074 (set (match_operand:SI 0 "s_register_operand" "")
7075 (if_then_else:SI (eq (match_dup 1) (const_int 0))
7077 (const_int 67108860)))] ; 0x03fffffc
7080 operands[1] = gen_rtx_REG (CC_NOOVmode, CC_REGNUM);
7083 (define_insn "*check_arch2"
7084 [(set (match_operand:CC_NOOV 0 "cc_register" "")
7085 (compare:CC_NOOV (unspec [(const_int 0)] UNSPEC_CHECK_ARCH)
7088 "teq\\t%|r0, %|r0\;teq\\t%|pc, %|pc"
7089 [(set_attr "length" "8")
7090 (set_attr "conds" "set")]
7093 ;; Call subroutine returning any type.
7095 (define_expand "untyped_call"
7096 [(parallel [(call (match_operand 0 "" "")
7098 (match_operand 1 "" "")
7099 (match_operand 2 "" "")])]
7105 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
7107 for (i = 0; i < XVECLEN (operands[2], 0); i++)
7109 rtx set = XVECEXP (operands[2], 0, i);
7111 emit_move_insn (SET_DEST (set), SET_SRC (set));
7114 /* The optimizer does not know that the call sets the function value
7115 registers we stored in the result block. We avoid problems by
7116 claiming that all hard registers are used and clobbered at this
7118 emit_insn (gen_blockage ());
7124 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
7125 ;; all of memory. This blocks insns from being moved across this point.
7127 (define_insn "blockage"
7128 [(unspec_volatile [(const_int 0)] VUNSPEC_BLOCKAGE)]
7131 [(set_attr "length" "0")
7132 (set_attr "type" "block")]
7135 (define_expand "casesi"
7136 [(match_operand:SI 0 "s_register_operand" "") ; index to jump on
7137 (match_operand:SI 1 "const_int_operand" "") ; lower bound
7138 (match_operand:SI 2 "const_int_operand" "") ; total range
7139 (match_operand:SI 3 "" "") ; table label
7140 (match_operand:SI 4 "" "")] ; Out of range label
7145 if (operands[1] != const0_rtx)
7147 reg = gen_reg_rtx (SImode);
7149 emit_insn (gen_addsi3 (reg, operands[0],
7150 GEN_INT (-INTVAL (operands[1]))));
7154 if (!const_ok_for_arm (INTVAL (operands[2])))
7155 operands[2] = force_reg (SImode, operands[2]);
7157 emit_jump_insn (gen_casesi_internal (operands[0], operands[2], operands[3],
7163 ;; The USE in this pattern is needed to tell flow analysis that this is
7164 ;; a CASESI insn. It has no other purpose.
7165 (define_insn "casesi_internal"
7166 [(parallel [(set (pc)
7168 (leu (match_operand:SI 0 "s_register_operand" "r")
7169 (match_operand:SI 1 "arm_rhs_operand" "rI"))
7170 (mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
7171 (label_ref (match_operand 2 "" ""))))
7172 (label_ref (match_operand 3 "" ""))))
7173 (clobber (reg:CC CC_REGNUM))
7174 (use (label_ref (match_dup 2)))])]
7178 return \"cmp\\t%0, %1\;addls\\t%|pc, %|pc, %0, asl #2\;b\\t%l3\";
7179 return \"cmp\\t%0, %1\;ldrls\\t%|pc, [%|pc, %0, asl #2]\;b\\t%l3\";
7181 [(set_attr "conds" "clob")
7182 (set_attr "length" "12")]
7185 (define_expand "indirect_jump"
7187 (match_operand:SI 0 "s_register_operand" ""))]
7192 (define_insn "*arm_indirect_jump"
7194 (match_operand:SI 0 "s_register_operand" "r"))]
7196 "mov%?\\t%|pc, %0\\t%@ indirect register jump"
7197 [(set_attr "predicable" "yes")]
7200 ;; Although not supported by the define_expand above,
7201 ;; cse/combine may generate this form.
7202 (define_insn "*load_indirect_jump"
7204 (match_operand:SI 0 "memory_operand" "m"))]
7206 "ldr%?\\t%|pc, %0\\t%@ indirect memory jump"
7207 [(set_attr "type" "load")
7208 (set_attr "pool_range" "4096")
7209 (set_attr "neg_pool_range" "4084")
7210 (set_attr "predicable" "yes")]
7213 (define_insn "*thumb_indirect_jump"
7215 (match_operand:SI 0 "register_operand" "l*r"))]
7218 [(set_attr "conds" "clob")
7219 (set_attr "length" "2")]
7230 return \"mov%?\\t%|r0, %|r0\\t%@ nop\";
7231 return \"mov\\tr8, r8\";
7233 [(set (attr "length")
7234 (if_then_else (eq_attr "is_thumb" "yes")
7240 ;; Patterns to allow combination of arithmetic, cond code and shifts
7242 (define_insn "*arith_shiftsi"
7243 [(set (match_operand:SI 0 "s_register_operand" "=r")
7244 (match_operator:SI 1 "shiftable_operator"
7245 [(match_operator:SI 3 "shift_operator"
7246 [(match_operand:SI 4 "s_register_operand" "r")
7247 (match_operand:SI 5 "reg_or_int_operand" "rI")])
7248 (match_operand:SI 2 "s_register_operand" "r")]))]
7250 "%i1%?\\t%0, %2, %4%S3"
7251 [(set_attr "predicable" "yes")
7252 (set_attr "shift" "4")
7256 (define_insn "*arith_shiftsi_compare0"
7257 [(set (reg:CC_NOOV CC_REGNUM)
7258 (compare:CC_NOOV (match_operator:SI 1 "shiftable_operator"
7259 [(match_operator:SI 3 "shift_operator"
7260 [(match_operand:SI 4 "s_register_operand" "r")
7261 (match_operand:SI 5 "reg_or_int_operand" "rI")])
7262 (match_operand:SI 2 "s_register_operand" "r")])
7264 (set (match_operand:SI 0 "s_register_operand" "=r")
7265 (match_op_dup 1 [(match_op_dup 3 [(match_dup 4) (match_dup 5)])
7268 "%i1%?s\\t%0, %2, %4%S3"
7269 [(set_attr "conds" "set")
7270 (set_attr "shift" "4")
7274 (define_insn "*arith_shiftsi_compare0_scratch"
7275 [(set (reg:CC_NOOV CC_REGNUM)
7276 (compare:CC_NOOV (match_operator:SI 1 "shiftable_operator"
7277 [(match_operator:SI 3 "shift_operator"
7278 [(match_operand:SI 4 "s_register_operand" "r")
7279 (match_operand:SI 5 "reg_or_int_operand" "rI")])
7280 (match_operand:SI 2 "s_register_operand" "r")])
7282 (clobber (match_scratch:SI 0 "=r"))]
7284 "%i1%?s\\t%0, %2, %4%S3"
7285 [(set_attr "conds" "set")
7286 (set_attr "shift" "4")
7290 (define_insn "*sub_shiftsi"
7291 [(set (match_operand:SI 0 "s_register_operand" "=r")
7292 (minus:SI (match_operand:SI 1 "s_register_operand" "r")
7293 (match_operator:SI 2 "shift_operator"
7294 [(match_operand:SI 3 "s_register_operand" "r")
7295 (match_operand:SI 4 "reg_or_int_operand" "rM")])))]
7297 "sub%?\\t%0, %1, %3%S2"
7298 [(set_attr "predicable" "yes")
7299 (set_attr "shift" "3")
7303 (define_insn "*sub_shiftsi_compare0"
7304 [(set (reg:CC_NOOV CC_REGNUM)
7306 (minus:SI (match_operand:SI 1 "s_register_operand" "r")
7307 (match_operator:SI 2 "shift_operator"
7308 [(match_operand:SI 3 "s_register_operand" "r")
7309 (match_operand:SI 4 "reg_or_int_operand" "rM")]))
7311 (set (match_operand:SI 0 "s_register_operand" "=r")
7312 (minus:SI (match_dup 1) (match_op_dup 2 [(match_dup 3)
7315 "sub%?s\\t%0, %1, %3%S2"
7316 [(set_attr "conds" "set")
7317 (set_attr "shift" "3")
7321 (define_insn "*sub_shiftsi_compare0_scratch"
7322 [(set (reg:CC_NOOV CC_REGNUM)
7324 (minus:SI (match_operand:SI 1 "s_register_operand" "r")
7325 (match_operator:SI 2 "shift_operator"
7326 [(match_operand:SI 3 "s_register_operand" "r")
7327 (match_operand:SI 4 "reg_or_int_operand" "rM")]))
7329 (clobber (match_scratch:SI 0 "=r"))]
7331 "sub%?s\\t%0, %1, %3%S2"
7332 [(set_attr "conds" "set")
7333 (set_attr "shift" "3")
7339 (define_insn "*and_scc"
7340 [(set (match_operand:SI 0 "s_register_operand" "=r")
7341 (and:SI (match_operator:SI 1 "arm_comparison_operator"
7342 [(match_operand 3 "cc_register" "") (const_int 0)])
7343 (match_operand:SI 2 "s_register_operand" "r")))]
7345 "mov%D1\\t%0, #0\;and%d1\\t%0, %2, #1"
7346 [(set_attr "conds" "use")
7347 (set_attr "length" "8")]
7350 (define_insn "*ior_scc"
7351 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
7352 (ior:SI (match_operator:SI 2 "arm_comparison_operator"
7353 [(match_operand 3 "cc_register" "") (const_int 0)])
7354 (match_operand:SI 1 "s_register_operand" "0,?r")))]
7358 mov%D2\\t%0, %1\;orr%d2\\t%0, %1, #1"
7359 [(set_attr "conds" "use")
7360 (set_attr "length" "4,8")]
7363 (define_insn "*compare_scc"
7364 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
7365 (match_operator:SI 1 "arm_comparison_operator"
7366 [(match_operand:SI 2 "s_register_operand" "r,r")
7367 (match_operand:SI 3 "arm_add_operand" "rI,L")]))
7368 (clobber (reg:CC CC_REGNUM))]
7371 if (operands[3] == const0_rtx)
7373 if (GET_CODE (operands[1]) == LT)
7374 return \"mov\\t%0, %2, lsr #31\";
7376 if (GET_CODE (operands[1]) == GE)
7377 return \"mvn\\t%0, %2\;mov\\t%0, %0, lsr #31\";
7379 if (GET_CODE (operands[1]) == EQ)
7380 return \"rsbs\\t%0, %2, #1\;movcc\\t%0, #0\";
7383 if (GET_CODE (operands[1]) == NE)
7385 if (which_alternative == 1)
7386 return \"adds\\t%0, %2, #%n3\;movne\\t%0, #1\";
7387 return \"subs\\t%0, %2, %3\;movne\\t%0, #1\";
7389 if (which_alternative == 1)
7390 output_asm_insn (\"cmn\\t%2, #%n3\", operands);
7392 output_asm_insn (\"cmp\\t%2, %3\", operands);
7393 return \"mov%D1\\t%0, #0\;mov%d1\\t%0, #1\";
7395 [(set_attr "conds" "clob")
7396 (set_attr "length" "12")]
7399 (define_insn "*cond_move"
7400 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
7401 (if_then_else:SI (match_operator 3 "equality_operator"
7402 [(match_operator 4 "arm_comparison_operator"
7403 [(match_operand 5 "cc_register" "") (const_int 0)])
7405 (match_operand:SI 1 "arm_rhs_operand" "0,rI,?rI")
7406 (match_operand:SI 2 "arm_rhs_operand" "rI,0,rI")))]
7409 if (GET_CODE (operands[3]) == NE)
7411 if (which_alternative != 1)
7412 output_asm_insn (\"mov%D4\\t%0, %2\", operands);
7413 if (which_alternative != 0)
7414 output_asm_insn (\"mov%d4\\t%0, %1\", operands);
7417 if (which_alternative != 0)
7418 output_asm_insn (\"mov%D4\\t%0, %1\", operands);
7419 if (which_alternative != 1)
7420 output_asm_insn (\"mov%d4\\t%0, %2\", operands);
7423 [(set_attr "conds" "use")
7424 (set_attr "length" "4,4,8")]
7427 (define_insn "*cond_arith"
7428 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
7429 (match_operator:SI 5 "shiftable_operator"
7430 [(match_operator:SI 4 "arm_comparison_operator"
7431 [(match_operand:SI 2 "s_register_operand" "r,r")
7432 (match_operand:SI 3 "arm_rhs_operand" "rI,rI")])
7433 (match_operand:SI 1 "s_register_operand" "0,?r")]))
7434 (clobber (reg:CC CC_REGNUM))]
7437 if (GET_CODE (operands[4]) == LT && operands[3] == const0_rtx)
7438 return \"%i5\\t%0, %1, %2, lsr #31\";
7440 output_asm_insn (\"cmp\\t%2, %3\", operands);
7441 if (GET_CODE (operands[5]) == AND)
7442 output_asm_insn (\"mov%D4\\t%0, #0\", operands);
7443 else if (GET_CODE (operands[5]) == MINUS)
7444 output_asm_insn (\"rsb%D4\\t%0, %1, #0\", operands);
7445 else if (which_alternative != 0)
7446 output_asm_insn (\"mov%D4\\t%0, %1\", operands);
7447 return \"%i5%d4\\t%0, %1, #1\";
7449 [(set_attr "conds" "clob")
7450 (set_attr "length" "12")]
7453 (define_insn "*cond_sub"
7454 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
7455 (minus:SI (match_operand:SI 1 "s_register_operand" "0,?r")
7456 (match_operator:SI 4 "arm_comparison_operator"
7457 [(match_operand:SI 2 "s_register_operand" "r,r")
7458 (match_operand:SI 3 "arm_rhs_operand" "rI,rI")])))
7459 (clobber (reg:CC CC_REGNUM))]
7462 output_asm_insn (\"cmp\\t%2, %3\", operands);
7463 if (which_alternative != 0)
7464 output_asm_insn (\"mov%D4\\t%0, %1\", operands);
7465 return \"sub%d4\\t%0, %1, #1\";
7467 [(set_attr "conds" "clob")
7468 (set_attr "length" "8,12")]
7471 (define_insn "*cmp_ite0"
7472 [(set (match_operand 6 "dominant_cc_register" "")
7475 (match_operator 4 "arm_comparison_operator"
7476 [(match_operand:SI 0 "s_register_operand" "r,r,r,r")
7477 (match_operand:SI 1 "arm_add_operand" "rI,L,rI,L")])
7478 (match_operator:SI 5 "arm_comparison_operator"
7479 [(match_operand:SI 2 "s_register_operand" "r,r,r,r")
7480 (match_operand:SI 3 "arm_add_operand" "rI,rI,L,L")])
7486 static const char * const opcodes[4][2] =
7488 {\"cmp\\t%2, %3\;cmp%d5\\t%0, %1\",
7489 \"cmp\\t%0, %1\;cmp%d4\\t%2, %3\"},
7490 {\"cmp\\t%2, %3\;cmn%d5\\t%0, #%n1\",
7491 \"cmn\\t%0, #%n1\;cmp%d4\\t%2, %3\"},
7492 {\"cmn\\t%2, #%n3\;cmp%d5\\t%0, %1\",
7493 \"cmp\\t%0, %1\;cmn%d4\\t%2, #%n3\"},
7494 {\"cmn\\t%2, #%n3\;cmn%d5\\t%0, #%n1\",
7495 \"cmn\\t%0, #%n1\;cmn%d4\\t%2, #%n3\"}
7498 comparison_dominates_p (GET_CODE (operands[5]), GET_CODE (operands[4]));
7500 return opcodes[which_alternative][swap];
7502 [(set_attr "conds" "set")
7503 (set_attr "length" "8")]
7506 (define_insn "*cmp_ite1"
7507 [(set (match_operand 6 "dominant_cc_register" "")
7510 (match_operator 4 "arm_comparison_operator"
7511 [(match_operand:SI 0 "s_register_operand" "r,r,r,r")
7512 (match_operand:SI 1 "arm_add_operand" "rI,L,rI,L")])
7513 (match_operator:SI 5 "arm_comparison_operator"
7514 [(match_operand:SI 2 "s_register_operand" "r,r,r,r")
7515 (match_operand:SI 3 "arm_add_operand" "rI,rI,L,L")])
7521 static const char * const opcodes[4][2] =
7523 {\"cmp\\t%0, %1\;cmp%d4\\t%2, %3\",
7524 \"cmp\\t%2, %3\;cmp%D5\\t%0, %1\"},
7525 {\"cmn\\t%0, #%n1\;cmp%d4\\t%2, %3\",
7526 \"cmp\\t%2, %3\;cmn%D5\\t%0, #%n1\"},
7527 {\"cmp\\t%0, %1\;cmn%d4\\t%2, #%n3\",
7528 \"cmn\\t%2, #%n3\;cmp%D5\\t%0, %1\"},
7529 {\"cmn\\t%0, #%n1\;cmn%d4\\t%2, #%n3\",
7530 \"cmn\\t%2, #%n3\;cmn%D5\\t%0, #%n1\"}
7533 comparison_dominates_p (GET_CODE (operands[5]),
7534 reverse_condition (GET_CODE (operands[4])));
7536 return opcodes[which_alternative][swap];
7538 [(set_attr "conds" "set")
7539 (set_attr "length" "8")]
7542 (define_insn "*cmp_and"
7543 [(set (match_operand 6 "dominant_cc_register" "")
7546 (match_operator 4 "arm_comparison_operator"
7547 [(match_operand:SI 0 "s_register_operand" "r,r,r,r")
7548 (match_operand:SI 1 "arm_add_operand" "rI,L,rI,L")])
7549 (match_operator:SI 5 "arm_comparison_operator"
7550 [(match_operand:SI 2 "s_register_operand" "r,r,r,r")
7551 (match_operand:SI 3 "arm_add_operand" "rI,rI,L,L")]))
7556 static const char *const opcodes[4][2] =
7558 {\"cmp\\t%2, %3\;cmp%d5\\t%0, %1\",
7559 \"cmp\\t%0, %1\;cmp%d4\\t%2, %3\"},
7560 {\"cmp\\t%2, %3\;cmn%d5\\t%0, #%n1\",
7561 \"cmn\\t%0, #%n1\;cmp%d4\\t%2, %3\"},
7562 {\"cmn\\t%2, #%n3\;cmp%d5\\t%0, %1\",
7563 \"cmp\\t%0, %1\;cmn%d4\\t%2, #%n3\"},
7564 {\"cmn\\t%2, #%n3\;cmn%d5\\t%0, #%n1\",
7565 \"cmn\\t%0, #%n1\;cmn%d4\\t%2, #%n3\"}
7568 comparison_dominates_p (GET_CODE (operands[5]), GET_CODE (operands[4]));
7570 return opcodes[which_alternative][swap];
7572 [(set_attr "conds" "set")
7573 (set_attr "predicable" "no")
7574 (set_attr "length" "8")]
7577 (define_insn "*cmp_ior"
7578 [(set (match_operand 6 "dominant_cc_register" "")
7581 (match_operator 4 "arm_comparison_operator"
7582 [(match_operand:SI 0 "s_register_operand" "r,r,r,r")
7583 (match_operand:SI 1 "arm_add_operand" "rI,L,rI,L")])
7584 (match_operator:SI 5 "arm_comparison_operator"
7585 [(match_operand:SI 2 "s_register_operand" "r,r,r,r")
7586 (match_operand:SI 3 "arm_add_operand" "rI,rI,L,L")]))
7591 static const char *const opcodes[4][2] =
7593 {\"cmp\\t%0, %1\;cmp%D4\\t%2, %3\",
7594 \"cmp\\t%2, %3\;cmp%D5\\t%0, %1\"},
7595 {\"cmn\\t%0, #%n1\;cmp%D4\\t%2, %3\",
7596 \"cmp\\t%2, %3\;cmn%D5\\t%0, #%n1\"},
7597 {\"cmp\\t%0, %1\;cmn%D4\\t%2, #%n3\",
7598 \"cmn\\t%2, #%n3\;cmp%D5\\t%0, %1\"},
7599 {\"cmn\\t%0, #%n1\;cmn%D4\\t%2, #%n3\",
7600 \"cmn\\t%2, #%n3\;cmn%D5\\t%0, #%n1\"}
7603 comparison_dominates_p (GET_CODE (operands[5]), GET_CODE (operands[4]));
7605 return opcodes[which_alternative][swap];
7608 [(set_attr "conds" "set")
7609 (set_attr "length" "8")]
7612 (define_insn_and_split "*ior_scc_scc"
7613 [(set (match_operand:SI 0 "s_register_operand" "=r")
7614 (ior:SI (match_operator:SI 3 "arm_comparison_operator"
7615 [(match_operand:SI 1 "s_register_operand" "r")
7616 (match_operand:SI 2 "arm_add_operand" "rIL")])
7617 (match_operator:SI 6 "arm_comparison_operator"
7618 [(match_operand:SI 4 "s_register_operand" "r")
7619 (match_operand:SI 5 "arm_add_operand" "rIL")])))
7620 (clobber (reg:CC CC_REGNUM))]
7622 && (arm_select_dominance_cc_mode (operands[3], operands[6], DOM_CC_X_OR_Y)
7625 "TARGET_ARM && reload_completed"
7629 (match_op_dup 3 [(match_dup 1) (match_dup 2)])
7630 (match_op_dup 6 [(match_dup 4) (match_dup 5)]))
7632 (set (match_dup 0) (ne:SI (match_dup 7) (const_int 0)))]
7634 = gen_rtx_REG (arm_select_dominance_cc_mode (operands[3], operands[6],
7637 [(set_attr "conds" "clob")
7638 (set_attr "length" "16")])
7640 ; If the above pattern is followed by a CMP insn, then the compare is
7641 ; redundant, since we can rework the conditional instruction that follows.
7642 (define_insn_and_split "*ior_scc_scc_cmp"
7643 [(set (match_operand 0 "dominant_cc_register" "")
7644 (compare (ior:SI (match_operator:SI 3 "arm_comparison_operator"
7645 [(match_operand:SI 1 "s_register_operand" "r")
7646 (match_operand:SI 2 "arm_add_operand" "rIL")])
7647 (match_operator:SI 6 "arm_comparison_operator"
7648 [(match_operand:SI 4 "s_register_operand" "r")
7649 (match_operand:SI 5 "arm_add_operand" "rIL")]))
7651 (set (match_operand:SI 7 "s_register_operand" "=r")
7652 (ior:SI (match_op_dup 3 [(match_dup 1) (match_dup 2)])
7653 (match_op_dup 6 [(match_dup 4) (match_dup 5)])))]
7656 "TARGET_ARM && reload_completed"
7660 (match_op_dup 3 [(match_dup 1) (match_dup 2)])
7661 (match_op_dup 6 [(match_dup 4) (match_dup 5)]))
7663 (set (match_dup 7) (ne:SI (match_dup 0) (const_int 0)))]
7665 [(set_attr "conds" "set")
7666 (set_attr "length" "16")])
7668 (define_insn_and_split "*and_scc_scc"
7669 [(set (match_operand:SI 0 "s_register_operand" "=r")
7670 (and:SI (match_operator:SI 3 "arm_comparison_operator"
7671 [(match_operand:SI 1 "s_register_operand" "r")
7672 (match_operand:SI 2 "arm_add_operand" "rIL")])
7673 (match_operator:SI 6 "arm_comparison_operator"
7674 [(match_operand:SI 4 "s_register_operand" "r")
7675 (match_operand:SI 5 "arm_add_operand" "rIL")])))
7676 (clobber (reg:CC CC_REGNUM))]
7678 && (arm_select_dominance_cc_mode (operands[3], operands[6], DOM_CC_X_AND_Y)
7681 "TARGET_ARM && reload_completed
7682 && (arm_select_dominance_cc_mode (operands[3], operands[6], DOM_CC_X_AND_Y)
7687 (match_op_dup 3 [(match_dup 1) (match_dup 2)])
7688 (match_op_dup 6 [(match_dup 4) (match_dup 5)]))
7690 (set (match_dup 0) (ne:SI (match_dup 7) (const_int 0)))]
7692 = gen_rtx_REG (arm_select_dominance_cc_mode (operands[3], operands[6],
7695 [(set_attr "conds" "clob")
7696 (set_attr "length" "16")])
7698 ; If the above pattern is followed by a CMP insn, then the compare is
7699 ; redundant, since we can rework the conditional instruction that follows.
7700 (define_insn_and_split "*and_scc_scc_cmp"
7701 [(set (match_operand 0 "dominant_cc_register" "")
7702 (compare (and:SI (match_operator:SI 3 "arm_comparison_operator"
7703 [(match_operand:SI 1 "s_register_operand" "r")
7704 (match_operand:SI 2 "arm_add_operand" "rIL")])
7705 (match_operator:SI 6 "arm_comparison_operator"
7706 [(match_operand:SI 4 "s_register_operand" "r")
7707 (match_operand:SI 5 "arm_add_operand" "rIL")]))
7709 (set (match_operand:SI 7 "s_register_operand" "=r")
7710 (and:SI (match_op_dup 3 [(match_dup 1) (match_dup 2)])
7711 (match_op_dup 6 [(match_dup 4) (match_dup 5)])))]
7714 "TARGET_ARM && reload_completed"
7718 (match_op_dup 3 [(match_dup 1) (match_dup 2)])
7719 (match_op_dup 6 [(match_dup 4) (match_dup 5)]))
7721 (set (match_dup 7) (ne:SI (match_dup 0) (const_int 0)))]
7723 [(set_attr "conds" "set")
7724 (set_attr "length" "16")])
7726 ;; If there is no dominance in the comparison, then we can still save an
7727 ;; instruction in the AND case, since we can know that the second compare
7728 ;; need only zero the value if false (if true, then the value is already
7730 (define_insn_and_split "*and_scc_scc_nodom"
7731 [(set (match_operand:SI 0 "s_register_operand" "=&r,&r,&r")
7732 (and:SI (match_operator:SI 3 "arm_comparison_operator"
7733 [(match_operand:SI 1 "s_register_operand" "r,r,0")
7734 (match_operand:SI 2 "arm_add_operand" "rIL,0,rIL")])
7735 (match_operator:SI 6 "arm_comparison_operator"
7736 [(match_operand:SI 4 "s_register_operand" "r,r,r")
7737 (match_operand:SI 5 "arm_add_operand" "rIL,rIL,rIL")])))
7738 (clobber (reg:CC CC_REGNUM))]
7740 && (arm_select_dominance_cc_mode (operands[3], operands[6], DOM_CC_X_AND_Y)
7743 "TARGET_ARM && reload_completed"
7744 [(parallel [(set (match_dup 0)
7745 (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
7746 (clobber (reg:CC CC_REGNUM))])
7747 (set (match_dup 7) (match_op_dup 8 [(match_dup 4) (match_dup 5)]))
7749 (if_then_else:SI (match_op_dup 6 [(match_dup 7) (const_int 0)])
7752 "operands[7] = gen_rtx_REG (SELECT_CC_MODE (GET_CODE (operands[6]),
7753 operands[4], operands[5]),
7755 operands[8] = gen_rtx_COMPARE (GET_MODE (operands[7]), operands[4],
7757 [(set_attr "conds" "clob")
7758 (set_attr "length" "20")])
7760 (define_insn "*negscc"
7761 [(set (match_operand:SI 0 "s_register_operand" "=r")
7762 (neg:SI (match_operator 3 "arm_comparison_operator"
7763 [(match_operand:SI 1 "s_register_operand" "r")
7764 (match_operand:SI 2 "arm_rhs_operand" "rI")])))
7765 (clobber (reg:CC CC_REGNUM))]
7768 if (GET_CODE (operands[3]) == LT && operands[3] == const0_rtx)
7769 return \"mov\\t%0, %1, asr #31\";
7771 if (GET_CODE (operands[3]) == NE)
7772 return \"subs\\t%0, %1, %2\;mvnne\\t%0, #0\";
7774 if (GET_CODE (operands[3]) == GT)
7775 return \"subs\\t%0, %1, %2\;mvnne\\t%0, %0, asr #31\";
7777 output_asm_insn (\"cmp\\t%1, %2\", operands);
7778 output_asm_insn (\"mov%D3\\t%0, #0\", operands);
7779 return \"mvn%d3\\t%0, #0\";
7781 [(set_attr "conds" "clob")
7782 (set_attr "length" "12")]
7785 (define_insn "movcond"
7786 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
7788 (match_operator 5 "arm_comparison_operator"
7789 [(match_operand:SI 3 "s_register_operand" "r,r,r")
7790 (match_operand:SI 4 "arm_add_operand" "rIL,rIL,rIL")])
7791 (match_operand:SI 1 "arm_rhs_operand" "0,rI,?rI")
7792 (match_operand:SI 2 "arm_rhs_operand" "rI,0,rI")))
7793 (clobber (reg:CC CC_REGNUM))]
7796 if (GET_CODE (operands[5]) == LT
7797 && (operands[4] == const0_rtx))
7799 if (which_alternative != 1 && GET_CODE (operands[1]) == REG)
7801 if (operands[2] == const0_rtx)
7802 return \"and\\t%0, %1, %3, asr #31\";
7803 return \"ands\\t%0, %1, %3, asr #32\;movcc\\t%0, %2\";
7805 else if (which_alternative != 0 && GET_CODE (operands[2]) == REG)
7807 if (operands[1] == const0_rtx)
7808 return \"bic\\t%0, %2, %3, asr #31\";
7809 return \"bics\\t%0, %2, %3, asr #32\;movcs\\t%0, %1\";
7811 /* The only case that falls through to here is when both ops 1 & 2
7815 if (GET_CODE (operands[5]) == GE
7816 && (operands[4] == const0_rtx))
7818 if (which_alternative != 1 && GET_CODE (operands[1]) == REG)
7820 if (operands[2] == const0_rtx)
7821 return \"bic\\t%0, %1, %3, asr #31\";
7822 return \"bics\\t%0, %1, %3, asr #32\;movcs\\t%0, %2\";
7824 else if (which_alternative != 0 && GET_CODE (operands[2]) == REG)
7826 if (operands[1] == const0_rtx)
7827 return \"and\\t%0, %2, %3, asr #31\";
7828 return \"ands\\t%0, %2, %3, asr #32\;movcc\\t%0, %1\";
7830 /* The only case that falls through to here is when both ops 1 & 2
7833 if (GET_CODE (operands[4]) == CONST_INT
7834 && !const_ok_for_arm (INTVAL (operands[4])))
7835 output_asm_insn (\"cmn\\t%3, #%n4\", operands);
7837 output_asm_insn (\"cmp\\t%3, %4\", operands);
7838 if (which_alternative != 0)
7839 output_asm_insn (\"mov%d5\\t%0, %1\", operands);
7840 if (which_alternative != 1)
7841 output_asm_insn (\"mov%D5\\t%0, %2\", operands);
7844 [(set_attr "conds" "clob")
7845 (set_attr "length" "8,8,12")]
7848 (define_insn "*ifcompare_plus_move"
7849 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
7850 (if_then_else:SI (match_operator 6 "arm_comparison_operator"
7851 [(match_operand:SI 4 "s_register_operand" "r,r")
7852 (match_operand:SI 5 "arm_add_operand" "rIL,rIL")])
7854 (match_operand:SI 2 "s_register_operand" "r,r")
7855 (match_operand:SI 3 "arm_add_operand" "rIL,rIL"))
7856 (match_operand:SI 1 "arm_rhs_operand" "0,?rI")))
7857 (clobber (reg:CC CC_REGNUM))]
7860 [(set_attr "conds" "clob")
7861 (set_attr "length" "8,12")]
7864 (define_insn "*if_plus_move"
7865 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r,r")
7867 (match_operator 4 "arm_comparison_operator"
7868 [(match_operand 5 "cc_register" "") (const_int 0)])
7870 (match_operand:SI 2 "s_register_operand" "r,r,r,r")
7871 (match_operand:SI 3 "arm_add_operand" "rI,L,rI,L"))
7872 (match_operand:SI 1 "arm_rhs_operand" "0,0,?rI,?rI")))]
7876 sub%d4\\t%0, %2, #%n3
7877 add%d4\\t%0, %2, %3\;mov%D4\\t%0, %1
7878 sub%d4\\t%0, %2, #%n3\;mov%D4\\t%0, %1"
7879 [(set_attr "conds" "use")
7880 (set_attr "length" "4,4,8,8")
7881 (set_attr "type" "*,*,*,*")]
7884 (define_insn "*ifcompare_move_plus"
7885 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
7886 (if_then_else:SI (match_operator 6 "arm_comparison_operator"
7887 [(match_operand:SI 4 "s_register_operand" "r,r")
7888 (match_operand:SI 5 "arm_add_operand" "rIL,rIL")])
7889 (match_operand:SI 1 "arm_rhs_operand" "0,?rI")
7891 (match_operand:SI 2 "s_register_operand" "r,r")
7892 (match_operand:SI 3 "arm_add_operand" "rIL,rIL"))))
7893 (clobber (reg:CC CC_REGNUM))]
7896 [(set_attr "conds" "clob")
7897 (set_attr "length" "8,12")]
7900 (define_insn "*if_move_plus"
7901 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r,r")
7903 (match_operator 4 "arm_comparison_operator"
7904 [(match_operand 5 "cc_register" "") (const_int 0)])
7905 (match_operand:SI 1 "arm_rhs_operand" "0,0,?rI,?rI")
7907 (match_operand:SI 2 "s_register_operand" "r,r,r,r")
7908 (match_operand:SI 3 "arm_add_operand" "rI,L,rI,L"))))]
7912 sub%D4\\t%0, %2, #%n3
7913 add%D4\\t%0, %2, %3\;mov%d4\\t%0, %1
7914 sub%D4\\t%0, %2, #%n3\;mov%d4\\t%0, %1"
7915 [(set_attr "conds" "use")
7916 (set_attr "length" "4,4,8,8")
7917 (set_attr "type" "*,*,*,*")]
7920 (define_insn "*ifcompare_arith_arith"
7921 [(set (match_operand:SI 0 "s_register_operand" "=r")
7922 (if_then_else:SI (match_operator 9 "arm_comparison_operator"
7923 [(match_operand:SI 5 "s_register_operand" "r")
7924 (match_operand:SI 6 "arm_add_operand" "rIL")])
7925 (match_operator:SI 8 "shiftable_operator"
7926 [(match_operand:SI 1 "s_register_operand" "r")
7927 (match_operand:SI 2 "arm_rhs_operand" "rI")])
7928 (match_operator:SI 7 "shiftable_operator"
7929 [(match_operand:SI 3 "s_register_operand" "r")
7930 (match_operand:SI 4 "arm_rhs_operand" "rI")])))
7931 (clobber (reg:CC CC_REGNUM))]
7934 [(set_attr "conds" "clob")
7935 (set_attr "length" "12")]
7938 (define_insn "*if_arith_arith"
7939 [(set (match_operand:SI 0 "s_register_operand" "=r")
7940 (if_then_else:SI (match_operator 5 "arm_comparison_operator"
7941 [(match_operand 8 "cc_register" "") (const_int 0)])
7942 (match_operator:SI 6 "shiftable_operator"
7943 [(match_operand:SI 1 "s_register_operand" "r")
7944 (match_operand:SI 2 "arm_rhs_operand" "rI")])
7945 (match_operator:SI 7 "shiftable_operator"
7946 [(match_operand:SI 3 "s_register_operand" "r")
7947 (match_operand:SI 4 "arm_rhs_operand" "rI")])))]
7949 "%I6%d5\\t%0, %1, %2\;%I7%D5\\t%0, %3, %4"
7950 [(set_attr "conds" "use")
7951 (set_attr "length" "8")]
7954 (define_insn "*ifcompare_arith_move"
7955 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
7956 (if_then_else:SI (match_operator 6 "arm_comparison_operator"
7957 [(match_operand:SI 2 "s_register_operand" "r,r")
7958 (match_operand:SI 3 "arm_add_operand" "rIL,rIL")])
7959 (match_operator:SI 7 "shiftable_operator"
7960 [(match_operand:SI 4 "s_register_operand" "r,r")
7961 (match_operand:SI 5 "arm_rhs_operand" "rI,rI")])
7962 (match_operand:SI 1 "arm_rhs_operand" "0,?rI")))
7963 (clobber (reg:CC CC_REGNUM))]
7966 /* If we have an operation where (op x 0) is the identity operation and
7967 the conditional operator is LT or GE and we are comparing against zero and
7968 everything is in registers then we can do this in two instructions */
7969 if (operands[3] == const0_rtx
7970 && GET_CODE (operands[7]) != AND
7971 && GET_CODE (operands[5]) == REG
7972 && GET_CODE (operands[1]) == REG
7973 && REGNO (operands[1]) == REGNO (operands[4])
7974 && REGNO (operands[4]) != REGNO (operands[0]))
7976 if (GET_CODE (operands[6]) == LT)
7977 return \"and\\t%0, %5, %2, asr #31\;%I7\\t%0, %4, %0\";
7978 else if (GET_CODE (operands[6]) == GE)
7979 return \"bic\\t%0, %5, %2, asr #31\;%I7\\t%0, %4, %0\";
7981 if (GET_CODE (operands[3]) == CONST_INT
7982 && !const_ok_for_arm (INTVAL (operands[3])))
7983 output_asm_insn (\"cmn\\t%2, #%n3\", operands);
7985 output_asm_insn (\"cmp\\t%2, %3\", operands);
7986 output_asm_insn (\"%I7%d6\\t%0, %4, %5\", operands);
7987 if (which_alternative != 0)
7988 return \"mov%D6\\t%0, %1\";
7991 [(set_attr "conds" "clob")
7992 (set_attr "length" "8,12")]
7995 (define_insn "*if_arith_move"
7996 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
7997 (if_then_else:SI (match_operator 4 "arm_comparison_operator"
7998 [(match_operand 6 "cc_register" "") (const_int 0)])
7999 (match_operator:SI 5 "shiftable_operator"
8000 [(match_operand:SI 2 "s_register_operand" "r,r")
8001 (match_operand:SI 3 "arm_rhs_operand" "rI,rI")])
8002 (match_operand:SI 1 "arm_rhs_operand" "0,?rI")))]
8006 %I5%d4\\t%0, %2, %3\;mov%D4\\t%0, %1"
8007 [(set_attr "conds" "use")
8008 (set_attr "length" "4,8")
8009 (set_attr "type" "*,*")]
8012 (define_insn "*ifcompare_move_arith"
8013 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
8014 (if_then_else:SI (match_operator 6 "arm_comparison_operator"
8015 [(match_operand:SI 4 "s_register_operand" "r,r")
8016 (match_operand:SI 5 "arm_add_operand" "rIL,rIL")])
8017 (match_operand:SI 1 "arm_rhs_operand" "0,?rI")
8018 (match_operator:SI 7 "shiftable_operator"
8019 [(match_operand:SI 2 "s_register_operand" "r,r")
8020 (match_operand:SI 3 "arm_rhs_operand" "rI,rI")])))
8021 (clobber (reg:CC CC_REGNUM))]
8024 /* If we have an operation where (op x 0) is the identity operation and
8025 the conditional operator is LT or GE and we are comparing against zero and
8026 everything is in registers then we can do this in two instructions */
8027 if (operands[5] == const0_rtx
8028 && GET_CODE (operands[7]) != AND
8029 && GET_CODE (operands[3]) == REG
8030 && GET_CODE (operands[1]) == REG
8031 && REGNO (operands[1]) == REGNO (operands[2])
8032 && REGNO (operands[2]) != REGNO (operands[0]))
8034 if (GET_CODE (operands[6]) == GE)
8035 return \"and\\t%0, %3, %4, asr #31\;%I7\\t%0, %2, %0\";
8036 else if (GET_CODE (operands[6]) == LT)
8037 return \"bic\\t%0, %3, %4, asr #31\;%I7\\t%0, %2, %0\";
8040 if (GET_CODE (operands[5]) == CONST_INT
8041 && !const_ok_for_arm (INTVAL (operands[5])))
8042 output_asm_insn (\"cmn\\t%4, #%n5\", operands);
8044 output_asm_insn (\"cmp\\t%4, %5\", operands);
8046 if (which_alternative != 0)
8047 output_asm_insn (\"mov%d6\\t%0, %1\", operands);
8048 return \"%I7%D6\\t%0, %2, %3\";
8050 [(set_attr "conds" "clob")
8051 (set_attr "length" "8,12")]
8054 (define_insn "*if_move_arith"
8055 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
8057 (match_operator 4 "arm_comparison_operator"
8058 [(match_operand 6 "cc_register" "") (const_int 0)])
8059 (match_operand:SI 1 "arm_rhs_operand" "0,?rI")
8060 (match_operator:SI 5 "shiftable_operator"
8061 [(match_operand:SI 2 "s_register_operand" "r,r")
8062 (match_operand:SI 3 "arm_rhs_operand" "rI,rI")])))]
8066 %I5%D4\\t%0, %2, %3\;mov%d4\\t%0, %1"
8067 [(set_attr "conds" "use")
8068 (set_attr "length" "4,8")
8069 (set_attr "type" "*,*")]
8072 (define_insn "*ifcompare_move_not"
8073 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
8075 (match_operator 5 "arm_comparison_operator"
8076 [(match_operand:SI 3 "s_register_operand" "r,r")
8077 (match_operand:SI 4 "arm_add_operand" "rIL,rIL")])
8078 (match_operand:SI 1 "arm_not_operand" "0,?rIK")
8080 (match_operand:SI 2 "s_register_operand" "r,r"))))
8081 (clobber (reg:CC CC_REGNUM))]
8084 [(set_attr "conds" "clob")
8085 (set_attr "length" "8,12")]
8088 (define_insn "*if_move_not"
8089 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
8091 (match_operator 4 "arm_comparison_operator"
8092 [(match_operand 3 "cc_register" "") (const_int 0)])
8093 (match_operand:SI 1 "arm_not_operand" "0,?rI,K")
8094 (not:SI (match_operand:SI 2 "s_register_operand" "r,r,r"))))]
8098 mov%d4\\t%0, %1\;mvn%D4\\t%0, %2
8099 mvn%d4\\t%0, #%B1\;mvn%D4\\t%0, %2"
8100 [(set_attr "conds" "use")
8101 (set_attr "length" "4,8,8")]
8104 (define_insn "*ifcompare_not_move"
8105 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
8107 (match_operator 5 "arm_comparison_operator"
8108 [(match_operand:SI 3 "s_register_operand" "r,r")
8109 (match_operand:SI 4 "arm_add_operand" "rIL,rIL")])
8111 (match_operand:SI 2 "s_register_operand" "r,r"))
8112 (match_operand:SI 1 "arm_not_operand" "0,?rIK")))
8113 (clobber (reg:CC CC_REGNUM))]
8116 [(set_attr "conds" "clob")
8117 (set_attr "length" "8,12")]
8120 (define_insn "*if_not_move"
8121 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
8123 (match_operator 4 "arm_comparison_operator"
8124 [(match_operand 3 "cc_register" "") (const_int 0)])
8125 (not:SI (match_operand:SI 2 "s_register_operand" "r,r,r"))
8126 (match_operand:SI 1 "arm_not_operand" "0,?rI,K")))]
8130 mov%D4\\t%0, %1\;mvn%d4\\t%0, %2
8131 mvn%D4\\t%0, #%B1\;mvn%d4\\t%0, %2"
8132 [(set_attr "conds" "use")
8133 (set_attr "length" "4,8,8")]
8136 (define_insn "*ifcompare_shift_move"
8137 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
8139 (match_operator 6 "arm_comparison_operator"
8140 [(match_operand:SI 4 "s_register_operand" "r,r")
8141 (match_operand:SI 5 "arm_add_operand" "rIL,rIL")])
8142 (match_operator:SI 7 "shift_operator"
8143 [(match_operand:SI 2 "s_register_operand" "r,r")
8144 (match_operand:SI 3 "arm_rhs_operand" "rM,rM")])
8145 (match_operand:SI 1 "arm_not_operand" "0,?rIK")))
8146 (clobber (reg:CC CC_REGNUM))]
8149 [(set_attr "conds" "clob")
8150 (set_attr "length" "8,12")]
8153 (define_insn "*if_shift_move"
8154 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
8156 (match_operator 5 "arm_comparison_operator"
8157 [(match_operand 6 "cc_register" "") (const_int 0)])
8158 (match_operator:SI 4 "shift_operator"
8159 [(match_operand:SI 2 "s_register_operand" "r,r,r")
8160 (match_operand:SI 3 "arm_rhs_operand" "rM,rM,rM")])
8161 (match_operand:SI 1 "arm_not_operand" "0,?rI,K")))]
8165 mov%D5\\t%0, %1\;mov%d5\\t%0, %2%S4
8166 mvn%D5\\t%0, #%B1\;mov%d5\\t%0, %2%S4"
8167 [(set_attr "conds" "use")
8168 (set_attr "shift" "2")
8169 (set_attr "length" "4,8,8")]
8172 (define_insn "*ifcompare_move_shift"
8173 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
8175 (match_operator 6 "arm_comparison_operator"
8176 [(match_operand:SI 4 "s_register_operand" "r,r")
8177 (match_operand:SI 5 "arm_add_operand" "rIL,rIL")])
8178 (match_operand:SI 1 "arm_not_operand" "0,?rIK")
8179 (match_operator:SI 7 "shift_operator"
8180 [(match_operand:SI 2 "s_register_operand" "r,r")
8181 (match_operand:SI 3 "arm_rhs_operand" "rM,rM")])))
8182 (clobber (reg:CC CC_REGNUM))]
8185 [(set_attr "conds" "clob")
8186 (set_attr "length" "8,12")]
8189 (define_insn "*if_move_shift"
8190 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
8192 (match_operator 5 "arm_comparison_operator"
8193 [(match_operand 6 "cc_register" "") (const_int 0)])
8194 (match_operand:SI 1 "arm_not_operand" "0,?rI,K")
8195 (match_operator:SI 4 "shift_operator"
8196 [(match_operand:SI 2 "s_register_operand" "r,r,r")
8197 (match_operand:SI 3 "arm_rhs_operand" "rM,rM,rM")])))]
8201 mov%d5\\t%0, %1\;mov%D5\\t%0, %2%S4
8202 mvn%d5\\t%0, #%B1\;mov%D5\\t%0, %2%S4"
8203 [(set_attr "conds" "use")
8204 (set_attr "shift" "2")
8205 (set_attr "length" "4,8,8")]
8208 (define_insn "*ifcompare_shift_shift"
8209 [(set (match_operand:SI 0 "s_register_operand" "=r")
8211 (match_operator 7 "arm_comparison_operator"
8212 [(match_operand:SI 5 "s_register_operand" "r")
8213 (match_operand:SI 6 "arm_add_operand" "rIL")])
8214 (match_operator:SI 8 "shift_operator"
8215 [(match_operand:SI 1 "s_register_operand" "r")
8216 (match_operand:SI 2 "arm_rhs_operand" "rM")])
8217 (match_operator:SI 9 "shift_operator"
8218 [(match_operand:SI 3 "s_register_operand" "r")
8219 (match_operand:SI 4 "arm_rhs_operand" "rM")])))
8220 (clobber (reg:CC CC_REGNUM))]
8223 [(set_attr "conds" "clob")
8224 (set_attr "length" "12")]
8227 (define_insn "*if_shift_shift"
8228 [(set (match_operand:SI 0 "s_register_operand" "=r")
8230 (match_operator 5 "arm_comparison_operator"
8231 [(match_operand 8 "cc_register" "") (const_int 0)])
8232 (match_operator:SI 6 "shift_operator"
8233 [(match_operand:SI 1 "s_register_operand" "r")
8234 (match_operand:SI 2 "arm_rhs_operand" "rM")])
8235 (match_operator:SI 7 "shift_operator"
8236 [(match_operand:SI 3 "s_register_operand" "r")
8237 (match_operand:SI 4 "arm_rhs_operand" "rM")])))]
8239 "mov%d5\\t%0, %1%S6\;mov%D5\\t%0, %3%S7"
8240 [(set_attr "conds" "use")
8241 (set_attr "shift" "1")
8242 (set_attr "length" "8")]
8245 (define_insn "*ifcompare_not_arith"
8246 [(set (match_operand:SI 0 "s_register_operand" "=r")
8248 (match_operator 6 "arm_comparison_operator"
8249 [(match_operand:SI 4 "s_register_operand" "r")
8250 (match_operand:SI 5 "arm_add_operand" "rIL")])
8251 (not:SI (match_operand:SI 1 "s_register_operand" "r"))
8252 (match_operator:SI 7 "shiftable_operator"
8253 [(match_operand:SI 2 "s_register_operand" "r")
8254 (match_operand:SI 3 "arm_rhs_operand" "rI")])))
8255 (clobber (reg:CC CC_REGNUM))]
8258 [(set_attr "conds" "clob")
8259 (set_attr "length" "12")]
8262 (define_insn "*if_not_arith"
8263 [(set (match_operand:SI 0 "s_register_operand" "=r")
8265 (match_operator 5 "arm_comparison_operator"
8266 [(match_operand 4 "cc_register" "") (const_int 0)])
8267 (not:SI (match_operand:SI 1 "s_register_operand" "r"))
8268 (match_operator:SI 6 "shiftable_operator"
8269 [(match_operand:SI 2 "s_register_operand" "r")
8270 (match_operand:SI 3 "arm_rhs_operand" "rI")])))]
8272 "mvn%d5\\t%0, %1\;%I6%D5\\t%0, %2, %3"
8273 [(set_attr "conds" "use")
8274 (set_attr "length" "8")]
8277 (define_insn "*ifcompare_arith_not"
8278 [(set (match_operand:SI 0 "s_register_operand" "=r")
8280 (match_operator 6 "arm_comparison_operator"
8281 [(match_operand:SI 4 "s_register_operand" "r")
8282 (match_operand:SI 5 "arm_add_operand" "rIL")])
8283 (match_operator:SI 7 "shiftable_operator"
8284 [(match_operand:SI 2 "s_register_operand" "r")
8285 (match_operand:SI 3 "arm_rhs_operand" "rI")])
8286 (not:SI (match_operand:SI 1 "s_register_operand" "r"))))
8287 (clobber (reg:CC CC_REGNUM))]
8290 [(set_attr "conds" "clob")
8291 (set_attr "length" "12")]
8294 (define_insn "*if_arith_not"
8295 [(set (match_operand:SI 0 "s_register_operand" "=r")
8297 (match_operator 5 "arm_comparison_operator"
8298 [(match_operand 4 "cc_register" "") (const_int 0)])
8299 (match_operator:SI 6 "shiftable_operator"
8300 [(match_operand:SI 2 "s_register_operand" "r")
8301 (match_operand:SI 3 "arm_rhs_operand" "rI")])
8302 (not:SI (match_operand:SI 1 "s_register_operand" "r"))))]
8304 "mvn%D5\\t%0, %1\;%I6%d5\\t%0, %2, %3"
8305 [(set_attr "conds" "use")
8306 (set_attr "length" "8")]
8309 (define_insn "*ifcompare_neg_move"
8310 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
8312 (match_operator 5 "arm_comparison_operator"
8313 [(match_operand:SI 3 "s_register_operand" "r,r")
8314 (match_operand:SI 4 "arm_add_operand" "rIL,rIL")])
8315 (neg:SI (match_operand:SI 2 "s_register_operand" "r,r"))
8316 (match_operand:SI 1 "arm_not_operand" "0,?rIK")))
8317 (clobber (reg:CC CC_REGNUM))]
8320 [(set_attr "conds" "clob")
8321 (set_attr "length" "8,12")]
8324 (define_insn "*if_neg_move"
8325 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
8327 (match_operator 4 "arm_comparison_operator"
8328 [(match_operand 3 "cc_register" "") (const_int 0)])
8329 (neg:SI (match_operand:SI 2 "s_register_operand" "r,r,r"))
8330 (match_operand:SI 1 "arm_not_operand" "0,?rI,K")))]
8334 mov%D4\\t%0, %1\;rsb%d4\\t%0, %2, #0
8335 mvn%D4\\t%0, #%B1\;rsb%d4\\t%0, %2, #0"
8336 [(set_attr "conds" "use")
8337 (set_attr "length" "4,8,8")]
8340 (define_insn "*ifcompare_move_neg"
8341 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
8343 (match_operator 5 "arm_comparison_operator"
8344 [(match_operand:SI 3 "s_register_operand" "r,r")
8345 (match_operand:SI 4 "arm_add_operand" "rIL,rIL")])
8346 (match_operand:SI 1 "arm_not_operand" "0,?rIK")
8347 (neg:SI (match_operand:SI 2 "s_register_operand" "r,r"))))
8348 (clobber (reg:CC CC_REGNUM))]
8351 [(set_attr "conds" "clob")
8352 (set_attr "length" "8,12")]
8355 (define_insn "*if_move_neg"
8356 [(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
8358 (match_operator 4 "arm_comparison_operator"
8359 [(match_operand 3 "cc_register" "") (const_int 0)])
8360 (match_operand:SI 1 "arm_not_operand" "0,?rI,K")
8361 (neg:SI (match_operand:SI 2 "s_register_operand" "r,r,r"))))]
8365 mov%d4\\t%0, %1\;rsb%D4\\t%0, %2, #0
8366 mvn%d4\\t%0, #%B1\;rsb%D4\\t%0, %2, #0"
8367 [(set_attr "conds" "use")
8368 (set_attr "length" "4,8,8")]
8371 (define_insn "*arith_adjacentmem"
8372 [(set (match_operand:SI 0 "s_register_operand" "=r")
8373 (match_operator:SI 1 "shiftable_operator"
8374 [(match_operand:SI 2 "memory_operand" "m")
8375 (match_operand:SI 3 "memory_operand" "m")]))
8376 (clobber (match_scratch:SI 4 "=r"))]
8377 "TARGET_ARM && adjacent_mem_locations (operands[2], operands[3])"
8382 int val1 = 0, val2 = 0;
8384 if (REGNO (operands[0]) > REGNO (operands[4]))
8386 ldm[1] = operands[4];
8387 ldm[2] = operands[0];
8391 ldm[1] = operands[0];
8392 ldm[2] = operands[4];
8394 if (GET_CODE (XEXP (operands[2], 0)) != REG)
8395 val1 = INTVAL (XEXP (XEXP (operands[2], 0), 1));
8396 if (GET_CODE (XEXP (operands[3], 0)) != REG)
8397 val2 = INTVAL (XEXP (XEXP (operands[3], 0), 1));
8398 arith[0] = operands[0];
8399 arith[3] = operands[1];
8413 ldm[0] = ops[0] = operands[4];
8414 ops[1] = XEXP (XEXP (operands[2], 0), 0);
8415 ops[2] = XEXP (XEXP (operands[2], 0), 1);
8416 output_add_immediate (ops);
8418 output_asm_insn (\"ldm%?ia\\t%0, {%1, %2}\", ldm);
8420 output_asm_insn (\"ldm%?da\\t%0, {%1, %2}\", ldm);
8424 ldm[0] = XEXP (operands[3], 0);
8426 output_asm_insn (\"ldm%?da\\t%0, {%1, %2}\", ldm);
8428 output_asm_insn (\"ldm%?ia\\t%0, {%1, %2}\", ldm);
8432 ldm[0] = XEXP (operands[2], 0);
8434 output_asm_insn (\"ldm%?ia\\t%0, {%1, %2}\", ldm);
8436 output_asm_insn (\"ldm%?da\\t%0, {%1, %2}\", ldm);
8438 output_asm_insn (\"%I3%?\\t%0, %1, %2\", arith);
8441 [(set_attr "length" "12")
8442 (set_attr "predicable" "yes")
8443 (set_attr "type" "load")]
8446 ;; the arm can support extended pre-inc instructions
8448 ;; In all these cases, we use operands 0 and 1 for the register being
8449 ;; incremented because those are the operands that local-alloc will
8450 ;; tie and these are the pair most likely to be tieable (and the ones
8451 ;; that will benefit the most).
8453 ;; We reject the frame pointer if it occurs anywhere in these patterns since
8454 ;; elimination will cause too many headaches.
8456 (define_insn "*strqi_preinc"
8457 [(set (mem:QI (plus:SI (match_operand:SI 1 "s_register_operand" "%0")
8458 (match_operand:SI 2 "index_operand" "rJ")))
8459 (match_operand:QI 3 "s_register_operand" "r"))
8460 (set (match_operand:SI 0 "s_register_operand" "=r")
8461 (plus:SI (match_dup 1) (match_dup 2)))]
8463 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8464 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8465 && (GET_CODE (operands[2]) != REG
8466 || REGNO (operands[2]) != FRAME_POINTER_REGNUM)"
8467 "str%?b\\t%3, [%0, %2]!"
8468 [(set_attr "type" "store1")
8469 (set_attr "predicable" "yes")]
8472 (define_insn "*strqi_predec"
8473 [(set (mem:QI (minus:SI (match_operand:SI 1 "s_register_operand" "0")
8474 (match_operand:SI 2 "s_register_operand" "r")))
8475 (match_operand:QI 3 "s_register_operand" "r"))
8476 (set (match_operand:SI 0 "s_register_operand" "=r")
8477 (minus:SI (match_dup 1) (match_dup 2)))]
8479 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8480 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8481 && (GET_CODE (operands[2]) != REG
8482 || REGNO (operands[2]) != FRAME_POINTER_REGNUM)"
8483 "str%?b\\t%3, [%0, -%2]!"
8484 [(set_attr "type" "store1")
8485 (set_attr "predicable" "yes")]
8488 (define_insn "*loadqi_preinc"
8489 [(set (match_operand:QI 3 "s_register_operand" "=r")
8490 (mem:QI (plus:SI (match_operand:SI 1 "s_register_operand" "%0")
8491 (match_operand:SI 2 "index_operand" "rJ"))))
8492 (set (match_operand:SI 0 "s_register_operand" "=r")
8493 (plus:SI (match_dup 1) (match_dup 2)))]
8495 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8496 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8497 && (GET_CODE (operands[2]) != REG
8498 || REGNO (operands[2]) != FRAME_POINTER_REGNUM)"
8499 "ldr%?b\\t%3, [%0, %2]!"
8500 [(set_attr "type" "load")
8501 (set_attr "predicable" "yes")]
8504 (define_insn "*loadqi_predec"
8505 [(set (match_operand:QI 3 "s_register_operand" "=r")
8506 (mem:QI (minus:SI (match_operand:SI 1 "s_register_operand" "0")
8507 (match_operand:SI 2 "s_register_operand" "r"))))
8508 (set (match_operand:SI 0 "s_register_operand" "=r")
8509 (minus:SI (match_dup 1) (match_dup 2)))]
8511 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8512 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8513 && (GET_CODE (operands[2]) != REG
8514 || REGNO (operands[2]) != FRAME_POINTER_REGNUM)"
8515 "ldr%?b\\t%3, [%0, -%2]!"
8516 [(set_attr "type" "load")
8517 (set_attr "predicable" "yes")]
8520 (define_insn "*loadqisi_preinc"
8521 [(set (match_operand:SI 3 "s_register_operand" "=r")
8523 (mem:QI (plus:SI (match_operand:SI 1 "s_register_operand" "%0")
8524 (match_operand:SI 2 "index_operand" "rJ")))))
8525 (set (match_operand:SI 0 "s_register_operand" "=r")
8526 (plus:SI (match_dup 1) (match_dup 2)))]
8528 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8529 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8530 && (GET_CODE (operands[2]) != REG
8531 || REGNO (operands[2]) != FRAME_POINTER_REGNUM)"
8532 "ldr%?b\\t%3, [%0, %2]!\\t%@ z_extendqisi"
8533 [(set_attr "type" "load")
8534 (set_attr "predicable" "yes")]
8537 (define_insn "*loadqisi_predec"
8538 [(set (match_operand:SI 3 "s_register_operand" "=r")
8540 (mem:QI (minus:SI (match_operand:SI 1 "s_register_operand" "0")
8541 (match_operand:SI 2 "s_register_operand" "r")))))
8542 (set (match_operand:SI 0 "s_register_operand" "=r")
8543 (minus:SI (match_dup 1) (match_dup 2)))]
8545 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8546 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8547 && (GET_CODE (operands[2]) != REG
8548 || REGNO (operands[2]) != FRAME_POINTER_REGNUM)"
8549 "ldr%?b\\t%3, [%0, -%2]!\\t%@ z_extendqisi"
8550 [(set_attr "type" "load")
8551 (set_attr "predicable" "yes")]
8554 (define_insn "*strsi_preinc"
8555 [(set (mem:SI (plus:SI (match_operand:SI 1 "s_register_operand" "%0")
8556 (match_operand:SI 2 "index_operand" "rJ")))
8557 (match_operand:SI 3 "s_register_operand" "r"))
8558 (set (match_operand:SI 0 "s_register_operand" "=r")
8559 (plus:SI (match_dup 1) (match_dup 2)))]
8561 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8562 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8563 && (GET_CODE (operands[2]) != REG
8564 || REGNO (operands[2]) != FRAME_POINTER_REGNUM)"
8565 "str%?\\t%3, [%0, %2]!"
8566 [(set_attr "type" "store1")
8567 (set_attr "predicable" "yes")]
8570 (define_insn "*strsi_predec"
8571 [(set (mem:SI (minus:SI (match_operand:SI 1 "s_register_operand" "0")
8572 (match_operand:SI 2 "s_register_operand" "r")))
8573 (match_operand:SI 3 "s_register_operand" "r"))
8574 (set (match_operand:SI 0 "s_register_operand" "=r")
8575 (minus:SI (match_dup 1) (match_dup 2)))]
8577 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8578 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8579 && (GET_CODE (operands[2]) != REG
8580 || REGNO (operands[2]) != FRAME_POINTER_REGNUM)"
8581 "str%?\\t%3, [%0, -%2]!"
8582 [(set_attr "type" "store1")
8583 (set_attr "predicable" "yes")]
8586 (define_insn "*loadsi_preinc"
8587 [(set (match_operand:SI 3 "s_register_operand" "=r")
8588 (mem:SI (plus:SI (match_operand:SI 1 "s_register_operand" "%0")
8589 (match_operand:SI 2 "index_operand" "rJ"))))
8590 (set (match_operand:SI 0 "s_register_operand" "=r")
8591 (plus:SI (match_dup 1) (match_dup 2)))]
8593 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8594 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8595 && (GET_CODE (operands[2]) != REG
8596 || REGNO (operands[2]) != FRAME_POINTER_REGNUM)"
8597 "ldr%?\\t%3, [%0, %2]!"
8598 [(set_attr "type" "load")
8599 (set_attr "predicable" "yes")]
8602 (define_insn "*loadsi_predec"
8603 [(set (match_operand:SI 3 "s_register_operand" "=r")
8604 (mem:SI (minus:SI (match_operand:SI 1 "s_register_operand" "0")
8605 (match_operand:SI 2 "s_register_operand" "r"))))
8606 (set (match_operand:SI 0 "s_register_operand" "=r")
8607 (minus:SI (match_dup 1) (match_dup 2)))]
8609 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8610 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8611 && (GET_CODE (operands[2]) != REG
8612 || REGNO (operands[2]) != FRAME_POINTER_REGNUM)"
8613 "ldr%?\\t%3, [%0, -%2]!"
8614 [(set_attr "type" "load")
8615 (set_attr "predicable" "yes")]
8618 (define_insn "*loadhi_preinc"
8619 [(set (match_operand:HI 3 "s_register_operand" "=r")
8620 (mem:HI (plus:SI (match_operand:SI 1 "s_register_operand" "%0")
8621 (match_operand:SI 2 "index_operand" "rJ"))))
8622 (set (match_operand:SI 0 "s_register_operand" "=r")
8623 (plus:SI (match_dup 1) (match_dup 2)))]
8625 && !BYTES_BIG_ENDIAN
8626 && !TARGET_MMU_TRAPS
8628 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8629 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8630 && (GET_CODE (operands[2]) != REG
8631 || REGNO (operands[2]) != FRAME_POINTER_REGNUM)"
8632 "ldr%?\\t%3, [%0, %2]!\\t%@ loadhi"
8633 [(set_attr "type" "load")
8634 (set_attr "predicable" "yes")]
8637 (define_insn "*loadhi_predec"
8638 [(set (match_operand:HI 3 "s_register_operand" "=r")
8639 (mem:HI (minus:SI (match_operand:SI 1 "s_register_operand" "0")
8640 (match_operand:SI 2 "s_register_operand" "r"))))
8641 (set (match_operand:SI 0 "s_register_operand" "=r")
8642 (minus:SI (match_dup 1) (match_dup 2)))]
8644 && !BYTES_BIG_ENDIAN
8645 && !TARGET_MMU_TRAPS
8647 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8648 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8649 && (GET_CODE (operands[2]) != REG
8650 || REGNO (operands[2]) != FRAME_POINTER_REGNUM)"
8651 "ldr%?\\t%3, [%0, -%2]!\\t%@ loadhi"
8652 [(set_attr "type" "load")
8653 (set_attr "predicable" "yes")]
8656 (define_insn "*strqi_shiftpreinc"
8657 [(set (mem:QI (plus:SI (match_operator:SI 2 "shift_operator"
8658 [(match_operand:SI 3 "s_register_operand" "r")
8659 (match_operand:SI 4 "const_shift_operand" "n")])
8660 (match_operand:SI 1 "s_register_operand" "0")))
8661 (match_operand:QI 5 "s_register_operand" "r"))
8662 (set (match_operand:SI 0 "s_register_operand" "=r")
8663 (plus:SI (match_op_dup 2 [(match_dup 3) (match_dup 4)])
8666 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8667 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8668 && REGNO (operands[3]) != FRAME_POINTER_REGNUM"
8669 "str%?b\\t%5, [%0, %3%S2]!"
8670 [(set_attr "type" "store1")
8671 (set_attr "predicable" "yes")]
8674 (define_insn "*strqi_shiftpredec"
8675 [(set (mem:QI (minus:SI (match_operand:SI 1 "s_register_operand" "0")
8676 (match_operator:SI 2 "shift_operator"
8677 [(match_operand:SI 3 "s_register_operand" "r")
8678 (match_operand:SI 4 "const_shift_operand" "n")])))
8679 (match_operand:QI 5 "s_register_operand" "r"))
8680 (set (match_operand:SI 0 "s_register_operand" "=r")
8681 (minus:SI (match_dup 1) (match_op_dup 2 [(match_dup 3)
8684 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8685 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8686 && REGNO (operands[3]) != FRAME_POINTER_REGNUM"
8687 "str%?b\\t%5, [%0, -%3%S2]!"
8688 [(set_attr "type" "store1")
8689 (set_attr "predicable" "yes")]
8692 (define_insn "*loadqi_shiftpreinc"
8693 [(set (match_operand:QI 5 "s_register_operand" "=r")
8694 (mem:QI (plus:SI (match_operator:SI 2 "shift_operator"
8695 [(match_operand:SI 3 "s_register_operand" "r")
8696 (match_operand:SI 4 "const_shift_operand" "n")])
8697 (match_operand:SI 1 "s_register_operand" "0"))))
8698 (set (match_operand:SI 0 "s_register_operand" "=r")
8699 (plus:SI (match_op_dup 2 [(match_dup 3) (match_dup 4)])
8702 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8703 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8704 && REGNO (operands[3]) != FRAME_POINTER_REGNUM"
8705 "ldr%?b\\t%5, [%0, %3%S2]!"
8706 [(set_attr "type" "load")
8707 (set_attr "predicable" "yes")]
8710 (define_insn "*loadqi_shiftpredec"
8711 [(set (match_operand:QI 5 "s_register_operand" "=r")
8712 (mem:QI (minus:SI (match_operand:SI 1 "s_register_operand" "0")
8713 (match_operator:SI 2 "shift_operator"
8714 [(match_operand:SI 3 "s_register_operand" "r")
8715 (match_operand:SI 4 "const_shift_operand" "n")]))))
8716 (set (match_operand:SI 0 "s_register_operand" "=r")
8717 (minus:SI (match_dup 1) (match_op_dup 2 [(match_dup 3)
8720 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8721 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8722 && REGNO (operands[3]) != FRAME_POINTER_REGNUM"
8723 "ldr%?b\\t%5, [%0, -%3%S2]!"
8724 [(set_attr "type" "load")
8725 (set_attr "predicable" "yes")]
8728 (define_insn "*strsi_shiftpreinc"
8729 [(set (mem:SI (plus:SI (match_operator:SI 2 "shift_operator"
8730 [(match_operand:SI 3 "s_register_operand" "r")
8731 (match_operand:SI 4 "const_shift_operand" "n")])
8732 (match_operand:SI 1 "s_register_operand" "0")))
8733 (match_operand:SI 5 "s_register_operand" "r"))
8734 (set (match_operand:SI 0 "s_register_operand" "=r")
8735 (plus:SI (match_op_dup 2 [(match_dup 3) (match_dup 4)])
8738 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8739 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8740 && REGNO (operands[3]) != FRAME_POINTER_REGNUM"
8741 "str%?\\t%5, [%0, %3%S2]!"
8742 [(set_attr "type" "store1")
8743 (set_attr "predicable" "yes")]
8746 (define_insn "*strsi_shiftpredec"
8747 [(set (mem:SI (minus:SI (match_operand:SI 1 "s_register_operand" "0")
8748 (match_operator:SI 2 "shift_operator"
8749 [(match_operand:SI 3 "s_register_operand" "r")
8750 (match_operand:SI 4 "const_shift_operand" "n")])))
8751 (match_operand:SI 5 "s_register_operand" "r"))
8752 (set (match_operand:SI 0 "s_register_operand" "=r")
8753 (minus:SI (match_dup 1) (match_op_dup 2 [(match_dup 3)
8756 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8757 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8758 && REGNO (operands[3]) != FRAME_POINTER_REGNUM"
8759 "str%?\\t%5, [%0, -%3%S2]!"
8760 [(set_attr "type" "store1")
8761 (set_attr "predicable" "yes")]
8764 (define_insn "*loadsi_shiftpreinc"
8765 [(set (match_operand:SI 5 "s_register_operand" "=r")
8766 (mem:SI (plus:SI (match_operator:SI 2 "shift_operator"
8767 [(match_operand:SI 3 "s_register_operand" "r")
8768 (match_operand:SI 4 "const_shift_operand" "n")])
8769 (match_operand:SI 1 "s_register_operand" "0"))))
8770 (set (match_operand:SI 0 "s_register_operand" "=r")
8771 (plus:SI (match_op_dup 2 [(match_dup 3) (match_dup 4)])
8774 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8775 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8776 && REGNO (operands[3]) != FRAME_POINTER_REGNUM"
8777 "ldr%?\\t%5, [%0, %3%S2]!"
8778 [(set_attr "type" "load")
8779 (set_attr "predicable" "yes")]
8782 (define_insn "*loadsi_shiftpredec"
8783 [(set (match_operand:SI 5 "s_register_operand" "=r")
8784 (mem:SI (minus:SI (match_operand:SI 1 "s_register_operand" "0")
8785 (match_operator:SI 2 "shift_operator"
8786 [(match_operand:SI 3 "s_register_operand" "r")
8787 (match_operand:SI 4 "const_shift_operand" "n")]))))
8788 (set (match_operand:SI 0 "s_register_operand" "=r")
8789 (minus:SI (match_dup 1) (match_op_dup 2 [(match_dup 3)
8792 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8793 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8794 && REGNO (operands[3]) != FRAME_POINTER_REGNUM"
8795 "ldr%?\\t%5, [%0, -%3%S2]!"
8796 [(set_attr "type" "load")
8797 (set_attr "predicable" "yes")])
8799 (define_insn "*loadhi_shiftpreinc"
8800 [(set (match_operand:HI 5 "s_register_operand" "=r")
8801 (mem:HI (plus:SI (match_operator:SI 2 "shift_operator"
8802 [(match_operand:SI 3 "s_register_operand" "r")
8803 (match_operand:SI 4 "const_shift_operand" "n")])
8804 (match_operand:SI 1 "s_register_operand" "0"))))
8805 (set (match_operand:SI 0 "s_register_operand" "=r")
8806 (plus:SI (match_op_dup 2 [(match_dup 3) (match_dup 4)])
8809 && !BYTES_BIG_ENDIAN
8810 && !TARGET_MMU_TRAPS
8812 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8813 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8814 && REGNO (operands[3]) != FRAME_POINTER_REGNUM"
8815 "ldr%?\\t%5, [%0, %3%S2]!\\t%@ loadhi"
8816 [(set_attr "type" "load")
8817 (set_attr "predicable" "yes")]
8820 (define_insn "*loadhi_shiftpredec"
8821 [(set (match_operand:HI 5 "s_register_operand" "=r")
8822 (mem:HI (minus:SI (match_operand:SI 1 "s_register_operand" "0")
8823 (match_operator:SI 2 "shift_operator"
8824 [(match_operand:SI 3 "s_register_operand" "r")
8825 (match_operand:SI 4 "const_shift_operand" "n")]))))
8826 (set (match_operand:SI 0 "s_register_operand" "=r")
8827 (minus:SI (match_dup 1) (match_op_dup 2 [(match_dup 3)
8830 && !BYTES_BIG_ENDIAN
8831 && !TARGET_MMU_TRAPS
8833 && REGNO (operands[0]) != FRAME_POINTER_REGNUM
8834 && REGNO (operands[1]) != FRAME_POINTER_REGNUM
8835 && REGNO (operands[3]) != FRAME_POINTER_REGNUM"
8836 "ldr%?\\t%5, [%0, -%3%S2]!\\t%@ loadhi"
8837 [(set_attr "type" "load")
8838 (set_attr "predicable" "yes")]
8841 ; It can also support extended post-inc expressions, but combine doesn't
8843 ; It doesn't seem worth adding peepholes for anything but the most common
8844 ; cases since, unlike combine, the increment must immediately follow the load
8845 ; for this pattern to match.
8846 ; We must watch to see that the source/destination register isn't also the
8847 ; same as the base address register, and that if the index is a register,
8848 ; that it is not the same as the base address register. In such cases the
8849 ; instruction that we would generate would have UNPREDICTABLE behavior so
8853 [(set (mem:QI (match_operand:SI 0 "s_register_operand" "+r"))
8854 (match_operand:QI 2 "s_register_operand" "r"))
8856 (plus:SI (match_dup 0) (match_operand:SI 1 "index_operand" "rJ")))]
8858 && (REGNO (operands[2]) != REGNO (operands[0]))
8859 && (GET_CODE (operands[1]) != REG
8860 || (REGNO (operands[1]) != REGNO (operands[0])))"
8861 "str%?b\\t%2, [%0], %1"
8865 [(set (match_operand:QI 0 "s_register_operand" "=r")
8866 (mem:QI (match_operand:SI 1 "s_register_operand" "+r")))
8868 (plus:SI (match_dup 1) (match_operand:SI 2 "index_operand" "rJ")))]
8870 && REGNO (operands[0]) != REGNO(operands[1])
8871 && (GET_CODE (operands[2]) != REG
8872 || REGNO(operands[0]) != REGNO (operands[2]))"
8873 "ldr%?b\\t%0, [%1], %2"
8877 [(set (mem:SI (match_operand:SI 0 "s_register_operand" "+r"))
8878 (match_operand:SI 2 "s_register_operand" "r"))
8880 (plus:SI (match_dup 0) (match_operand:SI 1 "index_operand" "rJ")))]
8882 && (REGNO (operands[2]) != REGNO (operands[0]))
8883 && (GET_CODE (operands[1]) != REG
8884 || (REGNO (operands[1]) != REGNO (operands[0])))"
8885 "str%?\\t%2, [%0], %1"
8889 [(set (match_operand:HI 0 "s_register_operand" "=r")
8890 (mem:HI (match_operand:SI 1 "s_register_operand" "+r")))
8892 (plus:SI (match_dup 1) (match_operand:SI 2 "index_operand" "rJ")))]
8894 && !BYTES_BIG_ENDIAN
8895 && !TARGET_MMU_TRAPS
8897 && REGNO (operands[0]) != REGNO(operands[1])
8898 && (GET_CODE (operands[2]) != REG
8899 || REGNO(operands[0]) != REGNO (operands[2]))"
8900 "ldr%?\\t%0, [%1], %2\\t%@ loadhi"
8904 [(set (match_operand:SI 0 "s_register_operand" "=r")
8905 (mem:SI (match_operand:SI 1 "s_register_operand" "+r")))
8907 (plus:SI (match_dup 1) (match_operand:SI 2 "index_operand" "rJ")))]
8909 && REGNO (operands[0]) != REGNO(operands[1])
8910 && (GET_CODE (operands[2]) != REG
8911 || REGNO(operands[0]) != REGNO (operands[2]))"
8912 "ldr%?\\t%0, [%1], %2"
8916 [(set (mem:QI (plus:SI (match_operand:SI 0 "s_register_operand" "+r")
8917 (match_operand:SI 1 "index_operand" "rJ")))
8918 (match_operand:QI 2 "s_register_operand" "r"))
8919 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))]
8921 && (REGNO (operands[2]) != REGNO (operands[0]))
8922 && (GET_CODE (operands[1]) != REG
8923 || (REGNO (operands[1]) != REGNO (operands[0])))"
8924 "str%?b\\t%2, [%0, %1]!"
8928 [(set (mem:QI (plus:SI (match_operator:SI 4 "shift_operator"
8929 [(match_operand:SI 0 "s_register_operand" "r")
8930 (match_operand:SI 1 "const_int_operand" "n")])
8931 (match_operand:SI 2 "s_register_operand" "+r")))
8932 (match_operand:QI 3 "s_register_operand" "r"))
8933 (set (match_dup 2) (plus:SI (match_op_dup 4 [(match_dup 0) (match_dup 1)])
8936 && (REGNO (operands[3]) != REGNO (operands[2]))
8937 && (REGNO (operands[0]) != REGNO (operands[2]))"
8938 "str%?b\\t%3, [%2, %0%S4]!"
8941 ; This pattern is never tried by combine, so do it as a peephole
8944 [(set (match_operand:SI 0 "s_register_operand" "")
8945 (match_operand:SI 1 "s_register_operand" ""))
8946 (set (reg:CC CC_REGNUM)
8947 (compare:CC (match_dup 1) (const_int 0)))]
8950 || (!cirrus_fp_register (operands[0], SImode)
8951 && !cirrus_fp_register (operands[1], SImode)))
8953 [(parallel [(set (reg:CC CC_REGNUM) (compare:CC (match_dup 1) (const_int 0)))
8954 (set (match_dup 0) (match_dup 1))])]
8958 ; Peepholes to spot possible load- and store-multiples, if the ordering is
8959 ; reversed, check that the memory references aren't volatile.
8962 [(set (match_operand:SI 0 "s_register_operand" "=r")
8963 (match_operand:SI 4 "memory_operand" "m"))
8964 (set (match_operand:SI 1 "s_register_operand" "=r")
8965 (match_operand:SI 5 "memory_operand" "m"))
8966 (set (match_operand:SI 2 "s_register_operand" "=r")
8967 (match_operand:SI 6 "memory_operand" "m"))
8968 (set (match_operand:SI 3 "s_register_operand" "=r")
8969 (match_operand:SI 7 "memory_operand" "m"))]
8970 "TARGET_ARM && load_multiple_sequence (operands, 4, NULL, NULL, NULL)"
8972 return emit_ldm_seq (operands, 4);
8977 [(set (match_operand:SI 0 "s_register_operand" "=r")
8978 (match_operand:SI 3 "memory_operand" "m"))
8979 (set (match_operand:SI 1 "s_register_operand" "=r")
8980 (match_operand:SI 4 "memory_operand" "m"))
8981 (set (match_operand:SI 2 "s_register_operand" "=r")
8982 (match_operand:SI 5 "memory_operand" "m"))]
8983 "TARGET_ARM && load_multiple_sequence (operands, 3, NULL, NULL, NULL)"
8985 return emit_ldm_seq (operands, 3);
8990 [(set (match_operand:SI 0 "s_register_operand" "=r")
8991 (match_operand:SI 2 "memory_operand" "m"))
8992 (set (match_operand:SI 1 "s_register_operand" "=r")
8993 (match_operand:SI 3 "memory_operand" "m"))]
8994 "TARGET_ARM && load_multiple_sequence (operands, 2, NULL, NULL, NULL)"
8996 return emit_ldm_seq (operands, 2);
9001 [(set (match_operand:SI 4 "memory_operand" "=m")
9002 (match_operand:SI 0 "s_register_operand" "r"))
9003 (set (match_operand:SI 5 "memory_operand" "=m")
9004 (match_operand:SI 1 "s_register_operand" "r"))
9005 (set (match_operand:SI 6 "memory_operand" "=m")
9006 (match_operand:SI 2 "s_register_operand" "r"))
9007 (set (match_operand:SI 7 "memory_operand" "=m")
9008 (match_operand:SI 3 "s_register_operand" "r"))]
9009 "TARGET_ARM && store_multiple_sequence (operands, 4, NULL, NULL, NULL)"
9011 return emit_stm_seq (operands, 4);
9016 [(set (match_operand:SI 3 "memory_operand" "=m")
9017 (match_operand:SI 0 "s_register_operand" "r"))
9018 (set (match_operand:SI 4 "memory_operand" "=m")
9019 (match_operand:SI 1 "s_register_operand" "r"))
9020 (set (match_operand:SI 5 "memory_operand" "=m")
9021 (match_operand:SI 2 "s_register_operand" "r"))]
9022 "TARGET_ARM && store_multiple_sequence (operands, 3, NULL, NULL, NULL)"
9024 return emit_stm_seq (operands, 3);
9029 [(set (match_operand:SI 2 "memory_operand" "=m")
9030 (match_operand:SI 0 "s_register_operand" "r"))
9031 (set (match_operand:SI 3 "memory_operand" "=m")
9032 (match_operand:SI 1 "s_register_operand" "r"))]
9033 "TARGET_ARM && store_multiple_sequence (operands, 2, NULL, NULL, NULL)"
9035 return emit_stm_seq (operands, 2);
9040 [(set (match_operand:SI 0 "s_register_operand" "")
9041 (and:SI (ge:SI (match_operand:SI 1 "s_register_operand" "")
9043 (neg:SI (match_operator:SI 2 "arm_comparison_operator"
9044 [(match_operand:SI 3 "s_register_operand" "")
9045 (match_operand:SI 4 "arm_rhs_operand" "")]))))
9046 (clobber (match_operand:SI 5 "s_register_operand" ""))]
9048 [(set (match_dup 5) (not:SI (ashiftrt:SI (match_dup 1) (const_int 31))))
9049 (set (match_dup 0) (and:SI (match_op_dup 2 [(match_dup 3) (match_dup 4)])
9054 ;; This split can be used because CC_Z mode implies that the following
9055 ;; branch will be an equality, or an unsigned inequality, so the sign
9056 ;; extension is not needed.
9059 [(set (reg:CC_Z CC_REGNUM)
9061 (ashift:SI (subreg:SI (match_operand:QI 0 "memory_operand" "") 0)
9063 (match_operand 1 "const_int_operand" "")))
9064 (clobber (match_scratch:SI 2 ""))]
9066 && (((unsigned HOST_WIDE_INT) INTVAL (operands[1]))
9067 == (((unsigned HOST_WIDE_INT) INTVAL (operands[1])) >> 24) << 24)"
9068 [(set (match_dup 2) (zero_extend:SI (match_dup 0)))
9069 (set (reg:CC CC_REGNUM) (compare:CC (match_dup 2) (match_dup 1)))]
9071 operands[1] = GEN_INT (((unsigned long) INTVAL (operands[1])) >> 24);
9075 (define_expand "prologue"
9076 [(clobber (const_int 0))]
9079 arm_expand_prologue ();
9081 thumb_expand_prologue ();
9086 (define_expand "epilogue"
9087 [(unspec_volatile [(return)] VUNSPEC_EPILOGUE)]
9091 thumb_expand_epilogue ();
9092 else if (USE_RETURN_INSN (FALSE))
9094 emit_jump_insn (gen_return ());
9097 emit_jump_insn (gen_rtx_UNSPEC_VOLATILE (VOIDmode,
9099 gen_rtx_RETURN (VOIDmode)),
9105 ;; Note - although unspec_volatile's USE all hard registers,
9106 ;; USEs are ignored after relaod has completed. Thus we need
9107 ;; to add an unspec of the link register to ensure that flow
9108 ;; does not think that it is unused by the sibcall branch that
9109 ;; will replace the standard function epilogue.
9110 (define_insn "sibcall_epilogue"
9111 [(parallel [(unspec:SI [(reg:SI LR_REGNUM)] UNSPEC_PROLOGUE_USE)
9112 (unspec_volatile [(return)] VUNSPEC_EPILOGUE)])]
9115 if (USE_RETURN_INSN (FALSE))
9116 return output_return_instruction (const_true_rtx, FALSE, FALSE);
9117 return arm_output_epilogue (FALSE);
9119 ;; Length is absolute worst case
9120 [(set_attr "length" "44")
9121 (set_attr "type" "block")
9122 ;; We don't clobber the conditions, but the potential length of this
9123 ;; operation is sufficient to make conditionalizing the sequence
9124 ;; unlikely to be profitable.
9125 (set_attr "conds" "clob")]
9128 (define_insn "*epilogue_insns"
9129 [(unspec_volatile [(return)] VUNSPEC_EPILOGUE)]
9133 return arm_output_epilogue (TRUE);
9134 else /* TARGET_THUMB */
9135 return thumb_unexpanded_epilogue ();
9137 ; Length is absolute worst case
9138 [(set_attr "length" "44")
9139 (set_attr "type" "block")
9140 ;; We don't clobber the conditions, but the potential length of this
9141 ;; operation is sufficient to make conditionalizing the sequence
9142 ;; unlikely to be profitable.
9143 (set_attr "conds" "clob")]
9146 (define_expand "eh_epilogue"
9147 [(use (match_operand:SI 0 "register_operand" ""))
9148 (use (match_operand:SI 1 "register_operand" ""))
9149 (use (match_operand:SI 2 "register_operand" ""))]
9153 cfun->machine->eh_epilogue_sp_ofs = operands[1];
9154 if (GET_CODE (operands[2]) != REG || REGNO (operands[2]) != 2)
9156 rtx ra = gen_rtx_REG (Pmode, 2);
9158 emit_move_insn (ra, operands[2]);
9161 /* This is a hack -- we may have crystalized the function type too
9163 cfun->machine->func_type = 0;
9167 ;; This split is only used during output to reduce the number of patterns
9168 ;; that need assembler instructions adding to them. We allowed the setting
9169 ;; of the conditions to be implicit during rtl generation so that
9170 ;; the conditional compare patterns would work. However this conflicts to
9171 ;; some extent with the conditional data operations, so we have to split them
9175 [(set (match_operand:SI 0 "s_register_operand" "")
9176 (if_then_else:SI (match_operator 1 "arm_comparison_operator"
9177 [(match_operand 2 "" "") (match_operand 3 "" "")])
9179 (match_operand 4 "" "")))
9180 (clobber (reg:CC CC_REGNUM))]
9181 "TARGET_ARM && reload_completed"
9182 [(set (match_dup 5) (match_dup 6))
9183 (cond_exec (match_dup 7)
9184 (set (match_dup 0) (match_dup 4)))]
9187 enum machine_mode mode = SELECT_CC_MODE (GET_CODE (operands[1]),
9188 operands[2], operands[3]);
9189 enum rtx_code rc = GET_CODE (operands[1]);
9191 operands[5] = gen_rtx_REG (mode, CC_REGNUM);
9192 operands[6] = gen_rtx_COMPARE (mode, operands[2], operands[3]);
9193 if (mode == CCFPmode || mode == CCFPEmode)
9194 rc = reverse_condition_maybe_unordered (rc);
9196 rc = reverse_condition (rc);
9198 operands[7] = gen_rtx_fmt_ee (rc, VOIDmode, operands[5], const0_rtx);
9203 [(set (match_operand:SI 0 "s_register_operand" "")
9204 (if_then_else:SI (match_operator 1 "arm_comparison_operator"
9205 [(match_operand 2 "" "") (match_operand 3 "" "")])
9206 (match_operand 4 "" "")
9208 (clobber (reg:CC CC_REGNUM))]
9209 "TARGET_ARM && reload_completed"
9210 [(set (match_dup 5) (match_dup 6))
9211 (cond_exec (match_op_dup 1 [(match_dup 5) (const_int 0)])
9212 (set (match_dup 0) (match_dup 4)))]
9215 enum machine_mode mode = SELECT_CC_MODE (GET_CODE (operands[1]),
9216 operands[2], operands[3]);
9218 operands[5] = gen_rtx_REG (mode, CC_REGNUM);
9219 operands[6] = gen_rtx_COMPARE (mode, operands[2], operands[3]);
9224 [(set (match_operand:SI 0 "s_register_operand" "")
9225 (if_then_else:SI (match_operator 1 "arm_comparison_operator"
9226 [(match_operand 2 "" "") (match_operand 3 "" "")])
9227 (match_operand 4 "" "")
9228 (match_operand 5 "" "")))
9229 (clobber (reg:CC CC_REGNUM))]
9230 "TARGET_ARM && reload_completed"
9231 [(set (match_dup 6) (match_dup 7))
9232 (cond_exec (match_op_dup 1 [(match_dup 6) (const_int 0)])
9233 (set (match_dup 0) (match_dup 4)))
9234 (cond_exec (match_dup 8)
9235 (set (match_dup 0) (match_dup 5)))]
9238 enum machine_mode mode = SELECT_CC_MODE (GET_CODE (operands[1]),
9239 operands[2], operands[3]);
9240 enum rtx_code rc = GET_CODE (operands[1]);
9242 operands[6] = gen_rtx_REG (mode, CC_REGNUM);
9243 operands[7] = gen_rtx_COMPARE (mode, operands[2], operands[3]);
9244 if (mode == CCFPmode || mode == CCFPEmode)
9245 rc = reverse_condition_maybe_unordered (rc);
9247 rc = reverse_condition (rc);
9249 operands[8] = gen_rtx_fmt_ee (rc, VOIDmode, operands[6], const0_rtx);
9254 [(set (match_operand:SI 0 "s_register_operand" "")
9255 (if_then_else:SI (match_operator 1 "arm_comparison_operator"
9256 [(match_operand:SI 2 "s_register_operand" "")
9257 (match_operand:SI 3 "arm_add_operand" "")])
9258 (match_operand:SI 4 "arm_rhs_operand" "")
9260 (match_operand:SI 5 "s_register_operand" ""))))
9261 (clobber (reg:CC CC_REGNUM))]
9262 "TARGET_ARM && reload_completed"
9263 [(set (match_dup 6) (match_dup 7))
9264 (cond_exec (match_op_dup 1 [(match_dup 6) (const_int 0)])
9265 (set (match_dup 0) (match_dup 4)))
9266 (cond_exec (match_dup 8)
9267 (set (match_dup 0) (not:SI (match_dup 5))))]
9270 enum machine_mode mode = SELECT_CC_MODE (GET_CODE (operands[1]),
9271 operands[2], operands[3]);
9272 enum rtx_code rc = GET_CODE (operands[1]);
9274 operands[6] = gen_rtx_REG (mode, CC_REGNUM);
9275 operands[7] = gen_rtx (COMPARE, mode, operands[2], operands[3]);
9276 if (mode == CCFPmode || mode == CCFPEmode)
9277 rc = reverse_condition_maybe_unordered (rc);
9279 rc = reverse_condition (rc);
9281 operands[8] = gen_rtx_fmt_ee (rc, VOIDmode, operands[6], const0_rtx);
9285 (define_insn "*cond_move_not"
9286 [(set (match_operand:SI 0 "s_register_operand" "=r,r")
9287 (if_then_else:SI (match_operator 4 "arm_comparison_operator"
9288 [(match_operand 3 "cc_register" "") (const_int 0)])
9289 (match_operand:SI 1 "arm_rhs_operand" "0,?rI")
9291 (match_operand:SI 2 "s_register_operand" "r,r"))))]
9295 mov%d4\\t%0, %1\;mvn%D4\\t%0, %2"
9296 [(set_attr "conds" "use")
9297 (set_attr "length" "4,8")]
9300 ;; The next two patterns occur when an AND operation is followed by a
9301 ;; scc insn sequence
9303 (define_insn "*sign_extract_onebit"
9304 [(set (match_operand:SI 0 "s_register_operand" "=r")
9305 (sign_extract:SI (match_operand:SI 1 "s_register_operand" "r")
9307 (match_operand:SI 2 "const_int_operand" "n")))
9308 (clobber (reg:CC CC_REGNUM))]
9311 operands[2] = GEN_INT (1 << INTVAL (operands[2]));
9312 output_asm_insn (\"ands\\t%0, %1, %2\", operands);
9313 return \"mvnne\\t%0, #0\";
9315 [(set_attr "conds" "clob")
9316 (set_attr "length" "8")]
9319 (define_insn "*not_signextract_onebit"
9320 [(set (match_operand:SI 0 "s_register_operand" "=r")
9322 (sign_extract:SI (match_operand:SI 1 "s_register_operand" "r")
9324 (match_operand:SI 2 "const_int_operand" "n"))))
9325 (clobber (reg:CC CC_REGNUM))]
9328 operands[2] = GEN_INT (1 << INTVAL (operands[2]));
9329 output_asm_insn (\"tst\\t%1, %2\", operands);
9330 output_asm_insn (\"mvneq\\t%0, #0\", operands);
9331 return \"movne\\t%0, #0\";
9333 [(set_attr "conds" "clob")
9334 (set_attr "length" "12")]
9337 ;; Push multiple registers to the stack. Registers are in parallel (use ...)
9338 ;; expressions. For simplicity, the first register is also in the unspec
9340 (define_insn "*push_multi"
9341 [(match_parallel 2 "multi_register_push"
9342 [(set (match_operand:BLK 0 "memory_operand" "=m")
9343 (unspec:BLK [(match_operand:SI 1 "s_register_operand" "r")]
9344 UNSPEC_PUSH_MULT))])]
9348 int num_saves = XVECLEN (operands[2], 0);
9350 /* For the StrongARM at least it is faster to
9351 use STR to store only a single register. */
9353 output_asm_insn (\"str\\t%1, [%m0, #-4]!\", operands);
9359 strcpy (pattern, \"stmfd\\t%m0!, {%1\");
9361 for (i = 1; i < num_saves; i++)
9363 strcat (pattern, \", %|\");
9365 reg_names[REGNO (XEXP (XVECEXP (operands[2], 0, i), 0))]);
9368 strcat (pattern, \"}\");
9369 output_asm_insn (pattern, operands);
9374 [(set_attr "type" "store4")]
9377 (define_insn "stack_tie"
9378 [(set (mem:BLK (scratch))
9379 (unspec:BLK [(match_operand:SI 0 "s_register_operand" "r")
9380 (match_operand:SI 1 "s_register_operand" "r")]
9384 [(set_attr "length" "0")]
9387 ;; Similarly for the floating point registers
9388 (define_insn "*push_fp_multi"
9389 [(match_parallel 2 "multi_register_push"
9390 [(set (match_operand:BLK 0 "memory_operand" "=m")
9391 (unspec:BLK [(match_operand:XF 1 "f_register_operand" "f")]
9392 UNSPEC_PUSH_MULT))])]
9398 sprintf (pattern, \"sfmfd\\t%%1, %d, [%%m0]!\", XVECLEN (operands[2], 0));
9399 output_asm_insn (pattern, operands);
9402 [(set_attr "type" "f_store")]
9405 ;; Special patterns for dealing with the constant pool
9407 (define_insn "align_4"
9408 [(unspec_volatile [(const_int 0)] VUNSPEC_ALIGN)]
9411 assemble_align (32);
9416 (define_insn "align_8"
9417 [(unspec_volatile [(const_int 0)] VUNSPEC_ALIGN8)]
9418 "TARGET_REALLY_IWMMXT"
9420 assemble_align (64);
9425 (define_insn "consttable_end"
9426 [(unspec_volatile [(const_int 0)] VUNSPEC_POOL_END)]
9429 making_const_table = FALSE;
9434 (define_insn "consttable_1"
9435 [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_1)]
9438 making_const_table = TRUE;
9439 assemble_integer (operands[0], 1, BITS_PER_WORD, 1);
9443 [(set_attr "length" "4")]
9446 (define_insn "consttable_2"
9447 [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_2)]
9450 making_const_table = TRUE;
9451 assemble_integer (operands[0], 2, BITS_PER_WORD, 1);
9455 [(set_attr "length" "4")]
9458 (define_insn "consttable_4"
9459 [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_4)]
9463 making_const_table = TRUE;
9464 switch (GET_MODE_CLASS (GET_MODE (operands[0])))
9469 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[0]);
9470 assemble_real (r, GET_MODE (operands[0]), BITS_PER_WORD);
9474 assemble_integer (operands[0], 4, BITS_PER_WORD, 1);
9479 [(set_attr "length" "4")]
9482 (define_insn "consttable_8"
9483 [(unspec_volatile [(match_operand 0 "" "")] VUNSPEC_POOL_8)]
9487 making_const_table = TRUE;
9488 switch (GET_MODE_CLASS (GET_MODE (operands[0])))
9493 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[0]);
9494 assemble_real (r, GET_MODE (operands[0]), BITS_PER_WORD);
9498 assemble_integer (operands[0], 8, BITS_PER_WORD, 1);
9503 [(set_attr "length" "8")]
9506 ;; Miscellaneous Thumb patterns
9508 (define_expand "tablejump"
9509 [(parallel [(set (pc) (match_operand:SI 0 "register_operand" ""))
9510 (use (label_ref (match_operand 1 "" "")))])]
9515 /* Hopefully, CSE will eliminate this copy. */
9516 rtx reg1 = copy_addr_to_reg (gen_rtx_LABEL_REF (Pmode, operands[1]));
9517 rtx reg2 = gen_reg_rtx (SImode);
9519 emit_insn (gen_addsi3 (reg2, operands[0], reg1));
9525 (define_insn "*thumb_tablejump"
9526 [(set (pc) (match_operand:SI 0 "register_operand" "l*r"))
9527 (use (label_ref (match_operand 1 "" "")))]
9530 [(set_attr "length" "2")]
9535 (define_insn "clzsi2"
9536 [(set (match_operand:SI 0 "s_register_operand" "=r")
9537 (clz:SI (match_operand:SI 1 "s_register_operand" "r")))]
9538 "TARGET_ARM && arm_arch5"
9540 [(set_attr "predicable" "yes")])
9542 (define_expand "ffssi2"
9543 [(set (match_operand:SI 0 "s_register_operand" "")
9544 (ffs:SI (match_operand:SI 1 "s_register_operand" "")))]
9545 "TARGET_ARM && arm_arch5"
9550 t1 = gen_reg_rtx (SImode);
9551 t2 = gen_reg_rtx (SImode);
9552 t3 = gen_reg_rtx (SImode);
9554 emit_insn (gen_negsi2 (t1, operands[1]));
9555 emit_insn (gen_andsi3 (t2, operands[1], t1));
9556 emit_insn (gen_clzsi2 (t3, t2));
9557 emit_insn (gen_subsi3 (operands[0], GEN_INT (32), t3));
9562 (define_expand "ctzsi2"
9563 [(set (match_operand:SI 0 "s_register_operand" "")
9564 (ctz:SI (match_operand:SI 1 "s_register_operand" "")))]
9565 "TARGET_ARM && arm_arch5"
9570 t1 = gen_reg_rtx (SImode);
9571 t2 = gen_reg_rtx (SImode);
9572 t3 = gen_reg_rtx (SImode);
9574 emit_insn (gen_negsi2 (t1, operands[1]));
9575 emit_insn (gen_andsi3 (t2, operands[1], t1));
9576 emit_insn (gen_clzsi2 (t3, t2));
9577 emit_insn (gen_subsi3 (operands[0], GEN_INT (31), t3));
9582 ;; V5E instructions.
9584 (define_insn "prefetch"
9585 [(prefetch (match_operand:SI 0 "address_operand" "p")
9586 (match_operand:SI 1 "" "")
9587 (match_operand:SI 2 "" ""))]
9588 "TARGET_ARM && arm_arch5e"
9591 ;; General predication pattern
9594 [(match_operator 0 "arm_comparison_operator"
9595 [(match_operand 1 "cc_register" "")
9601 (define_insn "prologue_use"
9602 [(unspec:SI [(match_operand:SI 0 "register_operand" "")] UNSPEC_PROLOGUE_USE)]
9604 "%@ %0 needed for prologue"
9607 ;; Load the FPA co-processor patterns
9609 ;; Load the Maverick co-processor patterns
9610 (include "cirrus.md")
9611 ;; Load the Intel Wireless Multimedia Extension patterns
9612 (include "iwmmxt.md")