1 ;; Machine description for the TMS320C[34]x for GNU C compiler
2 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998,
3 ;; 1999, 2000, 2002 Free Software Foundation, Inc.
5 ;; Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz)
6 ;; and Herman Ten Brugge (Haj.Ten.Brugge@net.HCC.nl)
8 ;; This file is part of GNU CC.
10 ;; GNU CC is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU CC is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU CC; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ; Try using PQImode again for addresses since C30 only uses
28 ; 24-bit addresses. Ideally GCC would emit different insns
29 ; for QImode and Pmode, whether Pmode was QImode or PQImode.
30 ; For addresses we wouldn't have to have a clobber of the CC
31 ; associated with each insn and we could use MPYI in address
32 ; calculations without having to synthesize a proper 32 bit multiply.
34 ; Additional C30/C40 instructions not coded:
35 ; CALLcond, IACK, IDLE, LDE, LDFI, LDII, LDM, NORM, RETIcond
36 ; ROLC, RORC, SIGI, STFI, STII, SUBC, SWI
38 ; Additional C40 instructions not coded:
39 ; LDEP, LDPE, LWRct, LAJcond, RETIcondD
44 ; QImode char, short, int, long (32-bits)
45 ; HImode long long (64-bits)
46 ; QFmode float, double (32-bits)
47 ; HFmode long double (40-bits)
54 ; comparison_operator LT, GT, LE, GE, LTU, GTU, LEU, GEU, EQ, NE
55 ; memory_operand memory [m]
56 ; immediate_operand immediate constant [IKN]
57 ; register_operand register [rf]
58 ; general_operand register, memory, constant [rfmI]
60 ; addr_reg_operand AR0-AR7, pseudo reg [a]
61 ; sp_reg_operand SP [b]
62 ; std_reg_operand AR0-AR7, IR0-IR1, RC, RS, RE, SP, pseudo [c]
63 ; ext_reg_operand R0-R11, pseudo reg [f]
64 ; ext_low_reg_operand R0-R7, pseudo reg [q]
65 ; index_reg_operand IR0-IR1, pseudo reg [x]
66 ; st_reg_operand ST [y]
67 ; dp_reg_operand DP [z]
68 ; stik_const_operand 5-bit const [K]
69 ; src_operand general operand [rfHmI]
70 ; par_ind_operand indirect S mode (ARx + 0, 1, IRx) [S<>]
71 ; parallel_operand par_ind_operand or ext_low_reg_operand
72 ; symbolic_address_operand
73 ; call_address_operand
75 ; ADDI src2, src1, dst three operand op
76 ; ADDI src, dst two operand op
78 ; Note that the predicates are only used when selecting a pattern
79 ; to determine if an operand is valid.
81 ; The constraints then select which of the possible valid operands
82 ; is present (and guide register selection). The actual assembly
83 ; instruction is then selected on the basis of the constraints.
85 ; The extra constraint (valid_operands) is used to determine if
86 ; the combination of operands is legitimate for the pattern.
91 ; a address reg AR0-AR7
93 ; c other int reg AR0-AR7, IR0-IR1, RC, RS, RE
94 ; d fp reg R0-R11 (sets CC when dst)
96 ; f fp reg R0-R11 (sets CC when dst)
97 ; g general reg, memory, constant
98 ; h fp reg (HFmode) R0-R11 (sets CC when dst)
99 ; i immediate int constant
104 ; n immediate int constant with known numeric value
105 ; o offsettable memory
107 ; q low fp reg R0-R7 (sets CC when dst)
108 ; r general reg R0-R11, AR0-AR7, IR0-IR1, RC, RS, RE
109 ; s immediate int constant (value not explicit)
112 ; v repeat count reg RC
114 ; x index reg IR0-IR1
115 ; y status (CC) reg ST
119 ; H fp 16-bit constant
121 ; J signed 8-bit (C4x only)
122 ; K signed 5-bit (C4x only)
124 ; M unsigned 8-bit (C4x only)
125 ; N ones complement of unsigned 16-bit
126 ; O 16 bit high constant
127 ; Q ARx + 9-bit signed disp
128 ; R ARx + 5-bit unsigned disp (C4x only)
129 ; S ARx + 0, 1, IRx disp
130 ; T direct memory operand
131 ; V non offsettable memory
133 ; < memory operand with autodecrement addressing
134 ; > memory operand with autoincrement addressing
135 ; { memory operand with pre-modify addressing
136 ; } memory operand with post-modify addressing
138 ; Note that the 'd', 'f', and 'h' constraints are equivalent.
139 ; The m constraint is equivalent to 'QT<>{}'
141 ; Note we cannot use the 'g' constraint with Pmode (i.e, QImode)
142 ; operations since LEGITIMATE_CONSTANT_P accepts SYMBOL_REF.
143 ; So instead we use 'rIm' for signed operands or 'rLm' for unsigned operands.
145 ; Note that the constraints are used to select the operands
146 ; for a chosen pattern. The constraint that requires the fewest
147 ; instructions to load an operand is chosen.
149 ; Note that the 'r' constraint is mostly only used for src integer register
150 ; operands, while 'c' and 'd' constraints are generally only used for dst
151 ; integer register operands (the 'r' constraint is the union of the 'c' and
152 ; 'd' constraints). When a register satisfying the 'd' constraint
153 ; is used as a dst operand, the CC gets clobbered (except for LDIcond)---but
156 ; The 'f' constraint is only for float register operands---when
157 ; a register satisying the 'f' constraint is used as a dst operand,
158 ; the CC gets clobbered (except for LDFcond).
160 ; The ! in front of the 'b' constaint says to GCC to disparage the
161 ; use of this constraint. The 'b' constraint applies only to the SP.
163 ; Note that we deal with the condition code CC like some of the RISC
164 ; architectures (arm, sh, sparc) where it is stored in a general register,
165 ; in this case the hard register ST (21). Unlike these other architectures
166 ; that do not set the CC with many instructions, the C[34]x architectures
167 ; sets the CC for many instructions when the destination register is
168 ; an extended precision register. While it would have been easier
169 ; to use the generic cc0 register to store the CC, as with most of
170 ; the other ported architectures, this constrains the setting and testing
171 ; of the CC to be consecutive insns. Thus we would reduce the benefit
172 ; of scheduling instructions to avoid pipeline conflicts and filling of
173 ; delayed branch slots.
175 ; Since the C[34]x has many instructions that set the CC, we pay the
176 ; price of having to explicity define which insns clobber the CC
177 ; (rather than using the macro NOTICE_UPDATE_CC).
179 ; Note that many patterns say that the CC is clobbered when in fact
180 ; that it may not be (depending on the destination register).
181 ; We have to cover ourselves if an extended precision register
182 ; is allocated to the destination register.
183 ; Unfortunately, it is not easy to tell GCC that the clobbering of CC
184 ; is register dependent. If we could tolerate the ST register being
185 ; copied about, then we could store the CC in a pseudo register and
186 ; use constructs such as (clobber (match_scratch:CC N "&y,X")) to
187 ; indicate that the 'y' class (ST register) is clobbered for the
188 ; first combination of operands, but not with the second.
189 ; I tried this approach for a while but reload got unhappy since I
190 ; didn't allow it to move the CC around.
192 ; Note that fundamental operations, such as moves, must not clobber the
193 ; CC. Thus movqi choses a move instruction that doesn't clobber the CC.
194 ; If GCC wants to combine a move with a compare, it is smart enough to
195 ; chose the move instruction that sets the CC.
197 ; Unfortunately, the C[34]x instruction set does not have arithmetic or
198 ; logical operations that never touch the CC. We thus have to assume
199 ; that the CC may be clobbered at all times. If we define patterns
200 ; such as addqi without the clobber of CC, then GCC will be forced
201 ; to use registers such as the auxiliary registers which can cause
202 ; horrible pipeline conflicts. The tradeoff is that GCC can't now
203 ; sneak in an add instruction between setting and testing of the CC.
205 ; Most of the C[34]x instructions require operands of the following formats,
206 ; where imm represents an immediate constant, dir a direct memory reference,
207 ; ind an indirect memory reference, and reg a register:
209 ; src2 (op2) src1 (op1) dst (op0)
210 ; imm dir ind reg | imm dir ind reg | reg Notes
211 ;---------------------+----------------------+------
212 ; ILH T Q<> r | - - - 0 | r 2 operand
213 ; - - S<> r | - - S<> r | r
214 ; J - R - | - - R r | r C4x
216 ; Arithmetic operations use the I, J constraints for immediate constants,
217 ; while logical operations use the L, J constraints. Floating point
218 ; operations use the H constraint for immediate constants.
220 ; With most instructions the src2 and src1 operands are commutative
221 ; (except for SUB, SUBR, ANDN). The assembler considers
222 ; ADDI 10, R0, R1 and ADDI R0, 10, R1 to be equivalent.
223 ; We thus match src2 and src1 with the src_operand predicate and
224 ; use valid_operands as the extra constraint to reject invalid
225 ; operand combinations. For example, ADDI @foo, @bar, R0.
227 ; Note that we use the ? modifier so that reload doesn't preferentially
228 ; try the alternative where three registers are acceptable as
229 ; operands (whenever an operand requires reloading). Instead it will try
230 ; the 2 operand form which will produce better code since it won't require
231 ; a new spill register.
233 ; Note that the floating point representation of 0.0 on the C4x
234 ; is 0x80000000 (-2147483648). This value produces an warning
235 ; message on 32-bit machines about the decimal constant being so large
236 ; that it is unsigned.
238 ; With two operand instructions patterns having two sets,
239 ; the compare set must come first to keep the combiner happy.
240 ; While the combiner seems to cope most of the time with the
241 ; compare set coming second, it's best to have it first.
244 ; C4x CONSTANT attributes
246 (define_attr "cpu" "c4x,c3x"
248 (cond [(symbol_ref "TARGET_C3X") (const_string "c3x")]
249 (const_string "c4x"))))
252 ; C4x INSN ATTRIBUTES:
254 ; lda load address, non-clobber CC
255 ; store memory store, non-clobber CC
256 ; load_load parallel memory loads, non-clobber CC
257 ; load_store parallel memory load and store, non-clobber CC
258 ; store_load parallel memory store and load, non-clobber CC
259 ; store_store parallel memory stores, non-clobber CC
260 ; unary two operand arithmetic, non-clobber CC
261 ; unarycc two operand arithmetic, clobber CC
262 ; binary three operand arithmetic, non-clobber CC
263 ; binarycc three operand arithmetic, clobber CC
264 ; compare compare, clobber CC
266 ; rets return from subroutine
267 ; jump unconditional branch
268 ; jmpc conditional branch
269 ; db decrement and branch (unconditional)
270 ; dbc decrement and branch (conditional)
274 ; repeat block repeat
275 ; repeat_top block repeat top
277 ; multi multiple instruction
280 ; The only real instructions that affect things are the ones that modify
281 ; address registers and ones that call or jump. Note that the number
282 ; of operands refers to the RTL insn pattern, not the number of explicit
283 ; operands in the machine instruction.
285 (define_attr "type" "lda,store,unary,unarycc,binary,binarycc,compare,call,rets,jump,jmpc,db,dbc,misc,ldp,repeat,repeat_top,laj,load_load,load_store,store_load,store_store,push,pop,multi"
286 (const_string "misc"))
289 ; Some instructions operate on unsigned data constants, some on signed data
290 ; constants, or the ones complement of unsigned constants.
291 ; This differentiates them. Default to signed. This attribute
292 ; is used by the macro SMALL_CONST () (defined in c4x.h) to determine
293 ; whether an immediate integer constant will fit within the instruction,
294 ; or will have to be loaded using direct addressing from memory.
295 ; Note that logical operations assume unsigned integers whereas
296 ; arithmetic operations assume signed integers. Note that the C4x
297 ; small immediate constant (J) used as src2 in three operand instructions
298 ; is always signed. not_uint16 refers to a number that fits into 16-bits
299 ; when one's complemented.
301 (define_attr "data" "int16,uint16,high_16,not_uint16" (const_string "int16"))
303 (define_asm_attributes
304 [(set_attr "type" "multi")])
309 ; Define delay slot scheduling for branch and call instructions.
310 ; The C[34]x has three delay slots. Note that none of the three instructions
311 ; that follow a delayed branch can be a Bcond, BcondD, BR, BRD, DBcond,
312 ; DBcondD, CALL, CALLcond, TRAPcond, RETIcond, RETScond, RPTB, RPTS, or IDLE.
314 ; Annulled branches are a bit difficult because the next instructions
316 ; The table below shows what phase of the c4x is executed.
318 ; op1 fetch, decode and read executed
319 ; op2 fetch and decode executed
321 ; This means that we can allow any instruction in the last delay slot
322 ; and only instructions which modify registers in the first two.
323 ; lda can not be executed in the first delay slot
324 ; and ldpk can not be executed in the first two delay slots.
326 (define_attr "onlyreg" "false,true"
327 (cond [(eq_attr "type" "unary,unarycc")
328 (if_then_else (and (match_operand 0 "reg_imm_operand" "")
329 (match_operand 1 "reg_imm_operand" ""))
330 (const_string "true") (const_string "false"))
331 (eq_attr "type" "binary,binarycc")
332 (if_then_else (and (match_operand 0 "reg_imm_operand" "")
333 (and (match_operand 1 "reg_imm_operand" "")
334 (match_operand 2 "reg_imm_operand" "")))
335 (const_string "true") (const_string "false"))]
336 (const_string "false")))
338 (define_attr "onlyreg_nomod" "false,true"
339 (cond [(eq_attr "type" "unary,unarycc,compare,lda,store")
340 (if_then_else (and (match_operand 0 "not_modify_reg" "")
341 (match_operand 1 "not_modify_reg" ""))
342 (const_string "true") (const_string "false"))
343 (eq_attr "type" "binary,binarycc")
344 (if_then_else (and (match_operand 0 "not_modify_reg" "")
345 (and (match_operand 1 "not_modify_reg" "")
346 (match_operand 2 "not_modify_reg" "")))
347 (const_string "true") (const_string "false"))]
348 (const_string "false")))
350 (define_attr "not_repeat_reg" "false,true"
351 (cond [(eq_attr "type" "unary,unarycc,compare,lda,ldp,store")
352 (if_then_else (and (match_operand 0 "not_rc_reg" "")
353 (match_operand 1 "not_rc_reg" ""))
354 (const_string "true") (const_string "false"))
355 (eq_attr "type" "binary,binarycc")
356 (if_then_else (and (match_operand 0 "not_rc_reg" "")
357 (and (match_operand 1 "not_rc_reg" "")
358 (match_operand 2 "not_rc_reg" "")))
359 (const_string "true") (const_string "false"))]
360 (const_string "false")))
362 /* Disable compare because the c4x contains a bug. The cmpi insn sets the CC
363 in the read phase of the pipeline instead of the execution phase when
364 two registers are compared. */
365 (define_attr "in_annul_slot_1" "false,true"
366 (if_then_else (and (and (eq_attr "cpu" "c4x")
367 (eq_attr "type" "!jump,call,rets,jmpc,compare,db,dbc,repeat,repeat_top,laj,push,pop,lda,ldp,multi"))
368 (eq_attr "onlyreg" "true"))
369 (const_string "true")
370 (const_string "false")))
372 (define_attr "in_annul_slot_2" "false,true"
373 (if_then_else (and (and (eq_attr "cpu" "c4x")
374 (eq_attr "type" "!jump,call,rets,jmpc,db,dbc,repeat,repeat_top,laj,push,pop,ldp,multi"))
375 (eq_attr "onlyreg_nomod" "true"))
376 (const_string "true")
377 (const_string "false")))
379 /* Disable ldp because the c4x contains a bug. The ldp insn modifies
380 the dp register when the insn is anulled or not.
381 Also disable autoincrement insns because of a silicon bug. */
382 (define_attr "in_annul_slot_3" "false,true"
383 (if_then_else (and (and (eq_attr "cpu" "c4x")
384 (eq_attr "type" "!jump,call,rets,jmpc,db,dbc,repeat,repeat_top,laj,push,pop,ldp,multi"))
385 (eq_attr "onlyreg_nomod" "true"))
386 (const_string "true")
387 (const_string "false")))
389 (define_attr "in_delay_slot" "false,true"
390 (if_then_else (eq_attr "type" "!jump,call,rets,jmpc,db,dbc,repeat,repeat_top,laj,multi")
391 (const_string "true")
392 (const_string "false")))
394 (define_attr "in_repeat_slot" "false,true"
395 (if_then_else (and (eq_attr "cpu" "c4x")
396 (and (eq_attr "type" "!jump,call,rets,jmpc,db,dbc,repeat,repeat_top,laj,multi")
397 (eq_attr "not_repeat_reg" "true")))
398 (const_string "true")
399 (const_string "false")))
401 (define_attr "in_dbc_slot" "false,true"
402 (if_then_else (eq_attr "type" "!jump,call,rets,jmpc,unarycc,binarycc,compare,db,dbc,repeat,repeat_top,laj,multi")
403 (const_string "true")
404 (const_string "false")))
406 (define_delay (eq_attr "type" "jmpc")
407 [(eq_attr "in_delay_slot" "true")
408 (eq_attr "in_annul_slot_1" "true")
409 (eq_attr "in_annul_slot_1" "true")
411 (eq_attr "in_delay_slot" "true")
412 (eq_attr "in_annul_slot_2" "true")
413 (eq_attr "in_annul_slot_2" "true")
415 (eq_attr "in_delay_slot" "true")
416 (eq_attr "in_annul_slot_3" "true")
417 (eq_attr "in_annul_slot_3" "true") ])
420 (define_delay (eq_attr "type" "repeat_top")
421 [(eq_attr "in_repeat_slot" "true") (nil) (nil)
422 (eq_attr "in_repeat_slot" "true") (nil) (nil)
423 (eq_attr "in_repeat_slot" "true") (nil) (nil)])
425 (define_delay (eq_attr "type" "jump,db")
426 [(eq_attr "in_delay_slot" "true") (nil) (nil)
427 (eq_attr "in_delay_slot" "true") (nil) (nil)
428 (eq_attr "in_delay_slot" "true") (nil) (nil)])
431 ; Decrement and branch conditional instructions cannot modify the
432 ; condition codes for the cycles in the delay slots.
434 (define_delay (eq_attr "type" "dbc")
435 [(eq_attr "in_dbc_slot" "true") (nil) (nil)
436 (eq_attr "in_dbc_slot" "true") (nil) (nil)
437 (eq_attr "in_dbc_slot" "true") (nil) (nil)])
439 ; The LAJ instruction has three delay slots but the last slot is
440 ; used for pushing the return address. Thus we can only use two slots.
442 (define_delay (eq_attr "type" "laj")
443 [(eq_attr "in_delay_slot" "true") (nil) (nil)
444 (eq_attr "in_delay_slot" "true") (nil) (nil)])
455 ; 7 repeat block filler
461 ; 13 Conditional load on overflow
474 ; C4x FUNCTIONAL UNITS
476 ; Define functional units for instruction scheduling to minimise
477 ; pipeline conflicts.
479 ; With the C3x, an external memory write (with no wait states) takes
480 ; two cycles and an external memory read (with no wait states) takes
481 ; one cycle. However, an external read following an external write
482 ; takes two cycles. With internal memory, reads and writes take
485 ; When a C4x address register is loaded it will not be available for
486 ; an extra machine cycle. Calculating with a C4x address register
487 ; makes it unavailable for 2 machine cycles. To notify GCC of these
488 ; pipeline delays, each of the auxiliary and index registers are declared
489 ; as separate functional units.
491 ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
492 ; TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
494 ; MULTIPLICITY 1 (C4x has no independent identical function units)
495 ; SIMULTANEITY 0 (C4x is pipelined)
496 ; READY_DELAY 1 (Results usually ready after every cyle)
497 ; ISSUE_DELAY 1 (Can issue insns every cycle)
499 ; Just some dummy definitions. The real work is done in c4x_adjust_cost.
500 ; These are needed so the min/max READY_DELAY is known.
502 (define_function_unit "dummy" 1 0 (const_int 0) 1 1)
503 (define_function_unit "dummy" 1 0 (const_int 0) 2 1)
504 (define_function_unit "dummy" 1 0 (const_int 0) 3 1)
506 ; The attribute setar0 is set to 1 for insns where ar0 is a dst operand.
507 ; Note that the attributes unarycc and binarycc do not apply
508 ; if ar0 is a dst operand (only loading an ext. prec. reg. sets CC)
509 (define_attr "setar0" ""
510 (cond [(eq_attr "type" "unary,binary")
511 (if_then_else (match_operand 0 "ar0_reg_operand" "")
512 (const_int 1) (const_int 0))]
515 (define_attr "setlda_ar0" ""
516 (cond [(eq_attr "type" "lda")
517 (if_then_else (match_operand 0 "ar0_reg_operand" "")
518 (const_int 1) (const_int 0))]
521 ; The attribute usear0 is set to 1 for insns where ar0 is used
522 ; for addressing, as a src operand, or as a dst operand.
523 (define_attr "usear0" ""
524 (cond [(eq_attr "type" "compare,store")
525 (if_then_else (match_operand 0 "ar0_mem_operand" "")
526 (const_int 1) (const_int 0))
527 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
528 (if_then_else (match_operand 1 "ar0_mem_operand" "")
529 (const_int 1) (const_int 0))
530 (eq_attr "type" "binary,binarycc")
531 (if_then_else (match_operand 2 "ar0_mem_operand" "")
532 (const_int 1) (const_int 0))
533 (eq_attr "type" "db,dbc")
534 (if_then_else (match_operand 0 "ar0_reg_operand" "")
535 (const_int 1) (const_int 0))]
538 ; The attribute readar0 is set to 1 for insns where ar0 is a src operand.
539 (define_attr "readar0" ""
540 (cond [(eq_attr "type" "compare")
541 (if_then_else (match_operand 0 "ar0_reg_operand" "")
542 (const_int 1) (const_int 0))
543 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
544 (if_then_else (match_operand 1 "ar0_reg_operand" "")
545 (const_int 1) (const_int 0))
546 (eq_attr "type" "binary,binarycc")
547 (if_then_else (match_operand 2 "ar0_reg_operand" "")
548 (const_int 1) (const_int 0))]
551 (define_attr "setar1" ""
552 (cond [(eq_attr "type" "unary,binary")
553 (if_then_else (match_operand 0 "ar1_reg_operand" "")
554 (const_int 1) (const_int 0))]
557 (define_attr "setlda_ar1" ""
558 (cond [(eq_attr "type" "lda")
559 (if_then_else (match_operand 0 "ar1_reg_operand" "")
560 (const_int 1) (const_int 0))]
563 (define_attr "usear1" ""
564 (cond [(eq_attr "type" "compare,store")
565 (if_then_else (match_operand 0 "ar1_mem_operand" "")
566 (const_int 1) (const_int 0))
567 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
568 (if_then_else (match_operand 1 "ar1_mem_operand" "")
569 (const_int 1) (const_int 0))
570 (eq_attr "type" "binary,binarycc")
571 (if_then_else (match_operand 2 "ar1_mem_operand" "")
572 (const_int 1) (const_int 0))
573 (eq_attr "type" "db,dbc")
574 (if_then_else (match_operand 0 "ar1_reg_operand" "")
575 (const_int 1) (const_int 0))]
578 (define_attr "readar1" ""
579 (cond [(eq_attr "type" "compare")
580 (if_then_else (match_operand 0 "ar1_reg_operand" "")
581 (const_int 1) (const_int 0))
582 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
583 (if_then_else (match_operand 1 "ar1_reg_operand" "")
584 (const_int 1) (const_int 0))
585 (eq_attr "type" "binary,binarycc")
586 (if_then_else (match_operand 2 "ar1_reg_operand" "")
587 (const_int 1) (const_int 0))]
590 (define_attr "setar2" ""
591 (cond [(eq_attr "type" "unary,binary")
592 (if_then_else (match_operand 0 "ar2_reg_operand" "")
593 (const_int 1) (const_int 0))]
596 (define_attr "setlda_ar2" ""
597 (cond [(eq_attr "type" "lda")
598 (if_then_else (match_operand 0 "ar2_reg_operand" "")
599 (const_int 1) (const_int 0))]
602 (define_attr "usear2" ""
603 (cond [(eq_attr "type" "compare,store")
604 (if_then_else (match_operand 0 "ar2_mem_operand" "")
605 (const_int 1) (const_int 0))
606 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
607 (if_then_else (match_operand 1 "ar2_mem_operand" "")
608 (const_int 1) (const_int 0))
609 (eq_attr "type" "binary,binarycc")
610 (if_then_else (match_operand 2 "ar2_mem_operand" "")
611 (const_int 1) (const_int 0))
612 (eq_attr "type" "db,dbc")
613 (if_then_else (match_operand 0 "ar2_reg_operand" "")
614 (const_int 1) (const_int 0))]
617 (define_attr "readar2" ""
618 (cond [(eq_attr "type" "compare")
619 (if_then_else (match_operand 0 "ar2_reg_operand" "")
620 (const_int 1) (const_int 0))
621 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
622 (if_then_else (match_operand 1 "ar2_reg_operand" "")
623 (const_int 1) (const_int 0))
624 (eq_attr "type" "binary,binarycc")
625 (if_then_else (match_operand 2 "ar2_reg_operand" "")
626 (const_int 1) (const_int 0))]
629 (define_attr "setar3" ""
630 (cond [(eq_attr "type" "unary,binary")
631 (if_then_else (match_operand 0 "ar3_reg_operand" "")
632 (const_int 1) (const_int 0))]
635 (define_attr "setlda_ar3" ""
636 (cond [(eq_attr "type" "lda")
637 (if_then_else (match_operand 0 "ar3_reg_operand" "")
638 (const_int 1) (const_int 0))]
641 (define_attr "usear3" ""
642 (cond [(eq_attr "type" "compare,store")
643 (if_then_else (match_operand 0 "ar3_mem_operand" "")
644 (const_int 1) (const_int 0))
645 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
646 (if_then_else (match_operand 1 "ar3_mem_operand" "")
647 (const_int 1) (const_int 0))
648 (eq_attr "type" "binary,binarycc")
649 (if_then_else (match_operand 2 "ar3_mem_operand" "")
650 (const_int 1) (const_int 0))
651 (eq_attr "type" "db,dbc")
652 (if_then_else (match_operand 0 "ar3_reg_operand" "")
653 (const_int 1) (const_int 0))]
656 (define_attr "readar3" ""
657 (cond [(eq_attr "type" "compare")
658 (if_then_else (match_operand 0 "ar3_reg_operand" "")
659 (const_int 1) (const_int 0))
660 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
661 (if_then_else (match_operand 1 "ar3_reg_operand" "")
662 (const_int 1) (const_int 0))
663 (eq_attr "type" "binary,binarycc")
664 (if_then_else (match_operand 2 "ar3_reg_operand" "")
665 (const_int 1) (const_int 0))]
668 (define_attr "setar4" ""
669 (cond [(eq_attr "type" "unary,binary")
670 (if_then_else (match_operand 0 "ar4_reg_operand" "")
671 (const_int 1) (const_int 0))]
674 (define_attr "setlda_ar4" ""
675 (cond [(eq_attr "type" "lda")
676 (if_then_else (match_operand 0 "ar4_reg_operand" "")
677 (const_int 1) (const_int 0))]
680 (define_attr "usear4" ""
681 (cond [(eq_attr "type" "compare,store")
682 (if_then_else (match_operand 0 "ar4_mem_operand" "")
683 (const_int 1) (const_int 0))
684 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
685 (if_then_else (match_operand 1 "ar4_mem_operand" "")
686 (const_int 1) (const_int 0))
687 (eq_attr "type" "binary,binarycc")
688 (if_then_else (match_operand 2 "ar4_mem_operand" "")
689 (const_int 1) (const_int 0))
690 (eq_attr "type" "db,dbc")
691 (if_then_else (match_operand 0 "ar4_reg_operand" "")
692 (const_int 1) (const_int 0))]
695 (define_attr "readar4" ""
696 (cond [(eq_attr "type" "compare")
697 (if_then_else (match_operand 0 "ar4_reg_operand" "")
698 (const_int 1) (const_int 0))
699 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
700 (if_then_else (match_operand 1 "ar4_reg_operand" "")
701 (const_int 1) (const_int 0))
702 (eq_attr "type" "binary,binarycc")
703 (if_then_else (match_operand 2 "ar4_reg_operand" "")
704 (const_int 1) (const_int 0))]
707 (define_attr "setar5" ""
708 (cond [(eq_attr "type" "unary,binary")
709 (if_then_else (match_operand 0 "ar5_reg_operand" "")
710 (const_int 1) (const_int 0))]
713 (define_attr "setlda_ar5" ""
714 (cond [(eq_attr "type" "lda")
715 (if_then_else (match_operand 0 "ar5_reg_operand" "")
716 (const_int 1) (const_int 0))]
719 (define_attr "usear5" ""
720 (cond [(eq_attr "type" "compare,store")
721 (if_then_else (match_operand 0 "ar5_mem_operand" "")
722 (const_int 1) (const_int 0))
723 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
724 (if_then_else (match_operand 1 "ar5_mem_operand" "")
725 (const_int 1) (const_int 0))
726 (eq_attr "type" "binary,binarycc")
727 (if_then_else (match_operand 2 "ar5_mem_operand" "")
728 (const_int 1) (const_int 0))
729 (eq_attr "type" "db,dbc")
730 (if_then_else (match_operand 0 "ar5_reg_operand" "")
731 (const_int 1) (const_int 0))]
734 (define_attr "readar5" ""
735 (cond [(eq_attr "type" "compare")
736 (if_then_else (match_operand 0 "ar5_reg_operand" "")
737 (const_int 1) (const_int 0))
738 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
739 (if_then_else (match_operand 1 "ar5_reg_operand" "")
740 (const_int 1) (const_int 0))
741 (eq_attr "type" "binary,binarycc")
742 (if_then_else (match_operand 2 "ar5_reg_operand" "")
743 (const_int 1) (const_int 0))]
746 (define_attr "setar6" ""
747 (cond [(eq_attr "type" "unary,binary")
748 (if_then_else (match_operand 0 "ar6_reg_operand" "")
749 (const_int 1) (const_int 0))]
752 (define_attr "setlda_ar6" ""
753 (cond [(eq_attr "type" "lda")
754 (if_then_else (match_operand 0 "ar6_reg_operand" "")
755 (const_int 1) (const_int 0))]
758 (define_attr "usear6" ""
759 (cond [(eq_attr "type" "compare,store")
760 (if_then_else (match_operand 0 "ar6_mem_operand" "")
761 (const_int 1) (const_int 0))
762 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
763 (if_then_else (match_operand 1 "ar6_mem_operand" "")
764 (const_int 1) (const_int 0))
765 (eq_attr "type" "binary,binarycc")
766 (if_then_else (match_operand 2 "ar6_mem_operand" "")
767 (const_int 1) (const_int 0))
768 (eq_attr "type" "db,dbc")
769 (if_then_else (match_operand 0 "ar6_reg_operand" "")
770 (const_int 1) (const_int 0))]
773 (define_attr "readar6" ""
774 (cond [(eq_attr "type" "compare")
775 (if_then_else (match_operand 0 "ar6_reg_operand" "")
776 (const_int 1) (const_int 0))
777 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
778 (if_then_else (match_operand 1 "ar6_reg_operand" "")
779 (const_int 1) (const_int 0))
780 (eq_attr "type" "binary,binarycc")
781 (if_then_else (match_operand 2 "ar6_reg_operand" "")
782 (const_int 1) (const_int 0))]
785 (define_attr "setar7" ""
786 (cond [(eq_attr "type" "unary,binary")
787 (if_then_else (match_operand 0 "ar7_reg_operand" "")
788 (const_int 1) (const_int 0))]
791 (define_attr "setlda_ar7" ""
792 (cond [(eq_attr "type" "lda")
793 (if_then_else (match_operand 0 "ar7_reg_operand" "")
794 (const_int 1) (const_int 0))]
797 (define_attr "usear7" ""
798 (cond [(eq_attr "type" "compare,store")
799 (if_then_else (match_operand 0 "ar7_mem_operand" "")
800 (const_int 1) (const_int 0))
801 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
802 (if_then_else (match_operand 1 "ar7_mem_operand" "")
803 (const_int 1) (const_int 0))
804 (eq_attr "type" "binary,binarycc")
805 (if_then_else (match_operand 2 "ar7_mem_operand" "")
806 (const_int 1) (const_int 0))
807 (eq_attr "type" "db,dbc")
808 (if_then_else (match_operand 0 "ar7_reg_operand" "")
809 (const_int 1) (const_int 0))]
812 (define_attr "readar7" ""
813 (cond [(eq_attr "type" "compare")
814 (if_then_else (match_operand 0 "ar7_reg_operand" "")
815 (const_int 1) (const_int 0))
816 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
817 (if_then_else (match_operand 1 "ar7_reg_operand" "")
818 (const_int 1) (const_int 0))
819 (eq_attr "type" "binary,binarycc")
820 (if_then_else (match_operand 2 "ar7_reg_operand" "")
821 (const_int 1) (const_int 0))]
824 (define_attr "setir0" ""
825 (cond [(eq_attr "type" "unary,binary")
826 (if_then_else (match_operand 0 "ir0_reg_operand" "")
827 (const_int 1) (const_int 0))]
830 (define_attr "setlda_ir0" ""
831 (cond [(eq_attr "type" "lda")
832 (if_then_else (match_operand 0 "ir0_reg_operand" "")
833 (const_int 1) (const_int 0))]
836 (define_attr "useir0" ""
837 (cond [(eq_attr "type" "compare,store")
838 (if_then_else (match_operand 0 "ir0_mem_operand" "")
839 (const_int 1) (const_int 0))
840 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
841 (if_then_else (match_operand 1 "ir0_mem_operand" "")
842 (const_int 1) (const_int 0))
843 (eq_attr "type" "binary,binarycc")
844 (if_then_else (match_operand 2 "ir0_mem_operand" "")
845 (const_int 1) (const_int 0))]
848 (define_attr "setir1" ""
849 (cond [(eq_attr "type" "unary,binary")
850 (if_then_else (match_operand 0 "ir1_reg_operand" "")
851 (const_int 1) (const_int 0))]
854 (define_attr "setlda_ir1" ""
855 (cond [(eq_attr "type" "lda")
856 (if_then_else (match_operand 0 "ir1_reg_operand" "")
857 (const_int 1) (const_int 0))]
860 (define_attr "useir1" ""
861 (cond [(eq_attr "type" "compare,store")
862 (if_then_else (match_operand 0 "ir1_mem_operand" "")
863 (const_int 1) (const_int 0))
864 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
865 (if_then_else (match_operand 1 "ir1_mem_operand" "")
866 (const_int 1) (const_int 0))
867 (eq_attr "type" "binary,binarycc")
868 (if_then_else (match_operand 2 "ir1_mem_operand" "")
869 (const_int 1) (const_int 0))]
872 ; With the C3x, things are simpler, but slower, i.e. more pipeline conflicts :(
873 ; There are three functional groups:
874 ; (1) AR0-AR7, IR0-IR1, BK
878 ; When a register in one of these functional groups is loaded,
879 ; the contents of that or any other register in its group
880 ; will not be available to the next instruction for 2 machine cycles.
881 ; Similarly, when a register in one of the functional groups is read
882 ; excepting (IR0-IR1, BK, DP) the contents of that or any other register
883 ; in its group will not be available to the next instruction for
886 ; Let's ignore functional groups 2 and 3 for now, since they are not
889 (define_attr "setgroup1" ""
890 (cond [(eq_attr "type" "lda,unary,binary")
891 (if_then_else (match_operand 0 "group1_reg_operand" "")
892 (const_int 1) (const_int 0))]
895 (define_attr "usegroup1" ""
896 (cond [(eq_attr "type" "compare,store,store_store,store_load")
897 (if_then_else (match_operand 0 "group1_mem_operand" "")
898 (const_int 1) (const_int 0))
899 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc,load_load,load_store")
900 (if_then_else (match_operand 1 "group1_mem_operand" "")
901 (const_int 1) (const_int 0))
902 (eq_attr "type" "store_store,load_store")
903 (if_then_else (match_operand 2 "group1_mem_operand" "")
904 (const_int 1) (const_int 0))
905 (eq_attr "type" "load_load,store_load")
906 (if_then_else (match_operand 3 "group1_mem_operand" "")
907 (const_int 1) (const_int 0))]
910 (define_attr "readarx" ""
911 (cond [(eq_attr "type" "compare")
912 (if_then_else (match_operand 0 "arx_reg_operand" "")
913 (const_int 1) (const_int 0))
914 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
915 (if_then_else (match_operand 1 "arx_reg_operand" "")
916 (const_int 1) (const_int 0))
917 (eq_attr "type" "binary,binarycc")
918 (if_then_else (match_operand 2 "arx_reg_operand" "")
919 (const_int 1) (const_int 0))]
926 ; Note that the movMM and addP patterns can be called during reload
927 ; so we need to take special care with theses patterns since
928 ; we cannot blindly clobber CC or generate new pseudo registers.
931 ; TWO OPERAND INTEGER INSTRUCTIONS
937 (define_insn "set_ldp"
938 [(set (match_operand:QI 0 "dp_reg_operand" "=z")
939 (high:QI (match_operand:QI 1 "" "")))]
941 "* return (TARGET_C3X) ? \"ldp\\t%A1\" : \"ldpk\\t%A1\";"
942 [(set_attr "type" "ldp")])
944 (define_insn "set_ldp_prologue"
945 [(set (match_operand:QI 0 "dp_reg_operand" "=z")
946 (high:QI (match_operand:QI 1 "" "")))]
947 "TARGET_SMALL && TARGET_PARANOID"
948 "* return (TARGET_C3X) ? \"ldp\\t@data_sec\" : \"ldpk\\t@data_sec\";"
949 [(set_attr "type" "ldp")])
951 (define_insn "set_high"
952 [(set (match_operand:QI 0 "std_reg_operand" "=c")
953 (high:QI (match_operand:QI 1 "symbolic_address_operand" "")))]
954 "! TARGET_C3X && ! TARGET_TI"
956 [(set_attr "type" "unary")])
958 (define_insn "set_lo_sum"
959 [(set (match_operand:QI 0 "std_reg_operand" "+c")
960 (lo_sum:QI (match_dup 0)
961 (match_operand:QI 1 "symbolic_address_operand" "")))]
964 [(set_attr "type" "unary")])
967 [(set (match_operand:QI 0 "std_reg_operand" "")
968 (match_operand:QI 1 "symbolic_address_operand" ""))]
969 "reload_completed && ! TARGET_C3X && ! TARGET_TI"
970 [(set (match_dup 0) (high:QI (match_dup 1)))
971 (set (match_dup 0) (lo_sum:QI (match_dup 0) (match_dup 1)))]
975 [(set (match_operand:QI 0 "reg_operand" "")
976 (match_operand:QI 1 "const_int_operand" ""))
977 (clobber (reg:QI 16))]
979 && ! IS_INT16_CONST (INTVAL (operands[1]))
980 && ! IS_HIGH_CONST (INTVAL (operands[1]))
982 && std_reg_operand (operands[0], QImode)"
983 [(set (match_dup 0) (match_dup 2))
984 (set (match_dup 0) (ior:QI (match_dup 0) (match_dup 3)))]
987 operands[2] = GEN_INT (INTVAL (operands[1]) & ~0xffff);
988 operands[3] = GEN_INT (INTVAL (operands[1]) & 0xffff);
992 [(set (match_operand:QI 0 "reg_operand" "")
993 (match_operand:QI 1 "const_int_operand" ""))]
995 && ! IS_INT16_CONST (INTVAL (operands[1]))
996 && ! IS_HIGH_CONST (INTVAL (operands[1]))
998 && std_reg_operand (operands[0], QImode)"
999 [(set (match_dup 0) (match_dup 2))
1000 (set (match_dup 0) (ior:QI (match_dup 0) (match_dup 3)))]
1003 operands[2] = GEN_INT (INTVAL (operands[1]) & ~0xffff);
1004 operands[3] = GEN_INT (INTVAL (operands[1]) & 0xffff);
1008 [(set (match_operand:QI 0 "reg_operand" "")
1009 (match_operand:QI 1 "const_int_operand" ""))
1010 (clobber (reg:QI 16))]
1011 "TARGET_C3X && ! TARGET_SMALL
1012 && ! IS_INT16_CONST (INTVAL (operands[1]))
1014 && std_reg_operand (operands[0], QImode)
1015 && c4x_shiftable_constant (operands[1]) < 0"
1016 [(set (match_dup 0) (match_dup 2))
1017 (set (match_dup 0) (ashift:QI (match_dup 0) (match_dup 4)))
1018 (set (match_dup 0) (ior:QI (match_dup 0) (match_dup 3)))]
1021 /* Generate two's complement value of 16 MSBs. */
1022 operands[2] = gen_rtx (CONST_INT, VOIDmode,
1023 (((INTVAL (operands[1]) >> 16) & 0xffff)
1024 - 0x8000) ^ ~0x7fff);
1025 operands[3] = GEN_INT (INTVAL (operands[1]) & 0xffff);
1026 operands[4] = GEN_INT (16);
1030 [(set (match_operand:QI 0 "reg_operand" "")
1031 (match_operand:QI 1 "const_int_operand" ""))]
1032 "TARGET_C3X && ! TARGET_SMALL
1033 && ! IS_INT16_CONST (INTVAL (operands[1]))
1035 && std_reg_operand (operands[0], QImode)
1036 && c4x_shiftable_constant (operands[1]) < 0"
1037 [(set (match_dup 0) (match_dup 2))
1038 (set (match_dup 0) (ashift:QI (match_dup 0) (match_dup 4)))
1039 (set (match_dup 0) (ior:QI (match_dup 0) (match_dup 3)))]
1042 /* Generate two's complement value of 16 MSBs. */
1043 operands[2] = gen_rtx (CONST_INT, VOIDmode,
1044 (((INTVAL (operands[1]) >> 16) & 0xffff)
1045 - 0x8000) ^ ~0x7fff);
1046 operands[3] = GEN_INT (INTVAL (operands[1]) & 0xffff);
1047 operands[4] = GEN_INT (16);
1051 [(set (match_operand:QI 0 "reg_operand" "")
1052 (match_operand:QI 1 "const_int_operand" ""))
1053 (clobber (reg:QI 16))]
1055 && ! IS_INT16_CONST (INTVAL (operands[1]))
1057 && std_reg_operand (operands[0], QImode)
1058 && c4x_shiftable_constant (operands[1]) >= 0"
1059 [(set (match_dup 0) (match_dup 2))
1060 (set (match_dup 0) (ashift:QI (match_dup 0) (match_dup 3)))]
1063 /* Generate two's complement value of MSBs. */
1064 int shift = c4x_shiftable_constant (operands[1]);
1066 operands[2] = GEN_INT ((((INTVAL (operands[1]) >> shift) & 0xffff)
1067 - 0x8000) ^ ~0x7fff);
1068 operands[3] = GEN_INT (shift);
1072 [(set (match_operand:QI 0 "reg_operand" "")
1073 (match_operand:QI 1 "const_int_operand" ""))]
1075 && ! IS_INT16_CONST (INTVAL (operands[1]))
1077 && std_reg_operand (operands[0], QImode)
1078 && c4x_shiftable_constant (operands[1]) >= 0"
1079 [(set (match_dup 0) (match_dup 2))
1080 (set (match_dup 0) (ashift:QI (match_dup 0) (match_dup 3)))]
1083 /* Generate two's complement value of MSBs. */
1084 int shift = c4x_shiftable_constant (operands[1]);
1086 operands[2] = GEN_INT ((((INTVAL (operands[1]) >> shift) & 0xffff)
1087 - 0x8000) ^ ~0x7fff);
1088 operands[3] = GEN_INT (shift);
1092 [(set (match_operand:QI 0 "reg_operand" "")
1093 (match_operand:QI 1 "const_int_operand" ""))
1094 (clobber (reg:QI 16))]
1096 && ! IS_INT16_CONST (INTVAL (operands[1]))
1097 && ! IS_HIGH_CONST (INTVAL (operands[1]))
1099 && ! std_reg_operand (operands[0], QImode)"
1100 [(set (match_dup 2) (high:QI (match_dup 3)))
1101 (set (match_dup 0) (match_dup 4))
1102 (use (match_dup 1))]
1105 rtx dp_reg = gen_rtx_REG (Pmode, DP_REGNO);
1106 operands[2] = dp_reg;
1107 operands[3] = force_const_mem (Pmode, operands[1]);
1108 operands[4] = change_address (operands[3], QImode,
1109 gen_rtx_LO_SUM (Pmode, dp_reg,
1110 XEXP (operands[3], 0)));
1111 operands[3] = XEXP (operands[3], 0);
1115 [(set (match_operand:QI 0 "reg_operand" "")
1116 (match_operand:QI 1 "const_int_operand" ""))]
1118 && ! IS_INT16_CONST (INTVAL (operands[1]))
1119 && ! IS_HIGH_CONST (INTVAL (operands[1]))
1121 && ! std_reg_operand (operands[0], QImode)"
1122 [(set (match_dup 2) (high:QI (match_dup 3)))
1123 (set (match_dup 0) (match_dup 4))
1124 (use (match_dup 1))]
1127 rtx dp_reg = gen_rtx_REG (Pmode, DP_REGNO);
1128 operands[2] = dp_reg;
1129 operands[3] = force_const_mem (Pmode, operands[1]);
1130 operands[4] = change_address (operands[3], QImode,
1131 gen_rtx_LO_SUM (Pmode, dp_reg,
1132 XEXP (operands[3], 0)));
1133 operands[3] = XEXP (operands[3], 0);
1137 [(set (match_operand:QI 0 "reg_operand" "")
1138 (match_operand:QI 1 "const_int_operand" ""))
1139 (clobber (reg:QI 16))]
1141 && ! IS_INT16_CONST (INTVAL (operands[1]))
1142 && ! IS_HIGH_CONST (INTVAL (operands[1]))
1144 && ((TARGET_C3X && c4x_shiftable_constant (operands[1]) < 0)
1145 || ! std_reg_operand (operands[0], QImode))"
1146 [(set (match_dup 0) (match_dup 2))
1147 (use (match_dup 1))]
1150 rtx dp_reg = gen_rtx_REG (Pmode, DP_REGNO);
1151 operands[2] = force_const_mem (Pmode, operands[1]);
1152 operands[2] = change_address (operands[2], QImode,
1153 gen_rtx_LO_SUM (Pmode, dp_reg,
1154 XEXP (operands[2], 0)));
1158 [(set (match_operand:QI 0 "reg_operand" "")
1159 (match_operand:QI 1 "const_int_operand" ""))]
1161 && ! IS_INT16_CONST (INTVAL (operands[1]))
1162 && ! IS_HIGH_CONST (INTVAL (operands[1]))
1164 && ((TARGET_C3X && c4x_shiftable_constant (operands[1]) < 0)
1165 || ! std_reg_operand (operands[0], QImode))"
1166 [(set (match_dup 0) (match_dup 2))
1167 (use (match_dup 1))]
1170 rtx dp_reg = gen_rtx_REG (Pmode, DP_REGNO);
1171 operands[2] = force_const_mem (Pmode, operands[1]);
1172 operands[2] = change_address (operands[2], QImode,
1173 gen_rtx_LO_SUM (Pmode, dp_reg,
1174 XEXP (operands[2], 0)));
1178 [(set (match_operand:HI 0 "reg_operand" "")
1179 (match_operand:HI 1 "const_int_operand" ""))
1180 (clobber (reg:QI 16))]
1182 [(set (match_dup 2) (match_dup 4))
1183 (set (match_dup 3) (match_dup 5))]
1186 operands[2] = c4x_operand_subword (operands[0], 0, 1, HImode);
1187 operands[3] = c4x_operand_subword (operands[0], 1, 1, HImode);
1188 operands[4] = c4x_operand_subword (operands[1], 0, 1, HImode);
1189 operands[5] = c4x_operand_subword (operands[1], 1, 1, HImode);
1193 ; We need to clobber the DP reg to be safe in case we
1194 ; need to load this address from memory
1195 (define_insn "load_immed_address"
1196 [(set (match_operand:QI 0 "reg_operand" "=a?x?c*r")
1197 (match_operand:QI 1 "symbolic_address_operand" ""))
1198 (clobber (reg:QI 16))]
1199 "TARGET_LOAD_ADDRESS"
1201 [(set_attr "type" "multi")])
1205 [(set (match_operand:QI 0 "std_reg_operand" "")
1206 (match_operand:QI 1 "symbolic_address_operand" ""))
1207 (clobber (reg:QI 16))]
1208 "reload_completed && ! TARGET_C3X && ! TARGET_TI"
1209 [(set (match_dup 0) (high:QI (match_dup 1)))
1210 (set (match_dup 0) (lo_sum:QI (match_dup 0) (match_dup 1)))]
1213 ; CC has been selected to load a symbolic address. We force the address
1214 ; into memory and then generate LDP and LDIU insns.
1215 ; This is also required for the C30 if we pretend that we can
1216 ; easily load symbolic addresses into a register.
1218 [(set (match_operand:QI 0 "reg_operand" "")
1219 (match_operand:QI 1 "symbolic_address_operand" ""))
1220 (clobber (reg:QI 16))]
1223 && (TARGET_C3X || TARGET_TI || ! std_reg_operand (operands[0], QImode))"
1224 [(set (match_dup 2) (high:QI (match_dup 3)))
1225 (set (match_dup 0) (match_dup 4))
1226 (use (match_dup 1))]
1229 rtx dp_reg = gen_rtx_REG (Pmode, DP_REGNO);
1230 operands[2] = dp_reg;
1231 operands[3] = force_const_mem (Pmode, operands[1]);
1232 operands[4] = change_address (operands[3], QImode,
1233 gen_rtx_LO_SUM (Pmode, dp_reg,
1234 XEXP (operands[3], 0)));
1235 operands[3] = XEXP (operands[3], 0);
1238 ; This pattern is similar to the above but does not emit a LDP
1239 ; for the small memory model.
1241 [(set (match_operand:QI 0 "reg_operand" "")
1242 (match_operand:QI 1 "symbolic_address_operand" ""))
1243 (clobber (reg:QI 16))]
1246 && (TARGET_C3X || TARGET_TI || ! std_reg_operand (operands[0], QImode))"
1247 [(set (match_dup 0) (match_dup 2))
1248 (use (match_dup 1))]
1251 rtx dp_reg = gen_rtx_REG (Pmode, DP_REGNO);
1252 operands[2] = force_const_mem (Pmode, operands[1]);
1253 operands[2] = change_address (operands[2], QImode,
1254 gen_rtx_LO_SUM (Pmode, dp_reg,
1255 XEXP (operands[2], 0)));
1258 (define_insn "loadhi_big_constant"
1259 [(set (match_operand:HI 0 "reg_operand" "=c*d")
1260 (match_operand:HI 1 "const_int_operand" ""))
1261 (clobber (reg:QI 16))]
1264 [(set_attr "type" "multi")])
1269 ; The following moves will not set the condition codes register.
1272 ; This must come before the general case
1273 (define_insn "*movqi_stik"
1274 [(set (match_operand:QI 0 "memory_operand" "=m")
1275 (match_operand:QI 1 "stik_const_operand" "K"))]
1278 [(set_attr "type" "store")])
1280 (define_insn "loadqi_big_constant"
1281 [(set (match_operand:QI 0 "reg_operand" "=c*d")
1282 (match_operand:QI 1 "const_int_operand" ""))
1283 (clobber (reg:QI 16))]
1284 "! IS_INT16_CONST (INTVAL (operands[1]))
1285 && ! IS_HIGH_CONST (INTVAL (operands[1]))"
1287 [(set_attr "type" "multi")])
1289 ; We must provide an alternative to store to memory in case we have to
1291 (define_insn "movqi_noclobber"
1292 [(set (match_operand:QI 0 "dst_operand" "=d,*c,m,r")
1293 (match_operand:QI 1 "src_hi_operand" "rIm,rIm,r,O"))]
1294 "(REG_P (operands[0]) || REG_P (operands[1])
1295 || GET_CODE (operands[0]) == SUBREG
1296 || GET_CODE (operands[1]) == SUBREG)
1297 && ! symbolic_address_operand (operands[1], QImode)"
1299 if (which_alternative == 2)
1300 return \"sti\\t%1,%0\";
1302 if (! TARGET_C3X && which_alternative == 3)
1304 operands[1] = GEN_INT ((INTVAL (operands[1]) >> 16) & 0xffff);
1305 return \"ldhi\\t%1,%0\";
1308 /* The lda instruction cannot use the same register as source
1310 if (! TARGET_C3X && which_alternative == 1
1311 && ( IS_ADDR_REG (operands[0])
1312 || IS_INDEX_REG (operands[0])
1313 || IS_SP_REG (operands[0]))
1314 && (REGNO (operands[0]) != REGNO (operands[1])))
1315 return \"lda\\t%1,%0\";
1316 return \"ldiu\\t%1,%0\";
1318 [(set_attr "type" "unary,lda,store,unary")
1319 (set_attr "data" "int16,int16,int16,high_16")])
1325 ; We shouldn't need these peepholes, but the combiner seems to miss them...
1327 [(set (match_operand:QI 0 "ext_reg_operand" "=d")
1328 (match_operand:QI 1 "src_operand" "rIm"))
1330 (compare:CC (match_dup 0) (const_int 0)))]
1333 [(set_attr "type" "unarycc")
1334 (set_attr "data" "int16")])
1336 (define_insn "*movqi_set"
1338 (compare:CC (match_operand:QI 1 "src_operand" "rIm")
1340 (set (match_operand:QI 0 "ext_reg_operand" "=d")
1344 [(set_attr "type" "unarycc")
1345 (set_attr "data" "int16")])
1347 ; This pattern probably gets in the way and requires a scratch register
1348 ; when a simple compare with zero will suffice.
1349 ;(define_insn "*movqi_test"
1351 ; (compare:CC (match_operand:QI 1 "src_operand" "rIm")
1353 ; (clobber (match_scratch:QI 0 "=d"))]
1357 ; [(set_attr "type" "unarycc")
1358 ; (set_attr "data" "int16")])
1360 ; If one of the operands is not a register, then we should
1361 ; emit two insns, using a scratch register. This will produce
1362 ; better code in loops if the source operand is invariant, since
1363 ; the source reload can be optimized out. During reload we cannot
1364 ; use change_address or force_reg which will allocate new pseudo regs.
1366 ; Unlike most other insns, the move insns can't be split with
1367 ; different predicates, because register spilling and other parts of
1368 ; the compiler, have memoized the insn number already.
1370 (define_expand "movqi"
1371 [(set (match_operand:QI 0 "general_operand" "")
1372 (match_operand:QI 1 "general_operand" ""))]
1376 if (c4x_emit_move_sequence (operands, QImode))
1381 ; As far as GCC is concerned, the moves are performed in parallel
1382 ; thus it must be convinced that there is no aliasing.
1383 ; It also assumes that the input operands are simultaneously loaded
1384 ; and then the output operands are simultaneously stored.
1385 ; With the C4x, if there are parallel stores to the same address
1386 ; both stores are executed.
1387 ; If there is a parallel load and store to the same address,
1388 ; the load is performed first.
1389 ; The problem with this pattern is that reload can spoil
1390 ; the show when it eliminates a reference to the frame pointer.
1391 ; This can invalidate the memory addressing mode, i.e., when
1392 ; the displacement is greater than 1.
1393 (define_insn "movqi_parallel"
1394 [(set (match_operand:QI 0 "parallel_operand" "=q,S<>!V,q,S<>!V")
1395 (match_operand:QI 1 "parallel_operand" "S<>!V,q,S<>!V,q"))
1396 (set (match_operand:QI 2 "parallel_operand" "=q,S<>!V,S<>!V,q")
1397 (match_operand:QI 3 "parallel_operand" "S<>!V,q,q,S<>!V"))]
1398 "TARGET_PARALLEL && valid_parallel_load_store (operands, QImode)"
1400 ldi1\\t%1,%0\\n||\\tldi2\\t%3,%2
1401 sti1\\t%1,%0\\n||\\tsti2\\t%3,%2
1402 ldi\\t%1,%0\\n||\\tsti\\t%3,%2
1403 ldi\\t%3,%2\\n||\\tsti\\t%1,%0"
1404 [(set_attr "type" "load_load,store_store,load_store,store_load")])
1409 (define_insn "pushqi"
1410 [(set (mem:QI (pre_inc:QI (reg:QI 20)))
1411 (match_operand:QI 0 "reg_operand" "r"))]
1414 [(set_attr "type" "push")])
1416 (define_insn "push_st"
1417 [(set (mem:QI (pre_inc:QI (reg:QI 20))) (unspec:QI [(reg:QI 21)] 14))
1421 [(set_attr "type" "push")])
1423 (define_insn "push_dp"
1424 [(set (mem:QI (pre_inc:QI (reg:QI 20))) (unspec:QI [(reg:QI 16)] 16))
1428 [(set_attr "type" "push")])
1430 (define_insn "popqi"
1431 [(set (match_operand:QI 0 "reg_operand" "=r")
1432 (mem:QI (post_dec:QI (reg:QI 20))))
1433 (clobber (reg:CC 21))]
1436 [(set_attr "type" "pop")])
1438 (define_insn "pop_st"
1439 [(set (unspec:QI [(reg:QI 21)] 15) (mem:QI (post_dec:QI (reg:QI 20))))
1440 (clobber (reg:CC 21))]
1443 [(set_attr "type" "pop")])
1445 (define_insn "pop_dp"
1446 [(set (unspec:QI [(reg:QI 16)] 17) (mem:QI (post_dec:QI (reg:QI 20))))
1447 (clobber (reg:CC 16))]
1450 [(set_attr "type" "pop")])
1452 (define_insn "popqi_unspec"
1453 [(set (unspec:QI [(match_operand:QI 0 "reg_operand" "=r")] 18)
1454 (mem:QI (post_dec:QI (reg:QI 20))))
1455 (clobber (match_dup 0))
1456 (clobber (reg:CC 21))]
1459 [(set_attr "type" "pop")])
1464 (define_expand "absqi2"
1465 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
1466 (abs:QI (match_operand:QI 1 "src_operand" "")))
1467 (clobber (reg:CC_NOOV 21))])]
1471 (define_insn "*absqi2_clobber"
1472 [(set (match_operand:QI 0 "reg_operand" "=d,c")
1473 (abs:QI (match_operand:QI 1 "src_operand" "rIm,rIm")))
1474 (clobber (reg:CC_NOOV 21))]
1477 [(set_attr "type" "unarycc,unary")
1478 (set_attr "data" "int16,int16")])
1480 (define_insn "*absqi2_noclobber"
1481 [(set (match_operand:QI 0 "std_reg_operand" "=c")
1482 (abs:QI (match_operand:QI 1 "src_operand" "rIm")))]
1485 [(set_attr "type" "unary")
1486 (set_attr "data" "int16")])
1489 [(set (match_operand:QI 0 "std_reg_operand" "")
1490 (abs:QI (match_operand:QI 1 "src_operand" "")))
1491 (clobber (reg:CC_NOOV 21))]
1494 (abs:QI (match_dup 1)))]
1497 (define_insn "*absqi2_test"
1498 [(set (reg:CC_NOOV 21)
1499 (compare:CC_NOOV (abs:QI (match_operand:QI 1 "src_operand" "rIm"))
1501 (clobber (match_scratch:QI 0 "=d"))]
1504 [(set_attr "type" "unarycc")
1505 (set_attr "data" "int16")])
1507 (define_insn "*absqi2_set"
1508 [(set (reg:CC_NOOV 21)
1509 (compare:CC_NOOV (abs:QI (match_operand:QI 1 "src_operand" "rIm"))
1511 (set (match_operand:QI 0 "ext_reg_operand" "=d")
1512 (abs:QI (match_dup 1)))]
1515 [(set_attr "type" "unarycc")
1516 (set_attr "data" "int16")])
1521 (define_expand "negqi2"
1522 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
1523 (neg:QI (match_operand:QI 1 "src_operand" "")))
1524 (clobber (reg:CC_NOOV 21))])]
1528 (define_insn "*negqi2_clobber"
1529 [(set (match_operand:QI 0 "reg_operand" "=d,c")
1530 (neg:QI (match_operand:QI 1 "src_operand" "rIm,rIm")))
1531 (clobber (reg:CC_NOOV 21))]
1534 [(set_attr "type" "unarycc,unary")
1535 (set_attr "data" "int16,int16")])
1537 (define_insn "*negqi2_noclobber"
1538 [(set (match_operand:QI 0 "std_reg_operand" "=c")
1539 (neg:QI (match_operand:QI 1 "src_operand" "rIm")))]
1542 [(set_attr "type" "unary")
1543 (set_attr "data" "int16")])
1546 [(set (match_operand:QI 0 "std_reg_operand" "")
1547 (neg:QI (match_operand:QI 1 "src_operand" "")))
1548 (clobber (reg:CC_NOOV 21))]
1551 (neg:QI (match_dup 1)))]
1554 (define_insn "*negqi2_test"
1555 [(set (reg:CC_NOOV 21)
1556 (compare:CC_NOOV (neg:QI (match_operand:QI 1 "src_operand" "rIm"))
1558 (clobber (match_scratch:QI 0 "=d"))]
1561 [(set_attr "type" "unarycc")
1562 (set_attr "data" "int16")])
1564 (define_insn "*negqi2_set"
1565 [(set (reg:CC_NOOV 21)
1566 (compare:CC_NOOV (neg:QI (match_operand:QI 1 "src_operand" "rIm"))
1568 (set (match_operand:QI 0 "ext_reg_operand" "=d")
1569 (neg:QI (match_dup 1)))]
1572 [(set_attr "type" "unarycc")
1573 (set_attr "data" "int16")])
1575 (define_insn "*negbqi2_clobber"
1576 [(set (match_operand:QI 0 "ext_reg_operand" "=d")
1577 (neg:QI (match_operand:QI 1 "src_operand" "rIm")))
1578 (use (reg:CC_NOOV 21))
1579 (clobber (reg:CC_NOOV 21))]
1582 [(set_attr "type" "unarycc")
1583 (set_attr "data" "int16")])
1588 (define_expand "one_cmplqi2"
1589 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
1590 (not:QI (match_operand:QI 1 "lsrc_operand" "")))
1591 (clobber (reg:CC 21))])]
1595 (define_insn "*one_cmplqi2_clobber"
1596 [(set (match_operand:QI 0 "reg_operand" "=d,c")
1597 (not:QI (match_operand:QI 1 "lsrc_operand" "rLm,rLm")))
1598 (clobber (reg:CC 21))]
1601 [(set_attr "type" "unarycc,unary")
1602 (set_attr "data" "uint16,uint16")])
1604 (define_insn "*one_cmplqi2_noclobber"
1605 [(set (match_operand:QI 0 "std_reg_operand" "=c")
1606 (not:QI (match_operand:QI 1 "lsrc_operand" "rLm")))]
1609 [(set_attr "type" "unary")
1610 (set_attr "data" "uint16")])
1613 [(set (match_operand:QI 0 "std_reg_operand" "")
1614 (not:QI (match_operand:QI 1 "lsrc_operand" "")))
1615 (clobber (reg:CC 21))]
1618 (not:QI (match_dup 1)))]
1621 (define_insn "*one_cmplqi2_test"
1623 (compare:CC (not:QI (match_operand:QI 1 "lsrc_operand" "rLm"))
1625 (clobber (match_scratch:QI 0 "=d"))]
1628 [(set_attr "type" "unarycc")
1629 (set_attr "data" "uint16")])
1631 (define_insn "*one_cmplqi2_set"
1633 (compare:CC (not:QI (match_operand:QI 1 "lsrc_operand" "rLm"))
1635 (set (match_operand:QI 0 "ext_reg_operand" "=d")
1636 (not:QI (match_dup 1)))]
1639 [(set_attr "type" "unarycc")
1640 (set_attr "data" "uint16")])
1642 (define_insn "*one_cmplqi2_const_clobber"
1643 [(set (match_operand:QI 0 "reg_operand" "=d,c")
1644 (match_operand:QI 1 "not_const_operand" "N,N"))
1645 (clobber (reg:CC 21))]
1650 [(set_attr "type" "unarycc,unary")
1651 (set_attr "data" "not_uint16,not_uint16")])
1653 ; movqi can use this for loading an integer that can't normally
1654 ; fit into a 16-bit signed integer. The drawback is that it cannot
1655 ; go into R0-R11 since that will clobber the CC and movqi shouldn't
1656 ; do that. This can cause additional reloading but in most cases
1657 ; this will cause only an additional register move. With the large
1658 ; memory model we require an extra instruction to load DP anyway,
1659 ; if we're loading the constant from memory. The big advantage of
1660 ; allowing constants that satisfy not_const_operand in movqi, is that
1661 ; it allows andn to be generated more often.
1662 ; However, there is a problem if GCC has decided that it wants
1663 ; to use R0-R11, since we won't have a matching pattern...
1664 ; In interim, we prevent immed_const allowing `N' constants.
1665 (define_insn "*one_cmplqi2_const_noclobber"
1666 [(set (match_operand:QI 0 "std_reg_operand" "=c")
1667 (match_operand:QI 1 "not_const_operand" "N"))]
1670 [(set_attr "type" "unary")
1671 (set_attr "data" "not_uint16")])
1676 (define_expand "rotlqi3"
1677 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
1678 (rotate:QI (match_operand:QI 1 "reg_operand" "")
1679 (match_operand:QI 2 "const_int_operand" "")))
1680 (clobber (reg:CC 21))])]
1682 "if (INTVAL (operands[2]) > 4)
1683 FAIL; /* Open code as two shifts and an or */
1684 if (INTVAL (operands[2]) > 1)
1689 /* If we have 4 or fewer shifts, then it is probably faster
1690 to emit separate ROL instructions. A C3x requires
1691 at least 4 instructions (a C4x requires at least 3), to
1692 perform a rotation by shifts. */
1695 for (i = 0; i < INTVAL (operands[2]) - 1; i++)
1697 tmp = gen_reg_rtx (QImode);
1698 emit_insn (gen_rotl_1_clobber (tmp, operands[1]));
1701 emit_insn (gen_rotl_1_clobber (operands[0], tmp));
1705 (define_insn "rotl_1_clobber"
1706 [(set (match_operand:QI 0 "reg_operand" "=d,c")
1707 (rotate:QI (match_operand:QI 1 "reg_operand" "0,0")
1709 (clobber (reg:CC 21))]
1712 [(set_attr "type" "unarycc,unary")])
1713 ; Default to int16 data attr.
1718 (define_expand "rotrqi3"
1719 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
1720 (rotatert:QI (match_operand:QI 1 "reg_operand" "")
1721 (match_operand:QI 2 "const_int_operand" "")))
1722 (clobber (reg:CC 21))])]
1724 "if (INTVAL (operands[2]) > 4)
1725 FAIL; /* Open code as two shifts and an or */
1726 if (INTVAL (operands[2]) > 1)
1731 /* If we have 4 or fewer shifts, then it is probably faster
1732 to emit separate ROL instructions. A C3x requires
1733 at least 4 instructions (a C4x requires at least 3), to
1734 perform a rotation by shifts. */
1737 for (i = 0; i < INTVAL (operands[2]) - 1; i++)
1739 tmp = gen_reg_rtx (QImode);
1740 emit_insn (gen_rotr_1_clobber (tmp, operands[1]));
1743 emit_insn (gen_rotr_1_clobber (operands[0], tmp));
1747 (define_insn "rotr_1_clobber"
1748 [(set (match_operand:QI 0 "reg_operand" "=d,c")
1749 (rotatert:QI (match_operand:QI 1 "reg_operand" "0,0")
1751 (clobber (reg:CC 21))]
1754 [(set_attr "type" "unarycc,unary")])
1755 ; Default to int16 data attr.
1759 ; THREE OPERAND INTEGER INSTRUCTIONS
1765 ; This is used by reload when it calls gen_add2_insn for address arithmetic
1766 ; so we must emit the pattern that doesn't clobber CC.
1768 (define_expand "addqi3"
1769 [(parallel [(set (match_operand:QI 0 "std_or_reg_operand" "")
1770 (plus:QI (match_operand:QI 1 "src_operand" "")
1771 (match_operand:QI 2 "src_operand" "")))
1772 (clobber (reg:CC_NOOV 21))])]
1774 "legitimize_operands (PLUS, operands, QImode);
1775 if (reload_in_progress
1776 || (! IS_PSEUDO_REG (operands[0])
1777 && ! IS_EXT_REG (operands[0])))
1779 emit_insn (gen_addqi3_noclobber (operands[0], operands[1], operands[2]));
1783 (define_insn "*addqi3_clobber"
1784 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
1785 (plus:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>,0,rR,rS<>")
1786 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>,rIm,JR,rS<>")))
1787 (clobber (reg:CC_NOOV 21))]
1788 "valid_operands (PLUS, operands, QImode)"
1796 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
1797 ; Default to int16 data attr.
1800 [(set (match_operand:QI 0 "std_reg_operand" "")
1801 (plus:QI (match_operand:QI 1 "src_operand" "")
1802 (match_operand:QI 2 "src_operand" "")))
1803 (clobber (reg:CC_NOOV 21))]
1806 (plus:QI (match_dup 1)
1810 (define_insn "*addqi3_test"
1811 [(set (reg:CC_NOOV 21)
1812 (compare:CC_NOOV (plus:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
1813 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>"))
1815 (clobber (match_scratch:QI 0 "=d,d,d"))]
1816 "valid_operands (PLUS, operands, QImode)"
1821 [(set_attr "type" "binarycc,binarycc,binarycc")])
1822 ; Default to int16 data attr.
1824 ; gcc does this in combine.c we just reverse it here
1825 (define_insn "*cmp_neg"
1826 [(set (reg:CC_NOOV 21)
1827 (compare:CC_NOOV (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
1828 (neg: QI (match_operand:QI 2 "src_operand" "g,JR,rS<>"))))
1829 (clobber (match_scratch:QI 0 "=d,d,d"))]
1830 "valid_operands (PLUS, operands, QImode)"
1835 [(set_attr "type" "binarycc,binarycc,binarycc")])
1838 [(parallel [(set (match_operand:QI 0 "ext_reg_operand" "=d,d,d")
1839 (plus:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
1840 (match_operand:QI 2 "src_operand" "g,JR,rS<>")))
1841 (clobber (reg:CC_NOOV 21))])
1842 (set (reg:CC_NOOV 21)
1843 (compare:CC_NOOV (match_dup 0) (const_int 0)))]
1844 "valid_operands (PLUS, operands, QImode)"
1849 [(set_attr "type" "binarycc,binarycc,binarycc")])
1851 (define_insn "*addqi3_set"
1852 [(set (reg:CC_NOOV 21)
1853 (compare:CC_NOOV (plus:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
1854 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>"))
1856 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d")
1857 (plus:QI (match_dup 1) (match_dup 2)))]
1858 "valid_operands (PLUS, operands, QImode)"
1863 [(set_attr "type" "binarycc,binarycc,binarycc")])
1864 ; Default to int16 data attr.
1866 ; This pattern is required primarily for manipulating the stack pointer
1867 ; where GCC doesn't expect CC to be clobbered or for calculating
1868 ; addresses during reload.
1869 (define_insn "addqi3_noclobber"
1870 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,c")
1871 (plus:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
1872 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>")))]
1873 "valid_operands (PLUS, operands, QImode)"
1878 [(set_attr "type" "binary,binary,binary")])
1879 ; Default to int16 data attr.
1882 ; This pattern is required during reload when eliminate_regs_in_insn
1883 ; effectively converts a move insn into an add insn when the src
1884 ; operand is the frame pointer plus a constant. Without this
1885 ; pattern, gen_addqi3 can be called with a register for operand0
1886 ; that can clobber CC.
1887 ; For example, we may have (set (mem (reg ar0)) (reg 99))
1888 ; with (set (reg 99) (plus (reg ar3) (const_int 8)))
1889 ; Now since ar3, the frame pointer, is unchanging within the function,
1890 ; (plus (reg ar3) (const_int 8)) is considered a constant.
1891 ; eliminate_regs_in_insn substitutes this constant to give
1892 ; (set (mem (reg ar0)) (plus (reg ar3) (const_int 8))).
1893 ; This is an invalid C4x insn but if we don't provide a pattern
1894 ; for it, it will be considered to be a move insn for reloading.
1895 (define_insn "*addqi3_noclobber_reload"
1896 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,c")
1897 (plus:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
1898 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>")))]
1899 "reload_in_progress"
1904 [(set_attr "type" "binary,binary,binary")])
1905 ; Default to int16 data attr.
1908 (define_insn "*addqi3_carry_clobber"
1909 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
1910 (plus:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>,0,rR,rS<>")
1911 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>,rIm,JR,rS<>")))
1912 (use (reg:CC_NOOV 21))
1913 (clobber (reg:CC_NOOV 21))]
1914 "valid_operands (PLUS, operands, QImode)"
1922 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
1923 ; Default to int16 data attr.
1929 (define_expand "subqi3"
1930 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
1931 (minus:QI (match_operand:QI 1 "src_operand" "")
1932 (match_operand:QI 2 "src_operand" "")))
1933 (clobber (reg:CC_NOOV 21))])]
1935 "legitimize_operands (MINUS, operands, QImode);")
1937 (define_insn "*subqi3_clobber"
1938 [(set (match_operand:QI 0 "reg_operand" "=d,d,d,?d,c,c,c,?c")
1939 (minus:QI (match_operand:QI 1 "src_operand" "0,rIm,rR,rS<>,0,rIm,rR,rS<>")
1940 (match_operand:QI 2 "src_operand" "rIm,0,JR,rS<>,rIm,0,JR,rS<>")))
1941 (clobber (reg:CC_NOOV 21))]
1942 "valid_operands (MINUS, operands, QImode)"
1952 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc,binary,binary,binary,binary")])
1953 ; Default to int16 data attr.
1956 [(set (match_operand:QI 0 "std_reg_operand" "")
1957 (minus:QI (match_operand:QI 1 "src_operand" "")
1958 (match_operand:QI 2 "src_operand" "")))
1959 (clobber (reg:CC_NOOV 21))]
1962 (minus:QI (match_dup 1)
1966 (define_insn "*subqi3_test"
1967 [(set (reg:CC_NOOV 21)
1968 (compare:CC_NOOV (minus:QI (match_operand:QI 1 "src_operand" "0,rIm,rR,rS<>")
1969 (match_operand:QI 2 "src_operand" "rIm,0,JR,rS<>"))
1971 (clobber (match_scratch:QI 0 "=d,d,d,?d"))]
1972 "valid_operands (MINUS, operands, QImode)"
1978 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
1979 ; Default to int16 data attr.
1982 [(parallel [(set (match_operand:QI 0 "ext_reg_operand" "=d,d,d,?d")
1983 (minus:QI (match_operand:QI 1 "src_operand" "0,rIm,rR,rS<>")
1984 (match_operand:QI 2 "src_operand" "rIm,0,JR,rS<>")))
1985 (clobber (reg:CC_NOOV 21))])
1986 (set (reg:CC_NOOV 21)
1987 (compare:CC_NOOV (match_dup 0) (const_int 0)))]
1988 "valid_operands (MINUS, operands, QImode)"
1994 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
1996 (define_insn "*subqi3_set"
1997 [(set (reg:CC_NOOV 21)
1998 (compare:CC_NOOV (minus:QI (match_operand:QI 1 "src_operand" "0,rIm,rR,rS<>")
1999 (match_operand:QI 2 "src_operand" "rIm,0,JR,rS<>"))
2001 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d,?d")
2002 (minus:QI (match_dup 1)
2004 "valid_operands (MINUS, operands, QImode)"
2010 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
2011 ; Default to int16 data attr.
2013 (define_insn "*subqi3_noclobber"
2014 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,c,?c")
2015 (minus:QI (match_operand:QI 1 "src_operand" "0,rIm,rR,rS<>")
2016 (match_operand:QI 2 "src_operand" "rIm,0,JR,rS<>")))]
2017 "valid_operands (MINUS, operands, QImode)"
2023 [(set_attr "type" "binary,binary,binary,binary")])
2024 ; Default to int16 data attr.
2026 (define_insn "*subqi3_carry_clobber"
2027 [(set (match_operand:QI 0 "reg_operand" "=d,d,d,?d,c,c,c,?c")
2028 (minus:QI (match_operand:QI 1 "src_operand" "0,rIm,rR,rS<>,0,rIm,rR,rS<>")
2029 (match_operand:QI 2 "src_operand" "rIm,0,JR,rS<>,rIm,0,JR,rS<>")))
2030 (use (reg:CC_NOOV 21))
2031 (clobber (reg:CC_NOOV 21))]
2032 "valid_operands (MINUS, operands, QImode)"
2042 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc,binary,binary,binary,binary")])
2043 ; Default to int16 data attr.
2045 (define_insn "*subqi3_carry_set"
2046 [(set (reg:CC_NOOV 21)
2047 (compare:CC_NOOV (minus:QI (match_operand:QI 1 "src_operand" "0,rIm,rR,rS<>")
2048 (match_operand:QI 2 "src_operand" "rIm,0,JR,rS<>"))
2050 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d,?d")
2051 (minus:QI (match_dup 1)
2053 (use (reg:CC_NOOV 21))]
2054 "valid_operands (MINUS, operands, QImode)"
2060 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
2061 ; Default to int16 data attr.
2066 (define_expand "mulqi3"
2067 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2068 (mult:QI (match_operand:QI 1 "src_operand" "")
2069 (match_operand:QI 2 "src_operand" "")))
2070 (clobber (reg:CC_NOOV 21))])]
2072 "if (TARGET_MPYI || (GET_CODE (operands[2]) == CONST_INT
2073 && exact_log2 (INTVAL (operands[2])) >= 0))
2074 legitimize_operands (MULT, operands, QImode);
2077 if (GET_CODE (operands[2]) == CONST_INT)
2079 /* Let GCC try to synthesize the multiplication using shifts
2080 and adds. In most cases this will be more profitable than
2081 using the C3x MPYI. */
2084 if (operands[1] == operands[2])
2086 /* Do the squaring operation in-line. */
2087 emit_insn (gen_sqrqi2_inline (operands[0], operands[1]));
2092 emit_insn (gen_mulqi3_inline (operands[0], operands[1],
2096 c4x_emit_libcall3 (smul_optab->handlers[(int) QImode].libfunc,
2097 MULT, QImode, operands);
2102 (define_insn "*mulqi3_clobber"
2103 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2104 (mult:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>,0,rR,rS<>")
2105 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>,rIm,JR,rS<>")))
2106 (clobber (reg:CC_NOOV 21))]
2107 "valid_operands (MULT, operands, QImode)"
2109 if (which_alternative == 0 || which_alternative == 3)
2112 && GET_CODE (operands[2]) == CONST_INT
2113 && exact_log2 (INTVAL (operands[2])) >= 0)
2114 return \"ash\\t%L2,%0\";
2116 return \"mpyi\\t%2,%0\";
2119 return \"mpyi3\\t%2,%1,%0\";"
2120 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
2121 ; Default to int16 data attr.
2123 (define_insn "*mulqi3_test"
2124 [(set (reg:CC_NOOV 21)
2125 (compare:CC_NOOV (mult:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2126 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>"))
2128 (clobber (match_scratch:QI 0 "=d,d,d"))]
2129 "valid_operands (MULT, operands, QImode)"
2131 if (which_alternative == 0)
2134 && GET_CODE (operands[2]) == CONST_INT
2135 && exact_log2 (INTVAL (operands[2])) >= 0)
2136 return \"ash\\t%L2,%0\";
2138 return \"mpyi\\t%2,%0\";
2141 return \"mpyi3\\t%2,%1,%0\";"
2142 [(set_attr "type" "binarycc,binarycc,binarycc")])
2143 ; Default to int16 data attr.
2145 (define_insn "*mulqi3_set"
2146 [(set (reg:CC_NOOV 21)
2147 (compare:CC_NOOV (mult:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2148 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>"))
2150 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d")
2151 (mult:QI (match_dup 1)
2153 "valid_operands (MULT, operands, QImode)"
2155 if (which_alternative == 0)
2158 && GET_CODE (operands[2]) == CONST_INT
2159 && exact_log2 (INTVAL (operands[2])) >= 0)
2160 return \"ash\\t%L2,%0\";
2162 return \"mpyi\\t%2,%0\";
2165 return \"mpyi3\\t%2,%1,%0\";"
2166 [(set_attr "type" "binarycc,binarycc,binarycc")])
2167 ; Default to int16 data attr.
2169 ; The C3x multiply instruction assumes 24-bit signed integer operands
2170 ; and the 48-bit result is truncated to 32-bits.
2171 (define_insn "mulqi3_24_clobber"
2172 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2175 (and:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>,0,rR,rS<>")
2176 (const_int 16777215)))
2178 (and:QI (match_operand:QI 2 "src_operand" "rIm,JR,rS<>,rIm,JR,rS<>")
2179 (const_int 16777215)))))
2180 (clobber (reg:CC_NOOV 21))]
2181 "TARGET_C3X && valid_operands (MULT, operands, QImode)"
2189 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
2190 ; Default to int16 data attr.
2193 ; Fast square function for C3x where TARGET_MPYI not asserted
2194 (define_expand "sqrqi2_inline"
2195 [(set (match_dup 7) (match_operand:QI 1 "src_operand" ""))
2196 (parallel [(set (match_dup 3)
2197 (lshiftrt:QI (match_dup 7) (const_int 16)))
2198 (clobber (reg:CC 21))])
2199 (parallel [(set (match_dup 2)
2200 (and:QI (match_dup 7) (const_int 65535)))
2201 (clobber (reg:CC 21))])
2202 (parallel [(set (match_dup 4)
2203 (mult:QI (sign_extend:QI (and:QI (match_dup 2)
2204 (const_int 16777215)))
2205 (sign_extend:QI (and:QI (match_dup 2)
2206 (const_int 16777215)))))
2207 (clobber (reg:CC_NOOV 21))])
2208 (parallel [(set (match_dup 5)
2209 (mult:QI (sign_extend:QI (and:QI (match_dup 2)
2210 (const_int 16777215)))
2211 (sign_extend:QI (and:QI (match_dup 3)
2212 (const_int 16777215)))))
2213 (clobber (reg:CC_NOOV 21))])
2214 (parallel [(set (match_dup 6)
2215 (ashift:QI (match_dup 5) (const_int 17)))
2216 (clobber (reg:CC 21))])
2217 (parallel [(set (match_operand:QI 0 "reg_operand" "")
2218 (plus:QI (match_dup 4) (match_dup 6)))
2219 (clobber (reg:CC_NOOV 21))])]
2222 operands[2] = gen_reg_rtx (QImode); /* a = val & 0xffff */
2223 operands[3] = gen_reg_rtx (QImode); /* b = val >> 16 */
2224 operands[4] = gen_reg_rtx (QImode); /* a * a */
2225 operands[5] = gen_reg_rtx (QImode); /* a * b */
2226 operands[6] = gen_reg_rtx (QImode); /* (a * b) << 17 */
2227 operands[7] = gen_reg_rtx (QImode); /* val */
2230 ; Inlined integer multiply for C3x
2231 (define_expand "mulqi3_inline"
2232 [(set (match_dup 12) (const_int -16))
2233 (set (match_dup 13) (match_operand:QI 1 "src_operand" ""))
2234 (set (match_dup 14) (match_operand:QI 2 "src_operand" ""))
2235 (parallel [(set (match_dup 4)
2236 (lshiftrt:QI (match_dup 13) (neg:QI (match_dup 12))))
2237 (clobber (reg:CC 21))])
2238 (parallel [(set (match_dup 6)
2239 (lshiftrt:QI (match_dup 14) (neg:QI (match_dup 12))))
2240 (clobber (reg:CC 21))])
2241 (parallel [(set (match_dup 3)
2242 (and:QI (match_dup 13)
2244 (clobber (reg:CC 21))])
2245 (parallel [(set (match_dup 5)
2246 (and:QI (match_dup 14)
2248 (clobber (reg:CC 21))])
2249 (parallel [(set (match_dup 7)
2250 (mult:QI (sign_extend:QI (and:QI (match_dup 4)
2251 (const_int 16777215)))
2252 (sign_extend:QI (and:QI (match_dup 5)
2253 (const_int 16777215)))))
2254 (clobber (reg:CC_NOOV 21))])
2255 (parallel [(set (match_dup 8)
2256 (mult:QI (sign_extend:QI (and:QI (match_dup 3)
2257 (const_int 16777215)))
2258 (sign_extend:QI (and:QI (match_dup 5)
2259 (const_int 16777215)))))
2260 (clobber (reg:CC_NOOV 21))])
2261 (parallel [(set (match_dup 9)
2262 (mult:QI (sign_extend:QI (and:QI (match_dup 3)
2263 (const_int 16777215)))
2264 (sign_extend:QI (and:QI (match_dup 6)
2265 (const_int 16777215)))))
2266 (clobber (reg:CC_NOOV 21))])
2267 (parallel [(set (match_dup 10)
2268 (plus:QI (match_dup 7) (match_dup 9)))
2269 (clobber (reg:CC_NOOV 21))])
2270 (parallel [(set (match_dup 11)
2271 (ashift:QI (match_dup 10) (const_int 16)))
2272 (clobber (reg:CC 21))])
2273 (parallel [(set (match_operand:QI 0 "reg_operand" "")
2274 (plus:QI (match_dup 8) (match_dup 11)))
2275 (clobber (reg:CC_NOOV 21))])]
2278 operands[3] = gen_reg_rtx (QImode); /* a = arg1 & 0xffff */
2279 operands[4] = gen_reg_rtx (QImode); /* b = arg1 >> 16 */
2280 operands[5] = gen_reg_rtx (QImode); /* a = arg2 & 0xffff */
2281 operands[6] = gen_reg_rtx (QImode); /* b = arg2 >> 16 */
2282 operands[7] = gen_reg_rtx (QImode); /* b * c */
2283 operands[8] = gen_reg_rtx (QImode); /* a * c */
2284 operands[9] = gen_reg_rtx (QImode); /* a * d */
2285 operands[10] = gen_reg_rtx (QImode); /* b * c + a * d */
2286 operands[11] = gen_reg_rtx (QImode); /* (b *c + a * d) << 16 */
2287 operands[12] = gen_reg_rtx (QImode); /* -16 */
2288 operands[13] = gen_reg_rtx (QImode); /* arg1 */
2289 operands[14] = gen_reg_rtx (QImode); /* arg2 */
2295 (define_expand "smulqi3_highpart"
2296 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2300 (sign_extend:HI (match_operand:QI 1 "src_operand" ""))
2301 (sign_extend:HI (match_operand:QI 2 "src_operand" "")))
2303 (clobber (reg:CC_NOOV 21))])]
2305 "legitimize_operands (MULT, operands, QImode);
2308 c4x_emit_libcall_mulhi (smulhi3_libfunc, SIGN_EXTEND, QImode, operands);
2313 (define_insn "*smulqi3_highpart_clobber"
2314 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2318 (sign_extend:HI (match_operand:QI 1 "src_operand" "%0,rR,rS<>,0,rR,rS<>"))
2319 (sign_extend:HI (match_operand:QI 2 "src_operand" "rIm,JR,rS<>,rIm,JR,rS<>")))
2321 (clobber (reg:CC_NOOV 21))]
2322 "! TARGET_C3X && valid_operands (MULT, operands, QImode)"
2330 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")
2331 (set_attr "data" "int16,int16,int16,int16,int16,int16")])
2333 (define_insn "*smulqi3_highpart_noclobber"
2334 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,?c")
2338 (sign_extend:HI (match_operand:QI 1 "src_operand" "0,rR,rS<>"))
2339 (sign_extend:HI (match_operand:QI 2 "src_operand" "rIm,JR,rS<>")))
2341 "! TARGET_C3X && valid_operands (MULT, operands, QImode)"
2346 [(set_attr "type" "binary,binary,binary")
2347 (set_attr "data" "int16,int16,int16")])
2352 (define_expand "umulqi3_highpart"
2353 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2357 (zero_extend:HI (match_operand:QI 1
2358 "nonimmediate_src_operand" ""))
2359 (zero_extend:HI (match_operand:QI 2
2360 "nonimmediate_lsrc_operand" "")))
2362 (clobber (reg:CC_NOOV 21))])]
2364 "legitimize_operands (MULT, operands, QImode);
2367 c4x_emit_libcall_mulhi (umulhi3_libfunc, ZERO_EXTEND, QImode, operands);
2372 (define_insn "*umulqi3_highpart_clobber"
2373 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2377 (zero_extend:HI (match_operand:QI 1
2378 "nonimmediate_src_operand" "%0,rR,rS<>,0,rR,rS<>"))
2379 (zero_extend:HI (match_operand:QI 2
2380 "nonimmediate_lsrc_operand" "rm,R,rS<>,rm,R,rS<>")))
2382 (clobber (reg:CC_NOOV 21))]
2383 "! TARGET_C3X && valid_operands (MULT, operands, QImode)"
2391 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")
2392 (set_attr "data" "uint16,uint16,uint16,uint16,uint16,uint16")])
2394 (define_insn "*umulqi3_highpart_noclobber"
2395 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,?c")
2399 (zero_extend:HI (match_operand:QI 1
2400 "nonimmediate_src_operand" "0,rR,rS<>"))
2401 (zero_extend:HI (match_operand:QI 2
2402 "nonimmediate_lsrc_operand" "rm,R,rS<>")))
2404 "! TARGET_C3X && valid_operands (MULT, operands, QImode)"
2409 [(set_attr "type" "binary,binary,binary")
2410 (set_attr "data" "uint16,uint16,uint16")])
2415 (define_expand "andqi3"
2416 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2417 (and:QI (match_operand:QI 1 "src_operand" "")
2418 (match_operand:QI 2 "tsrc_operand" "")))
2419 (clobber (reg:CC 21))])]
2421 "legitimize_operands (AND, operands, QImode);")
2424 (define_insn "*andqi3_255_clobber"
2425 [(set (match_operand:QI 0 "reg_operand" "=d,c")
2426 (and:QI (match_operand:QI 1 "src_operand" "mr,mr")
2428 (clobber (reg:CC 21))]
2431 [(set_attr "type" "unarycc,unary")])
2433 (define_insn "*andqi3_255_noclobber"
2434 [(set (match_operand:QI 0 "reg_operand" "=c")
2435 (and:QI (match_operand:QI 1 "src_operand" "mr")
2439 [(set_attr "type" "unary")])
2442 (define_insn "*andqi3_65535_clobber"
2443 [(set (match_operand:QI 0 "reg_operand" "=d,c")
2444 (and:QI (match_operand:QI 1 "src_operand" "mr,mr")
2446 (clobber (reg:CC 21))]
2449 [(set_attr "type" "unarycc,unary")])
2451 (define_insn "*andqi3_65535_noclobber"
2452 [(set (match_operand:QI 0 "reg_operand" "=c")
2453 (and:QI (match_operand:QI 1 "src_operand" "mr")
2454 (const_int 65535)))]
2457 [(set_attr "type" "unary")])
2459 (define_insn "*andqi3_clobber"
2460 [(set (match_operand:QI 0 "reg_operand" "=d,d,d,?d,c,c,c,?c")
2461 (and:QI (match_operand:QI 1 "src_operand" "%0,0,rR,rS<>,0,0,rR,rS<>")
2462 (match_operand:QI 2 "tsrc_operand" "N,rLm,JR,rS<>,N,rLm,JR,rS<>")))
2463 (clobber (reg:CC 21))]
2464 "valid_operands (AND, operands, QImode)"
2474 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc,binary,binary,binary,binary")
2475 (set_attr "data" "not_uint16,uint16,int16,uint16,not_uint16,uint16,int16,uint16")])
2477 (define_insn "*andqi3_noclobber"
2478 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,c,?c")
2479 (and:QI (match_operand:QI 1 "src_operand" "%0,0,rR,rS<>")
2480 (match_operand:QI 2 "tsrc_operand" "N,rLm,JR,rS<>")))]
2481 "valid_operands (AND, operands, QImode)"
2487 [(set_attr "type" "binary,binary,binary,binary")
2488 (set_attr "data" "not_uint16,uint16,int16,uint16")])
2490 (define_insn "andn_st"
2491 [(set (unspec:QI [(reg:QI 21)] 20)
2492 (and:QI (unspec:QI [(reg:QI 21)] 20)
2493 (match_operand:QI 0 "" "N")))
2496 (clobber (reg:CC 21))]
2499 [(set_attr "type" "misc")
2500 (set_attr "data" "not_uint16")])
2503 [(set (match_operand:QI 0 "std_reg_operand" "")
2504 (and:QI (match_operand:QI 1 "src_operand" "")
2505 (match_operand:QI 2 "tsrc_operand" "")))
2506 (clobber (reg:CC 21))]
2509 (and:QI (match_dup 1)
2513 (define_insn "*andqi3_test"
2515 (compare:CC (and:QI (match_operand:QI 1 "src_operand" "%0,r,rR,rS<>")
2516 (match_operand:QI 2 "tsrc_operand" "N,rLm,JR,rS<>"))
2518 (clobber (match_scratch:QI 0 "=d,X,X,?X"))]
2519 "valid_operands (AND, operands, QImode)"
2525 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")
2526 (set_attr "data" "not_uint16,uint16,int16,uint16")])
2529 [(parallel [(set (match_operand:QI 0 "ext_reg_operand" "=d,d,d,?d")
2530 (and:QI (match_operand:QI 1 "src_operand" "%0,0,rR,rS<>")
2531 (match_operand:QI 2 "tsrc_operand" "N,rLm,JR,rS<>")))
2532 (clobber (reg:CC 21))])
2534 (compare:CC (match_dup 0) (const_int 0)))]
2535 "valid_operands (AND, operands, QImode)"
2541 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")
2542 (set_attr "data" "not_uint16,uint16,int16,uint16")])
2544 (define_insn "*andqi3_set"
2546 (compare:CC (and:QI (match_operand:QI 1 "src_operand" "%0,0,rR,rS<>")
2547 (match_operand:QI 2 "tsrc_operand" "N,rLm,JR,rS<>"))
2549 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d,?d")
2550 (and:QI (match_dup 1)
2552 "valid_operands (AND, operands, QImode)"
2558 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")
2559 (set_attr "data" "not_uint16,uint16,int16,uint16")])
2564 ; NB, this insn doesn't have commutative operands, but valid_operands
2565 ; assumes that the code AND does. We might have to kludge this if
2566 ; we make valid_operands stricter.
2567 (define_insn "*andnqi3_clobber"
2568 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2569 (and:QI (not:QI (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>,rLm,JR,rS<>"))
2570 (match_operand:QI 1 "src_operand" "0,rR,rS<>,0,rR,rS<>")))
2571 (clobber (reg:CC 21))]
2572 "valid_operands (AND, operands, QImode)"
2580 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")
2581 (set_attr "data" "uint16,int16,uint16,uint16,int16,uint16")])
2583 (define_insn "*andnqi3_noclobber"
2584 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,?c")
2585 (and:QI (not:QI (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>"))
2586 (match_operand:QI 1 "src_operand" "0,rR,rS<>")))]
2587 "valid_operands (AND, operands, QImode)"
2592 [(set_attr "type" "binary,binary,binary")
2593 (set_attr "data" "uint16,int16,uint16")])
2596 [(set (match_operand:QI 0 "std_reg_operand" "")
2597 (and:QI (not:QI (match_operand:QI 2 "lsrc_operand" ""))
2598 (match_operand:QI 1 "src_operand" "")))
2599 (clobber (reg:CC 21))]
2602 (and:QI (not:QI (match_dup 2))
2606 (define_insn "*andnqi3_test"
2608 (compare:CC (and:QI (not:QI (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>"))
2609 (match_operand:QI 1 "src_operand" "0,rR,rS<>"))
2611 (clobber (match_scratch:QI 0 "=d,d,d"))]
2612 "valid_operands (AND, operands, QImode)"
2617 [(set_attr "type" "binarycc,binarycc,binarycc")
2618 (set_attr "data" "uint16,int16,uint16")])
2620 (define_insn "*andnqi3_set"
2622 (compare:CC (and:QI (not:QI (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>"))
2623 (match_operand:QI 1 "src_operand" "0,rR,rS<>"))
2625 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d")
2626 (and:QI (not:QI (match_dup 2))
2628 "valid_operands (AND, operands, QImode)"
2633 [(set_attr "type" "binarycc,binarycc,binarycc")
2634 (set_attr "data" "uint16,int16,uint16")])
2639 (define_expand "iorqi3"
2640 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2641 (ior:QI (match_operand:QI 1 "src_operand" "")
2642 (match_operand:QI 2 "lsrc_operand" "")))
2643 (clobber (reg:CC 21))])]
2645 "legitimize_operands (IOR, operands, QImode);")
2647 (define_insn "*iorqi3_clobber"
2648 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2649 (ior:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>,0,rR,rS<>")
2650 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>,rLm,JR,rS<>")))
2651 (clobber (reg:CC 21))]
2652 "valid_operands (IOR, operands, QImode)"
2660 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")
2661 (set_attr "data" "uint16,int16,uint16,uint16,int16,uint16")])
2664 [(set (match_operand:QI 0 "std_reg_operand" "")
2665 (ior:QI (match_operand:QI 1 "src_operand" "")
2666 (match_operand:QI 2 "lsrc_operand" "")))
2667 (clobber (reg:CC 21))]
2670 (ior:QI (match_dup 1)
2674 (define_insn "*iorqi3_test"
2676 (compare:CC (ior:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2677 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>"))
2679 (clobber (match_scratch:QI 0 "=d,d,d"))]
2680 "valid_operands (IOR, operands, QImode)"
2685 [(set_attr "type" "binarycc,binarycc,binarycc")
2686 (set_attr "data" "uint16,int16,uint16")])
2689 [(parallel [(set (match_operand:QI 0 "ext_reg_operand" "=d,d,d")
2690 (ior:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2691 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>")))
2692 (clobber (reg:CC 21))])
2694 (compare:CC (match_dup 0) (const_int 0)))]
2695 "valid_operands (IOR, operands, QImode)"
2700 [(set_attr "type" "binarycc,binarycc,binarycc")
2701 (set_attr "data" "uint16,int16,uint16")])
2703 (define_insn "*iorqi3_set"
2705 (compare:CC (ior:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2706 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>"))
2708 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d")
2709 (ior:QI (match_dup 1)
2711 "valid_operands (IOR, operands, QImode)"
2716 [(set_attr "type" "binarycc,binarycc,binarycc")
2717 (set_attr "data" "uint16,int16,uint16")])
2719 ; This pattern is used for loading symbol references in several parts.
2720 (define_insn "iorqi3_noclobber"
2721 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,c")
2722 (ior:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2723 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>")))]
2724 "valid_operands (IOR, operands, QImode)"
2729 [(set_attr "type" "binary,binary,binary")
2730 (set_attr "data" "uint16,int16,uint16")])
2735 (define_expand "xorqi3"
2736 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2737 (xor:QI (match_operand:QI 1 "src_operand" "")
2738 (match_operand:QI 2 "lsrc_operand" "")))
2739 (clobber (reg:CC 21))])]
2741 "legitimize_operands (XOR, operands, QImode);")
2743 (define_insn "*xorqi3_clobber"
2744 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2745 (xor:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>,0,rR,rS<>")
2746 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>,rLm,JR,rS<>")))
2747 (clobber (reg:CC 21))]
2748 "valid_operands (XOR, operands, QImode)"
2756 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")
2757 (set_attr "data" "uint16,int16,uint16,uint16,int16,uint16")])
2759 (define_insn "*xorqi3_noclobber"
2760 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,?c")
2761 (xor:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2762 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>")))]
2763 "valid_operands (XOR, operands, QImode)"
2768 [(set_attr "type" "binary,binary,binary")
2769 (set_attr "data" "uint16,int16,uint16")])
2772 [(set (match_operand:QI 0 "std_reg_operand" "")
2773 (xor:QI (match_operand:QI 1 "src_operand" "")
2774 (match_operand:QI 2 "lsrc_operand" "")))
2775 (clobber (reg:CC 21))]
2778 (xor:QI (match_dup 1)
2782 (define_insn "*xorqi3_test"
2784 (compare:CC (xor:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2785 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>"))
2787 (clobber (match_scratch:QI 0 "=d,d,d"))]
2788 "valid_operands (XOR, operands, QImode)"
2793 [(set_attr "type" "binarycc,binarycc,binarycc")
2794 (set_attr "data" "uint16,int16,uint16")])
2796 (define_insn "*xorqi3_set"
2798 (compare:CC (xor:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2799 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>"))
2801 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d")
2802 (xor:QI (match_dup 1)
2804 "valid_operands (XOR, operands, QImode)"
2809 [(set_attr "type" "binarycc,binarycc,binarycc")
2810 (set_attr "data" "uint16,int16,uint16")])
2815 ; The C3x and C4x have two shift instructions ASH and LSH
2816 ; If the shift count is positive, a left shift is performed
2817 ; otherwise a right shift is performed. The number of bits
2818 ; shifted is determined by the seven LSBs of the shift count.
2819 ; If the absolute value of the count is 32 or greater, the result
2820 ; using the LSH instruction is zero; with the ASH insn the result
2821 ; is zero or negative 1. Note that the ISO C standard allows
2822 ; the result to be machine dependent whenever the shift count
2823 ; exceeds the size of the object.
2824 (define_expand "ashlqi3"
2825 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2826 (ashift:QI (match_operand:QI 1 "src_operand" "")
2827 (match_operand:QI 2 "src_operand" "")))
2828 (clobber (reg:CC 21))])]
2830 "legitimize_operands (ASHIFT, operands, QImode);")
2832 (define_insn "*ashlqi3_clobber"
2833 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2834 (ashift:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>,0,rR,rS<>")
2835 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>,rIm,JR,rS<>")))
2836 (clobber (reg:CC 21))]
2837 "valid_operands (ASHIFT, operands, QImode)"
2845 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
2846 ; Default to int16 data attr.
2848 (define_insn "*ashlqi3_set"
2851 (ashift:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>")
2852 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>"))
2854 (set (match_operand:QI 0 "reg_operand" "=d,d,d")
2855 (ashift:QI (match_dup 1)
2857 "valid_operands (ASHIFT, operands, QImode)"
2862 [(set_attr "type" "binarycc,binarycc,binarycc")])
2863 ; Default to int16 data attr.
2865 (define_insn "ashlqi3_noclobber"
2866 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,?c")
2867 (ashift:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>")
2868 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>")))]
2869 "valid_operands (ASHIFT, operands, QImode)"
2874 [(set_attr "type" "binary,binary,binary")])
2875 ; Default to int16 data attr.
2878 [(set (match_operand:QI 0 "std_reg_operand" "")
2879 (ashift:QI (match_operand:QI 1 "src_operand" "")
2880 (match_operand:QI 2 "src_operand" "")))
2881 (clobber (reg:CC 21))]
2884 (ashift:QI (match_dup 1)
2888 ; This is only used by lshrhi3_reg where we need a LSH insn that will
2890 (define_insn "*lshlqi3_clobber"
2891 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2892 (ashift:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>,0,rR,rS<>")
2893 (unspec:QI [(match_operand:QI 2 "src_operand" "rIm,JR,rS<>,rIm,JR,rS<>")] 3)))
2894 (clobber (reg:CC 21))]
2895 "valid_operands (ASHIFT, operands, QImode)"
2903 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
2904 ; Default to int16 data attr.
2909 ; Logical right shift on the C[34]x works by negating the shift count,
2910 ; then emitting a right shift with the shift count negated. This means
2911 ; that all actual shift counts in the RTL will be positive.
2913 (define_expand "lshrqi3"
2914 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2915 (lshiftrt:QI (match_operand:QI 1 "src_operand" "")
2916 (match_operand:QI 2 "src_operand" "")))
2917 (clobber (reg:CC 21))])]
2919 "legitimize_operands (LSHIFTRT, operands, QImode);")
2922 (define_insn "*lshrqi3_24_clobber"
2923 [(set (match_operand:QI 0 "reg_operand" "=d,c")
2924 (lshiftrt:QI (match_operand:QI 1 "src_operand" "mr,mr")
2926 (clobber (reg:CC 21))]
2929 [(set_attr "type" "unarycc")])
2932 (define_insn "*ashrqi3_24_clobber"
2933 [(set (match_operand:QI 0 "reg_operand" "=d,c")
2934 (ashiftrt:QI (match_operand:QI 1 "src_operand" "mr,mr")
2936 (clobber (reg:CC 21))]
2939 [(set_attr "type" "unarycc")])
2942 (define_insn "lshrqi3_16_clobber"
2943 [(set (match_operand:QI 0 "reg_operand" "=d,c")
2944 (lshiftrt:QI (match_operand:QI 1 "src_operand" "mr,mr")
2946 (clobber (reg:CC 21))]
2949 [(set_attr "type" "unarycc")])
2952 (define_insn "*ashrqi3_16_clobber"
2953 [(set (match_operand:QI 0 "reg_operand" "=d,c")
2954 (ashiftrt:QI (match_operand:QI 1 "src_operand" "mr,mr")
2956 (clobber (reg:CC 21))]
2959 [(set_attr "type" "unarycc")])
2962 ; When the shift count is greater than the size of the word
2963 ; the result can be implementation specific
2964 (define_insn "*lshrqi3_const_clobber"
2965 [(set (match_operand:QI 0 "reg_operand" "=d,c,?d,?c")
2966 (lshiftrt:QI (match_operand:QI 1 "src_operand" "0,0,r,r")
2967 (match_operand:QI 2 "const_int_operand" "n,n,J,J")))
2968 (clobber (reg:CC 21))]
2969 "valid_operands (LSHIFTRT, operands, QImode)"
2975 [(set_attr "type" "binarycc,binary,binarycc,binary")])
2977 (define_insn "*lshrqi3_const_noclobber"
2978 [(set (match_operand:QI 0 "std_reg_operand" "=c,?c")
2979 (lshiftrt:QI (match_operand:QI 1 "src_operand" "0,r")
2980 (match_operand:QI 2 "const_int_operand" "n,J")))]
2981 "valid_operands (LSHIFTRT, operands, QImode)"
2985 [(set_attr "type" "binary,binary")])
2987 ; When the shift count is greater than the size of the word
2988 ; the result can be implementation specific
2989 (define_insn "*lshrqi3_const_set"
2992 (lshiftrt:QI (match_operand:QI 1 "src_operand" "0,r")
2993 (match_operand:QI 2 "const_int_operand" "n,J"))
2995 (set (match_operand:QI 0 "reg_operand" "=?d,d")
2996 (lshiftrt:QI (match_dup 1)
2998 "valid_operands (LSHIFTRT, operands, QImode)"
3002 [(set_attr "type" "binarycc,binarycc")])
3004 (define_insn "*lshrqi3_nonconst_clobber"
3005 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
3006 (lshiftrt:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>,0,rR,rS<>")
3007 (neg:QI (match_operand:QI 2 "src_operand" "rm,R,rS<>,rm,R,rS<>"))))
3008 (clobber (reg:CC 21))]
3009 "valid_operands (LSHIFTRT, operands, QImode)"
3017 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
3018 ; Default to int16 data attr.
3020 (define_insn "*lshrqi3_nonconst_noclobber"
3021 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,?c")
3022 (lshiftrt:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>")
3023 (neg:QI (match_operand:QI 2 "src_operand" "rm,R,rS<>"))))]
3024 "valid_operands (LSHIFTRT, operands, QImode)"
3029 [(set_attr "type" "binary,binary,binary")])
3030 ; Default to int16 data attr.
3035 ; Arithmetic right shift on the C[34]x works by negating the shift count,
3036 ; then emitting a right shift with the shift count negated. This means
3037 ; that all actual shift counts in the RTL will be positive.
3039 (define_expand "ashrqi3"
3040 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
3041 (ashiftrt:QI (match_operand:QI 1 "src_operand" "")
3042 (match_operand:QI 2 "src_operand" "")))
3043 (clobber (reg:CC 21))])]
3045 "legitimize_operands (ASHIFTRT, operands, QImode);")
3047 ; When the shift count is greater than the size of the word
3048 ; the result can be implementation specific
3049 (define_insn "*ashrqi3_const_clobber"
3050 [(set (match_operand:QI 0 "reg_operand" "=d,c,?d,?c")
3051 (ashiftrt:QI (match_operand:QI 1 "src_operand" "0,0,r,r")
3052 (match_operand:QI 2 "const_int_operand" "n,n,J,J")))
3053 (clobber (reg:CC 21))]
3054 "valid_operands (ASHIFTRT, operands, QImode)"
3060 [(set_attr "type" "binarycc,binary,binarycc,binary")])
3062 (define_insn "*ashrqi3_const_noclobber"
3063 [(set (match_operand:QI 0 "std_reg_operand" "=c,?c")
3064 (ashiftrt:QI (match_operand:QI 1 "src_operand" "0,r")
3065 (match_operand:QI 2 "const_int_operand" "n,J")))]
3066 "valid_operands (ASHIFTRT, operands, QImode)"
3070 [(set_attr "type" "binarycc,binarycc")])
3072 ; When the shift count is greater than the size of the word
3073 ; the result can be implementation specific
3074 (define_insn "*ashrqi3_const_set"
3077 (ashiftrt:QI (match_operand:QI 1 "src_operand" "0,r")
3078 (match_operand:QI 2 "const_int_operand" "n,J"))
3080 (set (match_operand:QI 0 "reg_operand" "=?d,d")
3081 (ashiftrt:QI (match_dup 1)
3083 "valid_operands (ASHIFTRT, operands, QImode)"
3087 [(set_attr "type" "binarycc,binarycc")])
3089 (define_insn "*ashrqi3_nonconst_clobber"
3090 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
3091 (ashiftrt:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>,0,rR,rS<>")
3092 (neg:QI (match_operand:QI 2 "src_operand" "rm,R,rS<>,rm,R,rS<>"))))
3093 (clobber (reg:CC 21))]
3094 "valid_operands (ASHIFTRT, operands, QImode)"
3102 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
3103 ; Default to int16 data attr.
3105 (define_insn "*ashrqi3_nonconst_noclobber"
3106 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,?c")
3107 (ashiftrt:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>")
3108 (neg:QI (match_operand:QI 2 "src_operand" "rm,R,rS<>"))))]
3109 "valid_operands (ASHIFTRT, operands, QImode)"
3114 [(set_attr "type" "binary,binary,binary")])
3115 ; Default to int16 data attr.
3120 ; Unfortunately the C40 doesn't allow cmpi3 7, *ar0++ so the next best
3121 ; thing would be to get the small constant loaded into a register (say r0)
3122 ; so that it could be hoisted out of the loop so that we only
3123 ; would need to do cmpi3 *ar0++, r0. Now the loop optimisation pass
3124 ; comes before the flow pass (which finds autoincrements) so we're stuck.
3125 ; Ideally, GCC requires another loop optimisation pass (preferably after
3126 ; reload) so that it can hoist invariants out of loops.
3127 ; The current solution modifies legitimize_operands () so that small
3128 ; constants are forced into a pseudo register.
3130 (define_expand "cmpqi"
3132 (compare:CC (match_operand:QI 0 "src_operand" "")
3133 (match_operand:QI 1 "src_operand" "")))]
3135 "legitimize_operands (COMPARE, operands, QImode);
3136 c4x_compare_op0 = operands[0];
3137 c4x_compare_op1 = operands[1];
3140 (define_insn "*cmpqi_test"
3142 (compare:CC (match_operand:QI 0 "src_operand" "r,rR,rS<>")
3143 (match_operand:QI 1 "src_operand" "rIm,JR,rS<>")))]
3144 "valid_operands (COMPARE, operands, QImode)"
3149 [(set_attr "type" "compare,compare,compare")])
3151 (define_insn "*cmpqi_test_noov"
3152 [(set (reg:CC_NOOV 21)
3153 (compare:CC_NOOV (match_operand:QI 0 "src_operand" "r,rR,rS<>")
3154 (match_operand:QI 1 "src_operand" "rIm,JR,rS<>")))]
3155 "valid_operands (COMPARE, operands, QImode)"
3160 [(set_attr "type" "compare,compare,compare")])
3164 ; BIT-FIELD INSTRUCTIONS
3168 ; LBx/LHw (C4x only)
3170 (define_expand "extv"
3171 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
3172 (sign_extract:QI (match_operand:QI 1 "src_operand" "")
3173 (match_operand:QI 2 "const_int_operand" "")
3174 (match_operand:QI 3 "const_int_operand" "")))
3175 (clobber (reg:CC 21))])]
3177 "if ((INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16)
3178 || (INTVAL (operands[3]) % INTVAL (operands[2]) != 0))
3182 (define_insn "*extv_clobber"
3183 [(set (match_operand:QI 0 "reg_operand" "=d,c")
3184 (sign_extract:QI (match_operand:QI 1 "src_operand" "rLm,rLm")
3185 (match_operand:QI 2 "const_int_operand" "n,n")
3186 (match_operand:QI 3 "const_int_operand" "n,n")))
3187 (clobber (reg:CC 21))]
3189 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
3190 && (INTVAL (operands[3]) % INTVAL (operands[2]) == 0)"
3192 if (INTVAL (operands[2]) == 8)
3194 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
3195 return \"lb%3\\t%1,%0\";
3197 operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
3198 return \"lh%3\\t%1,%0\";
3200 [(set_attr "type" "binarycc,binary")
3201 (set_attr "data" "int16,int16")])
3203 (define_insn "*extv_clobber_test"
3205 (compare:CC (sign_extract:QI (match_operand:QI 1 "src_operand" "rLm")
3206 (match_operand:QI 2 "const_int_operand" "n")
3207 (match_operand:QI 3 "const_int_operand" "n"))
3209 (clobber (match_scratch:QI 0 "=d"))]
3211 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
3212 && (INTVAL (operands[3]) % INTVAL (operands[2]) == 0)"
3214 if (INTVAL (operands[2]) == 8)
3216 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
3217 return \"lb%3\\t%1,%0\";
3219 operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
3220 return \"lh%3\\t%1,%0\";
3222 [(set_attr "type" "binarycc")
3223 (set_attr "data" "int16")])
3225 (define_insn "*extv_clobber_set"
3227 (compare:CC (sign_extract:QI (match_operand:QI 1 "src_operand" "rLm")
3228 (match_operand:QI 2 "const_int_operand" "n")
3229 (match_operand:QI 3 "const_int_operand" "n"))
3231 (set (match_operand:QI 0 "reg_operand" "=d")
3232 (sign_extract:QI (match_dup 1)
3236 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
3237 && (INTVAL (operands[3]) % INTVAL (operands[2]) == 0)"
3239 if (INTVAL (operands[2]) == 8)
3241 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
3242 return \"lb%3\\t%1,%0\";
3244 operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
3245 return \"lh%3\\t%1,%0\";
3247 [(set_attr "type" "binarycc")
3248 (set_attr "data" "int16")])
3251 ; LBUx/LHUw (C4x only)
3253 (define_expand "extzv"
3254 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
3255 (zero_extract:QI (match_operand:QI 1 "src_operand" "")
3256 (match_operand:QI 2 "const_int_operand" "")
3257 (match_operand:QI 3 "const_int_operand" "")))
3258 (clobber (reg:CC 21))])]
3260 "if ((INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16)
3261 || (INTVAL (operands[3]) % INTVAL (operands[2]) != 0))
3265 (define_insn "*extzv_clobber"
3266 [(set (match_operand:QI 0 "reg_operand" "=d,c")
3267 (zero_extract:QI (match_operand:QI 1 "src_operand" "rLm,rLm")
3268 (match_operand:QI 2 "const_int_operand" "n,n")
3269 (match_operand:QI 3 "const_int_operand" "n,n")))
3270 (clobber (reg:CC 21))]
3272 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
3273 && (INTVAL (operands[3]) % INTVAL (operands[2]) == 0)"
3275 if (INTVAL (operands[2]) == 8)
3277 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
3278 return \"lbu%3\\t%1,%0\";
3280 operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
3281 return \"lhu%3\\t%1,%0\";
3283 [(set_attr "type" "binarycc,binary")
3284 (set_attr "data" "uint16,uint16")])
3286 (define_insn "*extzv_test"
3288 (compare:CC (zero_extract:QI (match_operand:QI 1 "src_operand" "rLm")
3289 (match_operand:QI 2 "const_int_operand" "n")
3290 (match_operand:QI 3 "const_int_operand" "n"))
3292 (clobber (match_scratch:QI 0 "=d"))]
3294 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
3295 && (INTVAL (operands[3]) % INTVAL (operands[2]) == 0)"
3297 if (INTVAL (operands[2]) == 8)
3299 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
3300 return \"lbu%3\\t%1,%0\";
3302 operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
3303 return \"lhu%3\\t%1,%0\";
3305 [(set_attr "type" "binarycc")
3306 (set_attr "data" "uint16")])
3308 (define_insn "*extzv_set"
3310 (compare:CC (zero_extract:QI (match_operand:QI 1 "src_operand" "rLm")
3311 (match_operand:QI 2 "const_int_operand" "n")
3312 (match_operand:QI 3 "const_int_operand" "n"))
3314 (set (match_operand:QI 0 "ext_reg_operand" "=d")
3315 (zero_extract:QI (match_dup 1)
3319 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
3320 && (INTVAL (operands[3]) % INTVAL (operands[2]) == 0)"
3322 if (INTVAL (operands[2]) == 8)
3324 /* 8 bit extract. */
3325 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
3326 return \"lbu%3\\t%1,%0\";
3328 /* 16 bit extract. */
3329 operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
3330 return \"lhu%3\\t%1,%0\";
3332 [(set_attr "type" "binarycc")
3333 (set_attr "data" "uint16")])
3336 ; MBx/MHw (C4x only)
3338 (define_expand "insv"
3339 [(parallel [(set (zero_extract:QI (match_operand:QI 0 "reg_operand" "")
3340 (match_operand:QI 1 "const_int_operand" "")
3341 (match_operand:QI 2 "const_int_operand" ""))
3342 (match_operand:QI 3 "src_operand" ""))
3343 (clobber (reg:CC 21))])]
3345 "if (! (((INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
3346 && (INTVAL (operands[2]) % INTVAL (operands[1]) == 0))
3347 || (INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)))
3351 (define_insn "*insv_clobber"
3352 [(set (zero_extract:QI (match_operand:QI 0 "reg_operand" "+d,c")
3353 (match_operand:QI 1 "const_int_operand" "n,n")
3354 (match_operand:QI 2 "const_int_operand" "n,n"))
3355 (match_operand:QI 3 "src_operand" "rLm,rLm"))
3356 (clobber (reg:CC 21))]
3358 && (((INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
3359 && (INTVAL (operands[2]) % INTVAL (operands[1]) == 0))
3360 || (INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8))"
3362 if (INTVAL (operands[1]) == 8)
3365 operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
3366 return \"mb%2\\t%3,%0\";
3368 else if (INTVAL (operands[1]) == 16)
3370 /* 16 bit insert. */
3371 operands[2] = GEN_INT (INTVAL (operands[2]) / 16);
3372 return \"mh%2\\t%3,%0\";
3374 /* 24 bit insert. */
3375 return \"lwl1\\t%3,%0\";
3377 [(set_attr "type" "binarycc,binary")
3378 (set_attr "data" "uint16,uint16")])
3381 [(parallel [(set (zero_extract:QI (match_operand:QI 0 "ext_reg_operand" "+d")
3382 (match_operand:QI 1 "const_int_operand" "n")
3383 (match_operand:QI 2 "const_int_operand" "n"))
3384 (match_operand:QI 3 "src_operand" "rLm"))
3385 (clobber (reg:CC 21))])
3387 (compare:CC (match_dup 0) (const_int 0)))]
3389 && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
3390 && (INTVAL (operands[2]) % INTVAL (operands[1]) == 0)"
3392 if (INTVAL (operands[1]) == 8)
3394 operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
3395 return \"mb%2\\t%3,%0\";
3397 operands[2] = GEN_INT (INTVAL (operands[2]) / 16);
3398 return \"mh%2\\t%3,%0\";
3400 [(set_attr "type" "binarycc")
3401 (set_attr "data" "uint16")])
3404 ; TWO OPERAND FLOAT INSTRUCTIONS
3410 ; If one of the operands is not a register, then we should
3411 ; emit two insns, using a scratch register. This will produce
3412 ; better code in loops if the source operand is invariant, since
3413 ; the source reload can be optimized out. During reload we cannot
3414 ; use change_address or force_reg.
3415 (define_expand "movqf"
3416 [(set (match_operand:QF 0 "src_operand" "")
3417 (match_operand:QF 1 "src_operand" ""))]
3421 if (c4x_emit_move_sequence (operands, QFmode))
3425 ; This can generate invalid stack slot displacements
3427 [(set (match_operand:QI 0 "reg_operand" "")
3428 (unspec:QI [(match_operand:QF 1 "reg_operand" "")] 12))]
3430 [(set (match_dup 3) (match_dup 1))
3431 (set (match_dup 0) (match_dup 2))]
3432 "operands[2] = assign_stack_temp (QImode, GET_MODE_SIZE (QImode), 0);
3433 operands[3] = copy_rtx (operands[2]);
3434 PUT_MODE (operands[3], QFmode);")
3437 (define_insn "storeqf_int"
3438 [(set (match_operand:QI 0 "reg_operand" "=r")
3439 (unspec:QI [(match_operand:QF 1 "reg_operand" "f")] 12))]
3442 [(set_attr "type" "multi")])
3445 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
3446 (unspec:QI [(match_operand:QF 1 "reg_operand" "")] 12))
3447 (clobber (reg:CC 21))])]
3449 [(set (mem:QF (pre_inc:QI (reg:QI 20)))
3451 (parallel [(set (match_dup 0)
3452 (mem:QI (post_dec:QI (reg:QI 20))))
3453 (clobber (reg:CC 21))])]
3457 ; We need accurate death notes for this...
3459 ; [(set (match_operand:QF 0 "reg_operand" "=f")
3460 ; (match_operand:QF 1 "memory_operand" "m"))
3461 ; (set (mem:QF (pre_inc:QI (reg:QI 20)))
3463 ; (parallel [(set (match_operand:QI 2 "reg_operand" "r")
3464 ; (mem:QI (post_dec:QI (reg:QI 20))))
3465 ; (clobber (reg:CC 21))])]
3469 (define_insn "storeqf_int_clobber"
3470 [(parallel [(set (match_operand:QI 0 "reg_operand" "=r")
3471 (unspec:QI [(match_operand:QF 1 "reg_operand" "f")] 12))
3472 (clobber (reg:CC 21))])]
3475 [(set_attr "type" "multi")])
3478 ; This can generate invalid stack slot displacements
3480 [(set (match_operand:QF 0 "reg_operand" "")
3481 (unspec:QF [(match_operand:QI 1 "reg_operand" "")] 11))]
3483 [(set (match_dup 2) (match_dup 1))
3484 (set (match_dup 0) (match_dup 3))]
3485 "operands[2] = assign_stack_temp (QImode, GET_MODE_SIZE (QImode), 0);
3486 operands[3] = copy_rtx (operands[2]);
3487 PUT_MODE (operands[3], QFmode);")
3490 (define_insn "loadqf_int"
3491 [(set (match_operand:QF 0 "reg_operand" "=f")
3492 (unspec:QF [(match_operand:QI 1 "reg_operand" "r")] 11))]
3495 [(set_attr "type" "multi")])
3498 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
3499 (unspec:QF [(match_operand:QI 1 "reg_operand" "")] 11))
3500 (clobber (reg:CC 21))])]
3502 [(set (mem:QI (pre_inc:QI (reg:QI 20)))
3504 (parallel [(set (match_dup 0)
3505 (mem:QF (post_dec:QI (reg:QI 20))))
3506 (clobber (reg:CC 21))])]
3509 (define_insn "loadqf_int_clobber"
3510 [(parallel [(set (match_operand:QF 0 "reg_operand" "=f")
3511 (unspec:QF [(match_operand:QI 1 "reg_operand" "r")] 11))
3512 (clobber (reg:CC 21))])]
3515 [(set_attr "type" "multi")])
3517 ; We must provide an alternative to store to memory in case we have to
3519 (define_insn "movqf_noclobber"
3520 [(set (match_operand:QF 0 "dst_operand" "=f,m")
3521 (match_operand:QF 1 "src_operand" "fHm,f"))]
3522 "REG_P (operands[0]) || REG_P (operands[1])"
3526 [(set_attr "type" "unary,store")])
3528 ;(define_insn "*movqf_clobber"
3529 ; [(set (match_operand:QF 0 "reg_operand" "=f")
3530 ; (match_operand:QF 1 "src_operand" "fHm"))
3531 ; (clobber (reg:CC 21))]
3534 ; [(set_attr "type" "unarycc")])
3536 (define_insn "*movqf_test"
3538 (compare:CC (match_operand:QF 1 "src_operand" "fHm")
3540 (clobber (match_scratch:QF 0 "=f"))]
3543 [(set_attr "type" "unarycc")])
3545 (define_insn "*movqf_set"
3547 (compare:CC (match_operand:QF 1 "src_operand" "fHm")
3548 (match_operand:QF 2 "fp_zero_operand" "G")))
3549 (set (match_operand:QF 0 "reg_operand" "=f")
3553 [(set_attr "type" "unarycc")])
3556 (define_insn "*movqf_parallel"
3557 [(set (match_operand:QF 0 "parallel_operand" "=q,S<>!V,q,S<>!V")
3558 (match_operand:QF 1 "parallel_operand" "S<>!V,q,S<>!V,q"))
3559 (set (match_operand:QF 2 "parallel_operand" "=q,S<>!V,S<>!V,q")
3560 (match_operand:QF 3 "parallel_operand" "S<>!V,q,q,S<>!V"))]
3561 "TARGET_PARALLEL && valid_parallel_load_store (operands, QFmode)"
3563 ldf1\\t%1,%0\\n||\\tldf2\\t%3,%2
3564 stf1\\t%1,%0\\n||\\tstf2\\t%3,%2
3565 ldf\\t%1,%0\\n||\\tstf\\t%3,%2
3566 ldf\\t%3,%2\\n||\\tstf\\t%1,%0"
3567 [(set_attr "type" "load_load,store_store,load_store,store_load")])
3573 (define_insn "pushqf"
3574 [(set (mem:QF (pre_inc:QI (reg:QI 20)))
3575 (match_operand:QF 0 "reg_operand" "f"))]
3578 [(set_attr "type" "push")])
3580 (define_insn "popqf"
3581 [(set (match_operand:QF 0 "reg_operand" "=f")
3582 (mem:QF (post_dec:QI (reg:QI 20))))
3583 (clobber (reg:CC 21))]
3586 [(set_attr "type" "pop")])
3588 (define_insn "popqf_unspec"
3589 [(set (unspec:QF [(match_operand:QF 0 "reg_operand" "=f")] 19)
3590 (mem:QF (post_dec:QI (reg:QI 20))))
3591 (clobber (match_dup 0))
3592 (clobber (reg:CC 21))]
3595 [(set_attr "type" "pop")])
3600 (define_expand "absqf2"
3601 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
3602 (abs:QF (match_operand:QF 1 "src_operand" "")))
3603 (clobber (reg:CC_NOOV 21))])]
3607 (define_insn "*absqf2_clobber"
3608 [(set (match_operand:QF 0 "reg_operand" "=f")
3609 (abs:QF (match_operand:QF 1 "src_operand" "fHm")))
3610 (clobber (reg:CC_NOOV 21))]
3613 [(set_attr "type" "unarycc")])
3615 (define_insn "*absqf2_test"
3616 [(set (reg:CC_NOOV 21)
3617 (compare:CC_NOOV (abs:QF (match_operand:QF 1 "src_operand" "fHm"))
3618 (match_operand:QF 2 "fp_zero_operand" "G")))
3619 (clobber (match_scratch:QF 0 "=f"))]
3622 [(set_attr "type" "unarycc")])
3624 (define_insn "*absqf2_set"
3625 [(set (reg:CC_NOOV 21)
3626 (compare:CC_NOOV (abs:QF (match_operand:QF 1 "src_operand" "fHm"))
3627 (match_operand:QF 2 "fp_zero_operand" "G")))
3628 (set (match_operand:QF 0 "reg_operand" "=f")
3629 (abs:QF (match_dup 1)))]
3633 [(set_attr "type" "unarycc")])
3638 (define_expand "negqf2"
3639 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
3640 (neg:QF (match_operand:QF 1 "src_operand" "")))
3641 (clobber (reg:CC_NOOV 21))])]
3645 (define_insn "*negqf2_clobber"
3646 [(set (match_operand:QF 0 "reg_operand" "=f")
3647 (neg:QF (match_operand:QF 1 "src_operand" "fHm")))
3648 (clobber (reg:CC_NOOV 21))]
3651 [(set_attr "type" "unarycc")])
3653 (define_insn "*negqf2_test"
3654 [(set (reg:CC_NOOV 21)
3655 (compare:CC_NOOV (neg:QF (match_operand:QF 1 "src_operand" "fHm"))
3656 (match_operand:QF 2 "fp_zero_operand" "G")))
3657 (clobber (match_scratch:QF 0 "=f"))]
3660 [(set_attr "type" "unarycc")])
3662 (define_insn "*negqf2_set"
3663 [(set (reg:CC_NOOV 21)
3664 (compare:CC_NOOV (neg:QF (match_operand:QF 1 "src_operand" "fHm"))
3665 (match_operand:QF 2 "fp_zero_operand" "G")))
3666 (set (match_operand:QF 0 "reg_operand" "=f")
3667 (neg:QF (match_dup 1)))]
3670 [(set_attr "type" "unarycc")])
3675 (define_insn "floatqiqf2"
3676 [(set (match_operand:QF 0 "reg_operand" "=f")
3677 (float:QF (match_operand:QI 1 "src_operand" "rIm")))
3678 (clobber (reg:CC 21))]
3681 [(set_attr "type" "unarycc")])
3683 (define_insn "*floatqiqf2_set"
3685 (compare:CC (float:QF (match_operand:QI 1 "src_operand" "rIm"))
3686 (match_operand:QF 2 "fp_zero_operand" "G")))
3687 (set (match_operand:QF 0 "reg_operand" "=f")
3688 (float:QF (match_dup 1)))]
3691 [(set_attr "type" "unarycc")])
3693 ; Unsigned conversions are a little tricky because we need to
3694 ; add the value for the high bit if necessary.
3697 (define_expand "floatunsqiqf2"
3698 [(set (match_dup 2) (match_dup 3))
3699 (parallel [(set (reg:CC 21)
3700 (compare:CC (float:QF (match_operand:QI 1 "src_operand" ""))
3703 (float:QF (match_dup 1)))])
3705 (if_then_else:QF (lt (reg:CC 21) (const_int 0))
3708 (parallel [(set (match_operand:QF 0 "reg_operand" "")
3709 (plus:QF (match_dup 6) (match_dup 4)))
3710 (clobber (reg:CC_NOOV 21))])]
3712 "operands[2] = gen_reg_rtx (QFmode);
3713 operands[3] = CONST0_RTX (QFmode);
3714 operands[4] = gen_reg_rtx (QFmode);
3715 operands[5] = gen_reg_rtx (QFmode);
3716 operands[6] = gen_reg_rtx (QFmode);
3717 emit_move_insn (operands[5], CONST_DOUBLE_ATOF (\"4294967296.0\", QFmode));")
3719 (define_expand "floatunsqihf2"
3720 [(set (match_dup 2) (match_dup 3))
3721 (parallel [(set (reg:CC 21)
3722 (compare:CC (float:HF (match_operand:QI 1 "src_operand" ""))
3725 (float:HF (match_dup 1)))])
3727 (if_then_else:HF (lt (reg:CC 21) (const_int 0))
3730 (parallel [(set (match_operand:HF 0 "reg_operand" "")
3731 (plus:HF (match_dup 6) (match_dup 4)))
3732 (clobber (reg:CC_NOOV 21))])]
3734 "operands[2] = gen_reg_rtx (HFmode);
3735 operands[3] = CONST0_RTX (HFmode);
3736 operands[4] = gen_reg_rtx (HFmode);
3737 operands[5] = gen_reg_rtx (HFmode);
3738 operands[6] = gen_reg_rtx (HFmode);
3739 emit_move_insn (operands[5], CONST_DOUBLE_ATOF (\"4294967296.0\", HFmode));")
3741 (define_insn "floatqihf2"
3742 [(set (match_operand:HF 0 "reg_operand" "=h")
3743 (float:HF (match_operand:QI 1 "src_operand" "rIm")))
3744 (clobber (reg:CC 21))]
3747 [(set_attr "type" "unarycc")])
3749 (define_insn "*floatqihf2_set"
3751 (compare:CC (float:HF (match_operand:QI 1 "src_operand" "rIm"))
3752 (match_operand:QF 2 "fp_zero_operand" "G")))
3753 (set (match_operand:HF 0 "reg_operand" "=h")
3754 (float:HF (match_dup 1)))]
3757 [(set_attr "type" "unarycc")])
3762 (define_insn "fixqfqi_clobber"
3763 [(set (match_operand:QI 0 "reg_operand" "=d,c")
3764 (fix:QI (match_operand:QF 1 "src_operand" "fHm,fHm")))
3765 (clobber (reg:CC 21))]
3768 [(set_attr "type" "unarycc")])
3770 (define_insn "*fixqfqi_set"
3772 (compare:CC (fix:QI (match_operand:QF 1 "src_operand" "fHm"))
3774 (set (match_operand:QI 0 "ext_reg_operand" "=d")
3775 (fix:QI (match_dup 1)))]
3778 [(set_attr "type" "unarycc")])
3780 (define_insn "*fixhfqi_set"
3782 (compare:CC (fix:QI (match_operand:HF 1 "src_operand" "fH"))
3784 (set (match_operand:QI 0 "ext_reg_operand" "=d")
3785 (fix:QI (match_dup 1)))]
3788 [(set_attr "type" "unarycc")])
3791 ; The C[34]x fix instruction implements a floor, not a straight trunc,
3792 ; so we have to invert the number, fix it, and reinvert it if negative
3794 (define_expand "fix_truncqfqi2"
3795 [(parallel [(set (match_dup 2)
3796 (fix:QI (match_operand:QF 1 "src_operand" "")))
3797 (clobber (reg:CC 21))])
3798 (parallel [(set (match_dup 3) (neg:QF (match_dup 1)))
3799 (clobber (reg:CC_NOOV 21))])
3800 (parallel [(set (match_dup 4) (fix:QI (match_dup 3)))
3801 (clobber (reg:CC 21))])
3802 (parallel [(set (reg:CC_NOOV 21)
3803 (compare:CC_NOOV (neg:QI (match_dup 4)) (const_int 0)))
3804 (set (match_dup 5) (neg:QI (match_dup 4)))])
3806 (if_then_else:QI (le (reg:CC 21) (const_int 0))
3809 (set (match_operand:QI 0 "reg_operand" "=r") (match_dup 2))]
3811 "if (TARGET_FAST_FIX)
3813 emit_insn (gen_fixqfqi_clobber (operands[0], operands[1]));
3816 operands[2] = gen_reg_rtx (QImode);
3817 operands[3] = gen_reg_rtx (QFmode);
3818 operands[4] = gen_reg_rtx (QImode);
3819 operands[5] = gen_reg_rtx (QImode);
3822 (define_expand "fix_trunchfqi2"
3823 [(parallel [(set (match_dup 2)
3824 (fix:QI (match_operand:HF 1 "src_operand" "")))
3825 (clobber (reg:CC 21))])
3826 (parallel [(set (match_dup 3) (neg:HF (match_dup 1)))
3827 (clobber (reg:CC_NOOV 21))])
3828 (parallel [(set (match_dup 4) (fix:QI (match_dup 3)))
3829 (clobber (reg:CC 21))])
3830 (parallel [(set (reg:CC_NOOV 21)
3831 (compare:CC_NOOV (neg:QI (match_dup 4)) (const_int 0)))
3832 (set (match_dup 5) (neg:QI (match_dup 4)))])
3834 (if_then_else:QI (le (reg:CC 21) (const_int 0))
3837 (set (match_operand:QI 0 "reg_operand" "=r") (match_dup 2))]
3839 "if (TARGET_FAST_FIX)
3841 emit_insn (gen_fixhfqi_clobber (operands[0], operands[1]));
3844 operands[2] = gen_reg_rtx (QImode);
3845 operands[3] = gen_reg_rtx (HFmode);
3846 operands[4] = gen_reg_rtx (QImode);
3847 operands[5] = gen_reg_rtx (QImode);
3850 (define_expand "fix_truncqfhi2"
3851 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
3852 (fix:HI (match_operand:QF 1 "src_operand" "")))
3853 (clobber (reg:CC 21))])]
3855 "c4x_emit_libcall (fix_truncqfhi2_libfunc, FIX, HImode, QFmode, 2, operands);
3858 (define_expand "fixuns_truncqfqi2"
3859 [(parallel [(set (match_dup 2)
3860 (fix:QI (match_operand:QF 1 "src_operand" "fHm")))
3861 (clobber (reg:CC 21))])
3862 (parallel [(set (match_dup 3)
3863 (minus:QF (match_dup 1) (match_dup 5)))
3864 (clobber (reg:CC_NOOV 21))])
3865 (parallel [(set (reg:CC 21)
3866 (compare:CC (fix:QI (match_dup 3))
3869 (fix:QI (match_dup 3)))])
3870 (parallel [(set (match_dup 4) (unspec:QI [(match_dup 2)] 13))
3872 (set (match_operand:QI 0 "reg_operand" "=r") (match_dup 4))]
3874 "operands[2] = gen_reg_rtx (QImode);
3875 operands[3] = gen_reg_rtx (QFmode);
3876 operands[4] = gen_reg_rtx (QImode);
3877 operands[5] = gen_reg_rtx (QFmode);
3878 emit_move_insn (operands[5], CONST_DOUBLE_ATOF (\"4294967296.0\", QFmode));")
3880 (define_expand "fixuns_trunchfqi2"
3881 [(parallel [(set (match_dup 2)
3882 (fix:QI (match_operand:HF 1 "src_operand" "hH")))
3883 (clobber (reg:CC 21))])
3884 (parallel [(set (match_dup 3)
3885 (minus:HF (match_dup 1) (match_dup 5)))
3886 (clobber (reg:CC_NOOV 21))])
3887 (parallel [(set (reg:CC 21)
3888 (compare:CC (fix:QI (match_dup 3))
3891 (fix:QI (match_dup 3)))])
3892 (parallel [(set (match_dup 4) (unspec:QI [(match_dup 2)] 13))
3894 (set (match_operand:QI 0 "reg_operand" "=r") (match_dup 4))]
3896 "operands[2] = gen_reg_rtx (QImode);
3897 operands[3] = gen_reg_rtx (HFmode);
3898 operands[4] = gen_reg_rtx (QImode);
3899 operands[5] = gen_reg_rtx (HFmode);
3900 emit_move_insn (operands[5], CONST_DOUBLE_ATOF (\"4294967296.0\", HFmode));")
3902 (define_expand "fixuns_truncqfhi2"
3903 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
3904 (unsigned_fix:HI (match_operand:QF 1 "src_operand" "")))
3905 (clobber (reg:CC 21))])]
3907 "c4x_emit_libcall (fixuns_truncqfhi2_libfunc, UNSIGNED_FIX,
3908 HImode, QFmode, 2, operands);
3914 (define_insn "rcpfqf_clobber"
3915 [(set (match_operand:QF 0 "reg_operand" "=f")
3916 (unspec:QF [(match_operand:QF 1 "src_operand" "fHm")] 5))
3917 (clobber (reg:CC_NOOV 21))]
3920 [(set_attr "type" "unarycc")])
3925 (define_insn "*rsqrfqf_clobber"
3926 [(set (match_operand:QF 0 "reg_operand" "=f")
3927 (unspec:QF [(match_operand:QF 1 "src_operand" "fHm")] 10))
3928 (clobber (reg:CC_NOOV 21))]
3931 [(set_attr "type" "unarycc")])
3936 (define_insn "*rndqf_clobber"
3937 [(set (match_operand:QF 0 "reg_operand" "=f")
3938 (unspec:QF [(match_operand:QF 1 "src_operand" "fHm")] 6))
3939 (clobber (reg:CC_NOOV 21))]
3942 [(set_attr "type" "unarycc")])
3945 ; Inlined float square root for C4x
3946 (define_expand "sqrtqf2_inline"
3947 [(parallel [(set (match_dup 2)
3948 (unspec:QF [(match_operand:QF 1 "src_operand" "")] 10))
3949 (clobber (reg:CC_NOOV 21))])
3950 (parallel [(set (match_dup 3) (mult:QF (match_dup 5) (match_dup 1)))
3951 (clobber (reg:CC_NOOV 21))])
3952 (parallel [(set (match_dup 4) (mult:QF (match_dup 2) (match_dup 3)))
3953 (clobber (reg:CC_NOOV 21))])
3954 (parallel [(set (match_dup 4) (mult:QF (match_dup 2) (match_dup 4)))
3955 (clobber (reg:CC_NOOV 21))])
3956 (parallel [(set (match_dup 4) (minus:QF (match_dup 6) (match_dup 4)))
3957 (clobber (reg:CC_NOOV 21))])
3958 (parallel [(set (match_dup 2) (mult:QF (match_dup 2) (match_dup 4)))
3959 (clobber (reg:CC_NOOV 21))])
3960 (parallel [(set (match_dup 4) (mult:QF (match_dup 2) (match_dup 3)))
3961 (clobber (reg:CC_NOOV 21))])
3962 (parallel [(set (match_dup 4) (mult:QF (match_dup 2) (match_dup 4)))
3963 (clobber (reg:CC_NOOV 21))])
3964 (parallel [(set (match_dup 4) (minus:QF (match_dup 6) (match_dup 4)))
3965 (clobber (reg:CC_NOOV 21))])
3966 (parallel [(set (match_dup 2) (mult:QF (match_dup 2) (match_dup 4)))
3967 (clobber (reg:CC_NOOV 21))])
3968 (parallel [(set (match_dup 4) (mult:QF (match_dup 2) (match_dup 1)))
3969 (clobber (reg:CC_NOOV 21))])
3970 (parallel [(set (match_operand:QF 0 "reg_operand" "")
3971 (unspec:QF [(match_dup 4)] 6))
3972 (clobber (reg:CC_NOOV 21))])]
3974 "if (! reload_in_progress
3975 && ! reg_operand (operands[1], QFmode))
3976 operands[1] = force_reg (QFmode, operands[1]);
3977 operands[2] = gen_reg_rtx (QFmode);
3978 operands[3] = gen_reg_rtx (QFmode);
3979 operands[4] = gen_reg_rtx (QFmode);
3980 operands[5] = CONST_DOUBLE_ATOF (\"0.5\", QFmode);
3981 operands[6] = CONST_DOUBLE_ATOF (\"1.5\", QFmode);")
3983 (define_expand "sqrtqf2"
3984 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
3985 (sqrt:QF (match_operand:QF 1 "src_operand" "")))
3986 (clobber (reg:CC 21))])]
3987 "! TARGET_C3X && TARGET_INLINE"
3988 "emit_insn (gen_sqrtqf2_inline (operands[0], operands[1]));
3994 (define_insn "toieee"
3995 [(set (match_operand:QF 0 "reg_operand" "=f")
3996 (unspec:QF [(match_operand:QF 1 "src_operand" "fHm")] 23))
3997 (clobber (reg:CC 21))]
4001 (define_insn "frieee"
4002 [(set (match_operand:QF 0 "reg_operand" "=f")
4003 (unspec:QF [(match_operand:QF 1 "memory_operand" "m")] 24))
4004 (clobber (reg:CC 21))]
4009 ; THREE OPERAND FLOAT INSTRUCTIONS
4015 (define_expand "addqf3"
4016 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
4017 (plus:QF (match_operand:QF 1 "src_operand" "")
4018 (match_operand:QF 2 "src_operand" "")))
4019 (clobber (reg:CC_NOOV 21))])]
4021 "legitimize_operands (PLUS, operands, QFmode);")
4023 (define_insn "*addqf3_clobber"
4024 [(set (match_operand:QF 0 "reg_operand" "=f,f,?f")
4025 (plus:QF (match_operand:QF 1 "src_operand" "%0,fR,fS<>")
4026 (match_operand:QF 2 "src_operand" "fHm,R,fS<>")))
4027 (clobber (reg:CC_NOOV 21))]
4028 "valid_operands (PLUS, operands, QFmode)"
4033 [(set_attr "type" "binarycc,binarycc,binarycc")])
4035 (define_insn "*addqf3_test"
4036 [(set (reg:CC_NOOV 21)
4037 (compare:CC_NOOV (plus:QF (match_operand:QF 1 "src_operand" "%0,fR,fS<>")
4038 (match_operand:QF 2 "src_operand" "fHm,R,fS<>"))
4039 (match_operand:QF 3 "fp_zero_operand" "G,G,G")))
4040 (clobber (match_scratch:QF 0 "=f,f,?f"))]
4041 "valid_operands (PLUS, operands, QFmode)"
4046 [(set_attr "type" "binarycc,binarycc,binarycc")])
4048 (define_insn "*addqf3_set"
4049 [(set (reg:CC_NOOV 21)
4050 (compare:CC_NOOV (plus:QF (match_operand:QF 1 "src_operand" "%0,fR,fS<>")
4051 (match_operand:QF 2 "src_operand" "fHm,R,fS<>"))
4052 (match_operand:QF 3 "fp_zero_operand" "G,G,G")))
4053 (set (match_operand:QF 0 "reg_operand" "=f,f,?f")
4054 (plus:QF (match_dup 1)
4056 "valid_operands (PLUS, operands, QFmode)"
4061 [(set_attr "type" "binarycc,binarycc,binarycc")])
4066 (define_expand "subqf3"
4067 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
4068 (minus:QF (match_operand:QF 1 "src_operand" "")
4069 (match_operand:QF 2 "src_operand" "")))
4070 (clobber (reg:CC_NOOV 21))])]
4072 "legitimize_operands (MINUS, operands, QFmode);")
4074 (define_insn "*subqf3_clobber"
4075 [(set (match_operand:QF 0 "reg_operand" "=f,f,f,?f")
4076 (minus:QF (match_operand:QF 1 "src_operand" "0,fHm,fR,fS<>")
4077 (match_operand:QF 2 "src_operand" "fHm,0,R,fS<>")))
4078 (clobber (reg:CC_NOOV 21))]
4079 "valid_operands (MINUS, operands, QFmode)"
4085 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
4087 (define_insn "*subqf3_test"
4088 [(set (reg:CC_NOOV 21)
4089 (compare:CC_NOOV (minus:QF (match_operand:QF 1 "src_operand" "0,fHm,fR,fS<>")
4090 (match_operand:QF 2 "src_operand" "fHm,0,R,fS<>"))
4091 (match_operand:QF 3 "fp_zero_operand" "G,G,G,G")))
4092 (clobber (match_scratch:QF 0 "=f,f,f,?f"))]
4093 "valid_operands (MINUS, operands, QFmode)"
4099 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
4101 (define_insn "*subqf3_set"
4102 [(set (reg:CC_NOOV 21)
4103 (compare:CC_NOOV (minus:QF (match_operand:QF 1 "src_operand" "0,fHm,fR,fS<>")
4104 (match_operand:QF 2 "src_operand" "fHm,0,R,fS<>"))
4105 (match_operand:QF 3 "fp_zero_operand" "G,G,G,G")))
4106 (set (match_operand:QF 0 "reg_operand" "=f,f,f,?f")
4107 (minus:QF (match_dup 1)
4109 "valid_operands (MINUS, operands, QFmode)"
4115 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
4120 (define_expand "mulqf3"
4121 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
4122 (mult:QF (match_operand:QF 1 "src_operand" "")
4123 (match_operand:QF 2 "src_operand" "")))
4124 (clobber (reg:CC_NOOV 21))])]
4126 "legitimize_operands (MULT, operands, QFmode);")
4128 (define_insn "*mulqf3_clobber"
4129 [(set (match_operand:QF 0 "reg_operand" "=f,f,?f")
4130 (mult:QF (match_operand:QF 1 "src_operand" "%0,fR,fS<>")
4131 (match_operand:QF 2 "src_operand" "fHm,R,fS<>")))
4132 (clobber (reg:CC_NOOV 21))]
4133 "valid_operands (MULT, operands, QFmode)"
4138 [(set_attr "type" "binarycc,binarycc,binarycc")])
4140 (define_insn "*mulqf3_test"
4141 [(set (reg:CC_NOOV 21)
4142 (compare:CC_NOOV (mult:QF (match_operand:QF 1 "src_operand" "%0,fR,fS<>")
4143 (match_operand:QF 2 "src_operand" "fHm,R,fS<>"))
4144 (match_operand:QF 3 "fp_zero_operand" "G,G,G")))
4145 (clobber (match_scratch:QF 0 "=f,f,?f"))]
4146 "valid_operands (MULT, operands, QFmode)"
4151 [(set_attr "type" "binarycc,binarycc,binarycc")])
4153 (define_insn "*mulqf3_set"
4154 [(set (reg:CC_NOOV 21)
4155 (compare:CC_NOOV (mult:QF (match_operand:QF 1 "src_operand" "%0,fR,fS<>")
4156 (match_operand:QF 2 "src_operand" "fHm,R,fS<>"))
4157 (match_operand:QF 3 "fp_zero_operand" "G,G,G")))
4158 (set (match_operand:QF 0 "reg_operand" "=f,f,?f")
4159 (mult:QF (match_dup 1)
4161 "valid_operands (MULT, operands, QFmode)"
4166 [(set_attr "type" "binarycc,binarycc,binarycc")])
4171 (define_expand "cmpqf"
4173 (compare:CC (match_operand:QF 0 "src_operand" "")
4174 (match_operand:QF 1 "src_operand" "")))]
4176 "legitimize_operands (COMPARE, operands, QFmode);
4177 c4x_compare_op0 = operands[0];
4178 c4x_compare_op1 = operands[1];
4181 (define_insn "*cmpqf"
4183 (compare:CC (match_operand:QF 0 "src_operand" "f,fR,fS<>")
4184 (match_operand:QF 1 "src_operand" "fHm,R,fS<>")))]
4185 "valid_operands (COMPARE, operands, QFmode)"
4190 [(set_attr "type" "compare,compare,compare")])
4192 (define_insn "*cmpqf_noov"
4193 [(set (reg:CC_NOOV 21)
4194 (compare:CC_NOOV (match_operand:QF 0 "src_operand" "f,fR,fS<>")
4195 (match_operand:QF 1 "src_operand" "fHm,R,fS<>")))]
4196 "valid_operands (COMPARE, operands, QFmode)"
4201 [(set_attr "type" "compare,compare,compare")])
4203 ; Inlined float divide for C4x
4204 (define_expand "divqf3_inline"
4205 [(parallel [(set (match_dup 3)
4206 (unspec:QF [(match_operand:QF 2 "src_operand" "")] 5))
4207 (clobber (reg:CC_NOOV 21))])
4208 (parallel [(set (match_dup 4) (mult:QF (match_dup 2) (match_dup 3)))
4209 (clobber (reg:CC_NOOV 21))])
4210 (parallel [(set (match_dup 4) (minus:QF (match_dup 5) (match_dup 4)))
4211 (clobber (reg:CC_NOOV 21))])
4212 (parallel [(set (match_dup 3) (mult:QF (match_dup 3) (match_dup 4)))
4213 (clobber (reg:CC_NOOV 21))])
4214 (parallel [(set (match_dup 4) (mult:QF (match_dup 2) (match_dup 3)))
4215 (clobber (reg:CC_NOOV 21))])
4216 (parallel [(set (match_dup 4) (minus:QF (match_dup 5) (match_dup 4)))
4217 (clobber (reg:CC_NOOV 21))])
4218 (parallel [(set (match_dup 3) (mult:QF (match_dup 3) (match_dup 4)))
4219 (clobber (reg:CC_NOOV 21))])
4220 (parallel [(set (match_dup 3)
4221 (mult:QF (match_operand:QF 1 "src_operand" "")
4223 (clobber (reg:CC_NOOV 21))])
4224 (parallel [(set (match_operand:QF 0 "reg_operand" "")
4225 (unspec:QF [(match_dup 3)] 6))
4226 (clobber (reg:CC_NOOV 21))])]
4228 "if (! reload_in_progress
4229 && ! reg_operand (operands[2], QFmode))
4230 operands[2] = force_reg (QFmode, operands[2]);
4231 operands[3] = gen_reg_rtx (QFmode);
4232 operands[4] = gen_reg_rtx (QFmode);
4233 operands[5] = CONST2_RTX (QFmode);")
4235 (define_expand "divqf3"
4236 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
4237 (div:QF (match_operand:QF 1 "src_operand" "")
4238 (match_operand:QF 2 "src_operand" "")))
4239 (clobber (reg:CC 21))])]
4240 "! TARGET_C3X && TARGET_INLINE"
4241 "emit_insn (gen_divqf3_inline (operands[0], operands[1], operands[2]));
4248 ; ??? We should make these pattern fail if the src operand combination
4249 ; is not valid. Although reload will fix things up, it will introduce
4250 ; extra load instructions that won't be hoisted out of a loop.
4252 (define_insn "*ldi_conditional"
4253 [(set (match_operand:QI 0 "reg_operand" "=r,r")
4254 (if_then_else:QI (match_operator 1 "comparison_operator"
4255 [(reg:CC 21) (const_int 0)])
4256 (match_operand:QI 2 "src_operand" "rIm,0")
4257 (match_operand:QI 3 "src_operand" "0,rIm")))]
4262 [(set_attr "type" "binary")])
4264 (define_insn "*ldi_conditional_noov"
4265 [(set (match_operand:QI 0 "reg_operand" "=r,r")
4266 (if_then_else:QI (match_operator 1 "comparison_operator"
4267 [(reg:CC_NOOV 21) (const_int 0)])
4268 (match_operand:QI 2 "src_operand" "rIm,0")
4269 (match_operand:QI 3 "src_operand" "0,rIm")))]
4270 "GET_CODE (operands[1]) != LE
4271 && GET_CODE (operands[1]) != GE
4272 && GET_CODE (operands[1]) != LT
4273 && GET_CODE (operands[1]) != GT"
4277 [(set_attr "type" "binary")])
4279 (define_insn "*ldi_on_overflow"
4280 [(set (match_operand:QI 0 "reg_operand" "=r")
4281 (unspec:QI [(match_operand:QI 1 "src_operand" "rIm")] 13))
4285 [(set_attr "type" "unary")])
4287 ; Move operand 2 to operand 0 if condition (operand 1) is true
4288 ; else move operand 3 to operand 0.
4289 ; The temporary register is required below because some of the operands
4290 ; might be identical (namely 0 and 2).
4292 (define_expand "movqicc"
4293 [(set (match_operand:QI 0 "reg_operand" "")
4294 (if_then_else:QI (match_operand 1 "comparison_operator" "")
4295 (match_operand:QI 2 "src_operand" "")
4296 (match_operand:QI 3 "src_operand" "")))]
4299 enum rtx_code code = GET_CODE (operands[1]);
4300 rtx ccreg = c4x_gen_compare_reg (code, c4x_compare_op0, c4x_compare_op1);
4301 if (ccreg == NULL_RTX) FAIL;
4302 emit_insn (gen_rtx_SET (QImode, operands[0],
4303 gen_rtx_IF_THEN_ELSE (QImode,
4304 gen_rtx (code, VOIDmode, ccreg, const0_rtx),
4305 operands[2], operands[3])));
4308 (define_insn "*ldf_conditional"
4309 [(set (match_operand:QF 0 "reg_operand" "=f,f")
4310 (if_then_else:QF (match_operator 1 "comparison_operator"
4311 [(reg:CC 21) (const_int 0)])
4312 (match_operand:QF 2 "src_operand" "fHm,0")
4313 (match_operand:QF 3 "src_operand" "0,fHm")))]
4318 [(set_attr "type" "binary")])
4320 (define_insn "*ldf_conditional_noov"
4321 [(set (match_operand:QF 0 "reg_operand" "=f,f")
4322 (if_then_else:QF (match_operator 1 "comparison_operator"
4323 [(reg:CC_NOOV 21) (const_int 0)])
4324 (match_operand:QF 2 "src_operand" "fHm,0")
4325 (match_operand:QF 3 "src_operand" "0,fHm")))]
4326 "GET_CODE (operands[1]) != LE
4327 && GET_CODE (operands[1]) != GE
4328 && GET_CODE (operands[1]) != LT
4329 && GET_CODE (operands[1]) != GT"
4333 [(set_attr "type" "binary")])
4335 (define_expand "movqfcc"
4336 [(set (match_operand:QF 0 "reg_operand" "")
4337 (if_then_else:QF (match_operand 1 "comparison_operator" "")
4338 (match_operand:QF 2 "src_operand" "")
4339 (match_operand:QF 3 "src_operand" "")))]
4342 enum rtx_code code = GET_CODE (operands[1]);
4343 rtx ccreg = c4x_gen_compare_reg (code, c4x_compare_op0, c4x_compare_op1);
4344 if (ccreg == NULL_RTX) FAIL;
4345 emit_insn (gen_rtx_SET (QFmode, operands[0],
4346 gen_rtx_IF_THEN_ELSE (QFmode,
4347 gen_rtx (code, VOIDmode, ccreg, const0_rtx),
4348 operands[2], operands[3])));
4351 (define_insn "*ldhf_conditional"
4352 [(set (match_operand:HF 0 "reg_operand" "=h,h")
4353 (if_then_else:HF (match_operator 1 "comparison_operator"
4354 [(reg:CC 21) (const_int 0)])
4355 (match_operand:HF 2 "src_operand" "hH,0")
4356 (match_operand:HF 3 "src_operand" "0,hH")))]
4361 [(set_attr "type" "binary")])
4363 (define_insn "*ldhf_conditional_noov"
4364 [(set (match_operand:HF 0 "reg_operand" "=h,h")
4365 (if_then_else:HF (match_operator 1 "comparison_operator"
4366 [(reg:CC_NOOV 21) (const_int 0)])
4367 (match_operand:HF 2 "src_operand" "hH,0")
4368 (match_operand:HF 3 "src_operand" "0,hH")))]
4369 "GET_CODE (operands[1]) != LE
4370 && GET_CODE (operands[1]) != GE
4371 && GET_CODE (operands[1]) != LT
4372 && GET_CODE (operands[1]) != GT"
4376 [(set_attr "type" "binary")])
4378 (define_expand "movhfcc"
4379 [(set (match_operand:HF 0 "reg_operand" "")
4380 (if_then_else:HF (match_operand 1 "comparison_operator" "")
4381 (match_operand:HF 2 "src_operand" "")
4382 (match_operand:HF 3 "src_operand" "")))]
4385 enum rtx_code code = GET_CODE (operands[1]);
4386 rtx ccreg = c4x_gen_compare_reg (code, c4x_compare_op0, c4x_compare_op1);
4387 if (ccreg == NULL_RTX) FAIL;
4388 emit_insn (gen_rtx_SET (HFmode, operands[0],
4389 gen_rtx_IF_THEN_ELSE (HFmode,
4390 gen_rtx (code, VOIDmode, ccreg, const0_rtx),
4391 operands[2], operands[3])));
4394 (define_expand "seq"
4395 [(set (match_operand:QI 0 "reg_operand" "")
4398 (if_then_else:QI (eq (match_dup 1) (const_int 0))
4402 "operands[1] = c4x_gen_compare_reg (EQ, c4x_compare_op0, c4x_compare_op1);")
4404 (define_expand "sne"
4405 [(set (match_operand:QI 0 "reg_operand" "")
4408 (if_then_else:QI (ne (match_dup 1) (const_int 0))
4412 "operands[1] = c4x_gen_compare_reg (NE, c4x_compare_op0, c4x_compare_op1);")
4414 (define_expand "slt"
4415 [(set (match_operand:QI 0 "reg_operand" "")
4418 (if_then_else:QI (lt (match_dup 1) (const_int 0))
4422 "operands[1] = c4x_gen_compare_reg (LT, c4x_compare_op0, c4x_compare_op1);
4423 if (operands[1] == NULL_RTX) FAIL;")
4425 (define_expand "sltu"
4426 [(set (match_operand:QI 0 "reg_operand" "")
4429 (if_then_else:QI (ltu (match_dup 1) (const_int 0))
4433 "operands[1] = c4x_gen_compare_reg (LTU, c4x_compare_op0, c4x_compare_op1);")
4435 (define_expand "sgt"
4436 [(set (match_operand:QI 0 "reg_operand" "")
4439 (if_then_else:QI (gt (match_dup 1) (const_int 0))
4443 "operands[1] = c4x_gen_compare_reg (GT, c4x_compare_op0, c4x_compare_op1);
4444 if (operands[1] == NULL_RTX) FAIL;")
4446 (define_expand "sgtu"
4447 [(set (match_operand:QI 0 "reg_operand" "")
4450 (if_then_else:QI (gtu (match_dup 1) (const_int 0))
4454 "operands[1] = c4x_gen_compare_reg (GTU, c4x_compare_op0, c4x_compare_op1);")
4456 (define_expand "sle"
4457 [(set (match_operand:QI 0 "reg_operand" "")
4460 (if_then_else:QI (le (match_dup 1) (const_int 0))
4464 "operands[1] = c4x_gen_compare_reg (LE, c4x_compare_op0, c4x_compare_op1);
4465 if (operands[1] == NULL_RTX) FAIL;")
4467 (define_expand "sleu"
4468 [(set (match_operand:QI 0 "reg_operand" "")
4471 (if_then_else:QI (leu (match_dup 1) (const_int 0))
4475 "operands[1] = c4x_gen_compare_reg (LEU, c4x_compare_op0, c4x_compare_op1);")
4477 (define_expand "sge"
4478 [(set (match_operand:QI 0 "reg_operand" "")
4481 (if_then_else:QI (ge (match_dup 1) (const_int 0))
4485 "operands[1] = c4x_gen_compare_reg (GE, c4x_compare_op0, c4x_compare_op1);
4486 if (operands[1] == NULL_RTX) FAIL;")
4488 (define_expand "sgeu"
4489 [(set (match_operand:QI 0 "reg_operand" "")
4492 (if_then_else:QI (geu (match_dup 1) (const_int 0))
4496 "operands[1] = c4x_gen_compare_reg (GEU, c4x_compare_op0, c4x_compare_op1);")
4499 [(set (match_operand:QI 0 "reg_operand" "")
4500 (match_operator:QI 1 "comparison_operator" [(reg:CC 21) (const_int 0)]))]
4502 [(set (match_dup 0) (const_int 0))
4504 (if_then_else:QI (match_op_dup 1 [(reg:CC 21) (const_int 0)])
4510 [(set (match_operand:QI 0 "reg_operand" "")
4511 (match_operator:QI 1 "comparison_operator" [(reg:CC_NOOV 21) (const_int 0)]))]
4513 [(set (match_dup 0) (const_int 0))
4515 (if_then_else:QI (match_op_dup 1 [(reg:CC_NOOV 21) (const_int 0)])
4522 (unspec [(match_operand:QI 0 "reg_operand" "r")] 1))]
4525 [(set_attr "type" "jump")])
4527 (define_expand "caseqi"
4528 [(parallel [(set (match_dup 5)
4529 (minus:QI (match_operand:QI 0 "reg_operand" "")
4530 (match_operand:QI 1 "src_operand" "")))
4531 (clobber (reg:CC_NOOV 21))])
4533 (compare:CC (match_dup 5)
4534 (match_operand:QI 2 "src_operand" "")))
4536 (if_then_else (gtu (reg:CC 21)
4538 (label_ref (match_operand 4 "" ""))
4540 (parallel [(set (match_dup 6)
4541 (plus:QI (match_dup 5)
4542 (label_ref:QI (match_operand 3 "" ""))))
4543 (clobber (reg:CC_NOOV 21))])
4545 (mem:QI (match_dup 6)))
4546 (set (pc) (match_dup 7))]
4548 "operands[5] = gen_reg_rtx (QImode);
4549 operands[6] = gen_reg_rtx (QImode);
4550 operands[7] = gen_reg_rtx (QImode);")
4553 ; PARALLEL FLOAT INSTRUCTIONS
4555 ; This patterns are under development
4561 (define_insn "*absqf2_movqf_clobber"
4562 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q")
4563 (abs:QF (match_operand:QF 1 "par_ind_operand" "S<>")))
4564 (set (match_operand:QF 2 "par_ind_operand" "=S<>")
4565 (match_operand:QF 3 "ext_low_reg_operand" "q"))
4566 (clobber (reg:CC_NOOV 21))]
4567 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QFmode)"
4568 "absf\\t%1,%0\\n||\\tstf\\t%3,%2"
4569 [(set_attr "type" "binarycc")])
4575 (define_insn "*addqf3_movqf_clobber"
4576 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q,q")
4577 (plus:QF (match_operand:QF 1 "parallel_operand" "%q,S<>")
4578 (match_operand:QF 2 "parallel_operand" "S<>,q")))
4579 (set (match_operand:QF 3 "par_ind_operand" "=S<>,S<>")
4580 (match_operand:QF 4 "ext_low_reg_operand" "q,q"))
4581 (clobber (reg:CC 21))]
4582 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QFmode)"
4583 "addf3\\t%2,%1,%0\\n||\\tstf\\t%4,%3"
4584 [(set_attr "type" "binarycc,binarycc")])
4590 (define_insn "*floatqiqf2_movqf_clobber"
4591 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q")
4592 (float:QF (match_operand:QI 1 "par_ind_operand" "S<>")))
4593 (set (match_operand:QF 2 "par_ind_operand" "=S<>")
4594 (match_operand:QF 3 "ext_low_reg_operand" "q"))
4595 (clobber (reg:CC 21))]
4596 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QFmode)"
4597 "float\\t%1,%0\\n||\\tstf\\t%3,%2"
4598 [(set_attr "type" "binarycc")])
4604 (define_insn "*mulqf3_addqf3_clobber"
4605 [(set (match_operand:QF 0 "r0r1_reg_operand" "=t,t,t,t")
4606 (mult:QF (match_operand:QF 1 "parallel_operand" "%S<>!V,q,S<>!V,q")
4607 (match_operand:QF 2 "parallel_operand" "q,S<>!V,S<>!V,q")))
4608 (set (match_operand:QF 3 "r2r3_reg_operand" "=u,u,u,u")
4609 (plus:QF (match_operand:QF 4 "parallel_operand" "%S<>!V,q,q,S<>!V")
4610 (match_operand:QF 5 "parallel_operand" "q,S<>!V,q,S<>!V")))
4611 (clobber (reg:CC_NOOV 21))]
4612 "TARGET_PARALLEL_MPY && valid_parallel_operands_6 (operands, QFmode)"
4613 "mpyf3\\t%2,%1,%0\\n||\\taddf3\\t%5,%4,%3"
4614 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
4621 (define_insn "*mulqf3_movqf_clobber"
4622 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q,q")
4623 (mult:QF (match_operand:QF 1 "parallel_operand" "%q,S<>")
4624 (match_operand:QF 2 "parallel_operand" "S<>,q")))
4625 (set (match_operand:QF 3 "par_ind_operand" "=S<>,S<>")
4626 (match_operand:QF 4 "ext_low_reg_operand" "q,q"))
4627 (clobber (reg:CC 21))]
4628 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QFmode)"
4629 "mpyf3\\t%2,%1,%0\\n||\\tstf\\t%4,%3"
4630 [(set_attr "type" "binarycc,binarycc")])
4636 (define_insn "*mulqf3_subqf3_clobber"
4637 [(set (match_operand:QF 0 "r0r1_reg_operand" "=t,t")
4638 (mult:QF (match_operand:QF 1 "parallel_operand" "S<>,q")
4639 (match_operand:QF 2 "parallel_operand" "q,S<>")))
4640 (set (match_operand:QF 3 "r2r3_reg_operand" "=u,u")
4641 (minus:QF (match_operand:QF 4 "parallel_operand" "S<>,q")
4642 (match_operand:QF 5 "parallel_operand" "q,S<>")))
4643 (clobber (reg:CC 21))]
4644 "TARGET_PARALLEL_MPY && valid_parallel_operands_6 (operands, QFmode)"
4645 "mpyf3\\t%2,%1,%0\\n||\\tsubf3\\t%5,%4,%3"
4646 [(set_attr "type" "binarycc,binarycc")])
4652 (define_insn "*mulqf3_clrqf_clobber"
4653 [(set (match_operand:QF 0 "r0r1_reg_operand" "=t")
4654 (mult:QF (match_operand:QF 1 "par_ind_operand" "%S<>")
4655 (match_operand:QF 2 "par_ind_operand" "S<>")))
4656 (set (match_operand:QF 3 "r2r3_reg_operand" "=u")
4657 (match_operand:QF 4 "fp_zero_operand" "G"))
4658 (clobber (reg:CC 21))]
4659 "TARGET_PARALLEL_MPY"
4660 "mpyf3\\t%2,%1,%0\\n||\\tsubf3\\t%3,%3,%3"
4661 [(set_attr "type" "binarycc")])
4667 (define_insn "*negqf2_movqf_clobber"
4668 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q")
4669 (neg:QF (match_operand:QF 1 "par_ind_operand" "S<>")))
4670 (set (match_operand:QF 2 "par_ind_operand" "=S<>")
4671 (match_operand:QF 3 "ext_low_reg_operand" "q"))
4672 (clobber (reg:CC 21))]
4673 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QFmode)"
4674 "negf\\t%1,%0\\n||\\tstf\\t%3,%2"
4675 [(set_attr "type" "binarycc")])
4681 (define_insn "*subqf3_movqf_clobber"
4682 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q")
4683 (minus:QF (match_operand:QF 1 "ext_low_reg_operand" "q")
4684 (match_operand:QF 2 "par_ind_operand" "S<>")))
4685 (set (match_operand:QF 3 "par_ind_operand" "=S<>")
4686 (match_operand:QF 4 "ext_low_reg_operand" "q"))
4687 (clobber (reg:CC 21))]
4688 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QFmode)"
4689 "subf3\\t%2,%1,%0\\n||\\tstf\\t%4,%3"
4690 [(set_attr "type" "binarycc")])
4696 (define_insn "*toieee_movqf_clobber"
4697 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q")
4698 (unspec:QF [(match_operand:QF 1 "par_ind_operand" "S<>")] 23))
4699 (set (match_operand:QF 2 "par_ind_operand" "=S<>")
4700 (match_operand:QF 3 "ext_low_reg_operand" "q"))
4701 (clobber (reg:CC 21))]
4702 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QFmode)"
4703 "toieee\\t%1,%0\\n||\\tstf\\t%3,%2"
4704 [(set_attr "type" "binarycc")])
4710 (define_insn "*frieee_movqf_clobber"
4711 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q")
4712 (unspec:QF [(match_operand:QF 1 "par_ind_operand" "S<>")] 24))
4713 (set (match_operand:QF 2 "par_ind_operand" "=S<>")
4714 (match_operand:QF 3 "ext_low_reg_operand" "q"))
4715 (clobber (reg:CC 21))]
4716 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QFmode)"
4717 "frieee\\t%1,%0\\n||\\tstf\\t%3,%2"
4718 [(set_attr "type" "binarycc")])
4721 ; PARALLEL INTEGER INSTRUCTIONS
4728 (define_insn "*absqi2_movqi_clobber"
4729 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4730 (abs:QI (match_operand:QI 1 "par_ind_operand" "S<>")))
4731 (set (match_operand:QI 2 "par_ind_operand" "=S<>")
4732 (match_operand:QI 3 "ext_low_reg_operand" "q"))
4733 (clobber (reg:CC_NOOV 21))]
4734 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QImode)"
4735 "absi\\t%1,%0\\n||\\tsti\\t%3,%2"
4736 [(set_attr "type" "binarycc")])
4742 (define_insn "*addqi3_movqi_clobber"
4743 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q,q")
4744 (plus:QI (match_operand:QI 1 "parallel_operand" "%q,S<>")
4745 (match_operand:QI 2 "parallel_operand" "S<>,q")))
4746 (set (match_operand:QI 3 "par_ind_operand" "=S<>,S<>")
4747 (match_operand:QI 4 "ext_low_reg_operand" "q,q"))
4748 (clobber (reg:CC 21))]
4749 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4750 "addi3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4751 [(set_attr "type" "binarycc,binarycc")])
4757 (define_insn "*andqi3_movqi_clobber"
4758 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q,q")
4759 (and:QI (match_operand:QI 1 "parallel_operand" "%q,S<>")
4760 (match_operand:QI 2 "parallel_operand" "S<>,q")))
4761 (set (match_operand:QI 3 "par_ind_operand" "=S<>,S<>")
4762 (match_operand:QI 4 "ext_low_reg_operand" "q,q"))
4763 (clobber (reg:CC 21))]
4764 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4765 "and3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4766 [(set_attr "type" "binarycc,binarycc")])
4772 (define_insn "*ashlqi3_movqi_clobber"
4773 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4774 (ashift:QI (match_operand:QI 1 "par_ind_operand" "S<>")
4775 (match_operand:QI 2 "ext_low_reg_operand" "q")))
4776 (set (match_operand:QI 3 "par_ind_operand" "=S<>")
4777 (match_operand:QI 4 "ext_low_reg_operand" "q"))
4778 (clobber (reg:CC 21))]
4779 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4780 "ash3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4781 [(set_attr "type" "binarycc")])
4787 (define_insn "*ashrqi3_movqi_clobber"
4788 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4789 (ashiftrt:QI (match_operand:QI 1 "par_ind_operand" "S<>")
4790 (neg:QI (match_operand:QI 2 "ext_low_reg_operand" "q"))))
4791 (set (match_operand:QI 3 "par_ind_operand" "=S<>")
4792 (match_operand:QI 4 "ext_low_reg_operand" "q"))
4793 (clobber (reg:CC 21))]
4794 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4795 "ash3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4796 [(set_attr "type" "binarycc")])
4802 (define_insn "*fixqfqi2_movqi_clobber"
4803 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4804 (fix:QI (match_operand:QF 1 "par_ind_operand" "S<>")))
4805 (set (match_operand:QI 2 "par_ind_operand" "=S<>")
4806 (match_operand:QI 3 "ext_low_reg_operand" "q"))
4807 (clobber (reg:CC 21))]
4808 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QImode)"
4809 "fix\\t%1,%0\\n||\\tsti\\t%3,%2"
4810 [(set_attr "type" "binarycc")])
4816 (define_insn "*lshrqi3_movqi_clobber"
4817 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4818 (lshiftrt:QI (match_operand:QI 1 "par_ind_operand" "S<>")
4819 (neg:QI (match_operand:QI 2 "ext_low_reg_operand" "q"))))
4820 (set (match_operand:QI 3 "par_ind_operand" "=S<>")
4821 (match_operand:QI 4 "ext_low_reg_operand" "q"))
4822 (clobber (reg:CC 21))]
4823 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4824 "lsh3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4825 [(set_attr "type" "binarycc")])
4831 (define_insn "*mulqi3_addqi3_clobber"
4832 [(set (match_operand:QI 0 "r0r1_reg_operand" "=t,t,t,t")
4833 (mult:QI (match_operand:QI 1 "parallel_operand" "%S<>!V,q,S<>!V,q")
4834 (match_operand:QI 2 "parallel_operand" "q,S<>!V,S<>!V,q")))
4835 (set (match_operand:QI 3 "r2r3_reg_operand" "=u,u,u,u")
4836 (plus:QI (match_operand:QI 4 "parallel_operand" "%S<>!V,q,q,S<>!V")
4837 (match_operand:QI 5 "parallel_operand" "q,S<>!V,q,S<>!V")))
4838 (clobber (reg:CC 21))]
4839 "TARGET_PARALLEL_MPY && TARGET_MPYI
4840 && valid_parallel_operands_6 (operands, QImode)"
4841 "mpyi3\\t%2,%1,%0\\n||\\taddi3\\t%5,%4,%3"
4842 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
4849 (define_insn "*mulqi3_movqi_clobber"
4850 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q,q")
4851 (mult:QI (match_operand:QI 1 "parallel_operand" "%q,S<>")
4852 (match_operand:QI 2 "parallel_operand" "S<>,q")))
4853 (set (match_operand:QI 3 "par_ind_operand" "=S<>,S<>")
4854 (match_operand:QI 4 "ext_low_reg_operand" "q,q"))
4855 (clobber (reg:CC 21))]
4856 "TARGET_PARALLEL && TARGET_MPYI
4857 && valid_parallel_operands_5 (operands, QImode)"
4858 "mpyi3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4859 [(set_attr "type" "binarycc,binarycc")])
4865 (define_insn "*mulqi3_subqi3_clobber"
4866 [(set (match_operand:QI 0 "r0r1_reg_operand" "=t,t")
4867 (mult:QI (match_operand:QI 1 "parallel_operand" "S<>,q")
4868 (match_operand:QI 2 "parallel_operand" "q,S<>")))
4869 (set (match_operand:QI 3 "r2r3_reg_operand" "=u,u")
4870 (minus:QI (match_operand:QI 4 "parallel_operand" "S<>,q")
4871 (match_operand:QI 5 "parallel_operand" "q,S<>")))
4872 (clobber (reg:CC 21))]
4873 "TARGET_PARALLEL_MPY && TARGET_MPYI
4874 && valid_parallel_operands_6 (operands, QImode)"
4875 "mpyi3\\t%2,%1,%0\\n||\\tsubi3\\t%5,%4,%3"
4876 [(set_attr "type" "binarycc,binarycc")])
4882 (define_insn "*mulqi3_clrqi_clobber"
4883 [(set (match_operand:QI 0 "r0r1_reg_operand" "=t")
4884 (mult:QI (match_operand:QI 1 "par_ind_operand" "%S<>")
4885 (match_operand:QI 2 "par_ind_operand" "S<>")))
4886 (set (match_operand:QI 3 "r2r3_reg_operand" "=u")
4888 (clobber (reg:CC 21))]
4889 "TARGET_PARALLEL_MPY && TARGET_MPYI"
4890 "mpyi3\\t%2,%1,%0\\n||\\tsubi3\\t%3,%3,%3"
4891 [(set_attr "type" "binarycc")])
4897 (define_insn "*negqi2_movqi_clobber"
4898 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4899 (neg:QI (match_operand:QI 1 "par_ind_operand" "S<>")))
4900 (set (match_operand:QI 2 "par_ind_operand" "=S<>")
4901 (match_operand:QI 3 "ext_low_reg_operand" "q"))
4902 (clobber (reg:CC 21))]
4903 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QImode)"
4904 "negi\\t%1,%0\\n||\\tsti\\t%3,%2"
4905 [(set_attr "type" "binarycc")])
4911 (define_insn "*notqi2_movqi_clobber"
4912 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4913 (not:QI (match_operand:QI 1 "par_ind_operand" "S<>")))
4914 (set (match_operand:QI 2 "par_ind_operand" "=S<>")
4915 (match_operand:QI 3 "ext_low_reg_operand" "q"))
4916 (clobber (reg:CC 21))]
4917 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QImode)"
4918 "not\\t%1,%0\\n||\\tsti\\t%3,%2"
4919 [(set_attr "type" "binarycc")])
4925 (define_insn "*iorqi3_movqi_clobber"
4926 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q,q")
4927 (ior:QI (match_operand:QI 1 "parallel_operand" "%q,S<>")
4928 (match_operand:QI 2 "parallel_operand" "S<>,q")))
4929 (set (match_operand:QI 3 "par_ind_operand" "=S<>,S<>")
4930 (match_operand:QI 4 "ext_low_reg_operand" "q,q"))
4931 (clobber (reg:CC 21))]
4932 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4933 "or3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4934 [(set_attr "type" "binarycc,binarycc")])
4940 (define_insn "*subqi3_movqi_clobber"
4941 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4942 (minus:QI (match_operand:QI 1 "par_ind_operand" "S<>")
4943 (match_operand:QI 2 "ext_low_reg_operand" "q")))
4944 (set (match_operand:QI 3 "par_ind_operand" "=S<>")
4945 (match_operand:QI 4 "ext_low_reg_operand" "q"))
4946 (clobber (reg:CC 21))]
4947 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4948 "subi3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4949 [(set_attr "type" "binarycc")])
4955 (define_insn "*xorqi3_movqi_clobber"
4956 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q,q")
4957 (xor:QI (match_operand:QI 1 "parallel_operand" "%q,S<>")
4958 (match_operand:QI 2 "parallel_operand" "S<>,q")))
4959 (set (match_operand:QI 3 "par_ind_operand" "=S<>,S<>")
4960 (match_operand:QI 4 "ext_low_reg_operand" "q,q"))
4961 (clobber (reg:CC 21))]
4962 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4963 "xor3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4964 [(set_attr "type" "binarycc,binarycc")])
4967 ; BRANCH/CALL INSTRUCTIONS
4971 ; Branch instructions
4974 [(set (pc) (if_then_else (match_operator 0 "comparison_operator"
4975 [(reg:CC 21) (const_int 0)])
4976 (label_ref (match_operand 1 "" ""))
4980 return c4x_output_cbranch (\"b%0\", insn);"
4981 [(set_attr "type" "jmpc")])
4983 (define_insn "*b_rev"
4984 [(set (pc) (if_then_else (match_operator 0 "comparison_operator"
4985 [(reg:CC 21) (const_int 0)])
4987 (label_ref (match_operand 1 "" ""))))]
4990 return c4x_output_cbranch (\"b%I0\", insn);"
4991 [(set_attr "type" "jmpc")])
4993 (define_insn "*b_noov"
4994 [(set (pc) (if_then_else (match_operator 0 "comparison_operator"
4995 [(reg:CC_NOOV 21) (const_int 0)])
4996 (label_ref (match_operand 1 "" ""))
4998 "GET_CODE (operands[0]) != LE
4999 && GET_CODE (operands[0]) != GE
5000 && GET_CODE (operands[0]) != LT
5001 && GET_CODE (operands[0]) != GT"
5003 return c4x_output_cbranch (\"b%0\", insn);"
5004 [(set_attr "type" "jmpc")])
5006 (define_insn "*b_noov_rev"
5007 [(set (pc) (if_then_else (match_operator 0 "comparison_operator"
5008 [(reg:CC_NOOV 21) (const_int 0)])
5010 (label_ref (match_operand 1 "" ""))))]
5011 "GET_CODE (operands[0]) != LE
5012 && GET_CODE (operands[0]) != GE
5013 && GET_CODE (operands[0]) != LT
5014 && GET_CODE (operands[0]) != GT"
5016 return c4x_output_cbranch (\"b%I0\", insn);"
5017 [(set_attr "type" "jmpc")])
5019 (define_expand "beq"
5020 [(set (pc) (if_then_else (eq (match_dup 1) (const_int 0))
5021 (label_ref (match_operand 0 "" ""))
5024 "operands[1] = c4x_gen_compare_reg (EQ, c4x_compare_op0, c4x_compare_op1);")
5026 (define_expand "bne"
5027 [(set (pc) (if_then_else (ne (match_dup 1) (const_int 0))
5028 (label_ref (match_operand 0 "" ""))
5031 "operands[1] = c4x_gen_compare_reg (NE, c4x_compare_op0, c4x_compare_op1);")
5033 (define_expand "blt"
5034 [(set (pc) (if_then_else (lt (match_dup 1) (const_int 0))
5035 (label_ref (match_operand 0 "" ""))
5038 "operands[1] = c4x_gen_compare_reg (LT, c4x_compare_op0, c4x_compare_op1);
5039 if (operands[1] == NULL_RTX) FAIL;")
5041 (define_expand "bltu"
5042 [(set (pc) (if_then_else (ltu (match_dup 1) (const_int 0))
5043 (label_ref (match_operand 0 "" ""))
5046 "operands[1] = c4x_gen_compare_reg (LTU, c4x_compare_op0, c4x_compare_op1);")
5048 (define_expand "bgt"
5049 [(set (pc) (if_then_else (gt (match_dup 1) (const_int 0))
5050 (label_ref (match_operand 0 "" ""))
5053 "operands[1] = c4x_gen_compare_reg (GT, c4x_compare_op0, c4x_compare_op1);
5054 if (operands[1] == NULL_RTX) FAIL;")
5056 (define_expand "bgtu"
5057 [(set (pc) (if_then_else (gtu (match_dup 1) (const_int 0))
5058 (label_ref (match_operand 0 "" ""))
5061 "operands[1] = c4x_gen_compare_reg (GTU, c4x_compare_op0, c4x_compare_op1);")
5063 (define_expand "ble"
5064 [(set (pc) (if_then_else (le (match_dup 1) (const_int 0))
5065 (label_ref (match_operand 0 "" ""))
5068 "operands[1] = c4x_gen_compare_reg (LE, c4x_compare_op0, c4x_compare_op1);
5069 if (operands[1] == NULL_RTX) FAIL;")
5071 (define_expand "bleu"
5072 [(set (pc) (if_then_else (leu (match_dup 1) (const_int 0))
5073 (label_ref (match_operand 0 "" ""))
5076 "operands[1] = c4x_gen_compare_reg (LEU, c4x_compare_op0, c4x_compare_op1);")
5078 (define_expand "bge"
5079 [(set (pc) (if_then_else (ge (match_dup 1) (const_int 0))
5080 (label_ref (match_operand 0 "" ""))
5083 "operands[1] = c4x_gen_compare_reg (GE, c4x_compare_op0, c4x_compare_op1);
5084 if (operands[1] == NULL_RTX) FAIL;")
5086 (define_expand "bgeu"
5087 [(set (pc) (if_then_else (geu (match_dup 1) (const_int 0))
5088 (label_ref (match_operand 0 "" ""))
5091 "operands[1] = c4x_gen_compare_reg (GEU, c4x_compare_op0, c4x_compare_op1);")
5093 (define_insn "*b_reg"
5094 [(set (pc) (match_operand:QI 0 "reg_operand" "r"))]
5097 [(set_attr "type" "jump")])
5099 (define_expand "indirect_jump"
5100 [(set (pc) (match_operand:QI 0 "reg_operand" ""))]
5104 (define_insn "tablejump"
5105 [(set (pc) (match_operand:QI 0 "src_operand" "r"))
5106 (use (label_ref (match_operand 1 "" "")))]
5109 [(set_attr "type" "jump")])
5114 (define_insn "*call_c3x"
5115 [(call (mem:QI (match_operand:QI 0 "call_address_operand" "Ur"))
5116 (match_operand:QI 1 "general_operand" ""))
5117 (clobber (reg:QI 31))]
5118 ;; Operand 1 not really used on the C4x. The C30 doesn't have reg 31.
5122 [(set_attr "type" "call")])
5124 ; LAJ requires R11 (31) for the return address
5126 [(call (mem:QI (match_operand:QI 0 "call_address_operand" "Ur"))
5127 (match_operand:QI 1 "general_operand" ""))
5128 (clobber (reg:QI 31))]
5129 ;; Operand 1 not really used on the C4x.
5134 return c4x_check_laj_p (insn)
5135 ? \"nop\\n\\tlaj%U0\\t%C0\" : \"laj%U0\\t%C0\";
5137 return \"call%U0\\t%C0\";"
5138 [(set_attr "type" "laj")])
5140 (define_expand "call"
5141 [(parallel [(call (match_operand:QI 0 "" "")
5142 (match_operand:QI 1 "general_operand" ""))
5143 (clobber (reg:QI 31))])]
5147 if (GET_CODE (operands[0]) == MEM
5148 && ! call_address_operand (XEXP (operands[0], 0), Pmode))
5149 operands[0] = gen_rtx_MEM (GET_MODE (operands[0]),
5150 force_reg (Pmode, XEXP (operands[0], 0)));
5153 (define_insn "nodb_call"
5154 [(call (mem:QI (match_operand:QI 0 "call_address_operand" "Ur"))
5158 [(set_attr "type" "call")])
5160 (define_insn "*callv_c3x"
5161 [(set (match_operand 0 "" "=r")
5162 (call (mem:QI (match_operand:QI 1 "call_address_operand" "Ur"))
5163 (match_operand:QI 2 "general_operand" "")))
5164 (clobber (reg:QI 31))]
5165 ;; Operand 0 and 2 not really used for the C4x.
5166 ;; The C30 doesn't have reg 31.
5170 [(set_attr "type" "call")])
5172 ; LAJ requires R11 (31) for the return address
5173 (define_insn "*lajv"
5174 [(set (match_operand 0 "" "=r")
5175 (call (mem:QI (match_operand:QI 1 "call_address_operand" "Ur"))
5176 (match_operand:QI 2 "general_operand" "")))
5177 (clobber (reg:QI 31))]
5178 ;; Operand 0 and 2 not really used in the C30 instruction.
5183 return c4x_check_laj_p (insn)
5184 ? \"nop\\n\\tlaj%U1\\t%C1\" : \"laj%U1\\t%C1\";
5186 return \"call%U1\\t%C1\";"
5187 [(set_attr "type" "laj")])
5189 (define_expand "call_value"
5190 [(parallel [(set (match_operand 0 "" "")
5191 (call (match_operand:QI 1 "" "")
5192 (match_operand:QI 2 "general_operand" "")))
5193 (clobber (reg:QI 31))])]
5197 if (GET_CODE (operands[0]) == MEM
5198 && ! call_address_operand (XEXP (operands[1], 0), Pmode))
5199 operands[0] = gen_rtx_MEM (GET_MODE (operands[1]),
5200 force_reg (Pmode, XEXP (operands[1], 0)));
5203 (define_insn "return"
5205 "c4x_null_epilogue_p ()"
5207 [(set_attr "type" "rets")])
5209 (define_insn "return_from_epilogue"
5211 "reload_completed && ! c4x_interrupt_function_p ()"
5213 [(set_attr "type" "rets")])
5215 (define_insn "return_from_interrupt_epilogue"
5217 "reload_completed && c4x_interrupt_function_p ()"
5219 [(set_attr "type" "rets")])
5221 (define_insn "*return_cc"
5223 (if_then_else (match_operator 0 "comparison_operator"
5224 [(reg:CC 21) (const_int 0)])
5227 "c4x_null_epilogue_p ()"
5229 [(set_attr "type" "rets")])
5231 (define_insn "*return_cc_noov"
5233 (if_then_else (match_operator 0 "comparison_operator"
5234 [(reg:CC_NOOV 21) (const_int 0)])
5237 "GET_CODE (operands[0]) != LE
5238 && GET_CODE (operands[0]) != GE
5239 && GET_CODE (operands[0]) != LT
5240 && GET_CODE (operands[0]) != GT
5241 && c4x_null_epilogue_p ()"
5243 [(set_attr "type" "rets")])
5245 (define_insn "*return_cc_inverse"
5247 (if_then_else (match_operator 0 "comparison_operator"
5248 [(reg:CC 21) (const_int 0)])
5251 "c4x_null_epilogue_p ()"
5253 [(set_attr "type" "rets")])
5255 (define_insn "*return_cc_noov_inverse"
5257 (if_then_else (match_operator 0 "comparison_operator"
5258 [(reg:CC_NOOV 21) (const_int 0)])
5261 "GET_CODE (operands[0]) != LE
5262 && GET_CODE (operands[0]) != GE
5263 && GET_CODE (operands[0]) != LT
5264 && GET_CODE (operands[0]) != GT
5265 && c4x_null_epilogue_p ()"
5267 [(set_attr "type" "rets")])
5270 [(set (pc) (label_ref (match_operand 0 "" "")))]
5273 [(set_attr "type" "jump")])
5276 [(trap_if (const_int 1) (const_int 31))]
5279 [(set_attr "type" "call")])
5281 (define_expand "conditional_trap"
5282 [(trap_if (match_operand 0 "comparison_operator" "")
5283 (match_operand 1 "const_int_operand" ""))]
5286 enum rtx_code code = GET_CODE (operands[1]);
5287 rtx ccreg = c4x_gen_compare_reg (code, c4x_compare_op0, c4x_compare_op1);
5288 if (ccreg == NULL_RTX) FAIL;
5289 if (GET_MODE (ccreg) == CCmode)
5290 emit_insn (gen_cond_trap_cc (operands[0], operands[1]));
5292 emit_insn (gen_cond_trap_cc_noov (operands[0], operands[1]));
5295 (define_insn "cond_trap_cc"
5296 [(trap_if (match_operator 0 "comparison_operator"
5297 [(reg:CC 21) (const_int 0)])
5298 (match_operand 1 "const_int_operand" ""))]
5301 [(set_attr "type" "call")])
5303 (define_insn "cond_trap_cc_noov"
5304 [(trap_if (match_operator 0 "comparison_operator"
5305 [(reg:CC_NOOV 21) (const_int 0)])
5306 (match_operand 1 "const_int_operand" ""))]
5307 "GET_CODE (operands[0]) != LE
5308 && GET_CODE (operands[0]) != GE
5309 && GET_CODE (operands[0]) != LT
5310 && GET_CODE (operands[0]) != GT"
5312 [(set_attr "type" "call")])
5317 ; Note we have to emit a dbu instruction if there are no delay slots
5319 ; Also note that GCC will try to reverse a loop to see if it can
5320 ; utilize this instruction. However, if there are more than one
5321 ; memory reference in the loop, it cannot guarantee that reversing
5322 ; the loop will work :( (see check_dbra_loop() in loop.c)
5323 ; Note that the C3x only decrements the 24 LSBs of the address register
5324 ; and the 8 MSBs are untouched. The C4x uses all 32-bits. We thus
5325 ; have an option to disable this instruction.
5328 (if_then_else (ne (match_operand:QI 0 "addr_reg_operand" "+a,?*d,??*r,!m")
5330 (label_ref (match_operand 1 "" ""))
5333 (plus:QI (match_dup 0)
5336 (clobber (reg:CC_NOOV 21))]
5337 "TARGET_DB && TARGET_LOOP_UNSIGNED"
5339 if (which_alternative == 0)
5340 return \"dbu%#\\t%0,%l1\";
5341 else if (which_alternative == 1)
5342 return c4x_output_cbranch (\"subi\\t1,%0\\n\\tbge\", insn);
5343 else if (which_alternative == 2)
5344 return c4x_output_cbranch (\"subi\\t1,%0\\n\\tcmpi\\t0,%0\\n\\tbge\", insn);
5346 return c4x_output_cbranch (\"push\\tr0\\n\\tldi\\t%0,r0\\n\\tsubi\\t1,r0\\n\\tsti\\tr0,%0\\n\\tpop\\tr0\\n\\tbhs\", insn);
5348 [(set_attr "type" "db,jmpc,jmpc,jmpc")])
5350 (define_insn "*db_noclobber"
5352 (if_then_else (ne (match_operand:QI 0 "addr_reg_operand" "+a")
5354 (label_ref (match_operand 1 "" ""))
5357 (plus:QI (match_dup 0)
5359 "reload_completed && TARGET_DB && TARGET_LOOP_UNSIGNED"
5361 [(set_attr "type" "db")])
5365 (if_then_else (ne (match_operand:QI 0 "addr_reg_operand" "")
5367 (label_ref (match_operand 1 "" ""))
5370 (plus:QI (match_dup 0)
5373 (clobber (reg:CC_NOOV 21))]
5374 "reload_completed && TARGET_DB && TARGET_LOOP_UNSIGNED"
5375 [(parallel [(set (pc)
5376 (if_then_else (ne (match_dup 0)
5378 (label_ref (match_dup 1))
5381 (plus:QI (match_dup 0)
5386 ; This insn is used for some loop tests, typically loops reversed when
5387 ; strength reduction is used. It is actually created when the instruction
5388 ; combination phase combines the special loop test. Since this insn
5389 ; is both a jump insn and has an output, it must deal with its own
5390 ; reloads, hence the `m' constraints.
5392 ; The C4x does the decrement and then compares the result against zero.
5393 ; It branches if the result was greater than or equal to zero.
5394 ; In the RTL the comparison and decrement are assumed to happen
5395 ; at the same time so we bias the iteration counter with by -1
5396 ; when we make the test.
5397 (define_insn "decrement_and_branch_until_zero"
5399 (if_then_else (ge (plus:QI (match_operand:QI 0 "addr_reg_operand" "+a,?*d,??*r,!m")
5402 (label_ref (match_operand 1 "" ""))
5405 (plus:QI (match_dup 0)
5408 (clobber (reg:CC_NOOV 21))]
5409 "TARGET_DB && (find_reg_note (insn, REG_NONNEG, 0) || TARGET_LOOP_UNSIGNED)"
5411 if (which_alternative == 0)
5412 return \"dbu%#\\t%0,%l1\";
5413 else if (which_alternative == 1)
5414 return c4x_output_cbranch (\"subi\\t1,%0\\n\\tbge\", insn);
5415 else if (which_alternative == 2)
5416 return c4x_output_cbranch (\"subi\\t1,%0\\n\\tcmpi\\t0,%0\\n\\tbge\", insn);
5418 return c4x_output_cbranch (\"push\\tr0\\n\\tldi\\t%0,r0\\n\\tsubi\\t1,r0\\n\\tsti\\tr0,%0\\n\\tpop\\tr0\\n\\tbhs\", insn);
5420 [(set_attr "type" "db,jmpc,jmpc,jmpc")])
5422 (define_insn "*decrement_and_branch_until_zero_noclobber"
5424 (if_then_else (ge (plus:QI (match_operand:QI 0 "addr_reg_operand" "+a")
5427 (label_ref (match_operand 1 "" ""))
5430 (plus:QI (match_dup 0)
5432 "reload_completed && TARGET_DB && TARGET_LOOP_UNSIGNED"
5434 [(set_attr "type" "db")])
5438 (if_then_else (ge (plus:QI (match_operand:QI 0 "addr_reg_operand" "")
5441 (label_ref (match_operand 1 "" ""))
5444 (plus:QI (match_dup 0)
5447 (clobber (reg:CC_NOOV 21))]
5448 "reload_completed && TARGET_DB && TARGET_LOOP_UNSIGNED"
5449 [(parallel [(set (pc)
5450 (if_then_else (ge (plus:QI (match_dup 0)
5453 (label_ref (match_dup 1))
5456 (plus:QI (match_dup 0)
5471 ; Default to misc type attr.
5473 (define_insn "return_indirect_internal"
5475 (use (match_operand:QI 0 "reg_operand" ""))]
5478 [(set_attr "type" "jump")])
5480 (define_expand "prologue"
5483 "c4x_expand_prologue (); DONE;")
5485 (define_expand "epilogue"
5488 "c4x_expand_epilogue (); DONE;")
5493 (define_insn "rptb_top"
5494 [(use (label_ref (match_operand 0 "" "")))
5495 (use (label_ref (match_operand 1 "" "")))
5496 (clobber (reg:QI 25))
5497 (clobber (reg:QI 26))]
5500 return ! final_sequence && c4x_rptb_rpts_p (insn, operands[0])
5501 ? \"rpts\\trc\" : \"rptb%#\\t%l1-1\";
5503 [(set_attr "type" "repeat_top")])
5505 (define_insn "rpts_top"
5506 [(unspec [(use (label_ref (match_operand 0 "" "")))
5507 (use (label_ref (match_operand 1 "" "")))] 2)
5508 (clobber (reg:QI 25))
5509 (clobber (reg:QI 26))]
5512 return ! final_sequence && c4x_rptb_rpts_p (insn, operands[0])
5513 ? \"rpts\\trc\" : \"rptb%#\\t%l1-1\";
5515 [(set_attr "type" "repeat")])
5517 ; This pattern needs to be emitted at the start of the loop to
5518 ; say that RS and RE are loaded.
5519 (define_insn "rptb_init"
5520 [(unspec [(match_operand:QI 0 "register_operand" "va")] 22)
5521 (clobber (reg:QI 25))
5522 (clobber (reg:QI 26))]
5525 [(set_attr "type" "repeat")])
5528 ; operand 0 is the loop count pseudo register
5529 ; operand 1 is the number of loop iterations or 0 if it is unknown
5530 ; operand 2 is the maximum number of loop iterations
5531 ; operand 3 is the number of levels of enclosed loops
5532 (define_expand "doloop_begin"
5533 [(use (match_operand 0 "register_operand" ""))
5534 (use (match_operand:QI 1 "const_int_operand" ""))
5535 (use (match_operand:QI 2 "const_int_operand" ""))
5536 (use (match_operand:QI 3 "const_int_operand" ""))]
5538 "if (INTVAL (operands[3]) > 1 || ! TARGET_RPTB)
5540 emit_insn (gen_rptb_init (operands[0]));
5545 ; The RS (25) and RE (26) registers must be unviolate from the top of the loop
5547 (define_insn "rptb_end"
5549 (if_then_else (ge (match_operand:QI 0 "register_operand" "+v,?a,!*d,!*x*k,!m")
5551 (label_ref (match_operand 1 "" ""))
5554 (plus:QI (match_dup 0)
5559 (clobber (reg:CC_NOOV 21))]
5562 if (which_alternative == 0)
5563 return c4x_rptb_nop_p (insn) ? \"nop\" : \"\";
5564 else if (which_alternative == 1 && TARGET_DB)
5565 return \"dbu%#\\t%0,%l1\";
5566 else if (which_alternative == 2)
5567 return c4x_output_cbranch (\"subi\\t1,%0\\n\\tbge\", insn);
5568 else if (which_alternative == 3 || (which_alternative == 1 && ! TARGET_DB))
5569 return c4x_output_cbranch (\"subi\\t1,%0\\n\\tcmpi\\t0,%0\\n\\tbge\", insn);
5571 return c4x_output_cbranch (\"push\\tr0\\n\\tldi\\t%0,r0\\n\\tsubi\\t1,r0\\n\\tsti\\tr0,%0\\n\\tpop\\tr0\\n\\tbhs\", insn);
5573 [(set_attr "type" "repeat,db,jmpc,jmpc,jmpc")])
5577 (if_then_else (ge (match_operand:QI 0 "addr_reg_operand" "")
5579 (label_ref (match_operand 1 "" ""))
5582 (plus:QI (match_dup 0)
5584 (use (match_operand:QI 2 "const_int_operand" ""))
5585 (use (match_operand:QI 3 "const_int_operand" ""))
5586 (use (match_operand:QI 4 "const_int_operand" ""))
5590 (clobber (reg:CC_NOOV 21))]
5592 [(parallel [(set (pc)
5593 (if_then_else (ge (match_dup 0)
5595 (label_ref (match_dup 1))
5598 (plus:QI (match_dup 0)
5602 ; operand 0 is the loop count pseudo register
5603 ; operand 1 is the number of loop iterations or 0 if it is unknown
5604 ; operand 2 is the maximum number of loop iterations
5605 ; operand 3 is the number of levels of enclosed loops
5606 ; operand 4 is the label to jump to at the top of the loop
5607 (define_expand "doloop_end"
5608 [(use (match_operand 0 "register_operand" ""))
5609 (use (match_operand:QI 1 "const_int_operand" ""))
5610 (use (match_operand:QI 2 "const_int_operand" ""))
5611 (use (match_operand:QI 3 "const_int_operand" ""))
5612 (use (label_ref (match_operand 4 "" "")))]
5614 "if (! TARGET_LOOP_UNSIGNED
5615 && (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > ((unsigned) 1 << 31))
5617 if (INTVAL (operands[3]) > 1 || ! TARGET_RPTB)
5619 /* The C30 maximum iteration count for DB is 2^24. */
5622 emit_jump_insn (gen_decrement_and_branch_until_zero (operands[0],
5626 emit_jump_insn (gen_rptb_end (operands[0], operands[4]));
5630 ; The current low overhead looping code is naff and is not failsafe
5631 ; If you want RTPB instructions to be generated, apply the patches
5632 ; from www.elec.canterbury.ac.nz/c4x. This will utilize the
5633 ; doloop_begin and doloop_end patterns in this MD.
5634 (define_expand "decrement_and_branch_on_count"
5635 [(parallel [(set (pc)
5636 (if_then_else (ge (match_operand:QI 0 "register_operand" "")
5638 (label_ref (match_operand 1 "" ""))
5641 (plus:QI (match_dup 0)
5645 (clobber (reg:CC_NOOV 21))])]
5649 (define_expand "movstrqi_small2"
5650 [(parallel [(set (mem:BLK (match_operand:BLK 0 "src_operand" ""))
5651 (mem:BLK (match_operand:BLK 1 "src_operand" "")))
5652 (use (match_operand:QI 2 "immediate_operand" ""))
5653 (use (match_operand:QI 3 "immediate_operand" ""))
5654 (clobber (match_operand:QI 4 "ext_low_reg_operand" ""))])]
5659 rtx src_mem, dst_mem;
5665 len = INTVAL (operands[2]);
5668 src_mem = gen_rtx_MEM (QImode, src);
5669 dst_mem = gen_rtx_MEM (QImode, dst);
5671 if (TARGET_PARALLEL)
5673 emit_insn (gen_movqi (tmp, src_mem));
5674 emit_insn (gen_addqi3_noclobber (src, src, const1_rtx));
5675 for (i = 1; i < len; i++)
5677 emit_insn (gen_movqi_parallel (tmp, src_mem, dst_mem, tmp));
5678 emit_insn (gen_addqi3_noclobber (src, src, const1_rtx));
5679 emit_insn (gen_addqi3_noclobber (dst, dst, const1_rtx));
5681 emit_insn (gen_movqi (dst_mem, tmp));
5682 emit_insn (gen_addqi3_noclobber (dst, dst, const1_rtx));
5686 for (i = 0; i < len; i++)
5688 emit_insn (gen_movqi (tmp, src_mem));
5689 emit_insn (gen_movqi (dst_mem, tmp));
5690 emit_insn (gen_addqi3_noclobber (src, src, const1_rtx));
5691 emit_insn (gen_addqi3_noclobber (dst, dst, const1_rtx));
5701 ; We should probably get RC loaded when using RPTB automagically...
5702 ; There's probably no need to call _memcpy() if we don't get
5703 ; an immediate operand for the size. We could do a better job here
5704 ; than most memcpy() implementations.
5705 ; operand 2 is the number of bytes
5706 ; operand 3 is the shared alignment
5707 ; operand 4 is a scratch register
5709 (define_insn "movstrqi_small"
5710 [(set (mem:BLK (match_operand:QI 0 "addr_reg_operand" "+a"))
5711 (mem:BLK (match_operand:QI 1 "addr_reg_operand" "+a")))
5712 (use (match_operand:QI 2 "immediate_operand" "i"))
5713 (use (match_operand:QI 3 "immediate_operand" ""))
5714 (clobber (match_operand:QI 4 "ext_low_reg_operand" "=&q"))
5715 (clobber (match_dup 0))
5716 (clobber (match_dup 1))]
5721 int len = INTVAL (operands[2]);
5724 for (i = 0; i < len; i++)
5727 output_asm_insn (\"ldiu\\t*%1++,%4\", operands);
5729 output_asm_insn (\"|| ldi\\t*%1++,%4\", operands);
5730 output_asm_insn (\"sti\\t%4,*%0++\", operands);
5736 [(set_attr "type" "multi")])
5738 (define_insn "movstrqi_large"
5739 [(set (mem:BLK (match_operand:QI 0 "addr_reg_operand" "+a"))
5740 (mem:BLK (match_operand:QI 1 "addr_reg_operand" "+a")))
5741 (use (match_operand:QI 2 "immediate_operand" "i"))
5742 (use (match_operand:QI 3 "immediate_operand" ""))
5743 (clobber (match_operand:QI 4 "ext_low_reg_operand" "=&q"))
5744 (clobber (match_dup 0))
5745 (clobber (match_dup 1))
5746 (clobber (reg:QI 25))
5747 (clobber (reg:QI 26))
5748 (clobber (reg:QI 27))]
5752 int len = INTVAL (operands[2]);
5754 output_asm_insn (\"ldiu\\t*%1++,%4\", operands);
5755 if (TARGET_RPTS_CYCLES (len))
5757 output_asm_insn (\"rpts\\t%2-2\", operands);
5758 output_asm_insn (\"sti\\t%4,*%0++\", operands);
5759 output_asm_insn (\"|| ldi\\t*%1++,%4\", operands);
5760 return \"sti\\t%4,*%0++\";
5764 output_asm_insn (\"ldiu\\t%2-2,rc\", operands);
5765 output_asm_insn (\"rptb\\t$+1\", operands);
5766 output_asm_insn (\"sti\\t%4,*%0++\", operands);
5767 output_asm_insn (\"|| ldi\\t*%1++,%4\", operands);
5769 return \"sti\\t%4,*%0++\";
5773 [(set_attr "type" "multi")])
5775 ; Operand 2 is the count, operand 3 is the alignment.
5776 (define_expand "movstrqi"
5777 [(parallel [(set (mem:BLK (match_operand:BLK 0 "src_operand" ""))
5778 (mem:BLK (match_operand:BLK 1 "src_operand" "")))
5779 (use (match_operand:QI 2 "immediate_operand" ""))
5780 (use (match_operand:QI 3 "immediate_operand" ""))])]
5785 if (GET_CODE (operands[2]) != CONST_INT
5786 || INTVAL (operands[2]) > 32767
5787 || INTVAL (operands[2]) <= 0)
5789 FAIL; /* Try to call _memcpy */
5792 operands[0] = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
5793 operands[1] = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
5794 tmp = gen_reg_rtx (QImode);
5795 if (INTVAL (operands[2]) < 8)
5796 emit_insn (gen_movstrqi_small2 (operands[0], operands[1], operands[2],
5800 emit_insn (gen_movstrqi_large (operands[0], operands[1], operands[2],
5807 (define_insn "*cmpstrqi"
5808 [(set (match_operand:QI 0 "ext_reg_operand" "=d")
5809 (compare:QI (mem:BLK (match_operand:QI 1 "addr_reg_operand" "+a"))
5810 (mem:BLK (match_operand:QI 2 "addr_reg_operand" "+a"))))
5811 (use (match_operand:QI 3 "immediate_operand" "i"))
5812 (use (match_operand:QI 4 "immediate_operand" ""))
5813 (clobber (match_operand:QI 5 "std_reg_operand" "=&c"))
5814 (clobber (reg:QI 21))]
5818 output_asm_insn (\"ldi\\t%3-1,%5\", operands);
5819 output_asm_insn (\"$1:\tsubi3\\t*%1++,*%2++,%0\", operands);
5820 output_asm_insn (\"dbeq\\t%5,$1\", operands);
5824 (define_expand "cmpstrqi"
5825 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
5826 (compare:QI (match_operand:BLK 1 "general_operand" "")
5827 (match_operand:BLK 2 "general_operand" "")))
5828 (use (match_operand:QI 3 "immediate_operand" ""))
5829 (use (match_operand:QI 4 "immediate_operand" ""))
5830 (clobber (match_dup 5))
5831 (clobber (reg:QI 21))])]
5835 if (GET_CODE (operands[3]) != CONST_INT
5836 || INTVAL (operands[3]) > 32767
5837 || INTVAL (operands[3]) <= 0)
5841 operands[1] = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
5842 operands[2] = copy_to_mode_reg (Pmode, XEXP (operands[2], 0));
5843 operands[5] = gen_reg_rtx (QImode);
5847 ; TWO OPERAND LONG DOUBLE INSTRUCTIONS
5850 (define_expand "movhf"
5851 [(set (match_operand:HF 0 "src_operand" "")
5852 (match_operand:HF 1 "src_operand" ""))]
5854 "if (c4x_emit_move_sequence (operands, HFmode))
5857 (define_insn "*movhf_noclobber_reg"
5858 [(set (match_operand:HF 0 "reg_operand" "=h")
5859 (match_operand:HF 1 "src_operand" "Hh"))]
5860 "GET_CODE (operands[1]) != MEM"
5862 [(set_attr "type" "unary")])
5864 (define_insn "*movhf_noclobber"
5865 [(set (match_operand:HF 0 "dst_operand" "=h,m")
5866 (match_operand:HF 1 "src_operand" "Hm,h"))]
5867 "reg_operand (operands[0], HFmode) ^ reg_operand (operands[1], HFmode)"
5869 [(set_attr "type" "multi,multi")])
5871 (define_insn "*movhf_test"
5873 (compare:CC (match_operand:HF 1 "reg_operand" "h")
5875 (clobber (match_scratch:HF 0 "=h"))]
5878 [(set_attr "type" "unarycc")])
5880 (define_insn "*movhf_set"
5882 (compare:CC (match_operand:HF 1 "reg_operand" "h")
5883 (match_operand:HF 2 "fp_zero_operand" "G")))
5884 (set (match_operand:HF 0 "reg_operand" "=h")
5888 [(set_attr "type" "unarycc")])
5891 [(set (match_operand:HF 0 "reg_operand" "")
5892 (match_operand:HF 1 "memory_operand" ""))]
5894 [(set (match_dup 0) (float_extend:HF (match_dup 2)))
5895 (set (match_dup 0) (unspec:HF [(subreg:QI (match_dup 0) 0)
5897 "operands[2] = c4x_operand_subword (operands[1], 0, 1, HFmode);
5898 operands[3] = c4x_operand_subword (operands[1], 1, 1, HFmode);
5899 PUT_MODE (operands[2], QFmode);
5900 PUT_MODE (operands[3], QImode);")
5903 [(set (match_operand:HF 0 "reg_operand" "")
5904 (match_operand:HF 1 "const_operand" ""))]
5905 "reload_completed && 0"
5906 [(set (match_dup 0) (float_extend:HF (match_dup 2)))
5907 (set (match_dup 0) (unspec:HF [(subreg:QI (match_dup 0) 0)
5909 "operands[2] = c4x_operand_subword (operands[1], 0, 1, HFmode);
5910 operands[3] = c4x_operand_subword (operands[1], 1, 1, HFmode);
5911 PUT_MODE (operands[2], QFmode);
5912 PUT_MODE (operands[3], QImode);")
5915 [(set (match_operand:HF 0 "memory_operand" "")
5916 (match_operand:HF 1 "reg_operand" ""))]
5918 [(set (match_dup 2) (float_truncate:QF (match_dup 1)))
5919 (set (match_dup 3) (unspec:QI [(match_dup 1)] 9))]
5920 "operands[2] = c4x_operand_subword (operands[0], 0, 1, HFmode);
5921 operands[3] = c4x_operand_subword (operands[0], 1, 1, HFmode);
5922 PUT_MODE (operands[2], QFmode);
5923 PUT_MODE (operands[3], QImode);")
5925 (define_insn "*loadhf_float"
5926 [(set (match_operand:HF 0 "reg_operand" "=h")
5927 (float_extend:HF (match_operand:QF 1 "src_operand" "fHm")))]
5930 [(set_attr "type" "unary")])
5932 (define_insn "*loadhf_int"
5933 [(set (match_operand:HF 0 "reg_operand" "+h")
5934 (unspec:HF [(subreg:QI (match_dup 0) 0)
5935 (match_operand:QI 1 "src_operand" "rIm")] 8))]
5938 [(set_attr "type" "unary")])
5940 (define_insn "*storehf_float"
5941 [(set (match_operand:QF 0 "memory_operand" "=m")
5942 (float_truncate:QF (match_operand:HF 1 "reg_operand" "h")))]
5945 [(set_attr "type" "store")])
5947 (define_insn "*storehf_int"
5948 [(set (match_operand:QI 0 "memory_operand" "=m")
5949 (unspec:QI [(match_operand:HF 1 "reg_operand" "h")] 9))]
5952 [(set_attr "type" "store")])
5954 (define_insn "extendqfhf2"
5955 [(set (match_operand:HF 0 "reg_operand" "=h")
5956 (float_extend:HF (match_operand:QF 1 "reg_operand" "h")))]
5959 [(set_attr "type" "unarycc")])
5961 (define_insn "trunchfqf2"
5962 [(set (match_operand:QF 0 "reg_operand" "=h")
5963 (float_truncate:QF (match_operand:HF 1 "reg_operand" "0")))
5964 (clobber (reg:CC 21))]
5967 [(set_attr "type" "unarycc")])
5972 (define_insn "pushhf"
5973 [(set (mem:HF (pre_inc:QI (reg:QI 20)))
5974 (match_operand:HF 0 "reg_operand" "h"))]
5977 [(set_attr "type" "multi")])
5980 [(set (mem:HF (pre_inc:QI (reg:QI 20)))
5981 (match_operand:HF 0 "reg_operand" ""))]
5983 [(set (mem:QF (pre_inc:QI (reg:QI 20)))
5984 (float_truncate:QF (match_dup 0)))
5985 (set (mem:QI (pre_inc:QI (reg:QI 20)))
5986 (unspec:QI [(match_dup 0)] 9))]
5989 (define_insn "pushhf_trunc"
5990 [(set (mem:QF (pre_inc:QI (reg:QI 20)))
5991 (float_truncate:QF (match_operand:HF 0 "reg_operand" "h")))]
5994 [(set_attr "type" "push")])
5996 (define_insn "pushhf_int"
5997 [(set (mem:QI (pre_inc:QI (reg:QI 20)))
5998 (unspec:QI [(match_operand:HF 0 "reg_operand" "h")] 9))]
6001 [(set_attr "type" "push")])
6003 ; we can not use this because the popf will destroy the low 8 bits
6004 ;(define_insn "pophf"
6005 ; [(set (match_operand:HF 0 "reg_operand" "=h")
6006 ; (mem:HF (post_dec:QI (reg:QI 20))))
6007 ; (clobber (reg:CC 21))]
6010 ; [(set_attr "type" "multi")])
6013 [(set (match_operand:HF 0 "reg_operand" "")
6014 (mem:HF (post_dec:QI (reg:QI 20))))
6015 (clobber (reg:CC 21))]
6017 [(parallel [(set (match_operand:HF 0 "reg_operand" "=h")
6018 (float_extend:HF (mem:QF (post_dec:QI (reg:QI 20)))))
6019 (clobber (reg:CC 21))])
6020 (parallel [(set (match_dup 0)
6021 (unspec:HF [(subreg:QI (match_dup 0) 0)
6022 (mem:QI (post_dec:QI (reg:QI 20)))] 8))
6023 (clobber (reg:CC 21))])]
6026 (define_insn "*pophf_int"
6027 [(set (match_operand:HF 0 "reg_operand" "+h")
6028 (unspec:HF [(subreg:QI (match_dup 0) 0)
6029 (mem:QI (post_dec:QI (reg:QI 20)))] 8))
6030 (clobber (reg:CC 21))]
6033 [(set_attr "type" "pop")])
6035 (define_insn "*pophf_float"
6036 [(set (match_operand:HF 0 "reg_operand" "=h")
6037 (float_extend:HF (mem:QF (post_dec:QI (reg:QI 20)))))
6038 (clobber (reg:CC 21))]
6041 [(set_attr "type" "pop")])
6046 (define_insn "fixhfqi_clobber"
6047 [(set (match_operand:QI 0 "reg_operand" "=dc")
6048 (fix:QI (match_operand:HF 1 "reg_or_const_operand" "hH")))
6049 (clobber (reg:CC 21))]
6052 [(set_attr "type" "unarycc")])
6057 (define_expand "abshf2"
6058 [(parallel [(set (match_operand:HF 0 "reg_operand" "")
6059 (abs:HF (match_operand:HF 1 "reg_or_const_operand" "")))
6060 (clobber (reg:CC_NOOV 21))])]
6064 (define_insn "*abshf2_clobber"
6065 [(set (match_operand:HF 0 "reg_operand" "=h")
6066 (abs:HF (match_operand:HF 1 "reg_or_const_operand" "hH")))
6067 (clobber (reg:CC_NOOV 21))]
6070 [(set_attr "type" "unarycc")])
6072 (define_insn "*abshf2_test"
6073 [(set (reg:CC_NOOV 21)
6074 (compare:CC_NOOV (abs:HF (match_operand:HF 1 "reg_operand" "h"))
6075 (match_operand:HF 2 "fp_zero_operand" "G")))
6076 (clobber (match_scratch:HF 0 "=h"))]
6079 [(set_attr "type" "unarycc")])
6081 (define_insn "*abshf2_set"
6082 [(set (reg:CC_NOOV 21)
6083 (compare:CC_NOOV (abs:HF (match_operand:HF 1 "reg_or_const_operand" "hH"))
6084 (match_operand:HF 2 "fp_zero_operand" "G")))
6085 (set (match_operand:HF 0 "reg_operand" "=h")
6086 (abs:HF (match_dup 1)))]
6090 [(set_attr "type" "unarycc")])
6095 (define_expand "neghf2"
6096 [(parallel [(set (match_operand:HF 0 "reg_operand" "")
6097 (neg:HF (match_operand:HF 1 "reg_or_const_operand" "")))
6098 (clobber (reg:CC_NOOV 21))])]
6102 (define_insn "*neghf2_clobber"
6103 [(set (match_operand:HF 0 "reg_operand" "=h")
6104 (neg:HF (match_operand:HF 1 "reg_or_const_operand" "hH")))
6105 (clobber (reg:CC_NOOV 21))]
6108 [(set_attr "type" "unarycc")])
6110 (define_insn "*neghf2_test"
6111 [(set (reg:CC_NOOV 21)
6112 (compare:CC_NOOV (neg:HF (match_operand:HF 1 "reg_or_const_operand" "hH"))
6113 (match_operand:HF 2 "fp_zero_operand" "G")))
6114 (clobber (match_scratch:HF 0 "=h"))]
6117 [(set_attr "type" "unarycc")])
6119 (define_insn "*neghf2_set"
6120 [(set (reg:CC_NOOV 21)
6121 (compare:CC_NOOV (neg:HF (match_operand:HF 1 "reg_or_const_operand" "hH"))
6122 (match_operand:HF 2 "fp_zero_operand" "G")))
6123 (set (match_operand:HF 0 "reg_operand" "=h")
6124 (neg:HF (match_dup 1)))]
6127 [(set_attr "type" "unarycc")])
6132 (define_insn "*rcpfhf_clobber"
6133 [(set (match_operand:HF 0 "reg_operand" "=h")
6134 (unspec:HF [(match_operand:HF 1 "reg_or_const_operand" "hH")] 5))
6135 (clobber (reg:CC_NOOV 21))]
6138 [(set_attr "type" "unarycc")])
6143 (define_insn "*rsqrfhf_clobber"
6144 [(set (match_operand:HF 0 "reg_operand" "=h")
6145 (unspec:HF [(match_operand:HF 1 "reg_or_const_operand" "hH")] 10))
6146 (clobber (reg:CC_NOOV 21))]
6149 [(set_attr "type" "unarycc")])
6154 (define_insn "*rndhf_clobber"
6155 [(set (match_operand:HF 0 "reg_operand" "=h")
6156 (unspec:HF [(match_operand:HF 1 "reg_or_const_operand" "hH")] 6))
6157 (clobber (reg:CC_NOOV 21))]
6160 [(set_attr "type" "unarycc")])
6163 ; Inlined float square root for C4x
6164 (define_expand "sqrthf2_inline"
6165 [(parallel [(set (match_dup 2)
6166 (unspec:HF [(match_operand:HF 1 "reg_operand" "")] 10))
6167 (clobber (reg:CC_NOOV 21))])
6168 (parallel [(set (match_dup 3) (mult:HF (match_dup 5) (match_dup 1)))
6169 (clobber (reg:CC_NOOV 21))])
6170 (parallel [(set (match_dup 4) (mult:HF (match_dup 2) (match_dup 3)))
6171 (clobber (reg:CC_NOOV 21))])
6172 (parallel [(set (match_dup 4) (mult:HF (match_dup 2) (match_dup 4)))
6173 (clobber (reg:CC_NOOV 21))])
6174 (parallel [(set (match_dup 4) (minus:HF (match_dup 6) (match_dup 4)))
6175 (clobber (reg:CC_NOOV 21))])
6176 (parallel [(set (match_dup 2) (mult:HF (match_dup 2) (match_dup 4)))
6177 (clobber (reg:CC_NOOV 21))])
6178 (parallel [(set (match_dup 4) (mult:HF (match_dup 2) (match_dup 3)))
6179 (clobber (reg:CC_NOOV 21))])
6180 (parallel [(set (match_dup 4) (mult:HF (match_dup 2) (match_dup 4)))
6181 (clobber (reg:CC_NOOV 21))])
6182 (parallel [(set (match_dup 4) (minus:HF (match_dup 6) (match_dup 4)))
6183 (clobber (reg:CC_NOOV 21))])
6184 (parallel [(set (match_dup 2) (mult:HF (match_dup 2) (match_dup 4)))
6185 (clobber (reg:CC_NOOV 21))])
6186 (parallel [(set (match_operand:HF 0 "reg_operand" "")
6187 (mult:HF (match_dup 2) (match_dup 1)))
6188 (clobber (reg:CC_NOOV 21))])]
6191 operands[2] = gen_reg_rtx (HFmode);
6192 operands[3] = gen_reg_rtx (HFmode);
6193 operands[4] = gen_reg_rtx (HFmode);
6194 operands[5] = CONST_DOUBLE_ATOF (\"0.5\", HFmode);
6195 operands[6] = CONST_DOUBLE_ATOF (\"1.5\", HFmode);
6199 (define_expand "sqrthf2"
6200 [(parallel [(set (match_operand:HF 0 "reg_operand" "")
6201 (sqrt:HF (match_operand:HF 1 "reg_operand" "")))
6202 (clobber (reg:CC 21))])]
6203 "! TARGET_C3X && TARGET_INLINE"
6204 "emit_insn (gen_sqrthf2_inline (operands[0], operands[1]));
6208 (define_expand "fix_trunchfhi2"
6209 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6210 (fix:HI (match_operand:HF 1 "reg_operand" "")))
6211 (clobber (reg:CC 21))])]
6213 "c4x_emit_libcall (fix_trunchfhi2_libfunc, FIX, HImode, HFmode, 2, operands);
6216 (define_expand "fixuns_trunchfhi2"
6217 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6218 (unsigned_fix:HI (match_operand:HF 1 "reg_operand" "")))
6219 (clobber (reg:CC 21))])]
6221 "c4x_emit_libcall (fixuns_trunchfhi2_libfunc, UNSIGNED_FIX,
6222 HImode, HFmode, 2, operands);
6226 ; THREE OPERAND LONG DOUBLE INSTRUCTIONS
6232 (define_insn "addhf3"
6233 [(set (match_operand:HF 0 "reg_operand" "=h,?h")
6234 (plus:HF (match_operand:HF 1 "reg_operand" "%0,h")
6235 (match_operand:HF 2 "reg_or_const_operand" "H,h")))
6236 (clobber (reg:CC_NOOV 21))]
6241 [(set_attr "type" "binarycc,binarycc")])
6246 (define_insn "subhf3"
6247 [(set (match_operand:HF 0 "reg_operand" "=h,h,?h")
6248 (minus:HF (match_operand:HF 1 "reg_or_const_operand" "0,H,h")
6249 (match_operand:HF 2 "reg_or_const_operand" "H,0,h")))
6250 (clobber (reg:CC_NOOV 21))]
6256 [(set_attr "type" "binarycc,binarycc,binarycc")])
6261 ; The C3x MPYF only uses 24 bit precision while the C4x uses 32 bit precison.
6263 (define_expand "mulhf3"
6264 [(parallel [(set (match_operand:HF 0 "reg_operand" "=h")
6265 (mult:HF (match_operand:HF 1 "reg_operand" "h")
6266 (match_operand:HF 2 "reg_operand" "h")))
6267 (clobber (reg:CC_NOOV 21))])]
6271 (define_insn "*mulhf3_c40"
6272 [(set (match_operand:HF 0 "reg_operand" "=h,?h")
6273 (mult:HF (match_operand:HF 1 "reg_operand" "%0,h")
6274 (match_operand:HF 2 "reg_or_const_operand" "hH,h")))
6275 (clobber (reg:CC_NOOV 21))]
6280 [(set_attr "type" "binarycc,binarycc")])
6285 (define_expand "cmphf"
6287 (compare:CC (match_operand:HF 0 "reg_operand" "")
6288 (match_operand:HF 1 "reg_or_const_operand" "")))]
6290 "c4x_compare_op0 = operands[0];
6291 c4x_compare_op1 = operands[1];
6294 (define_insn "*cmphf"
6296 (compare:CC (match_operand:HF 0 "reg_operand" "h")
6297 (match_operand:HF 1 "reg_or_const_operand" "hH")))]
6300 [(set_attr "type" "compare")])
6302 (define_insn "*cmphf_noov"
6303 [(set (reg:CC_NOOV 21)
6304 (compare:CC_NOOV (match_operand:HF 0 "reg_operand" "h")
6305 (match_operand:HF 1 "reg_or_const_operand" "hH")))]
6308 [(set_attr "type" "compare")])
6310 ; Inlined float divide for C4x
6311 (define_expand "divhf3_inline"
6312 [(parallel [(set (match_dup 3)
6313 (unspec:HF [(match_operand:HF 2 "reg_operand" "")] 5))
6314 (clobber (reg:CC_NOOV 21))])
6315 (parallel [(set (match_dup 4) (mult:HF (match_dup 2) (match_dup 3)))
6316 (clobber (reg:CC_NOOV 21))])
6317 (parallel [(set (match_dup 4) (minus:HF (match_dup 5) (match_dup 4)))
6318 (clobber (reg:CC_NOOV 21))])
6319 (parallel [(set (match_dup 3) (mult:HF (match_dup 3) (match_dup 4)))
6320 (clobber (reg:CC_NOOV 21))])
6321 (parallel [(set (match_dup 4) (mult:HF (match_dup 2) (match_dup 3)))
6322 (clobber (reg:CC_NOOV 21))])
6323 (parallel [(set (match_dup 4) (minus:HF (match_dup 5) (match_dup 4)))
6324 (clobber (reg:CC_NOOV 21))])
6325 (parallel [(set (match_dup 3) (mult:HF (match_dup 3) (match_dup 4)))
6326 (clobber (reg:CC_NOOV 21))])
6327 (parallel [(set (match_operand:HF 0 "reg_operand" "")
6328 (mult:HF (match_operand:HF 1 "reg_operand" "")
6330 (clobber (reg:CC_NOOV 21))])]
6333 operands[3] = gen_reg_rtx (HFmode);
6334 operands[4] = gen_reg_rtx (HFmode);
6335 operands[5] = CONST2_RTX (HFmode);
6338 (define_expand "divhf3"
6339 [(parallel [(set (match_operand:HF 0 "reg_operand" "")
6340 (div:HF (match_operand:HF 1 "reg_operand" "")
6341 (match_operand:HF 2 "reg_operand" "")))
6342 (clobber (reg:CC 21))])]
6343 "! TARGET_C3X && TARGET_INLINE"
6344 "emit_insn (gen_divhf3_inline (operands[0], operands[1], operands[2]));
6349 ; TWO OPERAND LONG LONG INSTRUCTIONS
6352 (define_insn "*movhi_stik"
6353 [(set (match_operand:HI 0 "memory_operand" "=m")
6354 (match_operand:HI 1 "stik_const_operand" "K"))]
6357 [(set_attr "type" "multi")])
6359 ; We could load some constants using define_splits for the C30
6360 ; in the large memory model---these would emit shift and or insns.
6361 (define_expand "movhi"
6362 [(set (match_operand:HI 0 "src_operand" "")
6363 (match_operand:HI 1 "src_operand" ""))]
6365 "if (c4x_emit_move_sequence (operands, HImode))
6368 ; The constraints for movhi must include 'r' if we don't
6369 ; restrict HImode regnos to start on an even number, since
6370 ; we can get RC, R8 allocated as a pair. We want more
6371 ; votes for FP_REGS so we use dr as the constraints.
6372 (define_insn "*movhi_noclobber"
6373 [(set (match_operand:HI 0 "dst_operand" "=dr,m")
6374 (match_operand:HI 1 "src_operand" "drIm,r"))]
6375 "reg_operand (operands[0], HImode)
6376 || reg_operand (operands[1], HImode)"
6378 [(set_attr "type" "multi,multi")])
6380 ; This will fail miserably if the destination register is used in the
6381 ; source memory address.
6382 ; The usual strategy in this case is to swap the order of insns we emit,
6383 ; however, this will fail if we have an autoincrement memory address.
6388 ; We could convert this to
6392 ; However, things are likely to be very screwed up if we get this.
6395 [(set (match_operand:HI 0 "dst_operand" "")
6396 (match_operand:HI 1 "src_operand" ""))]
6398 && (reg_operand (operands[0], HImode)
6399 || reg_operand (operands[1], HImode)
6400 || stik_const_operand (operands[1], HImode))"
6401 [(set (match_dup 2) (match_dup 4))
6402 (set (match_dup 3) (match_dup 5))]
6403 "operands[2] = c4x_operand_subword (operands[0], 0, 1, HImode);
6404 operands[3] = c4x_operand_subword (operands[0], 1, 1, HImode);
6405 operands[4] = c4x_operand_subword (operands[1], 0, 1, HImode);
6406 operands[5] = c4x_operand_subword (operands[1], 1, 1, HImode);
6407 if (reg_overlap_mentioned_p (operands[2], operands[5]))
6409 /* Swap order of move insns. */
6412 operands[2] =operands[3];
6415 operands[4] =operands[5];
6420 (define_insn "extendqihi2"
6421 [(set (match_operand:HI 0 "reg_operand" "=dc")
6422 (sign_extend:HI (match_operand:QI 1 "src_operand" "rIm")))
6423 (clobber (reg:CC 21))]
6426 [(set_attr "type" "multi")])
6429 [(set (match_operand:HI 0 "reg_operand" "")
6430 (sign_extend:HI (match_operand:QI 1 "src_operand" "")))
6431 (clobber (reg:CC 21))]
6432 "reload_completed && TARGET_C3X"
6433 [(set (match_dup 2) (match_dup 1))
6434 (set (match_dup 3) (match_dup 2))
6435 (parallel [(set (match_dup 3) (ashiftrt:QI (match_dup 3) (const_int 31)))
6436 (clobber (reg:CC 21))])]
6437 "operands[2] = c4x_operand_subword (operands[0], 0, 0, HImode);
6438 operands[3] = c4x_operand_subword (operands[0], 1, 0, HImode);")
6441 [(set (match_operand:HI 0 "reg_operand" "")
6442 (sign_extend:HI (match_operand:QI 1 "src_operand" "")))
6443 (clobber (reg:CC 21))]
6444 "reload_completed && ! TARGET_C3X"
6445 [(set (match_dup 2) (match_dup 1))
6446 (parallel [(set (match_dup 3) (ashiftrt:QI (match_dup 2) (const_int 31)))
6447 (clobber (reg:CC 21))])]
6448 "operands[2] = c4x_operand_subword (operands[0], 0, 0, HImode);
6449 operands[3] = c4x_operand_subword (operands[0], 1, 0, HImode);")
6451 (define_insn "zero_extendqihi2"
6452 [(set (match_operand:HI 0 "reg_operand" "=?dc")
6453 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "rm")))
6454 (clobber (reg:CC 21))]
6457 [(set_attr "type" "multi")])
6459 ; If operand0 and operand1 are the same register we don't need
6462 [(set (match_operand:HI 0 "reg_operand" "")
6463 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "")))
6464 (clobber (reg:CC 21))]
6466 [(set (match_dup 2) (match_dup 1))
6467 (set (match_dup 3) (const_int 0))]
6468 "operands[2] = c4x_operand_subword (operands[0], 0, 0, HImode);
6469 operands[3] = c4x_operand_subword (operands[0], 1, 0, HImode);")
6474 (define_insn "*pushhi"
6475 [(set (mem:HI (pre_inc:QI (reg:QI 20)))
6476 (match_operand:HI 0 "reg_operand" "r"))]
6479 [(set_attr "type" "multi")])
6482 [(set (mem:HI (pre_inc:QI (reg:QI 20)))
6483 (match_operand:HI 0 "reg_operand" ""))]
6485 [(set (mem:QI (pre_inc:QI (reg:QI 20))) (match_dup 2))
6486 (set (mem:QI (pre_inc:QI (reg:QI 20))) (match_dup 3))]
6487 "operands[2] = c4x_operand_subword (operands[0], 0, 0, HImode);
6488 operands[3] = c4x_operand_subword (operands[0], 1, 0, HImode);")
6490 (define_insn "*pophi"
6491 [(set (match_operand:HI 0 "reg_operand" "=r")
6492 (mem:HI (post_dec:QI (reg:QI 20))))
6493 (clobber (reg:CC 21))]
6496 [(set_attr "type" "multi")])
6499 [(set (match_operand:HI 0 "reg_operand" "")
6500 (mem:HI (pre_inc:QI (reg:QI 20))))]
6502 [(set (match_dup 2) (mem:QI (pre_inc:QI (reg:QI 20))))
6503 (set (match_dup 3) (mem:QI (pre_inc:QI (reg:QI 20))))]
6504 "operands[2] = c4x_operand_subword (operands[0], 0, 0, HImode);
6505 operands[3] = c4x_operand_subword (operands[0], 1, 0, HImode);")
6510 (define_insn "neghi2"
6511 [(set (match_operand:HI 0 "ext_reg_operand" "=d")
6512 (neg:HI (match_operand:HI 1 "src_operand" "rm")))
6513 (clobber (reg:CC_NOOV 21))]
6516 [(set_attr "type" "multi")])
6519 [(set (match_operand:HI 0 "ext_reg_operand" "")
6520 (neg:HI (match_operand:HI 1 "src_operand" "")))
6521 (clobber (reg:CC_NOOV 21))]
6523 [(parallel [(set (reg:CC_NOOV 21)
6524 (compare:CC_NOOV (neg:QI (match_dup 3))
6526 (set (match_dup 2) (neg:QI (match_dup 3)))])
6527 (parallel [(set (match_dup 4) (neg:QI (match_dup 5)))
6528 (use (reg:CC_NOOV 21))
6529 (clobber (reg:CC_NOOV 21))])]
6530 "operands[2] = c4x_operand_subword (operands[0], 0, 1, HImode);
6531 operands[3] = c4x_operand_subword (operands[1], 0, 1, HImode);
6532 operands[4] = c4x_operand_subword (operands[0], 1, 1, HImode);
6533 operands[5] = c4x_operand_subword (operands[1], 1, 1, HImode);")
6535 (define_insn "one_cmplhi2"
6536 [(set (match_operand:HI 0 "reg_operand" "=r")
6537 (not:HI (match_operand:HI 1 "src_operand" "rm")))
6538 (clobber (reg:CC 21))]
6541 [(set_attr "type" "multi")])
6544 [(set (match_operand:HI 0 "reg_operand" "")
6545 (not:HI (match_operand:HI 1 "src_operand" "")))
6546 (clobber (reg:CC 21))]
6548 [(parallel [(set (match_dup 2) (not:QI (match_dup 3)))
6549 (clobber (reg:CC 21))])
6550 (parallel [(set (match_dup 4) (not:QI (match_dup 5)))
6551 (clobber (reg:CC 21))])]
6552 "operands[2] = c4x_operand_subword (operands[0], 0, 1, HImode);
6553 operands[3] = c4x_operand_subword (operands[1], 0, 1, HImode);
6554 operands[4] = c4x_operand_subword (operands[0], 1, 1, HImode);
6555 operands[5] = c4x_operand_subword (operands[1], 1, 1, HImode);")
6557 (define_expand "floathiqf2"
6558 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
6559 (float:QF (match_operand:HI 1 "src_operand" "")))
6560 (clobber (reg:CC 21))])]
6562 "c4x_emit_libcall (floathiqf2_libfunc, FLOAT, QFmode, HImode, 2, operands);
6565 (define_expand "floatunshiqf2"
6566 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
6567 (unsigned_float:QF (match_operand:HI 1 "src_operand" "")))
6568 (clobber (reg:CC 21))])]
6570 "c4x_emit_libcall (floatunshiqf2_libfunc, UNSIGNED_FLOAT,
6571 QFmode, HImode, 2, operands);
6574 (define_expand "floathihf2"
6575 [(parallel [(set (match_operand:HF 0 "reg_operand" "")
6576 (float:HF (match_operand:HI 1 "src_operand" "")))
6577 (clobber (reg:CC 21))])]
6579 "c4x_emit_libcall (floathihf2_libfunc, FLOAT, HFmode, HImode, 2, operands);
6582 (define_expand "floatunshihf2"
6583 [(parallel [(set (match_operand:HF 0 "reg_operand" "")
6584 (unsigned_float:HF (match_operand:HI 1 "src_operand" "")))
6585 (clobber (reg:CC 21))])]
6587 "c4x_emit_libcall (floatunshihf2_libfunc, UNSIGNED_FLOAT,
6588 HFmode, HImode, 2, operands);
6593 ; THREE OPERAND LONG LONG INSTRUCTIONS
6596 (define_expand "addhi3"
6597 [(parallel [(set (match_operand:HI 0 "ext_reg_operand" "")
6598 (plus:HI (match_operand:HI 1 "src_operand" "")
6599 (match_operand:HI 2 "src_operand" "")))
6600 (clobber (reg:CC_NOOV 21))])]
6602 "legitimize_operands (PLUS, operands, HImode);")
6604 (define_insn "*addhi3_clobber"
6605 [(set (match_operand:HI 0 "ext_reg_operand" "=d,d,?d")
6606 (plus:HI (match_operand:HI 1 "src_operand" "%0,rR,rS<>")
6607 (match_operand:HI 2 "src_operand" "rm,R,rS<>")))
6608 (clobber (reg:CC_NOOV 21))]
6609 "valid_operands (PLUS, operands, HImode)"
6611 [(set_attr "type" "multi,multi,multi")])
6614 [(set (match_operand:HI 0 "ext_reg_operand" "")
6615 (plus:HI (match_operand:HI 1 "src_operand" "")
6616 (match_operand:HI 2 "src_operand" "")))
6617 (clobber (reg:CC_NOOV 21))]
6619 [(parallel [(set (reg:CC_NOOV 21)
6620 (compare:CC_NOOV (plus:QI (match_dup 4) (match_dup 5))
6622 (set (match_dup 3) (plus:QI (match_dup 4) (match_dup 5)))])
6623 (parallel [(set (match_dup 6) (plus:QI (match_dup 7) (match_dup 8)))
6624 (use (reg:CC_NOOV 21))
6625 (clobber (reg:CC_NOOV 21))])]
6626 "operands[3] = c4x_operand_subword (operands[0], 0, 1, HImode);
6627 operands[4] = c4x_operand_subword (operands[1], 0, 1, HImode);
6628 operands[5] = c4x_operand_subword (operands[2], 0, 1, HImode);
6629 operands[6] = c4x_operand_subword (operands[0], 1, 1, HImode);
6630 operands[7] = c4x_operand_subword (operands[1], 1, 1, HImode);
6631 operands[8] = c4x_operand_subword (operands[2], 1, 1, HImode);")
6633 (define_expand "subhi3"
6634 [(parallel [(set (match_operand:HI 0 "ext_reg_operand" "")
6635 (minus:HI (match_operand:HI 1 "src_operand" "")
6636 (match_operand:HI 2 "src_operand" "")))
6637 (clobber (reg:CC_NOOV 21))])]
6639 "legitimize_operands (MINUS, operands, HImode);")
6642 (define_insn "*subhi3_clobber"
6643 [(set (match_operand:HI 0 "ext_reg_operand" "=d,d,?d")
6644 (minus:HI (match_operand:HI 1 "src_operand" "0,rR,rS<>")
6645 (match_operand:HI 2 "src_operand" "rm,R,rS<>")))
6646 (clobber (reg:CC_NOOV 21))]
6647 "valid_operands (MINUS, operands, HImode)"
6649 [(set_attr "type" "multi,multi,multi")])
6652 [(set (match_operand:HI 0 "ext_reg_operand" "")
6653 (minus:HI (match_operand:HI 1 "src_operand" "")
6654 (match_operand:HI 2 "src_operand" "")))
6655 (clobber (reg:CC_NOOV 21))]
6657 [(parallel [(set (reg:CC_NOOV 21)
6658 (compare:CC_NOOV (minus:QI (match_dup 4) (match_dup 5))
6660 (set (match_dup 3) (minus:QI (match_dup 4) (match_dup 5)))])
6661 (parallel [(set (match_dup 6) (minus:QI (match_dup 7) (match_dup 8)))
6662 (use (reg:CC_NOOV 21))
6663 (clobber (reg:CC_NOOV 21))])]
6664 "operands[3] = c4x_operand_subword (operands[0], 0, 1, HImode);
6665 operands[4] = c4x_operand_subword (operands[1], 0, 1, HImode);
6666 operands[5] = c4x_operand_subword (operands[2], 0, 1, HImode);
6667 operands[6] = c4x_operand_subword (operands[0], 1, 1, HImode);
6668 operands[7] = c4x_operand_subword (operands[1], 1, 1, HImode);
6669 operands[8] = c4x_operand_subword (operands[2], 1, 1, HImode);")
6671 (define_expand "iorhi3"
6672 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6673 (ior:HI (match_operand:HI 1 "src_operand" "")
6674 (match_operand:HI 2 "src_operand" "")))
6675 (clobber (reg:CC 21))])]
6677 "legitimize_operands (IOR, operands, HImode);")
6679 (define_insn "*iorhi3_clobber"
6680 [(set (match_operand:HI 0 "reg_operand" "=d,d,?d")
6681 (ior:HI (match_operand:HI 1 "src_operand" "%0,rR,rS<>")
6682 (match_operand:HI 2 "src_operand" "rm,R,rS<>")))
6683 (clobber (reg:CC 21))]
6684 "valid_operands (IOR, operands, HImode)"
6686 [(set_attr "type" "multi,multi,multi")])
6689 [(set (match_operand:HI 0 "reg_operand" "")
6690 (ior:HI (match_operand:HI 1 "src_operand" "")
6691 (match_operand:HI 2 "src_operand" "")))
6692 (clobber (reg:CC 21))]
6694 [(parallel [(set (match_dup 3) (ior:QI (match_dup 4) (match_dup 5)))
6695 (clobber (reg:CC 21))])
6696 (parallel [(set (match_dup 6) (ior:QI (match_dup 7) (match_dup 8)))
6697 (clobber (reg:CC 21))])]
6698 "operands[3] = c4x_operand_subword (operands[0], 0, 1, HImode);
6699 operands[4] = c4x_operand_subword (operands[1], 0, 1, HImode);
6700 operands[5] = c4x_operand_subword (operands[2], 0, 1, HImode);
6701 operands[6] = c4x_operand_subword (operands[0], 1, 1, HImode);
6702 operands[7] = c4x_operand_subword (operands[1], 1, 1, HImode);
6703 operands[8] = c4x_operand_subword (operands[2], 1, 1, HImode);")
6705 (define_expand "andhi3"
6706 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6707 (and:HI (match_operand:HI 1 "src_operand" "")
6708 (match_operand:HI 2 "src_operand" "")))
6709 (clobber (reg:CC 21))])]
6711 "legitimize_operands (AND, operands, HImode);")
6713 (define_insn "*andhi3_clobber"
6714 [(set (match_operand:HI 0 "reg_operand" "=d,d,?d")
6715 (and:HI (match_operand:HI 1 "src_operand" "%0,rR,rS<>")
6716 (match_operand:HI 2 "src_operand" "rm,R,rS<>")))
6717 (clobber (reg:CC 21))]
6718 "valid_operands (AND, operands, HImode)"
6720 [(set_attr "type" "multi,multi,multi")])
6723 [(set (match_operand:HI 0 "reg_operand" "")
6724 (and:HI (match_operand:HI 1 "src_operand" "")
6725 (match_operand:HI 2 "src_operand" "")))
6726 (clobber (reg:CC 21))]
6728 [(parallel [(set (match_dup 3) (and:QI (match_dup 4) (match_dup 5)))
6729 (clobber (reg:CC 21))])
6730 (parallel [(set (match_dup 6) (and:QI (match_dup 7) (match_dup 8)))
6731 (clobber (reg:CC 21))])]
6732 "operands[3] = c4x_operand_subword (operands[0], 0, 1, HImode);
6733 operands[4] = c4x_operand_subword (operands[1], 0, 1, HImode);
6734 operands[5] = c4x_operand_subword (operands[2], 0, 1, HImode);
6735 operands[6] = c4x_operand_subword (operands[0], 1, 1, HImode);
6736 operands[7] = c4x_operand_subword (operands[1], 1, 1, HImode);
6737 operands[8] = c4x_operand_subword (operands[2], 1, 1, HImode);")
6739 (define_expand "xorhi3"
6740 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6741 (xor:HI (match_operand:HI 1 "src_operand" "")
6742 (match_operand:HI 2 "src_operand" "")))
6743 (clobber (reg:CC 21))])]
6745 "legitimize_operands (XOR, operands, HImode);")
6748 (define_insn "*xorhi3_clobber"
6749 [(set (match_operand:HI 0 "reg_operand" "=d,d,?d")
6750 (xor:HI (match_operand:HI 1 "src_operand" "%0,rR,rS<>")
6751 (match_operand:HI 2 "src_operand" "rm,R,rS<>")))
6752 (clobber (reg:CC 21))]
6753 "valid_operands (XOR, operands, HImode)"
6755 [(set_attr "type" "multi,multi,multi")])
6758 [(set (match_operand:HI 0 "reg_operand" "")
6759 (xor:HI (match_operand:HI 1 "src_operand" "")
6760 (match_operand:HI 2 "src_operand" "")))
6761 (clobber (reg:CC 21))]
6763 [(parallel [(set (match_dup 3) (xor:QI (match_dup 4) (match_dup 5)))
6764 (clobber (reg:CC 21))])
6765 (parallel [(set (match_dup 6) (xor:QI (match_dup 7) (match_dup 8)))
6766 (clobber (reg:CC 21))])]
6767 "operands[3] = c4x_operand_subword (operands[0], 0, 1, HImode);
6768 operands[4] = c4x_operand_subword (operands[1], 0, 1, HImode);
6769 operands[5] = c4x_operand_subword (operands[2], 0, 1, HImode);
6770 operands[6] = c4x_operand_subword (operands[0], 1, 1, HImode);
6771 operands[7] = c4x_operand_subword (operands[1], 1, 1, HImode);
6772 operands[8] = c4x_operand_subword (operands[2], 1, 1, HImode);")
6774 (define_expand "ashlhi3"
6775 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6776 (ashift:HI (match_operand:HI 1 "src_operand" "")
6777 (match_operand:QI 2 "src_operand" "")))
6778 (clobber (reg:CC 21))])]
6780 "if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32)
6782 rtx op0hi = operand_subword (operands[0], 1, 0, HImode);
6783 rtx op0lo = operand_subword (operands[0], 0, 0, HImode);
6784 rtx op1lo = operand_subword (operands[1], 0, 0, HImode);
6785 rtx count = GEN_INT ((INTVAL (operands[2]) - 32));
6788 emit_insn (gen_ashlqi3 (op0hi, op1lo, count));
6790 emit_insn (gen_movqi (op0hi, op1lo));
6791 emit_insn (gen_movqi (op0lo, const0_rtx));
6794 if (! REG_P (operands[1]))
6795 operands[1] = force_reg (HImode, operands[1]);
6796 emit_insn (gen_ashlhi3_reg (operands[0], operands[1], operands[2]));
6800 ; %0.lo = %1.lo << %2
6801 ; %0.hi = (%1.hi << %2 ) | (%1.lo >> (32 - %2))
6802 ; This algorithm should work for shift counts greater than 32
6803 (define_expand "ashlhi3_reg"
6804 [(use (match_operand:HI 1 "reg_operand" ""))
6805 (use (match_operand:HI 0 "reg_operand" ""))
6806 /* If the shift count is greater than 32 this will give zero. */
6807 (parallel [(set (match_dup 7)
6808 (ashift:QI (match_dup 3)
6809 (match_operand:QI 2 "reg_operand" "")))
6810 (clobber (reg:CC 21))])
6811 /* If the shift count is greater than 32 this will give zero. */
6812 (parallel [(set (match_dup 8)
6813 (ashift:QI (match_dup 4) (match_dup 2)))
6814 (clobber (reg:CC 21))])
6815 (parallel [(set (match_dup 10)
6816 (plus:QI (match_dup 2) (const_int -32)))
6817 (clobber (reg:CC_NOOV 21))])
6818 /* If the shift count is greater than 32 this will do a left shift. */
6819 (parallel [(set (match_dup 9)
6820 (lshiftrt:QI (match_dup 3) (neg:QI (match_dup 10))))
6821 (clobber (reg:CC 21))])
6822 (set (match_dup 5) (match_dup 7))
6823 (parallel [(set (match_dup 6)
6824 (ior:QI (match_dup 8) (match_dup 9)))
6825 (clobber (reg:CC 21))])]
6828 operands[3] = operand_subword (operands[1], 0, 1, HImode); /* lo */
6829 operands[4] = operand_subword (operands[1], 1, 1, HImode); /* hi */
6830 operands[5] = operand_subword (operands[0], 0, 1, HImode); /* lo */
6831 operands[6] = operand_subword (operands[0], 1, 1, HImode); /* hi */
6832 operands[7] = gen_reg_rtx (QImode); /* lo << count */
6833 operands[8] = gen_reg_rtx (QImode); /* hi << count */
6834 operands[9] = gen_reg_rtx (QImode); /* lo >> (32 - count) */
6835 operands[10] = gen_reg_rtx (QImode); /* 32 - count */
6838 ; This should do all the dirty work with define_split
6839 (define_expand "lshrhi3"
6840 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6841 (lshiftrt:HI (match_operand:HI 1 "src_operand" "")
6842 (match_operand:QI 2 "src_operand" "")))
6843 (clobber (reg:CC 21))])]
6845 "if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32)
6847 rtx op0hi = operand_subword (operands[0], 1, 0, HImode);
6848 rtx op0lo = operand_subword (operands[0], 0, 0, HImode);
6849 rtx op1hi = operand_subword (operands[1], 1, 0, HImode);
6850 rtx count = GEN_INT ((INTVAL (operands[2]) - 32));
6853 emit_insn (gen_lshrqi3 (op0lo, op1hi, count));
6855 emit_insn (gen_movqi (op0lo, op1hi));
6856 emit_insn (gen_movqi (op0hi, const0_rtx));
6859 if (! REG_P (operands[1]))
6860 operands[1] = force_reg (HImode, operands[1]);
6861 emit_insn (gen_lshrhi3_reg (operands[0], operands[1], operands[2]));
6864 ; %0.hi = %1.hi >> %2
6865 ; %0.lo = (%1.lo >> %2 ) | (%1.hi << (32 - %2))
6866 ; This algorithm should work for shift counts greater than 32
6867 (define_expand "lshrhi3_reg"
6868 [(use (match_operand:HI 1 "reg_operand" ""))
6869 (use (match_operand:HI 0 "reg_operand" ""))
6870 (parallel [(set (match_dup 11)
6871 (neg:QI (match_operand:QI 2 "reg_operand" "")))
6872 (clobber (reg:CC_NOOV 21))])
6873 /* If the shift count is greater than 32 this will give zero. */
6874 (parallel [(set (match_dup 7)
6875 (lshiftrt:QI (match_dup 3)
6876 (neg:QI (match_dup 11))))
6877 (clobber (reg:CC 21))])
6878 /* If the shift count is greater than 32 this will give zero. */
6879 (parallel [(set (match_dup 8)
6880 (lshiftrt:QI (match_dup 4)
6881 (neg:QI (match_dup 11))))
6882 (clobber (reg:CC 21))])
6883 (parallel [(set (match_dup 10)
6884 (plus:QI (match_dup 11) (const_int 32)))
6885 (clobber (reg:CC_NOOV 21))])
6886 /* If the shift count is greater than 32 this will do an arithmetic
6887 right shift. However, we need a logical right shift. */
6888 (parallel [(set (match_dup 9)
6889 (ashift:QI (match_dup 4) (unspec:QI [(match_dup 10)] 3)))
6890 (clobber (reg:CC 21))])
6891 (set (match_dup 6) (match_dup 8))
6892 (parallel [(set (match_dup 5)
6893 (ior:QI (match_dup 7) (match_dup 9)))
6894 (clobber (reg:CC 21))])]
6897 operands[3] = operand_subword (operands[1], 0, 1, HImode); /* lo */
6898 operands[4] = operand_subword (operands[1], 1, 1, HImode); /* hi */
6899 operands[5] = operand_subword (operands[0], 0, 1, HImode); /* lo */
6900 operands[6] = operand_subword (operands[0], 1, 1, HImode); /* hi */
6901 operands[7] = gen_reg_rtx (QImode); /* lo >> count */
6902 operands[8] = gen_reg_rtx (QImode); /* hi >> count */
6903 operands[9] = gen_reg_rtx (QImode); /* hi << (32 - count) */
6904 operands[10] = gen_reg_rtx (QImode); /* 32 - count */
6905 operands[11] = gen_reg_rtx (QImode); /* -count */
6908 ; This should do all the dirty work with define_split
6909 (define_expand "ashrhi3"
6910 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6911 (ashiftrt:HI (match_operand:HI 1 "src_operand" "")
6912 (match_operand:QI 2 "src_operand" "")))
6913 (clobber (reg:CC 21))])]
6915 "if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32)
6917 rtx op0hi = operand_subword (operands[0], 1, 0, HImode);
6918 rtx op0lo = operand_subword (operands[0], 0, 0, HImode);
6919 rtx op1hi = operand_subword (operands[1], 1, 0, HImode);
6920 rtx count = GEN_INT ((INTVAL (operands[2]) - 32));
6923 emit_insn (gen_ashrqi3 (op0lo, op1hi, count));
6925 emit_insn (gen_movqi (op0lo, op1hi));
6926 emit_insn (gen_ashrqi3 (op0hi, op1hi, GEN_INT (31)));
6929 if (! REG_P (operands[1]))
6930 operands[1] = force_reg (HImode, operands[1]);
6931 emit_insn (gen_ashrhi3_reg (operands[0], operands[1], operands[2]));
6934 ; %0.hi = %1.hi >> %2
6935 ; %0.lo = (%1.lo >> %2 ) | (%1.hi << (32 - %2))
6936 ; This algorithm should work for shift counts greater than 32
6937 (define_expand "ashrhi3_reg"
6938 [(use (match_operand:HI 1 "reg_operand" ""))
6939 (use (match_operand:HI 0 "reg_operand" ""))
6940 (parallel [(set (match_dup 11)
6941 (neg:QI (match_operand:QI 2 "reg_operand" "")))
6942 (clobber (reg:CC_NOOV 21))])
6943 /* If the shift count is greater than 32 this will give zero. */
6944 (parallel [(set (match_dup 7)
6945 (lshiftrt:QI (match_dup 3)
6946 (neg:QI (match_dup 11))))
6947 (clobber (reg:CC 21))])
6948 /* If the shift count is greater than 32 this will give zero. */
6949 (parallel [(set (match_dup 8)
6950 (ashiftrt:QI (match_dup 4)
6951 (neg:QI (match_dup 11))))
6952 (clobber (reg:CC 21))])
6953 (parallel [(set (match_dup 10)
6954 (plus:QI (match_dup 11) (const_int 32)))
6955 (clobber (reg:CC_NOOV 21))])
6956 /* If the shift count is greater than 32 this will do an arithmetic
6958 (parallel [(set (match_dup 9)
6959 (ashift:QI (match_dup 4) (match_dup 10)))
6960 (clobber (reg:CC 21))])
6961 (set (match_dup 6) (match_dup 8))
6962 (parallel [(set (match_dup 5)
6963 (ior:QI (match_dup 7) (match_dup 9)))
6964 (clobber (reg:CC 21))])]
6967 operands[3] = operand_subword (operands[1], 0, 1, HImode); /* lo */
6968 operands[4] = operand_subword (operands[1], 1, 1, HImode); /* hi */
6969 operands[5] = operand_subword (operands[0], 0, 1, HImode); /* lo */
6970 operands[6] = operand_subword (operands[0], 1, 1, HImode); /* hi */
6971 operands[7] = gen_reg_rtx (QImode); /* lo >> count */
6972 operands[8] = gen_reg_rtx (QImode); /* hi >> count */
6973 operands[9] = gen_reg_rtx (QImode); /* hi << (32 - count) */
6974 operands[10] = gen_reg_rtx (QImode); /* 32 - count */
6975 operands[11] = gen_reg_rtx (QImode); /* -count */
6978 (define_expand "cmphi"
6980 (compare:CC (match_operand:HI 0 "src_operand" "")
6981 (match_operand:HI 1 "src_operand" "")))]
6983 "legitimize_operands (COMPARE, operands, HImode);
6984 c4x_compare_op0 = operands[0];
6985 c4x_compare_op1 = operands[1];
6988 (define_insn "*cmphi_cc"
6990 (compare:CC (match_operand:HI 0 "src_operand" "rR,rS<>")
6991 (match_operand:HI 1 "src_operand" "R,rS<>")))]
6992 "valid_operands (COMPARE, operands, HImode)"
6994 [(set_attr "type" "multi")])
6996 (define_insn "*cmphi_cc_noov"
6997 [(set (reg:CC_NOOV 21)
6998 (compare:CC_NOOV (match_operand:HI 0 "src_operand" "rR,rS<>")
6999 (match_operand:HI 1 "src_operand" "R,rS<>")))]
7000 "valid_operands (COMPARE, operands, HImode)"
7002 [(set_attr "type" "multi")])
7004 ; This works only before reload because we need 2 extra registers.
7005 ; Use unspec to avoid recursive split.
7008 (compare:CC (match_operand:HI 0 "src_operand" "")
7009 (match_operand:HI 1 "src_operand" "")))]
7010 "! reload_completed"
7011 [(parallel [(set (reg:CC 21)
7012 (unspec:CC [(compare:CC (match_dup 0)
7014 (clobber (match_scratch:QI 2 ""))
7015 (clobber (match_scratch:QI 3 ""))])]
7019 [(set (reg:CC_NOOV 21)
7020 (compare:CC_NOOV (match_operand:HI 0 "src_operand" "")
7021 (match_operand:HI 1 "src_operand" "")))]
7022 "! reload_completed"
7023 [(parallel [(set (reg:CC_NOOV 21)
7024 (unspec:CC_NOOV [(compare:CC_NOOV (match_dup 0)
7026 (clobber (match_scratch:QI 2 ""))
7027 (clobber (match_scratch:QI 3 ""))])]
7030 ; This is normally not used. The define splits above are used first.
7033 (compare:CC (match_operand:HI 0 "src_operand" "")
7034 (match_operand:HI 1 "src_operand" "")))]
7036 [(parallel [(set (reg:CC 21)
7037 (compare:CC (match_dup 0) (match_dup 1)))
7038 (use (reg:QI 20))])]
7042 [(set (reg:CC_NOOV 21)
7043 (compare:CC_NOOV (match_operand:HI 0 "src_operand" "")
7044 (match_operand:HI 1 "src_operand" "")))]
7046 [(parallel [(set (reg:CC_NOOV 21)
7047 (compare:CC_NOOV (match_dup 0) (match_dup 1)))
7048 (use (reg:QI 20))])]
7051 (define_insn "*cmphi"
7053 (compare:CC (match_operand:HI 0 "src_operand" "rR,rS<>")
7054 (match_operand:HI 1 "src_operand" "R,rS<>")))
7056 "valid_operands (COMPARE, operands, HImode)"
7059 int use_ir1 = (reg_operand (operands[0], HImode)
7060 && REG_P (operands[0])
7061 && REGNO (operands[0]) == IR1_REGNO)
7062 || (reg_operand (operands[1], HImode)
7063 && REG_P (operands[1])
7064 && REGNO (operands[1]) == IR1_REGNO);
7067 output_asm_insn (\"push\\tir1\", operands);
7069 output_asm_insn (\"push\\tbk\", operands);
7070 output_asm_insn (\"push\\tr0\", operands);
7071 output_asm_insn (\"subi3\\t%1,%0,r0\", operands);
7074 output_asm_insn (\"ldiu\\tst,ir1\", operands);
7075 output_asm_insn (\"or\\t07bh,ir1\", operands);
7079 output_asm_insn (\"ldiu\\tst,bk\", operands);
7080 output_asm_insn (\"or\\t07bh,bk\", operands);
7082 output_asm_insn (\"subb3\\t%O1,%O0,r0\", operands);
7084 output_asm_insn (\"and3\\tir1,st,ir1\", operands);
7086 output_asm_insn (\"and3\\tbk,st,bk\", operands);
7087 output_asm_insn (\"pop\\tr0\", operands);
7090 output_asm_insn (\"ldiu\\tir1,st\", operands);
7091 output_asm_insn (\"pop\\tir1\", operands);
7095 output_asm_insn (\"ldiu\\tbk,st\", operands);
7096 output_asm_insn (\"pop\\tbk\", operands);
7100 [(set_attr "type" "multi")])
7102 (define_insn "*cmphi_noov"
7103 [(set (reg:CC_NOOV 21)
7104 (compare:CC_NOOV (match_operand:HI 0 "src_operand" "rR,rS<>")
7105 (match_operand:HI 1 "src_operand" "R,rS<>")))
7107 "valid_operands (COMPARE, operands, HImode)"
7110 int use_ir1 = (reg_operand (operands[0], HImode)
7111 && REG_P (operands[0])
7112 && REGNO (operands[0]) == IR1_REGNO)
7113 || (reg_operand (operands[1], HImode)
7114 && REG_P (operands[1])
7115 && REGNO (operands[1]) == IR1_REGNO);
7118 output_asm_insn (\"push\\tir1\", operands);
7120 output_asm_insn (\"push\\tbk\", operands);
7121 output_asm_insn (\"push\\tr0\", operands);
7122 output_asm_insn (\"subi3\\t%1,%0,r0\", operands);
7125 output_asm_insn (\"ldiu\\tst,ir1\", operands);
7126 output_asm_insn (\"or\\t07bh,ir1\", operands);
7130 output_asm_insn (\"ldiu\\tst,bk\", operands);
7131 output_asm_insn (\"or\\t07bh,bk\", operands);
7133 output_asm_insn (\"subb3\\t%O1,%O0,r0\", operands);
7135 output_asm_insn (\"and3\\tir1,st,ir1\", operands);
7137 output_asm_insn (\"and3\\tbk,st,bk\", operands);
7138 output_asm_insn (\"pop\\tr0\", operands);
7141 output_asm_insn (\"ldiu\\tir1,st\", operands);
7142 output_asm_insn (\"pop\\tir1\", operands);
7146 output_asm_insn (\"ldiu\\tbk,st\", operands);
7147 output_asm_insn (\"pop\\tbk\", operands);
7151 [(set_attr "type" "multi")])
7154 (define_insn "cmphi_cc"
7156 (unspec:CC [(compare:CC (match_operand:HI 0 "src_operand" "rR,rS<>")
7157 (match_operand:HI 1 "src_operand" "R,rS<>"))] 4))
7158 (clobber (match_scratch:QI 2 "=&d,&d"))
7159 (clobber (match_scratch:QI 3 "=&c,&c"))]
7160 "valid_operands (COMPARE, operands, HImode)"
7162 output_asm_insn (\"subi3\\t%1,%0,%2\", operands);
7163 output_asm_insn (\"ldiu\\tst,%3\", operands);
7164 output_asm_insn (\"or\\t07bh,%3\", operands);
7165 output_asm_insn (\"subb3\\t%O1,%O0,%2\", operands);
7166 output_asm_insn (\"and\\t%3,st\", operands);
7168 [(set_attr "type" "multi")])
7170 (define_insn "cmphi_cc_noov"
7171 [(set (reg:CC_NOOV 21)
7172 (unspec:CC_NOOV [(compare:CC_NOOV (match_operand:HI 0 "src_operand" "rR,rS<>")
7173 (match_operand:HI 1 "src_operand" "R,rS<>"))] 4))
7174 (clobber (match_scratch:QI 2 "=&d,&d"))
7175 (clobber (match_scratch:QI 3 "=&c,&c"))]
7176 "valid_operands (COMPARE, operands, HImode)"
7178 output_asm_insn (\"subi3\\t%1,%0,%2\", operands);
7179 output_asm_insn (\"ldiu\\tst,%3\", operands);
7180 output_asm_insn (\"or\\t07bh,%3\", operands);
7181 output_asm_insn (\"subb3\\t%O1,%O0,%2\", operands);
7182 output_asm_insn (\"and\\t%3,st\", operands);
7184 [(set_attr "type" "multi")])
7186 (define_expand "mulhi3"
7187 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
7188 (mult:HI (match_operand:HI 1 "src_operand" "")
7189 (match_operand:HI 2 "src_operand" "")))
7190 (clobber (reg:CC 21))])]
7192 "c4x_emit_libcall3 (smul_optab->handlers[(int) HImode].libfunc,
7193 MULT, HImode, operands);
7206 ; bCC label ; abnormal loop termination
7207 ; dbu aN, loop ; normal loop termination
7215 ; Which moves the bCC condition outside the inner loop for free.
7218 [(set (pc) (if_then_else (match_operator 3 "comparison_operator"
7219 [(reg:CC 21) (const_int 0)])
7220 (label_ref (match_operand 2 "" ""))
7225 (ge (plus:QI (match_operand:QI 0 "addr_reg_operand" "+a")
7228 (label_ref (match_operand 1 "" ""))
7231 (plus:QI (match_dup 0)
7234 (clobber (reg:CC_NOOV 21))])]
7235 "! c4x_label_conflict (insn, operands[2], operands[1])"
7236 "db%I3\\t%0,%l1\\n\\tb%3\\t%l2"
7237 [(set_attr "type" "multi")])
7240 [(set (pc) (if_then_else (match_operator 3 "comparison_operator"
7241 [(reg:CC 21) (const_int 0)])
7242 (label_ref (match_operand 2 "" ""))
7247 (ne (match_operand:QI 0 "addr_reg_operand" "+a")
7249 (label_ref (match_operand 1 "" ""))
7252 (plus:QI (match_dup 0)
7254 "! c4x_label_conflict (insn, operands[2], operands[1])"
7255 "db%I3\\t%0,%l1\\n\\tb%3\\t%l2"
7256 [(set_attr "type" "multi")])
7259 ; Peepholes to convert 'call label; rets' into jump label
7263 [(parallel [(call (mem:QI (match_operand:QI 0 "call_address_operand" ""))
7264 (match_operand:QI 1 "general_operand" ""))
7265 (clobber (reg:QI 31))])
7267 "c4x_null_epilogue_p ()"
7269 if (REG_P (operands[0]))
7270 return \"bu%#\\t%C0\";
7272 return \"br%#\\t%C0\";"
7273 [(set_attr "type" "jump")])
7276 [(parallel [(set (match_operand 0 "" "")
7277 (call (mem:QI (match_operand:QI 1 "call_address_operand" ""))
7278 (match_operand:QI 2 "general_operand" "")))
7279 (clobber (reg:QI 31))])
7281 "c4x_null_epilogue_p ()"
7283 if (REG_P (operands[1]))
7284 return \"bu%#\\t%C1\";
7286 return \"br%#\\t%C1\";"
7287 [(set_attr "type" "jump")])
7290 ; This peephole should be unnecessary with my patches to flow.c
7291 ; for better autoincrement detection
7293 [(set (match_operand:QF 0 "ext_low_reg_operand" "")
7294 (mem:QF (match_operand:QI 1 "addr_reg_operand" "")))
7295 (set (match_operand:QF 2 "ext_low_reg_operand" "")
7296 (mem:QF (plus:QI (match_dup 1) (const_int 1))))
7297 (parallel [(set (match_dup 1) (plus:QI (match_dup 1) (const_int 2)))
7298 (clobber (reg:CC_NOOV 21))])]
7300 "ldf\\t*%1++,%0\\n\\tldf\\t*%1++,%2")
7303 ; This peephole should be unnecessary with my patches to flow.c
7304 ; for better autoincrement detection
7306 [(set (mem:QF (match_operand:QI 0 "addr_reg_operand" ""))
7307 (match_operand:QF 1 "ext_low_reg_operand" ""))
7308 (set (mem:QF (plus:QI (match_dup 0) (const_int 1)))
7309 (match_operand:QF 2 "ext_low_reg_operand" ""))
7310 (parallel [(set (match_dup 0) (plus:QI (match_dup 0) (const_int 2)))
7311 (clobber (reg:CC_NOOV 21))])]
7313 "stf\\t%1,*%0++\\n\\tstf\\t%2,*%0++")
7316 ; The following two peepholes remove an unecessary load
7317 ; often found at the end of a function. These peepholes
7318 ; could be generalized to other binary operators. They shouldn't
7319 ; be required if we run a post reload mop-up pass.
7321 [(parallel [(set (match_operand:QF 0 "ext_reg_operand" "")
7322 (plus:QF (match_operand:QF 1 "ext_reg_operand" "")
7323 (match_operand:QF 2 "ext_reg_operand" "")))
7324 (clobber (reg:CC_NOOV 21))])
7325 (set (match_operand:QF 3 "ext_reg_operand" "")
7327 "dead_or_set_p (insn, operands[0])"
7331 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
7332 (plus:QI (match_operand:QI 1 "reg_operand" "")
7333 (match_operand:QI 2 "reg_operand" "")))
7334 (clobber (reg:CC_NOOV 21))])
7335 (set (match_operand:QI 3 "reg_operand" "")
7337 "dead_or_set_p (insn, operands[0])"