8dbd6be07d1ca5904031025b01fa30c3c8b114ad
[gcc.git] / gcc / config / c4x / c4x.md
1 ;; Machine description for the TMS320C[34]x for GCC
2 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998,
3 ;; 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
4
5 ;; Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz)
6 ;; and Herman Ten Brugge (Haj.Ten.Brugge@net.HCC.nl)
7
8 ;; This file is part of GCC.
9
10 ;; GCC 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)
13 ;; any later version.
14
15 ;; GCC 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.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GCC; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;
26 ; TODO :
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.
33
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
37
38 ; Additional C40 instructions not coded:
39 ; LDEP, LDPE, LWRct, LAJcond, RETIcondD
40
41 ;
42 ; C4x MODES
43 ;
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)
48 ; CCmode
49 ; CC_NOOVmode
50
51 ;
52 ; C4x PREDICATES:
53 ;
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]
59
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
74
75 ; ADDI src2, src1, dst three operand op
76 ; ADDI src, dst two operand op
77
78 ; Note that the predicates are only used when selecting a pattern
79 ; to determine if an operand is valid.
80
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.
84
85 ; The extra constraint (valid_operands) is used to determine if
86 ; the combination of operands is legitimate for the pattern.
87
88 ;
89 ; C4x CONSTRAINTS:
90 ;
91 ; a address reg AR0-AR7
92 ; b stack pointer SP
93 ; c other int reg AR0-AR7, IR0-IR1, RC, RS, RE
94 ; d fp reg R0-R11 (sets CC when dst)
95 ; e
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
100 ; j
101 ; k block count BK
102 ; l
103 ; m memory
104 ; n immediate int constant with known numeric value
105 ; o offsettable memory
106 ; p memory address
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)
110 ; t R0-R1
111 ; u R2-R3
112 ; v repeat count reg RC
113 ; w
114 ; x index reg IR0-IR1
115 ; y status (CC) reg ST
116 ; z data pointer DP
117
118 ; G fp zero
119 ; H fp 16-bit constant
120 ; I signed 16-bit
121 ; J signed 8-bit (C4x only)
122 ; K signed 5-bit (C4x only)
123 ; L unsigned 16-bit
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
132 ; X any operand
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
137
138 ; Note that the 'd', 'f', and 'h' constraints are equivalent.
139 ; The m constraint is equivalent to 'QT<>{}'
140
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.
144
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.
148
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
154 ; not for 'c'.
155
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).
159
160 ; The ! in front of the 'b' constraint says to GCC to disparage the
161 ; use of this constraint. The 'b' constraint applies only to the SP.
162
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.
174
175 ; Since the C[34]x has many instructions that set the CC, we pay the
176 ; price of having to explicitly define which insns clobber the CC
177 ; (rather than using the macro NOTICE_UPDATE_CC).
178
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.
191
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.
196
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.
204
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:
208
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
215
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.
219
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.
226
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.
232
233 ; Note that the floating point representation of 0.0 on the C4x
234 ; is 0x80000000 (-2147483648). This value produces a warning
235 ; message on 32-bit machines about the decimal constant being so large
236 ; that it is unsigned.
237
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.
242
243 ;
244 ; C4x CONSTANT attributes
245 ;
246 (define_attr "cpu" "c4x,c3x"
247 (const
248 (cond [(symbol_ref "TARGET_C3X") (const_string "c3x")]
249 (const_string "c4x"))))
250
251 ;
252 ; C4x INSN ATTRIBUTES:
253 ;
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
265 ; call function call
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)
271 ; ldp load DP
272 ; push stack push
273 ; pop stack pop
274 ; repeat block repeat
275 ; repeat_top block repeat top
276 ; laj link and jump
277 ; multi multiple instruction
278 ; misc nop (default)
279
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.
284 ;
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"))
287
288
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.
300 ;
301 (define_attr "data" "int16,uint16,high_16,not_uint16" (const_string "int16"))
302
303 (define_asm_attributes
304 [(set_attr "type" "multi")])
305
306 ;
307 ; C4x DELAY SLOTS
308 ;
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.
313 ;
314 ; Annulled branches are a bit difficult because the next instructions
315 ; are preprocessed.
316 ; The table below shows what phase of the c4x is executed.
317 ; BccA[TF] label
318 ; op1 fetch, decode and read executed
319 ; op2 fetch and decode executed
320 ; op3 fetch 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.
325
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")))
337
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")))
349
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")))
361
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")))
371
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")))
378
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")))
388
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")))
393
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")))
400
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")))
405
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")
410
411 (eq_attr "in_delay_slot" "true")
412 (eq_attr "in_annul_slot_2" "true")
413 (eq_attr "in_annul_slot_2" "true")
414
415 (eq_attr "in_delay_slot" "true")
416 (eq_attr "in_annul_slot_3" "true")
417 (eq_attr "in_annul_slot_3" "true") ])
418
419
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)])
424
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)])
429
430
431 ; Decrement and branch conditional instructions cannot modify the
432 ; condition codes for the cycles in the delay slots.
433 ;
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)])
438
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.
441 ;
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)])
445
446 ;
447 ; C4x UNSPEC NUMBERS
448 ;
449 (define_constants
450 [
451 (UNSPEC_BU 1)
452 (UNSPEC_RPTS 2)
453 (UNSPEC_LSH 3)
454 (UNSPEC_CMPHI 4)
455 (UNSPEC_RCPF 5)
456 (UNSPEC_RND 6)
457 (UNSPEC_RPTB_FILL 7)
458 (UNSPEC_LOADHF_INT 8)
459 (UNSPEC_STOREHF_INT 9)
460 (UNSPEC_RSQRF 10)
461 (UNSPEC_LOADQF_INT 11)
462 (UNSPEC_STOREQF_INT 12)
463 (UNSPEC_LDIV 13)
464 (UNSPEC_PUSH_ST 14)
465 (UNSPEC_POP_ST 15)
466 (UNSPEC_PUSH_DP 16)
467 (UNSPEC_POP_DP 17)
468 (UNSPEC_POPQI 18)
469 (UNSPEC_POPQF 19)
470 (UNSPEC_ANDN_ST 20)
471 (UNSPEC_RPTB_INIT 22)
472 (UNSPEC_TOIEEE 23)
473 (UNSPEC_FRIEEE 24)
474 ])
475
476 ;
477 ; C4x FUNCTIONAL UNITS
478 ;
479 ; Define functional units for instruction scheduling to minimize
480 ; pipeline conflicts.
481 ;
482 ; With the C3x, an external memory write (with no wait states) takes
483 ; two cycles and an external memory read (with no wait states) takes
484 ; one cycle. However, an external read following an external write
485 ; takes two cycles. With internal memory, reads and writes take
486 ; half a cycle.
487 ;
488 ; When a C4x address register is loaded it will not be available for
489 ; an extra machine cycle. Calculating with a C4x address register
490 ; makes it unavailable for 2 machine cycles. To notify GCC of these
491 ; pipeline delays, each of the auxiliary and index registers are declared
492 ; as separate functional units.
493 ;
494 ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
495 ; TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
496 ;
497 ; MULTIPLICITY 1 (C4x has no independent identical function units)
498 ; SIMULTANEITY 0 (C4x is pipelined)
499 ; READY_DELAY 1 (Results usually ready after every cyle)
500 ; ISSUE_DELAY 1 (Can issue insns every cycle)
501
502 ; Just some dummy definitions. The real work is done in c4x_adjust_cost.
503 ; These are needed so the min/max READY_DELAY is known.
504
505 (define_function_unit "dummy" 1 0 (const_int 0) 1 1)
506 (define_function_unit "dummy" 1 0 (const_int 0) 2 1)
507 (define_function_unit "dummy" 1 0 (const_int 0) 3 1)
508
509 ; The attribute setar0 is set to 1 for insns where ar0 is a dst operand.
510 ; Note that the attributes unarycc and binarycc do not apply
511 ; if ar0 is a dst operand (only loading an ext. prec. reg. sets CC)
512 (define_attr "setar0" ""
513 (cond [(eq_attr "type" "unary,binary")
514 (if_then_else (match_operand 0 "ar0_reg_operand" "")
515 (const_int 1) (const_int 0))]
516 (const_int 0)))
517
518 (define_attr "setlda_ar0" ""
519 (cond [(eq_attr "type" "lda")
520 (if_then_else (match_operand 0 "ar0_reg_operand" "")
521 (const_int 1) (const_int 0))]
522 (const_int 0)))
523
524 ; The attribute usear0 is set to 1 for insns where ar0 is used
525 ; for addressing, as a src operand, or as a dst operand.
526 (define_attr "usear0" ""
527 (cond [(eq_attr "type" "compare,store")
528 (if_then_else (match_operand 0 "ar0_mem_operand" "")
529 (const_int 1) (const_int 0))
530 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
531 (if_then_else (match_operand 1 "ar0_mem_operand" "")
532 (const_int 1) (const_int 0))
533 (eq_attr "type" "binary,binarycc")
534 (if_then_else (match_operand 2 "ar0_mem_operand" "")
535 (const_int 1) (const_int 0))
536 (eq_attr "type" "db,dbc")
537 (if_then_else (match_operand 0 "ar0_reg_operand" "")
538 (const_int 1) (const_int 0))]
539 (const_int 0)))
540
541 ; The attribute readar0 is set to 1 for insns where ar0 is a src operand.
542 (define_attr "readar0" ""
543 (cond [(eq_attr "type" "compare")
544 (if_then_else (match_operand 0 "ar0_reg_operand" "")
545 (const_int 1) (const_int 0))
546 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
547 (if_then_else (match_operand 1 "ar0_reg_operand" "")
548 (const_int 1) (const_int 0))
549 (eq_attr "type" "binary,binarycc")
550 (if_then_else (match_operand 2 "ar0_reg_operand" "")
551 (const_int 1) (const_int 0))]
552 (const_int 0)))
553
554 (define_attr "setar1" ""
555 (cond [(eq_attr "type" "unary,binary")
556 (if_then_else (match_operand 0 "ar1_reg_operand" "")
557 (const_int 1) (const_int 0))]
558 (const_int 0)))
559
560 (define_attr "setlda_ar1" ""
561 (cond [(eq_attr "type" "lda")
562 (if_then_else (match_operand 0 "ar1_reg_operand" "")
563 (const_int 1) (const_int 0))]
564 (const_int 0)))
565
566 (define_attr "usear1" ""
567 (cond [(eq_attr "type" "compare,store")
568 (if_then_else (match_operand 0 "ar1_mem_operand" "")
569 (const_int 1) (const_int 0))
570 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
571 (if_then_else (match_operand 1 "ar1_mem_operand" "")
572 (const_int 1) (const_int 0))
573 (eq_attr "type" "binary,binarycc")
574 (if_then_else (match_operand 2 "ar1_mem_operand" "")
575 (const_int 1) (const_int 0))
576 (eq_attr "type" "db,dbc")
577 (if_then_else (match_operand 0 "ar1_reg_operand" "")
578 (const_int 1) (const_int 0))]
579 (const_int 0)))
580
581 (define_attr "readar1" ""
582 (cond [(eq_attr "type" "compare")
583 (if_then_else (match_operand 0 "ar1_reg_operand" "")
584 (const_int 1) (const_int 0))
585 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
586 (if_then_else (match_operand 1 "ar1_reg_operand" "")
587 (const_int 1) (const_int 0))
588 (eq_attr "type" "binary,binarycc")
589 (if_then_else (match_operand 2 "ar1_reg_operand" "")
590 (const_int 1) (const_int 0))]
591 (const_int 0)))
592
593 (define_attr "setar2" ""
594 (cond [(eq_attr "type" "unary,binary")
595 (if_then_else (match_operand 0 "ar2_reg_operand" "")
596 (const_int 1) (const_int 0))]
597 (const_int 0)))
598
599 (define_attr "setlda_ar2" ""
600 (cond [(eq_attr "type" "lda")
601 (if_then_else (match_operand 0 "ar2_reg_operand" "")
602 (const_int 1) (const_int 0))]
603 (const_int 0)))
604
605 (define_attr "usear2" ""
606 (cond [(eq_attr "type" "compare,store")
607 (if_then_else (match_operand 0 "ar2_mem_operand" "")
608 (const_int 1) (const_int 0))
609 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
610 (if_then_else (match_operand 1 "ar2_mem_operand" "")
611 (const_int 1) (const_int 0))
612 (eq_attr "type" "binary,binarycc")
613 (if_then_else (match_operand 2 "ar2_mem_operand" "")
614 (const_int 1) (const_int 0))
615 (eq_attr "type" "db,dbc")
616 (if_then_else (match_operand 0 "ar2_reg_operand" "")
617 (const_int 1) (const_int 0))]
618 (const_int 0)))
619
620 (define_attr "readar2" ""
621 (cond [(eq_attr "type" "compare")
622 (if_then_else (match_operand 0 "ar2_reg_operand" "")
623 (const_int 1) (const_int 0))
624 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
625 (if_then_else (match_operand 1 "ar2_reg_operand" "")
626 (const_int 1) (const_int 0))
627 (eq_attr "type" "binary,binarycc")
628 (if_then_else (match_operand 2 "ar2_reg_operand" "")
629 (const_int 1) (const_int 0))]
630 (const_int 0)))
631
632 (define_attr "setar3" ""
633 (cond [(eq_attr "type" "unary,binary")
634 (if_then_else (match_operand 0 "ar3_reg_operand" "")
635 (const_int 1) (const_int 0))]
636 (const_int 0)))
637
638 (define_attr "setlda_ar3" ""
639 (cond [(eq_attr "type" "lda")
640 (if_then_else (match_operand 0 "ar3_reg_operand" "")
641 (const_int 1) (const_int 0))]
642 (const_int 0)))
643
644 (define_attr "usear3" ""
645 (cond [(eq_attr "type" "compare,store")
646 (if_then_else (match_operand 0 "ar3_mem_operand" "")
647 (const_int 1) (const_int 0))
648 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
649 (if_then_else (match_operand 1 "ar3_mem_operand" "")
650 (const_int 1) (const_int 0))
651 (eq_attr "type" "binary,binarycc")
652 (if_then_else (match_operand 2 "ar3_mem_operand" "")
653 (const_int 1) (const_int 0))
654 (eq_attr "type" "db,dbc")
655 (if_then_else (match_operand 0 "ar3_reg_operand" "")
656 (const_int 1) (const_int 0))]
657 (const_int 0)))
658
659 (define_attr "readar3" ""
660 (cond [(eq_attr "type" "compare")
661 (if_then_else (match_operand 0 "ar3_reg_operand" "")
662 (const_int 1) (const_int 0))
663 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
664 (if_then_else (match_operand 1 "ar3_reg_operand" "")
665 (const_int 1) (const_int 0))
666 (eq_attr "type" "binary,binarycc")
667 (if_then_else (match_operand 2 "ar3_reg_operand" "")
668 (const_int 1) (const_int 0))]
669 (const_int 0)))
670
671 (define_attr "setar4" ""
672 (cond [(eq_attr "type" "unary,binary")
673 (if_then_else (match_operand 0 "ar4_reg_operand" "")
674 (const_int 1) (const_int 0))]
675 (const_int 0)))
676
677 (define_attr "setlda_ar4" ""
678 (cond [(eq_attr "type" "lda")
679 (if_then_else (match_operand 0 "ar4_reg_operand" "")
680 (const_int 1) (const_int 0))]
681 (const_int 0)))
682
683 (define_attr "usear4" ""
684 (cond [(eq_attr "type" "compare,store")
685 (if_then_else (match_operand 0 "ar4_mem_operand" "")
686 (const_int 1) (const_int 0))
687 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
688 (if_then_else (match_operand 1 "ar4_mem_operand" "")
689 (const_int 1) (const_int 0))
690 (eq_attr "type" "binary,binarycc")
691 (if_then_else (match_operand 2 "ar4_mem_operand" "")
692 (const_int 1) (const_int 0))
693 (eq_attr "type" "db,dbc")
694 (if_then_else (match_operand 0 "ar4_reg_operand" "")
695 (const_int 1) (const_int 0))]
696 (const_int 0)))
697
698 (define_attr "readar4" ""
699 (cond [(eq_attr "type" "compare")
700 (if_then_else (match_operand 0 "ar4_reg_operand" "")
701 (const_int 1) (const_int 0))
702 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
703 (if_then_else (match_operand 1 "ar4_reg_operand" "")
704 (const_int 1) (const_int 0))
705 (eq_attr "type" "binary,binarycc")
706 (if_then_else (match_operand 2 "ar4_reg_operand" "")
707 (const_int 1) (const_int 0))]
708 (const_int 0)))
709
710 (define_attr "setar5" ""
711 (cond [(eq_attr "type" "unary,binary")
712 (if_then_else (match_operand 0 "ar5_reg_operand" "")
713 (const_int 1) (const_int 0))]
714 (const_int 0)))
715
716 (define_attr "setlda_ar5" ""
717 (cond [(eq_attr "type" "lda")
718 (if_then_else (match_operand 0 "ar5_reg_operand" "")
719 (const_int 1) (const_int 0))]
720 (const_int 0)))
721
722 (define_attr "usear5" ""
723 (cond [(eq_attr "type" "compare,store")
724 (if_then_else (match_operand 0 "ar5_mem_operand" "")
725 (const_int 1) (const_int 0))
726 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
727 (if_then_else (match_operand 1 "ar5_mem_operand" "")
728 (const_int 1) (const_int 0))
729 (eq_attr "type" "binary,binarycc")
730 (if_then_else (match_operand 2 "ar5_mem_operand" "")
731 (const_int 1) (const_int 0))
732 (eq_attr "type" "db,dbc")
733 (if_then_else (match_operand 0 "ar5_reg_operand" "")
734 (const_int 1) (const_int 0))]
735 (const_int 0)))
736
737 (define_attr "readar5" ""
738 (cond [(eq_attr "type" "compare")
739 (if_then_else (match_operand 0 "ar5_reg_operand" "")
740 (const_int 1) (const_int 0))
741 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
742 (if_then_else (match_operand 1 "ar5_reg_operand" "")
743 (const_int 1) (const_int 0))
744 (eq_attr "type" "binary,binarycc")
745 (if_then_else (match_operand 2 "ar5_reg_operand" "")
746 (const_int 1) (const_int 0))]
747 (const_int 0)))
748
749 (define_attr "setar6" ""
750 (cond [(eq_attr "type" "unary,binary")
751 (if_then_else (match_operand 0 "ar6_reg_operand" "")
752 (const_int 1) (const_int 0))]
753 (const_int 0)))
754
755 (define_attr "setlda_ar6" ""
756 (cond [(eq_attr "type" "lda")
757 (if_then_else (match_operand 0 "ar6_reg_operand" "")
758 (const_int 1) (const_int 0))]
759 (const_int 0)))
760
761 (define_attr "usear6" ""
762 (cond [(eq_attr "type" "compare,store")
763 (if_then_else (match_operand 0 "ar6_mem_operand" "")
764 (const_int 1) (const_int 0))
765 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
766 (if_then_else (match_operand 1 "ar6_mem_operand" "")
767 (const_int 1) (const_int 0))
768 (eq_attr "type" "binary,binarycc")
769 (if_then_else (match_operand 2 "ar6_mem_operand" "")
770 (const_int 1) (const_int 0))
771 (eq_attr "type" "db,dbc")
772 (if_then_else (match_operand 0 "ar6_reg_operand" "")
773 (const_int 1) (const_int 0))]
774 (const_int 0)))
775
776 (define_attr "readar6" ""
777 (cond [(eq_attr "type" "compare")
778 (if_then_else (match_operand 0 "ar6_reg_operand" "")
779 (const_int 1) (const_int 0))
780 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
781 (if_then_else (match_operand 1 "ar6_reg_operand" "")
782 (const_int 1) (const_int 0))
783 (eq_attr "type" "binary,binarycc")
784 (if_then_else (match_operand 2 "ar6_reg_operand" "")
785 (const_int 1) (const_int 0))]
786 (const_int 0)))
787
788 (define_attr "setar7" ""
789 (cond [(eq_attr "type" "unary,binary")
790 (if_then_else (match_operand 0 "ar7_reg_operand" "")
791 (const_int 1) (const_int 0))]
792 (const_int 0)))
793
794 (define_attr "setlda_ar7" ""
795 (cond [(eq_attr "type" "lda")
796 (if_then_else (match_operand 0 "ar7_reg_operand" "")
797 (const_int 1) (const_int 0))]
798 (const_int 0)))
799
800 (define_attr "usear7" ""
801 (cond [(eq_attr "type" "compare,store")
802 (if_then_else (match_operand 0 "ar7_mem_operand" "")
803 (const_int 1) (const_int 0))
804 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
805 (if_then_else (match_operand 1 "ar7_mem_operand" "")
806 (const_int 1) (const_int 0))
807 (eq_attr "type" "binary,binarycc")
808 (if_then_else (match_operand 2 "ar7_mem_operand" "")
809 (const_int 1) (const_int 0))
810 (eq_attr "type" "db,dbc")
811 (if_then_else (match_operand 0 "ar7_reg_operand" "")
812 (const_int 1) (const_int 0))]
813 (const_int 0)))
814
815 (define_attr "readar7" ""
816 (cond [(eq_attr "type" "compare")
817 (if_then_else (match_operand 0 "ar7_reg_operand" "")
818 (const_int 1) (const_int 0))
819 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
820 (if_then_else (match_operand 1 "ar7_reg_operand" "")
821 (const_int 1) (const_int 0))
822 (eq_attr "type" "binary,binarycc")
823 (if_then_else (match_operand 2 "ar7_reg_operand" "")
824 (const_int 1) (const_int 0))]
825 (const_int 0)))
826
827 (define_attr "setir0" ""
828 (cond [(eq_attr "type" "unary,binary")
829 (if_then_else (match_operand 0 "ir0_reg_operand" "")
830 (const_int 1) (const_int 0))]
831 (const_int 0)))
832
833 (define_attr "setlda_ir0" ""
834 (cond [(eq_attr "type" "lda")
835 (if_then_else (match_operand 0 "ir0_reg_operand" "")
836 (const_int 1) (const_int 0))]
837 (const_int 0)))
838
839 (define_attr "useir0" ""
840 (cond [(eq_attr "type" "compare,store")
841 (if_then_else (match_operand 0 "ir0_mem_operand" "")
842 (const_int 1) (const_int 0))
843 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
844 (if_then_else (match_operand 1 "ir0_mem_operand" "")
845 (const_int 1) (const_int 0))
846 (eq_attr "type" "binary,binarycc")
847 (if_then_else (match_operand 2 "ir0_mem_operand" "")
848 (const_int 1) (const_int 0))]
849 (const_int 0)))
850
851 (define_attr "setir1" ""
852 (cond [(eq_attr "type" "unary,binary")
853 (if_then_else (match_operand 0 "ir1_reg_operand" "")
854 (const_int 1) (const_int 0))]
855 (const_int 0)))
856
857 (define_attr "setlda_ir1" ""
858 (cond [(eq_attr "type" "lda")
859 (if_then_else (match_operand 0 "ir1_reg_operand" "")
860 (const_int 1) (const_int 0))]
861 (const_int 0)))
862
863 (define_attr "useir1" ""
864 (cond [(eq_attr "type" "compare,store")
865 (if_then_else (match_operand 0 "ir1_mem_operand" "")
866 (const_int 1) (const_int 0))
867 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc")
868 (if_then_else (match_operand 1 "ir1_mem_operand" "")
869 (const_int 1) (const_int 0))
870 (eq_attr "type" "binary,binarycc")
871 (if_then_else (match_operand 2 "ir1_mem_operand" "")
872 (const_int 1) (const_int 0))]
873 (const_int 0)))
874
875 ; With the C3x, things are simpler but slower, i.e. more pipeline conflicts :(
876 ; There are three functional groups:
877 ; (1) AR0-AR7, IR0-IR1, BK
878 ; (2) DP
879 ; (3) SP
880 ;
881 ; When a register in one of these functional groups is loaded,
882 ; the contents of that or any other register in its group
883 ; will not be available to the next instruction for 2 machine cycles.
884 ; Similarly, when a register in one of the functional groups is read
885 ; excepting (IR0-IR1, BK, DP) the contents of that or any other register
886 ; in its group will not be available to the next instruction for
887 ; 1 machine cycle.
888 ;
889 ; Let's ignore functional groups 2 and 3 for now, since they are not
890 ; so important.
891
892 (define_attr "setgroup1" ""
893 (cond [(eq_attr "type" "lda,unary,binary")
894 (if_then_else (match_operand 0 "group1_reg_operand" "")
895 (const_int 1) (const_int 0))]
896 (const_int 0)))
897
898 (define_attr "usegroup1" ""
899 (cond [(eq_attr "type" "compare,store,store_store,store_load")
900 (if_then_else (match_operand 0 "group1_mem_operand" "")
901 (const_int 1) (const_int 0))
902 (eq_attr "type" "compare,lda,unary,unarycc,binary,binarycc,load_load,load_store")
903 (if_then_else (match_operand 1 "group1_mem_operand" "")
904 (const_int 1) (const_int 0))
905 (eq_attr "type" "store_store,load_store")
906 (if_then_else (match_operand 2 "group1_mem_operand" "")
907 (const_int 1) (const_int 0))
908 (eq_attr "type" "load_load,store_load")
909 (if_then_else (match_operand 3 "group1_mem_operand" "")
910 (const_int 1) (const_int 0))]
911 (const_int 0)))
912
913 (define_attr "readarx" ""
914 (cond [(eq_attr "type" "compare")
915 (if_then_else (match_operand 0 "arx_reg_operand" "")
916 (const_int 1) (const_int 0))
917 (eq_attr "type" "compare,store,lda,unary,unarycc,binary,binarycc")
918 (if_then_else (match_operand 1 "arx_reg_operand" "")
919 (const_int 1) (const_int 0))
920 (eq_attr "type" "binary,binarycc")
921 (if_then_else (match_operand 2 "arx_reg_operand" "")
922 (const_int 1) (const_int 0))]
923 (const_int 0)))
924
925
926 ;
927 ; C4x INSN PATTERNS:
928 ;
929 ; Note that the movMM and addP patterns can be called during reload
930 ; so we need to take special care with theses patterns since
931 ; we cannot blindly clobber CC or generate new pseudo registers.
932
933 ;
934 ; TWO OPERAND INTEGER INSTRUCTIONS
935 ;
936
937 ;
938 ; LDP/LDPK
939 ;
940 (define_insn "set_ldp"
941 [(set (match_operand:QI 0 "dp_reg_operand" "=z")
942 (high:QI (match_operand:QI 1 "" "")))]
943 "! TARGET_SMALL"
944 "* return (TARGET_C3X) ? \"ldp\\t%A1\" : \"ldpk\\t%A1\";"
945 [(set_attr "type" "ldp")])
946
947 (define_insn "set_ldp_prologue"
948 [(set (match_operand:QI 0 "dp_reg_operand" "=z")
949 (high:QI (match_operand:QI 1 "" "")))]
950 "TARGET_SMALL && TARGET_PARANOID"
951 "* return (TARGET_C3X) ? \"ldp\\t@data_sec\" : \"ldpk\\t@data_sec\";"
952 [(set_attr "type" "ldp")])
953
954 (define_insn "set_high"
955 [(set (match_operand:QI 0 "std_reg_operand" "=c")
956 (high:QI (match_operand:QI 1 "symbolic_address_operand" "")))]
957 "! TARGET_C3X && ! TARGET_TI"
958 "ldhi\\t^%H1,%0"
959 [(set_attr "type" "unary")])
960
961 (define_insn "set_lo_sum"
962 [(set (match_operand:QI 0 "std_reg_operand" "+c")
963 (lo_sum:QI (match_dup 0)
964 (match_operand:QI 1 "symbolic_address_operand" "")))]
965 "! TARGET_TI"
966 "or\\t#%H1,%0"
967 [(set_attr "type" "unary")])
968
969 (define_split
970 [(set (match_operand:QI 0 "std_reg_operand" "")
971 (match_operand:QI 1 "symbolic_address_operand" ""))]
972 "reload_completed && ! TARGET_C3X && ! TARGET_TI"
973 [(set (match_dup 0) (high:QI (match_dup 1)))
974 (set (match_dup 0) (lo_sum:QI (match_dup 0) (match_dup 1)))]
975 "")
976
977 (define_split
978 [(set (match_operand:QI 0 "reg_operand" "")
979 (match_operand:QI 1 "const_int_operand" ""))
980 (clobber (reg:QI 16))]
981 "! TARGET_C3X
982 && ! IS_INT16_CONST (INTVAL (operands[1]))
983 && ! IS_HIGH_CONST (INTVAL (operands[1]))
984 && reload_completed
985 && std_reg_operand (operands[0], QImode)"
986 [(set (match_dup 0) (match_dup 2))
987 (set (match_dup 0) (ior:QI (match_dup 0) (match_dup 3)))]
988 "
989 {
990 operands[2] = GEN_INT (INTVAL (operands[1]) & ~0xffff);
991 operands[3] = GEN_INT (INTVAL (operands[1]) & 0xffff);
992 }")
993
994 (define_split
995 [(set (match_operand:QI 0 "reg_operand" "")
996 (match_operand:QI 1 "const_int_operand" ""))]
997 "! TARGET_C3X
998 && ! IS_INT16_CONST (INTVAL (operands[1]))
999 && ! IS_HIGH_CONST (INTVAL (operands[1]))
1000 && reload_completed
1001 && std_reg_operand (operands[0], QImode)"
1002 [(set (match_dup 0) (match_dup 2))
1003 (set (match_dup 0) (ior:QI (match_dup 0) (match_dup 3)))]
1004 "
1005 {
1006 operands[2] = GEN_INT (INTVAL (operands[1]) & ~0xffff);
1007 operands[3] = GEN_INT (INTVAL (operands[1]) & 0xffff);
1008 }")
1009
1010 (define_split
1011 [(set (match_operand:QI 0 "reg_operand" "")
1012 (match_operand:QI 1 "const_int_operand" ""))
1013 (clobber (reg:QI 16))]
1014 "TARGET_C3X && ! TARGET_SMALL
1015 && ! IS_INT16_CONST (INTVAL (operands[1]))
1016 && reload_completed
1017 && std_reg_operand (operands[0], QImode)
1018 && c4x_shiftable_constant (operands[1]) < 0"
1019 [(set (match_dup 0) (match_dup 2))
1020 (set (match_dup 0) (ashift:QI (match_dup 0) (match_dup 4)))
1021 (set (match_dup 0) (ior:QI (match_dup 0) (match_dup 3)))]
1022 "
1023 {
1024 /* Generate two's complement value of 16 MSBs. */
1025 operands[2] = gen_rtx (CONST_INT, VOIDmode,
1026 (((INTVAL (operands[1]) >> 16) & 0xffff)
1027 - 0x8000) ^ ~0x7fff);
1028 operands[3] = GEN_INT (INTVAL (operands[1]) & 0xffff);
1029 operands[4] = GEN_INT (16);
1030 }")
1031
1032 (define_split
1033 [(set (match_operand:QI 0 "reg_operand" "")
1034 (match_operand:QI 1 "const_int_operand" ""))]
1035 "TARGET_C3X && ! TARGET_SMALL
1036 && ! IS_INT16_CONST (INTVAL (operands[1]))
1037 && reload_completed
1038 && std_reg_operand (operands[0], QImode)
1039 && c4x_shiftable_constant (operands[1]) < 0"
1040 [(set (match_dup 0) (match_dup 2))
1041 (set (match_dup 0) (ashift:QI (match_dup 0) (match_dup 4)))
1042 (set (match_dup 0) (ior:QI (match_dup 0) (match_dup 3)))]
1043 "
1044 {
1045 /* Generate two's complement value of 16 MSBs. */
1046 operands[2] = gen_rtx (CONST_INT, VOIDmode,
1047 (((INTVAL (operands[1]) >> 16) & 0xffff)
1048 - 0x8000) ^ ~0x7fff);
1049 operands[3] = GEN_INT (INTVAL (operands[1]) & 0xffff);
1050 operands[4] = GEN_INT (16);
1051 }")
1052
1053 (define_split
1054 [(set (match_operand:QI 0 "reg_operand" "")
1055 (match_operand:QI 1 "const_int_operand" ""))
1056 (clobber (reg:QI 16))]
1057 "TARGET_C3X
1058 && ! IS_INT16_CONST (INTVAL (operands[1]))
1059 && reload_completed
1060 && std_reg_operand (operands[0], QImode)
1061 && c4x_shiftable_constant (operands[1]) >= 0"
1062 [(set (match_dup 0) (match_dup 2))
1063 (set (match_dup 0) (ashift:QI (match_dup 0) (match_dup 3)))]
1064 "
1065 {
1066 /* Generate two's complement value of MSBs. */
1067 int shift = c4x_shiftable_constant (operands[1]);
1068
1069 operands[2] = GEN_INT ((((INTVAL (operands[1]) >> shift) & 0xffff)
1070 - 0x8000) ^ ~0x7fff);
1071 operands[3] = GEN_INT (shift);
1072 }")
1073
1074 (define_split
1075 [(set (match_operand:QI 0 "reg_operand" "")
1076 (match_operand:QI 1 "const_int_operand" ""))]
1077 "TARGET_C3X
1078 && ! IS_INT16_CONST (INTVAL (operands[1]))
1079 && reload_completed
1080 && std_reg_operand (operands[0], QImode)
1081 && c4x_shiftable_constant (operands[1]) >= 0"
1082 [(set (match_dup 0) (match_dup 2))
1083 (set (match_dup 0) (ashift:QI (match_dup 0) (match_dup 3)))]
1084 "
1085 {
1086 /* Generate two's complement value of MSBs. */
1087 int shift = c4x_shiftable_constant (operands[1]);
1088
1089 operands[2] = GEN_INT ((((INTVAL (operands[1]) >> shift) & 0xffff)
1090 - 0x8000) ^ ~0x7fff);
1091 operands[3] = GEN_INT (shift);
1092 }")
1093
1094 (define_split
1095 [(set (match_operand:QI 0 "reg_operand" "")
1096 (match_operand:QI 1 "const_int_operand" ""))
1097 (clobber (reg:QI 16))]
1098 "! TARGET_SMALL
1099 && ! IS_INT16_CONST (INTVAL (operands[1]))
1100 && ! IS_HIGH_CONST (INTVAL (operands[1]))
1101 && reload_completed
1102 && ! std_reg_operand (operands[0], QImode)"
1103 [(set (match_dup 2) (high:QI (match_dup 3)))
1104 (set (match_dup 0) (match_dup 4))
1105 (use (match_dup 1))]
1106 "
1107 {
1108 rtx dp_reg = gen_rtx_REG (Pmode, DP_REGNO);
1109 operands[2] = dp_reg;
1110 operands[3] = force_const_mem (Pmode, operands[1]);
1111 operands[4] = change_address (operands[3], QImode,
1112 gen_rtx_LO_SUM (Pmode, dp_reg,
1113 XEXP (operands[3], 0)));
1114 operands[3] = XEXP (operands[3], 0);
1115 }")
1116
1117 (define_split
1118 [(set (match_operand:QI 0 "reg_operand" "")
1119 (match_operand:QI 1 "const_int_operand" ""))]
1120 "! TARGET_SMALL
1121 && ! IS_INT16_CONST (INTVAL (operands[1]))
1122 && ! IS_HIGH_CONST (INTVAL (operands[1]))
1123 && reload_completed
1124 && ! std_reg_operand (operands[0], QImode)"
1125 [(set (match_dup 2) (high:QI (match_dup 3)))
1126 (set (match_dup 0) (match_dup 4))
1127 (use (match_dup 1))]
1128 "
1129 {
1130 rtx dp_reg = gen_rtx_REG (Pmode, DP_REGNO);
1131 operands[2] = dp_reg;
1132 operands[3] = force_const_mem (Pmode, operands[1]);
1133 operands[4] = change_address (operands[3], QImode,
1134 gen_rtx_LO_SUM (Pmode, dp_reg,
1135 XEXP (operands[3], 0)));
1136 operands[3] = XEXP (operands[3], 0);
1137 }")
1138
1139 (define_split
1140 [(set (match_operand:QI 0 "reg_operand" "")
1141 (match_operand:QI 1 "const_int_operand" ""))
1142 (clobber (reg:QI 16))]
1143 "TARGET_SMALL
1144 && ! IS_INT16_CONST (INTVAL (operands[1]))
1145 && ! IS_HIGH_CONST (INTVAL (operands[1]))
1146 && reload_completed
1147 && ((TARGET_C3X && c4x_shiftable_constant (operands[1]) < 0)
1148 || ! std_reg_operand (operands[0], QImode))"
1149 [(set (match_dup 0) (match_dup 2))
1150 (use (match_dup 1))]
1151 "
1152 {
1153 rtx dp_reg = gen_rtx_REG (Pmode, DP_REGNO);
1154 operands[2] = force_const_mem (Pmode, operands[1]);
1155 operands[2] = change_address (operands[2], QImode,
1156 gen_rtx_LO_SUM (Pmode, dp_reg,
1157 XEXP (operands[2], 0)));
1158 }")
1159
1160 (define_split
1161 [(set (match_operand:QI 0 "reg_operand" "")
1162 (match_operand:QI 1 "const_int_operand" ""))]
1163 "TARGET_SMALL
1164 && ! IS_INT16_CONST (INTVAL (operands[1]))
1165 && ! IS_HIGH_CONST (INTVAL (operands[1]))
1166 && reload_completed
1167 && ((TARGET_C3X && c4x_shiftable_constant (operands[1]) < 0)
1168 || ! std_reg_operand (operands[0], QImode))"
1169 [(set (match_dup 0) (match_dup 2))
1170 (use (match_dup 1))]
1171 "
1172 {
1173 rtx dp_reg = gen_rtx_REG (Pmode, DP_REGNO);
1174 operands[2] = force_const_mem (Pmode, operands[1]);
1175 operands[2] = change_address (operands[2], QImode,
1176 gen_rtx_LO_SUM (Pmode, dp_reg,
1177 XEXP (operands[2], 0)));
1178 }")
1179
1180 (define_split
1181 [(set (match_operand:HI 0 "reg_operand" "")
1182 (match_operand:HI 1 "const_int_operand" ""))
1183 (clobber (reg:QI 16))]
1184 "reload_completed"
1185 [(set (match_dup 2) (match_dup 4))
1186 (set (match_dup 3) (match_dup 5))]
1187 "
1188 {
1189 operands[2] = c4x_operand_subword (operands[0], 0, 1, HImode);
1190 operands[3] = c4x_operand_subword (operands[0], 1, 1, HImode);
1191 operands[4] = c4x_operand_subword (operands[1], 0, 1, HImode);
1192 operands[5] = c4x_operand_subword (operands[1], 1, 1, HImode);
1193 }")
1194
1195
1196 ; We need to clobber the DP reg to be safe in case we
1197 ; need to load this address from memory
1198 (define_insn "load_immed_address"
1199 [(set (match_operand:QI 0 "reg_operand" "=a?x?c*r")
1200 (match_operand:QI 1 "symbolic_address_operand" ""))
1201 (clobber (reg:QI 16))]
1202 "TARGET_LOAD_ADDRESS"
1203 "#"
1204 [(set_attr "type" "multi")])
1205
1206
1207 (define_split
1208 [(set (match_operand:QI 0 "std_reg_operand" "")
1209 (match_operand:QI 1 "symbolic_address_operand" ""))
1210 (clobber (reg:QI 16))]
1211 "reload_completed && ! TARGET_C3X && ! TARGET_TI"
1212 [(set (match_dup 0) (high:QI (match_dup 1)))
1213 (set (match_dup 0) (lo_sum:QI (match_dup 0) (match_dup 1)))]
1214 "")
1215
1216 ; CC has been selected to load a symbolic address. We force the address
1217 ; into memory and then generate LDP and LDIU insns.
1218 ; This is also required for the C30 if we pretend that we can
1219 ; easily load symbolic addresses into a register.
1220 (define_split
1221 [(set (match_operand:QI 0 "reg_operand" "")
1222 (match_operand:QI 1 "symbolic_address_operand" ""))
1223 (clobber (reg:QI 16))]
1224 "reload_completed
1225 && ! TARGET_SMALL
1226 && (TARGET_C3X || TARGET_TI || ! std_reg_operand (operands[0], QImode))"
1227 [(set (match_dup 2) (high:QI (match_dup 3)))
1228 (set (match_dup 0) (match_dup 4))
1229 (use (match_dup 1))]
1230 "
1231 {
1232 rtx dp_reg = gen_rtx_REG (Pmode, DP_REGNO);
1233 operands[2] = dp_reg;
1234 operands[3] = force_const_mem (Pmode, operands[1]);
1235 operands[4] = change_address (operands[3], QImode,
1236 gen_rtx_LO_SUM (Pmode, dp_reg,
1237 XEXP (operands[3], 0)));
1238 operands[3] = XEXP (operands[3], 0);
1239 }")
1240
1241 ; This pattern is similar to the above but does not emit a LDP
1242 ; for the small memory model.
1243 (define_split
1244 [(set (match_operand:QI 0 "reg_operand" "")
1245 (match_operand:QI 1 "symbolic_address_operand" ""))
1246 (clobber (reg:QI 16))]
1247 "reload_completed
1248 && TARGET_SMALL
1249 && (TARGET_C3X || TARGET_TI || ! std_reg_operand (operands[0], QImode))"
1250 [(set (match_dup 0) (match_dup 2))
1251 (use (match_dup 1))]
1252 "
1253 {
1254 rtx dp_reg = gen_rtx_REG (Pmode, DP_REGNO);
1255 operands[2] = force_const_mem (Pmode, operands[1]);
1256 operands[2] = change_address (operands[2], QImode,
1257 gen_rtx_LO_SUM (Pmode, dp_reg,
1258 XEXP (operands[2], 0)));
1259 }")
1260
1261 (define_insn "loadhi_big_constant"
1262 [(set (match_operand:HI 0 "reg_operand" "=c*d")
1263 (match_operand:HI 1 "const_int_operand" ""))
1264 (clobber (reg:QI 16))]
1265 ""
1266 "#"
1267 [(set_attr "type" "multi")])
1268
1269 ;
1270 ; LDIU/LDA/STI/STIK
1271 ;
1272 ; The following moves will not set the condition codes register.
1273 ;
1274
1275 ; This must come before the general case
1276 (define_insn "*movqi_stik"
1277 [(set (match_operand:QI 0 "memory_operand" "=m")
1278 (match_operand:QI 1 "stik_const_operand" "K"))]
1279 "! TARGET_C3X"
1280 "stik\\t%1,%0"
1281 [(set_attr "type" "store")])
1282
1283 (define_insn "loadqi_big_constant"
1284 [(set (match_operand:QI 0 "reg_operand" "=c*d")
1285 (match_operand:QI 1 "const_int_operand" ""))
1286 (clobber (reg:QI 16))]
1287 "! IS_INT16_CONST (INTVAL (operands[1]))
1288 && ! IS_HIGH_CONST (INTVAL (operands[1]))"
1289 "#"
1290 [(set_attr "type" "multi")])
1291
1292 ; We must provide an alternative to store to memory in case we have to
1293 ; spill a register.
1294 (define_insn "movqi_noclobber"
1295 [(set (match_operand:QI 0 "dst_operand" "=d,*c,m,r")
1296 (match_operand:QI 1 "src_hi_operand" "rIm,rIm,r,O"))]
1297 "(REG_P (operands[0]) || REG_P (operands[1])
1298 || GET_CODE (operands[0]) == SUBREG
1299 || GET_CODE (operands[1]) == SUBREG)
1300 && ! symbolic_address_operand (operands[1], QImode)"
1301 "*
1302 if (which_alternative == 2)
1303 return \"sti\\t%1,%0\";
1304
1305 if (! TARGET_C3X && which_alternative == 3)
1306 {
1307 operands[1] = GEN_INT ((INTVAL (operands[1]) >> 16) & 0xffff);
1308 return \"ldhi\\t%1,%0\";
1309 }
1310
1311 /* The lda instruction cannot use the same register as source
1312 and destination. */
1313 if (! TARGET_C3X && which_alternative == 1
1314 && ( IS_ADDR_REG (operands[0])
1315 || IS_INDEX_REG (operands[0])
1316 || IS_SP_REG (operands[0]))
1317 && (REGNO (operands[0]) != REGNO (operands[1])))
1318 return \"lda\\t%1,%0\";
1319 return \"ldiu\\t%1,%0\";
1320 "
1321 [(set_attr "type" "unary,lda,store,unary")
1322 (set_attr "data" "int16,int16,int16,high_16")])
1323
1324 ;
1325 ; LDI
1326 ;
1327
1328 ; We shouldn't need these peepholes, but the combiner seems to miss them...
1329 (define_peephole
1330 [(set (match_operand:QI 0 "ext_reg_operand" "=d")
1331 (match_operand:QI 1 "src_operand" "rIm"))
1332 (set (reg:CC 21)
1333 (compare:CC (match_dup 0) (const_int 0)))]
1334 ""
1335 "ldi\\t%1,%0"
1336 [(set_attr "type" "unarycc")
1337 (set_attr "data" "int16")])
1338
1339 (define_insn "*movqi_set"
1340 [(set (reg:CC 21)
1341 (compare:CC (match_operand:QI 1 "src_operand" "rIm")
1342 (const_int 0)))
1343 (set (match_operand:QI 0 "ext_reg_operand" "=d")
1344 (match_dup 1))]
1345 ""
1346 "ldi\\t%1,%0"
1347 [(set_attr "type" "unarycc")
1348 (set_attr "data" "int16")])
1349
1350 ; This pattern probably gets in the way and requires a scratch register
1351 ; when a simple compare with zero will suffice.
1352 ;(define_insn "*movqi_test"
1353 ; [(set (reg:CC 21)
1354 ; (compare:CC (match_operand:QI 1 "src_operand" "rIm")
1355 ; (const_int 0)))
1356 ; (clobber (match_scratch:QI 0 "=d"))]
1357 ; ""
1358 ; "@
1359 ; ldi\\t%1,%0"
1360 ; [(set_attr "type" "unarycc")
1361 ; (set_attr "data" "int16")])
1362
1363 ; If one of the operands is not a register, then we should
1364 ; emit two insns, using a scratch register. This will produce
1365 ; better code in loops if the source operand is invariant, since
1366 ; the source reload can be optimized out. During reload we cannot
1367 ; use change_address or force_reg which will allocate new pseudo regs.
1368
1369 ; Unlike most other insns, the move insns can't be split with
1370 ; different predicates, because register spilling and other parts of
1371 ; the compiler, have memoized the insn number already.
1372
1373 (define_expand "movqi"
1374 [(set (match_operand:QI 0 "general_operand" "")
1375 (match_operand:QI 1 "general_operand" ""))]
1376 ""
1377 "
1378 {
1379 if (c4x_emit_move_sequence (operands, QImode))
1380 DONE;
1381 }")
1382
1383
1384 ; As far as GCC is concerned, the moves are performed in parallel
1385 ; thus it must be convinced that there is no aliasing.
1386 ; It also assumes that the input operands are simultaneously loaded
1387 ; and then the output operands are simultaneously stored.
1388 ; With the C4x, if there are parallel stores to the same address
1389 ; both stores are executed.
1390 ; If there is a parallel load and store to the same address,
1391 ; the load is performed first.
1392 ; The problem with this pattern is that reload can spoil
1393 ; the show when it eliminates a reference to the frame pointer.
1394 ; This can invalidate the memory addressing mode, i.e., when
1395 ; the displacement is greater than 1.
1396 (define_insn "movqi_parallel"
1397 [(set (match_operand:QI 0 "parallel_operand" "=q,S<>!V,q,S<>!V")
1398 (match_operand:QI 1 "parallel_operand" "S<>!V,q,S<>!V,q"))
1399 (set (match_operand:QI 2 "parallel_operand" "=q,S<>!V,S<>!V,q")
1400 (match_operand:QI 3 "parallel_operand" "S<>!V,q,q,S<>!V"))]
1401 "TARGET_PARALLEL && valid_parallel_load_store (operands, QImode)"
1402 "@
1403 ldi1\\t%1,%0\\n||\\tldi2\\t%3,%2
1404 sti1\\t%1,%0\\n||\\tsti2\\t%3,%2
1405 ldi\\t%1,%0\\n||\\tsti\\t%3,%2
1406 ldi\\t%3,%2\\n||\\tsti\\t%1,%0"
1407 [(set_attr "type" "load_load,store_store,load_store,store_load")])
1408
1409 ;
1410 ; PUSH/POP
1411 ;
1412 (define_insn "pushqi"
1413 [(set (mem:QI (pre_inc:QI (reg:QI 20)))
1414 (match_operand:QI 0 "reg_operand" "r"))]
1415 ""
1416 "push\\t%0"
1417 [(set_attr "type" "push")])
1418
1419 (define_insn "push_st"
1420 [(set (mem:QI (pre_inc:QI (reg:QI 20)))
1421 (unspec:QI [(reg:QI 21)] UNSPEC_PUSH_ST))
1422 (use (reg:QI 21))]
1423 ""
1424 "push\\tst"
1425 [(set_attr "type" "push")])
1426
1427 (define_insn "push_dp"
1428 [(set (mem:QI (pre_inc:QI (reg:QI 20)))
1429 (unspec:QI [(reg:QI 16)] UNSPEC_PUSH_DP))
1430 (use (reg:QI 16))]
1431 ""
1432 "push\\tdp"
1433 [(set_attr "type" "push")])
1434
1435 (define_insn "popqi"
1436 [(set (match_operand:QI 0 "reg_operand" "=r")
1437 (mem:QI (post_dec:QI (reg:QI 20))))
1438 (clobber (reg:CC 21))]
1439 ""
1440 "pop\\t%0"
1441 [(set_attr "type" "pop")])
1442
1443 (define_insn "pop_st"
1444 [(set (unspec:QI [(reg:QI 21)] UNSPEC_POP_ST)
1445 (mem:QI (post_dec:QI (reg:QI 20))))
1446 (clobber (reg:CC 21))]
1447 ""
1448 "pop\\tst"
1449 [(set_attr "type" "pop")])
1450
1451 (define_insn "pop_dp"
1452 [(set (unspec:QI [(reg:QI 16)] UNSPEC_POP_DP)
1453 (mem:QI (post_dec:QI (reg:QI 20))))
1454 (clobber (reg:CC 16))]
1455 ""
1456 "pop\\tdp"
1457 [(set_attr "type" "pop")])
1458
1459 (define_insn "popqi_unspec"
1460 [(set (unspec:QI [(match_operand:QI 0 "reg_operand" "=r")] UNSPEC_POPQI)
1461 (mem:QI (post_dec:QI (reg:QI 20))))
1462 (clobber (match_dup 0))
1463 (clobber (reg:CC 21))]
1464 ""
1465 "pop\\t%0"
1466 [(set_attr "type" "pop")])
1467
1468 ;
1469 ; ABSI
1470 ;
1471 (define_expand "absqi2"
1472 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
1473 (abs:QI (match_operand:QI 1 "src_operand" "")))
1474 (clobber (reg:CC_NOOV 21))])]
1475 ""
1476 "")
1477
1478 (define_insn "*absqi2_clobber"
1479 [(set (match_operand:QI 0 "reg_operand" "=d,c")
1480 (abs:QI (match_operand:QI 1 "src_operand" "rIm,rIm")))
1481 (clobber (reg:CC_NOOV 21))]
1482 ""
1483 "absi\\t%1,%0"
1484 [(set_attr "type" "unarycc,unary")
1485 (set_attr "data" "int16,int16")])
1486
1487 (define_insn "*absqi2_noclobber"
1488 [(set (match_operand:QI 0 "std_reg_operand" "=c")
1489 (abs:QI (match_operand:QI 1 "src_operand" "rIm")))]
1490 ""
1491 "absi\\t%1,%0"
1492 [(set_attr "type" "unary")
1493 (set_attr "data" "int16")])
1494
1495 (define_split
1496 [(set (match_operand:QI 0 "std_reg_operand" "")
1497 (abs:QI (match_operand:QI 1 "src_operand" "")))
1498 (clobber (reg:CC_NOOV 21))]
1499 "reload_completed"
1500 [(set (match_dup 0)
1501 (abs:QI (match_dup 1)))]
1502 "")
1503
1504 (define_insn "*absqi2_test"
1505 [(set (reg:CC_NOOV 21)
1506 (compare:CC_NOOV (abs:QI (match_operand:QI 1 "src_operand" "rIm"))
1507 (const_int 0)))
1508 (clobber (match_scratch:QI 0 "=d"))]
1509 ""
1510 "absi\\t%1,%0"
1511 [(set_attr "type" "unarycc")
1512 (set_attr "data" "int16")])
1513
1514 (define_insn "*absqi2_set"
1515 [(set (reg:CC_NOOV 21)
1516 (compare:CC_NOOV (abs:QI (match_operand:QI 1 "src_operand" "rIm"))
1517 (const_int 0)))
1518 (set (match_operand:QI 0 "ext_reg_operand" "=d")
1519 (abs:QI (match_dup 1)))]
1520 ""
1521 "absi\\t%1,%0"
1522 [(set_attr "type" "unarycc")
1523 (set_attr "data" "int16")])
1524
1525 ;
1526 ; NEGI
1527 ;
1528 (define_expand "negqi2"
1529 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
1530 (neg:QI (match_operand:QI 1 "src_operand" "")))
1531 (clobber (reg:CC_NOOV 21))])]
1532 ""
1533 "")
1534
1535 (define_insn "*negqi2_clobber"
1536 [(set (match_operand:QI 0 "reg_operand" "=d,c")
1537 (neg:QI (match_operand:QI 1 "src_operand" "rIm,rIm")))
1538 (clobber (reg:CC_NOOV 21))]
1539 ""
1540 "negi\\t%1,%0"
1541 [(set_attr "type" "unarycc,unary")
1542 (set_attr "data" "int16,int16")])
1543
1544 (define_insn "*negqi2_noclobber"
1545 [(set (match_operand:QI 0 "std_reg_operand" "=c")
1546 (neg:QI (match_operand:QI 1 "src_operand" "rIm")))]
1547 ""
1548 "negi\\t%1,%0"
1549 [(set_attr "type" "unary")
1550 (set_attr "data" "int16")])
1551
1552 (define_split
1553 [(set (match_operand:QI 0 "std_reg_operand" "")
1554 (neg:QI (match_operand:QI 1 "src_operand" "")))
1555 (clobber (reg:CC_NOOV 21))]
1556 "reload_completed"
1557 [(set (match_dup 0)
1558 (neg:QI (match_dup 1)))]
1559 "")
1560
1561 (define_insn "*negqi2_test"
1562 [(set (reg:CC_NOOV 21)
1563 (compare:CC_NOOV (neg:QI (match_operand:QI 1 "src_operand" "rIm"))
1564 (const_int 0)))
1565 (clobber (match_scratch:QI 0 "=d"))]
1566 ""
1567 "negi\\t%1,%0"
1568 [(set_attr "type" "unarycc")
1569 (set_attr "data" "int16")])
1570
1571 (define_insn "*negqi2_set"
1572 [(set (reg:CC_NOOV 21)
1573 (compare:CC_NOOV (neg:QI (match_operand:QI 1 "src_operand" "rIm"))
1574 (const_int 0)))
1575 (set (match_operand:QI 0 "ext_reg_operand" "=d")
1576 (neg:QI (match_dup 1)))]
1577 ""
1578 "negi\\t%1,%0"
1579 [(set_attr "type" "unarycc")
1580 (set_attr "data" "int16")])
1581
1582 (define_insn "*negbqi2_clobber"
1583 [(set (match_operand:QI 0 "ext_reg_operand" "=d")
1584 (neg:QI (match_operand:QI 1 "src_operand" "rIm")))
1585 (use (reg:CC_NOOV 21))
1586 (clobber (reg:CC_NOOV 21))]
1587 ""
1588 "negb\\t%1,%0"
1589 [(set_attr "type" "unarycc")
1590 (set_attr "data" "int16")])
1591
1592 ;
1593 ; NOT
1594 ;
1595 (define_expand "one_cmplqi2"
1596 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
1597 (not:QI (match_operand:QI 1 "lsrc_operand" "")))
1598 (clobber (reg:CC 21))])]
1599 ""
1600 "")
1601
1602 (define_insn "*one_cmplqi2_clobber"
1603 [(set (match_operand:QI 0 "reg_operand" "=d,c")
1604 (not:QI (match_operand:QI 1 "lsrc_operand" "rLm,rLm")))
1605 (clobber (reg:CC 21))]
1606 ""
1607 "not\\t%1,%0"
1608 [(set_attr "type" "unarycc,unary")
1609 (set_attr "data" "uint16,uint16")])
1610
1611 (define_insn "*one_cmplqi2_noclobber"
1612 [(set (match_operand:QI 0 "std_reg_operand" "=c")
1613 (not:QI (match_operand:QI 1 "lsrc_operand" "rLm")))]
1614 ""
1615 "not\\t%1,%0"
1616 [(set_attr "type" "unary")
1617 (set_attr "data" "uint16")])
1618
1619 (define_split
1620 [(set (match_operand:QI 0 "std_reg_operand" "")
1621 (not:QI (match_operand:QI 1 "lsrc_operand" "")))
1622 (clobber (reg:CC 21))]
1623 "reload_completed"
1624 [(set (match_dup 0)
1625 (not:QI (match_dup 1)))]
1626 "")
1627
1628 (define_insn "*one_cmplqi2_test"
1629 [(set (reg:CC 21)
1630 (compare:CC (not:QI (match_operand:QI 1 "lsrc_operand" "rLm"))
1631 (const_int 0)))
1632 (clobber (match_scratch:QI 0 "=d"))]
1633 ""
1634 "not\\t%1,%0"
1635 [(set_attr "type" "unarycc")
1636 (set_attr "data" "uint16")])
1637
1638 (define_insn "*one_cmplqi2_set"
1639 [(set (reg:CC 21)
1640 (compare:CC (not:QI (match_operand:QI 1 "lsrc_operand" "rLm"))
1641 (const_int 0)))
1642 (set (match_operand:QI 0 "ext_reg_operand" "=d")
1643 (not:QI (match_dup 1)))]
1644 ""
1645 "not\\t%1,%0"
1646 [(set_attr "type" "unarycc")
1647 (set_attr "data" "uint16")])
1648
1649 (define_insn "*one_cmplqi2_const_clobber"
1650 [(set (match_operand:QI 0 "reg_operand" "=d,c")
1651 (match_operand:QI 1 "not_const_operand" "N,N"))
1652 (clobber (reg:CC 21))]
1653 ""
1654 "@
1655 not\\t%N1,%0
1656 not\\t%N1,%0"
1657 [(set_attr "type" "unarycc,unary")
1658 (set_attr "data" "not_uint16,not_uint16")])
1659
1660 ; movqi can use this for loading an integer that can't normally
1661 ; fit into a 16-bit signed integer. The drawback is that it cannot
1662 ; go into R0-R11 since that will clobber the CC and movqi shouldn't
1663 ; do that. This can cause additional reloading but in most cases
1664 ; this will cause only an additional register move. With the large
1665 ; memory model we require an extra instruction to load DP anyway,
1666 ; if we're loading the constant from memory. The big advantage of
1667 ; allowing constants that satisfy not_const_operand in movqi, is that
1668 ; it allows andn to be generated more often.
1669 ; However, there is a problem if GCC has decided that it wants
1670 ; to use R0-R11, since we won't have a matching pattern...
1671 ; In interim, we prevent immed_const allowing `N' constants.
1672 (define_insn "*one_cmplqi2_const_noclobber"
1673 [(set (match_operand:QI 0 "std_reg_operand" "=c")
1674 (match_operand:QI 1 "not_const_operand" "N"))]
1675 ""
1676 "not\\t%N1,%0"
1677 [(set_attr "type" "unary")
1678 (set_attr "data" "not_uint16")])
1679
1680 ;
1681 ; ROL
1682 ;
1683 (define_expand "rotlqi3"
1684 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
1685 (rotate:QI (match_operand:QI 1 "reg_operand" "")
1686 (match_operand:QI 2 "const_int_operand" "")))
1687 (clobber (reg:CC 21))])]
1688 ""
1689 "if (INTVAL (operands[2]) > 4)
1690 FAIL; /* Open code as two shifts and an or */
1691 if (INTVAL (operands[2]) > 1)
1692 {
1693 int i;
1694 rtx tmp;
1695
1696 /* If we have 4 or fewer shifts, then it is probably faster
1697 to emit separate ROL instructions. A C3x requires
1698 at least 4 instructions (a C4x requires at least 3), to
1699 perform a rotation by shifts. */
1700
1701 tmp = operands[1];
1702 for (i = 0; i < INTVAL (operands[2]) - 1; i++)
1703 {
1704 tmp = gen_reg_rtx (QImode);
1705 emit_insn (gen_rotl_1_clobber (tmp, operands[1]));
1706 operands[1] = tmp;
1707 }
1708 emit_insn (gen_rotl_1_clobber (operands[0], tmp));
1709 DONE;
1710 }")
1711
1712 (define_insn "rotl_1_clobber"
1713 [(set (match_operand:QI 0 "reg_operand" "=d,c")
1714 (rotate:QI (match_operand:QI 1 "reg_operand" "0,0")
1715 (const_int 1)))
1716 (clobber (reg:CC 21))]
1717 ""
1718 "rol\\t%0"
1719 [(set_attr "type" "unarycc,unary")])
1720 ; Default to int16 data attr.
1721
1722 ;
1723 ; ROR
1724 ;
1725 (define_expand "rotrqi3"
1726 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
1727 (rotatert:QI (match_operand:QI 1 "reg_operand" "")
1728 (match_operand:QI 2 "const_int_operand" "")))
1729 (clobber (reg:CC 21))])]
1730 ""
1731 "if (INTVAL (operands[2]) > 4)
1732 FAIL; /* Open code as two shifts and an or */
1733 if (INTVAL (operands[2]) > 1)
1734 {
1735 int i;
1736 rtx tmp;
1737
1738 /* If we have 4 or fewer shifts, then it is probably faster
1739 to emit separate ROL instructions. A C3x requires
1740 at least 4 instructions (a C4x requires at least 3), to
1741 perform a rotation by shifts. */
1742
1743 tmp = operands[1];
1744 for (i = 0; i < INTVAL (operands[2]) - 1; i++)
1745 {
1746 tmp = gen_reg_rtx (QImode);
1747 emit_insn (gen_rotr_1_clobber (tmp, operands[1]));
1748 operands[1] = tmp;
1749 }
1750 emit_insn (gen_rotr_1_clobber (operands[0], tmp));
1751 DONE;
1752 }")
1753
1754 (define_insn "rotr_1_clobber"
1755 [(set (match_operand:QI 0 "reg_operand" "=d,c")
1756 (rotatert:QI (match_operand:QI 1 "reg_operand" "0,0")
1757 (const_int 1)))
1758 (clobber (reg:CC 21))]
1759 ""
1760 "ror\\t%0"
1761 [(set_attr "type" "unarycc,unary")])
1762 ; Default to int16 data attr.
1763
1764
1765 ;
1766 ; THREE OPERAND INTEGER INSTRUCTIONS
1767 ;
1768
1769 ;
1770 ; ADDI
1771 ;
1772 ; This is used by reload when it calls gen_add2_insn for address arithmetic
1773 ; so we must emit the pattern that doesn't clobber CC.
1774 ;
1775 (define_expand "addqi3"
1776 [(parallel [(set (match_operand:QI 0 "std_or_reg_operand" "")
1777 (plus:QI (match_operand:QI 1 "src_operand" "")
1778 (match_operand:QI 2 "src_operand" "")))
1779 (clobber (reg:CC_NOOV 21))])]
1780 ""
1781 "legitimize_operands (PLUS, operands, QImode);
1782 if (reload_in_progress
1783 || (! IS_PSEUDO_REG (operands[0])
1784 && ! IS_EXT_REG (operands[0])))
1785 {
1786 emit_insn (gen_addqi3_noclobber (operands[0], operands[1], operands[2]));
1787 DONE;
1788 }")
1789
1790 ; This pattern is required primarily for manipulating the stack pointer
1791 ; where GCC doesn't expect CC to be clobbered or for calculating
1792 ; addresses during reload. Since this is a more specific pattern
1793 ; it needs to go first (otherwise we get into problems trying to decide
1794 ; to add clobbers).
1795 (define_insn "addqi3_noclobber"
1796 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,c")
1797 (plus:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
1798 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>")))]
1799 "valid_operands (PLUS, operands, QImode)"
1800 "@
1801 addi\\t%2,%0
1802 addi3\\t%2,%1,%0
1803 addi3\\t%2,%1,%0"
1804 [(set_attr "type" "binary,binary,binary")])
1805 ; Default to int16 data attr.
1806
1807 (define_insn "*addqi3_clobber"
1808 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
1809 (plus:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>,0,rR,rS<>")
1810 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>,rIm,JR,rS<>")))
1811 (clobber (reg:CC_NOOV 21))]
1812 "valid_operands (PLUS, operands, QImode)"
1813 "@
1814 addi\\t%2,%0
1815 addi3\\t%2,%1,%0
1816 addi3\\t%2,%1,%0
1817 addi\\t%2,%0
1818 addi3\\t%2,%1,%0
1819 addi3\\t%2,%1,%0"
1820 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
1821 ; Default to int16 data attr.
1822
1823 (define_split
1824 [(set (match_operand:QI 0 "std_reg_operand" "")
1825 (plus:QI (match_operand:QI 1 "src_operand" "")
1826 (match_operand:QI 2 "src_operand" "")))
1827 (clobber (reg:CC_NOOV 21))]
1828 "reload_completed"
1829 [(set (match_dup 0)
1830 (plus:QI (match_dup 1)
1831 (match_dup 2)))]
1832 "")
1833
1834 (define_insn "*addqi3_test"
1835 [(set (reg:CC_NOOV 21)
1836 (compare:CC_NOOV (plus:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
1837 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>"))
1838 (const_int 0)))
1839 (clobber (match_scratch:QI 0 "=d,d,d"))]
1840 "valid_operands (PLUS, operands, QImode)"
1841 "@
1842 addi\\t%2,%0
1843 addi3\\t%2,%1,%0
1844 addi3\\t%2,%1,%0"
1845 [(set_attr "type" "binarycc,binarycc,binarycc")])
1846 ; Default to int16 data attr.
1847
1848 ; gcc does this in combine.c we just reverse it here
1849 (define_insn "*cmp_neg"
1850 [(set (reg:CC_NOOV 21)
1851 (compare:CC_NOOV (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
1852 (neg: QI (match_operand:QI 2 "src_operand" "g,JR,rS<>"))))
1853 (clobber (match_scratch:QI 0 "=d,d,d"))]
1854 "valid_operands (PLUS, operands, QImode)"
1855 "@
1856 addi\\t%2,%0
1857 addi3\\t%2,%1,%0
1858 addi3\\t%2,%1,%0"
1859 [(set_attr "type" "binarycc,binarycc,binarycc")])
1860
1861 (define_peephole
1862 [(parallel [(set (match_operand:QI 0 "ext_reg_operand" "=d,d,d")
1863 (plus:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
1864 (match_operand:QI 2 "src_operand" "g,JR,rS<>")))
1865 (clobber (reg:CC_NOOV 21))])
1866 (set (reg:CC_NOOV 21)
1867 (compare:CC_NOOV (match_dup 0) (const_int 0)))]
1868 "valid_operands (PLUS, operands, QImode)"
1869 "@
1870 addi\\t%2,%0
1871 addi3\\t%2,%1,%0
1872 addi3\\t%2,%1,%0"
1873 [(set_attr "type" "binarycc,binarycc,binarycc")])
1874
1875 (define_insn "*addqi3_set"
1876 [(set (reg:CC_NOOV 21)
1877 (compare:CC_NOOV (plus:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
1878 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>"))
1879 (const_int 0)))
1880 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d")
1881 (plus:QI (match_dup 1) (match_dup 2)))]
1882 "valid_operands (PLUS, operands, QImode)"
1883 "@
1884 addi\\t%2,%0
1885 addi3\\t%2,%1,%0
1886 addi3\\t%2,%1,%0"
1887 [(set_attr "type" "binarycc,binarycc,binarycc")])
1888 ; Default to int16 data attr.
1889
1890
1891 ; This pattern is required during reload when eliminate_regs_in_insn
1892 ; effectively converts a move insn into an add insn when the src
1893 ; operand is the frame pointer plus a constant. Without this
1894 ; pattern, gen_addqi3 can be called with a register for operand0
1895 ; that can clobber CC.
1896 ; For example, we may have (set (mem (reg ar0)) (reg 99))
1897 ; with (set (reg 99) (plus (reg ar3) (const_int 8)))
1898 ; Now since ar3, the frame pointer, is unchanging within the function,
1899 ; (plus (reg ar3) (const_int 8)) is considered a constant.
1900 ; eliminate_regs_in_insn substitutes this constant to give
1901 ; (set (mem (reg ar0)) (plus (reg ar3) (const_int 8))).
1902 ; This is an invalid C4x insn but if we don't provide a pattern
1903 ; for it, it will be considered to be a move insn for reloading.
1904 (define_insn "*addqi3_noclobber_reload"
1905 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,c")
1906 (plus:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
1907 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>")))]
1908 "reload_in_progress"
1909 "@
1910 addi\\t%2,%0
1911 addi3\\t%2,%1,%0
1912 addi3\\t%2,%1,%0"
1913 [(set_attr "type" "binary,binary,binary")])
1914 ; Default to int16 data attr.
1915
1916
1917 (define_insn "*addqi3_carry_clobber"
1918 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
1919 (plus:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>,0,rR,rS<>")
1920 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>,rIm,JR,rS<>")))
1921 (use (reg:CC_NOOV 21))
1922 (clobber (reg:CC_NOOV 21))]
1923 "valid_operands (PLUS, operands, QImode)"
1924 "@
1925 addc\\t%2,%0
1926 addc3\\t%2,%1,%0
1927 addc3\\t%2,%1,%0
1928 addc\\t%2,%0
1929 addc3\\t%2,%1,%0
1930 addc3\\t%2,%1,%0"
1931 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
1932 ; Default to int16 data attr.
1933
1934
1935 ;
1936 ; SUBI/SUBRI
1937 ;
1938 (define_expand "subqi3"
1939 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
1940 (minus:QI (match_operand:QI 1 "src_operand" "")
1941 (match_operand:QI 2 "src_operand" "")))
1942 (clobber (reg:CC_NOOV 21))])]
1943 ""
1944 "legitimize_operands (MINUS, operands, QImode);")
1945
1946 (define_insn "*subqi3_clobber"
1947 [(set (match_operand:QI 0 "reg_operand" "=d,d,d,?d,c,c,c,?c")
1948 (minus:QI (match_operand:QI 1 "src_operand" "0,rIm,rR,rS<>,0,rIm,rR,rS<>")
1949 (match_operand:QI 2 "src_operand" "rIm,0,JR,rS<>,rIm,0,JR,rS<>")))
1950 (clobber (reg:CC_NOOV 21))]
1951 "valid_operands (MINUS, operands, QImode)"
1952 "@
1953 subi\\t%2,%0
1954 subri\\t%1,%0
1955 subi3\\t%2,%1,%0
1956 subi3\\t%2,%1,%0
1957 subi\\t%2,%0
1958 subri\\t%1,%0
1959 subi3\\t%2,%1,%0
1960 subi3\\t%2,%1,%0"
1961 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc,binary,binary,binary,binary")])
1962 ; Default to int16 data attr.
1963
1964 (define_split
1965 [(set (match_operand:QI 0 "std_reg_operand" "")
1966 (minus:QI (match_operand:QI 1 "src_operand" "")
1967 (match_operand:QI 2 "src_operand" "")))
1968 (clobber (reg:CC_NOOV 21))]
1969 "reload_completed"
1970 [(set (match_dup 0)
1971 (minus:QI (match_dup 1)
1972 (match_dup 2)))]
1973 "")
1974
1975 (define_insn "*subqi3_test"
1976 [(set (reg:CC_NOOV 21)
1977 (compare:CC_NOOV (minus:QI (match_operand:QI 1 "src_operand" "0,rIm,rR,rS<>")
1978 (match_operand:QI 2 "src_operand" "rIm,0,JR,rS<>"))
1979 (const_int 0)))
1980 (clobber (match_scratch:QI 0 "=d,d,d,?d"))]
1981 "valid_operands (MINUS, operands, QImode)"
1982 "@
1983 subi\\t%2,%0
1984 subri\\t%1,%0
1985 subi3\\t%2,%1,%0
1986 subi3\\t%2,%1,%0"
1987 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
1988 ; Default to int16 data attr.
1989
1990 (define_peephole
1991 [(parallel [(set (match_operand:QI 0 "ext_reg_operand" "=d,d,d,?d")
1992 (minus:QI (match_operand:QI 1 "src_operand" "0,rIm,rR,rS<>")
1993 (match_operand:QI 2 "src_operand" "rIm,0,JR,rS<>")))
1994 (clobber (reg:CC_NOOV 21))])
1995 (set (reg:CC_NOOV 21)
1996 (compare:CC_NOOV (match_dup 0) (const_int 0)))]
1997 "valid_operands (MINUS, operands, QImode)"
1998 "@
1999 subi\\t%2,%0
2000 subri\\t%1,%0
2001 subi3\\t%2,%1,%0
2002 subi3\\t%2,%1,%0"
2003 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
2004
2005 (define_insn "*subqi3_set"
2006 [(set (reg:CC_NOOV 21)
2007 (compare:CC_NOOV (minus:QI (match_operand:QI 1 "src_operand" "0,rIm,rR,rS<>")
2008 (match_operand:QI 2 "src_operand" "rIm,0,JR,rS<>"))
2009 (const_int 0)))
2010 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d,?d")
2011 (minus:QI (match_dup 1)
2012 (match_dup 2)))]
2013 "valid_operands (MINUS, operands, QImode)"
2014 "@
2015 subi\\t%2,%0
2016 subri\\t%1,%0
2017 subi3\\t%2,%1,%0
2018 subi3\\t%2,%1,%0"
2019 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
2020 ; Default to int16 data attr.
2021
2022 (define_insn "*subqi3_noclobber"
2023 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,c,?c")
2024 (minus:QI (match_operand:QI 1 "src_operand" "0,rIm,rR,rS<>")
2025 (match_operand:QI 2 "src_operand" "rIm,0,JR,rS<>")))]
2026 "valid_operands (MINUS, operands, QImode)"
2027 "@
2028 subi\\t%2,%0
2029 subri\\t%1,%0
2030 subi3\\t%2,%1,%0
2031 subi3\\t%2,%1,%0"
2032 [(set_attr "type" "binary,binary,binary,binary")])
2033 ; Default to int16 data attr.
2034
2035 (define_insn "*subqi3_carry_clobber"
2036 [(set (match_operand:QI 0 "reg_operand" "=d,d,d,?d,c,c,c,?c")
2037 (minus:QI (match_operand:QI 1 "src_operand" "0,rIm,rR,rS<>,0,rIm,rR,rS<>")
2038 (match_operand:QI 2 "src_operand" "rIm,0,JR,rS<>,rIm,0,JR,rS<>")))
2039 (use (reg:CC_NOOV 21))
2040 (clobber (reg:CC_NOOV 21))]
2041 "valid_operands (MINUS, operands, QImode)"
2042 "@
2043 subb\\t%2,%0
2044 subrb\\t%1,%0
2045 subb3\\t%2,%1,%0
2046 subb3\\t%2,%1,%0
2047 subb\\t%2,%0
2048 subrb\\t%1,%0
2049 subb3\\t%2,%1,%0
2050 subb3\\t%2,%1,%0"
2051 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc,binary,binary,binary,binary")])
2052 ; Default to int16 data attr.
2053
2054 (define_insn "*subqi3_carry_set"
2055 [(set (reg:CC_NOOV 21)
2056 (compare:CC_NOOV (minus:QI (match_operand:QI 1 "src_operand" "0,rIm,rR,rS<>")
2057 (match_operand:QI 2 "src_operand" "rIm,0,JR,rS<>"))
2058 (const_int 0)))
2059 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d,?d")
2060 (minus:QI (match_dup 1)
2061 (match_dup 2)))
2062 (use (reg:CC_NOOV 21))]
2063 "valid_operands (MINUS, operands, QImode)"
2064 "@
2065 subb\\t%2,%0
2066 subrb\\t%1,%0
2067 subb3\\t%2,%1,%0
2068 subb3\\t%2,%1,%0"
2069 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
2070 ; Default to int16 data attr.
2071
2072 ;
2073 ; MPYI
2074 ;
2075 (define_expand "mulqi3"
2076 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2077 (mult:QI (match_operand:QI 1 "src_operand" "")
2078 (match_operand:QI 2 "src_operand" "")))
2079 (clobber (reg:CC_NOOV 21))])]
2080 ""
2081 "if (TARGET_MPYI || (GET_CODE (operands[2]) == CONST_INT
2082 && exact_log2 (INTVAL (operands[2])) >= 0))
2083 legitimize_operands (MULT, operands, QImode);
2084 else
2085 {
2086 if (GET_CODE (operands[2]) == CONST_INT)
2087 {
2088 /* Let GCC try to synthesize the multiplication using shifts
2089 and adds. In most cases this will be more profitable than
2090 using the C3x MPYI. */
2091 FAIL;
2092 }
2093 if (operands[1] == operands[2])
2094 {
2095 /* Do the squaring operation in-line. */
2096 emit_insn (gen_sqrqi2_inline (operands[0], operands[1]));
2097 DONE;
2098 }
2099 if (TARGET_INLINE)
2100 {
2101 emit_insn (gen_mulqi3_inline (operands[0], operands[1],
2102 operands[2]));
2103 DONE;
2104 }
2105 c4x_emit_libcall3 (smul_optab->handlers[(int) QImode].libfunc,
2106 MULT, QImode, operands);
2107 DONE;
2108 }
2109 ")
2110
2111 (define_insn "*mulqi3_clobber"
2112 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2113 (mult:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>,0,rR,rS<>")
2114 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>,rIm,JR,rS<>")))
2115 (clobber (reg:CC_NOOV 21))]
2116 "valid_operands (MULT, operands, QImode)"
2117 "*
2118 if (which_alternative == 0 || which_alternative == 3)
2119 {
2120 if (TARGET_C3X
2121 && GET_CODE (operands[2]) == CONST_INT
2122 && exact_log2 (INTVAL (operands[2])) >= 0)
2123 return \"ash\\t%L2,%0\";
2124 else
2125 return \"mpyi\\t%2,%0\";
2126 }
2127 else
2128 return \"mpyi3\\t%2,%1,%0\";"
2129 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
2130 ; Default to int16 data attr.
2131
2132 (define_insn "*mulqi3_test"
2133 [(set (reg:CC_NOOV 21)
2134 (compare:CC_NOOV (mult:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2135 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>"))
2136 (const_int 0)))
2137 (clobber (match_scratch:QI 0 "=d,d,d"))]
2138 "valid_operands (MULT, operands, QImode)"
2139 "*
2140 if (which_alternative == 0)
2141 {
2142 if (TARGET_C3X
2143 && GET_CODE (operands[2]) == CONST_INT
2144 && exact_log2 (INTVAL (operands[2])) >= 0)
2145 return \"ash\\t%L2,%0\";
2146 else
2147 return \"mpyi\\t%2,%0\";
2148 }
2149 else
2150 return \"mpyi3\\t%2,%1,%0\";"
2151 [(set_attr "type" "binarycc,binarycc,binarycc")])
2152 ; Default to int16 data attr.
2153
2154 (define_insn "*mulqi3_set"
2155 [(set (reg:CC_NOOV 21)
2156 (compare:CC_NOOV (mult:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2157 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>"))
2158 (const_int 0)))
2159 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d")
2160 (mult:QI (match_dup 1)
2161 (match_dup 2)))]
2162 "valid_operands (MULT, operands, QImode)"
2163 "*
2164 if (which_alternative == 0)
2165 {
2166 if (TARGET_C3X
2167 && GET_CODE (operands[2]) == CONST_INT
2168 && exact_log2 (INTVAL (operands[2])) >= 0)
2169 return \"ash\\t%L2,%0\";
2170 else
2171 return \"mpyi\\t%2,%0\";
2172 }
2173 else
2174 return \"mpyi3\\t%2,%1,%0\";"
2175 [(set_attr "type" "binarycc,binarycc,binarycc")])
2176 ; Default to int16 data attr.
2177
2178 ; The C3x multiply instruction assumes 24-bit signed integer operands
2179 ; and the 48-bit result is truncated to 32-bits.
2180 (define_insn "mulqi3_24_clobber"
2181 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2182 (mult:QI
2183 (sign_extend:QI
2184 (and:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>,0,rR,rS<>")
2185 (const_int 16777215)))
2186 (sign_extend:QI
2187 (and:QI (match_operand:QI 2 "src_operand" "rIm,JR,rS<>,rIm,JR,rS<>")
2188 (const_int 16777215)))))
2189 (clobber (reg:CC_NOOV 21))]
2190 "TARGET_C3X && valid_operands (MULT, operands, QImode)"
2191 "@
2192 mpyi\\t%2,%0
2193 mpyi3\\t%2,%1,%0
2194 mpyi3\\t%2,%1,%0
2195 mpyi\\t%2,%0
2196 mpyi3\\t%2,%1,%0
2197 mpyi3\\t%2,%1,%0"
2198 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
2199 ; Default to int16 data attr.
2200
2201
2202 ; Fast square function for C3x where TARGET_MPYI not asserted
2203 (define_expand "sqrqi2_inline"
2204 [(set (match_dup 7) (match_operand:QI 1 "src_operand" ""))
2205 (parallel [(set (match_dup 3)
2206 (lshiftrt:QI (match_dup 7) (const_int 16)))
2207 (clobber (reg:CC 21))])
2208 (parallel [(set (match_dup 2)
2209 (and:QI (match_dup 7) (const_int 65535)))
2210 (clobber (reg:CC 21))])
2211 (parallel [(set (match_dup 4)
2212 (mult:QI (sign_extend:QI (and:QI (match_dup 2)
2213 (const_int 16777215)))
2214 (sign_extend:QI (and:QI (match_dup 2)
2215 (const_int 16777215)))))
2216 (clobber (reg:CC_NOOV 21))])
2217 (parallel [(set (match_dup 5)
2218 (mult:QI (sign_extend:QI (and:QI (match_dup 2)
2219 (const_int 16777215)))
2220 (sign_extend:QI (and:QI (match_dup 3)
2221 (const_int 16777215)))))
2222 (clobber (reg:CC_NOOV 21))])
2223 (parallel [(set (match_dup 6)
2224 (ashift:QI (match_dup 5) (const_int 17)))
2225 (clobber (reg:CC 21))])
2226 (parallel [(set (match_operand:QI 0 "reg_operand" "")
2227 (plus:QI (match_dup 4) (match_dup 6)))
2228 (clobber (reg:CC_NOOV 21))])]
2229 ""
2230 "
2231 operands[2] = gen_reg_rtx (QImode); /* a = val & 0xffff */
2232 operands[3] = gen_reg_rtx (QImode); /* b = val >> 16 */
2233 operands[4] = gen_reg_rtx (QImode); /* a * a */
2234 operands[5] = gen_reg_rtx (QImode); /* a * b */
2235 operands[6] = gen_reg_rtx (QImode); /* (a * b) << 17 */
2236 operands[7] = gen_reg_rtx (QImode); /* val */
2237 ")
2238
2239 ; Inlined integer multiply for C3x
2240 (define_expand "mulqi3_inline"
2241 [(set (match_dup 12) (const_int -16))
2242 (set (match_dup 13) (match_operand:QI 1 "src_operand" ""))
2243 (set (match_dup 14) (match_operand:QI 2 "src_operand" ""))
2244 (parallel [(set (match_dup 4)
2245 (lshiftrt:QI (match_dup 13) (neg:QI (match_dup 12))))
2246 (clobber (reg:CC 21))])
2247 (parallel [(set (match_dup 6)
2248 (lshiftrt:QI (match_dup 14) (neg:QI (match_dup 12))))
2249 (clobber (reg:CC 21))])
2250 (parallel [(set (match_dup 3)
2251 (and:QI (match_dup 13)
2252 (const_int 65535)))
2253 (clobber (reg:CC 21))])
2254 (parallel [(set (match_dup 5)
2255 (and:QI (match_dup 14)
2256 (const_int 65535)))
2257 (clobber (reg:CC 21))])
2258 (parallel [(set (match_dup 7)
2259 (mult:QI (sign_extend:QI (and:QI (match_dup 4)
2260 (const_int 16777215)))
2261 (sign_extend:QI (and:QI (match_dup 5)
2262 (const_int 16777215)))))
2263 (clobber (reg:CC_NOOV 21))])
2264 (parallel [(set (match_dup 8)
2265 (mult:QI (sign_extend:QI (and:QI (match_dup 3)
2266 (const_int 16777215)))
2267 (sign_extend:QI (and:QI (match_dup 5)
2268 (const_int 16777215)))))
2269 (clobber (reg:CC_NOOV 21))])
2270 (parallel [(set (match_dup 9)
2271 (mult:QI (sign_extend:QI (and:QI (match_dup 3)
2272 (const_int 16777215)))
2273 (sign_extend:QI (and:QI (match_dup 6)
2274 (const_int 16777215)))))
2275 (clobber (reg:CC_NOOV 21))])
2276 (parallel [(set (match_dup 10)
2277 (plus:QI (match_dup 7) (match_dup 9)))
2278 (clobber (reg:CC_NOOV 21))])
2279 (parallel [(set (match_dup 11)
2280 (ashift:QI (match_dup 10) (const_int 16)))
2281 (clobber (reg:CC 21))])
2282 (parallel [(set (match_operand:QI 0 "reg_operand" "")
2283 (plus:QI (match_dup 8) (match_dup 11)))
2284 (clobber (reg:CC_NOOV 21))])]
2285 "TARGET_C3X"
2286 "
2287 operands[3] = gen_reg_rtx (QImode); /* a = arg1 & 0xffff */
2288 operands[4] = gen_reg_rtx (QImode); /* b = arg1 >> 16 */
2289 operands[5] = gen_reg_rtx (QImode); /* a = arg2 & 0xffff */
2290 operands[6] = gen_reg_rtx (QImode); /* b = arg2 >> 16 */
2291 operands[7] = gen_reg_rtx (QImode); /* b * c */
2292 operands[8] = gen_reg_rtx (QImode); /* a * c */
2293 operands[9] = gen_reg_rtx (QImode); /* a * d */
2294 operands[10] = gen_reg_rtx (QImode); /* b * c + a * d */
2295 operands[11] = gen_reg_rtx (QImode); /* (b *c + a * d) << 16 */
2296 operands[12] = gen_reg_rtx (QImode); /* -16 */
2297 operands[13] = gen_reg_rtx (QImode); /* arg1 */
2298 operands[14] = gen_reg_rtx (QImode); /* arg2 */
2299 ")
2300
2301 ;
2302 ; MPYSHI (C4x only)
2303 ;
2304 (define_expand "smulqi3_highpart"
2305 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2306 (truncate:QI
2307 (lshiftrt:HI
2308 (mult:HI
2309 (sign_extend:HI (match_operand:QI 1 "src_operand" ""))
2310 (sign_extend:HI (match_operand:QI 2 "src_operand" "")))
2311 (const_int 32))))
2312 (clobber (reg:CC_NOOV 21))])]
2313 ""
2314 "legitimize_operands (MULT, operands, QImode);
2315 if (TARGET_C3X)
2316 {
2317 c4x_emit_libcall_mulhi (smulhi3_libfunc, SIGN_EXTEND, QImode, operands);
2318 DONE;
2319 }
2320 ")
2321
2322 (define_insn "*smulqi3_highpart_clobber"
2323 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2324 (truncate:QI
2325 (lshiftrt:HI
2326 (mult:HI
2327 (sign_extend:HI (match_operand:QI 1 "src_operand" "%0,rR,rS<>,0,rR,rS<>"))
2328 (sign_extend:HI (match_operand:QI 2 "src_operand" "rIm,JR,rS<>,rIm,JR,rS<>")))
2329 (const_int 32))))
2330 (clobber (reg:CC_NOOV 21))]
2331 "! TARGET_C3X && valid_operands (MULT, operands, QImode)"
2332 "@
2333 mpyshi\\t%2,%0
2334 mpyshi3\\t%2,%1,%0
2335 mpyshi3\\t%2,%1,%0
2336 mpyshi\\t%2,%0
2337 mpyshi3\\t%2,%1,%0
2338 mpyshi3\\t%2,%1,%0"
2339 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")
2340 (set_attr "data" "int16,int16,int16,int16,int16,int16")])
2341
2342 (define_insn "*smulqi3_highpart_noclobber"
2343 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,?c")
2344 (truncate:QI
2345 (lshiftrt:HI
2346 (mult:HI
2347 (sign_extend:HI (match_operand:QI 1 "src_operand" "0,rR,rS<>"))
2348 (sign_extend:HI (match_operand:QI 2 "src_operand" "rIm,JR,rS<>")))
2349 (const_int 32))))]
2350 "! TARGET_C3X && valid_operands (MULT, operands, QImode)"
2351 "@
2352 mpyshi\\t%2,%0
2353 mpyshi3\\t%2,%1,%0
2354 mpyshi3\\t%2,%1,%0"
2355 [(set_attr "type" "binary,binary,binary")
2356 (set_attr "data" "int16,int16,int16")])
2357
2358 ;
2359 ; MPYUHI (C4x only)
2360 ;
2361 (define_expand "umulqi3_highpart"
2362 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2363 (truncate:QI
2364 (lshiftrt:HI
2365 (mult:HI
2366 (zero_extend:HI (match_operand:QI 1
2367 "nonimmediate_src_operand" ""))
2368 (zero_extend:HI (match_operand:QI 2
2369 "nonimmediate_lsrc_operand" "")))
2370 (const_int 32))))
2371 (clobber (reg:CC_NOOV 21))])]
2372 ""
2373 "legitimize_operands (MULT, operands, QImode);
2374 if (TARGET_C3X)
2375 {
2376 c4x_emit_libcall_mulhi (umulhi3_libfunc, ZERO_EXTEND, QImode, operands);
2377 DONE;
2378 }
2379 ")
2380
2381 (define_insn "*umulqi3_highpart_clobber"
2382 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2383 (truncate:QI
2384 (lshiftrt:HI
2385 (mult:HI
2386 (zero_extend:HI (match_operand:QI 1
2387 "nonimmediate_src_operand" "%0,rR,rS<>,0,rR,rS<>"))
2388 (zero_extend:HI (match_operand:QI 2
2389 "nonimmediate_lsrc_operand" "rm,R,rS<>,rm,R,rS<>")))
2390 (const_int 32))))
2391 (clobber (reg:CC_NOOV 21))]
2392 "! TARGET_C3X && valid_operands (MULT, operands, QImode)"
2393 "@
2394 mpyuhi\\t%2,%0
2395 mpyuhi3\\t%2,%1,%0
2396 mpyuhi3\\t%2,%1,%0
2397 mpyuhi\\t%2,%0
2398 mpyuhi3\\t%2,%1,%0
2399 mpyuhi3\\t%2,%1,%0"
2400 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")
2401 (set_attr "data" "uint16,uint16,uint16,uint16,uint16,uint16")])
2402
2403 (define_insn "*umulqi3_highpart_noclobber"
2404 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,?c")
2405 (truncate:QI
2406 (lshiftrt:HI
2407 (mult:HI
2408 (zero_extend:HI (match_operand:QI 1
2409 "nonimmediate_src_operand" "0,rR,rS<>"))
2410 (zero_extend:HI (match_operand:QI 2
2411 "nonimmediate_lsrc_operand" "rm,R,rS<>")))
2412 (const_int 32))))]
2413 "! TARGET_C3X && valid_operands (MULT, operands, QImode)"
2414 "@
2415 mpyuhi\\t%2,%0
2416 mpyuhi3\\t%2,%1,%0
2417 mpyuhi3\\t%2,%1,%0"
2418 [(set_attr "type" "binary,binary,binary")
2419 (set_attr "data" "uint16,uint16,uint16")])
2420
2421 ;
2422 ; AND
2423 ;
2424 (define_expand "andqi3"
2425 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2426 (and:QI (match_operand:QI 1 "src_operand" "")
2427 (match_operand:QI 2 "tsrc_operand" "")))
2428 (clobber (reg:CC 21))])]
2429 ""
2430 "legitimize_operands (AND, operands, QImode);")
2431
2432
2433 (define_insn "*andqi3_255_clobber"
2434 [(set (match_operand:QI 0 "reg_operand" "=d,c")
2435 (and:QI (match_operand:QI 1 "src_operand" "mr,mr")
2436 (const_int 255)))
2437 (clobber (reg:CC 21))]
2438 "! TARGET_C3X"
2439 "lbu0\\t%1,%0"
2440 [(set_attr "type" "unarycc,unary")])
2441
2442 (define_insn "*andqi3_255_noclobber"
2443 [(set (match_operand:QI 0 "reg_operand" "=c")
2444 (and:QI (match_operand:QI 1 "src_operand" "mr")
2445 (const_int 255)))]
2446 "! TARGET_C3X"
2447 "lbu0\\t%1,%0"
2448 [(set_attr "type" "unary")])
2449
2450
2451 (define_insn "*andqi3_65535_clobber"
2452 [(set (match_operand:QI 0 "reg_operand" "=d,c")
2453 (and:QI (match_operand:QI 1 "src_operand" "mr,mr")
2454 (const_int 65535)))
2455 (clobber (reg:CC 21))]
2456 "! TARGET_C3X"
2457 "lhu0\\t%1,%0"
2458 [(set_attr "type" "unarycc,unary")])
2459
2460 (define_insn "*andqi3_65535_noclobber"
2461 [(set (match_operand:QI 0 "reg_operand" "=c")
2462 (and:QI (match_operand:QI 1 "src_operand" "mr")
2463 (const_int 65535)))]
2464 "! TARGET_C3X"
2465 "lhu0\\t%1,%0"
2466 [(set_attr "type" "unary")])
2467
2468 (define_insn "*andqi3_clobber"
2469 [(set (match_operand:QI 0 "reg_operand" "=d,d,d,?d,c,c,c,?c")
2470 (and:QI (match_operand:QI 1 "src_operand" "%0,0,rR,rS<>,0,0,rR,rS<>")
2471 (match_operand:QI 2 "tsrc_operand" "N,rLm,JR,rS<>,N,rLm,JR,rS<>")))
2472 (clobber (reg:CC 21))]
2473 "valid_operands (AND, operands, QImode)"
2474 "@
2475 andn\\t%N2,%0
2476 and\\t%2,%0
2477 and3\\t%2,%1,%0
2478 and3\\t%2,%1,%0
2479 andn\\t%N2,%0
2480 and\\t%2,%0
2481 and3\\t%2,%1,%0
2482 and3\\t%2,%1,%0"
2483 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc,binary,binary,binary,binary")
2484 (set_attr "data" "not_uint16,uint16,int16,uint16,not_uint16,uint16,int16,uint16")])
2485
2486 (define_insn "*andqi3_noclobber"
2487 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,c,?c")
2488 (and:QI (match_operand:QI 1 "src_operand" "%0,0,rR,rS<>")
2489 (match_operand:QI 2 "tsrc_operand" "N,rLm,JR,rS<>")))]
2490 "valid_operands (AND, operands, QImode)"
2491 "@
2492 andn\\t%N2,%0
2493 and\\t%2,%0
2494 and3\\t%2,%1,%0
2495 and3\\t%2,%1,%0"
2496 [(set_attr "type" "binary,binary,binary,binary")
2497 (set_attr "data" "not_uint16,uint16,int16,uint16")])
2498
2499 (define_insn "andn_st"
2500 [(set (unspec:QI [(reg:QI 21)] 20)
2501 (and:QI (unspec:QI [(reg:QI 21)] UNSPEC_ANDN_ST)
2502 (match_operand:QI 0 "" "N")))
2503 (use (match_dup 0))
2504 (use (reg:CC 21))
2505 (clobber (reg:CC 21))]
2506 ""
2507 "andn\\t%N0,st"
2508 [(set_attr "type" "misc")
2509 (set_attr "data" "not_uint16")])
2510
2511 (define_split
2512 [(set (match_operand:QI 0 "std_reg_operand" "")
2513 (and:QI (match_operand:QI 1 "src_operand" "")
2514 (match_operand:QI 2 "tsrc_operand" "")))
2515 (clobber (reg:CC 21))]
2516 "reload_completed"
2517 [(set (match_dup 0)
2518 (and:QI (match_dup 1)
2519 (match_dup 2)))]
2520 "")
2521
2522 (define_insn "*andqi3_test"
2523 [(set (reg:CC 21)
2524 (compare:CC (and:QI (match_operand:QI 1 "src_operand" "%0,r,rR,rS<>")
2525 (match_operand:QI 2 "tsrc_operand" "N,rLm,JR,rS<>"))
2526 (const_int 0)))
2527 (clobber (match_scratch:QI 0 "=d,X,X,?X"))]
2528 "valid_operands (AND, operands, QImode)"
2529 "@
2530 andn\\t%N2,%0
2531 tstb\\t%2,%1
2532 tstb3\\t%2,%1
2533 tstb3\\t%2,%1"
2534 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")
2535 (set_attr "data" "not_uint16,uint16,int16,uint16")])
2536
2537 (define_peephole
2538 [(parallel [(set (match_operand:QI 0 "ext_reg_operand" "=d,d,d,?d")
2539 (and:QI (match_operand:QI 1 "src_operand" "%0,0,rR,rS<>")
2540 (match_operand:QI 2 "tsrc_operand" "N,rLm,JR,rS<>")))
2541 (clobber (reg:CC 21))])
2542 (set (reg:CC 21)
2543 (compare:CC (match_dup 0) (const_int 0)))]
2544 "valid_operands (AND, operands, QImode)"
2545 "@
2546 andn\\t%N2,%0
2547 and\\t%2,%0
2548 and3\\t%2,%1,%0
2549 and3\\t%2,%1,%0"
2550 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")
2551 (set_attr "data" "not_uint16,uint16,int16,uint16")])
2552
2553 (define_insn "*andqi3_set"
2554 [(set (reg:CC 21)
2555 (compare:CC (and:QI (match_operand:QI 1 "src_operand" "%0,0,rR,rS<>")
2556 (match_operand:QI 2 "tsrc_operand" "N,rLm,JR,rS<>"))
2557 (const_int 0)))
2558 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d,?d")
2559 (and:QI (match_dup 1)
2560 (match_dup 2)))]
2561 "valid_operands (AND, operands, QImode)"
2562 "@
2563 andn\\t%N2,%0
2564 and\\t%2,%0
2565 and3\\t%2,%1,%0
2566 and3\\t%2,%1,%0"
2567 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")
2568 (set_attr "data" "not_uint16,uint16,int16,uint16")])
2569
2570 ;
2571 ; ANDN
2572 ;
2573 ; NB, this insn doesn't have commutative operands, but valid_operands
2574 ; assumes that the code AND does. We might have to kludge this if
2575 ; we make valid_operands stricter.
2576 (define_insn "*andnqi3_clobber"
2577 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2578 (and:QI (not:QI (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>,rLm,JR,rS<>"))
2579 (match_operand:QI 1 "src_operand" "0,rR,rS<>,0,rR,rS<>")))
2580 (clobber (reg:CC 21))]
2581 "valid_operands (AND, operands, QImode)"
2582 "@
2583 andn\\t%2,%0
2584 andn3\\t%2,%1,%0
2585 andn3\\t%2,%1,%0
2586 andn\\t%2,%0
2587 andn3\\t%2,%1,%0
2588 andn3\\t%2,%1,%0"
2589 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")
2590 (set_attr "data" "uint16,int16,uint16,uint16,int16,uint16")])
2591
2592 (define_insn "*andnqi3_noclobber"
2593 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,?c")
2594 (and:QI (not:QI (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>"))
2595 (match_operand:QI 1 "src_operand" "0,rR,rS<>")))]
2596 "valid_operands (AND, operands, QImode)"
2597 "@
2598 andn\\t%2,%0
2599 andn3\\t%2,%1,%0
2600 andn3\\t%2,%1,%0"
2601 [(set_attr "type" "binary,binary,binary")
2602 (set_attr "data" "uint16,int16,uint16")])
2603
2604 (define_split
2605 [(set (match_operand:QI 0 "std_reg_operand" "")
2606 (and:QI (not:QI (match_operand:QI 2 "lsrc_operand" ""))
2607 (match_operand:QI 1 "src_operand" "")))
2608 (clobber (reg:CC 21))]
2609 "reload_completed"
2610 [(set (match_dup 0)
2611 (and:QI (not:QI (match_dup 2))
2612 (match_dup 1)))]
2613 "")
2614
2615 (define_insn "*andnqi3_test"
2616 [(set (reg:CC 21)
2617 (compare:CC (and:QI (not:QI (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>"))
2618 (match_operand:QI 1 "src_operand" "0,rR,rS<>"))
2619 (const_int 0)))
2620 (clobber (match_scratch:QI 0 "=d,d,d"))]
2621 "valid_operands (AND, operands, QImode)"
2622 "@
2623 andn\\t%2,%0
2624 andn3\\t%2,%1,%0
2625 andn3\\t%2,%1,%0"
2626 [(set_attr "type" "binarycc,binarycc,binarycc")
2627 (set_attr "data" "uint16,int16,uint16")])
2628
2629 (define_insn "*andnqi3_set"
2630 [(set (reg:CC 21)
2631 (compare:CC (and:QI (not:QI (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>"))
2632 (match_operand:QI 1 "src_operand" "0,rR,rS<>"))
2633 (const_int 0)))
2634 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d")
2635 (and:QI (not:QI (match_dup 2))
2636 (match_dup 1)))]
2637 "valid_operands (AND, operands, QImode)"
2638 "@
2639 andn\\t%2,%0
2640 andn3\\t%2,%1,%0
2641 andn3\\t%2,%1,%0"
2642 [(set_attr "type" "binarycc,binarycc,binarycc")
2643 (set_attr "data" "uint16,int16,uint16")])
2644
2645 ;
2646 ; OR
2647 ;
2648 (define_expand "iorqi3"
2649 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2650 (ior:QI (match_operand:QI 1 "src_operand" "")
2651 (match_operand:QI 2 "lsrc_operand" "")))
2652 (clobber (reg:CC 21))])]
2653 ""
2654 "legitimize_operands (IOR, operands, QImode);")
2655
2656 (define_insn "*iorqi3_clobber"
2657 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2658 (ior:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>,0,rR,rS<>")
2659 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>,rLm,JR,rS<>")))
2660 (clobber (reg:CC 21))]
2661 "valid_operands (IOR, operands, QImode)"
2662 "@
2663 or\\t%2,%0
2664 or3\\t%2,%1,%0
2665 or3\\t%2,%1,%0
2666 or\\t%2,%0
2667 or3\\t%2,%1,%0
2668 or3\\t%2,%1,%0"
2669 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")
2670 (set_attr "data" "uint16,int16,uint16,uint16,int16,uint16")])
2671
2672 (define_split
2673 [(set (match_operand:QI 0 "std_reg_operand" "")
2674 (ior:QI (match_operand:QI 1 "src_operand" "")
2675 (match_operand:QI 2 "lsrc_operand" "")))
2676 (clobber (reg:CC 21))]
2677 "reload_completed"
2678 [(set (match_dup 0)
2679 (ior:QI (match_dup 1)
2680 (match_dup 2)))]
2681 "")
2682
2683 (define_insn "*iorqi3_test"
2684 [(set (reg:CC 21)
2685 (compare:CC (ior:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2686 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>"))
2687 (const_int 0)))
2688 (clobber (match_scratch:QI 0 "=d,d,d"))]
2689 "valid_operands (IOR, operands, QImode)"
2690 "@
2691 or\\t%2,%0
2692 or3\\t%2,%1,%0
2693 or3\\t%2,%1,%0"
2694 [(set_attr "type" "binarycc,binarycc,binarycc")
2695 (set_attr "data" "uint16,int16,uint16")])
2696
2697 (define_peephole
2698 [(parallel [(set (match_operand:QI 0 "ext_reg_operand" "=d,d,d")
2699 (ior:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2700 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>")))
2701 (clobber (reg:CC 21))])
2702 (set (reg:CC 21)
2703 (compare:CC (match_dup 0) (const_int 0)))]
2704 "valid_operands (IOR, operands, QImode)"
2705 "@
2706 or\\t%2,%0
2707 or3\\t%2,%1,%0
2708 or3\\t%2,%1,%0"
2709 [(set_attr "type" "binarycc,binarycc,binarycc")
2710 (set_attr "data" "uint16,int16,uint16")])
2711
2712 (define_insn "*iorqi3_set"
2713 [(set (reg:CC 21)
2714 (compare:CC (ior:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2715 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>"))
2716 (const_int 0)))
2717 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d")
2718 (ior:QI (match_dup 1)
2719 (match_dup 2)))]
2720 "valid_operands (IOR, operands, QImode)"
2721 "@
2722 or\\t%2,%0
2723 or3\\t%2,%1,%0
2724 or3\\t%2,%1,%0"
2725 [(set_attr "type" "binarycc,binarycc,binarycc")
2726 (set_attr "data" "uint16,int16,uint16")])
2727
2728 ; This pattern is used for loading symbol references in several parts.
2729 (define_insn "iorqi3_noclobber"
2730 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,c")
2731 (ior:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2732 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>")))]
2733 "valid_operands (IOR, operands, QImode)"
2734 "@
2735 or\\t%2,%0
2736 or3\\t%2,%1,%0
2737 or3\\t%2,%1,%0"
2738 [(set_attr "type" "binary,binary,binary")
2739 (set_attr "data" "uint16,int16,uint16")])
2740
2741 ;
2742 ; XOR
2743 ;
2744 (define_expand "xorqi3"
2745 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2746 (xor:QI (match_operand:QI 1 "src_operand" "")
2747 (match_operand:QI 2 "lsrc_operand" "")))
2748 (clobber (reg:CC 21))])]
2749 ""
2750 "legitimize_operands (XOR, operands, QImode);")
2751
2752 (define_insn "*xorqi3_clobber"
2753 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2754 (xor:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>,0,rR,rS<>")
2755 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>,rLm,JR,rS<>")))
2756 (clobber (reg:CC 21))]
2757 "valid_operands (XOR, operands, QImode)"
2758 "@
2759 xor\\t%2,%0
2760 xor3\\t%2,%1,%0
2761 xor3\\t%2,%1,%0
2762 xor\\t%2,%0
2763 xor3\\t%2,%1,%0
2764 xor3\\t%2,%1,%0"
2765 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")
2766 (set_attr "data" "uint16,int16,uint16,uint16,int16,uint16")])
2767
2768 (define_insn "*xorqi3_noclobber"
2769 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,?c")
2770 (xor:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2771 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>")))]
2772 "valid_operands (XOR, operands, QImode)"
2773 "@
2774 xor\\t%2,%0
2775 xor3\\t%2,%1,%0
2776 xor3\\t%2,%1,%0"
2777 [(set_attr "type" "binary,binary,binary")
2778 (set_attr "data" "uint16,int16,uint16")])
2779
2780 (define_split
2781 [(set (match_operand:QI 0 "std_reg_operand" "")
2782 (xor:QI (match_operand:QI 1 "src_operand" "")
2783 (match_operand:QI 2 "lsrc_operand" "")))
2784 (clobber (reg:CC 21))]
2785 "reload_completed"
2786 [(set (match_dup 0)
2787 (xor:QI (match_dup 1)
2788 (match_dup 2)))]
2789 "")
2790
2791 (define_insn "*xorqi3_test"
2792 [(set (reg:CC 21)
2793 (compare:CC (xor:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2794 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>"))
2795 (const_int 0)))
2796 (clobber (match_scratch:QI 0 "=d,d,d"))]
2797 "valid_operands (XOR, operands, QImode)"
2798 "@
2799 xor\\t%2,%0
2800 xor3\\t%2,%1,%0
2801 xor3\\t%2,%1,%0"
2802 [(set_attr "type" "binarycc,binarycc,binarycc")
2803 (set_attr "data" "uint16,int16,uint16")])
2804
2805 (define_insn "*xorqi3_set"
2806 [(set (reg:CC 21)
2807 (compare:CC (xor:QI (match_operand:QI 1 "src_operand" "%0,rR,rS<>")
2808 (match_operand:QI 2 "lsrc_operand" "rLm,JR,rS<>"))
2809 (const_int 0)))
2810 (set (match_operand:QI 0 "ext_reg_operand" "=d,d,d")
2811 (xor:QI (match_dup 1)
2812 (match_dup 2)))]
2813 "valid_operands (XOR, operands, QImode)"
2814 "@
2815 xor\\t%2,%0
2816 xor3\\t%2,%1,%0
2817 xor3\\t%2,%1,%0"
2818 [(set_attr "type" "binarycc,binarycc,binarycc")
2819 (set_attr "data" "uint16,int16,uint16")])
2820
2821 ;
2822 ; LSH/ASH (left)
2823 ;
2824 ; The C3x and C4x have two shift instructions ASH and LSH
2825 ; If the shift count is positive, a left shift is performed
2826 ; otherwise a right shift is performed. The number of bits
2827 ; shifted is determined by the seven LSBs of the shift count.
2828 ; If the absolute value of the count is 32 or greater, the result
2829 ; using the LSH instruction is zero; with the ASH insn the result
2830 ; is zero or negative 1. Note that the ISO C standard allows
2831 ; the result to be machine dependent whenever the shift count
2832 ; exceeds the size of the object.
2833 (define_expand "ashlqi3"
2834 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2835 (ashift:QI (match_operand:QI 1 "src_operand" "")
2836 (match_operand:QI 2 "src_operand" "")))
2837 (clobber (reg:CC 21))])]
2838 ""
2839 "legitimize_operands (ASHIFT, operands, QImode);")
2840
2841 (define_insn "*ashlqi3_clobber"
2842 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2843 (ashift:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>,0,rR,rS<>")
2844 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>,rIm,JR,rS<>")))
2845 (clobber (reg:CC 21))]
2846 "valid_operands (ASHIFT, operands, QImode)"
2847 "@
2848 ash\\t%2,%0
2849 ash3\\t%2,%1,%0
2850 ash3\\t%2,%1,%0
2851 ash\\t%2,%0
2852 ash3\\t%2,%1,%0
2853 ash3\\t%2,%1,%0"
2854 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
2855 ; Default to int16 data attr.
2856
2857 (define_insn "*ashlqi3_set"
2858 [(set (reg:CC 21)
2859 (compare:CC
2860 (ashift:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>")
2861 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>"))
2862 (const_int 0)))
2863 (set (match_operand:QI 0 "reg_operand" "=d,d,d")
2864 (ashift:QI (match_dup 1)
2865 (match_dup 2)))]
2866 "valid_operands (ASHIFT, operands, QImode)"
2867 "@
2868 ash\\t%2,%0
2869 ash3\\t%2,%1,%0
2870 ash3\\t%2,%1,%0"
2871 [(set_attr "type" "binarycc,binarycc,binarycc")])
2872 ; Default to int16 data attr.
2873
2874 (define_insn "ashlqi3_noclobber"
2875 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,?c")
2876 (ashift:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>")
2877 (match_operand:QI 2 "src_operand" "rIm,JR,rS<>")))]
2878 "valid_operands (ASHIFT, operands, QImode)"
2879 "@
2880 ash\\t%2,%0
2881 ash3\\t%2,%1,%0
2882 ash3\\t%2,%1,%0"
2883 [(set_attr "type" "binary,binary,binary")])
2884 ; Default to int16 data attr.
2885
2886 (define_split
2887 [(set (match_operand:QI 0 "std_reg_operand" "")
2888 (ashift:QI (match_operand:QI 1 "src_operand" "")
2889 (match_operand:QI 2 "src_operand" "")))
2890 (clobber (reg:CC 21))]
2891 "reload_completed"
2892 [(set (match_dup 0)
2893 (ashift:QI (match_dup 1)
2894 (match_dup 2)))]
2895 "")
2896
2897 ; This is only used by lshrhi3_reg where we need a LSH insn that will
2898 ; shift both ways.
2899 (define_insn "*lshlqi3_clobber"
2900 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
2901 (ashift:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>,0,rR,rS<>")
2902 (unspec:QI [(match_operand:QI 2 "src_operand" "rIm,JR,rS<>,rIm,JR,rS<>")] UNSPEC_LSH)))
2903 (clobber (reg:CC 21))]
2904 "valid_operands (ASHIFT, operands, QImode)"
2905 "@
2906 lsh\\t%2,%0
2907 lsh3\\t%2,%1,%0
2908 lsh3\\t%2,%1,%0
2909 lsh\\t%2,%0
2910 lsh3\\t%2,%1,%0
2911 lsh3\\t%2,%1,%0"
2912 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
2913 ; Default to int16 data attr.
2914
2915 ;
2916 ; LSH (right)
2917 ;
2918 ; Logical right shift on the C[34]x works by negating the shift count,
2919 ; then emitting a right shift with the shift count negated. This means
2920 ; that all actual shift counts in the RTL will be positive.
2921 ;
2922 (define_expand "lshrqi3"
2923 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
2924 (lshiftrt:QI (match_operand:QI 1 "src_operand" "")
2925 (match_operand:QI 2 "src_operand" "")))
2926 (clobber (reg:CC 21))])]
2927 ""
2928 "legitimize_operands (LSHIFTRT, operands, QImode);")
2929
2930
2931 (define_insn "*lshrqi3_24_clobber"
2932 [(set (match_operand:QI 0 "reg_operand" "=d,c")
2933 (lshiftrt:QI (match_operand:QI 1 "src_operand" "mr,mr")
2934 (const_int 24)))
2935 (clobber (reg:CC 21))]
2936 "! TARGET_C3X"
2937 "lbu3\\t%1,%0"
2938 [(set_attr "type" "unarycc")])
2939
2940
2941 (define_insn "*ashrqi3_24_clobber"
2942 [(set (match_operand:QI 0 "reg_operand" "=d,c")
2943 (ashiftrt:QI (match_operand:QI 1 "src_operand" "mr,mr")
2944 (const_int 24)))
2945 (clobber (reg:CC 21))]
2946 "! TARGET_C3X"
2947 "lb3\\t%1,%0"
2948 [(set_attr "type" "unarycc")])
2949
2950
2951 (define_insn "lshrqi3_16_clobber"
2952 [(set (match_operand:QI 0 "reg_operand" "=d,c")
2953 (lshiftrt:QI (match_operand:QI 1 "src_operand" "mr,mr")
2954 (const_int 16)))
2955 (clobber (reg:CC 21))]
2956 "! TARGET_C3X"
2957 "lhu1\\t%1,%0"
2958 [(set_attr "type" "unarycc")])
2959
2960
2961 (define_insn "*ashrqi3_16_clobber"
2962 [(set (match_operand:QI 0 "reg_operand" "=d,c")
2963 (ashiftrt:QI (match_operand:QI 1 "src_operand" "mr,mr")
2964 (const_int 16)))
2965 (clobber (reg:CC 21))]
2966 "! TARGET_C3X"
2967 "lh1\\t%1,%0"
2968 [(set_attr "type" "unarycc")])
2969
2970
2971 ; When the shift count is greater than the size of the word
2972 ; the result can be implementation specific
2973 (define_insn "*lshrqi3_const_clobber"
2974 [(set (match_operand:QI 0 "reg_operand" "=d,c,?d,?c")
2975 (lshiftrt:QI (match_operand:QI 1 "src_operand" "0,0,r,r")
2976 (match_operand:QI 2 "const_int_operand" "n,n,J,J")))
2977 (clobber (reg:CC 21))]
2978 "valid_operands (LSHIFTRT, operands, QImode)"
2979 "@
2980 lsh\\t%n2,%0
2981 lsh\\t%n2,%0
2982 lsh3\\t%n2,%1,%0
2983 lsh3\\t%n2,%1,%0"
2984 [(set_attr "type" "binarycc,binary,binarycc,binary")])
2985
2986 (define_insn "*lshrqi3_const_noclobber"
2987 [(set (match_operand:QI 0 "std_reg_operand" "=c,?c")
2988 (lshiftrt:QI (match_operand:QI 1 "src_operand" "0,r")
2989 (match_operand:QI 2 "const_int_operand" "n,J")))]
2990 "valid_operands (LSHIFTRT, operands, QImode)"
2991 "@
2992 lsh\\t%n2,%0
2993 lsh3\\t%n2,%1,%0"
2994 [(set_attr "type" "binary,binary")])
2995
2996 ; When the shift count is greater than the size of the word
2997 ; the result can be implementation specific
2998 (define_insn "*lshrqi3_const_set"
2999 [(set (reg:CC 21)
3000 (compare:CC
3001 (lshiftrt:QI (match_operand:QI 1 "src_operand" "0,r")
3002 (match_operand:QI 2 "const_int_operand" "n,J"))
3003 (const_int 0)))
3004 (set (match_operand:QI 0 "reg_operand" "=?d,d")
3005 (lshiftrt:QI (match_dup 1)
3006 (match_dup 2)))]
3007 "valid_operands (LSHIFTRT, operands, QImode)"
3008 "@
3009 lsh\\t%n2,%0
3010 lsh3\\t%n2,%1,%0"
3011 [(set_attr "type" "binarycc,binarycc")])
3012
3013 (define_insn "*lshrqi3_nonconst_clobber"
3014 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
3015 (lshiftrt:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>,0,rR,rS<>")
3016 (neg:QI (match_operand:QI 2 "src_operand" "rm,R,rS<>,rm,R,rS<>"))))
3017 (clobber (reg:CC 21))]
3018 "valid_operands (LSHIFTRT, operands, QImode)"
3019 "@
3020 lsh\\t%2,%0
3021 lsh3\\t%2,%1,%0
3022 lsh3\\t%2,%1,%0
3023 lsh\\t%2,%0
3024 lsh3\\t%2,%1,%0
3025 lsh3\\t%2,%1,%0"
3026 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
3027 ; Default to int16 data attr.
3028
3029 (define_insn "*lshrqi3_nonconst_noclobber"
3030 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,?c")
3031 (lshiftrt:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>")
3032 (neg:QI (match_operand:QI 2 "src_operand" "rm,R,rS<>"))))]
3033 "valid_operands (LSHIFTRT, operands, QImode)"
3034 "@
3035 lsh\\t%2,%0
3036 lsh3\\t%2,%1,%0
3037 lsh3\\t%2,%1,%0"
3038 [(set_attr "type" "binary,binary,binary")])
3039 ; Default to int16 data attr.
3040
3041 ;
3042 ; ASH (right)
3043 ;
3044 ; Arithmetic right shift on the C[34]x works by negating the shift count,
3045 ; then emitting a right shift with the shift count negated. This means
3046 ; that all actual shift counts in the RTL will be positive.
3047
3048 (define_expand "ashrqi3"
3049 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
3050 (ashiftrt:QI (match_operand:QI 1 "src_operand" "")
3051 (match_operand:QI 2 "src_operand" "")))
3052 (clobber (reg:CC 21))])]
3053 ""
3054 "legitimize_operands (ASHIFTRT, operands, QImode);")
3055
3056 ; When the shift count is greater than the size of the word
3057 ; the result can be implementation specific
3058 (define_insn "*ashrqi3_const_clobber"
3059 [(set (match_operand:QI 0 "reg_operand" "=d,c,?d,?c")
3060 (ashiftrt:QI (match_operand:QI 1 "src_operand" "0,0,r,r")
3061 (match_operand:QI 2 "const_int_operand" "n,n,J,J")))
3062 (clobber (reg:CC 21))]
3063 "valid_operands (ASHIFTRT, operands, QImode)"
3064 "@
3065 ash\\t%n2,%0
3066 ash\\t%n2,%0
3067 ash3\\t%n2,%1,%0
3068 ash3\\t%n2,%1,%0"
3069 [(set_attr "type" "binarycc,binary,binarycc,binary")])
3070
3071 (define_insn "*ashrqi3_const_noclobber"
3072 [(set (match_operand:QI 0 "std_reg_operand" "=c,?c")
3073 (ashiftrt:QI (match_operand:QI 1 "src_operand" "0,r")
3074 (match_operand:QI 2 "const_int_operand" "n,J")))]
3075 "valid_operands (ASHIFTRT, operands, QImode)"
3076 "@
3077 ash\\t%n2,%0
3078 ash3\\t%n2,%1,%0"
3079 [(set_attr "type" "binarycc,binarycc")])
3080
3081 ; When the shift count is greater than the size of the word
3082 ; the result can be implementation specific
3083 (define_insn "*ashrqi3_const_set"
3084 [(set (reg:CC 21)
3085 (compare:CC
3086 (ashiftrt:QI (match_operand:QI 1 "src_operand" "0,r")
3087 (match_operand:QI 2 "const_int_operand" "n,J"))
3088 (const_int 0)))
3089 (set (match_operand:QI 0 "reg_operand" "=?d,d")
3090 (ashiftrt:QI (match_dup 1)
3091 (match_dup 2)))]
3092 "valid_operands (ASHIFTRT, operands, QImode)"
3093 "@
3094 ash\\t%n2,%0
3095 ash3\\t%n2,%1,%0"
3096 [(set_attr "type" "binarycc,binarycc")])
3097
3098 (define_insn "*ashrqi3_nonconst_clobber"
3099 [(set (match_operand:QI 0 "reg_operand" "=d,d,?d,c,c,?c")
3100 (ashiftrt:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>,0,rR,rS<>")
3101 (neg:QI (match_operand:QI 2 "src_operand" "rm,R,rS<>,rm,R,rS<>"))))
3102 (clobber (reg:CC 21))]
3103 "valid_operands (ASHIFTRT, operands, QImode)"
3104 "@
3105 ash\\t%2,%0
3106 ash3\\t%2,%1,%0
3107 ash3\\t%2,%1,%0
3108 ash\\t%2,%0
3109 ash3\\t%2,%1,%0
3110 ash3\\t%2,%1,%0"
3111 [(set_attr "type" "binarycc,binarycc,binarycc,binary,binary,binary")])
3112 ; Default to int16 data attr.
3113
3114 (define_insn "*ashrqi3_nonconst_noclobber"
3115 [(set (match_operand:QI 0 "std_reg_operand" "=c,c,?c")
3116 (ashiftrt:QI (match_operand:QI 1 "src_operand" "0,rR,rS<>")
3117 (neg:QI (match_operand:QI 2 "src_operand" "rm,R,rS<>"))))]
3118 "valid_operands (ASHIFTRT, operands, QImode)"
3119 "@
3120 ash\\t%2,%0
3121 ash3\\t%2,%1,%0
3122 ash3\\t%2,%1,%0"
3123 [(set_attr "type" "binary,binary,binary")])
3124 ; Default to int16 data attr.
3125
3126 ;
3127 ; CMPI
3128 ;
3129 ; Unfortunately the C40 doesn't allow cmpi3 7, *ar0++ so the next best
3130 ; thing would be to get the small constant loaded into a register (say r0)
3131 ; so that it could be hoisted out of the loop so that we only
3132 ; would need to do cmpi3 *ar0++, r0. Now the loop optimization pass
3133 ; comes before the flow pass (which finds autoincrements) so we're stuck.
3134 ; Ideally, GCC requires another loop optimization pass (preferably after
3135 ; reload) so that it can hoist invariants out of loops.
3136 ; The current solution modifies legitimize_operands () so that small
3137 ; constants are forced into a pseudo register.
3138 ;
3139 (define_expand "cmpqi"
3140 [(set (reg:CC 21)
3141 (compare:CC (match_operand:QI 0 "src_operand" "")
3142 (match_operand:QI 1 "src_operand" "")))]
3143 ""
3144 "legitimize_operands (COMPARE, operands, QImode);
3145 c4x_compare_op0 = operands[0];
3146 c4x_compare_op1 = operands[1];
3147 DONE;")
3148
3149 (define_insn "*cmpqi_test"
3150 [(set (reg:CC 21)
3151 (compare:CC (match_operand:QI 0 "src_operand" "r,rR,rS<>")
3152 (match_operand:QI 1 "src_operand" "rIm,JR,rS<>")))]
3153 "valid_operands (COMPARE, operands, QImode)"
3154 "@
3155 cmpi\\t%1,%0
3156 cmpi3\\t%1,%0
3157 cmpi3\\t%1,%0"
3158 [(set_attr "type" "compare,compare,compare")])
3159
3160 (define_insn "*cmpqi_test_noov"
3161 [(set (reg:CC_NOOV 21)
3162 (compare:CC_NOOV (match_operand:QI 0 "src_operand" "r,rR,rS<>")
3163 (match_operand:QI 1 "src_operand" "rIm,JR,rS<>")))]
3164 "valid_operands (COMPARE, operands, QImode)"
3165 "@
3166 cmpi\\t%1,%0
3167 cmpi3\\t%1,%0
3168 cmpi3\\t%1,%0"
3169 [(set_attr "type" "compare,compare,compare")])
3170
3171
3172 ;
3173 ; BIT-FIELD INSTRUCTIONS
3174 ;
3175
3176 ;
3177 ; LBx/LHw (C4x only)
3178 ;
3179 (define_expand "extv"
3180 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
3181 (sign_extract:QI (match_operand:QI 1 "src_operand" "")
3182 (match_operand:QI 2 "const_int_operand" "")
3183 (match_operand:QI 3 "const_int_operand" "")))
3184 (clobber (reg:CC 21))])]
3185 "! TARGET_C3X"
3186 "if ((INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16)
3187 || (INTVAL (operands[3]) % INTVAL (operands[2]) != 0))
3188 FAIL;
3189 ")
3190
3191 (define_insn "*extv_clobber"
3192 [(set (match_operand:QI 0 "reg_operand" "=d,c")
3193 (sign_extract:QI (match_operand:QI 1 "src_operand" "rLm,rLm")
3194 (match_operand:QI 2 "const_int_operand" "n,n")
3195 (match_operand:QI 3 "const_int_operand" "n,n")))
3196 (clobber (reg:CC 21))]
3197 "! TARGET_C3X
3198 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
3199 && (INTVAL (operands[3]) % INTVAL (operands[2]) == 0)"
3200 "*
3201 if (INTVAL (operands[2]) == 8)
3202 {
3203 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
3204 return \"lb%3\\t%1,%0\";
3205 }
3206 operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
3207 return \"lh%3\\t%1,%0\";
3208 "
3209 [(set_attr "type" "binarycc,binary")
3210 (set_attr "data" "int16,int16")])
3211
3212 (define_insn "*extv_clobber_test"
3213 [(set (reg:CC 21)
3214 (compare:CC (sign_extract:QI (match_operand:QI 1 "src_operand" "rLm")
3215 (match_operand:QI 2 "const_int_operand" "n")
3216 (match_operand:QI 3 "const_int_operand" "n"))
3217 (const_int 0)))
3218 (clobber (match_scratch:QI 0 "=d"))]
3219 "! TARGET_C3X
3220 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
3221 && (INTVAL (operands[3]) % INTVAL (operands[2]) == 0)"
3222 "*
3223 if (INTVAL (operands[2]) == 8)
3224 {
3225 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
3226 return \"lb%3\\t%1,%0\";
3227 }
3228 operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
3229 return \"lh%3\\t%1,%0\";
3230 "
3231 [(set_attr "type" "binarycc")
3232 (set_attr "data" "int16")])
3233
3234 (define_insn "*extv_clobber_set"
3235 [(set (reg:CC 21)
3236 (compare:CC (sign_extract:QI (match_operand:QI 1 "src_operand" "rLm")
3237 (match_operand:QI 2 "const_int_operand" "n")
3238 (match_operand:QI 3 "const_int_operand" "n"))
3239 (const_int 0)))
3240 (set (match_operand:QI 0 "reg_operand" "=d")
3241 (sign_extract:QI (match_dup 1)
3242 (match_dup 2)
3243 (match_dup 3)))]
3244 "! TARGET_C3X
3245 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
3246 && (INTVAL (operands[3]) % INTVAL (operands[2]) == 0)"
3247 "*
3248 if (INTVAL (operands[2]) == 8)
3249 {
3250 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
3251 return \"lb%3\\t%1,%0\";
3252 }
3253 operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
3254 return \"lh%3\\t%1,%0\";
3255 "
3256 [(set_attr "type" "binarycc")
3257 (set_attr "data" "int16")])
3258
3259 ;
3260 ; LBUx/LHUw (C4x only)
3261 ;
3262 (define_expand "extzv"
3263 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
3264 (zero_extract:QI (match_operand:QI 1 "src_operand" "")
3265 (match_operand:QI 2 "const_int_operand" "")
3266 (match_operand:QI 3 "const_int_operand" "")))
3267 (clobber (reg:CC 21))])]
3268 "! TARGET_C3X"
3269 "if ((INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16)
3270 || (INTVAL (operands[3]) % INTVAL (operands[2]) != 0))
3271 FAIL;
3272 ")
3273
3274 (define_insn "*extzv_clobber"
3275 [(set (match_operand:QI 0 "reg_operand" "=d,c")
3276 (zero_extract:QI (match_operand:QI 1 "src_operand" "rLm,rLm")
3277 (match_operand:QI 2 "const_int_operand" "n,n")
3278 (match_operand:QI 3 "const_int_operand" "n,n")))
3279 (clobber (reg:CC 21))]
3280 "! TARGET_C3X
3281 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
3282 && (INTVAL (operands[3]) % INTVAL (operands[2]) == 0)"
3283 "*
3284 if (INTVAL (operands[2]) == 8)
3285 {
3286 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
3287 return \"lbu%3\\t%1,%0\";
3288 }
3289 operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
3290 return \"lhu%3\\t%1,%0\";
3291 "
3292 [(set_attr "type" "binarycc,binary")
3293 (set_attr "data" "uint16,uint16")])
3294
3295 (define_insn "*extzv_test"
3296 [(set (reg:CC 21)
3297 (compare:CC (zero_extract:QI (match_operand:QI 1 "src_operand" "rLm")
3298 (match_operand:QI 2 "const_int_operand" "n")
3299 (match_operand:QI 3 "const_int_operand" "n"))
3300 (const_int 0)))
3301 (clobber (match_scratch:QI 0 "=d"))]
3302 "! TARGET_C3X
3303 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
3304 && (INTVAL (operands[3]) % INTVAL (operands[2]) == 0)"
3305 "*
3306 if (INTVAL (operands[2]) == 8)
3307 {
3308 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
3309 return \"lbu%3\\t%1,%0\";
3310 }
3311 operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
3312 return \"lhu%3\\t%1,%0\";
3313 "
3314 [(set_attr "type" "binarycc")
3315 (set_attr "data" "uint16")])
3316
3317 (define_insn "*extzv_set"
3318 [(set (reg:CC 21)
3319 (compare:CC (zero_extract:QI (match_operand:QI 1 "src_operand" "rLm")
3320 (match_operand:QI 2 "const_int_operand" "n")
3321 (match_operand:QI 3 "const_int_operand" "n"))
3322 (const_int 0)))
3323 (set (match_operand:QI 0 "ext_reg_operand" "=d")
3324 (zero_extract:QI (match_dup 1)
3325 (match_dup 2)
3326 (match_dup 3)))]
3327 "! TARGET_C3X
3328 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
3329 && (INTVAL (operands[3]) % INTVAL (operands[2]) == 0)"
3330 "*
3331 if (INTVAL (operands[2]) == 8)
3332 {
3333 /* 8 bit extract. */
3334 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
3335 return \"lbu%3\\t%1,%0\";
3336 }
3337 /* 16 bit extract. */
3338 operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
3339 return \"lhu%3\\t%1,%0\";
3340 "
3341 [(set_attr "type" "binarycc")
3342 (set_attr "data" "uint16")])
3343
3344 ;
3345 ; MBx/MHw (C4x only)
3346 ;
3347 (define_expand "insv"
3348 [(parallel [(set (zero_extract:QI (match_operand:QI 0 "reg_operand" "")
3349 (match_operand:QI 1 "const_int_operand" "")
3350 (match_operand:QI 2 "const_int_operand" ""))
3351 (match_operand:QI 3 "src_operand" ""))
3352 (clobber (reg:CC 21))])]
3353 "! TARGET_C3X"
3354 "if (! (((INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
3355 && (INTVAL (operands[2]) % INTVAL (operands[1]) == 0))
3356 || (INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)))
3357 FAIL;
3358 ")
3359
3360 (define_insn "*insv_clobber"
3361 [(set (zero_extract:QI (match_operand:QI 0 "reg_operand" "+d,c")
3362 (match_operand:QI 1 "const_int_operand" "n,n")
3363 (match_operand:QI 2 "const_int_operand" "n,n"))
3364 (match_operand:QI 3 "src_operand" "rLm,rLm"))
3365 (clobber (reg:CC 21))]
3366 "! TARGET_C3X
3367 && (((INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
3368 && (INTVAL (operands[2]) % INTVAL (operands[1]) == 0))
3369 || (INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8))"
3370 "*
3371 if (INTVAL (operands[1]) == 8)
3372 {
3373 /* 8 bit insert. */
3374 operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
3375 return \"mb%2\\t%3,%0\";
3376 }
3377 else if (INTVAL (operands[1]) == 16)
3378 {
3379 /* 16 bit insert. */
3380 operands[2] = GEN_INT (INTVAL (operands[2]) / 16);
3381 return \"mh%2\\t%3,%0\";
3382 }
3383 /* 24 bit insert. */
3384 return \"lwl1\\t%3,%0\";
3385 "
3386 [(set_attr "type" "binarycc,binary")
3387 (set_attr "data" "uint16,uint16")])
3388
3389 (define_peephole
3390 [(parallel [(set (zero_extract:QI (match_operand:QI 0 "ext_reg_operand" "+d")
3391 (match_operand:QI 1 "const_int_operand" "n")
3392 (match_operand:QI 2 "const_int_operand" "n"))
3393 (match_operand:QI 3 "src_operand" "rLm"))
3394 (clobber (reg:CC 21))])
3395 (set (reg:CC 21)
3396 (compare:CC (match_dup 0) (const_int 0)))]
3397 "! TARGET_C3X
3398 && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
3399 && (INTVAL (operands[2]) % INTVAL (operands[1]) == 0)"
3400 "*
3401 if (INTVAL (operands[1]) == 8)
3402 {
3403 operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
3404 return \"mb%2\\t%3,%0\";
3405 }
3406 operands[2] = GEN_INT (INTVAL (operands[2]) / 16);
3407 return \"mh%2\\t%3,%0\";
3408 "
3409 [(set_attr "type" "binarycc")
3410 (set_attr "data" "uint16")])
3411
3412
3413 ; TWO OPERAND FLOAT INSTRUCTIONS
3414 ;
3415
3416 ;
3417 ; LDF/STF
3418 ;
3419 ; If one of the operands is not a register, then we should
3420 ; emit two insns, using a scratch register. This will produce
3421 ; better code in loops if the source operand is invariant, since
3422 ; the source reload can be optimized out. During reload we cannot
3423 ; use change_address or force_reg.
3424 (define_expand "movqf"
3425 [(set (match_operand:QF 0 "src_operand" "")
3426 (match_operand:QF 1 "src_operand" ""))]
3427 ""
3428 "
3429 {
3430 if (c4x_emit_move_sequence (operands, QFmode))
3431 DONE;
3432 }")
3433
3434 ; This can generate invalid stack slot displacements
3435 (define_split
3436 [(set (match_operand:QI 0 "reg_operand" "")
3437 (unspec:QI [(match_operand:QF 1 "reg_operand" "")] UNSPEC_STOREQF_INT))]
3438 "reload_completed"
3439 [(set (match_dup 3) (match_dup 1))
3440 (set (match_dup 0) (match_dup 2))]
3441 "operands[2] = assign_stack_temp (QImode, GET_MODE_SIZE (QImode), 0);
3442 operands[3] = copy_rtx (operands[2]);
3443 PUT_MODE (operands[3], QFmode);")
3444
3445
3446 (define_insn "storeqf_int"
3447 [(set (match_operand:QI 0 "reg_operand" "=r")
3448 (unspec:QI [(match_operand:QF 1 "reg_operand" "f")] UNSPEC_STOREQF_INT))]
3449 ""
3450 "#"
3451 [(set_attr "type" "multi")])
3452
3453 (define_split
3454 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
3455 (unspec:QI [(match_operand:QF 1 "reg_operand" "")] UNSPEC_STOREQF_INT))
3456 (clobber (reg:CC 21))])]
3457 "reload_completed"
3458 [(set (mem:QF (pre_inc:QI (reg:QI 20)))
3459 (match_dup 1))
3460 (parallel [(set (match_dup 0)
3461 (mem:QI (post_dec:QI (reg:QI 20))))
3462 (clobber (reg:CC 21))])]
3463 "")
3464
3465
3466 ; We need accurate death notes for this...
3467 ;(define_peephole
3468 ; [(set (match_operand:QF 0 "reg_operand" "=f")
3469 ; (match_operand:QF 1 "memory_operand" "m"))
3470 ; (set (mem:QF (pre_inc:QI (reg:QI 20)))
3471 ; (match_dup 0))
3472 ; (parallel [(set (match_operand:QI 2 "reg_operand" "r")
3473 ; (mem:QI (post_dec:QI (reg:QI 20))))
3474 ; (clobber (reg:CC 21))])]
3475 ; ""
3476 ; "ldiu\\t%1,%0")
3477
3478 (define_insn "storeqf_int_clobber"
3479 [(parallel [(set (match_operand:QI 0 "reg_operand" "=r")
3480 (unspec:QI [(match_operand:QF 1 "reg_operand" "f")] UNSPEC_STOREQF_INT))
3481 (clobber (reg:CC 21))])]
3482 ""
3483 "#"
3484 [(set_attr "type" "multi")])
3485
3486
3487 ; This can generate invalid stack slot displacements
3488 (define_split
3489 [(set (match_operand:QF 0 "reg_operand" "")
3490 (unspec:QF [(match_operand:QI 1 "reg_operand" "")] UNSPEC_LOADQF_INT))]
3491 "reload_completed"
3492 [(set (match_dup 2) (match_dup 1))
3493 (set (match_dup 0) (match_dup 3))]
3494 "operands[2] = assign_stack_temp (QImode, GET_MODE_SIZE (QImode), 0);
3495 operands[3] = copy_rtx (operands[2]);
3496 PUT_MODE (operands[3], QFmode);")
3497
3498
3499 (define_insn "loadqf_int"
3500 [(set (match_operand:QF 0 "reg_operand" "=f")
3501 (unspec:QF [(match_operand:QI 1 "reg_operand" "r")] UNSPEC_LOADQF_INT))]
3502 ""
3503 "#"
3504 [(set_attr "type" "multi")])
3505
3506 (define_split
3507 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
3508 (unspec:QF [(match_operand:QI 1 "reg_operand" "")] UNSPEC_LOADQF_INT))
3509 (clobber (reg:CC 21))])]
3510 "reload_completed"
3511 [(set (mem:QI (pre_inc:QI (reg:QI 20)))
3512 (match_dup 1))
3513 (parallel [(set (match_dup 0)
3514 (mem:QF (post_dec:QI (reg:QI 20))))
3515 (clobber (reg:CC 21))])]
3516 "")
3517
3518 (define_insn "loadqf_int_clobber"
3519 [(parallel [(set (match_operand:QF 0 "reg_operand" "=f")
3520 (unspec:QF [(match_operand:QI 1 "reg_operand" "r")] UNSPEC_LOADQF_INT))
3521 (clobber (reg:CC 21))])]
3522 ""
3523 "#"
3524 [(set_attr "type" "multi")])
3525
3526 ; We must provide an alternative to store to memory in case we have to
3527 ; spill a register.
3528 (define_insn "movqf_noclobber"
3529 [(set (match_operand:QF 0 "dst_operand" "=f,m")
3530 (match_operand:QF 1 "src_operand" "fHm,f"))]
3531 "REG_P (operands[0]) || REG_P (operands[1])"
3532 "@
3533 ldfu\\t%1,%0
3534 stf\\t%1,%0"
3535 [(set_attr "type" "unary,store")])
3536
3537 ;(define_insn "*movqf_clobber"
3538 ; [(set (match_operand:QF 0 "reg_operand" "=f")
3539 ; (match_operand:QF 1 "src_operand" "fHm"))
3540 ; (clobber (reg:CC 21))]
3541 ; "0"
3542 ; "ldf\\t%1,%0"
3543 ; [(set_attr "type" "unarycc")])
3544
3545 (define_insn "*movqf_test"
3546 [(set (reg:CC 21)
3547 (compare:CC (match_operand:QF 1 "src_operand" "fHm")
3548 (const_int 0)))
3549 (clobber (match_scratch:QF 0 "=f"))]
3550 ""
3551 "ldf\\t%1,%0"
3552 [(set_attr "type" "unarycc")])
3553
3554 (define_insn "*movqf_set"
3555 [(set (reg:CC 21)
3556 (compare:CC (match_operand:QF 1 "src_operand" "fHm")
3557 (match_operand:QF 2 "fp_zero_operand" "G")))
3558 (set (match_operand:QF 0 "reg_operand" "=f")
3559 (match_dup 1))]
3560 ""
3561 "ldf\\t%1,%0"
3562 [(set_attr "type" "unarycc")])
3563
3564
3565 (define_insn "*movqf_parallel"
3566 [(set (match_operand:QF 0 "parallel_operand" "=q,S<>!V,q,S<>!V")
3567 (match_operand:QF 1 "parallel_operand" "S<>!V,q,S<>!V,q"))
3568 (set (match_operand:QF 2 "parallel_operand" "=q,S<>!V,S<>!V,q")
3569 (match_operand:QF 3 "parallel_operand" "S<>!V,q,q,S<>!V"))]
3570 "TARGET_PARALLEL && valid_parallel_load_store (operands, QFmode)"
3571 "@
3572 ldf1\\t%1,%0\\n||\\tldf2\\t%3,%2
3573 stf1\\t%1,%0\\n||\\tstf2\\t%3,%2
3574 ldf\\t%1,%0\\n||\\tstf\\t%3,%2
3575 ldf\\t%3,%2\\n||\\tstf\\t%1,%0"
3576 [(set_attr "type" "load_load,store_store,load_store,store_load")])
3577
3578
3579 ;
3580 ; PUSH/POP
3581 ;
3582 (define_insn "pushqf"
3583 [(set (mem:QF (pre_inc:QI (reg:QI 20)))
3584 (match_operand:QF 0 "reg_operand" "f"))]
3585 ""
3586 "pushf\\t%0"
3587 [(set_attr "type" "push")])
3588
3589 (define_insn "popqf"
3590 [(set (match_operand:QF 0 "reg_operand" "=f")
3591 (mem:QF (post_dec:QI (reg:QI 20))))
3592 (clobber (reg:CC 21))]
3593 ""
3594 "popf\\t%0"
3595 [(set_attr "type" "pop")])
3596
3597 (define_insn "popqf_unspec"
3598 [(set (unspec:QF [(match_operand:QF 0 "reg_operand" "=f")] UNSPEC_POPQF)
3599 (mem:QF (post_dec:QI (reg:QI 20))))
3600 (clobber (match_dup 0))
3601 (clobber (reg:CC 21))]
3602 ""
3603 "popf\\t%0"
3604 [(set_attr "type" "pop")])
3605
3606 ;
3607 ; ABSF
3608 ;
3609 (define_expand "absqf2"
3610 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
3611 (abs:QF (match_operand:QF 1 "src_operand" "")))
3612 (clobber (reg:CC_NOOV 21))])]
3613 ""
3614 "")
3615
3616 (define_insn "*absqf2_clobber"
3617 [(set (match_operand:QF 0 "reg_operand" "=f")
3618 (abs:QF (match_operand:QF 1 "src_operand" "fHm")))
3619 (clobber (reg:CC_NOOV 21))]
3620 ""
3621 "absf\\t%1,%0"
3622 [(set_attr "type" "unarycc")])
3623
3624 (define_insn "*absqf2_test"
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 (clobber (match_scratch:QF 0 "=f"))]
3629 ""
3630 "absf\\t%1,%0"
3631 [(set_attr "type" "unarycc")])
3632
3633 (define_insn "*absqf2_set"
3634 [(set (reg:CC_NOOV 21)
3635 (compare:CC_NOOV (abs:QF (match_operand:QF 1 "src_operand" "fHm"))
3636 (match_operand:QF 2 "fp_zero_operand" "G")))
3637 (set (match_operand:QF 0 "reg_operand" "=f")
3638 (abs:QF (match_dup 1)))]
3639
3640 ""
3641 "absf\\t%1,%0"
3642 [(set_attr "type" "unarycc")])
3643
3644 ;
3645 ; NEGF
3646 ;
3647 (define_expand "negqf2"
3648 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
3649 (neg:QF (match_operand:QF 1 "src_operand" "")))
3650 (clobber (reg:CC_NOOV 21))])]
3651 ""
3652 "")
3653
3654 (define_insn "*negqf2_clobber"
3655 [(set (match_operand:QF 0 "reg_operand" "=f")
3656 (neg:QF (match_operand:QF 1 "src_operand" "fHm")))
3657 (clobber (reg:CC_NOOV 21))]
3658 ""
3659 "negf\\t%1,%0"
3660 [(set_attr "type" "unarycc")])
3661
3662 (define_insn "*negqf2_test"
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 (clobber (match_scratch:QF 0 "=f"))]
3667 ""
3668 "negf\\t%1,%0"
3669 [(set_attr "type" "unarycc")])
3670
3671 (define_insn "*negqf2_set"
3672 [(set (reg:CC_NOOV 21)
3673 (compare:CC_NOOV (neg:QF (match_operand:QF 1 "src_operand" "fHm"))
3674 (match_operand:QF 2 "fp_zero_operand" "G")))
3675 (set (match_operand:QF 0 "reg_operand" "=f")
3676 (neg:QF (match_dup 1)))]
3677 ""
3678 "negf\\t%1,%0"
3679 [(set_attr "type" "unarycc")])
3680
3681 ;
3682 ; FLOAT
3683 ;
3684 (define_insn "floatqiqf2"
3685 [(set (match_operand:QF 0 "reg_operand" "=f")
3686 (float:QF (match_operand:QI 1 "src_operand" "rIm")))
3687 (clobber (reg:CC 21))]
3688 ""
3689 "float\\t%1,%0"
3690 [(set_attr "type" "unarycc")])
3691
3692 (define_insn "*floatqiqf2_set"
3693 [(set (reg:CC 21)
3694 (compare:CC (float:QF (match_operand:QI 1 "src_operand" "rIm"))
3695 (match_operand:QF 2 "fp_zero_operand" "G")))
3696 (set (match_operand:QF 0 "reg_operand" "=f")
3697 (float:QF (match_dup 1)))]
3698 ""
3699 "float\\t%1,%0"
3700 [(set_attr "type" "unarycc")])
3701
3702 ; Unsigned conversions are a little tricky because we need to
3703 ; add the value for the high bit if necessary.
3704 ;
3705 ;
3706 (define_expand "floatunsqiqf2"
3707 [(set (match_dup 2) (match_dup 3))
3708 (parallel [(set (reg:CC 21)
3709 (compare:CC (float:QF (match_operand:QI 1 "src_operand" ""))
3710 (match_dup 3)))
3711 (set (match_dup 4)
3712 (float:QF (match_dup 1)))])
3713 (set (match_dup 2)
3714 (if_then_else:QF (lt (reg:CC 21) (const_int 0))
3715 (match_dup 5)
3716 (match_dup 2)))
3717 (parallel [(set (match_operand:QF 0 "reg_operand" "")
3718 (plus:QF (match_dup 2) (match_dup 4)))
3719 (clobber (reg:CC_NOOV 21))])]
3720 ""
3721 "operands[2] = gen_reg_rtx (QFmode);
3722 operands[3] = CONST0_RTX (QFmode);
3723 operands[4] = gen_reg_rtx (QFmode);
3724 operands[5] = gen_reg_rtx (QFmode);
3725 emit_move_insn (operands[5], CONST_DOUBLE_ATOF (\"4294967296.0\", QFmode));")
3726
3727 (define_expand "floatunsqihf2"
3728 [(set (match_dup 2) (match_dup 3))
3729 (parallel [(set (reg:CC 21)
3730 (compare:CC (float:HF (match_operand:QI 1 "src_operand" ""))
3731 (match_dup 3)))
3732 (set (match_dup 4)
3733 (float:HF (match_dup 1)))])
3734 (set (match_dup 2)
3735 (if_then_else:HF (lt (reg:CC 21) (const_int 0))
3736 (match_dup 5)
3737 (match_dup 2)))
3738 (parallel [(set (match_operand:HF 0 "reg_operand" "")
3739 (plus:HF (match_dup 2) (match_dup 4)))
3740 (clobber (reg:CC_NOOV 21))])]
3741 ""
3742 "operands[2] = gen_reg_rtx (HFmode);
3743 operands[3] = CONST0_RTX (HFmode);
3744 operands[4] = gen_reg_rtx (HFmode);
3745 operands[5] = gen_reg_rtx (HFmode);
3746 emit_move_insn (operands[5], CONST_DOUBLE_ATOF (\"4294967296.0\", HFmode));")
3747
3748 (define_insn "floatqihf2"
3749 [(set (match_operand:HF 0 "reg_operand" "=h")
3750 (float:HF (match_operand:QI 1 "src_operand" "rIm")))
3751 (clobber (reg:CC 21))]
3752 ""
3753 "float\\t%1,%0"
3754 [(set_attr "type" "unarycc")])
3755
3756 (define_insn "*floatqihf2_set"
3757 [(set (reg:CC 21)
3758 (compare:CC (float:HF (match_operand:QI 1 "src_operand" "rIm"))
3759 (match_operand:QF 2 "fp_zero_operand" "G")))
3760 (set (match_operand:HF 0 "reg_operand" "=h")
3761 (float:HF (match_dup 1)))]
3762 ""
3763 "float\\t%1,%0"
3764 [(set_attr "type" "unarycc")])
3765
3766 ;
3767 ; FIX
3768 ;
3769 (define_insn "fixqfqi_clobber"
3770 [(set (match_operand:QI 0 "reg_operand" "=d,c")
3771 (fix:QI (match_operand:QF 1 "src_operand" "fHm,fHm")))
3772 (clobber (reg:CC 21))]
3773 ""
3774 "fix\\t%1,%0"
3775 [(set_attr "type" "unarycc")])
3776
3777 (define_insn "*fixqfqi_set"
3778 [(set (reg:CC 21)
3779 (compare:CC (fix:QI (match_operand:QF 1 "src_operand" "fHm"))
3780 (const_int 0)))
3781 (set (match_operand:QI 0 "ext_reg_operand" "=d")
3782 (fix:QI (match_dup 1)))]
3783 ""
3784 "fix\\t%1,%0"
3785 [(set_attr "type" "unarycc")])
3786
3787 ;
3788 ; The C[34]x fix instruction implements a floor, not a straight trunc,
3789 ; so we have to invert the number, fix it, and reinvert it if negative
3790 ;
3791 (define_expand "fix_truncqfqi2"
3792 [(parallel [(set (match_dup 2)
3793 (fix:QI (match_operand:QF 1 "src_operand" "")))
3794 (clobber (reg:CC 21))])
3795 (parallel [(set (match_dup 3) (neg:QF (match_dup 1)))
3796 (clobber (reg:CC_NOOV 21))])
3797 (parallel [(set (match_dup 4) (fix:QI (match_dup 3)))
3798 (clobber (reg:CC 21))])
3799 (parallel [(set (reg:CC_NOOV 21)
3800 (compare:CC_NOOV (neg:QI (match_dup 4)) (const_int 0)))
3801 (set (match_dup 5) (neg:QI (match_dup 4)))])
3802 (set (match_dup 2)
3803 (if_then_else:QI (le (reg:CC 21) (const_int 0))
3804 (match_dup 5)
3805 (match_dup 2)))
3806 (set (match_operand:QI 0 "reg_operand" "=r") (match_dup 2))]
3807 ""
3808 "if (TARGET_FAST_FIX)
3809 {
3810 emit_insn (gen_fixqfqi_clobber (operands[0], operands[1]));
3811 DONE;
3812 }
3813 operands[2] = gen_reg_rtx (QImode);
3814 operands[3] = gen_reg_rtx (QFmode);
3815 operands[4] = gen_reg_rtx (QImode);
3816 operands[5] = gen_reg_rtx (QImode);
3817 ")
3818
3819 (define_expand "fix_truncqfhi2"
3820 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
3821 (fix:HI (match_operand:QF 1 "src_operand" "")))
3822 (clobber (reg:CC 21))])]
3823 ""
3824 "c4x_emit_libcall (fix_truncqfhi2_libfunc, FIX, HImode, QFmode, 2, operands);
3825 DONE;")
3826
3827 (define_expand "fixuns_truncqfqi2"
3828 [(parallel [(set (match_dup 2)
3829 (fix:QI (match_operand:QF 1 "src_operand" "fHm")))
3830 (clobber (reg:CC 21))])
3831 (parallel [(set (match_dup 3)
3832 (minus:QF (match_dup 1) (match_dup 5)))
3833 (clobber (reg:CC_NOOV 21))])
3834 (parallel [(set (reg:CC 21)
3835 (compare:CC (fix:QI (match_dup 3))
3836 (const_int 0)))
3837 (set (match_dup 4)
3838 (fix:QI (match_dup 3)))])
3839 (parallel [(set (match_dup 4) (unspec:QI [(match_dup 2)] UNSPEC_LDIV))
3840 (use (reg:CC 21))])
3841 (set (match_operand:QI 0 "reg_operand" "=r") (match_dup 4))]
3842 ""
3843 "operands[2] = gen_reg_rtx (QImode);
3844 operands[3] = gen_reg_rtx (QFmode);
3845 operands[4] = gen_reg_rtx (QImode);
3846 operands[5] = gen_reg_rtx (QFmode);
3847 emit_move_insn (operands[5], CONST_DOUBLE_ATOF (\"4294967296.0\", QFmode));")
3848
3849 (define_expand "fixuns_truncqfhi2"
3850 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
3851 (unsigned_fix:HI (match_operand:QF 1 "src_operand" "")))
3852 (clobber (reg:CC 21))])]
3853 ""
3854 "c4x_emit_libcall (fixuns_truncqfhi2_libfunc, UNSIGNED_FIX,
3855 HImode, QFmode, 2, operands);
3856 DONE;")
3857
3858 ;
3859 ; RCPF
3860 ;
3861 (define_insn "rcpfqf_clobber"
3862 [(set (match_operand:QF 0 "reg_operand" "=f")
3863 (unspec:QF [(match_operand:QF 1 "src_operand" "fHm")] UNSPEC_RCPF))
3864 (clobber (reg:CC_NOOV 21))]
3865 "! TARGET_C3X"
3866 "rcpf\\t%1,%0"
3867 [(set_attr "type" "unarycc")])
3868
3869 ;
3870 ; RSQRF
3871 ;
3872 (define_insn "*rsqrfqf_clobber"
3873 [(set (match_operand:QF 0 "reg_operand" "=f")
3874 (unspec:QF [(match_operand:QF 1 "src_operand" "fHm")] UNSPEC_RSQRF))
3875 (clobber (reg:CC_NOOV 21))]
3876 "! TARGET_C3X"
3877 "rsqrf\\t%1,%0"
3878 [(set_attr "type" "unarycc")])
3879
3880 ;
3881 ; RNDF
3882 ;
3883 (define_insn "*rndqf_clobber"
3884 [(set (match_operand:QF 0 "reg_operand" "=f")
3885 (unspec:QF [(match_operand:QF 1 "src_operand" "fHm")] UNSPEC_RND))
3886 (clobber (reg:CC_NOOV 21))]
3887 "! TARGET_C3X"
3888 "rnd\\t%1,%0"
3889 [(set_attr "type" "unarycc")])
3890
3891
3892 ; Inlined float square root for C4x
3893 (define_expand "sqrtqf2_inline"
3894 [(parallel [(set (match_dup 2)
3895 (unspec:QF [(match_operand:QF 1 "src_operand" "")] UNSPEC_RSQRF))
3896 (clobber (reg:CC_NOOV 21))])
3897 (parallel [(set (match_dup 3) (mult:QF (match_dup 5) (match_dup 1)))
3898 (clobber (reg:CC_NOOV 21))])
3899 (parallel [(set (match_dup 4) (mult:QF (match_dup 2) (match_dup 3)))
3900 (clobber (reg:CC_NOOV 21))])
3901 (parallel [(set (match_dup 4) (mult:QF (match_dup 2) (match_dup 4)))
3902 (clobber (reg:CC_NOOV 21))])
3903 (parallel [(set (match_dup 4) (minus:QF (match_dup 6) (match_dup 4)))
3904 (clobber (reg:CC_NOOV 21))])
3905 (parallel [(set (match_dup 2) (mult:QF (match_dup 2) (match_dup 4)))
3906 (clobber (reg:CC_NOOV 21))])
3907 (parallel [(set (match_dup 4) (mult:QF (match_dup 2) (match_dup 3)))
3908 (clobber (reg:CC_NOOV 21))])
3909 (parallel [(set (match_dup 4) (mult:QF (match_dup 2) (match_dup 4)))
3910 (clobber (reg:CC_NOOV 21))])
3911 (parallel [(set (match_dup 4) (minus:QF (match_dup 6) (match_dup 4)))
3912 (clobber (reg:CC_NOOV 21))])
3913 (parallel [(set (match_dup 2) (mult:QF (match_dup 2) (match_dup 4)))
3914 (clobber (reg:CC_NOOV 21))])
3915 (parallel [(set (match_dup 4) (mult:QF (match_dup 2) (match_dup 1)))
3916 (clobber (reg:CC_NOOV 21))])
3917 (parallel [(set (match_operand:QF 0 "reg_operand" "")
3918 (unspec:QF [(match_dup 4)] UNSPEC_RND))
3919 (clobber (reg:CC_NOOV 21))])]
3920 "! TARGET_C3X"
3921 "if (! reload_in_progress
3922 && ! reg_operand (operands[1], QFmode))
3923 operands[1] = force_reg (QFmode, operands[1]);
3924 operands[2] = gen_reg_rtx (QFmode);
3925 operands[3] = gen_reg_rtx (QFmode);
3926 operands[4] = gen_reg_rtx (QFmode);
3927 operands[5] = CONST_DOUBLE_ATOF (\"0.5\", QFmode);
3928 operands[6] = CONST_DOUBLE_ATOF (\"1.5\", QFmode);")
3929
3930 (define_expand "sqrtqf2"
3931 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
3932 (sqrt:QF (match_operand:QF 1 "src_operand" "")))
3933 (clobber (reg:CC 21))])]
3934 "! TARGET_C3X && TARGET_INLINE"
3935 "emit_insn (gen_sqrtqf2_inline (operands[0], operands[1]));
3936 DONE;")
3937
3938 ;
3939 ; TOIEEE / FRIEEE
3940 ;
3941 (define_insn "toieee"
3942 [(set (match_operand:QF 0 "reg_operand" "=f")
3943 (unspec:QF [(match_operand:QF 1 "src_operand" "fHm")] UNSPEC_TOIEEE))
3944 (clobber (reg:CC 21))]
3945 ""
3946 "toieee\\t%1,%0")
3947
3948 (define_insn "frieee"
3949 [(set (match_operand:QF 0 "reg_operand" "=f")
3950 (unspec:QF [(match_operand:QF 1 "memory_operand" "m")] UNSPEC_FRIEEE))
3951 (clobber (reg:CC 21))]
3952 ""
3953 "frieee\\t%1,%0")
3954
3955 ;
3956 ; THREE OPERAND FLOAT INSTRUCTIONS
3957 ;
3958
3959 ;
3960 ; ADDF
3961 ;
3962 (define_expand "addqf3"
3963 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
3964 (plus:QF (match_operand:QF 1 "src_operand" "")
3965 (match_operand:QF 2 "src_operand" "")))
3966 (clobber (reg:CC_NOOV 21))])]
3967 ""
3968 "legitimize_operands (PLUS, operands, QFmode);")
3969
3970 (define_insn "*addqf3_clobber"
3971 [(set (match_operand:QF 0 "reg_operand" "=f,f,?f")
3972 (plus:QF (match_operand:QF 1 "src_operand" "%0,fR,fS<>")
3973 (match_operand:QF 2 "src_operand" "fHm,R,fS<>")))
3974 (clobber (reg:CC_NOOV 21))]
3975 "valid_operands (PLUS, operands, QFmode)"
3976 "@
3977 addf\\t%2,%0
3978 addf3\\t%2,%1,%0
3979 addf3\\t%2,%1,%0"
3980 [(set_attr "type" "binarycc,binarycc,binarycc")])
3981
3982 (define_insn "*addqf3_test"
3983 [(set (reg:CC_NOOV 21)
3984 (compare:CC_NOOV (plus:QF (match_operand:QF 1 "src_operand" "%0,fR,fS<>")
3985 (match_operand:QF 2 "src_operand" "fHm,R,fS<>"))
3986 (match_operand:QF 3 "fp_zero_operand" "G,G,G")))
3987 (clobber (match_scratch:QF 0 "=f,f,?f"))]
3988 "valid_operands (PLUS, operands, QFmode)"
3989 "@
3990 addf\\t%2,%0
3991 addf3\\t%2,%1,%0
3992 addf3\\t%2,%1,%0"
3993 [(set_attr "type" "binarycc,binarycc,binarycc")])
3994
3995 (define_insn "*addqf3_set"
3996 [(set (reg:CC_NOOV 21)
3997 (compare:CC_NOOV (plus:QF (match_operand:QF 1 "src_operand" "%0,fR,fS<>")
3998 (match_operand:QF 2 "src_operand" "fHm,R,fS<>"))
3999 (match_operand:QF 3 "fp_zero_operand" "G,G,G")))
4000 (set (match_operand:QF 0 "reg_operand" "=f,f,?f")
4001 (plus:QF (match_dup 1)
4002 (match_dup 2)))]
4003 "valid_operands (PLUS, operands, QFmode)"
4004 "@
4005 addf\\t%2,%0
4006 addf3\\t%2,%1,%0
4007 addf3\\t%2,%1,%0"
4008 [(set_attr "type" "binarycc,binarycc,binarycc")])
4009
4010 ;
4011 ; SUBF/SUBRF
4012 ;
4013 (define_expand "subqf3"
4014 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
4015 (minus:QF (match_operand:QF 1 "src_operand" "")
4016 (match_operand:QF 2 "src_operand" "")))
4017 (clobber (reg:CC_NOOV 21))])]
4018 ""
4019 "legitimize_operands (MINUS, operands, QFmode);")
4020
4021 (define_insn "*subqf3_clobber"
4022 [(set (match_operand:QF 0 "reg_operand" "=f,f,f,?f")
4023 (minus:QF (match_operand:QF 1 "src_operand" "0,fHm,fR,fS<>")
4024 (match_operand:QF 2 "src_operand" "fHm,0,R,fS<>")))
4025 (clobber (reg:CC_NOOV 21))]
4026 "valid_operands (MINUS, operands, QFmode)"
4027 "@
4028 subf\\t%2,%0
4029 subrf\\t%1,%0
4030 subf3\\t%2,%1,%0
4031 subf3\\t%2,%1,%0"
4032 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
4033
4034 (define_insn "*subqf3_test"
4035 [(set (reg:CC_NOOV 21)
4036 (compare:CC_NOOV (minus:QF (match_operand:QF 1 "src_operand" "0,fHm,fR,fS<>")
4037 (match_operand:QF 2 "src_operand" "fHm,0,R,fS<>"))
4038 (match_operand:QF 3 "fp_zero_operand" "G,G,G,G")))
4039 (clobber (match_scratch:QF 0 "=f,f,f,?f"))]
4040 "valid_operands (MINUS, operands, QFmode)"
4041 "@
4042 subf\\t%2,%0
4043 subrf\\t%1,%0
4044 subf3\\t%2,%1,%0
4045 subf3\\t%2,%1,%0"
4046 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
4047
4048 (define_insn "*subqf3_set"
4049 [(set (reg:CC_NOOV 21)
4050 (compare:CC_NOOV (minus:QF (match_operand:QF 1 "src_operand" "0,fHm,fR,fS<>")
4051 (match_operand:QF 2 "src_operand" "fHm,0,R,fS<>"))
4052 (match_operand:QF 3 "fp_zero_operand" "G,G,G,G")))
4053 (set (match_operand:QF 0 "reg_operand" "=f,f,f,?f")
4054 (minus:QF (match_dup 1)
4055 (match_dup 2)))]
4056 "valid_operands (MINUS, operands, QFmode)"
4057 "@
4058 subf\\t%2,%0
4059 subrf\\t%1,%0
4060 subf3\\t%2,%1,%0
4061 subf3\\t%2,%1,%0"
4062 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
4063
4064 ;
4065 ; MPYF
4066 ;
4067 (define_expand "mulqf3"
4068 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
4069 (mult:QF (match_operand:QF 1 "src_operand" "")
4070 (match_operand:QF 2 "src_operand" "")))
4071 (clobber (reg:CC_NOOV 21))])]
4072 ""
4073 "legitimize_operands (MULT, operands, QFmode);")
4074
4075 (define_insn "*mulqf3_clobber"
4076 [(set (match_operand:QF 0 "reg_operand" "=f,f,?f")
4077 (mult:QF (match_operand:QF 1 "src_operand" "%0,fR,fS<>")
4078 (match_operand:QF 2 "src_operand" "fHm,R,fS<>")))
4079 (clobber (reg:CC_NOOV 21))]
4080 "valid_operands (MULT, operands, QFmode)"
4081 "@
4082 mpyf\\t%2,%0
4083 mpyf3\\t%2,%1,%0
4084 mpyf3\\t%2,%1,%0"
4085 [(set_attr "type" "binarycc,binarycc,binarycc")])
4086
4087 (define_insn "*mulqf3_test"
4088 [(set (reg:CC_NOOV 21)
4089 (compare:CC_NOOV (mult:QF (match_operand:QF 1 "src_operand" "%0,fR,fS<>")
4090 (match_operand:QF 2 "src_operand" "fHm,R,fS<>"))
4091 (match_operand:QF 3 "fp_zero_operand" "G,G,G")))
4092 (clobber (match_scratch:QF 0 "=f,f,?f"))]
4093 "valid_operands (MULT, operands, QFmode)"
4094 "@
4095 mpyf\\t%2,%0
4096 mpyf3\\t%2,%1,%0
4097 mpyf3\\t%2,%1,%0"
4098 [(set_attr "type" "binarycc,binarycc,binarycc")])
4099
4100 (define_insn "*mulqf3_set"
4101 [(set (reg:CC_NOOV 21)
4102 (compare:CC_NOOV (mult:QF (match_operand:QF 1 "src_operand" "%0,fR,fS<>")
4103 (match_operand:QF 2 "src_operand" "fHm,R,fS<>"))
4104 (match_operand:QF 3 "fp_zero_operand" "G,G,G")))
4105 (set (match_operand:QF 0 "reg_operand" "=f,f,?f")
4106 (mult:QF (match_dup 1)
4107 (match_dup 2)))]
4108 "valid_operands (MULT, operands, QFmode)"
4109 "@
4110 mpyf\\t%2,%0
4111 mpyf3\\t%2,%1,%0
4112 mpyf3\\t%2,%1,%0"
4113 [(set_attr "type" "binarycc,binarycc,binarycc")])
4114
4115 ;
4116 ; CMPF
4117 ;
4118 (define_expand "cmpqf"
4119 [(set (reg:CC 21)
4120 (compare:CC (match_operand:QF 0 "src_operand" "")
4121 (match_operand:QF 1 "src_operand" "")))]
4122 ""
4123 "legitimize_operands (COMPARE, operands, QFmode);
4124 c4x_compare_op0 = operands[0];
4125 c4x_compare_op1 = operands[1];
4126 DONE;")
4127
4128 (define_insn "*cmpqf"
4129 [(set (reg:CC 21)
4130 (compare:CC (match_operand:QF 0 "src_operand" "f,fR,fS<>")
4131 (match_operand:QF 1 "src_operand" "fHm,R,fS<>")))]
4132 "valid_operands (COMPARE, operands, QFmode)"
4133 "@
4134 cmpf\\t%1,%0
4135 cmpf3\\t%1,%0
4136 cmpf3\\t%1,%0"
4137 [(set_attr "type" "compare,compare,compare")])
4138
4139 (define_insn "*cmpqf_noov"
4140 [(set (reg:CC_NOOV 21)
4141 (compare:CC_NOOV (match_operand:QF 0 "src_operand" "f,fR,fS<>")
4142 (match_operand:QF 1 "src_operand" "fHm,R,fS<>")))]
4143 "valid_operands (COMPARE, operands, QFmode)"
4144 "@
4145 cmpf\\t%1,%0
4146 cmpf3\\t%1,%0
4147 cmpf3\\t%1,%0"
4148 [(set_attr "type" "compare,compare,compare")])
4149
4150 ; Inlined float divide for C4x
4151 (define_expand "divqf3_inline"
4152 [(parallel [(set (match_dup 3)
4153 (unspec:QF [(match_operand:QF 2 "src_operand" "")] UNSPEC_RCPF))
4154 (clobber (reg:CC_NOOV 21))])
4155 (parallel [(set (match_dup 4) (mult:QF (match_dup 2) (match_dup 3)))
4156 (clobber (reg:CC_NOOV 21))])
4157 (parallel [(set (match_dup 4) (minus:QF (match_dup 5) (match_dup 4)))
4158 (clobber (reg:CC_NOOV 21))])
4159 (parallel [(set (match_dup 3) (mult:QF (match_dup 3) (match_dup 4)))
4160 (clobber (reg:CC_NOOV 21))])
4161 (parallel [(set (match_dup 4) (mult:QF (match_dup 2) (match_dup 3)))
4162 (clobber (reg:CC_NOOV 21))])
4163 (parallel [(set (match_dup 4) (minus:QF (match_dup 5) (match_dup 4)))
4164 (clobber (reg:CC_NOOV 21))])
4165 (parallel [(set (match_dup 3) (mult:QF (match_dup 3) (match_dup 4)))
4166 (clobber (reg:CC_NOOV 21))])
4167 (parallel [(set (match_dup 3)
4168 (mult:QF (match_operand:QF 1 "src_operand" "")
4169 (match_dup 3)))
4170 (clobber (reg:CC_NOOV 21))])
4171 (parallel [(set (match_operand:QF 0 "reg_operand" "")
4172 (unspec:QF [(match_dup 3)] UNSPEC_RND))
4173 (clobber (reg:CC_NOOV 21))])]
4174 "! TARGET_C3X"
4175 "if (! reload_in_progress
4176 && ! reg_operand (operands[2], QFmode))
4177 operands[2] = force_reg (QFmode, operands[2]);
4178 operands[3] = gen_reg_rtx (QFmode);
4179 operands[4] = gen_reg_rtx (QFmode);
4180 operands[5] = CONST2_RTX (QFmode);")
4181
4182 (define_expand "divqf3"
4183 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
4184 (div:QF (match_operand:QF 1 "src_operand" "")
4185 (match_operand:QF 2 "src_operand" "")))
4186 (clobber (reg:CC 21))])]
4187 "! TARGET_C3X && TARGET_INLINE"
4188 "emit_insn (gen_divqf3_inline (operands[0], operands[1], operands[2]));
4189 DONE;")
4190
4191 ;
4192 ; CONDITIONAL MOVES
4193 ;
4194
4195 ; ??? We should make these pattern fail if the src operand combination
4196 ; is not valid. Although reload will fix things up, it will introduce
4197 ; extra load instructions that won't be hoisted out of a loop.
4198
4199 (define_insn "*ldi_conditional"
4200 [(set (match_operand:QI 0 "reg_operand" "=r,r")
4201 (if_then_else:QI (match_operator 1 "comparison_operator"
4202 [(reg:CC 21) (const_int 0)])
4203 (match_operand:QI 2 "src_operand" "rIm,0")
4204 (match_operand:QI 3 "src_operand" "0,rIm")))]
4205 "valid_operands (IF_THEN_ELSE, operands, QImode)"
4206 "@
4207 ldi%1\\t%2,%0
4208 ldi%I1\\t%3,%0"
4209 [(set_attr "type" "binary")])
4210
4211 (define_insn "*ldi_conditional_noov"
4212 [(set (match_operand:QI 0 "reg_operand" "=r,r")
4213 (if_then_else:QI (match_operator 1 "comparison_operator"
4214 [(reg:CC_NOOV 21) (const_int 0)])
4215 (match_operand:QI 2 "src_operand" "rIm,0")
4216 (match_operand:QI 3 "src_operand" "0,rIm")))]
4217 "GET_CODE (operands[1]) != LE
4218 && GET_CODE (operands[1]) != GE
4219 && GET_CODE (operands[1]) != LT
4220 && GET_CODE (operands[1]) != GT
4221 && valid_operands (IF_THEN_ELSE, operands, QImode)"
4222 "@
4223 ldi%1\\t%2,%0
4224 ldi%I1\\t%3,%0"
4225 [(set_attr "type" "binary")])
4226
4227 (define_insn "*ldi_on_overflow"
4228 [(set (match_operand:QI 0 "reg_operand" "=r")
4229 (unspec:QI [(match_operand:QI 1 "src_operand" "rIm")] UNSPEC_LDIV))
4230 (use (reg:CC 21))]
4231 ""
4232 "ldiv\\t%1,%0"
4233 [(set_attr "type" "unary")])
4234
4235 ; Move operand 2 to operand 0 if condition (operand 1) is true
4236 ; else move operand 3 to operand 0.
4237 ; The temporary register is required below because some of the operands
4238 ; might be identical (namely 0 and 2).
4239 ;
4240 (define_expand "movqicc"
4241 [(set (match_operand:QI 0 "reg_operand" "")
4242 (if_then_else:QI (match_operand 1 "comparison_operator" "")
4243 (match_operand:QI 2 "src_operand" "")
4244 (match_operand:QI 3 "src_operand" "")))]
4245 ""
4246 "{
4247 enum rtx_code code = GET_CODE (operands[1]);
4248 rtx ccreg = c4x_gen_compare_reg (code, c4x_compare_op0, c4x_compare_op1);
4249 if (ccreg == NULL_RTX) FAIL;
4250 emit_insn (gen_rtx_SET (QImode, operands[0],
4251 gen_rtx_IF_THEN_ELSE (QImode,
4252 gen_rtx (code, VOIDmode, ccreg, const0_rtx),
4253 operands[2], operands[3])));
4254 DONE;}")
4255
4256 (define_insn "*ldf_conditional"
4257 [(set (match_operand:QF 0 "reg_operand" "=f,f")
4258 (if_then_else:QF (match_operator 1 "comparison_operator"
4259 [(reg:CC 21) (const_int 0)])
4260 (match_operand:QF 2 "src_operand" "fHm,0")
4261 (match_operand:QF 3 "src_operand" "0,fHm")))]
4262 "valid_operands (IF_THEN_ELSE, operands, QFmode)"
4263 "@
4264 ldf%1\\t%2,%0
4265 ldf%I1\\t%3,%0"
4266 [(set_attr "type" "binary")])
4267
4268 (define_insn "*ldf_conditional_noov"
4269 [(set (match_operand:QF 0 "reg_operand" "=f,f")
4270 (if_then_else:QF (match_operator 1 "comparison_operator"
4271 [(reg:CC_NOOV 21) (const_int 0)])
4272 (match_operand:QF 2 "src_operand" "fHm,0")
4273 (match_operand:QF 3 "src_operand" "0,fHm")))]
4274 "GET_CODE (operands[1]) != LE
4275 && GET_CODE (operands[1]) != GE
4276 && GET_CODE (operands[1]) != LT
4277 && GET_CODE (operands[1]) != GT
4278 && valid_operands (IF_THEN_ELSE, operands, QFmode)"
4279 "@
4280 ldf%1\\t%2,%0
4281 ldf%I1\\t%3,%0"
4282 [(set_attr "type" "binary")])
4283
4284 (define_expand "movqfcc"
4285 [(set (match_operand:QF 0 "reg_operand" "")
4286 (if_then_else:QF (match_operand 1 "comparison_operator" "")
4287 (match_operand:QF 2 "src_operand" "")
4288 (match_operand:QF 3 "src_operand" "")))]
4289 ""
4290 "{
4291 enum rtx_code code = GET_CODE (operands[1]);
4292 rtx ccreg = c4x_gen_compare_reg (code, c4x_compare_op0, c4x_compare_op1);
4293 if (ccreg == NULL_RTX) FAIL;
4294 emit_insn (gen_rtx_SET (QFmode, operands[0],
4295 gen_rtx_IF_THEN_ELSE (QFmode,
4296 gen_rtx (code, VOIDmode, ccreg, const0_rtx),
4297 operands[2], operands[3])));
4298 DONE;}")
4299
4300 (define_insn "*ldhf_conditional"
4301 [(set (match_operand:HF 0 "reg_operand" "=h,h")
4302 (if_then_else:HF (match_operator 1 "comparison_operator"
4303 [(reg:CC 21) (const_int 0)])
4304 (match_operand:HF 2 "src_operand" "hH,0")
4305 (match_operand:HF 3 "src_operand" "0,hH")))]
4306 ""
4307 "@
4308 ldf%1\\t%2,%0
4309 ldf%I1\\t%3,%0"
4310 [(set_attr "type" "binary")])
4311
4312 (define_insn "*ldhf_conditional_noov"
4313 [(set (match_operand:HF 0 "reg_operand" "=h,h")
4314 (if_then_else:HF (match_operator 1 "comparison_operator"
4315 [(reg:CC_NOOV 21) (const_int 0)])
4316 (match_operand:HF 2 "src_operand" "hH,0")
4317 (match_operand:HF 3 "src_operand" "0,hH")))]
4318 "GET_CODE (operands[1]) != LE
4319 && GET_CODE (operands[1]) != GE
4320 && GET_CODE (operands[1]) != LT
4321 && GET_CODE (operands[1]) != GT"
4322 "@
4323 ldf%1\\t%2,%0
4324 ldf%I1\\t%3,%0"
4325 [(set_attr "type" "binary")])
4326
4327 (define_expand "movhfcc"
4328 [(set (match_operand:HF 0 "reg_operand" "")
4329 (if_then_else:HF (match_operand 1 "comparison_operator" "")
4330 (match_operand:HF 2 "src_operand" "")
4331 (match_operand:HF 3 "src_operand" "")))]
4332 ""
4333 "{
4334 enum rtx_code code = GET_CODE (operands[1]);
4335 rtx ccreg = c4x_gen_compare_reg (code, c4x_compare_op0, c4x_compare_op1);
4336 if (ccreg == NULL_RTX) FAIL;
4337 emit_insn (gen_rtx_SET (HFmode, operands[0],
4338 gen_rtx_IF_THEN_ELSE (HFmode,
4339 gen_rtx (code, VOIDmode, ccreg, const0_rtx),
4340 operands[2], operands[3])));
4341 DONE;}")
4342
4343 (define_expand "seq"
4344 [(set (match_operand:QI 0 "reg_operand" "")
4345 (const_int 0))
4346 (set (match_dup 0)
4347 (if_then_else:QI (eq (match_dup 1) (const_int 0))
4348 (const_int 1)
4349 (match_dup 0)))]
4350 ""
4351 "operands[1] = c4x_gen_compare_reg (EQ, c4x_compare_op0, c4x_compare_op1);")
4352
4353 (define_expand "sne"
4354 [(set (match_operand:QI 0 "reg_operand" "")
4355 (const_int 0))
4356 (set (match_dup 0)
4357 (if_then_else:QI (ne (match_dup 1) (const_int 0))
4358 (const_int 1)
4359 (match_dup 0)))]
4360 ""
4361 "operands[1] = c4x_gen_compare_reg (NE, c4x_compare_op0, c4x_compare_op1);")
4362
4363 (define_expand "slt"
4364 [(set (match_operand:QI 0 "reg_operand" "")
4365 (const_int 0))
4366 (set (match_dup 0)
4367 (if_then_else:QI (lt (match_dup 1) (const_int 0))
4368 (const_int 1)
4369 (match_dup 0)))]
4370 ""
4371 "operands[1] = c4x_gen_compare_reg (LT, c4x_compare_op0, c4x_compare_op1);
4372 if (operands[1] == NULL_RTX) FAIL;")
4373
4374 (define_expand "sltu"
4375 [(set (match_operand:QI 0 "reg_operand" "")
4376 (const_int 0))
4377 (set (match_dup 0)
4378 (if_then_else:QI (ltu (match_dup 1) (const_int 0))
4379 (const_int 1)
4380 (match_dup 0)))]
4381 ""
4382 "operands[1] = c4x_gen_compare_reg (LTU, c4x_compare_op0, c4x_compare_op1);")
4383
4384 (define_expand "sgt"
4385 [(set (match_operand:QI 0 "reg_operand" "")
4386 (const_int 0))
4387 (set (match_dup 0)
4388 (if_then_else:QI (gt (match_dup 1) (const_int 0))
4389 (const_int 1)
4390 (match_dup 0)))]
4391 ""
4392 "operands[1] = c4x_gen_compare_reg (GT, c4x_compare_op0, c4x_compare_op1);
4393 if (operands[1] == NULL_RTX) FAIL;")
4394
4395 (define_expand "sgtu"
4396 [(set (match_operand:QI 0 "reg_operand" "")
4397 (const_int 0))
4398 (set (match_dup 0)
4399 (if_then_else:QI (gtu (match_dup 1) (const_int 0))
4400 (const_int 1)
4401 (match_dup 0)))]
4402 ""
4403 "operands[1] = c4x_gen_compare_reg (GTU, c4x_compare_op0, c4x_compare_op1);")
4404
4405 (define_expand "sle"
4406 [(set (match_operand:QI 0 "reg_operand" "")
4407 (const_int 0))
4408 (set (match_dup 0)
4409 (if_then_else:QI (le (match_dup 1) (const_int 0))
4410 (const_int 1)
4411 (match_dup 0)))]
4412 ""
4413 "operands[1] = c4x_gen_compare_reg (LE, c4x_compare_op0, c4x_compare_op1);
4414 if (operands[1] == NULL_RTX) FAIL;")
4415
4416 (define_expand "sleu"
4417 [(set (match_operand:QI 0 "reg_operand" "")
4418 (const_int 0))
4419 (set (match_dup 0)
4420 (if_then_else:QI (leu (match_dup 1) (const_int 0))
4421 (const_int 1)
4422 (match_dup 0)))]
4423 ""
4424 "operands[1] = c4x_gen_compare_reg (LEU, c4x_compare_op0, c4x_compare_op1);")
4425
4426 (define_expand "sge"
4427 [(set (match_operand:QI 0 "reg_operand" "")
4428 (const_int 0))
4429 (set (match_dup 0)
4430 (if_then_else:QI (ge (match_dup 1) (const_int 0))
4431 (const_int 1)
4432 (match_dup 0)))]
4433 ""
4434 "operands[1] = c4x_gen_compare_reg (GE, c4x_compare_op0, c4x_compare_op1);
4435 if (operands[1] == NULL_RTX) FAIL;")
4436
4437 (define_expand "sgeu"
4438 [(set (match_operand:QI 0 "reg_operand" "")
4439 (const_int 0))
4440 (set (match_dup 0)
4441 (if_then_else:QI (geu (match_dup 1) (const_int 0))
4442 (const_int 1)
4443 (match_dup 0)))]
4444 ""
4445 "operands[1] = c4x_gen_compare_reg (GEU, c4x_compare_op0, c4x_compare_op1);")
4446
4447 (define_split
4448 [(set (match_operand:QI 0 "reg_operand" "")
4449 (match_operator:QI 1 "comparison_operator" [(reg:CC 21) (const_int 0)]))]
4450 "reload_completed"
4451 [(set (match_dup 0) (const_int 0))
4452 (set (match_dup 0)
4453 (if_then_else:QI (match_op_dup 1 [(reg:CC 21) (const_int 0)])
4454 (const_int 1)
4455 (match_dup 0)))]
4456 "")
4457
4458 (define_split
4459 [(set (match_operand:QI 0 "reg_operand" "")
4460 (match_operator:QI 1 "comparison_operator" [(reg:CC_NOOV 21) (const_int 0)]))]
4461 "reload_completed"
4462 [(set (match_dup 0) (const_int 0))
4463 (set (match_dup 0)
4464 (if_then_else:QI (match_op_dup 1 [(reg:CC_NOOV 21) (const_int 0)])
4465 (const_int 1)
4466 (match_dup 0)))]
4467 "")
4468
4469 (define_insn "*bu"
4470 [(set (pc)
4471 (unspec [(match_operand:QI 0 "reg_operand" "r")] UNSPEC_BU))]
4472 ""
4473 "bu%#\\t%0"
4474 [(set_attr "type" "jump")])
4475
4476 (define_expand "caseqi"
4477 [(parallel [(set (match_dup 5)
4478 (minus:QI (match_operand:QI 0 "reg_operand" "")
4479 (match_operand:QI 1 "src_operand" "")))
4480 (clobber (reg:CC_NOOV 21))])
4481 (set (reg:CC 21)
4482 (compare:CC (match_dup 5)
4483 (match_operand:QI 2 "src_operand" "")))
4484 (set (pc)
4485 (if_then_else (gtu (reg:CC 21)
4486 (const_int 0))
4487 (label_ref (match_operand 4 "" ""))
4488 (pc)))
4489 (parallel [(set (match_dup 6)
4490 (plus:QI (match_dup 5)
4491 (label_ref:QI (match_operand 3 "" ""))))
4492 (clobber (reg:CC_NOOV 21))])
4493 (set (match_dup 7)
4494 (mem:QI (match_dup 6)))
4495 (set (pc) (match_dup 7))]
4496 ""
4497 "operands[5] = gen_reg_rtx (QImode);
4498 operands[6] = gen_reg_rtx (QImode);
4499 operands[7] = gen_reg_rtx (QImode);")
4500
4501 ;
4502 ; PARALLEL FLOAT INSTRUCTIONS
4503 ;
4504 ; This patterns are under development
4505
4506 ;
4507 ; ABSF/STF
4508 ;
4509
4510 (define_insn "*absqf2_movqf_clobber"
4511 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q")
4512 (abs:QF (match_operand:QF 1 "par_ind_operand" "S<>")))
4513 (set (match_operand:QF 2 "par_ind_operand" "=S<>")
4514 (match_operand:QF 3 "ext_low_reg_operand" "q"))
4515 (clobber (reg:CC_NOOV 21))]
4516 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QFmode)"
4517 "absf\\t%1,%0\\n||\\tstf\\t%3,%2"
4518 [(set_attr "type" "binarycc")])
4519
4520 ;
4521 ; ADDF/STF
4522 ;
4523
4524 (define_insn "*addqf3_movqf_clobber"
4525 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q,q")
4526 (plus:QF (match_operand:QF 1 "parallel_operand" "%q,S<>")
4527 (match_operand:QF 2 "parallel_operand" "S<>,q")))
4528 (set (match_operand:QF 3 "par_ind_operand" "=S<>,S<>")
4529 (match_operand:QF 4 "ext_low_reg_operand" "q,q"))
4530 (clobber (reg:CC 21))]
4531 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QFmode)"
4532 "addf3\\t%2,%1,%0\\n||\\tstf\\t%4,%3"
4533 [(set_attr "type" "binarycc,binarycc")])
4534
4535 ;
4536 ; FLOAT/STF
4537 ;
4538
4539 (define_insn "*floatqiqf2_movqf_clobber"
4540 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q")
4541 (float:QF (match_operand:QI 1 "par_ind_operand" "S<>")))
4542 (set (match_operand:QF 2 "par_ind_operand" "=S<>")
4543 (match_operand:QF 3 "ext_low_reg_operand" "q"))
4544 (clobber (reg:CC 21))]
4545 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QFmode)"
4546 "float\\t%1,%0\\n||\\tstf\\t%3,%2"
4547 [(set_attr "type" "binarycc")])
4548
4549 ;
4550 ; MPYF/ADDF
4551 ;
4552
4553 (define_insn "*mulqf3_addqf3_clobber"
4554 [(set (match_operand:QF 0 "r0r1_reg_operand" "=t,t,t,t")
4555 (mult:QF (match_operand:QF 1 "parallel_operand" "%S<>!V,q,S<>!V,q")
4556 (match_operand:QF 2 "parallel_operand" "q,S<>!V,S<>!V,q")))
4557 (set (match_operand:QF 3 "r2r3_reg_operand" "=u,u,u,u")
4558 (plus:QF (match_operand:QF 4 "parallel_operand" "%S<>!V,q,q,S<>!V")
4559 (match_operand:QF 5 "parallel_operand" "q,S<>!V,q,S<>!V")))
4560 (clobber (reg:CC_NOOV 21))]
4561 "TARGET_PARALLEL_MPY && valid_parallel_operands_6 (operands, QFmode)"
4562 "mpyf3\\t%2,%1,%0\\n||\\taddf3\\t%5,%4,%3"
4563 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
4564
4565
4566 ;
4567 ; MPYF/STF
4568 ;
4569
4570 (define_insn "*mulqf3_movqf_clobber"
4571 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q,q")
4572 (mult:QF (match_operand:QF 1 "parallel_operand" "%q,S<>")
4573 (match_operand:QF 2 "parallel_operand" "S<>,q")))
4574 (set (match_operand:QF 3 "par_ind_operand" "=S<>,S<>")
4575 (match_operand:QF 4 "ext_low_reg_operand" "q,q"))
4576 (clobber (reg:CC 21))]
4577 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QFmode)"
4578 "mpyf3\\t%2,%1,%0\\n||\\tstf\\t%4,%3"
4579 [(set_attr "type" "binarycc,binarycc")])
4580
4581 ;
4582 ; MPYF/SUBF
4583 ;
4584
4585 (define_insn "*mulqf3_subqf3_clobber"
4586 [(set (match_operand:QF 0 "r0r1_reg_operand" "=t,t")
4587 (mult:QF (match_operand:QF 1 "parallel_operand" "S<>,q")
4588 (match_operand:QF 2 "parallel_operand" "q,S<>")))
4589 (set (match_operand:QF 3 "r2r3_reg_operand" "=u,u")
4590 (minus:QF (match_operand:QF 4 "parallel_operand" "S<>,q")
4591 (match_operand:QF 5 "parallel_operand" "q,S<>")))
4592 (clobber (reg:CC 21))]
4593 "TARGET_PARALLEL_MPY && valid_parallel_operands_6 (operands, QFmode)"
4594 "mpyf3\\t%2,%1,%0\\n||\\tsubf3\\t%5,%4,%3"
4595 [(set_attr "type" "binarycc,binarycc")])
4596
4597 ;
4598 ; MPYF/LDF 0
4599 ;
4600
4601 (define_insn "*mulqf3_clrqf_clobber"
4602 [(set (match_operand:QF 0 "r0r1_reg_operand" "=t")
4603 (mult:QF (match_operand:QF 1 "par_ind_operand" "%S<>")
4604 (match_operand:QF 2 "par_ind_operand" "S<>")))
4605 (set (match_operand:QF 3 "r2r3_reg_operand" "=u")
4606 (match_operand:QF 4 "fp_zero_operand" "G"))
4607 (clobber (reg:CC 21))]
4608 "TARGET_PARALLEL_MPY"
4609 "mpyf3\\t%2,%1,%0\\n||\\tsubf3\\t%3,%3,%3"
4610 [(set_attr "type" "binarycc")])
4611
4612 ;
4613 ; NEGF/STF
4614 ;
4615
4616 (define_insn "*negqf2_movqf_clobber"
4617 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q")
4618 (neg:QF (match_operand:QF 1 "par_ind_operand" "S<>")))
4619 (set (match_operand:QF 2 "par_ind_operand" "=S<>")
4620 (match_operand:QF 3 "ext_low_reg_operand" "q"))
4621 (clobber (reg:CC 21))]
4622 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QFmode)"
4623 "negf\\t%1,%0\\n||\\tstf\\t%3,%2"
4624 [(set_attr "type" "binarycc")])
4625
4626 ;
4627 ; SUBF/STF
4628 ;
4629
4630 (define_insn "*subqf3_movqf_clobber"
4631 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q")
4632 (minus:QF (match_operand:QF 1 "ext_low_reg_operand" "q")
4633 (match_operand:QF 2 "par_ind_operand" "S<>")))
4634 (set (match_operand:QF 3 "par_ind_operand" "=S<>")
4635 (match_operand:QF 4 "ext_low_reg_operand" "q"))
4636 (clobber (reg:CC 21))]
4637 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QFmode)"
4638 "subf3\\t%2,%1,%0\\n||\\tstf\\t%4,%3"
4639 [(set_attr "type" "binarycc")])
4640
4641 ;
4642 ; TOIEEE/STF
4643 ;
4644
4645 (define_insn "*toieee_movqf_clobber"
4646 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q")
4647 (unspec:QF [(match_operand:QF 1 "par_ind_operand" "S<>")] UNSPEC_TOIEEE))
4648 (set (match_operand:QF 2 "par_ind_operand" "=S<>")
4649 (match_operand:QF 3 "ext_low_reg_operand" "q"))
4650 (clobber (reg:CC 21))]
4651 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QFmode)"
4652 "toieee\\t%1,%0\\n||\\tstf\\t%3,%2"
4653 [(set_attr "type" "binarycc")])
4654
4655 ;
4656 ; FRIEEE/STF
4657 ;
4658
4659 (define_insn "*frieee_movqf_clobber"
4660 [(set (match_operand:QF 0 "ext_low_reg_operand" "=q")
4661 (unspec:QF [(match_operand:QF 1 "par_ind_operand" "S<>")] UNSPEC_FRIEEE))
4662 (set (match_operand:QF 2 "par_ind_operand" "=S<>")
4663 (match_operand:QF 3 "ext_low_reg_operand" "q"))
4664 (clobber (reg:CC 21))]
4665 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QFmode)"
4666 "frieee\\t%1,%0\\n||\\tstf\\t%3,%2"
4667 [(set_attr "type" "binarycc")])
4668
4669 ;
4670 ; PARALLEL INTEGER INSTRUCTIONS
4671 ;
4672
4673 ;
4674 ; ABSI/STI
4675 ;
4676
4677 (define_insn "*absqi2_movqi_clobber"
4678 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4679 (abs:QI (match_operand:QI 1 "par_ind_operand" "S<>")))
4680 (set (match_operand:QI 2 "par_ind_operand" "=S<>")
4681 (match_operand:QI 3 "ext_low_reg_operand" "q"))
4682 (clobber (reg:CC_NOOV 21))]
4683 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QImode)"
4684 "absi\\t%1,%0\\n||\\tsti\\t%3,%2"
4685 [(set_attr "type" "binarycc")])
4686
4687 ;
4688 ; ADDI/STI
4689 ;
4690
4691 (define_insn "*addqi3_movqi_clobber"
4692 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q,q")
4693 (plus:QI (match_operand:QI 1 "parallel_operand" "%q,S<>")
4694 (match_operand:QI 2 "parallel_operand" "S<>,q")))
4695 (set (match_operand:QI 3 "par_ind_operand" "=S<>,S<>")
4696 (match_operand:QI 4 "ext_low_reg_operand" "q,q"))
4697 (clobber (reg:CC 21))]
4698 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4699 "addi3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4700 [(set_attr "type" "binarycc,binarycc")])
4701
4702 ;
4703 ; AND/STI
4704 ;
4705
4706 (define_insn "*andqi3_movqi_clobber"
4707 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q,q")
4708 (and:QI (match_operand:QI 1 "parallel_operand" "%q,S<>")
4709 (match_operand:QI 2 "parallel_operand" "S<>,q")))
4710 (set (match_operand:QI 3 "par_ind_operand" "=S<>,S<>")
4711 (match_operand:QI 4 "ext_low_reg_operand" "q,q"))
4712 (clobber (reg:CC 21))]
4713 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4714 "and3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4715 [(set_attr "type" "binarycc,binarycc")])
4716
4717 ;
4718 ; ASH(left)/STI
4719 ;
4720
4721 (define_insn "*ashlqi3_movqi_clobber"
4722 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4723 (ashift:QI (match_operand:QI 1 "par_ind_operand" "S<>")
4724 (match_operand:QI 2 "ext_low_reg_operand" "q")))
4725 (set (match_operand:QI 3 "par_ind_operand" "=S<>")
4726 (match_operand:QI 4 "ext_low_reg_operand" "q"))
4727 (clobber (reg:CC 21))]
4728 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4729 "ash3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4730 [(set_attr "type" "binarycc")])
4731
4732 ;
4733 ; ASH(right)/STI
4734 ;
4735
4736 (define_insn "*ashrqi3_movqi_clobber"
4737 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4738 (ashiftrt:QI (match_operand:QI 1 "par_ind_operand" "S<>")
4739 (neg:QI (match_operand:QI 2 "ext_low_reg_operand" "q"))))
4740 (set (match_operand:QI 3 "par_ind_operand" "=S<>")
4741 (match_operand:QI 4 "ext_low_reg_operand" "q"))
4742 (clobber (reg:CC 21))]
4743 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4744 "ash3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4745 [(set_attr "type" "binarycc")])
4746
4747 ;
4748 ; FIX/STI
4749 ;
4750
4751 (define_insn "*fixqfqi2_movqi_clobber"
4752 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4753 (fix:QI (match_operand:QF 1 "par_ind_operand" "S<>")))
4754 (set (match_operand:QI 2 "par_ind_operand" "=S<>")
4755 (match_operand:QI 3 "ext_low_reg_operand" "q"))
4756 (clobber (reg:CC 21))]
4757 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QImode)"
4758 "fix\\t%1,%0\\n||\\tsti\\t%3,%2"
4759 [(set_attr "type" "binarycc")])
4760
4761 ;
4762 ; LSH(right)/STI
4763 ;
4764
4765 (define_insn "*lshrqi3_movqi_clobber"
4766 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4767 (lshiftrt:QI (match_operand:QI 1 "par_ind_operand" "S<>")
4768 (neg:QI (match_operand:QI 2 "ext_low_reg_operand" "q"))))
4769 (set (match_operand:QI 3 "par_ind_operand" "=S<>")
4770 (match_operand:QI 4 "ext_low_reg_operand" "q"))
4771 (clobber (reg:CC 21))]
4772 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4773 "lsh3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4774 [(set_attr "type" "binarycc")])
4775
4776 ;
4777 ; MPYI/ADDI
4778 ;
4779
4780 (define_insn "*mulqi3_addqi3_clobber"
4781 [(set (match_operand:QI 0 "r0r1_reg_operand" "=t,t,t,t")
4782 (mult:QI (match_operand:QI 1 "parallel_operand" "%S<>!V,q,S<>!V,q")
4783 (match_operand:QI 2 "parallel_operand" "q,S<>!V,S<>!V,q")))
4784 (set (match_operand:QI 3 "r2r3_reg_operand" "=u,u,u,u")
4785 (plus:QI (match_operand:QI 4 "parallel_operand" "%S<>!V,q,q,S<>!V")
4786 (match_operand:QI 5 "parallel_operand" "q,S<>!V,q,S<>!V")))
4787 (clobber (reg:CC 21))]
4788 "TARGET_PARALLEL_MPY && TARGET_MPYI
4789 && valid_parallel_operands_6 (operands, QImode)"
4790 "mpyi3\\t%2,%1,%0\\n||\\taddi3\\t%5,%4,%3"
4791 [(set_attr "type" "binarycc,binarycc,binarycc,binarycc")])
4792
4793
4794 ;
4795 ; MPYI/STI
4796 ;
4797
4798 (define_insn "*mulqi3_movqi_clobber"
4799 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q,q")
4800 (mult:QI (match_operand:QI 1 "parallel_operand" "%q,S<>")
4801 (match_operand:QI 2 "parallel_operand" "S<>,q")))
4802 (set (match_operand:QI 3 "par_ind_operand" "=S<>,S<>")
4803 (match_operand:QI 4 "ext_low_reg_operand" "q,q"))
4804 (clobber (reg:CC 21))]
4805 "TARGET_PARALLEL && TARGET_MPYI
4806 && valid_parallel_operands_5 (operands, QImode)"
4807 "mpyi3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4808 [(set_attr "type" "binarycc,binarycc")])
4809
4810 ;
4811 ; MPYI/SUBI
4812 ;
4813
4814 (define_insn "*mulqi3_subqi3_clobber"
4815 [(set (match_operand:QI 0 "r0r1_reg_operand" "=t,t")
4816 (mult:QI (match_operand:QI 1 "parallel_operand" "S<>,q")
4817 (match_operand:QI 2 "parallel_operand" "q,S<>")))
4818 (set (match_operand:QI 3 "r2r3_reg_operand" "=u,u")
4819 (minus:QI (match_operand:QI 4 "parallel_operand" "S<>,q")
4820 (match_operand:QI 5 "parallel_operand" "q,S<>")))
4821 (clobber (reg:CC 21))]
4822 "TARGET_PARALLEL_MPY && TARGET_MPYI
4823 && valid_parallel_operands_6 (operands, QImode)"
4824 "mpyi3\\t%2,%1,%0\\n||\\tsubi3\\t%5,%4,%3"
4825 [(set_attr "type" "binarycc,binarycc")])
4826
4827 ;
4828 ; MPYI/LDI 0
4829 ;
4830
4831 (define_insn "*mulqi3_clrqi_clobber"
4832 [(set (match_operand:QI 0 "r0r1_reg_operand" "=t")
4833 (mult:QI (match_operand:QI 1 "par_ind_operand" "%S<>")
4834 (match_operand:QI 2 "par_ind_operand" "S<>")))
4835 (set (match_operand:QI 3 "r2r3_reg_operand" "=u")
4836 (const_int 0))
4837 (clobber (reg:CC 21))]
4838 "TARGET_PARALLEL_MPY && TARGET_MPYI"
4839 "mpyi3\\t%2,%1,%0\\n||\\tsubi3\\t%3,%3,%3"
4840 [(set_attr "type" "binarycc")])
4841
4842 ;
4843 ; NEGI/STI
4844 ;
4845
4846 (define_insn "*negqi2_movqi_clobber"
4847 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4848 (neg:QI (match_operand:QI 1 "par_ind_operand" "S<>")))
4849 (set (match_operand:QI 2 "par_ind_operand" "=S<>")
4850 (match_operand:QI 3 "ext_low_reg_operand" "q"))
4851 (clobber (reg:CC 21))]
4852 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QImode)"
4853 "negi\\t%1,%0\\n||\\tsti\\t%3,%2"
4854 [(set_attr "type" "binarycc")])
4855
4856 ;
4857 ; NOT/STI
4858 ;
4859
4860 (define_insn "*notqi2_movqi_clobber"
4861 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4862 (not:QI (match_operand:QI 1 "par_ind_operand" "S<>")))
4863 (set (match_operand:QI 2 "par_ind_operand" "=S<>")
4864 (match_operand:QI 3 "ext_low_reg_operand" "q"))
4865 (clobber (reg:CC 21))]
4866 "TARGET_PARALLEL && valid_parallel_operands_4 (operands, QImode)"
4867 "not\\t%1,%0\\n||\\tsti\\t%3,%2"
4868 [(set_attr "type" "binarycc")])
4869
4870 ;
4871 ; OR/STI
4872 ;
4873
4874 (define_insn "*iorqi3_movqi_clobber"
4875 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q,q")
4876 (ior:QI (match_operand:QI 1 "parallel_operand" "%q,S<>")
4877 (match_operand:QI 2 "parallel_operand" "S<>,q")))
4878 (set (match_operand:QI 3 "par_ind_operand" "=S<>,S<>")
4879 (match_operand:QI 4 "ext_low_reg_operand" "q,q"))
4880 (clobber (reg:CC 21))]
4881 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4882 "or3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4883 [(set_attr "type" "binarycc,binarycc")])
4884
4885 ;
4886 ; SUBI/STI
4887 ;
4888
4889 (define_insn "*subqi3_movqi_clobber"
4890 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q")
4891 (minus:QI (match_operand:QI 1 "par_ind_operand" "S<>")
4892 (match_operand:QI 2 "ext_low_reg_operand" "q")))
4893 (set (match_operand:QI 3 "par_ind_operand" "=S<>")
4894 (match_operand:QI 4 "ext_low_reg_operand" "q"))
4895 (clobber (reg:CC 21))]
4896 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4897 "subi3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4898 [(set_attr "type" "binarycc")])
4899
4900 ;
4901 ; XOR/STI
4902 ;
4903
4904 (define_insn "*xorqi3_movqi_clobber"
4905 [(set (match_operand:QI 0 "ext_low_reg_operand" "=q,q")
4906 (xor:QI (match_operand:QI 1 "parallel_operand" "%q,S<>")
4907 (match_operand:QI 2 "parallel_operand" "S<>,q")))
4908 (set (match_operand:QI 3 "par_ind_operand" "=S<>,S<>")
4909 (match_operand:QI 4 "ext_low_reg_operand" "q,q"))
4910 (clobber (reg:CC 21))]
4911 "TARGET_PARALLEL && valid_parallel_operands_5 (operands, QImode)"
4912 "xor3\\t%2,%1,%0\\n||\\tsti\\t%4,%3"
4913 [(set_attr "type" "binarycc,binarycc")])
4914
4915 ;
4916 ; BRANCH/CALL INSTRUCTIONS
4917 ;
4918
4919 ;
4920 ; Branch instructions
4921 ;
4922 (define_insn "*b"
4923 [(set (pc) (if_then_else (match_operator 0 "comparison_operator"
4924 [(reg:CC 21) (const_int 0)])
4925 (label_ref (match_operand 1 "" ""))
4926 (pc)))]
4927 ""
4928 "*
4929 return c4x_output_cbranch (\"b%0\", insn);"
4930 [(set_attr "type" "jmpc")])
4931
4932 (define_insn "*b_rev"
4933 [(set (pc) (if_then_else (match_operator 0 "comparison_operator"
4934 [(reg:CC 21) (const_int 0)])
4935 (pc)
4936 (label_ref (match_operand 1 "" ""))))]
4937 ""
4938 "*
4939 return c4x_output_cbranch (\"b%I0\", insn);"
4940 [(set_attr "type" "jmpc")])
4941
4942 (define_insn "*b_noov"
4943 [(set (pc) (if_then_else (match_operator 0 "comparison_operator"
4944 [(reg:CC_NOOV 21) (const_int 0)])
4945 (label_ref (match_operand 1 "" ""))
4946 (pc)))]
4947 "GET_CODE (operands[0]) != LE
4948 && GET_CODE (operands[0]) != GE
4949 && GET_CODE (operands[0]) != LT
4950 && GET_CODE (operands[0]) != GT"
4951 "*
4952 return c4x_output_cbranch (\"b%0\", insn);"
4953 [(set_attr "type" "jmpc")])
4954
4955 (define_insn "*b_noov_rev"
4956 [(set (pc) (if_then_else (match_operator 0 "comparison_operator"
4957 [(reg:CC_NOOV 21) (const_int 0)])
4958 (pc)
4959 (label_ref (match_operand 1 "" ""))))]
4960 "GET_CODE (operands[0]) != LE
4961 && GET_CODE (operands[0]) != GE
4962 && GET_CODE (operands[0]) != LT
4963 && GET_CODE (operands[0]) != GT"
4964 "*
4965 return c4x_output_cbranch (\"b%I0\", insn);"
4966 [(set_attr "type" "jmpc")])
4967
4968 (define_expand "beq"
4969 [(set (pc) (if_then_else (eq (match_dup 1) (const_int 0))
4970 (label_ref (match_operand 0 "" ""))
4971 (pc)))]
4972 ""
4973 "operands[1] = c4x_gen_compare_reg (EQ, c4x_compare_op0, c4x_compare_op1);")
4974
4975 (define_expand "bne"
4976 [(set (pc) (if_then_else (ne (match_dup 1) (const_int 0))
4977 (label_ref (match_operand 0 "" ""))
4978 (pc)))]
4979 ""
4980 "operands[1] = c4x_gen_compare_reg (NE, c4x_compare_op0, c4x_compare_op1);")
4981
4982 (define_expand "blt"
4983 [(set (pc) (if_then_else (lt (match_dup 1) (const_int 0))
4984 (label_ref (match_operand 0 "" ""))
4985 (pc)))]
4986 ""
4987 "operands[1] = c4x_gen_compare_reg (LT, c4x_compare_op0, c4x_compare_op1);
4988 if (operands[1] == NULL_RTX) FAIL;")
4989
4990 (define_expand "bltu"
4991 [(set (pc) (if_then_else (ltu (match_dup 1) (const_int 0))
4992 (label_ref (match_operand 0 "" ""))
4993 (pc)))]
4994 ""
4995 "operands[1] = c4x_gen_compare_reg (LTU, c4x_compare_op0, c4x_compare_op1);")
4996
4997 (define_expand "bgt"
4998 [(set (pc) (if_then_else (gt (match_dup 1) (const_int 0))
4999 (label_ref (match_operand 0 "" ""))
5000 (pc)))]
5001 ""
5002 "operands[1] = c4x_gen_compare_reg (GT, c4x_compare_op0, c4x_compare_op1);
5003 if (operands[1] == NULL_RTX) FAIL;")
5004
5005 (define_expand "bgtu"
5006 [(set (pc) (if_then_else (gtu (match_dup 1) (const_int 0))
5007 (label_ref (match_operand 0 "" ""))
5008 (pc)))]
5009 ""
5010 "operands[1] = c4x_gen_compare_reg (GTU, c4x_compare_op0, c4x_compare_op1);")
5011
5012 (define_expand "ble"
5013 [(set (pc) (if_then_else (le (match_dup 1) (const_int 0))
5014 (label_ref (match_operand 0 "" ""))
5015 (pc)))]
5016 ""
5017 "operands[1] = c4x_gen_compare_reg (LE, c4x_compare_op0, c4x_compare_op1);
5018 if (operands[1] == NULL_RTX) FAIL;")
5019
5020 (define_expand "bleu"
5021 [(set (pc) (if_then_else (leu (match_dup 1) (const_int 0))
5022 (label_ref (match_operand 0 "" ""))
5023 (pc)))]
5024 ""
5025 "operands[1] = c4x_gen_compare_reg (LEU, c4x_compare_op0, c4x_compare_op1);")
5026
5027 (define_expand "bge"
5028 [(set (pc) (if_then_else (ge (match_dup 1) (const_int 0))
5029 (label_ref (match_operand 0 "" ""))
5030 (pc)))]
5031 ""
5032 "operands[1] = c4x_gen_compare_reg (GE, c4x_compare_op0, c4x_compare_op1);
5033 if (operands[1] == NULL_RTX) FAIL;")
5034
5035 (define_expand "bgeu"
5036 [(set (pc) (if_then_else (geu (match_dup 1) (const_int 0))
5037 (label_ref (match_operand 0 "" ""))
5038 (pc)))]
5039 ""
5040 "operands[1] = c4x_gen_compare_reg (GEU, c4x_compare_op0, c4x_compare_op1);")
5041
5042 (define_insn "*b_reg"
5043 [(set (pc) (match_operand:QI 0 "reg_operand" "r"))]
5044 ""
5045 "bu%#\\t%0"
5046 [(set_attr "type" "jump")])
5047
5048 (define_expand "indirect_jump"
5049 [(set (pc) (match_operand:QI 0 "reg_operand" ""))]
5050 ""
5051 "")
5052
5053 (define_insn "tablejump"
5054 [(set (pc) (match_operand:QI 0 "src_operand" "r"))
5055 (use (label_ref (match_operand 1 "" "")))]
5056 ""
5057 "bu%#\\t%0"
5058 [(set_attr "type" "jump")])
5059
5060 ;
5061 ; CALL
5062 ;
5063 (define_insn "*call_c3x"
5064 [(call (mem:QI (match_operand:QI 0 "call_address_operand" "Ur"))
5065 (match_operand:QI 1 "general_operand" ""))
5066 (clobber (reg:QI 31))]
5067 ;; Operand 1 not really used on the C4x. The C30 doesn't have reg 31.
5068
5069 "TARGET_C3X"
5070 "call%U0\\t%C0"
5071 [(set_attr "type" "call")])
5072
5073 ; LAJ requires R11 (31) for the return address
5074 (define_insn "*laj"
5075 [(call (mem:QI (match_operand:QI 0 "call_address_operand" "Ur"))
5076 (match_operand:QI 1 "general_operand" ""))
5077 (clobber (reg:QI 31))]
5078 ;; Operand 1 not really used on the C4x.
5079
5080 "! TARGET_C3X"
5081 "*
5082 if (final_sequence)
5083 return c4x_check_laj_p (insn)
5084 ? \"nop\\n\\tlaj%U0\\t%C0\" : \"laj%U0\\t%C0\";
5085 else
5086 return \"call%U0\\t%C0\";"
5087 [(set_attr "type" "laj")])
5088
5089 (define_expand "call"
5090 [(parallel [(call (match_operand:QI 0 "" "")
5091 (match_operand:QI 1 "general_operand" ""))
5092 (clobber (reg:QI 31))])]
5093 ""
5094 "
5095 {
5096 if (GET_CODE (operands[0]) == MEM
5097 && ! call_address_operand (XEXP (operands[0], 0), Pmode))
5098 operands[0] = gen_rtx_MEM (GET_MODE (operands[0]),
5099 force_reg (Pmode, XEXP (operands[0], 0)));
5100 }")
5101
5102 (define_insn "nodb_call"
5103 [(call (mem:QI (match_operand:QI 0 "call_address_operand" "Ur"))
5104 (const_int 0))]
5105 ""
5106 "call%U0\\t%C0"
5107 [(set_attr "type" "call")])
5108
5109 (define_insn "*callv_c3x"
5110 [(set (match_operand 0 "" "=r")
5111 (call (mem:QI (match_operand:QI 1 "call_address_operand" "Ur"))
5112 (match_operand:QI 2 "general_operand" "")))
5113 (clobber (reg:QI 31))]
5114 ;; Operand 0 and 2 not really used for the C4x.
5115 ;; The C30 doesn't have reg 31.
5116
5117 "TARGET_C3X"
5118 "call%U1\\t%C1"
5119 [(set_attr "type" "call")])
5120
5121 ; LAJ requires R11 (31) for the return address
5122 (define_insn "*lajv"
5123 [(set (match_operand 0 "" "=r")
5124 (call (mem:QI (match_operand:QI 1 "call_address_operand" "Ur"))
5125 (match_operand:QI 2 "general_operand" "")))
5126 (clobber (reg:QI 31))]
5127 ;; Operand 0 and 2 not really used in the C30 instruction.
5128
5129 "! TARGET_C3X"
5130 "*
5131 if (final_sequence)
5132 return c4x_check_laj_p (insn)
5133 ? \"nop\\n\\tlaj%U1\\t%C1\" : \"laj%U1\\t%C1\";
5134 else
5135 return \"call%U1\\t%C1\";"
5136 [(set_attr "type" "laj")])
5137
5138 (define_expand "call_value"
5139 [(parallel [(set (match_operand 0 "" "")
5140 (call (match_operand:QI 1 "" "")
5141 (match_operand:QI 2 "general_operand" "")))
5142 (clobber (reg:QI 31))])]
5143 ""
5144 "
5145 {
5146 if (GET_CODE (operands[0]) == MEM
5147 && ! call_address_operand (XEXP (operands[1], 0), Pmode))
5148 operands[0] = gen_rtx_MEM (GET_MODE (operands[1]),
5149 force_reg (Pmode, XEXP (operands[1], 0)));
5150 }")
5151
5152 (define_insn "return"
5153 [(return)]
5154 "! c4x_null_epilogue_p ()"
5155 "rets"
5156 [(set_attr "type" "rets")])
5157
5158 (define_insn "return_from_epilogue"
5159 [(return)]
5160 "reload_completed && ! c4x_interrupt_function_p ()"
5161 "rets"
5162 [(set_attr "type" "rets")])
5163
5164 (define_insn "return_from_interrupt_epilogue"
5165 [(return)]
5166 "reload_completed && c4x_interrupt_function_p ()"
5167 "reti"
5168 [(set_attr "type" "rets")])
5169
5170 (define_insn "*return_cc"
5171 [(set (pc)
5172 (if_then_else (match_operator 0 "comparison_operator"
5173 [(reg:CC 21) (const_int 0)])
5174 (return)
5175 (pc)))]
5176 "! c4x_null_epilogue_p ()"
5177 "rets%0"
5178 [(set_attr "type" "rets")])
5179
5180 (define_insn "*return_cc_noov"
5181 [(set (pc)
5182 (if_then_else (match_operator 0 "comparison_operator"
5183 [(reg:CC_NOOV 21) (const_int 0)])
5184 (return)
5185 (pc)))]
5186 "GET_CODE (operands[0]) != LE
5187 && GET_CODE (operands[0]) != GE
5188 && GET_CODE (operands[0]) != LT
5189 && GET_CODE (operands[0]) != GT
5190 && ! c4x_null_epilogue_p ()"
5191 "rets%0"
5192 [(set_attr "type" "rets")])
5193
5194 (define_insn "*return_cc_inverse"
5195 [(set (pc)
5196 (if_then_else (match_operator 0 "comparison_operator"
5197 [(reg:CC 21) (const_int 0)])
5198 (pc)
5199 (return)))]
5200 "! c4x_null_epilogue_p ()"
5201 "rets%I0"
5202 [(set_attr "type" "rets")])
5203
5204 (define_insn "*return_cc_noov_inverse"
5205 [(set (pc)
5206 (if_then_else (match_operator 0 "comparison_operator"
5207 [(reg:CC_NOOV 21) (const_int 0)])
5208 (pc)
5209 (return)))]
5210 "GET_CODE (operands[0]) != LE
5211 && GET_CODE (operands[0]) != GE
5212 && GET_CODE (operands[0]) != LT
5213 && GET_CODE (operands[0]) != GT
5214 && ! c4x_null_epilogue_p ()"
5215 "rets%I0"
5216 [(set_attr "type" "rets")])
5217
5218 (define_insn "jump"
5219 [(set (pc) (label_ref (match_operand 0 "" "")))]
5220 ""
5221 "br%#\\t%l0"
5222 [(set_attr "type" "jump")])
5223
5224 (define_insn "trap"
5225 [(trap_if (const_int 1) (const_int 31))]
5226 ""
5227 "trapu\\t31"
5228 [(set_attr "type" "call")])
5229
5230 (define_expand "conditional_trap"
5231 [(trap_if (match_operand 0 "comparison_operator" "")
5232 (match_operand 1 "const_int_operand" ""))]
5233 ""
5234 "{
5235 enum rtx_code code = GET_CODE (operands[1]);
5236 rtx ccreg = c4x_gen_compare_reg (code, c4x_compare_op0, c4x_compare_op1);
5237 if (ccreg == NULL_RTX) FAIL;
5238 if (GET_MODE (ccreg) == CCmode)
5239 emit_insn (gen_cond_trap_cc (operands[0], operands[1]));
5240 else
5241 emit_insn (gen_cond_trap_cc_noov (operands[0], operands[1]));
5242 DONE;}")
5243
5244 (define_insn "cond_trap_cc"
5245 [(trap_if (match_operator 0 "comparison_operator"
5246 [(reg:CC 21) (const_int 0)])
5247 (match_operand 1 "const_int_operand" ""))]
5248 ""
5249 "trap%0\\t31"
5250 [(set_attr "type" "call")])
5251
5252 (define_insn "cond_trap_cc_noov"
5253 [(trap_if (match_operator 0 "comparison_operator"
5254 [(reg:CC_NOOV 21) (const_int 0)])
5255 (match_operand 1 "const_int_operand" ""))]
5256 "GET_CODE (operands[0]) != LE
5257 && GET_CODE (operands[0]) != GE
5258 && GET_CODE (operands[0]) != LT
5259 && GET_CODE (operands[0]) != GT"
5260 "trap%0\\t31"
5261 [(set_attr "type" "call")])
5262
5263 ;
5264 ; DBcond
5265 ;
5266 ; Note we have to emit a dbu instruction if there are no delay slots
5267 ; to fill.
5268 ; Also note that GCC will try to reverse a loop to see if it can
5269 ; utilize this instruction. However, if there are more than one
5270 ; memory reference in the loop, it cannot guarantee that reversing
5271 ; the loop will work :( (see check_dbra_loop() in loop.c)
5272 ; Note that the C3x only decrements the 24 LSBs of the address register
5273 ; and the 8 MSBs are untouched. The C4x uses all 32-bits. We thus
5274 ; have an option to disable this instruction.
5275 (define_insn "*db"
5276 [(set (pc)
5277 (if_then_else (ne (match_operand:QI 0 "addr_reg_operand" "+a,?*d,??*r,!m")
5278 (const_int 0))
5279 (label_ref (match_operand 1 "" ""))
5280 (pc)))
5281 (set (match_dup 0)
5282 (plus:QI (match_dup 0)
5283 (const_int -1)))
5284 (use (reg:QI 20))
5285 (clobber (reg:CC_NOOV 21))]
5286 "TARGET_DB && TARGET_LOOP_UNSIGNED"
5287 "*
5288 if (which_alternative == 0)
5289 return \"dbu%#\\t%0,%l1\";
5290 else if (which_alternative == 1)
5291 return c4x_output_cbranch (\"subi\\t1,%0\\n\\tbge\", insn);
5292 else if (which_alternative == 2)
5293 return c4x_output_cbranch (\"subi\\t1,%0\\n\\tcmpi\\t0,%0\\n\\tbge\", insn);
5294 else
5295 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);
5296 "
5297 [(set_attr "type" "db,jmpc,jmpc,jmpc")])
5298
5299 (define_insn "*db_noclobber"
5300 [(set (pc)
5301 (if_then_else (ne (match_operand:QI 0 "addr_reg_operand" "+a")
5302 (const_int 0))
5303 (label_ref (match_operand 1 "" ""))
5304 (pc)))
5305 (set (match_dup 0)
5306 (plus:QI (match_dup 0)
5307 (const_int -1)))]
5308 "reload_completed && TARGET_DB && TARGET_LOOP_UNSIGNED"
5309 "dbu%#\\t%0,%l1"
5310 [(set_attr "type" "db")])
5311
5312 (define_split
5313 [(set (pc)
5314 (if_then_else (ne (match_operand:QI 0 "addr_reg_operand" "")
5315 (const_int 0))
5316 (label_ref (match_operand 1 "" ""))
5317 (pc)))
5318 (set (match_dup 0)
5319 (plus:QI (match_dup 0)
5320 (const_int -1)))
5321 (use (reg:QI 20))
5322 (clobber (reg:CC_NOOV 21))]
5323 "reload_completed && TARGET_DB && TARGET_LOOP_UNSIGNED"
5324 [(parallel [(set (pc)
5325 (if_then_else (ne (match_dup 0)
5326 (const_int 0))
5327 (label_ref (match_dup 1))
5328 (pc)))
5329 (set (match_dup 0)
5330 (plus:QI (match_dup 0)
5331 (const_int -1)))])]
5332 "")
5333
5334
5335 ; This insn is used for some loop tests, typically loops reversed when
5336 ; strength reduction is used. It is actually created when the instruction
5337 ; combination phase combines the special loop test. Since this insn
5338 ; is both a jump insn and has an output, it must deal with its own
5339 ; reloads, hence the `m' constraints.
5340
5341 ; The C4x does the decrement and then compares the result against zero.
5342 ; It branches if the result was greater than or equal to zero.
5343 ; In the RTL the comparison and decrement are assumed to happen
5344 ; at the same time so we bias the iteration counter with by -1
5345 ; when we make the test.
5346 (define_insn "decrement_and_branch_until_zero"
5347 [(set (pc)
5348 (if_then_else (ge (plus:QI (match_operand:QI 0 "addr_reg_operand" "+a,?*d,??*r,!m")
5349 (const_int -1))
5350 (const_int 0))
5351 (label_ref (match_operand 1 "" ""))
5352 (pc)))
5353 (set (match_dup 0)
5354 (plus:QI (match_dup 0)
5355 (const_int -1)))
5356 (use (reg:QI 20))
5357 (clobber (reg:CC_NOOV 21))]
5358 "TARGET_DB && (find_reg_note (insn, REG_NONNEG, 0) || TARGET_LOOP_UNSIGNED)"
5359 "*
5360 if (which_alternative == 0)
5361 return \"dbu%#\\t%0,%l1\";
5362 else if (which_alternative == 1)
5363 return c4x_output_cbranch (\"subi\\t1,%0\\n\\tbge\", insn);
5364 else if (which_alternative == 2)
5365 return c4x_output_cbranch (\"subi\\t1,%0\\n\\tcmpi\\t0,%0\\n\\tbge\", insn);
5366 else
5367 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);
5368 "
5369 [(set_attr "type" "db,jmpc,jmpc,jmpc")])
5370
5371 (define_insn "*decrement_and_branch_until_zero_noclobber"
5372 [(set (pc)
5373 (if_then_else (ge (plus:QI (match_operand:QI 0 "addr_reg_operand" "+a")
5374 (const_int -1))
5375 (const_int 0))
5376 (label_ref (match_operand 1 "" ""))
5377 (pc)))
5378 (set (match_dup 0)
5379 (plus:QI (match_dup 0)
5380 (const_int -1)))]
5381 "reload_completed && TARGET_DB && TARGET_LOOP_UNSIGNED"
5382 "dbu%#\\t%0,%l1"
5383 [(set_attr "type" "db")])
5384
5385 (define_split
5386 [(set (pc)
5387 (if_then_else (ge (plus:QI (match_operand:QI 0 "addr_reg_operand" "")
5388 (const_int -1))
5389 (const_int 0))
5390 (label_ref (match_operand 1 "" ""))
5391 (pc)))
5392 (set (match_dup 0)
5393 (plus:QI (match_dup 0)
5394 (const_int -1)))
5395 (use (reg:QI 20))
5396 (clobber (reg:CC_NOOV 21))]
5397 "reload_completed && TARGET_DB && TARGET_LOOP_UNSIGNED"
5398 [(parallel [(set (pc)
5399 (if_then_else (ge (plus:QI (match_dup 0)
5400 (const_int -1))
5401 (const_int 0))
5402 (label_ref (match_dup 1))
5403 (pc)))
5404 (set (match_dup 0)
5405 (plus:QI (match_dup 0)
5406 (const_int -1)))])]
5407 "")
5408
5409 ;
5410 ; MISC INSTRUCTIONS
5411 ;
5412
5413 ;
5414 ; NOP
5415 ;
5416 (define_insn "nop"
5417 [(const_int 0)]
5418 ""
5419 "nop")
5420 ; Default to misc type attr.
5421
5422 (define_insn "return_indirect_internal"
5423 [(return)
5424 (use (match_operand:QI 0 "reg_operand" ""))]
5425 "reload_completed"
5426 "bu%#\\t%0"
5427 [(set_attr "type" "jump")])
5428
5429 (define_expand "prologue"
5430 [(const_int 1)]
5431 ""
5432 "c4x_expand_prologue (); DONE;")
5433
5434 (define_expand "epilogue"
5435 [(const_int 1)]
5436 ""
5437 "c4x_expand_epilogue (); DONE;")
5438
5439 ;
5440 ; RPTB
5441 ;
5442 (define_insn "rptb_top"
5443 [(use (label_ref (match_operand 0 "" "")))
5444 (use (label_ref (match_operand 1 "" "")))
5445 (clobber (reg:QI 25))
5446 (clobber (reg:QI 26))]
5447 ""
5448 "*
5449 return ! final_sequence && c4x_rptb_rpts_p (insn, operands[0])
5450 ? \"rpts\\trc\" : \"rptb%#\\t%l1-1\";
5451 "
5452 [(set_attr "type" "repeat_top")])
5453
5454 (define_insn "rpts_top"
5455 [(unspec [(use (label_ref (match_operand 0 "" "")))
5456 (use (label_ref (match_operand 1 "" "")))] UNSPEC_RPTS)
5457 (clobber (reg:QI 25))
5458 (clobber (reg:QI 26))]
5459 ""
5460 "*
5461 return ! final_sequence && c4x_rptb_rpts_p (insn, operands[0])
5462 ? \"rpts\\trc\" : \"rptb%#\\t%l1-1\";
5463 "
5464 [(set_attr "type" "repeat")])
5465
5466 ; This pattern needs to be emitted at the start of the loop to
5467 ; say that RS and RE are loaded.
5468 (define_insn "rptb_init"
5469 [(unspec [(match_operand:QI 0 "register_operand" "va")] UNSPEC_RPTB_INIT)
5470 (clobber (reg:QI 25))
5471 (clobber (reg:QI 26))]
5472 ""
5473 ""
5474 [(set_attr "type" "repeat")])
5475
5476
5477 ; operand 0 is the loop count pseudo register
5478 ; operand 1 is the number of loop iterations or 0 if it is unknown
5479 ; operand 2 is the maximum number of loop iterations
5480 ; operand 3 is the number of levels of enclosed loops
5481 (define_expand "doloop_begin"
5482 [(use (match_operand 0 "register_operand" ""))
5483 (use (match_operand:QI 1 "const_int_operand" ""))
5484 (use (match_operand:QI 2 "const_int_operand" ""))
5485 (use (match_operand:QI 3 "const_int_operand" ""))]
5486 ""
5487 "if (INTVAL (operands[3]) > 1 || ! TARGET_RPTB)
5488 FAIL;
5489 emit_insn (gen_rptb_init (operands[0]));
5490 DONE;
5491 ")
5492
5493
5494 ; The RS (25) and RE (26) registers must be unviolate from the top of the loop
5495 ; to here.
5496 (define_insn "rptb_end"
5497 [(set (pc)
5498 (if_then_else (ge (match_operand:QI 0 "register_operand" "+v,?a,!*d,!*x*k,!m")
5499 (const_int 0))
5500 (label_ref (match_operand 1 "" ""))
5501 (pc)))
5502 (set (match_dup 0)
5503 (plus:QI (match_dup 0)
5504 (const_int -1)))
5505 (use (reg:QI 25))
5506 (use (reg:QI 26))
5507 (use (reg:QI 20))
5508 (clobber (reg:CC_NOOV 21))]
5509 ""
5510 "*
5511 if (which_alternative == 0)
5512 return c4x_rptb_nop_p (insn) ? \"nop\" : \"\";
5513 else if (which_alternative == 1 && TARGET_DB)
5514 return \"dbu%#\\t%0,%l1\";
5515 else if (which_alternative == 2)
5516 return c4x_output_cbranch (\"subi\\t1,%0\\n\\tbge\", insn);
5517 else if (which_alternative == 3 || (which_alternative == 1 && ! TARGET_DB))
5518 return c4x_output_cbranch (\"subi\\t1,%0\\n\\tcmpi\\t0,%0\\n\\tbge\", insn);
5519 else
5520 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);
5521 "
5522 [(set_attr "type" "repeat,db,jmpc,jmpc,jmpc")])
5523
5524 (define_split
5525 [(set (pc)
5526 (if_then_else (ge (match_operand:QI 0 "addr_reg_operand" "")
5527 (const_int 0))
5528 (label_ref (match_operand 1 "" ""))
5529 (pc)))
5530 (set (match_dup 0)
5531 (plus:QI (match_dup 0)
5532 (const_int -1)))
5533 (use (match_operand:QI 2 "const_int_operand" ""))
5534 (use (match_operand:QI 3 "const_int_operand" ""))
5535 (use (match_operand:QI 4 "const_int_operand" ""))
5536 (use (reg:QI 25))
5537 (use (reg:QI 26))
5538 (use (reg:QI 20))
5539 (clobber (reg:CC_NOOV 21))]
5540 "reload_completed"
5541 [(parallel [(set (pc)
5542 (if_then_else (ge (match_dup 0)
5543 (const_int 0))
5544 (label_ref (match_dup 1))
5545 (pc)))
5546 (set (match_dup 0)
5547 (plus:QI (match_dup 0)
5548 (const_int -1)))])]
5549 "")
5550
5551 ; operand 0 is the loop count pseudo register
5552 ; operand 1 is the number of loop iterations or 0 if it is unknown
5553 ; operand 2 is the maximum number of loop iterations
5554 ; operand 3 is the number of levels of enclosed loops
5555 ; operand 4 is the label to jump to at the top of the loop
5556 (define_expand "doloop_end"
5557 [(use (match_operand 0 "register_operand" ""))
5558 (use (match_operand:QI 1 "const_int_operand" ""))
5559 (use (match_operand:QI 2 "const_int_operand" ""))
5560 (use (match_operand:QI 3 "const_int_operand" ""))
5561 (use (label_ref (match_operand 4 "" "")))]
5562 ""
5563 "if (! TARGET_LOOP_UNSIGNED
5564 && (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > ((unsigned) 1 << 31))
5565 FAIL;
5566 if (INTVAL (operands[3]) > 1 || ! TARGET_RPTB)
5567 {
5568 /* The C30 maximum iteration count for DB is 2^24. */
5569 if (! TARGET_DB)
5570 FAIL;
5571 emit_jump_insn (gen_decrement_and_branch_until_zero (operands[0],
5572 operands[4]));
5573 DONE;
5574 }
5575 emit_jump_insn (gen_rptb_end (operands[0], operands[4]));
5576 DONE;
5577 ")
5578
5579 (define_expand "decrement_and_branch_on_count"
5580 [(parallel [(set (pc)
5581 (if_then_else (ge (match_operand:QI 0 "register_operand" "")
5582 (const_int 0))
5583 (label_ref (match_operand 1 "" ""))
5584 (pc)))
5585 (set (match_dup 0)
5586 (plus:QI (match_dup 0)
5587 (const_int -1)))
5588 (use (reg:QI 25))
5589 (use (reg:QI 26))
5590 (clobber (reg:CC_NOOV 21))])]
5591 "0"
5592 "")
5593
5594 (define_expand "movstrqi_small"
5595 [(parallel [(set (mem:BLK (match_operand:BLK 0 "src_operand" ""))
5596 (mem:BLK (match_operand:BLK 1 "src_operand" "")))
5597 (use (match_operand:QI 2 "immediate_operand" ""))
5598 (use (match_operand:QI 3 "immediate_operand" ""))
5599 (clobber (match_operand:QI 4 "ext_low_reg_operand" ""))])]
5600 ""
5601 "
5602 {
5603 rtx src, dst, tmp;
5604 rtx src_mem, dst_mem;
5605 int len;
5606 int i;
5607
5608 dst = operands[0];
5609 src = operands[1];
5610 len = INTVAL (operands[2]);
5611 tmp = operands[4];
5612
5613 src_mem = gen_rtx_MEM (QImode, src);
5614 dst_mem = gen_rtx_MEM (QImode, dst);
5615
5616 if (TARGET_PARALLEL)
5617 {
5618 emit_insn (gen_movqi (tmp, src_mem));
5619 emit_insn (gen_addqi3_noclobber (src, src, const1_rtx));
5620 for (i = 1; i < len; i++)
5621 {
5622 emit_insn (gen_movqi_parallel (tmp, src_mem, dst_mem, tmp));
5623 emit_insn (gen_addqi3_noclobber (src, src, const1_rtx));
5624 emit_insn (gen_addqi3_noclobber (dst, dst, const1_rtx));
5625 }
5626 emit_insn (gen_movqi (dst_mem, tmp));
5627 emit_insn (gen_addqi3_noclobber (dst, dst, const1_rtx));
5628 }
5629 else
5630 {
5631 for (i = 0; i < len; i++)
5632 {
5633 emit_insn (gen_movqi (tmp, src_mem));
5634 emit_insn (gen_movqi (dst_mem, tmp));
5635 emit_insn (gen_addqi3_noclobber (src, src, const1_rtx));
5636 emit_insn (gen_addqi3_noclobber (dst, dst, const1_rtx));
5637 }
5638 }
5639 DONE;
5640 }
5641 ")
5642
5643
5644 ;
5645 ; BLOCK MOVE
5646 ; We should probably get RC loaded when using RPTB automagically...
5647 ; There's probably no need to call _memcpy() if we don't get
5648 ; an immediate operand for the size. We could do a better job here
5649 ; than most memcpy() implementations.
5650 ; operand 2 is the number of bytes
5651 ; operand 3 is the shared alignment
5652 ; operand 4 is a scratch register
5653
5654 (define_insn "movstrqi_large"
5655 [(set (mem:BLK (match_operand:QI 0 "addr_reg_operand" "a"))
5656 (mem:BLK (match_operand:QI 1 "addr_reg_operand" "a")))
5657 (use (match_operand:QI 2 "immediate_operand" "i"))
5658 (use (match_operand:QI 3 "immediate_operand" ""))
5659 (clobber (match_operand:QI 4 "ext_low_reg_operand" "=&q"))
5660 (clobber (match_scratch:QI 5 "=0"))
5661 (clobber (match_scratch:QI 6 "=1"))
5662 (clobber (reg:QI 25))
5663 (clobber (reg:QI 26))
5664 (clobber (reg:QI 27))]
5665 ""
5666 "*
5667 {
5668 int i;
5669 int len = INTVAL (operands[2]);
5670
5671 output_asm_insn (\"ldiu\\t*%1++,%4\", operands);
5672 if (len < 8)
5673 {
5674 for (i = 1; i < len; i++)
5675 {
5676 output_asm_insn (\"sti\\t%4,*%0++\", operands);
5677 output_asm_insn (\"|| ldi\\t*%1++,%4\", operands);
5678 }
5679 }
5680 else
5681 {
5682 if (TARGET_RPTS_CYCLES (len))
5683 {
5684 output_asm_insn (\"rpts\\t%2-2\", operands);
5685 output_asm_insn (\"sti\\t%4,*%0++\", operands);
5686 output_asm_insn (\"|| ldi\\t*%1++,%4\", operands);
5687 }
5688 else
5689 {
5690 output_asm_insn (\"ldiu\\t%2-2,rc\", operands);
5691 output_asm_insn (\"rptb\\t$+1\", operands);
5692 output_asm_insn (\"sti\\t%4,*%0++\", operands);
5693 output_asm_insn (\"|| ldi\\t*%1++,%4\", operands);
5694 }
5695 }
5696 return \"sti\\t%4,*%0++\";
5697 }"
5698 [(set_attr "type" "multi")])
5699
5700 ; Operand 2 is the count, operand 3 is the alignment.
5701 (define_expand "movstrqi"
5702 [(parallel [(set (mem:BLK (match_operand:BLK 0 "src_operand" ""))
5703 (mem:BLK (match_operand:BLK 1 "src_operand" "")))
5704 (use (match_operand:QI 2 "immediate_operand" ""))
5705 (use (match_operand:QI 3 "immediate_operand" ""))])]
5706 ""
5707 "
5708 {
5709 rtx tmp;
5710 if (GET_CODE (operands[2]) != CONST_INT
5711 || INTVAL (operands[2]) > 32767
5712 || INTVAL (operands[2]) <= 0)
5713 {
5714 FAIL; /* Try to call _memcpy */
5715 }
5716
5717 operands[0] = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
5718 operands[1] = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
5719 tmp = gen_reg_rtx (QImode);
5720 /* Disabled because of reload problems. */
5721 if (0 && INTVAL (operands[2]) < 8)
5722 emit_insn (gen_movstrqi_small (operands[0], operands[1], operands[2],
5723 operands[3], tmp));
5724 else
5725 {
5726 emit_insn (gen_movstrqi_large (operands[0], operands[1], operands[2],
5727 operands[3], tmp));
5728 }
5729 DONE;
5730 }")
5731
5732
5733 (define_insn "*cmpstrqi"
5734 [(set (match_operand:QI 0 "ext_reg_operand" "=d")
5735 (compare:QI (mem:BLK (match_operand:QI 1 "addr_reg_operand" "+a"))
5736 (mem:BLK (match_operand:QI 2 "addr_reg_operand" "+a"))))
5737 (use (match_operand:QI 3 "immediate_operand" "i"))
5738 (use (match_operand:QI 4 "immediate_operand" ""))
5739 (clobber (match_operand:QI 5 "std_reg_operand" "=&c"))
5740 (clobber (reg:QI 21))]
5741 ""
5742 "*
5743 {
5744 output_asm_insn (\"ldi\\t%3-1,%5\", operands);
5745 output_asm_insn (\"$1:\tsubi3\\t*%1++,*%2++,%0\", operands);
5746 output_asm_insn (\"dbeq\\t%5,$1\", operands);
5747 return \"\";
5748 }")
5749
5750 (define_expand "cmpstrqi"
5751 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
5752 (compare:QI (match_operand:BLK 1 "general_operand" "")
5753 (match_operand:BLK 2 "general_operand" "")))
5754 (use (match_operand:QI 3 "immediate_operand" ""))
5755 (use (match_operand:QI 4 "immediate_operand" ""))
5756 (clobber (match_dup 5))
5757 (clobber (reg:QI 21))])]
5758 ""
5759 "
5760 {
5761 if (GET_CODE (operands[3]) != CONST_INT
5762 || INTVAL (operands[3]) > 32767
5763 || INTVAL (operands[3]) <= 0)
5764 {
5765 FAIL;
5766 }
5767 operands[1] = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
5768 operands[2] = copy_to_mode_reg (Pmode, XEXP (operands[2], 0));
5769 operands[5] = gen_reg_rtx (QImode);
5770 }")
5771
5772 ;
5773 ; TWO OPERAND LONG DOUBLE INSTRUCTIONS
5774 ;
5775
5776 (define_expand "movhf"
5777 [(set (match_operand:HF 0 "src_operand" "")
5778 (match_operand:HF 1 "src_operand" ""))]
5779 ""
5780 "if (c4x_emit_move_sequence (operands, HFmode))
5781 DONE;")
5782
5783 (define_insn "*movhf_noclobber_reg"
5784 [(set (match_operand:HF 0 "reg_operand" "=h")
5785 (match_operand:HF 1 "src_operand" "Hh"))]
5786 "GET_CODE (operands[1]) != MEM"
5787 "ldfu\\t%1,%0"
5788 [(set_attr "type" "unary")])
5789
5790 (define_insn "*movhf_noclobber"
5791 [(set (match_operand:HF 0 "dst_operand" "=h,m")
5792 (match_operand:HF 1 "src_operand" "Hm,h"))]
5793 "reg_operand (operands[0], HFmode) ^ reg_operand (operands[1], HFmode)"
5794 "#"
5795 [(set_attr "type" "multi,multi")])
5796
5797 (define_insn "*movhf_test"
5798 [(set (reg:CC 21)
5799 (compare:CC (match_operand:HF 1 "reg_operand" "h")
5800 (const_int 0)))
5801 (clobber (match_scratch:HF 0 "=h"))]
5802 ""
5803 "ldf\\t%1,%0"
5804 [(set_attr "type" "unarycc")])
5805
5806 (define_insn "*movhf_set"
5807 [(set (reg:CC 21)
5808 (compare:CC (match_operand:HF 1 "reg_operand" "h")
5809 (match_operand:HF 2 "fp_zero_operand" "G")))
5810 (set (match_operand:HF 0 "reg_operand" "=h")
5811 (match_dup 1))]
5812 ""
5813 "ldf\\t%1,%0"
5814 [(set_attr "type" "unarycc")])
5815
5816 (define_split
5817 [(set (match_operand:HF 0 "reg_operand" "")
5818 (match_operand:HF 1 "memory_operand" ""))]
5819 "reload_completed"
5820 [(set (match_dup 0) (float_extend:HF (match_dup 2)))
5821 (set (match_dup 0) (unspec:HF [(subreg:QI (match_dup 0) 0)
5822 (match_dup 3)] UNSPEC_LOADHF_INT))]
5823 "operands[2] = c4x_operand_subword (operands[1], 0, 1, HFmode);
5824 operands[3] = c4x_operand_subword (operands[1], 1, 1, HFmode);
5825 PUT_MODE (operands[2], QFmode);
5826 PUT_MODE (operands[3], QImode);")
5827
5828 (define_split
5829 [(set (match_operand:HF 0 "reg_operand" "")
5830 (match_operand:HF 1 "const_operand" ""))]
5831 "reload_completed && 0"
5832 [(set (match_dup 0) (float_extend:HF (match_dup 2)))
5833 (set (match_dup 0) (unspec:HF [(subreg:QI (match_dup 0) 0)
5834 (match_dup 3)] UNSPEC_LOADHF_INT))]
5835 "operands[2] = c4x_operand_subword (operands[1], 0, 1, HFmode);
5836 operands[3] = c4x_operand_subword (operands[1], 1, 1, HFmode);
5837 PUT_MODE (operands[2], QFmode);
5838 PUT_MODE (operands[3], QImode);")
5839
5840 (define_split
5841 [(set (match_operand:HF 0 "memory_operand" "")
5842 (match_operand:HF 1 "reg_operand" ""))]
5843 "reload_completed"
5844 [(set (match_dup 2) (float_truncate:QF (match_dup 1)))
5845 (set (match_dup 3) (unspec:QI [(match_dup 1)] UNSPEC_STOREHF_INT))]
5846 "operands[2] = c4x_operand_subword (operands[0], 0, 1, HFmode);
5847 operands[3] = c4x_operand_subword (operands[0], 1, 1, HFmode);
5848 PUT_MODE (operands[2], QFmode);
5849 PUT_MODE (operands[3], QImode);")
5850
5851 (define_insn "*loadhf_float"
5852 [(set (match_operand:HF 0 "reg_operand" "=h")
5853 (float_extend:HF (match_operand:QF 1 "src_operand" "fHm")))]
5854 ""
5855 "ldfu\\t%1,%0"
5856 [(set_attr "type" "unary")])
5857
5858 (define_insn "*loadhf_int"
5859 [(set (match_operand:HF 0 "reg_operand" "+h")
5860 (unspec:HF [(subreg:QI (match_dup 0) 0)
5861 (match_operand:QI 1 "src_operand" "rIm")] UNSPEC_LOADHF_INT))]
5862 ""
5863 "ldiu\\t%1,%0"
5864 [(set_attr "type" "unary")])
5865
5866 (define_insn "*storehf_float"
5867 [(set (match_operand:QF 0 "memory_operand" "=m")
5868 (float_truncate:QF (match_operand:HF 1 "reg_operand" "h")))]
5869 ""
5870 "stf\\t%1,%0"
5871 [(set_attr "type" "store")])
5872
5873 (define_insn "*storehf_int"
5874 [(set (match_operand:QI 0 "memory_operand" "=m")
5875 (unspec:QI [(match_operand:HF 1 "reg_operand" "h")] UNSPEC_STOREHF_INT))]
5876 ""
5877 "sti\\t%1,%0"
5878 [(set_attr "type" "store")])
5879
5880 (define_insn "extendqfhf2"
5881 [(set (match_operand:HF 0 "reg_operand" "=h")
5882 (float_extend:HF (match_operand:QF 1 "reg_operand" "h")))]
5883 ""
5884 "ldfu\\t%1,%0"
5885 [(set_attr "type" "unarycc")])
5886
5887 (define_insn "trunchfqf2"
5888 [(set (match_operand:QF 0 "reg_operand" "=h")
5889 (float_truncate:QF (match_operand:HF 1 "reg_operand" "0")))
5890 (clobber (reg:CC 21))]
5891 ""
5892 "andn\\t0ffh,%0"
5893 [(set_attr "type" "unarycc")])
5894
5895 ;
5896 ; PUSH/POP
5897 ;
5898 (define_insn "pushhf"
5899 [(set (mem:HF (pre_inc:QI (reg:QI 20)))
5900 (match_operand:HF 0 "reg_operand" "h"))]
5901 ""
5902 "#"
5903 [(set_attr "type" "multi")])
5904
5905 (define_split
5906 [(set (mem:HF (pre_inc:QI (reg:QI 20)))
5907 (match_operand:HF 0 "reg_operand" ""))]
5908 "reload_completed"
5909 [(set (mem:QF (pre_inc:QI (reg:QI 20)))
5910 (float_truncate:QF (match_dup 0)))
5911 (set (mem:QI (pre_inc:QI (reg:QI 20)))
5912 (unspec:QI [(match_dup 0)] UNSPEC_STOREHF_INT))]
5913 "")
5914
5915 (define_insn "pushhf_trunc"
5916 [(set (mem:QF (pre_inc:QI (reg:QI 20)))
5917 (float_truncate:QF (match_operand:HF 0 "reg_operand" "h")))]
5918 ""
5919 "pushf\\t%0"
5920 [(set_attr "type" "push")])
5921
5922 (define_insn "pushhf_int"
5923 [(set (mem:QI (pre_inc:QI (reg:QI 20)))
5924 (unspec:QI [(match_operand:HF 0 "reg_operand" "h")] UNSPEC_STOREHF_INT))]
5925 ""
5926 "push\\t%0"
5927 [(set_attr "type" "push")])
5928
5929 ; we can not use this because the popf will destroy the low 8 bits
5930 ;(define_insn "pophf"
5931 ; [(set (match_operand:HF 0 "reg_operand" "=h")
5932 ; (mem:HF (post_dec:QI (reg:QI 20))))
5933 ; (clobber (reg:CC 21))]
5934 ; ""
5935 ; "#"
5936 ; [(set_attr "type" "multi")])
5937
5938 (define_split
5939 [(set (match_operand:HF 0 "reg_operand" "")
5940 (mem:HF (post_dec:QI (reg:QI 20))))
5941 (clobber (reg:CC 21))]
5942 "reload_completed"
5943 [(parallel [(set (match_operand:HF 0 "reg_operand" "=h")
5944 (float_extend:HF (mem:QF (post_dec:QI (reg:QI 20)))))
5945 (clobber (reg:CC 21))])
5946 (parallel [(set (match_dup 0)
5947 (unspec:HF [(subreg:QI (match_dup 0) 0)
5948 (mem:QI (post_dec:QI (reg:QI 20)))] UNSPEC_LOADHF_INT))
5949 (clobber (reg:CC 21))])]
5950 "")
5951
5952 (define_insn "*pophf_int"
5953 [(set (match_operand:HF 0 "reg_operand" "+h")
5954 (unspec:HF [(subreg:QI (match_dup 0) 0)
5955 (mem:QI (post_dec:QI (reg:QI 20)))] UNSPEC_LOADHF_INT))
5956 (clobber (reg:CC 21))]
5957 ""
5958 "pop\\t%0"
5959 [(set_attr "type" "pop")])
5960
5961 (define_insn "*pophf_float"
5962 [(set (match_operand:HF 0 "reg_operand" "=h")
5963 (float_extend:HF (mem:QF (post_dec:QI (reg:QI 20)))))
5964 (clobber (reg:CC 21))]
5965 ""
5966 "popf\\t%0"
5967 [(set_attr "type" "pop")])
5968
5969 ;
5970 ; FIX
5971 ;
5972 (define_expand "fixuns_trunchfqi2"
5973 [(parallel [(set (match_dup 2)
5974 (fix:QI (match_operand:HF 1 "reg_or_const_operand" "hH")))
5975 (clobber (reg:CC 21))])
5976 (parallel [(set (match_dup 3)
5977 (minus:HF (match_dup 1) (match_dup 5)))
5978 (clobber (reg:CC_NOOV 21))])
5979 (parallel [(set (reg:CC 21)
5980 (compare:CC (fix:QI (match_dup 3))
5981 (const_int 0)))
5982 (set (match_dup 4)
5983 (fix:QI (match_dup 3)))])
5984 (parallel [(set (match_dup 4) (unspec:QI [(match_dup 2)] UNSPEC_LDIV))
5985 (use (reg:CC 21))])
5986 (set (match_operand:QI 0 "reg_operand" "=r") (match_dup 4))]
5987 ""
5988 "operands[2] = gen_reg_rtx (QImode);
5989 operands[3] = gen_reg_rtx (HFmode);
5990 operands[4] = gen_reg_rtx (QImode);
5991 operands[5] = gen_reg_rtx (HFmode);
5992 emit_move_insn (operands[5], CONST_DOUBLE_ATOF (\"4294967296.0\", HFmode));")
5993
5994 (define_expand "fix_trunchfqi2"
5995 [(parallel [(set (match_dup 2)
5996 (fix:QI (match_operand:HF 1 "reg_or_const_operand" "")))
5997 (clobber (reg:CC 21))])
5998 (parallel [(set (match_dup 3) (neg:HF (match_dup 1)))
5999 (clobber (reg:CC_NOOV 21))])
6000 (parallel [(set (match_dup 4) (fix:QI (match_dup 3)))
6001 (clobber (reg:CC 21))])
6002 (parallel [(set (reg:CC_NOOV 21)
6003 (compare:CC_NOOV (neg:QI (match_dup 4)) (const_int 0)))
6004 (set (match_dup 5) (neg:QI (match_dup 4)))])
6005 (set (match_dup 2)
6006 (if_then_else:QI (le (reg:CC 21) (const_int 0))
6007 (match_dup 5)
6008 (match_dup 2)))
6009 (set (match_operand:QI 0 "reg_operand" "=r") (match_dup 2))]
6010 ""
6011 "if (TARGET_FAST_FIX)
6012 {
6013 emit_insn (gen_fixhfqi_clobber (operands[0], operands[1]));
6014 DONE;
6015 }
6016 operands[2] = gen_reg_rtx (QImode);
6017 operands[3] = gen_reg_rtx (HFmode);
6018 operands[4] = gen_reg_rtx (QImode);
6019 operands[5] = gen_reg_rtx (QImode);
6020 ")
6021
6022 (define_insn "*fixhfqi_set"
6023 [(set (reg:CC 21)
6024 (compare:CC (fix:QI (match_operand:HF 1 "reg_or_const_operand" "hH"))
6025 (const_int 0)))
6026 (set (match_operand:QI 0 "ext_reg_operand" "=d")
6027 (fix:QI (match_dup 1)))]
6028 ""
6029 "fix\\t%1,%0"
6030 [(set_attr "type" "unarycc")])
6031
6032 (define_insn "fixhfqi_clobber"
6033 [(set (match_operand:QI 0 "reg_operand" "=dc")
6034 (fix:QI (match_operand:HF 1 "reg_or_const_operand" "hH")))
6035 (clobber (reg:CC 21))]
6036 ""
6037 "fix\\t%1,%0"
6038 [(set_attr "type" "unarycc")])
6039
6040 (define_expand "fix_trunchfhi2"
6041 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6042 (fix:HI (match_operand:HF 1 "reg_operand" "")))
6043 (clobber (reg:CC 21))])]
6044 ""
6045 "c4x_emit_libcall (fix_trunchfhi2_libfunc, FIX, HImode, HFmode, 2, operands);
6046 DONE;")
6047
6048 (define_expand "fixuns_trunchfhi2"
6049 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6050 (unsigned_fix:HI (match_operand:HF 1 "reg_operand" "")))
6051 (clobber (reg:CC 21))])]
6052 ""
6053 "c4x_emit_libcall (fixuns_trunchfhi2_libfunc, UNSIGNED_FIX,
6054 HImode, HFmode, 2, operands);
6055 DONE;")
6056
6057 ;
6058 ; ABSF
6059 ;
6060 (define_expand "abshf2"
6061 [(parallel [(set (match_operand:HF 0 "reg_operand" "")
6062 (abs:HF (match_operand:HF 1 "reg_or_const_operand" "")))
6063 (clobber (reg:CC_NOOV 21))])]
6064 ""
6065 "")
6066
6067 (define_insn "*abshf2_clobber"
6068 [(set (match_operand:HF 0 "reg_operand" "=h")
6069 (abs:HF (match_operand:HF 1 "reg_or_const_operand" "hH")))
6070 (clobber (reg:CC_NOOV 21))]
6071 ""
6072 "absf\\t%1,%0"
6073 [(set_attr "type" "unarycc")])
6074
6075 (define_insn "*abshf2_test"
6076 [(set (reg:CC_NOOV 21)
6077 (compare:CC_NOOV (abs:HF (match_operand:HF 1 "reg_operand" "h"))
6078 (match_operand:HF 2 "fp_zero_operand" "G")))
6079 (clobber (match_scratch:HF 0 "=h"))]
6080 ""
6081 "absf\\t%1,%0"
6082 [(set_attr "type" "unarycc")])
6083
6084 (define_insn "*abshf2_set"
6085 [(set (reg:CC_NOOV 21)
6086 (compare:CC_NOOV (abs:HF (match_operand:HF 1 "reg_or_const_operand" "hH"))
6087 (match_operand:HF 2 "fp_zero_operand" "G")))
6088 (set (match_operand:HF 0 "reg_operand" "=h")
6089 (abs:HF (match_dup 1)))]
6090
6091 ""
6092 "absf\\t%1,%0"
6093 [(set_attr "type" "unarycc")])
6094
6095 ;
6096 ; NEGF
6097 ;
6098 (define_expand "neghf2"
6099 [(parallel [(set (match_operand:HF 0 "reg_operand" "")
6100 (neg:HF (match_operand:HF 1 "reg_or_const_operand" "")))
6101 (clobber (reg:CC_NOOV 21))])]
6102 ""
6103 "")
6104
6105 (define_insn "*neghf2_clobber"
6106 [(set (match_operand:HF 0 "reg_operand" "=h")
6107 (neg:HF (match_operand:HF 1 "reg_or_const_operand" "hH")))
6108 (clobber (reg:CC_NOOV 21))]
6109 ""
6110 "negf\\t%1,%0"
6111 [(set_attr "type" "unarycc")])
6112
6113 (define_insn "*neghf2_test"
6114 [(set (reg:CC_NOOV 21)
6115 (compare:CC_NOOV (neg:HF (match_operand:HF 1 "reg_or_const_operand" "hH"))
6116 (match_operand:HF 2 "fp_zero_operand" "G")))
6117 (clobber (match_scratch:HF 0 "=h"))]
6118 ""
6119 "negf\\t%1,%0"
6120 [(set_attr "type" "unarycc")])
6121
6122 (define_insn "*neghf2_set"
6123 [(set (reg:CC_NOOV 21)
6124 (compare:CC_NOOV (neg:HF (match_operand:HF 1 "reg_or_const_operand" "hH"))
6125 (match_operand:HF 2 "fp_zero_operand" "G")))
6126 (set (match_operand:HF 0 "reg_operand" "=h")
6127 (neg:HF (match_dup 1)))]
6128 ""
6129 "negf\\t%1,%0"
6130 [(set_attr "type" "unarycc")])
6131
6132 ;
6133 ; RCPF
6134 ;
6135 (define_insn "*rcpfhf_clobber"
6136 [(set (match_operand:HF 0 "reg_operand" "=h")
6137 (unspec:HF [(match_operand:HF 1 "reg_or_const_operand" "hH")] UNSPEC_RCPF))
6138 (clobber (reg:CC_NOOV 21))]
6139 "! TARGET_C3X"
6140 "rcpf\\t%1,%0"
6141 [(set_attr "type" "unarycc")])
6142
6143 ;
6144 ; RSQRF
6145 ;
6146 (define_insn "*rsqrfhf_clobber"
6147 [(set (match_operand:HF 0 "reg_operand" "=h")
6148 (unspec:HF [(match_operand:HF 1 "reg_or_const_operand" "hH")] UNSPEC_RSQRF))
6149 (clobber (reg:CC_NOOV 21))]
6150 "! TARGET_C3X"
6151 "rsqrf\\t%1,%0"
6152 [(set_attr "type" "unarycc")])
6153
6154 ;
6155 ; RNDF
6156 ;
6157 (define_insn "*rndhf_clobber"
6158 [(set (match_operand:HF 0 "reg_operand" "=h")
6159 (unspec:HF [(match_operand:HF 1 "reg_or_const_operand" "hH")] UNSPEC_RND))
6160 (clobber (reg:CC_NOOV 21))]
6161 "! TARGET_C3X"
6162 "rnd\\t%1,%0"
6163 [(set_attr "type" "unarycc")])
6164
6165
6166 ; Inlined float square root for C4x
6167 (define_expand "sqrthf2_inline"
6168 [(parallel [(set (match_dup 2)
6169 (unspec:HF [(match_operand:HF 1 "reg_operand" "")] UNSPEC_RSQRF))
6170 (clobber (reg:CC_NOOV 21))])
6171 (parallel [(set (match_dup 3) (mult:HF (match_dup 5) (match_dup 1)))
6172 (clobber (reg:CC_NOOV 21))])
6173 (parallel [(set (match_dup 4) (mult:HF (match_dup 2) (match_dup 3)))
6174 (clobber (reg:CC_NOOV 21))])
6175 (parallel [(set (match_dup 4) (mult:HF (match_dup 2) (match_dup 4)))
6176 (clobber (reg:CC_NOOV 21))])
6177 (parallel [(set (match_dup 4) (minus:HF (match_dup 6) (match_dup 4)))
6178 (clobber (reg:CC_NOOV 21))])
6179 (parallel [(set (match_dup 2) (mult:HF (match_dup 2) (match_dup 4)))
6180 (clobber (reg:CC_NOOV 21))])
6181 (parallel [(set (match_dup 4) (mult:HF (match_dup 2) (match_dup 3)))
6182 (clobber (reg:CC_NOOV 21))])
6183 (parallel [(set (match_dup 4) (mult:HF (match_dup 2) (match_dup 4)))
6184 (clobber (reg:CC_NOOV 21))])
6185 (parallel [(set (match_dup 4) (minus:HF (match_dup 6) (match_dup 4)))
6186 (clobber (reg:CC_NOOV 21))])
6187 (parallel [(set (match_dup 2) (mult:HF (match_dup 2) (match_dup 4)))
6188 (clobber (reg:CC_NOOV 21))])
6189 (parallel [(set (match_operand:HF 0 "reg_operand" "")
6190 (mult:HF (match_dup 2) (match_dup 1)))
6191 (clobber (reg:CC_NOOV 21))])]
6192 "! TARGET_C3X"
6193 "
6194 operands[2] = gen_reg_rtx (HFmode);
6195 operands[3] = gen_reg_rtx (HFmode);
6196 operands[4] = gen_reg_rtx (HFmode);
6197 operands[5] = CONST_DOUBLE_ATOF (\"0.5\", HFmode);
6198 operands[6] = CONST_DOUBLE_ATOF (\"1.5\", HFmode);
6199 ")
6200
6201
6202 (define_expand "sqrthf2"
6203 [(parallel [(set (match_operand:HF 0 "reg_operand" "")
6204 (sqrt:HF (match_operand:HF 1 "reg_operand" "")))
6205 (clobber (reg:CC 21))])]
6206 "! TARGET_C3X && TARGET_INLINE"
6207 "emit_insn (gen_sqrthf2_inline (operands[0], operands[1]));
6208 DONE;")
6209
6210 ;
6211 ; THREE OPERAND LONG DOUBLE INSTRUCTIONS
6212 ;
6213
6214 ;
6215 ; ADDF
6216 ;
6217 (define_insn "addhf3"
6218 [(set (match_operand:HF 0 "reg_operand" "=h,?h")
6219 (plus:HF (match_operand:HF 1 "reg_operand" "%0,h")
6220 (match_operand:HF 2 "reg_or_const_operand" "H,h")))
6221 (clobber (reg:CC_NOOV 21))]
6222 ""
6223 "@
6224 addf\\t%2,%0
6225 addf3\\t%2,%1,%0"
6226 [(set_attr "type" "binarycc,binarycc")])
6227
6228 ;
6229 ; SUBF
6230 ;
6231 (define_insn "subhf3"
6232 [(set (match_operand:HF 0 "reg_operand" "=h,h,?h")
6233 (minus:HF (match_operand:HF 1 "reg_or_const_operand" "0,H,h")
6234 (match_operand:HF 2 "reg_or_const_operand" "H,0,h")))
6235 (clobber (reg:CC_NOOV 21))]
6236 ""
6237 "@
6238 subf\\t%2,%0
6239 subrf\\t%1,%0
6240 subf3\\t%2,%1,%0"
6241 [(set_attr "type" "binarycc,binarycc,binarycc")])
6242
6243 ;
6244 ; MULF
6245 ;
6246 ; The C3x MPYF only uses 24-bit precision while the C4x uses 32-bit precision.
6247 ;
6248 (define_expand "mulhf3"
6249 [(parallel [(set (match_operand:HF 0 "reg_operand" "=h")
6250 (mult:HF (match_operand:HF 1 "reg_operand" "h")
6251 (match_operand:HF 2 "reg_operand" "h")))
6252 (clobber (reg:CC_NOOV 21))])]
6253 "! TARGET_C3X"
6254 "")
6255
6256 (define_insn "*mulhf3_c40"
6257 [(set (match_operand:HF 0 "reg_operand" "=h,?h")
6258 (mult:HF (match_operand:HF 1 "reg_operand" "%0,h")
6259 (match_operand:HF 2 "reg_or_const_operand" "hH,h")))
6260 (clobber (reg:CC_NOOV 21))]
6261 ""
6262 "@
6263 mpyf\\t%2,%0
6264 mpyf3\\t%2,%1,%0"
6265 [(set_attr "type" "binarycc,binarycc")])
6266
6267 ;
6268 ; CMPF
6269 ;
6270 (define_expand "cmphf"
6271 [(set (reg:CC 21)
6272 (compare:CC (match_operand:HF 0 "reg_operand" "")
6273 (match_operand:HF 1 "reg_or_const_operand" "")))]
6274 ""
6275 "c4x_compare_op0 = operands[0];
6276 c4x_compare_op1 = operands[1];
6277 DONE;")
6278
6279 (define_insn "*cmphf"
6280 [(set (reg:CC 21)
6281 (compare:CC (match_operand:HF 0 "reg_operand" "h")
6282 (match_operand:HF 1 "reg_or_const_operand" "hH")))]
6283 ""
6284 "cmpf\\t%1,%0"
6285 [(set_attr "type" "compare")])
6286
6287 (define_insn "*cmphf_noov"
6288 [(set (reg:CC_NOOV 21)
6289 (compare:CC_NOOV (match_operand:HF 0 "reg_operand" "h")
6290 (match_operand:HF 1 "reg_or_const_operand" "hH")))]
6291 ""
6292 "cmpf\\t%1,%0"
6293 [(set_attr "type" "compare")])
6294
6295 ; Inlined float divide for C4x
6296 (define_expand "divhf3_inline"
6297 [(parallel [(set (match_dup 3)
6298 (unspec:HF [(match_operand:HF 2 "reg_operand" "")] UNSPEC_RCPF))
6299 (clobber (reg:CC_NOOV 21))])
6300 (parallel [(set (match_dup 4) (mult:HF (match_dup 2) (match_dup 3)))
6301 (clobber (reg:CC_NOOV 21))])
6302 (parallel [(set (match_dup 4) (minus:HF (match_dup 5) (match_dup 4)))
6303 (clobber (reg:CC_NOOV 21))])
6304 (parallel [(set (match_dup 3) (mult:HF (match_dup 3) (match_dup 4)))
6305 (clobber (reg:CC_NOOV 21))])
6306 (parallel [(set (match_dup 4) (mult:HF (match_dup 2) (match_dup 3)))
6307 (clobber (reg:CC_NOOV 21))])
6308 (parallel [(set (match_dup 4) (minus:HF (match_dup 5) (match_dup 4)))
6309 (clobber (reg:CC_NOOV 21))])
6310 (parallel [(set (match_dup 3) (mult:HF (match_dup 3) (match_dup 4)))
6311 (clobber (reg:CC_NOOV 21))])
6312 (parallel [(set (match_operand:HF 0 "reg_operand" "")
6313 (mult:HF (match_operand:HF 1 "reg_operand" "")
6314 (match_dup 3)))
6315 (clobber (reg:CC_NOOV 21))])]
6316 "! TARGET_C3X"
6317 "
6318 operands[3] = gen_reg_rtx (HFmode);
6319 operands[4] = gen_reg_rtx (HFmode);
6320 operands[5] = CONST2_RTX (HFmode);
6321 ")
6322
6323 (define_expand "divhf3"
6324 [(parallel [(set (match_operand:HF 0 "reg_operand" "")
6325 (div:HF (match_operand:HF 1 "reg_operand" "")
6326 (match_operand:HF 2 "reg_operand" "")))
6327 (clobber (reg:CC 21))])]
6328 "! TARGET_C3X && TARGET_INLINE"
6329 "emit_insn (gen_divhf3_inline (operands[0], operands[1], operands[2]));
6330 DONE;")
6331
6332
6333 ;
6334 ; TWO OPERAND LONG LONG INSTRUCTIONS
6335 ;
6336
6337 (define_insn "*movhi_stik"
6338 [(set (match_operand:HI 0 "memory_operand" "=m")
6339 (match_operand:HI 1 "stik_const_operand" "K"))]
6340 "! TARGET_C3X"
6341 "#"
6342 [(set_attr "type" "multi")])
6343
6344 ; We could load some constants using define_splits for the C30
6345 ; in the large memory model---these would emit shift and or insns.
6346 (define_expand "movhi"
6347 [(set (match_operand:HI 0 "src_operand" "")
6348 (match_operand:HI 1 "src_operand" ""))]
6349 ""
6350 "if (c4x_emit_move_sequence (operands, HImode))
6351 DONE;")
6352
6353 ; The constraints for movhi must include 'r' if we don't
6354 ; restrict HImode regnos to start on an even number, since
6355 ; we can get RC, R8 allocated as a pair. We want more
6356 ; votes for FP_REGS so we use dr as the constraints.
6357 (define_insn "*movhi_noclobber"
6358 [(set (match_operand:HI 0 "dst_operand" "=dr,m")
6359 (match_operand:HI 1 "src_operand" "drIm,r"))]
6360 "reg_operand (operands[0], HImode)
6361 || reg_operand (operands[1], HImode)"
6362 "#"
6363 [(set_attr "type" "multi,multi")])
6364
6365 ; This will fail miserably if the destination register is used in the
6366 ; source memory address.
6367 ; The usual strategy in this case is to swap the order of insns we emit,
6368 ; however, this will fail if we have an autoincrement memory address.
6369 ; For example:
6370 ; ldi *ar0++, ar0
6371 ; ldi *ar0++, ar1
6372 ;
6373 ; We could convert this to
6374 ; ldi *ar0(1), ar1
6375 ; ldi *ar0, ar0
6376 ;
6377 ; However, things are likely to be very screwed up if we get this.
6378
6379 (define_split
6380 [(set (match_operand:HI 0 "dst_operand" "")
6381 (match_operand:HI 1 "src_operand" ""))]
6382 "reload_completed
6383 && (reg_operand (operands[0], HImode)
6384 || reg_operand (operands[1], HImode)
6385 || stik_const_operand (operands[1], HImode))"
6386 [(set (match_dup 2) (match_dup 4))
6387 (set (match_dup 3) (match_dup 5))]
6388 "operands[2] = c4x_operand_subword (operands[0], 0, 1, HImode);
6389 operands[3] = c4x_operand_subword (operands[0], 1, 1, HImode);
6390 operands[4] = c4x_operand_subword (operands[1], 0, 1, HImode);
6391 operands[5] = c4x_operand_subword (operands[1], 1, 1, HImode);
6392 if (reg_overlap_mentioned_p (operands[2], operands[5]))
6393 {
6394 /* Swap order of move insns. */
6395 rtx tmp;
6396 tmp = operands[2];
6397 operands[2] =operands[3];
6398 operands[3] = tmp;
6399 tmp = operands[4];
6400 operands[4] =operands[5];
6401 operands[5] = tmp;
6402 }")
6403
6404
6405 (define_insn "extendqihi2"
6406 [(set (match_operand:HI 0 "reg_operand" "=dc")
6407 (sign_extend:HI (match_operand:QI 1 "src_operand" "rIm")))
6408 (clobber (reg:CC 21))]
6409 ""
6410 "#"
6411 [(set_attr "type" "multi")])
6412
6413 (define_split
6414 [(set (match_operand:HI 0 "reg_operand" "")
6415 (sign_extend:HI (match_operand:QI 1 "src_operand" "")))
6416 (clobber (reg:CC 21))]
6417 "reload_completed && TARGET_C3X"
6418 [(set (match_dup 2) (match_dup 1))
6419 (set (match_dup 3) (match_dup 2))
6420 (parallel [(set (match_dup 3) (ashiftrt:QI (match_dup 3) (const_int 31)))
6421 (clobber (reg:CC 21))])]
6422 "operands[2] = c4x_operand_subword (operands[0], 0, 0, HImode);
6423 operands[3] = c4x_operand_subword (operands[0], 1, 0, HImode);")
6424
6425 (define_split
6426 [(set (match_operand:HI 0 "reg_operand" "")
6427 (sign_extend:HI (match_operand:QI 1 "src_operand" "")))
6428 (clobber (reg:CC 21))]
6429 "reload_completed && ! TARGET_C3X"
6430 [(set (match_dup 2) (match_dup 1))
6431 (parallel [(set (match_dup 3) (ashiftrt:QI (match_dup 2) (const_int 31)))
6432 (clobber (reg:CC 21))])]
6433 "operands[2] = c4x_operand_subword (operands[0], 0, 0, HImode);
6434 operands[3] = c4x_operand_subword (operands[0], 1, 0, HImode);")
6435
6436 (define_insn "zero_extendqihi2"
6437 [(set (match_operand:HI 0 "reg_operand" "=?dc")
6438 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "rm")))
6439 (clobber (reg:CC 21))]
6440 ""
6441 "#"
6442 [(set_attr "type" "multi")])
6443
6444 ; If operand0 and operand1 are the same register we don't need
6445 ; the first set.
6446 (define_split
6447 [(set (match_operand:HI 0 "reg_operand" "")
6448 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "")))
6449 (clobber (reg:CC 21))]
6450 "reload_completed"
6451 [(set (match_dup 2) (match_dup 1))
6452 (set (match_dup 3) (const_int 0))]
6453 "operands[2] = c4x_operand_subword (operands[0], 0, 0, HImode);
6454 operands[3] = c4x_operand_subword (operands[0], 1, 0, HImode);")
6455
6456 ;
6457 ; PUSH/POP
6458 ;
6459 (define_insn "*pushhi"
6460 [(set (mem:HI (pre_inc:QI (reg:QI 20)))
6461 (match_operand:HI 0 "reg_operand" "r"))]
6462 ""
6463 "#"
6464 [(set_attr "type" "multi")])
6465
6466 (define_split
6467 [(set (mem:HI (pre_inc:QI (reg:QI 20)))
6468 (match_operand:HI 0 "reg_operand" ""))]
6469 "reload_completed"
6470 [(set (mem:QI (pre_inc:QI (reg:QI 20))) (match_dup 2))
6471 (set (mem:QI (pre_inc:QI (reg:QI 20))) (match_dup 3))]
6472 "operands[2] = c4x_operand_subword (operands[0], 0, 0, HImode);
6473 operands[3] = c4x_operand_subword (operands[0], 1, 0, HImode);")
6474
6475 (define_insn "*pophi"
6476 [(set (match_operand:HI 0 "reg_operand" "=r")
6477 (mem:HI (post_dec:QI (reg:QI 20))))
6478 (clobber (reg:CC 21))]
6479 ""
6480 "#"
6481 [(set_attr "type" "multi")])
6482
6483 (define_split
6484 [(set (match_operand:HI 0 "reg_operand" "")
6485 (mem:HI (pre_inc:QI (reg:QI 20))))]
6486 "reload_completed"
6487 [(set (match_dup 2) (mem:QI (pre_inc:QI (reg:QI 20))))
6488 (set (match_dup 3) (mem:QI (pre_inc:QI (reg:QI 20))))]
6489 "operands[2] = c4x_operand_subword (operands[0], 0, 0, HImode);
6490 operands[3] = c4x_operand_subword (operands[0], 1, 0, HImode);")
6491
6492 ;
6493 ; NEG
6494 ;
6495 (define_insn "neghi2"
6496 [(set (match_operand:HI 0 "ext_reg_operand" "=d")
6497 (neg:HI (match_operand:HI 1 "src_operand" "rm")))
6498 (clobber (reg:CC_NOOV 21))]
6499 ""
6500 "#"
6501 [(set_attr "type" "multi")])
6502
6503 (define_split
6504 [(set (match_operand:HI 0 "ext_reg_operand" "")
6505 (neg:HI (match_operand:HI 1 "src_operand" "")))
6506 (clobber (reg:CC_NOOV 21))]
6507 "reload_completed"
6508 [(parallel [(set (reg:CC_NOOV 21)
6509 (compare:CC_NOOV (neg:QI (match_dup 3))
6510 (const_int 0)))
6511 (set (match_dup 2) (neg:QI (match_dup 3)))])
6512 (parallel [(set (match_dup 4) (neg:QI (match_dup 5)))
6513 (use (reg:CC_NOOV 21))
6514 (clobber (reg:CC_NOOV 21))])]
6515 "operands[2] = c4x_operand_subword (operands[0], 0, 1, HImode);
6516 operands[3] = c4x_operand_subword (operands[1], 0, 1, HImode);
6517 operands[4] = c4x_operand_subword (operands[0], 1, 1, HImode);
6518 operands[5] = c4x_operand_subword (operands[1], 1, 1, HImode);")
6519
6520 (define_insn "one_cmplhi2"
6521 [(set (match_operand:HI 0 "reg_operand" "=r")
6522 (not:HI (match_operand:HI 1 "src_operand" "rm")))
6523 (clobber (reg:CC 21))]
6524 ""
6525 "#"
6526 [(set_attr "type" "multi")])
6527
6528 (define_split
6529 [(set (match_operand:HI 0 "reg_operand" "")
6530 (not:HI (match_operand:HI 1 "src_operand" "")))
6531 (clobber (reg:CC 21))]
6532 "reload_completed"
6533 [(parallel [(set (match_dup 2) (not:QI (match_dup 3)))
6534 (clobber (reg:CC 21))])
6535 (parallel [(set (match_dup 4) (not:QI (match_dup 5)))
6536 (clobber (reg:CC 21))])]
6537 "operands[2] = c4x_operand_subword (operands[0], 0, 1, HImode);
6538 operands[3] = c4x_operand_subword (operands[1], 0, 1, HImode);
6539 operands[4] = c4x_operand_subword (operands[0], 1, 1, HImode);
6540 operands[5] = c4x_operand_subword (operands[1], 1, 1, HImode);")
6541
6542 (define_expand "floathiqf2"
6543 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
6544 (float:QF (match_operand:HI 1 "src_operand" "")))
6545 (clobber (reg:CC 21))])]
6546 ""
6547 "c4x_emit_libcall (floathiqf2_libfunc, FLOAT, QFmode, HImode, 2, operands);
6548 DONE;")
6549
6550 (define_expand "floatunshiqf2"
6551 [(parallel [(set (match_operand:QF 0 "reg_operand" "")
6552 (unsigned_float:QF (match_operand:HI 1 "src_operand" "")))
6553 (clobber (reg:CC 21))])]
6554 ""
6555 "c4x_emit_libcall (floatunshiqf2_libfunc, UNSIGNED_FLOAT,
6556 QFmode, HImode, 2, operands);
6557 DONE;")
6558
6559 (define_expand "floathihf2"
6560 [(parallel [(set (match_operand:HF 0 "reg_operand" "")
6561 (float:HF (match_operand:HI 1 "src_operand" "")))
6562 (clobber (reg:CC 21))])]
6563 ""
6564 "c4x_emit_libcall (floathihf2_libfunc, FLOAT, HFmode, HImode, 2, operands);
6565 DONE;")
6566
6567 (define_expand "floatunshihf2"
6568 [(parallel [(set (match_operand:HF 0 "reg_operand" "")
6569 (unsigned_float:HF (match_operand:HI 1 "src_operand" "")))
6570 (clobber (reg:CC 21))])]
6571 ""
6572 "c4x_emit_libcall (floatunshihf2_libfunc, UNSIGNED_FLOAT,
6573 HFmode, HImode, 2, operands);
6574 DONE;")
6575
6576
6577 ;
6578 ; THREE OPERAND LONG LONG INSTRUCTIONS
6579 ;
6580
6581 (define_expand "addhi3"
6582 [(parallel [(set (match_operand:HI 0 "ext_reg_operand" "")
6583 (plus:HI (match_operand:HI 1 "src_operand" "")
6584 (match_operand:HI 2 "src_operand" "")))
6585 (clobber (reg:CC_NOOV 21))])]
6586 ""
6587 "legitimize_operands (PLUS, operands, HImode);")
6588
6589 (define_insn "*addhi3_clobber"
6590 [(set (match_operand:HI 0 "ext_reg_operand" "=d,d,?d")
6591 (plus:HI (match_operand:HI 1 "src_operand" "%0,rR,rS<>")
6592 (match_operand:HI 2 "src_operand" "rm,R,rS<>")))
6593 (clobber (reg:CC_NOOV 21))]
6594 "valid_operands (PLUS, operands, HImode)"
6595 "#"
6596 [(set_attr "type" "multi,multi,multi")])
6597
6598 (define_split
6599 [(set (match_operand:HI 0 "ext_reg_operand" "")
6600 (plus:HI (match_operand:HI 1 "src_operand" "")
6601 (match_operand:HI 2 "src_operand" "")))
6602 (clobber (reg:CC_NOOV 21))]
6603 "reload_completed"
6604 [(parallel [(set (reg:CC_NOOV 21)
6605 (compare:CC_NOOV (plus:QI (match_dup 4) (match_dup 5))
6606 (const_int 0)))
6607 (set (match_dup 3) (plus:QI (match_dup 4) (match_dup 5)))])
6608 (parallel [(set (match_dup 6) (plus:QI (match_dup 7) (match_dup 8)))
6609 (use (reg:CC_NOOV 21))
6610 (clobber (reg:CC_NOOV 21))])]
6611 "operands[3] = c4x_operand_subword (operands[0], 0, 1, HImode);
6612 operands[4] = c4x_operand_subword (operands[1], 0, 1, HImode);
6613 operands[5] = c4x_operand_subword (operands[2], 0, 1, HImode);
6614 operands[6] = c4x_operand_subword (operands[0], 1, 1, HImode);
6615 operands[7] = c4x_operand_subword (operands[1], 1, 1, HImode);
6616 operands[8] = c4x_operand_subword (operands[2], 1, 1, HImode);")
6617
6618 (define_expand "subhi3"
6619 [(parallel [(set (match_operand:HI 0 "ext_reg_operand" "")
6620 (minus:HI (match_operand:HI 1 "src_operand" "")
6621 (match_operand:HI 2 "src_operand" "")))
6622 (clobber (reg:CC_NOOV 21))])]
6623 ""
6624 "legitimize_operands (MINUS, operands, HImode);")
6625
6626
6627 (define_insn "*subhi3_clobber"
6628 [(set (match_operand:HI 0 "ext_reg_operand" "=d,d,?d")
6629 (minus:HI (match_operand:HI 1 "src_operand" "0,rR,rS<>")
6630 (match_operand:HI 2 "src_operand" "rm,R,rS<>")))
6631 (clobber (reg:CC_NOOV 21))]
6632 "valid_operands (MINUS, operands, HImode)"
6633 "#"
6634 [(set_attr "type" "multi,multi,multi")])
6635
6636 (define_split
6637 [(set (match_operand:HI 0 "ext_reg_operand" "")
6638 (minus:HI (match_operand:HI 1 "src_operand" "")
6639 (match_operand:HI 2 "src_operand" "")))
6640 (clobber (reg:CC_NOOV 21))]
6641 "reload_completed"
6642 [(parallel [(set (reg:CC_NOOV 21)
6643 (compare:CC_NOOV (minus:QI (match_dup 4) (match_dup 5))
6644 (const_int 0)))
6645 (set (match_dup 3) (minus:QI (match_dup 4) (match_dup 5)))])
6646 (parallel [(set (match_dup 6) (minus:QI (match_dup 7) (match_dup 8)))
6647 (use (reg:CC_NOOV 21))
6648 (clobber (reg:CC_NOOV 21))])]
6649 "operands[3] = c4x_operand_subword (operands[0], 0, 1, HImode);
6650 operands[4] = c4x_operand_subword (operands[1], 0, 1, HImode);
6651 operands[5] = c4x_operand_subword (operands[2], 0, 1, HImode);
6652 operands[6] = c4x_operand_subword (operands[0], 1, 1, HImode);
6653 operands[7] = c4x_operand_subword (operands[1], 1, 1, HImode);
6654 operands[8] = c4x_operand_subword (operands[2], 1, 1, HImode);")
6655
6656 (define_expand "iorhi3"
6657 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6658 (ior:HI (match_operand:HI 1 "src_operand" "")
6659 (match_operand:HI 2 "src_operand" "")))
6660 (clobber (reg:CC 21))])]
6661 ""
6662 "legitimize_operands (IOR, operands, HImode);")
6663
6664 (define_insn "*iorhi3_clobber"
6665 [(set (match_operand:HI 0 "reg_operand" "=d,d,?d")
6666 (ior:HI (match_operand:HI 1 "src_operand" "%0,rR,rS<>")
6667 (match_operand:HI 2 "src_operand" "rm,R,rS<>")))
6668 (clobber (reg:CC 21))]
6669 "valid_operands (IOR, operands, HImode)"
6670 "#"
6671 [(set_attr "type" "multi,multi,multi")])
6672
6673 (define_split
6674 [(set (match_operand:HI 0 "reg_operand" "")
6675 (ior:HI (match_operand:HI 1 "src_operand" "")
6676 (match_operand:HI 2 "src_operand" "")))
6677 (clobber (reg:CC 21))]
6678 "reload_completed"
6679 [(parallel [(set (match_dup 3) (ior:QI (match_dup 4) (match_dup 5)))
6680 (clobber (reg:CC 21))])
6681 (parallel [(set (match_dup 6) (ior:QI (match_dup 7) (match_dup 8)))
6682 (clobber (reg:CC 21))])]
6683 "operands[3] = c4x_operand_subword (operands[0], 0, 1, HImode);
6684 operands[4] = c4x_operand_subword (operands[1], 0, 1, HImode);
6685 operands[5] = c4x_operand_subword (operands[2], 0, 1, HImode);
6686 operands[6] = c4x_operand_subword (operands[0], 1, 1, HImode);
6687 operands[7] = c4x_operand_subword (operands[1], 1, 1, HImode);
6688 operands[8] = c4x_operand_subword (operands[2], 1, 1, HImode);")
6689
6690 (define_expand "andhi3"
6691 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6692 (and:HI (match_operand:HI 1 "src_operand" "")
6693 (match_operand:HI 2 "src_operand" "")))
6694 (clobber (reg:CC 21))])]
6695 ""
6696 "legitimize_operands (AND, operands, HImode);")
6697
6698 (define_insn "*andhi3_clobber"
6699 [(set (match_operand:HI 0 "reg_operand" "=d,d,?d")
6700 (and:HI (match_operand:HI 1 "src_operand" "%0,rR,rS<>")
6701 (match_operand:HI 2 "src_operand" "rm,R,rS<>")))
6702 (clobber (reg:CC 21))]
6703 "valid_operands (AND, operands, HImode)"
6704 "#"
6705 [(set_attr "type" "multi,multi,multi")])
6706
6707 (define_split
6708 [(set (match_operand:HI 0 "reg_operand" "")
6709 (and:HI (match_operand:HI 1 "src_operand" "")
6710 (match_operand:HI 2 "src_operand" "")))
6711 (clobber (reg:CC 21))]
6712 "reload_completed"
6713 [(parallel [(set (match_dup 3) (and:QI (match_dup 4) (match_dup 5)))
6714 (clobber (reg:CC 21))])
6715 (parallel [(set (match_dup 6) (and:QI (match_dup 7) (match_dup 8)))
6716 (clobber (reg:CC 21))])]
6717 "operands[3] = c4x_operand_subword (operands[0], 0, 1, HImode);
6718 operands[4] = c4x_operand_subword (operands[1], 0, 1, HImode);
6719 operands[5] = c4x_operand_subword (operands[2], 0, 1, HImode);
6720 operands[6] = c4x_operand_subword (operands[0], 1, 1, HImode);
6721 operands[7] = c4x_operand_subword (operands[1], 1, 1, HImode);
6722 operands[8] = c4x_operand_subword (operands[2], 1, 1, HImode);")
6723
6724 (define_expand "xorhi3"
6725 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6726 (xor:HI (match_operand:HI 1 "src_operand" "")
6727 (match_operand:HI 2 "src_operand" "")))
6728 (clobber (reg:CC 21))])]
6729 ""
6730 "legitimize_operands (XOR, operands, HImode);")
6731
6732
6733 (define_insn "*xorhi3_clobber"
6734 [(set (match_operand:HI 0 "reg_operand" "=d,d,?d")
6735 (xor:HI (match_operand:HI 1 "src_operand" "%0,rR,rS<>")
6736 (match_operand:HI 2 "src_operand" "rm,R,rS<>")))
6737 (clobber (reg:CC 21))]
6738 "valid_operands (XOR, operands, HImode)"
6739 "#"
6740 [(set_attr "type" "multi,multi,multi")])
6741
6742 (define_split
6743 [(set (match_operand:HI 0 "reg_operand" "")
6744 (xor:HI (match_operand:HI 1 "src_operand" "")
6745 (match_operand:HI 2 "src_operand" "")))
6746 (clobber (reg:CC 21))]
6747 "reload_completed"
6748 [(parallel [(set (match_dup 3) (xor:QI (match_dup 4) (match_dup 5)))
6749 (clobber (reg:CC 21))])
6750 (parallel [(set (match_dup 6) (xor:QI (match_dup 7) (match_dup 8)))
6751 (clobber (reg:CC 21))])]
6752 "operands[3] = c4x_operand_subword (operands[0], 0, 1, HImode);
6753 operands[4] = c4x_operand_subword (operands[1], 0, 1, HImode);
6754 operands[5] = c4x_operand_subword (operands[2], 0, 1, HImode);
6755 operands[6] = c4x_operand_subword (operands[0], 1, 1, HImode);
6756 operands[7] = c4x_operand_subword (operands[1], 1, 1, HImode);
6757 operands[8] = c4x_operand_subword (operands[2], 1, 1, HImode);")
6758
6759 (define_expand "ashlhi3"
6760 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6761 (ashift:HI (match_operand:HI 1 "src_operand" "")
6762 (match_operand:QI 2 "src_operand" "")))
6763 (clobber (reg:CC 21))])]
6764 ""
6765 "if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32)
6766 {
6767 rtx op0hi = operand_subword (operands[0], 1, 0, HImode);
6768 rtx op0lo = operand_subword (operands[0], 0, 0, HImode);
6769 rtx op1lo = operand_subword (operands[1], 0, 0, HImode);
6770 rtx count = GEN_INT ((INTVAL (operands[2]) - 32));
6771
6772 if (INTVAL (count))
6773 emit_insn (gen_ashlqi3 (op0hi, op1lo, count));
6774 else
6775 emit_insn (gen_movqi (op0hi, op1lo));
6776 emit_insn (gen_movqi (op0lo, const0_rtx));
6777 DONE;
6778 }
6779 if (! REG_P (operands[1]))
6780 operands[1] = force_reg (HImode, operands[1]);
6781 emit_insn (gen_ashlhi3_reg (operands[0], operands[1], operands[2]));
6782 DONE;
6783 ")
6784
6785 ; %0.lo = %1.lo << %2
6786 ; %0.hi = (%1.hi << %2 ) | (%1.lo >> (32 - %2))
6787 ; This algorithm should work for shift counts greater than 32
6788 (define_expand "ashlhi3_reg"
6789 [(use (match_operand:HI 1 "reg_operand" ""))
6790 (use (match_operand:HI 0 "reg_operand" ""))
6791 /* If the shift count is greater than 32 this will give zero. */
6792 (parallel [(set (match_dup 7)
6793 (ashift:QI (match_dup 3)
6794 (match_operand:QI 2 "reg_operand" "")))
6795 (clobber (reg:CC 21))])
6796 /* If the shift count is greater than 32 this will give zero. */
6797 (parallel [(set (match_dup 8)
6798 (ashift:QI (match_dup 4) (match_dup 2)))
6799 (clobber (reg:CC 21))])
6800 (parallel [(set (match_dup 10)
6801 (plus:QI (match_dup 2) (const_int -32)))
6802 (clobber (reg:CC_NOOV 21))])
6803 /* If the shift count is greater than 32 this will do a left shift. */
6804 (parallel [(set (match_dup 9)
6805 (lshiftrt:QI (match_dup 3) (neg:QI (match_dup 10))))
6806 (clobber (reg:CC 21))])
6807 (set (match_dup 5) (match_dup 7))
6808 (parallel [(set (match_dup 6)
6809 (ior:QI (match_dup 8) (match_dup 9)))
6810 (clobber (reg:CC 21))])]
6811 ""
6812 "
6813 operands[3] = operand_subword (operands[1], 0, 1, HImode); /* lo */
6814 operands[4] = operand_subword (operands[1], 1, 1, HImode); /* hi */
6815 operands[5] = operand_subword (operands[0], 0, 1, HImode); /* lo */
6816 operands[6] = operand_subword (operands[0], 1, 1, HImode); /* hi */
6817 operands[7] = gen_reg_rtx (QImode); /* lo << count */
6818 operands[8] = gen_reg_rtx (QImode); /* hi << count */
6819 operands[9] = gen_reg_rtx (QImode); /* lo >> (32 - count) */
6820 operands[10] = gen_reg_rtx (QImode); /* 32 - count */
6821 ")
6822
6823 ; This should do all the dirty work with define_split
6824 (define_expand "lshrhi3"
6825 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6826 (lshiftrt:HI (match_operand:HI 1 "src_operand" "")
6827 (match_operand:QI 2 "src_operand" "")))
6828 (clobber (reg:CC 21))])]
6829 ""
6830 "if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32)
6831 {
6832 rtx op0hi = operand_subword (operands[0], 1, 0, HImode);
6833 rtx op0lo = operand_subword (operands[0], 0, 0, HImode);
6834 rtx op1hi = operand_subword (operands[1], 1, 0, HImode);
6835 rtx count = GEN_INT ((INTVAL (operands[2]) - 32));
6836
6837 if (INTVAL (count))
6838 emit_insn (gen_lshrqi3 (op0lo, op1hi, count));
6839 else
6840 emit_insn (gen_movqi (op0lo, op1hi));
6841 emit_insn (gen_movqi (op0hi, const0_rtx));
6842 DONE;
6843 }
6844 if (! REG_P (operands[1]))
6845 operands[1] = force_reg (HImode, operands[1]);
6846 emit_insn (gen_lshrhi3_reg (operands[0], operands[1], operands[2]));
6847 DONE;")
6848
6849 ; %0.hi = %1.hi >> %2
6850 ; %0.lo = (%1.lo >> %2 ) | (%1.hi << (32 - %2))
6851 ; This algorithm should work for shift counts greater than 32
6852 (define_expand "lshrhi3_reg"
6853 [(use (match_operand:HI 1 "reg_operand" ""))
6854 (use (match_operand:HI 0 "reg_operand" ""))
6855 (parallel [(set (match_dup 11)
6856 (neg:QI (match_operand:QI 2 "reg_operand" "")))
6857 (clobber (reg:CC_NOOV 21))])
6858 /* If the shift count is greater than 32 this will give zero. */
6859 (parallel [(set (match_dup 7)
6860 (lshiftrt:QI (match_dup 3)
6861 (neg:QI (match_dup 11))))
6862 (clobber (reg:CC 21))])
6863 /* If the shift count is greater than 32 this will give zero. */
6864 (parallel [(set (match_dup 8)
6865 (lshiftrt:QI (match_dup 4)
6866 (neg:QI (match_dup 11))))
6867 (clobber (reg:CC 21))])
6868 (parallel [(set (match_dup 10)
6869 (plus:QI (match_dup 11) (const_int 32)))
6870 (clobber (reg:CC_NOOV 21))])
6871 /* If the shift count is greater than 32 this will do an arithmetic
6872 right shift. However, we need a logical right shift. */
6873 (parallel [(set (match_dup 9)
6874 (ashift:QI (match_dup 4) (unspec:QI [(match_dup 10)] UNSPEC_LSH)))
6875 (clobber (reg:CC 21))])
6876 (set (match_dup 6) (match_dup 8))
6877 (parallel [(set (match_dup 5)
6878 (ior:QI (match_dup 7) (match_dup 9)))
6879 (clobber (reg:CC 21))])]
6880 ""
6881 "
6882 operands[3] = operand_subword (operands[1], 0, 1, HImode); /* lo */
6883 operands[4] = operand_subword (operands[1], 1, 1, HImode); /* hi */
6884 operands[5] = operand_subword (operands[0], 0, 1, HImode); /* lo */
6885 operands[6] = operand_subword (operands[0], 1, 1, HImode); /* hi */
6886 operands[7] = gen_reg_rtx (QImode); /* lo >> count */
6887 operands[8] = gen_reg_rtx (QImode); /* hi >> count */
6888 operands[9] = gen_reg_rtx (QImode); /* hi << (32 - count) */
6889 operands[10] = gen_reg_rtx (QImode); /* 32 - count */
6890 operands[11] = gen_reg_rtx (QImode); /* -count */
6891 ")
6892
6893 ; This should do all the dirty work with define_split
6894 (define_expand "ashrhi3"
6895 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
6896 (ashiftrt:HI (match_operand:HI 1 "src_operand" "")
6897 (match_operand:QI 2 "src_operand" "")))
6898 (clobber (reg:CC 21))])]
6899 ""
6900 "if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32)
6901 {
6902 rtx op0hi = operand_subword (operands[0], 1, 0, HImode);
6903 rtx op0lo = operand_subword (operands[0], 0, 0, HImode);
6904 rtx op1hi = operand_subword (operands[1], 1, 0, HImode);
6905 rtx count = GEN_INT ((INTVAL (operands[2]) - 32));
6906
6907 if (INTVAL (count))
6908 emit_insn (gen_ashrqi3 (op0lo, op1hi, count));
6909 else
6910 emit_insn (gen_movqi (op0lo, op1hi));
6911 emit_insn (gen_ashrqi3 (op0hi, op1hi, GEN_INT (31)));
6912 DONE;
6913 }
6914 if (! REG_P (operands[1]))
6915 operands[1] = force_reg (HImode, operands[1]);
6916 emit_insn (gen_ashrhi3_reg (operands[0], operands[1], operands[2]));
6917 DONE;")
6918
6919 ; %0.hi = %1.hi >> %2
6920 ; %0.lo = (%1.lo >> %2 ) | (%1.hi << (32 - %2))
6921 ; This algorithm should work for shift counts greater than 32
6922 (define_expand "ashrhi3_reg"
6923 [(use (match_operand:HI 1 "reg_operand" ""))
6924 (use (match_operand:HI 0 "reg_operand" ""))
6925 (parallel [(set (match_dup 11)
6926 (neg:QI (match_operand:QI 2 "reg_operand" "")))
6927 (clobber (reg:CC_NOOV 21))])
6928 /* If the shift count is greater than 32 this will give zero. */
6929 (parallel [(set (match_dup 7)
6930 (lshiftrt:QI (match_dup 3)
6931 (neg:QI (match_dup 11))))
6932 (clobber (reg:CC 21))])
6933 /* If the shift count is greater than 32 this will give zero. */
6934 (parallel [(set (match_dup 8)
6935 (ashiftrt:QI (match_dup 4)
6936 (neg:QI (match_dup 11))))
6937 (clobber (reg:CC 21))])
6938 (parallel [(set (match_dup 10)
6939 (plus:QI (match_dup 11) (const_int 32)))
6940 (clobber (reg:CC_NOOV 21))])
6941 /* If the shift count is greater than 32 this will do an arithmetic
6942 right shift. */
6943 (parallel [(set (match_dup 9)
6944 (ashift:QI (match_dup 4) (match_dup 10)))
6945 (clobber (reg:CC 21))])
6946 (set (match_dup 6) (match_dup 8))
6947 (parallel [(set (match_dup 5)
6948 (ior:QI (match_dup 7) (match_dup 9)))
6949 (clobber (reg:CC 21))])]
6950 ""
6951 "
6952 operands[3] = operand_subword (operands[1], 0, 1, HImode); /* lo */
6953 operands[4] = operand_subword (operands[1], 1, 1, HImode); /* hi */
6954 operands[5] = operand_subword (operands[0], 0, 1, HImode); /* lo */
6955 operands[6] = operand_subword (operands[0], 1, 1, HImode); /* hi */
6956 operands[7] = gen_reg_rtx (QImode); /* lo >> count */
6957 operands[8] = gen_reg_rtx (QImode); /* hi >> count */
6958 operands[9] = gen_reg_rtx (QImode); /* hi << (32 - count) */
6959 operands[10] = gen_reg_rtx (QImode); /* 32 - count */
6960 operands[11] = gen_reg_rtx (QImode); /* -count */
6961 ")
6962
6963 (define_expand "cmphi"
6964 [(set (reg:CC 21)
6965 (compare:CC (match_operand:HI 0 "src_operand" "")
6966 (match_operand:HI 1 "src_operand" "")))]
6967 ""
6968 "legitimize_operands (COMPARE, operands, HImode);
6969 c4x_compare_op0 = operands[0];
6970 c4x_compare_op1 = operands[1];
6971 DONE;")
6972
6973 (define_insn "*cmphi_cc"
6974 [(set (reg:CC 21)
6975 (compare:CC (match_operand:HI 0 "src_operand" "rR,rS<>")
6976 (match_operand:HI 1 "src_operand" "R,rS<>")))]
6977 "valid_operands (COMPARE, operands, HImode)"
6978 "#"
6979 [(set_attr "type" "multi")])
6980
6981 (define_insn "*cmphi_cc_noov"
6982 [(set (reg:CC_NOOV 21)
6983 (compare:CC_NOOV (match_operand:HI 0 "src_operand" "rR,rS<>")
6984 (match_operand:HI 1 "src_operand" "R,rS<>")))]
6985 "valid_operands (COMPARE, operands, HImode)"
6986 "#"
6987 [(set_attr "type" "multi")])
6988
6989 ; This works only before reload because we need 2 extra registers.
6990 ; Use unspec to avoid recursive split.
6991 (define_split
6992 [(set (reg:CC 21)
6993 (compare:CC (match_operand:HI 0 "src_operand" "")
6994 (match_operand:HI 1 "src_operand" "")))]
6995 "! reload_completed"
6996 [(parallel [(set (reg:CC 21)
6997 (unspec:CC [(compare:CC (match_dup 0)
6998 (match_dup 1))] UNSPEC_CMPHI))
6999 (clobber (match_scratch:QI 2 ""))
7000 (clobber (match_scratch:QI 3 ""))])]
7001 "")
7002
7003 (define_split
7004 [(set (reg:CC_NOOV 21)
7005 (compare:CC_NOOV (match_operand:HI 0 "src_operand" "")
7006 (match_operand:HI 1 "src_operand" "")))]
7007 "! reload_completed"
7008 [(parallel [(set (reg:CC_NOOV 21)
7009 (unspec:CC_NOOV [(compare:CC_NOOV (match_dup 0)
7010 (match_dup 1))] UNSPEC_CMPHI))
7011 (clobber (match_scratch:QI 2 ""))
7012 (clobber (match_scratch:QI 3 ""))])]
7013 "")
7014
7015 ; This is normally not used. The define splits above are used first.
7016 (define_split
7017 [(set (reg:CC 21)
7018 (compare:CC (match_operand:HI 0 "src_operand" "")
7019 (match_operand:HI 1 "src_operand" "")))]
7020 "reload_completed"
7021 [(parallel [(set (reg:CC 21)
7022 (compare:CC (match_dup 0) (match_dup 1)))
7023 (use (reg:QI 20))])]
7024 "")
7025
7026 (define_split
7027 [(set (reg:CC_NOOV 21)
7028 (compare:CC_NOOV (match_operand:HI 0 "src_operand" "")
7029 (match_operand:HI 1 "src_operand" "")))]
7030 "reload_completed"
7031 [(parallel [(set (reg:CC_NOOV 21)
7032 (compare:CC_NOOV (match_dup 0) (match_dup 1)))
7033 (use (reg:QI 20))])]
7034 "")
7035
7036 (define_insn "*cmphi"
7037 [(set (reg:CC 21)
7038 (compare:CC (match_operand:HI 0 "src_operand" "rR,rS<>")
7039 (match_operand:HI 1 "src_operand" "R,rS<>")))
7040 (use (reg:QI 20))]
7041 "valid_operands (COMPARE, operands, HImode)"
7042 "*
7043 {
7044 int use_ir1 = (reg_operand (operands[0], HImode)
7045 && REG_P (operands[0])
7046 && REGNO (operands[0]) == IR1_REGNO)
7047 || (reg_operand (operands[1], HImode)
7048 && REG_P (operands[1])
7049 && REGNO (operands[1]) == IR1_REGNO);
7050
7051 if (use_ir1)
7052 output_asm_insn (\"push\\tir1\", operands);
7053 else
7054 output_asm_insn (\"push\\tbk\", operands);
7055 output_asm_insn (\"push\\tr0\", operands);
7056 output_asm_insn (\"subi3\\t%1,%0,r0\", operands);
7057 if (use_ir1)
7058 {
7059 output_asm_insn (\"ldiu\\tst,ir1\", operands);
7060 output_asm_insn (\"or\\t07bh,ir1\", operands);
7061 }
7062 else
7063 {
7064 output_asm_insn (\"ldiu\\tst,bk\", operands);
7065 output_asm_insn (\"or\\t07bh,bk\", operands);
7066 }
7067 output_asm_insn (\"subb3\\t%O1,%O0,r0\", operands);
7068 if (use_ir1)
7069 output_asm_insn (\"and3\\tir1,st,ir1\", operands);
7070 else
7071 output_asm_insn (\"and3\\tbk,st,bk\", operands);
7072 output_asm_insn (\"pop\\tr0\", operands);
7073 if (use_ir1)
7074 {
7075 output_asm_insn (\"ldiu\\tir1,st\", operands);
7076 output_asm_insn (\"pop\\tir1\", operands);
7077 }
7078 else
7079 {
7080 output_asm_insn (\"ldiu\\tbk,st\", operands);
7081 output_asm_insn (\"pop\\tbk\", operands);
7082 }
7083 return \"\";
7084 }"
7085 [(set_attr "type" "multi")])
7086
7087 (define_insn "*cmphi_noov"
7088 [(set (reg:CC_NOOV 21)
7089 (compare:CC_NOOV (match_operand:HI 0 "src_operand" "rR,rS<>")
7090 (match_operand:HI 1 "src_operand" "R,rS<>")))
7091 (use (reg:QI 20))]
7092 "valid_operands (COMPARE, operands, HImode)"
7093 "*
7094 {
7095 int use_ir1 = (reg_operand (operands[0], HImode)
7096 && REG_P (operands[0])
7097 && REGNO (operands[0]) == IR1_REGNO)
7098 || (reg_operand (operands[1], HImode)
7099 && REG_P (operands[1])
7100 && REGNO (operands[1]) == IR1_REGNO);
7101
7102 if (use_ir1)
7103 output_asm_insn (\"push\\tir1\", operands);
7104 else
7105 output_asm_insn (\"push\\tbk\", operands);
7106 output_asm_insn (\"push\\tr0\", operands);
7107 output_asm_insn (\"subi3\\t%1,%0,r0\", operands);
7108 if (use_ir1)
7109 {
7110 output_asm_insn (\"ldiu\\tst,ir1\", operands);
7111 output_asm_insn (\"or\\t07bh,ir1\", operands);
7112 }
7113 else
7114 {
7115 output_asm_insn (\"ldiu\\tst,bk\", operands);
7116 output_asm_insn (\"or\\t07bh,bk\", operands);
7117 }
7118 output_asm_insn (\"subb3\\t%O1,%O0,r0\", operands);
7119 if (use_ir1)
7120 output_asm_insn (\"and3\\tir1,st,ir1\", operands);
7121 else
7122 output_asm_insn (\"and3\\tbk,st,bk\", operands);
7123 output_asm_insn (\"pop\\tr0\", operands);
7124 if (use_ir1)
7125 {
7126 output_asm_insn (\"ldiu\\tir1,st\", operands);
7127 output_asm_insn (\"pop\\tir1\", operands);
7128 }
7129 else
7130 {
7131 output_asm_insn (\"ldiu\\tbk,st\", operands);
7132 output_asm_insn (\"pop\\tbk\", operands);
7133 }
7134 return \"\";
7135 }"
7136 [(set_attr "type" "multi")])
7137
7138
7139 (define_insn "cmphi_cc"
7140 [(set (reg:CC 21)
7141 (unspec:CC [(compare:CC (match_operand:HI 0 "src_operand" "rR,rS<>")
7142 (match_operand:HI 1 "src_operand" "R,rS<>"))] UNSPEC_CMPHI))
7143 (clobber (match_scratch:QI 2 "=&d,&d"))
7144 (clobber (match_scratch:QI 3 "=&c,&c"))]
7145 "valid_operands (COMPARE, operands, HImode)"
7146 "*
7147 output_asm_insn (\"subi3\\t%1,%0,%2\", operands);
7148 output_asm_insn (\"ldiu\\tst,%3\", operands);
7149 output_asm_insn (\"or\\t07bh,%3\", operands);
7150 output_asm_insn (\"subb3\\t%O1,%O0,%2\", operands);
7151 output_asm_insn (\"and\\t%3,st\", operands);
7152 return \"\";"
7153 [(set_attr "type" "multi")])
7154
7155 (define_insn "cmphi_cc_noov"
7156 [(set (reg:CC_NOOV 21)
7157 (unspec:CC_NOOV [(compare:CC_NOOV (match_operand:HI 0 "src_operand" "rR,rS<>")
7158 (match_operand:HI 1 "src_operand" "R,rS<>"))] UNSPEC_CMPHI))
7159 (clobber (match_scratch:QI 2 "=&d,&d"))
7160 (clobber (match_scratch:QI 3 "=&c,&c"))]
7161 "valid_operands (COMPARE, operands, HImode)"
7162 "*
7163 output_asm_insn (\"subi3\\t%1,%0,%2\", operands);
7164 output_asm_insn (\"ldiu\\tst,%3\", operands);
7165 output_asm_insn (\"or\\t07bh,%3\", operands);
7166 output_asm_insn (\"subb3\\t%O1,%O0,%2\", operands);
7167 output_asm_insn (\"and\\t%3,st\", operands);
7168 return \"\";"
7169 [(set_attr "type" "multi")])
7170
7171 (define_expand "mulhi3"
7172 [(parallel [(set (match_operand:HI 0 "reg_operand" "")
7173 (mult:HI (match_operand:HI 1 "src_operand" "")
7174 (match_operand:HI 2 "src_operand" "")))
7175 (clobber (reg:CC 21))])]
7176 ""
7177 "c4x_emit_libcall3 (smul_optab->handlers[(int) HImode].libfunc,
7178 MULT, HImode, operands);
7179 DONE;")
7180
7181
7182 ;
7183 ; PEEPHOLES
7184 ;
7185
7186 ; dbCC peepholes
7187 ;
7188 ; Turns
7189 ; loop:
7190 ; [ ... ]
7191 ; bCC label ; abnormal loop termination
7192 ; dbu aN, loop ; normal loop termination
7193 ;
7194 ; Into
7195 ; loop:
7196 ; [ ... ]
7197 ; dbCC aN, loop
7198 ; bCC label
7199 ;
7200 ; Which moves the bCC condition outside the inner loop for free.
7201 ;
7202 (define_peephole
7203 [(set (pc) (if_then_else (match_operator 3 "comparison_operator"
7204 [(reg:CC 21) (const_int 0)])
7205 (label_ref (match_operand 2 "" ""))
7206 (pc)))
7207 (parallel
7208 [(set (pc)
7209 (if_then_else
7210 (ge (plus:QI (match_operand:QI 0 "addr_reg_operand" "+a")
7211 (const_int -1))
7212 (const_int 0))
7213 (label_ref (match_operand 1 "" ""))
7214 (pc)))
7215 (set (match_dup 0)
7216 (plus:QI (match_dup 0)
7217 (const_int -1)))
7218 (use (reg:QI 20))
7219 (clobber (reg:CC_NOOV 21))])]
7220 "! c4x_label_conflict (insn, operands[2], operands[1])"
7221 "db%I3\\t%0,%l1\\n\\tb%3\\t%l2"
7222 [(set_attr "type" "multi")])
7223
7224 (define_peephole
7225 [(set (pc) (if_then_else (match_operator 3 "comparison_operator"
7226 [(reg:CC 21) (const_int 0)])
7227 (label_ref (match_operand 2 "" ""))
7228 (pc)))
7229 (parallel
7230 [(set (pc)
7231 (if_then_else
7232 (ne (match_operand:QI 0 "addr_reg_operand" "+a")
7233 (const_int 0))
7234 (label_ref (match_operand 1 "" ""))
7235 (pc)))
7236 (set (match_dup 0)
7237 (plus:QI (match_dup 0)
7238 (const_int -1)))])]
7239 "! c4x_label_conflict (insn, operands[2], operands[1])"
7240 "db%I3\\t%0,%l1\\n\\tb%3\\t%l2"
7241 [(set_attr "type" "multi")])
7242
7243 ;
7244 ; Peepholes to convert 'call label; rets' into jump label
7245 ;
7246
7247 (define_peephole
7248 [(parallel [(call (mem:QI (match_operand:QI 0 "call_address_operand" ""))
7249 (match_operand:QI 1 "general_operand" ""))
7250 (clobber (reg:QI 31))])
7251 (return)]
7252 "! c4x_null_epilogue_p ()"
7253 "*
7254 if (REG_P (operands[0]))
7255 return \"bu%#\\t%C0\";
7256 else
7257 return \"br%#\\t%C0\";"
7258 [(set_attr "type" "jump")])
7259
7260 (define_peephole
7261 [(parallel [(set (match_operand 0 "" "")
7262 (call (mem:QI (match_operand:QI 1 "call_address_operand" ""))
7263 (match_operand:QI 2 "general_operand" "")))
7264 (clobber (reg:QI 31))])
7265 (return)]
7266 "! c4x_null_epilogue_p ()"
7267 "*
7268 if (REG_P (operands[1]))
7269 return \"bu%#\\t%C1\";
7270 else
7271 return \"br%#\\t%C1\";"
7272 [(set_attr "type" "jump")])
7273
7274
7275 ; This peephole should be unnecessary with my patches to flow.c
7276 ; for better autoincrement detection
7277 (define_peephole
7278 [(set (match_operand:QF 0 "ext_low_reg_operand" "")
7279 (mem:QF (match_operand:QI 1 "addr_reg_operand" "")))
7280 (set (match_operand:QF 2 "ext_low_reg_operand" "")
7281 (mem:QF (plus:QI (match_dup 1) (const_int 1))))
7282 (parallel [(set (match_dup 1) (plus:QI (match_dup 1) (const_int 2)))
7283 (clobber (reg:CC_NOOV 21))])]
7284 ""
7285 "ldf\\t*%1++,%0\\n\\tldf\\t*%1++,%2")
7286
7287
7288 ; This peephole should be unnecessary with my patches to flow.c
7289 ; for better autoincrement detection
7290 (define_peephole
7291 [(set (mem:QF (match_operand:QI 0 "addr_reg_operand" ""))
7292 (match_operand:QF 1 "ext_low_reg_operand" ""))
7293 (set (mem:QF (plus:QI (match_dup 0) (const_int 1)))
7294 (match_operand:QF 2 "ext_low_reg_operand" ""))
7295 (parallel [(set (match_dup 0) (plus:QI (match_dup 0) (const_int 2)))
7296 (clobber (reg:CC_NOOV 21))])]
7297 ""
7298 "stf\\t%1,*%0++\\n\\tstf\\t%2,*%0++")
7299
7300
7301 ; The following two peepholes remove an unnecessary load
7302 ; often found at the end of a function. These peepholes
7303 ; could be generalized to other binary operators. They shouldn't
7304 ; be required if we run a post reload mop-up pass.
7305 (define_peephole
7306 [(parallel [(set (match_operand:QF 0 "ext_reg_operand" "")
7307 (plus:QF (match_operand:QF 1 "ext_reg_operand" "")
7308 (match_operand:QF 2 "ext_reg_operand" "")))
7309 (clobber (reg:CC_NOOV 21))])
7310 (set (match_operand:QF 3 "ext_reg_operand" "")
7311 (match_dup 0))]
7312 "dead_or_set_p (insn, operands[0])"
7313 "addf3\\t%2,%1,%3")
7314
7315 (define_peephole
7316 [(parallel [(set (match_operand:QI 0 "reg_operand" "")
7317 (plus:QI (match_operand:QI 1 "reg_operand" "")
7318 (match_operand:QI 2 "reg_operand" "")))
7319 (clobber (reg:CC_NOOV 21))])
7320 (set (match_operand:QI 3 "reg_operand" "")
7321 (match_dup 0))]
7322 "dead_or_set_p (insn, operands[0])"
7323 "addi3\\t%2,%1,%3")