This commit was manufactured by cvs2svn to create branch
[official-gcc.git] / gcc / config / frv / frv.md
blobaef10bc9d43bbe206dfb713de931f99f5d01a9fe
1 ;; Frv Machine Description
2 ;; Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
3 ;; Contributed by Red Hat, Inc.
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; any later version.
12 ;; GCC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING.  If not, write to
19 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
22 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
25 ;; ::::::::::::::::::::
26 ;; ::
27 ;; :: Unspec's used
28 ;; ::
29 ;; ::::::::::::::::::::
31 (define_constants
32   [(UNSPEC_BLOCKAGE             0)
33    (UNSPEC_CC_TO_GPR            1)
34    (UNSPEC_GPR_TO_CC            2)
35    (UNSPEC_PIC_PROLOGUE         3)
36    (UNSPEC_CR_LOGIC             4)
37    (UNSPEC_STACK_ADJUST         5)
38    (UNSPEC_EH_RETURN_EPILOGUE   6)])
42 ;; ::::::::::::::::::::
43 ;; ::
44 ;; :: Constraints
45 ;; ::
46 ;; ::::::::::::::::::::
48 ;; Standard Constraints
50 ;; `m' A memory operand is allowed, with any kind of address that the
51 ;;     machine supports in general.
53 ;; `o' A memory operand is allowed, but only if the address is
54 ;;     "offsettable".  This means that adding a small integer (actually, the
55 ;;     width in bytes of the operand, as determined by its machine mode) may be
56 ;;     added to the address and the result is also a valid memory address.
58 ;; `V' A memory operand that is not offsettable.  In other words,
59 ;;     anything that would fit the `m' constraint but not the `o' constraint.
61 ;; `<' A memory operand with autodecrement addressing (either
62 ;;     predecrement or postdecrement) is allowed.
64 ;; `>' A memory operand with autoincrement addressing (either
65 ;;     preincrement or postincrement) is allowed.
67 ;; `r' A register operand is allowed provided that it is in a general
68 ;;     register.
70 ;; `d', `a', `f', ...
71 ;;     Other letters can be defined in machine-dependent fashion to stand for
72 ;;     particular classes of registers.  `d', `a' and `f' are defined on the
73 ;;     68000/68020 to stand for data, address and floating point registers.
75 ;; `i' An immediate integer operand (one with constant value) is allowed.
76 ;;     This includes symbolic constants whose values will be known only at
77 ;;     assembly time.
79 ;; `n' An immediate integer operand with a known numeric value is allowed.
80 ;;     Many systems cannot support assembly-time constants for operands less
81 ;;     than a word wide.  Constraints for these operands should use `n' rather
82 ;;     than `i'.
84 ;; 'I' First machine-dependent integer constant (6 bit signed ints).
85 ;; 'J' Second machine-dependent integer constant (10 bit signed ints).
86 ;; 'K' Third machine-dependent integer constant (-2048).
87 ;; 'L' Fourth machine-dependent integer constant (16 bit signed ints).
88 ;; 'M' Fifth machine-dependent integer constant (16 bit unsigned ints).
89 ;; 'N' Sixth machine-dependent integer constant (-2047..-1).
90 ;; 'O' Seventh machine-dependent integer constant (zero).
91 ;; 'P' Eighth machine-dependent integer constant (1..2047).
93 ;;     Other letters in the range `I' through `P' may be defined in a
94 ;;     machine-dependent fashion to permit immediate integer operands with
95 ;;     explicit integer values in specified ranges.  For example, on the 68000,
96 ;;     `I' is defined to stand for the range of values 1 to 8.  This is the
97 ;;     range permitted as a shift count in the shift instructions.
99 ;; `E' An immediate floating operand (expression code `const_double') is
100 ;;     allowed, but only if the target floating point format is the same as
101 ;;     that of the host machine (on which the compiler is running).
103 ;; `F' An immediate floating operand (expression code `const_double') is
104 ;;     allowed.
106 ;; 'G' First machine-dependent const_double.
107 ;; 'H' Second machine-dependent const_double.
109 ;; `s' An immediate integer operand whose value is not an explicit
110 ;;     integer is allowed.
112 ;;     This might appear strange; if an insn allows a constant operand with a
113 ;;     value not known at compile time, it certainly must allow any known
114 ;;     value.  So why use `s' instead of `i'?  Sometimes it allows better code
115 ;;     to be generated.
117 ;;     For example, on the 68000 in a fullword instruction it is possible to
118 ;;     use an immediate operand; but if the immediate value is between -128 and
119 ;;     127, better code results from loading the value into a register and
120 ;;     using the register.  This is because the load into the register can be
121 ;;     done with a `moveq' instruction.  We arrange for this to happen by
122 ;;     defining the letter `K' to mean "any integer outside the range -128 to
123 ;;     127", and then specifying `Ks' in the operand constraints.
125 ;; `g' Any register, memory or immediate integer operand is allowed,
126 ;;     except for registers that are not general registers.
128 ;; `X' Any operand whatsoever is allowed, even if it does not satisfy
129 ;;     `general_operand'.  This is normally used in the constraint of a
130 ;;     `match_scratch' when certain alternatives will not actually require a
131 ;;     scratch register.
133 ;; `0' Match operand 0.
134 ;; `1' Match operand 1.
135 ;; `2' Match operand 2.
136 ;; `3' Match operand 3.
137 ;; `4' Match operand 4.
138 ;; `5' Match operand 5.
139 ;; `6' Match operand 6.
140 ;; `7' Match operand 7.
141 ;; `8' Match operand 8.
142 ;; `9' Match operand 9.
144 ;;     An operand that matches the specified operand number is allowed.  If a
145 ;;     digit is used together with letters within the same alternative, the
146 ;;     digit should come last.
148 ;;     This is called a "matching constraint" and what it really means is that
149 ;;     the assembler has only a single operand that fills two roles considered
150 ;;     separate in the RTL insn.  For example, an add insn has two input
151 ;;     operands and one output operand in the RTL, but on most CISC machines an
152 ;;     add instruction really has only two operands, one of them an
153 ;;     input-output operand:
155 ;;          addl #35,r12
157 ;;     Matching constraints are used in these circumstances.  More precisely,
158 ;;     the two operands that match must include one input-only operand and one
159 ;;     output-only operand.  Moreover, the digit must be a smaller number than
160 ;;     the number of the operand that uses it in the constraint.
162 ;;     For operands to match in a particular case usually means that they are
163 ;;     identical-looking RTL expressions.  But in a few special cases specific
164 ;;     kinds of dissimilarity are allowed.  For example, `*x' as an input
165 ;;     operand will match `*x++' as an output operand.  For proper results in
166 ;;     such cases, the output template should always use the output-operand's
167 ;;     number when printing the operand.
169 ;; `p' An operand that is a valid memory address is allowed.  This is for
170 ;;     "load address" and "push address" instructions.
172 ;;     `p' in the constraint must be accompanied by `address_operand' as the
173 ;;     predicate in the `match_operand'.  This predicate interprets the mode
174 ;;     specified in the `match_operand' as the mode of the memory reference for
175 ;;     which the address would be valid.
177 ;; `Q` First non constant, non register machine-dependent insns
178 ;; `R` Second non constant, non register machine-dependent insns
179 ;; `S` Third non constant, non register machine-dependent insns
180 ;; `T` Fourth non constant, non register machine-dependent insns
181 ;; `U` Fifth non constant, non register machine-dependent insns
183 ;;     Letters in the range `Q' through `U' may be defined in a
184 ;;     machine-dependent fashion to stand for arbitrary operand types.  The
185 ;;     machine description macro `EXTRA_CONSTRAINT' is passed the operand as
186 ;;     its first argument and the constraint letter as its second operand.
188 ;;     A typical use for this would be to distinguish certain types of memory
189 ;;     references that affect other insn operands.
191 ;;     Do not define these constraint letters to accept register references
192 ;;     (`reg'); the reload pass does not expect this and would not handle it
193 ;;     properly.
195 ;; Multiple Alternative Constraints
196 ;; `?' Disparage slightly the alternative that the `?' appears in, as a
197 ;;     choice when no alternative applies exactly.  The compiler regards this
198 ;;     alternative as one unit more costly for each `?' that appears in it.
200 ;; `!' Disparage severely the alternative that the `!' appears in.  This
201 ;;     alternative can still be used if it fits without reloading, but if
202 ;;     reloading is needed, some other alternative will be used.
204 ;; Constraint modifiers
205 ;; `=' Means that this operand is write-only for this instruction: the
206 ;;     previous value is discarded and replaced by output data.
208 ;; `+' Means that this operand is both read and written by the
209 ;;     instruction.
211 ;;     When the compiler fixes up the operands to satisfy the constraints, it
212 ;;     needs to know which operands are inputs to the instruction and which are
213 ;;     outputs from it.  `=' identifies an output; `+' identifies an operand
214 ;;     that is both input and output; all other operands are assumed to be
215 ;;     input only.
217 ;; `&' Means (in a particular alternative) that this operand is written
218 ;;     before the instruction is finished using the input operands.  Therefore,
219 ;;     this operand may not lie in a register that is used as an input operand
220 ;;     or as part of any memory address.
222 ;;     `&' applies only to the alternative in which it is written.  In
223 ;;     constraints with multiple alternatives, sometimes one alternative
224 ;;     requires `&' while others do not.
226 ;;     `&' does not obviate the need to write `='.
228 ;; `%' Declares the instruction to be commutative for this operand and the
229 ;;     following operand.  This means that the compiler may interchange the two
230 ;;     operands if that is the cheapest way to make all operands fit the
231 ;;     constraints.  This is often used in patterns for addition instructions
232 ;;     that really have only two operands: the result must go in one of the
233 ;;     arguments.
235 ;; `#' Says that all following characters, up to the next comma, are to be
236 ;;     ignored as a constraint.  They are significant only for choosing
237 ;;     register preferences.
239 ;; `*' Says that the following character should be ignored when choosing
240 ;;     register preferences.  `*' has no effect on the meaning of the
241 ;;     constraint as a constraint, and no effect on reloading.
244 ;; ::::::::::::::::::::
245 ;; ::
246 ;; :: Attributes
247 ;; ::
248 ;; ::::::::::::::::::::
250 ;; The `define_attr' expression is used to define each attribute required by
251 ;; the target machine.  It looks like:
253 ;; (define_attr NAME LIST-OF-VALUES DEFAULT)
255 ;; NAME is a string specifying the name of the attribute being defined.
257 ;; LIST-OF-VALUES is either a string that specifies a comma-separated list of
258 ;; values that can be assigned to the attribute, or a null string to indicate
259 ;; that the attribute takes numeric values.
261 ;; DEFAULT is an attribute expression that gives the value of this attribute
262 ;; for insns that match patterns whose definition does not include an explicit
263 ;; value for this attribute.
265 ;; For each defined attribute, a number of definitions are written to the
266 ;; `insn-attr.h' file.  For cases where an explicit set of values is specified
267 ;; for an attribute, the following are defined:
269 ;; * A `#define' is written for the symbol `HAVE_ATTR_NAME'.
271 ;; * An enumeral class is defined for `attr_NAME' with elements of the
272 ;;   form `UPPER-NAME_UPPER-VALUE' where the attribute name and value are first
273 ;;   converted to upper case.
275 ;; * A function `get_attr_NAME' is defined that is passed an insn and
276 ;;   returns the attribute value for that insn.
278 ;; For example, if the following is present in the `md' file:
280 ;; (define_attr "type" "branch,fp,load,store,arith" ...)
282 ;; the following lines will be written to the file `insn-attr.h'.
284 ;; #define HAVE_ATTR_type
285 ;; enum attr_type {TYPE_BRANCH, TYPE_FP, TYPE_LOAD, TYPE_STORE, TYPE_ARITH};
286 ;; extern enum attr_type get_attr_type ();
288 ;; If the attribute takes numeric values, no `enum' type will be defined and
289 ;; the function to obtain the attribute's value will return `int'.
291 (define_attr "length" "" (const_int 4))
293 ;; Processor type -- this attribute must exactly match the processor_type
294 ;; enumeration in frv-protos.h.
296 (define_attr "cpu" "generic,fr500,fr400,fr300,simple,tomcat"
297   (const (symbol_ref "frv_cpu_type")))
299 ;; Attribute is "yes" for branches and jumps that span too great a distance
300 ;; to be implemented in the most natural way.  Such instructions will use
301 ;; a call instruction in some way.
303 (define_attr "far_jump" "yes,no" (const_string "no"))
305 ;; Instruction type
307 ;; The table below summarizes the types of media instruction and their
308 ;; scheduling classification.  Headings are:
310 ;; Type:        the name of the define_attr type
311 ;; Conditions:  "yes" if conditional variants are available
312 ;; FR500:       Fujitsu's categorisation for the FR500
313 ;; FR400:       Fujitsu's categorisation for the FR400 (but see below).
315 ;; On the FR400, media instructions are divided into 2 broad categories.
316 ;; Category 1 instructions can execute in either the M0 or M1 unit and can
317 ;; execute in parallel with other category 1 instructions.  Category 2
318 ;; instructions must use the M0 unit, and therefore cannot run in parallel
319 ;; with other media instructions.
321 ;; The FR400 documentation also divides media instructions into one of seven
322 ;; categories (m1 to m7).  m1 to m4 contain both Category 1 and Category 2
323 ;; instructions, so we use a combination of the categories here.
325 ;; Type         Conditional     FR500   FR400
326 ;; ----         ----------      -----   -----
327 ;; mlogic       yes             m1      m1:1
328 ;; mrdacc       no              m2      m4:1
329 ;; mwtacc       no              m3      m5:1
330 ;; maveh        no              m1      m1:1
331 ;; msath        no              m1      m1:1
332 ;; maddh        yes             m1      m1:1
333 ;; mqaddh       yes             m1      m1:2
334 ;; mpackh       no              m2      m3:1
335 ;; munpackh     no              m2      m3:2
336 ;; mdpackh      no              m5      m3:2
337 ;; mbhconv      yes             m2      m3:2
338 ;; mrot         no              m2      m3:1
339 ;; mshift       no              m2      m3:1
340 ;; mexpdhw      yes             m2      m3:1
341 ;; mexpdhd      yes             m2      m3:2
342 ;; mwcut        no              m2      m3:2
343 ;; mmulh        yes             m4      m2:1
344 ;; mmulxh       no              m4      m2:1
345 ;; mmach        yes             m4      m2:1
346 ;; mmrdh        no              m4      m2:1
347 ;; mqmulh       yes             m4      m2:2
348 ;; mqmulxh      no              m4      m2:2
349 ;; mqmach       yes             m4      m2:2
350 ;; mcpx         yes             m4      m2:1
351 ;; mqcpx        yes             m4      m2:2
352 ;; mcut         no              m2      m4:1
353 ;; mclracc      no              m3      m4:1
354 ;; mclracca     no              m6      m4:2
355 ;; mdunpackh    no              m2      n/a
356 ;; mbhconve     no              m2      n/a
357 ;; maddacc      no              n/a     m2:1
358 ;; mdaddacc     no              n/a     m2:2
359 ;; mabsh        no              n/a     m1:1
360 ;; mdrot        no              n/a     m3:2
361 ;; mcpl         no              n/a     m3:2
362 ;; mdcut        no              n/a     m4:2
363 ;; mqsath       no              n/a     m1:2
364 ;; mset         no              n/a     m1:1
366 (define_attr "type"
367   "int,sethi,setlo,mul,div,gload,gstore,fload,fstore,movfg,movgf,branch,jump,jumpl,call,spr,trap,fsconv,fsadd,fsmul,fmas,fsdiv,sqrt_single,fdconv,fdadd,fdmul,fddiv,sqrt_double,mlogic,maveh,msath,maddh,mqaddh,mpackh,munpackh,mdpackh,mbhconv,mrot,mshift,mexpdhw,mexpdhd,mwcut,mmulh,mmulxh,mmach,mmrdh,mqmulh,mqmulxh,mqmach,mcpx,mqcpx,mcut,mclracc,mclracca,mdunpackh,mbhconve,mrdacc,mwtacc,maddacc,mdaddacc,mabsh,mdrot,mcpl,mdcut,mqsath,mset,m7,ccr,multi,unknown"
368   (const_string "unknown"))
372 /* This is description of pipeline hazards based on DFA.  The
373    following constructions can be used for this:
375    o define_cpu_unit string [string]) describes a cpu functional unit
376      (separated by comma).
378      1st operand: Names of cpu function units.
379      2nd operand: Name of automaton (see comments for
380      DEFINE_AUTOMATON).
382      All define_reservations and define_cpu_units should have unique
383      names which can not be "nothing".
385    o (exclusion_set string string) means that each CPU function unit
386      in the first string can not be reserved simultaneously with each
387      unit whose name is in the second string and vise versa.  CPU
388      units in the string are separated by commas. For example, it is
389      useful for description CPU with fully pipelined floating point
390      functional unit which can execute simultaneously only single
391      floating point insns or only double floating point insns.
393    o (presence_set string string) means that each CPU function unit in
394      the first string can not be reserved unless at least one of units
395      whose names are in the second string is reserved.  This is an
396      asymmetric relation.  CPU units in the string are separated by
397      commas.  For example, it is useful for description that slot1 is
398      reserved after slot0 reservation for a VLIW processor.
400    o (absence_set string string) means that each CPU function unit in
401      the first string can not be reserved only if each unit whose name
402      is in the second string is not reserved.  This is an asymmetric
403      relation (actually exclusion set is analogous to this one but it
404      is symmetric).  CPU units in the string are separated by commas.
405      For example, it is useful for description that slot0 can not be
406      reserved after slot1 or slot2 reservation for a VLIW processor.
408    o (define_bypass number out_insn_names in_insn_names) names bypass with
409      given latency (the first number) from insns given by the first
410      string (see define_insn_reservation) into insns given by the
411      second string.  Insn names in the strings are separated by
412      commas.
414    o (define_automaton string) describes names of an automaton
415      generated and used for pipeline hazards recognition.  The names
416      are separated by comma.  Actually it is possibly to generate the
417      single automaton but unfortunately it can be very large.  If we
418      use more one automata, the summary size of the automata usually
419      is less than the single one.  The automaton name is used in
420      define_cpu_unit.  All automata should have unique names.
422    o (define_reservation string string) names reservation (the first
423      string) of cpu functional units (the 2nd string).  Sometimes unit
424      reservations for different insns contain common parts.  In such
425      case, you describe common part and use one its name (the 1st
426      parameter) in regular expression in define_insn_reservation.  All
427      define_reservations, define results and define_cpu_units should
428      have unique names which can not be "nothing".
430    o (define_insn_reservation name default_latency condition regexpr)
431      describes reservation of cpu functional units (the 3nd operand)
432      for instruction which is selected by the condition (the 2nd
433      parameter).  The first parameter is used for output of debugging
434      information.  The reservations are described by a regular
435      expression according the following syntax:
437        regexp = regexp "," oneof
438               | oneof
440        oneof = oneof "|" allof
441              | allof
443        allof = allof "+" repeat
444              | repeat
446        repeat = element "*" number
447               | element
449        element = cpu_function_name
450                | reservation_name
451                | result_name
452                | "nothing"
453                | "(" regexp ")"
455        1. "," is used for describing start of the next cycle in
456           reservation.
458        2. "|" is used for describing the reservation described by the
459           first regular expression *or* the reservation described by
460           the second regular expression *or* etc.
462        3. "+" is used for describing the reservation described by the
463           first regular expression *and* the reservation described by
464           the second regular expression *and* etc.
466        4. "*" is used for convenience and simply means sequence in
467           which the regular expression are repeated NUMBER times with
468           cycle advancing (see ",").
470        5. cpu function unit name which means reservation.
472        6. reservation name -- see define_reservation.
474        7. string "nothing" means no units reservation.
478 (define_automaton "nodiv, idiv, div")
480 ;; An FR500 packet can contain a single control instruction or a sequence
481 ;; of up to four operations matching the regular expression:
483 ;;      (I FM? I? FM? | FM? FM?) B? B?
485 ;; where I denotes an integer operation, FM a floating-point or media
486 ;; operation, and B a branch operation.  There are two units for each type
487 ;; of instruction: I0 and I1, FM0 and FM1, and B0 and B1.  Units are
488 ;; allocated left-to-right: the first integer instruction uses I0, the
489 ;; second uses I1, and so on.
491 ;; The FR400 is similar to the FR500 except that it allows only 2 operations
492 ;; per packet and has only one branch unit.  We can use the FR500 conflict
493 ;; description for the FR400, but need to define different cpu_units
494 ;; later.
496 ;; Slot/unit combinations available on the FR400 and above:
497 (define_cpu_unit "sl0_i0, sl0_fm0, sl0_b0, sl0_c" "nodiv")
498 (define_cpu_unit "sl1_fm0, sl1_i1, sl1_fm1, sl1_b0" "nodiv")
500 ;; These are available on the FR500 and above:
501 (define_cpu_unit "sl1_b1" "nodiv")
502 (define_cpu_unit "sl2_i1, sl2_fm1, sl2_b0, sl2_b1" "nodiv")
503 (define_cpu_unit "sl3_fm1, sl3_b0, sl3_b1"  "nodiv")
505 ;; The following describes conlicts by slots
506 ;; slot0
507 (exclusion_set "sl0_i0"  "sl0_fm0,sl0_b0,sl0_c")
508 (exclusion_set "sl0_fm0" "sl0_b0,sl0_c")
509 (exclusion_set "sl0_b0"  "sl0_c")
511 ;; slot1
512 (exclusion_set "sl1_fm0" "sl1_i1,sl1_fm1,sl1_b0,sl1_b1")
513 (exclusion_set "sl1_i1"  "sl1_fm1,sl1_b0,sl1_b1")
514 (exclusion_set "sl1_fm1" "sl1_b0,sl1_b1")
515 (exclusion_set "sl1_b0"  "sl1_b1")
517 ;; slot2
518 (exclusion_set "sl2_i1"  "sl2_fm1,sl2_b0,sl2_b1")
519 (exclusion_set "sl2_fm1" "sl2_b0,sl2_b1")
520 (exclusion_set "sl2_b0"  "sl2_b1")
522 ;; slot3
523 (exclusion_set "sl3_fm1" "sl3_b0,sl3_b1")
524 (exclusion_set "sl3_b0"  "sl3_b1")
526 ;; The following describes conlicts by units
527 ;; fm0
528 (exclusion_set "sl0_fm0" "sl1_fm0")
530 ;; b0
531 (exclusion_set "sl0_b0"  "sl1_b0,sl2_b0,sl3_b0")
532 (exclusion_set "sl1_b0"  "sl2_b0,sl3_b0")
533 (exclusion_set "sl2_b0"  "sl3_b0")
535 ;; i1
536 (exclusion_set "sl1_i1"  "sl2_i1")
538 ;; fm1
539 (exclusion_set "sl1_fm1" "sl2_fm1,sl3_fm1")
540 (exclusion_set "sl2_fm1" "sl3_fm1")
542 ;; b1
543 (exclusion_set "sl1_b1"  "sl2_b1,sl3_b1")
544 (exclusion_set "sl2_b1"  "sl3_b1")
546 ;; The following describes remaining combinations of conflicts
547 ;; slot0
548 (exclusion_set "sl0_i0"  "sl1_fm1,sl1_b1")
549 (exclusion_set "sl0_fm0" "sl1_i1,sl1_b1,sl2_i1,sl2_fm1,sl3_fm1,sl3_b0")
550 (exclusion_set "sl0_b0"  "sl1_fm0,sl1_i1,sl1_fm1,sl2_i1,sl2_fm1,sl2_b1,\
551                           sl3_fm1,sl3_b1")
552 (exclusion_set "sl0_c"   "sl1_fm0,sl1_i1,sl1_fm1,sl1_b0,sl1_b1,sl2_i1,sl2_fm1,\
553                           sl2_b0,sl2_b1,sl3_fm1,sl3_b0,sl3_b1")
556 ;; slot1
557 (exclusion_set "sl1_fm0" "sl2_b1")
558 (exclusion_set "sl1_i1"  "sl2_fm1,sl2_b1,sl3_fm1,sl3_b0")
559 (exclusion_set "sl1_fm1" "sl2_i1,sl2_b1,sl3_b0")
560 (exclusion_set "sl1_b0"  "sl2_i1,sl2_fm1,sl3_fm1,sl3_b1")
561 (exclusion_set "sl1_b1"  "sl2_i1,sl2_fm1,sl2_b0,sl3_fm1,sl3_b0")
563 ;; slot2
564 (exclusion_set "sl2_i1"  "sl3_b1")
565 (exclusion_set "sl2_fm1" "sl3_b1")
566 (exclusion_set "sl2_b0"  "sl3_fm1")
567 (exclusion_set "sl2_b1"  "sl3_fm1,sl3_b0")
569 ;; slot3
570 (exclusion_set "sl1_fm0" "sl2_i1,sl2_fm1,sl2_b0,sl2_b1,sl3_fm1,sl3_b0,sl3_b1")
571 (exclusion_set "sl3_fm1" "sl2_i1,sl2_fm1,sl2_b0,sl2_b1,sl3_b0,sl3_b1")
573 ;; ::::::::::::::::::::
574 ;; ::
575 ;; :: Generic/FR500 scheduler description
576 ;; ::
577 ;; ::::::::::::::::::::
579 ;; Define reservation in order to describe only in terms of units.
581 (define_reservation "i0" "sl0_i0")
582 (define_reservation "f0" "sl0_fm0|sl1_fm0")
583 (define_reservation "m0" "f0")
584 (define_reservation "b0" "sl0_b0|sl1_b0|sl2_b0|sl3_b0")
585 (define_reservation "c"  "sl0_c")
586 (define_reservation "i1" "sl1_i1|sl2_i1")
587 (define_reservation "f1" "sl1_fm1|sl2_fm1|sl3_fm1")
588 (define_reservation "m1" "f1")
589 (define_reservation "b1" "sl1_b1|sl2_b1|sl3_b1")
591 ;; Integer insns
592 ;; It is not possibly to issue load & store in one VLIW insn.
593 (define_cpu_unit "idiv1" "idiv")
594 (define_cpu_unit "idiv2" "idiv")
595 (define_cpu_unit "l0"    "nodiv")
596 (define_cpu_unit "l1"    "nodiv")
597 (define_cpu_unit "s0"    "nodiv")
599 (exclusion_set "l1,l0" "s0")
601 ;; We set the default_latency of sethi to be 0 to allow sethi and setlo to be
602 ;; combined in the same VLIW instruction as allowed by the architecture.  This
603 ;; assumes the only use of sethi is always followed by a setlo of the same
604 ;; register.
605 (define_insn_reservation "i1_sethi" 0
606   (and (eq_attr "cpu" "generic,fr500,tomcat")
607        (eq_attr "type" "sethi"))
608   "i0|i1")
610 (define_insn_reservation "i1_setlo" 1
611   (and (eq_attr "cpu" "generic,fr500,tomcat")
612        (eq_attr "type" "setlo"))
613   "i0|i1")
615 (define_insn_reservation "i1_int" 1
616   (and (eq_attr "cpu" "generic,fr500,tomcat")
617        (eq_attr "type" "int"))
618   "i0|i1")
620 (define_insn_reservation "i1_mul" 3
621   (and (eq_attr "cpu" "generic,fr500,tomcat")
622        (eq_attr "type" "mul"))
623   "i0|i1")
625 (define_insn_reservation "i1_div" 19
626   (and (eq_attr "cpu" "generic,fr500,tomcat")
627        (eq_attr "type" "div"))
628   "(i0|i1),(idiv1*18|idiv2*18)")
630 (define_insn_reservation "i2_gload" 4
631   (and (eq_attr "cpu" "generic,fr500,tomcat")
632        (eq_attr "type" "gload"))
633   "(i0|i1)+(l0|l1)")
635 (define_insn_reservation "i2_fload" 4
636   (and (eq_attr "cpu" "generic,fr500,tomcat")
637        (eq_attr "type" "fload"))
638   "(i0|i1)+(l0|l1)")
640 (define_insn_reservation "i3_gstore" 0
641   (and (eq_attr "cpu" "generic,fr500,tomcat")
642        (eq_attr "type" "gstore"))
643   "i0+s0")
645 (define_insn_reservation "i3_fstore" 0
646   (and (eq_attr "cpu" "generic,fr500,tomcat")
647        (eq_attr "type" "fstore"))
648   "i0+s0")
650 (define_insn_reservation "i4_move_gf" 3
651   (and (eq_attr "cpu" "generic,fr500,tomcat")
652        (eq_attr "type" "movgf"))
653   "i0")
655 (define_insn_reservation "i4_move_fg" 3 
656   (and (eq_attr "cpu" "generic,fr500,tomcat")
657        (eq_attr "type" "movfg"))
658   "i0")
660 (define_insn_reservation "i5" 0
661   (and (eq_attr "cpu" "generic,fr500,tomcat")
662        (eq_attr "type" "jumpl"))
663   "i0")
665 ;; Clear/commit is not generated now:
666 (define_insn_reservation "i6" 0 (const_int 0) "i0|i1")
669 ;; Branch-instructions
671 (define_insn_reservation "b1/b3" 0
672   (and (eq_attr "cpu" "generic,fr500,tomcat")
673        (eq_attr "type" "jump,branch,ccr"))
674   "b0|b1")
676 ;; The following insn is not generated now.
678 (define_insn_reservation "b2" 0 (const_int 0) "b0")
680 (define_insn_reservation "b4" 0
681   (and (eq_attr "cpu" "generic,fr500,tomcat")
682        (eq_attr "type" "call"))
683   "b0")
685 ;; The following insns are not generated now.
686 (define_insn_reservation "b5" 0 (const_int 0) "b0|b1")
687 (define_insn_reservation "b6" 0 (const_int 0) "b0|b1")
689 ;; Control insns
690 (define_insn_reservation "trap" 0
691   (and (eq_attr "cpu" "generic,fr500,tomcat")
692        (eq_attr "type" "trap"))
693   "c")
695 (define_insn_reservation "control" 0
696   (and (eq_attr "cpu" "generic,fr500,tomcat")
697        (eq_attr "type" "spr"))
698   "c")
700 ;; Floating point insns
701 (define_cpu_unit "add0" "nodiv")
702 (define_cpu_unit "add1" "nodiv")
703 (define_cpu_unit "mul0" "nodiv")
704 (define_cpu_unit "mul1" "nodiv")
705 (define_cpu_unit "div1" "div")
706 (define_cpu_unit "div2" "div")
707 (define_cpu_unit "root" "div")
709 (define_bypass 4 "f1" "m1,m2,m3,m4,m5,m6,m7")
710 (define_insn_reservation "f1" 3
711   (and (eq_attr "cpu" "generic,fr500,tomcat")
712        (eq_attr "type" "fsconv,fdconv"))
713   "(f0|f1)")
715 (define_bypass 4 "f2" "m1,m2,m3,m4,m5,m6,m7")
716 (define_insn_reservation "f2" 3
717   (and (eq_attr "cpu" "generic,fr500,tomcat")
718        (eq_attr "type" "fsadd,fdadd"))
719   "(f0|f1)+(add0|add1)")
721 (define_bypass 4 "f3" "m1,m2,m3,m4,m5,m6,m7")
722 (define_insn_reservation "f3" 3
723   (and (eq_attr "cpu" "generic,fr500,tomcat")
724        (eq_attr "type" "fsmul,fdmul"))
725   "(f0|f1)+(mul0|mul1)")
727 (define_bypass 11 "f4_div" "m1,m2,m3,m4,m5,m6,m7")
728 (define_insn_reservation "f4_div" 10
729   (and (eq_attr "cpu" "generic,fr500,tomcat")
730        (eq_attr "type" "fsdiv,fddiv"))
731   "(f0|f1),(div1*9|div2*9)")
733 (define_bypass 16 "f4_root" "m1,m2,m3,m4,m5,m6,m7")
734 (define_insn_reservation "f4_root" 15
735   (and (eq_attr "cpu" "generic,fr500,tomcat")
736        (eq_attr "type" "sqrt_single,sqrt_double"))
737   "(f0|f1)+root*15")
739 (define_bypass 4 "f5" "m1,m2,m3,m4,m5,m6,m7")
740 (define_insn_reservation "f5" 3
741   (and (eq_attr "cpu" "generic,fr500,tomcat")
742        (eq_attr "type" "fmas"))
743   "(f0|f1)+(add0|add1)+(mul0|mul1)")
745 ;; The following insns are not generated by gcc now:
746 (define_insn_reservation "f6" 0 (const_int 0) "(f0|f1)+add0+add1")
747 (define_insn_reservation "f7" 0 (const_int 0) "(f0|f1)+mul0+mul1")
749 ;; Media insns.  Now they are all not generated now.
750 (define_cpu_unit "m1_0" "nodiv")
751 (define_cpu_unit "m1_1" "nodiv")
752 (define_cpu_unit "m2_0" "nodiv")
753 (define_cpu_unit "m2_1" "nodiv")
754 (define_cpu_unit "m3_0" "nodiv")
755 (define_cpu_unit "m3_1" "nodiv")
756 (define_cpu_unit "m4_0" "nodiv")
757 (define_cpu_unit "m4_1" "nodiv")
758 (define_cpu_unit "m5"   "nodiv")
759 (define_cpu_unit "m6"   "nodiv")
760 (define_cpu_unit "m7"   "nodiv")
762 (exclusion_set "m5,m6,m7" "m2_0,m2_1,m3_0,m3_1")
763 (exclusion_set "m5"       "m6,m7")
764 (exclusion_set "m6"       "m4_0,m4_1,m7")
765 (exclusion_set "m7"       "m1_0,m1_1,add0,add1,mul0,mul1")
767 (define_bypass 2 "m1" "m1,m2,m3,m4,m5,m6,m7")
768 (define_bypass 4 "m1" "f1,f2,f3,f4_div,f4_root,f5,f6,f7")
769 (define_insn_reservation "m1" 3
770   (and (eq_attr "cpu" "generic,fr500,tomcat")
771        (eq_attr "type" "mlogic,maveh,msath,maddh,mqaddh"))
772   "(m0|m1)+(m1_0|m1_1)")
774 (define_bypass 2 "m2" "m1,m2,m3,m4,m5,m6,m7")
775 (define_bypass 4 "m2" "f1,f2,f3,f4_div,f4_root,f5,f6,f7")
776 (define_insn_reservation "m2" 3
777   (and (eq_attr "cpu" "generic,fr500,tomcat")
778        (eq_attr "type" "mrdacc,mpackh,munpackh,mbhconv,mrot,mshift,mexpdhw,mexpdhd,mwcut,mcut,mdunpackh,mbhconve"))
779   "(m0|m1)+(m2_0|m2_1)")
781 (define_bypass 1 "m3" "m4")
782 (define_insn_reservation "m3" 2
783   (and (eq_attr "cpu" "generic,fr500,tomcat")
784        (eq_attr "type" "mclracc,mwtacc"))
785   "(m0|m1)+(m3_0|m3_1)")
787 (define_bypass 1 "m4" "m4")
788 (define_insn_reservation "m4" 2
789   (and (eq_attr "cpu" "generic,fr500,tomcat")
790        (eq_attr "type" "mmulh,mmulxh,mmach,mmrdh,mqmulh,mqmulxh,mqmach,mcpx,mqcpx"))
791   "(m0|m1)+(m4_0|m4_1)")
793 (define_bypass 2 "m5" "m1,m2,m3,m4,m5,m6,m7")
794 (define_bypass 4 "m5" "f1,f2,f3,f4_div,f4_root,f5,f6,f7")
795 (define_insn_reservation "m5" 3
796   (and (eq_attr "cpu" "generic,fr500,tomcat")
797        (eq_attr "type" "mdpackh"))
798   "(m0|m1)+m5")
800 (define_bypass 1 "m6" "m4")
801 (define_insn_reservation "m6" 2
802   (and (eq_attr "cpu" "generic,fr500,tomcat")
803        (eq_attr "type" "mclracca"))
804   "(m0|m1)+m6")
806 (define_bypass 2 "m7" "m1,m2,m3,m4,m5,m6,m7")
807 (define_bypass 4 "m7" "f1,f2,f3,f4_div,f4_root,f5,f6,f7")
809 (define_insn_reservation "m7" 3
810   (and (eq_attr "cpu" "generic,fr500,tomcat")
811        (eq_attr "type" "m7"))
812   "(m0|m1)+m7")
814 ;; Unknown & multi insns starts on new cycle and the next insn starts
815 ;; on new cycle.  To describe this we consider as a control insn.
816 (define_insn_reservation "unknown" 1
817   (and (eq_attr "cpu" "generic,fr500,tomcat")
818        (eq_attr "type" "unknown,multi"))
819   "c")
821 ;; ::::::::::::::::::::
822 ;; ::
823 ;; :: FR400 scheduler description
824 ;; ::
825 ;; ::::::::::::::::::::
827 ;; Category 2 media instructions use both media units, but can be packed
828 ;; with non-media instructions.  Use fr400_m1unit to claim the M1 unit
829 ;; without claiming a slot.
831 (define_cpu_unit "fr400_m1unit" "nodiv")
833 (define_reservation "fr400_i0"      "sl0_i0")
834 (define_reservation "fr400_i1"      "sl1_i1")
835 (define_reservation "fr400_m0"      "sl0_fm0|sl1_fm0")
836 (define_reservation "fr400_m1"      "sl1_fm1")
837 (define_reservation "fr400_meither" "fr400_m0|(fr400_m1+fr400_m1unit)")
838 (define_reservation "fr400_mboth"   "fr400_m0+fr400_m1unit")
839 (define_reservation "fr400_b"       "sl0_b0|sl1_b0")
840 (define_reservation "fr400_c"       "sl0_c")
842 ;; Name         Class   Units   Latency
843 ;; ====         =====   =====   =======
844 ;; int          I1      I0/I1   1
845 ;; sethi        I1      I0/I1   0       -- does not interfere with setlo
846 ;; setlo        I1      I0/I1   1
847 ;; mul          I1      I0      3  (*)
848 ;; div          I1      I0      20 (*)
849 ;; gload        I2      I0      4  (*)
850 ;; fload        I2      I0      4       -- only 3 if read by a media insn
851 ;; gstore       I3      I0      0       -- provides no result
852 ;; fstore       I3      I0      0       -- provides no result
853 ;; movfg        I4      I0      3  (*)
854 ;; movgf        I4      I0      3  (*)
855 ;; jumpl        I5      I0      0       -- provides no result
857 ;; (*) The results of these instructions can be read one cycle earlier
858 ;; than indicated.  The penalty given is for instructions with write-after-
859 ;; write dependencies.
861 ;; The FR400 can only do loads and stores in I0, so we there's no danger
862 ;; of memory unit collision in the same packet.  There's only one divide
863 ;; unit too.
865 (define_insn_reservation "fr400_i1_int" 1
866   (and (eq_attr "cpu" "fr400")
867        (eq_attr "type" "int"))
868   "fr400_i0|fr400_i1")
870 (define_insn_reservation "fr400_i1_sethi" 0
871   (and (eq_attr "cpu" "fr400")
872        (eq_attr "type" "sethi"))
873   "fr400_i0|fr400_i1")
875 (define_insn_reservation "fr400_i1_setlo" 1
876   (and (eq_attr "cpu" "fr400")
877        (eq_attr "type" "setlo"))
878   "fr400_i0|fr400_i1")
880 (define_insn_reservation "fr400_i1_mul" 3
881   (and (eq_attr "cpu" "fr400")
882        (eq_attr "type" "mul"))
883   "fr400_i0")
885 (define_insn_reservation "fr400_i1_div" 20
886   (and (eq_attr "cpu" "fr400")
887        (eq_attr "type" "div"))
888   "fr400_i0+idiv1*19")
890 (define_insn_reservation "fr400_i2_gload" 4
891   (and (eq_attr "cpu" "fr400")
892        (eq_attr "type" "gload"))
893   "fr400_i0")
895 (define_insn_reservation "fr400_i2_fload" 4
896   (and (eq_attr "cpu" "fr400")
897        (eq_attr "type" "fload"))
898   "fr400_i0")
900 (define_insn_reservation "fr400_i3_gstore" 0
901   (and (eq_attr "cpu" "fr400")
902        (eq_attr "type" "gstore"))
903   "fr400_i0")
905 (define_insn_reservation "fr400_i3_fstore" 0
906   (and (eq_attr "cpu" "fr400")
907        (eq_attr "type" "fstore"))
908   "fr400_i0")
910 (define_insn_reservation "fr400_i4_movfg" 3
911   (and (eq_attr "cpu" "fr400")
912        (eq_attr "type" "movfg"))
913   "fr400_i0")
915 (define_insn_reservation "fr400_i4_movgf" 3
916   (and (eq_attr "cpu" "fr400")
917        (eq_attr "type" "movgf"))
918   "fr400_i0")
920 (define_insn_reservation "fr400_i5_jumpl" 0
921   (and (eq_attr "cpu" "fr400")
922        (eq_attr "type" "jumpl"))
923   "fr400_i0")
925 ;; The bypass between FPR loads and media instructions, described above.
927 (define_bypass 3
928   "fr400_i2_fload"
929   "fr400_m1_1,fr400_m1_2,\
930    fr400_m2_1,fr400_m2_2,\
931    fr400_m3_1,fr400_m3_2,\
932    fr400_m4_1,fr400_m4_2,\
933    fr400_m5")
935 ;; The branch instructions all use the B unit and produce no result.
937 (define_insn_reservation "fr400_b" 0
938   (and (eq_attr "cpu" "fr400")
939        (eq_attr "type" "jump,branch,ccr,call"))
940   "fr400_b")
942 ;; Control instructions use the C unit, which excludes all the others.
944 (define_insn_reservation "fr400_c" 0
945   (and (eq_attr "cpu" "fr400")
946        (eq_attr "type" "spr,trap"))
947   "fr400_c")
949 ;; Unknown instructions use the C unit, since it requires single-operation
950 ;; packets.
952 (define_insn_reservation "fr400_unknown" 1
953   (and (eq_attr "cpu" "fr400")
954        (eq_attr "type" "unknown,multi"))
955   "fr400_c")
957 ;; FP->FP moves are marked as "fsconv" instructions in the define_insns
958 ;; below, but are implemented on the FR400 using "mlogic" instructions.
959 ;; It's easier to class "fsconv" as a "m1:1" instruction than provide
960 ;; separate define_insns for the FR400.
962 ;; M1 instructions store their results in FPRs.  Any instruction can read
963 ;; the result in the following cycle, so no penalty occurs.
965 (define_insn_reservation "fr400_m1_1" 1
966   (and (eq_attr "cpu" "fr400")
967        (eq_attr "type" "fsconv,mlogic,maveh,msath,maddh,mabsh,mset"))
968   "fr400_meither")
970 (define_insn_reservation "fr400_m1_2" 1
971   (and (eq_attr "cpu" "fr400")
972        (eq_attr "type" "mqaddh,mqsath"))
973   "fr400_mboth")
975 ;; M2 instructions store their results in accumulators, which are read
976 ;; by M2 or M4 media commands.  M2 instructions can read the results in
977 ;; the following cycle, but M4 instructions must wait a cycle more.
979 (define_bypass 1
980   "fr400_m2_1,fr400_m2_2"
981   "fr400_m2_1,fr400_m2_2")
983 (define_insn_reservation "fr400_m2_1" 2
984   (and (eq_attr "cpu" "fr400")
985        (eq_attr "type" "mmulh,mmulxh,mmach,mmrdh,mcpx,maddacc"))
986   "fr400_meither")
988 (define_insn_reservation "fr400_m2_2" 2
989   (and (eq_attr "cpu" "fr400")
990        (eq_attr "type" "mqmulh,mqmulxh,mqmach,mqcpx,mdaddacc"))
991   "fr400_mboth")
993 ;; For our purposes, there seems to be little real difference between
994 ;; M1 and M3 instructions.  Keep them separate anyway in case the distinction
995 ;; is needed later.
997 (define_insn_reservation "fr400_m3_1" 1
998   (and (eq_attr "cpu" "fr400")
999        (eq_attr "type" "mpackh,mrot,mshift,mexpdhw"))
1000   "fr400_meither")
1002 (define_insn_reservation "fr400_m3_2" 1
1003   (and (eq_attr "cpu" "fr400")
1004        (eq_attr "type" "munpackh,mdpackh,mbhconv,mexpdhd,mwcut,mdrot,mcpl"))
1005   "fr400_mboth")
1007 ;; M4 instructions write to accumulators or FPRs.  MOVFG and STF
1008 ;; instructions can read an FPR result in the following cycle, but
1009 ;; M-unit instructions must wait a cycle more for either kind of result.
1011 (define_bypass 1
1012   "fr400_m4_1,fr400_m4_2"
1013   "fr400_i3_fstore,fr400_i4_movfg")
1015 (define_insn_reservation "fr400_m4_1" 2
1016   (and (eq_attr "cpu" "fr400")
1017        (eq_attr "type" "mrdacc,mcut,mclracc"))
1018   "fr400_meither")
1020 (define_insn_reservation "fr400_m4_2" 2
1021   (and (eq_attr "cpu" "fr400")
1022        (eq_attr "type" "mclracca,mdcut"))
1023   "fr400_mboth")
1025 ;; M5 instructions always incur a 1-cycle penalty.
1027 (define_insn_reservation "fr400_m5" 2
1028   (and (eq_attr "cpu" "fr400")
1029        (eq_attr "type" "mwtacc"))
1030   "fr400_mboth")
1032 ;; ::::::::::::::::::::
1033 ;; ::
1034 ;; :: Simple/FR300 scheduler description
1035 ;; ::
1036 ;; ::::::::::::::::::::
1038 ;; Fr300 or simple processor.  To describe it as 1 insn issue
1039 ;; processor, we use control unit.
1041 (define_insn_reservation "fr300_lat1" 1
1042   (and (eq_attr "cpu" "fr300,simple")
1043        (eq_attr "type" "!gload,fload,movfg,movgf"))
1044   "c")
1046 (define_insn_reservation "fr300_lat2" 2
1047   (and (eq_attr "cpu" "fr300,simple")
1048        (eq_attr "type" "gload,fload,movfg,movgf"))
1049   "c")
1052 ;; ::::::::::::::::::::
1053 ;; ::
1054 ;; :: Delay Slots
1055 ;; ::
1056 ;; ::::::::::::::::::::
1058 ;; The insn attribute mechanism can be used to specify the requirements for
1059 ;; delay slots, if any, on a target machine.  An instruction is said to require
1060 ;; a "delay slot" if some instructions that are physically after the
1061 ;; instruction are executed as if they were located before it.  Classic
1062 ;; examples are branch and call instructions, which often execute the following
1063 ;; instruction before the branch or call is performed.
1065 ;; On some machines, conditional branch instructions can optionally "annul"
1066 ;; instructions in the delay slot.  This means that the instruction will not be
1067 ;; executed for certain branch outcomes.  Both instructions that annul if the
1068 ;; branch is true and instructions that annul if the branch is false are
1069 ;; supported.
1071 ;; Delay slot scheduling differs from instruction scheduling in that
1072 ;; determining whether an instruction needs a delay slot is dependent only
1073 ;; on the type of instruction being generated, not on data flow between the
1074 ;; instructions.  See the next section for a discussion of data-dependent
1075 ;; instruction scheduling.
1077 ;; The requirement of an insn needing one or more delay slots is indicated via
1078 ;; the `define_delay' expression.  It has the following form:
1080 ;; (define_delay TEST
1081 ;;   [DELAY-1 ANNUL-TRUE-1 ANNUL-FALSE-1
1082 ;;    DELAY-2 ANNUL-TRUE-2 ANNUL-FALSE-2
1083 ;;    ...])
1085 ;; TEST is an attribute test that indicates whether this `define_delay' applies
1086 ;; to a particular insn.  If so, the number of required delay slots is
1087 ;; determined by the length of the vector specified as the second argument.  An
1088 ;; insn placed in delay slot N must satisfy attribute test DELAY-N.
1089 ;; ANNUL-TRUE-N is an attribute test that specifies which insns may be annulled
1090 ;; if the branch is true.  Similarly, ANNUL-FALSE-N specifies which insns in
1091 ;; the delay slot may be annulled if the branch is false.  If annulling is not
1092 ;; supported for that delay slot, `(nil)' should be coded.
1094 ;; For example, in the common case where branch and call insns require a single
1095 ;; delay slot, which may contain any insn other than a branch or call, the
1096 ;; following would be placed in the `md' file:
1098 ;; (define_delay (eq_attr "type" "branch,call")
1099 ;;               [(eq_attr "type" "!branch,call") (nil) (nil)])
1101 ;; Multiple `define_delay' expressions may be specified.  In this case, each
1102 ;; such expression specifies different delay slot requirements and there must
1103 ;; be no insn for which tests in two `define_delay' expressions are both true.
1105 ;; For example, if we have a machine that requires one delay slot for branches
1106 ;; but two for calls, no delay slot can contain a branch or call insn, and any
1107 ;; valid insn in the delay slot for the branch can be annulled if the branch is
1108 ;; true, we might represent this as follows:
1110 ;; (define_delay (eq_attr "type" "branch")
1111 ;;   [(eq_attr "type" "!branch,call")
1112 ;;    (eq_attr "type" "!branch,call")
1113 ;;    (nil)])
1115 ;; (define_delay (eq_attr "type" "call")
1116 ;;   [(eq_attr "type" "!branch,call") (nil) (nil)
1117 ;;    (eq_attr "type" "!branch,call") (nil) (nil)])
1119 ;; Note - it is the backend's responsibility to fill any unfilled delay slots
1120 ;; at assembler generation time.  This is usually done by adding a special print
1121 ;; operand to the delayed instruction, and then in the PRINT_OPERAND function
1122 ;; calling dbr_sequence_length() to determine how many delay slots were filled.
1123 ;; For example:
1125 ;; --------------<machine>.md-----------------
1126 ;; (define_insn "call"
1127 ;;  [(call (match_operand 0 "memory_operand" "m")
1128 ;;         (match_operand 1 "" ""))]
1129 ;;   ""
1130 ;;   "call_delayed %0,%1,%2%#"
1131 ;;  [(set_attr "length" "4")
1132 ;;   (set_attr "type" "call")])
1134 ;; -------------<machine>.h-------------------
1135 ;; #define PRINT_OPERAND_PUNCT_VALID_P(CODE) (CODE == '#')
1137 ;;  ------------<machine>.c------------------
1138 ;; void
1139 ;; machine_print_operand (file, x, code)
1140 ;;     FILE * file;
1141 ;;     rtx    x;
1142 ;;     int    code;
1143 ;; {
1144 ;;   switch (code)
1145 ;;   {
1146 ;;   case '#':
1147 ;;     if (dbr_sequence_length () == 0)
1148 ;;       fputs ("\n\tnop", file);
1149 ;;     return;
1151 ;; ::::::::::::::::::::
1152 ;; ::
1153 ;; :: Notes on Patterns
1154 ;; ::
1155 ;; ::::::::::::::::::::
1157 ;; If you need to construct a sequence of assembler instructions in order
1158 ;; to implement a pattern be sure to escape any backslashes and double quotes
1159 ;; that you use, eg:
1161 ;; (define_insn "an example"
1162 ;;   [(some rtl)]
1163 ;;   ""
1164 ;;   "*
1165 ;;    { static char buffer [100];
1166 ;;      sprintf (buffer, \"insn \\t %d\", REGNO (operands[1]));
1167 ;;      return buffer;
1168 ;;    }"
1169 ;; )
1171 ;; Also if there is more than one instruction, they can be separated by \\;
1172 ;; which is a space saving synonym for \\n\\t:
1174 ;; (define_insn "another example"
1175 ;;   [(some rtl)]
1176 ;;   ""
1177 ;;   "*
1178 ;;    { static char buffer [100];
1179 ;;      sprintf (buffer, \"insn1 \\t %d\\;insn2 \\t %%1\",
1180 ;;        REGNO (operands[1]));
1181 ;;      return buffer;
1182 ;;    }"
1183 ;; )
1187 ;; ::::::::::::::::::::
1188 ;; ::
1189 ;; :: Moves
1190 ;; ::
1191 ;; ::::::::::::::::::::
1193 ;; Wrap moves in define_expand to prevent memory->memory moves from being
1194 ;; generated at the RTL level, which generates better code for most machines
1195 ;; which can't do mem->mem moves.
1197 ;; If operand 0 is a `subreg' with mode M of a register whose own mode is wider
1198 ;; than M, the effect of this instruction is to store the specified value in
1199 ;; the part of the register that corresponds to mode M.  The effect on the rest
1200 ;; of the register is undefined.
1202 ;; This class of patterns is special in several ways.  First of all, each of
1203 ;; these names *must* be defined, because there is no other way to copy a datum
1204 ;; from one place to another.
1206 ;; Second, these patterns are not used solely in the RTL generation pass.  Even
1207 ;; the reload pass can generate move insns to copy values from stack slots into
1208 ;; temporary registers.  When it does so, one of the operands is a hard
1209 ;; register and the other is an operand that can need to be reloaded into a
1210 ;; register.
1212 ;; Therefore, when given such a pair of operands, the pattern must
1213 ;; generate RTL which needs no reloading and needs no temporary
1214 ;; registers--no registers other than the operands.  For example, if
1215 ;; you support the pattern with a `define_expand', then in such a
1216 ;; case the `define_expand' mustn't call `force_reg' or any other such
1217 ;; function which might generate new pseudo registers.
1219 ;; This requirement exists even for subword modes on a RISC machine
1220 ;; where fetching those modes from memory normally requires several
1221 ;; insns and some temporary registers.  Look in `spur.md' to see how
1222 ;; the requirement can be satisfied.
1224 ;; During reload a memory reference with an invalid address may be passed as an
1225 ;; operand.  Such an address will be replaced with a valid address later in the
1226 ;; reload pass.  In this case, nothing may be done with the address except to
1227 ;; use it as it stands.  If it is copied, it will not be replaced with a valid
1228 ;; address.  No attempt should be made to make such an address into a valid
1229 ;; address and no routine (such as `change_address') that will do so may be
1230 ;; called.  Note that `general_operand' will fail when applied to such an
1231 ;; address.
1233 ;; The global variable `reload_in_progress' (which must be explicitly declared
1234 ;; if required) can be used to determine whether such special handling is
1235 ;; required.
1237 ;; The variety of operands that have reloads depends on the rest of
1238 ;; the machine description, but typically on a RISC machine these can
1239 ;; only be pseudo registers that did not get hard registers, while on
1240 ;; other machines explicit memory references will get optional
1241 ;; reloads.
1243 ;; If a scratch register is required to move an object to or from memory, it
1244 ;; can be allocated using `gen_reg_rtx' prior to reload.  But this is
1245 ;; impossible during and after reload.  If there are cases needing scratch
1246 ;; registers after reload, you must define `SECONDARY_INPUT_RELOAD_CLASS' and
1247 ;; perhaps also `SECONDARY_OUTPUT_RELOAD_CLASS' to detect them, and provide
1248 ;; patterns `reload_inM' or `reload_outM' to handle them.
1250 ;; The constraints on a `moveM' must permit moving any hard register to any
1251 ;; other hard register provided that `HARD_REGNO_MODE_OK' permits mode M in
1252 ;; both registers and `REGISTER_MOVE_COST' applied to their classes returns a
1253 ;; value of 2.
1255 ;; It is obligatory to support floating point `moveM' instructions
1256 ;; into and out of any registers that can hold fixed point values,
1257 ;; because unions and structures (which have modes `SImode' or
1258 ;; `DImode') can be in those registers and they may have floating
1259 ;; point members.
1261 ;; There may also be a need to support fixed point `moveM' instructions in and
1262 ;; out of floating point registers.  Unfortunately, I have forgotten why this
1263 ;; was so, and I don't know whether it is still true.  If `HARD_REGNO_MODE_OK'
1264 ;; rejects fixed point values in floating point registers, then the constraints
1265 ;; of the fixed point `moveM' instructions must be designed to avoid ever
1266 ;; trying to reload into a floating point register.
1268 (define_expand "movqi"
1269   [(set (match_operand:QI 0 "general_operand" "")
1270         (match_operand:QI 1 "general_operand" ""))]
1271   ""
1272   "
1274   if (!reload_in_progress
1275       && !reload_completed
1276       && !register_operand (operands[0], QImode)
1277       && !reg_or_0_operand (operands[1], QImode))
1278     operands[1] = copy_to_mode_reg (QImode, operands[1]);
1281 (define_insn "*movqi_load"
1282   [(set (match_operand:QI 0 "register_operand" "=d,f")
1283         (match_operand:QI 1 "frv_load_operand" "m,m"))]
1284   ""
1285   "* return output_move_single (operands, insn);"
1286   [(set_attr "length" "4")
1287    (set_attr "type" "gload,fload")])
1289 (define_insn "*movqi_internal"
1290   [(set (match_operand:QI 0 "move_destination_operand" "=d,d,m,m,?f,?f,?d,?m,f")
1291         (match_operand:QI 1 "move_source_operand"       "L,d,d,O, d, f, f, f,GO"))]
1292   "register_operand(operands[0], QImode) || reg_or_0_operand (operands[1], QImode)"
1293   "* return output_move_single (operands, insn);"
1294   [(set_attr "length" "4")
1295    (set_attr "type" "int,int,gstore,gstore,movgf,fsconv,movfg,fstore,movgf")])
1297 (define_expand "movhi"
1298   [(set (match_operand:HI 0 "general_operand" "")
1299         (match_operand:HI 1 "general_operand" ""))]
1300   ""
1301   "
1303   if (!reload_in_progress
1304       && !reload_completed
1305       && !register_operand (operands[0], HImode)
1306       && !reg_or_0_operand (operands[1], HImode))
1307     operands[1] = copy_to_mode_reg (HImode, operands[1]);
1310 (define_insn "*movhi_load"
1311   [(set (match_operand:HI 0 "register_operand" "=d,f")
1312         (match_operand:HI 1 "frv_load_operand" "m,m"))]
1313   ""
1314   "* return output_move_single (operands, insn);"
1315   [(set_attr "length" "4")
1316    (set_attr "type" "gload,fload")])
1318 (define_insn "*movhi_internal"
1319   [(set (match_operand:HI 0 "move_destination_operand" "=d,d,d,m,m,?f,?f,?d,?m,f")
1320         (match_operand:HI 1 "move_source_operand"       "L,i,d,d,O, d, f, f, f,GO"))]
1321   "register_operand(operands[0], HImode) || reg_or_0_operand (operands[1], HImode)"
1322   "* return output_move_single (operands, insn);"
1323   [(set_attr "length" "4,8,4,4,4,4,4,4,4,4")
1324    (set_attr "type" "int,multi,int,gstore,gstore,movgf,fsconv,movfg,fstore,movgf")])
1326 ;; Split 2 word load of constants into sethi/setlo instructions
1327 (define_split
1328   [(set (match_operand:HI 0 "integer_register_operand" "")
1329         (match_operand:HI 1 "int_2word_operand" ""))]
1330   "reload_completed"
1331   [(set (match_dup 0)
1332         (high:HI (match_dup 1)))
1333    (set (match_dup 0)
1334         (lo_sum:HI (match_dup 0)
1335                 (match_dup 1)))]
1336   "")
1338 (define_insn "movhi_high"
1339   [(set (match_operand:HI 0 "integer_register_operand" "=d")
1340         (high:HI (match_operand:HI 1 "int_2word_operand" "i")))]
1341   ""
1342   "sethi #hi(%1), %0"
1343   [(set_attr "type" "sethi")
1344    (set_attr "length" "4")])
1346 (define_insn "movhi_lo_sum"
1347   [(set (match_operand:HI 0 "integer_register_operand" "+d")
1348         (lo_sum:HI (match_dup 0)
1349                    (match_operand:HI 1 "int_2word_operand" "i")))]
1350   ""
1351   "setlo #lo(%1), %0"
1352   [(set_attr "type" "setlo")
1353    (set_attr "length" "4")])
1355 (define_expand "movsi"
1356   [(set (match_operand:SI 0 "move_destination_operand" "")
1357         (match_operand:SI 1 "move_source_operand" ""))]
1358   ""
1359   "
1361   if (frv_emit_movsi (operands[0], operands[1]))
1362     DONE;
1365 ;; Note - it is best to only have one movsi pattern and to handle
1366 ;; all the various contingencies by the use of alternatives.  This
1367 ;; allows reload the greatest amount of flexibility (since reload will
1368 ;; only choose amoungst alternatives for a selected insn, it will not
1369 ;; replace the insn with another one).
1371 ;; Unfortunately, we do have to separate out load-type moves from the rest,
1372 ;; and only allow memory source operands in the former.  If we do memory and
1373 ;; constant loads in a single pattern, reload will be tempted to force
1374 ;; constants into memory when the destination is a floating-point register.
1375 ;; That may make a function use a PIC pointer when it didn't before, and we
1376 ;; cannot change PIC usage (and hence stack layout) so late in the game.
1377 ;; The resulting sequences for loading constants into FPRs are preferable
1378 ;; even when we're not generating PIC code.
1380 (define_insn "*movsi_load"
1381   [(set (match_operand:SI 0 "register_operand" "=d,f")
1382         (match_operand:SI 1 "frv_load_operand" "m,m"))]
1383   ""
1384   "* return output_move_single (operands, insn);"
1385   [(set_attr "length" "4")
1386    (set_attr "type" "gload,fload")])
1388 (define_insn "*movsi_internal"
1389   [(set (match_operand:SI 0 "move_destination_operand" "=d,d,d,m,m,z,d,d,f,f,m,?f,?z")
1390         (match_operand:SI 1 "move_source_operand"      "LQ,i,d,d,O,d,z,f,d,f,f,GO,GO"))]
1391   "register_operand (operands[0], SImode) || reg_or_0_operand (operands[1], SImode)"
1392   "* return output_move_single (operands, insn);"
1393   [(set_attr "length" "4,8,4,4,4,4,4,4,4,4,4,4,4")
1394    (set_attr "type" "int,multi,int,gstore,gstore,spr,spr,movfg,movgf,fsconv,fstore,movgf,spr")])
1396 (define_insn "*movsi_lda_sdata"
1397   [(set (match_operand:SI 0 "integer_register_operand" "=d")
1398         (plus:SI (match_operand:SI 1 "small_data_register_operand" "d")
1399                  (match_operand:SI 2 "small_data_symbolic_operand" "Q")))]
1400   ""
1401   "addi %1, #gprel12(%2), %0"
1402   [(set_attr "type" "int")
1403    (set_attr "length" "4")])
1405 ;; Split 2 word load of constants into sethi/setlo instructions
1406 (define_split
1407   [(set (match_operand:SI 0 "integer_register_operand" "")
1408         (match_operand:SI 1 "int_2word_operand" ""))]
1409   "reload_completed"
1410   [(set (match_dup 0)
1411         (high:SI (match_dup 1)))
1412    (set (match_dup 0)
1413         (lo_sum:SI (match_dup 0)
1414                 (match_dup 1)))]
1415   "")
1417 (define_insn "movsi_high"
1418   [(set (match_operand:SI 0 "integer_register_operand" "=d")
1419         (high:SI (match_operand:SI 1 "int_2word_operand" "i")))]
1420   ""
1421   "sethi #hi(%1), %0"
1422   [(set_attr "type" "sethi")
1423    (set_attr "length" "4")])
1425 (define_insn "movsi_lo_sum"
1426   [(set (match_operand:SI 0 "integer_register_operand" "+d")
1427         (lo_sum:SI (match_dup 0)
1428                    (match_operand:SI 1 "int_2word_operand" "i")))]
1429   ""
1430   "setlo #lo(%1), %0"
1431   [(set_attr "type" "setlo")
1432    (set_attr "length" "4")])
1434 ;; Split loads of addresses with PIC specified into 3 separate instructions
1435 (define_insn_and_split "*movsi_pic"
1436   [(set (match_operand:SI 0 "integer_register_operand" "=d")
1437         (plus:SI (match_operand:SI 1 "pic_register_operand" "d")
1438                  (match_operand:SI 2 "pic_symbolic_operand" "")))]
1439   ""
1440   "#"
1441   "reload_completed"
1442   [(set (match_dup 0)
1443         (high:SI (match_dup 2)))
1444    (set (match_dup 0)
1445         (lo_sum:SI (match_dup 0)
1446                    (match_dup 2)))
1447    (set (match_dup 0)
1448         (plus:SI (match_dup 0) (match_dup 1)))]
1450   ""
1451   [(set_attr "type" "multi")
1452    (set_attr "length" "12")])
1454 (define_insn "movsi_high_pic"
1455   [(set (match_operand:SI 0 "integer_register_operand" "=d")
1456         (high:SI (match_operand:SI 1 "pic_symbolic_operand" "")))]
1457   ""
1458   "sethi #gprelhi(%1), %0"
1459   [(set_attr "type" "sethi")
1460    (set_attr "length" "4")])
1462 (define_insn "movsi_lo_sum_pic"
1463   [(set (match_operand:SI 0 "integer_register_operand" "+d")
1464         (lo_sum:SI (match_dup 0)
1465                    (match_operand:SI 1 "pic_symbolic_operand" "")))]
1466   ""
1467   "setlo #gprello(%1), %0"
1468   [(set_attr "type" "setlo")
1469    (set_attr "length" "4")])
1471 (define_expand "movdi"
1472   [(set (match_operand:DI 0 "nonimmediate_operand" "")
1473         (match_operand:DI 1 "general_operand" ""))]
1474   ""
1475   "
1477   if (!reload_in_progress
1478       && !reload_completed
1479       && !register_operand (operands[0], DImode)
1480       && !reg_or_0_operand (operands[1], DImode))
1481     operands[1] = copy_to_mode_reg (DImode, operands[1]);
1484 (define_insn "*movdi_double"
1485   [(set (match_operand:DI 0 "move_destination_operand" "=e,?h,??d,??f,R,?R,??m,??m,e,?h,??d,??f,?e,??d,?h,??f,R,m,e,??d,e,??d,?h,??f")
1486         (match_operand:DI 1 "move_source_operand"      " e,h,d,f,e,h,d,f,R,R,m,m,h,f,e,d,GO,GO,GO,GO,nF,nF,GO,GO"))]
1487   "TARGET_DOUBLE
1488    && (register_operand (operands[0], DImode)
1489        || reg_or_0_operand (operands[1], DImode))"
1490   "* return output_move_double (operands, insn);"
1491   [(set_attr "length" "8,4,8,8,4,4,8,8,4,4,8,8,4,8,4,8,4,8,8,8,16,16,8,8")
1492    (set_attr "type" "multi,fdconv,multi,multi,gstore,fstore,gstore,fstore,gload,fload,gload,fload,movfg,movfg,movgf,movgf,gstore,gstore,multi,multi,multi,multi,movgf,movgf")])
1494 (define_insn "*movdi_nodouble"
1495   [(set (match_operand:DI 0 "move_destination_operand" "=e,?h,??d,??f,R,?R,??m,??m,e,?h,??d,??f,?e,??d,?h,??f,R,m,e,??d,e,??d,?h,??f")
1496         (match_operand:DI 1 "move_source_operand"      " e,h,d,f,e,h,d,f,R,R,m,m,h,f,e,d,GO,GO,GO,GO,nF,nF,GO,GO"))]
1497   "!TARGET_DOUBLE
1498    && (register_operand (operands[0], DImode)
1499        || reg_or_0_operand (operands[1], DImode))"
1500   "* return output_move_double (operands, insn);"
1501   [(set_attr "length" "8,8,8,8,4,4,8,8,4,4,8,8,8,8,8,8,4,8,8,8,16,16,8,8")
1502    (set_attr "type" "multi,multi,multi,multi,gstore,fstore,gstore,fstore,gload,fload,gload,fload,movfg,movfg,movgf,movgf,gstore,gstore,multi,multi,multi,multi,movgf,movgf")])
1504 (define_split
1505   [(set (match_operand:DI 0 "register_operand" "")
1506         (match_operand:DI 1 "dbl_memory_two_insn_operand" ""))]
1507   "reload_completed"
1508   [(const_int 0)]
1509   "frv_split_double_load (operands[0], operands[1]);")
1511 (define_split
1512   [(set (match_operand:DI 0 "odd_reg_operand" "")
1513         (match_operand:DI 1 "memory_operand" ""))]
1514   "reload_completed"
1515   [(const_int 0)]
1516   "frv_split_double_load (operands[0], operands[1]);")
1518 (define_split
1519   [(set (match_operand:DI 0 "dbl_memory_two_insn_operand" "")
1520         (match_operand:DI 1 "reg_or_0_operand" ""))]
1521   "reload_completed"
1522   [(const_int 0)]
1523   "frv_split_double_store (operands[0], operands[1]);")
1525 (define_split
1526   [(set (match_operand:DI 0 "memory_operand" "")
1527         (match_operand:DI 1 "odd_reg_operand" ""))]
1528   "reload_completed"
1529   [(const_int 0)]
1530   "frv_split_double_store (operands[0], operands[1]);")
1532 (define_split
1533   [(set (match_operand:DI 0 "register_operand" "")
1534         (match_operand:DI 1 "register_operand" ""))]
1535   "reload_completed
1536    && (odd_reg_operand (operands[0], DImode)
1537        || odd_reg_operand (operands[1], DImode)
1538        || (integer_register_operand (operands[0], DImode)
1539            && integer_register_operand (operands[1], DImode))
1540        || (!TARGET_DOUBLE
1541            && fpr_operand (operands[0], DImode)
1542            && fpr_operand (operands[1], DImode)))"
1543   [(set (match_dup 2) (match_dup 4))
1544    (set (match_dup 3) (match_dup 5))]
1545   "
1547   rtx op0      = operands[0];
1548   rtx op0_low  = gen_lowpart (SImode, op0);
1549   rtx op0_high = gen_highpart (SImode, op0);
1550   rtx op1      = operands[1];
1551   rtx op1_low  = gen_lowpart (SImode, op1);
1552   rtx op1_high = gen_highpart (SImode, op1);
1554   /* We normally copy the low-numbered register first.  However, if the first
1555      register operand 0 is the same as the second register of operand 1, we
1556      must copy in the opposite order.  */
1558   if (REGNO (op0_high) == REGNO (op1_low))
1559     {
1560       operands[2] = op0_low;
1561       operands[3] = op0_high;
1562       operands[4] = op1_low;
1563       operands[5] = op1_high;
1564     }
1565   else
1566     {
1567       operands[2] = op0_high;
1568       operands[3] = op0_low;
1569       operands[4] = op1_high;
1570       operands[5] = op1_low;
1571     }
1574 (define_split
1575   [(set (match_operand:DI 0 "register_operand" "")
1576         (match_operand:DI 1 "const_int_operand" ""))]
1577   "reload_completed"
1578   [(set (match_dup 2) (match_dup 4))
1579    (set (match_dup 3) (match_dup 1))]
1580   "
1582   rtx op0 = operands[0];
1583   rtx op1 = operands[1];
1585   operands[2] = gen_highpart (SImode, op0);
1586   operands[3] = gen_lowpart (SImode, op0);
1587   operands[4] = GEN_INT ((INTVAL (op1) < 0) ? -1 : 0);
1590 (define_split
1591   [(set (match_operand:DI 0 "register_operand" "")
1592         (match_operand:DI 1 "const_double_operand" ""))]
1593   "reload_completed"
1594   [(set (match_dup 2) (match_dup 4))
1595    (set (match_dup 3) (match_dup 5))]
1596   "
1598   rtx op0 = operands[0];
1599   rtx op1 = operands[1];
1601   operands[2] = gen_highpart (SImode, op0);
1602   operands[3] = gen_lowpart (SImode, op0);
1603   operands[4] = GEN_INT (CONST_DOUBLE_HIGH (op1));
1604   operands[5] = GEN_INT (CONST_DOUBLE_LOW (op1));
1607 ;; Floating Point Moves
1609 ;; Note - Patterns for SF mode moves are compulsory, but
1610 ;; patterns for DF are optional, as GCC can synthesize them.
1612 (define_expand "movsf"
1613   [(set (match_operand:SF 0 "general_operand" "")
1614         (match_operand:SF 1 "general_operand" ""))]
1615   ""
1616   "
1618   if (!reload_in_progress
1619       && !reload_completed
1620       && !register_operand (operands[0], SFmode)
1621       && !reg_or_0_operand (operands[1], SFmode))
1622     operands[1] = copy_to_mode_reg (SFmode, operands[1]);
1625 (define_split
1626   [(set (match_operand:SF 0 "integer_register_operand" "")
1627         (match_operand:SF 1 "int_2word_operand" ""))]
1628   "reload_completed"
1629   [(set (match_dup 0)
1630         (high:SF (match_dup 1)))
1631    (set (match_dup 0)
1632         (lo_sum:SF (match_dup 0)
1633                 (match_dup 1)))]
1634   "")
1636 (define_insn "*movsf_load_has_fprs"
1637   [(set (match_operand:SF 0 "register_operand" "=f,d")
1638         (match_operand:SF 1 "frv_load_operand" "m,m"))]
1639   "TARGET_HAS_FPRS"
1640   "* return output_move_single (operands, insn);"
1641   [(set_attr "length" "4")
1642    (set_attr "type" "fload,gload")])
1644 (define_insn "*movsf_internal_has_fprs"
1645   [(set (match_operand:SF 0 "move_destination_operand" "=f,f,m,m,?f,?d,?d,m,?d")
1646         (match_operand:SF 1 "move_source_operand" "f,OG,f,OG,d,f,d,d,F"))]
1647   "TARGET_HAS_FPRS
1648    && (register_operand (operands[0], SFmode) || reg_or_0_operand (operands[1], SFmode))"
1649   "* return output_move_single (operands, insn);"
1650   [(set_attr "length" "4,4,4,4,4,4,4,4,8")
1651    (set_attr "type" "fsconv,movgf,fstore,gstore,movgf,movfg,int,gstore,multi")])
1653 ;; If we don't support the double instructions, prefer gprs over fprs, since it
1654 ;; will all be emulated
1655 (define_insn "*movsf_internal_no_fprs"
1656   [(set (match_operand:SF 0 "move_destination_operand" "=d,d,m,d,d")
1657         (match_operand:SF 1 "move_source_operand"      " d,OG,dOG,m,F"))]
1658   "!TARGET_HAS_FPRS
1659    && (register_operand (operands[0], SFmode) || reg_or_0_operand (operands[1], SFmode))"
1660   "* return output_move_single (operands, insn);"
1661   [(set_attr "length" "4,4,4,4,8")
1662    (set_attr "type" "int,int,gstore,gload,multi")])
1664 (define_insn "movsf_high"
1665   [(set (match_operand:SF 0 "integer_register_operand" "=d")
1666         (high:SF (match_operand:SF 1 "int_2word_operand" "i")))]
1667   ""
1668   "sethi #hi(%1), %0"
1669   [(set_attr "type" "sethi")
1670    (set_attr "length" "4")])
1672 (define_insn "movsf_lo_sum"
1673   [(set (match_operand:SF 0 "integer_register_operand" "+d")
1674         (lo_sum:SF (match_dup 0)
1675                    (match_operand:SF 1 "int_2word_operand" "i")))]
1676   ""
1677   "setlo #lo(%1), %0"
1678   [(set_attr "type" "setlo")
1679    (set_attr "length" "4")])
1681 (define_expand "movdf"
1682   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1683         (match_operand:DF 1 "general_operand" ""))]
1684   ""
1685   "
1687   if (!reload_in_progress
1688       && !reload_completed
1689       && !register_operand (operands[0], DFmode)
1690       && !reg_or_0_operand (operands[1], DFmode))
1691     operands[1] = copy_to_mode_reg (DFmode, operands[1]);
1694 (define_insn "*movdf_double"
1695   [(set (match_operand:DF 0 "move_destination_operand" "=h,?e,??f,??d,R,?R,??m,??m,h,?e,??f,??d,?h,??f,?e,??d,R,m,h,??f,e,??d")
1696         (match_operand:DF 1 "move_source_operand"      " h,e,f,d,h,e,f,d,R,R,m,m,e,d,h,f,GO,GO,GO,GO,GO,GO"))]
1697   "TARGET_DOUBLE
1698    && (register_operand (operands[0], DFmode)
1699        || reg_or_0_operand (operands[1], DFmode))"
1700   "* return output_move_double (operands, insn);"
1701   [(set_attr "length" "4,8,8,8,4,4,8,8,4,4,8,8,4,8,4,8,4,8,8,8,8,8")
1702    (set_attr "type" "fdconv,multi,multi,multi,fstore,gstore,fstore,gstore,fload,gload,fload,gload,movgf,movgf,movfg,movfg,gstore,gstore,movgf,movgf,multi,multi")])
1704 ;; If we don't support the double instructions, prefer gprs over fprs, since it
1705 ;; will all be emulated
1706 (define_insn "*movdf_nodouble"
1707   [(set (match_operand:DF 0 "move_destination_operand" "=e,?h,??d,??f,R,?R,??m,??m,e,?h,??d,??f,?e,??d,?h,??f,R,m,e,??d,e,??d,?h,??f")
1708         (match_operand:DF 1 "move_source_operand"      " e,h,d,f,e,h,d,f,R,R,m,m,h,f,e,d,GO,GO,GO,GO,nF,nF,GO,GO"))]
1709   "!TARGET_DOUBLE
1710    && (register_operand (operands[0], DFmode)
1711        || reg_or_0_operand (operands[1], DFmode))"
1712   "* return output_move_double (operands, insn);"
1713   [(set_attr "length" "8,8,8,8,4,4,8,8,4,4,8,8,8,8,8,8,4,8,8,8,16,16,8,8")
1714    (set_attr "type" "multi,multi,multi,multi,gstore,fstore,gstore,fstore,gload,fload,gload,fload,movfg,movfg,movgf,movgf,gstore,gstore,multi,multi,multi,multi,movgf,movgf")])
1716 (define_split
1717   [(set (match_operand:DF 0 "register_operand" "")
1718         (match_operand:DF 1 "dbl_memory_two_insn_operand" ""))]
1719   "reload_completed"
1720   [(const_int 0)]
1721   "frv_split_double_load (operands[0], operands[1]);")
1723 (define_split
1724   [(set (match_operand:DF 0 "odd_reg_operand" "")
1725         (match_operand:DF 1 "memory_operand" ""))]
1726   "reload_completed"
1727   [(const_int 0)]
1728   "frv_split_double_load (operands[0], operands[1]);")
1730 (define_split
1731   [(set (match_operand:DF 0 "dbl_memory_two_insn_operand" "")
1732         (match_operand:DF 1 "reg_or_0_operand" ""))]
1733   "reload_completed"
1734   [(const_int 0)]
1735   "frv_split_double_store (operands[0], operands[1]);")
1737 (define_split
1738   [(set (match_operand:DF 0 "memory_operand" "")
1739         (match_operand:DF 1 "odd_reg_operand" ""))]
1740   "reload_completed"
1741   [(const_int 0)]
1742   "frv_split_double_store (operands[0], operands[1]);")
1744 (define_split
1745   [(set (match_operand:DF 0 "register_operand" "")
1746         (match_operand:DF 1 "register_operand" ""))]
1747   "reload_completed
1748    && (odd_reg_operand (operands[0], DFmode)
1749        || odd_reg_operand (operands[1], DFmode)
1750        || (integer_register_operand (operands[0], DFmode)
1751            && integer_register_operand (operands[1], DFmode))
1752        || (!TARGET_DOUBLE
1753            && fpr_operand (operands[0], DFmode)
1754            && fpr_operand (operands[1], DFmode)))"
1755   [(set (match_dup 2) (match_dup 4))
1756    (set (match_dup 3) (match_dup 5))]
1757   "
1759   rtx op0      = operands[0];
1760   rtx op0_low  = gen_lowpart (SImode, op0);
1761   rtx op0_high = gen_highpart (SImode, op0);
1762   rtx op1      = operands[1];
1763   rtx op1_low  = gen_lowpart (SImode, op1);
1764   rtx op1_high = gen_highpart (SImode, op1);
1766   /* We normally copy the low-numbered register first.  However, if the first
1767      register operand 0 is the same as the second register of operand 1, we
1768      must copy in the opposite order.  */
1770   if (REGNO (op0_high) == REGNO (op1_low))
1771     {
1772       operands[2] = op0_low;
1773       operands[3] = op0_high;
1774       operands[4] = op1_low;
1775       operands[5] = op1_high;
1776     }
1777   else
1778     {
1779       operands[2] = op0_high;
1780       operands[3] = op0_low;
1781       operands[4] = op1_high;
1782       operands[5] = op1_low;
1783     }
1786 (define_split
1787   [(set (match_operand:DF 0 "register_operand" "")
1788         (match_operand:DF 1 "const_int_operand" ""))]
1789   "reload_completed"
1790   [(set (match_dup 2) (match_dup 4))
1791    (set (match_dup 3) (match_dup 1))]
1792   "
1794   rtx op0 = operands[0];
1795   rtx op1 = operands[1];
1797   operands[2] = gen_highpart (SImode, op0);
1798   operands[3] = gen_lowpart (SImode, op0);
1799   operands[4] = GEN_INT ((INTVAL (op1) < 0) ? -1 : 0);
1802 (define_split
1803   [(set (match_operand:DF 0 "register_operand" "")
1804         (match_operand:DF 1 "const_double_operand" ""))]
1805   "reload_completed"
1806   [(set (match_dup 2) (match_dup 4))
1807    (set (match_dup 3) (match_dup 5))]
1808   "
1810   rtx op0 = operands[0];
1811   rtx op1 = operands[1];
1812   REAL_VALUE_TYPE rv;
1813   long l[2];
1815   REAL_VALUE_FROM_CONST_DOUBLE (rv, op1);
1816   REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
1818   operands[2] = gen_highpart (SImode, op0);
1819   operands[3] = gen_lowpart (SImode, op0);
1820   operands[4] = GEN_INT (l[0]);
1821   operands[5] = GEN_INT (l[1]);
1824 ;; String/block move insn.
1825 ;; Argument 0 is the destination
1826 ;; Argument 1 is the source
1827 ;; Argument 2 is the length
1828 ;; Argument 3 is the alignment
1830 (define_expand "movstrsi"
1831   [(parallel [(set (match_operand:BLK 0 "" "")
1832                    (match_operand:BLK 1 "" ""))
1833               (use (match_operand:SI 2 "" ""))
1834               (use (match_operand:SI 3 "" ""))])]
1835   ""
1836   "
1838   if (frv_expand_block_move (operands))
1839     DONE;
1840   else
1841     FAIL;
1844 ;; String/block clear insn.
1845 ;; Argument 0 is the destination
1846 ;; Argument 1 is the length
1847 ;; Argument 2 is the alignment
1849 (define_expand "clrstrsi"
1850   [(parallel [(set (match_operand:BLK 0 "" "")
1851                    (const_int 0))
1852               (use (match_operand:SI 1 "" ""))
1853               (use (match_operand:SI 2 "" ""))])]
1854   ""
1855   "
1857   if (frv_expand_block_clear (operands))
1858     DONE;
1859   else
1860     FAIL;
1864 ;; ::::::::::::::::::::
1865 ;; ::
1866 ;; :: Reload CC registers
1867 ;; ::
1868 ;; ::::::::::::::::::::
1870 ;; Use as a define_expand so that cse/gcse/combine can't accidentally
1871 ;; create movcc insns.
1873 (define_expand "movcc"
1874   [(parallel [(set (match_operand:CC 0 "move_destination_operand" "")
1875                    (match_operand:CC 1 "move_source_operand" ""))
1876               (clobber (match_dup 2))])]
1877   ""
1878   "
1880  if (! reload_in_progress && ! reload_completed)
1881     FAIL;
1883  operands[2] = gen_rtx_REG (CC_CCRmode, ICR_TEMP);
1886 (define_insn "*internal_movcc"
1887   [(set (match_operand:CC 0 "move_destination_operand" "=t,d,d,m,d")
1888         (match_operand:CC 1 "move_source_operand" "d,d,m,d,t"))
1889    (clobber (match_scratch:CC_CCR 2 "=X,X,X,X,&v"))]
1890   "reload_in_progress || reload_completed"
1891   "@
1892    cmpi %1, #0, %0
1893    mov %1, %0
1894    ld%I1%U1 %M1, %0
1895    st%I0%U0 %1, %M0
1896    #"
1897   [(set_attr "length" "4,4,4,4,20")
1898    (set_attr "type" "int,int,gload,gstore,multi")])
1900 ;; To move an ICC value to a GPR for a signed comparison, we create a value
1901 ;; that when compared to 0, sets the N and Z flags appropriately (we don't care
1902 ;; about the V and C flags, since these comparisons are signed).
1904 (define_split
1905   [(set (match_operand:CC 0 "integer_register_operand" "")
1906         (match_operand:CC 1 "icc_operand" ""))
1907    (clobber (match_operand:CC_CCR 2 "icr_operand" ""))]
1908   "reload_in_progress || reload_completed"
1909   [(match_dup 3)]
1910   "
1912   rtx dest = simplify_gen_subreg (SImode, operands[0], CCmode, 0);
1913   rtx icc  = operands[1];
1914   rtx icr  = operands[2];
1916   start_sequence ();
1918   emit_insn (gen_rtx_SET (VOIDmode, icr,
1919                           gen_rtx_LT (CC_CCRmode, icc, const0_rtx)));
1921   emit_insn (gen_movsi (dest, const1_rtx));
1923   emit_insn (gen_rtx_COND_EXEC (VOIDmode,
1924                                 gen_rtx_NE (CC_CCRmode, icr, const0_rtx),
1925                                 gen_rtx_SET (VOIDmode, dest,
1926                                              gen_rtx_NEG (SImode, dest))));
1928   emit_insn (gen_rtx_SET (VOIDmode, icr,
1929                           gen_rtx_EQ (CC_CCRmode, icc, const0_rtx)));
1931   emit_insn (gen_rtx_COND_EXEC (VOIDmode,
1932                                 gen_rtx_NE (CC_CCRmode, icr, const0_rtx),
1933                                 gen_rtx_SET (VOIDmode, dest, const0_rtx)));
1935   operands[3] = get_insns ();
1936   end_sequence ();
1939 (define_expand "reload_incc"
1940   [(parallel [(set (match_operand:CC 2 "integer_register_operand" "=&d")
1941                    (match_operand:CC 1 "memory_operand" "m"))
1942               (clobber (match_scratch:CC_CCR 3 ""))])
1943    (parallel [(set (match_operand:CC 0 "icc_operand" "=t")
1944                    (match_dup 2))
1945               (clobber (match_scratch:CC_CCR 4 ""))])]
1946   ""
1947   "")
1949 (define_expand "reload_outcc"
1950   [(parallel [(set (match_operand:CC 2 "integer_register_operand" "=&d")
1951                    (match_operand:CC 1 "icc_operand" "t"))
1952               (clobber (match_dup 3))])
1953    (parallel [(set (match_operand:CC 0 "memory_operand" "=m")
1954                    (match_dup 2))
1955               (clobber (match_scratch:CC_CCR 4 ""))])]
1956   ""
1957   "operands[3] = gen_rtx_REG (CC_CCRmode, ICR_TEMP);")
1959 ;; Reload CC_UNSmode for unsigned integer comparisons
1960 ;; Use define_expand so that cse/gcse/combine can't create movcc_uns insns
1962 (define_expand "movcc_uns"
1963   [(parallel [(set (match_operand:CC_UNS 0 "move_destination_operand" "")
1964                    (match_operand:CC_UNS 1 "move_source_operand" ""))
1965               (clobber (match_dup 2))])]
1966   ""
1967   "
1969  if (! reload_in_progress && ! reload_completed)
1970     FAIL;
1971  operands[2] = gen_rtx_REG (CC_CCRmode, ICR_TEMP);
1974 (define_insn "*internal_movcc_uns"
1975   [(set (match_operand:CC_UNS 0 "move_destination_operand" "=t,d,d,m,d")
1976         (match_operand:CC_UNS 1 "move_source_operand" "d,d,m,d,t"))
1977    (clobber (match_scratch:CC_CCR 2 "=X,X,X,X,&v"))]
1978   "reload_in_progress || reload_completed"
1979   "@
1980    cmpi %1, #1, %0
1981    mov %1, %0
1982    ld%I1%U1 %M1, %0
1983    st%I0%U0 %1, %M0
1984    #"
1985   [(set_attr "length" "4,4,4,4,20")
1986    (set_attr "type" "int,int,gload,gstore,multi")])
1988 ;; To move an ICC value to a GPR for an unsigned comparison, we create a value
1989 ;; that when compared to 1, sets the Z, V, and C flags appropriately (we don't
1990 ;; care about the N flag, since these comparisons are unsigned).
1992 (define_split
1993   [(set (match_operand:CC_UNS 0 "integer_register_operand" "")
1994         (match_operand:CC_UNS 1 "icc_operand" ""))
1995    (clobber (match_operand:CC_CCR 2 "icr_operand" ""))]
1996   "reload_in_progress || reload_completed"
1997   [(match_dup 3)]
1998   "
2000   rtx dest = simplify_gen_subreg (SImode, operands[0], CC_UNSmode, 0);
2001   rtx icc  = operands[1];
2002   rtx icr  = operands[2];
2004   start_sequence ();
2006   emit_insn (gen_rtx_SET (VOIDmode, icr,
2007                           gen_rtx_GTU (CC_CCRmode, icc, const0_rtx)));
2009   emit_insn (gen_movsi (dest, const1_rtx));
2011   emit_insn (gen_rtx_COND_EXEC (VOIDmode,
2012                                 gen_rtx_NE (CC_CCRmode, icr, const0_rtx),
2013                                 gen_addsi3 (dest, dest, dest)));
2015   emit_insn (gen_rtx_SET (VOIDmode, icr,
2016                           gen_rtx_LTU (CC_CCRmode, icc, const0_rtx)));
2018   emit_insn (gen_rtx_COND_EXEC (VOIDmode,
2019                                 gen_rtx_NE (CC_CCRmode, icr, const0_rtx),
2020                                 gen_rtx_SET (VOIDmode, dest, const0_rtx)));
2022   operands[3] = get_insns ();
2023   end_sequence ();
2026 (define_expand "reload_incc_uns"
2027   [(parallel [(set (match_operand:CC_UNS 2 "integer_register_operand" "=&d")
2028                    (match_operand:CC_UNS 1 "memory_operand" "m"))
2029               (clobber (match_scratch:CC_CCR 3 ""))])
2030    (parallel [(set (match_operand:CC_UNS 0 "icc_operand" "=t")
2031                    (match_dup 2))
2032               (clobber (match_scratch:CC_CCR 4 ""))])]
2033   ""
2034   "")
2036 (define_expand "reload_outcc_uns"
2037   [(parallel [(set (match_operand:CC_UNS 2 "integer_register_operand" "=&d")
2038                    (match_operand:CC_UNS 1 "icc_operand" "t"))
2039               (clobber (match_dup 3))])
2040    (parallel [(set (match_operand:CC_UNS 0 "memory_operand" "=m")
2041                    (match_dup 2))
2042               (clobber (match_scratch:CC_CCR 4 ""))])]
2043   ""
2044   "operands[3] = gen_rtx_REG (CC_CCRmode, ICR_TEMP);")
2046 ;; Reload CC_FPmode for floating point comparisons
2047 ;; We use a define_expand here so that cse/gcse/combine can't accidentally
2048 ;; create movcc insns.  If this was a named define_insn, we would not be able
2049 ;; to make it conditional on reload.
2051 (define_expand "movcc_fp"
2052   [(set (match_operand:CC_FP 0 "move_destination_operand" "")
2053         (match_operand:CC_FP 1 "move_source_operand" ""))]
2054   "TARGET_HAS_FPRS"
2055   "
2057  if (! reload_in_progress && ! reload_completed)
2058     FAIL;
2061 (define_insn "*movcc_fp_internal"
2062   [(set (match_operand:CC_FP 0 "move_destination_operand" "=d,d,d,m")
2063         (match_operand:CC_FP 1 "move_source_operand" "u,d,m,d"))]
2064   "TARGET_HAS_FPRS && (reload_in_progress || reload_completed)"
2065   "@
2066    #
2067    mov %1, %0
2068    ld%I1%U1 %M1, %0
2069    st%I0%U0 %1, %M0"
2070   [(set_attr "length" "12,4,4,4")
2071    (set_attr "type" "multi,int,gload,gstore")])
2074 (define_expand "reload_incc_fp"
2075   [(match_operand:CC_FP 0 "fcc_operand" "=u")
2076    (match_operand:CC_FP 1 "memory_operand" "m")
2077    (match_operand:TI 2 "integer_register_operand" "=&d")]
2078   "TARGET_HAS_FPRS"
2079   "
2081   rtx cc_op2 = simplify_gen_subreg (CC_FPmode, operands[2], TImode, 0);
2082   rtx int_op2 = simplify_gen_subreg (SImode, operands[2], TImode, 0);
2083   rtx temp1 = simplify_gen_subreg (SImode, operands[2], TImode, 4);
2084   rtx temp2 = simplify_gen_subreg (SImode, operands[2], TImode, 8);
2085   int shift = CC_SHIFT_RIGHT (REGNO (operands[0]));
2086   HOST_WIDE_INT mask;
2088   emit_insn (gen_movcc_fp (cc_op2, operands[1]));
2089   if (shift)
2090     emit_insn (gen_ashlsi3 (int_op2, int_op2, GEN_INT (shift)));
2092   mask = ~ ((HOST_WIDE_INT)CC_MASK << shift);
2093   emit_insn (gen_movsi (temp1, GEN_INT (mask)));
2094   emit_insn (gen_update_fcc (operands[0], int_op2, temp1, temp2));
2095   DONE;
2098 (define_expand "reload_outcc_fp"
2099   [(set (match_operand:CC_FP 2 "integer_register_operand" "=&d")
2100         (match_operand:CC_FP 1 "fcc_operand" "u"))
2101    (set (match_operand:CC_FP 0 "memory_operand" "=m")
2102         (match_dup 2))]
2103   "TARGET_HAS_FPRS"
2104  "")
2106 ;; Convert a FCC value to gpr
2107 (define_insn "read_fcc"
2108   [(set (match_operand:SI 0 "integer_register_operand" "=d")
2109         (unspec:SI [(match_operand:CC_FP 1 "fcc_operand" "u")]
2110                    UNSPEC_CC_TO_GPR))]
2111   "TARGET_HAS_FPRS"
2112   "movsg ccr, %0"
2113   [(set_attr "type" "spr")
2114    (set_attr "length" "4")])
2116 (define_split
2117   [(set (match_operand:CC_FP 0 "integer_register_operand" "")
2118         (match_operand:CC_FP 1 "fcc_operand" ""))]
2119   "reload_completed && TARGET_HAS_FPRS"
2120   [(match_dup 2)]
2121   "
2123   rtx int_op0 = simplify_gen_subreg (SImode, operands[0], CC_FPmode, 0);
2124   int shift = CC_SHIFT_RIGHT (REGNO (operands[1]));
2126   start_sequence ();
2128   emit_insn (gen_read_fcc (int_op0, operands[1]));
2129   if (shift)
2130     emit_insn (gen_lshrsi3 (int_op0, int_op0, GEN_INT (shift)));
2132   emit_insn (gen_andsi3 (int_op0, int_op0, GEN_INT (CC_MASK)));
2134   operands[2] = get_insns ();
2135   end_sequence ();
2138 ;; Move a gpr value to FCC.
2139 ;; Operand0 = FCC
2140 ;; Operand1 = reloaded value shifted appropriately
2141 ;; Operand2 = mask to eliminate current register
2142 ;; Operand3 = temporary to load/store ccr
2143 (define_insn "update_fcc"
2144   [(set (match_operand:CC_FP 0 "fcc_operand" "=u")
2145         (unspec:CC_FP [(match_operand:SI 1 "integer_register_operand" "d")
2146                        (match_operand:SI 2 "integer_register_operand" "d")]
2147                       UNSPEC_GPR_TO_CC))
2148    (clobber (match_operand:SI 3 "integer_register_operand" "=&d"))]
2149   "TARGET_HAS_FPRS"
2150   "movsg ccr, %3\;and %2, %3, %3\;or %1, %3, %3\;movgs %3, ccr"
2151   [(set_attr "type" "multi")
2152    (set_attr "length" "16")])
2154 ;; Reload CC_CCRmode for conditional execution registers
2155 (define_insn "movcc_ccr"
2156   [(set (match_operand:CC_CCR 0 "move_destination_operand" "=d,d,d,m,v,?w,C,d")
2157         (match_operand:CC_CCR 1 "move_source_operand" "C,d,m,d,n,n,C,L"))]
2158   ""
2159   "@
2160    #
2161    mov %1, %0
2162    ld%I1%U1 %M1, %0
2163    st%I0%U0 %1, %M0
2164    #
2165    #
2166    orcr %1, %1, %0
2167    setlos #%1, %0"
2168   [(set_attr "length" "8,4,4,4,8,12,4,4")
2169    (set_attr "type" "multi,int,gload,gstore,multi,multi,ccr,int")])
2171 (define_expand "reload_incc_ccr"
2172   [(match_operand:CC_CCR 0 "cr_operand" "=C")
2173    (match_operand:CC_CCR 1 "memory_operand" "m")
2174    (match_operand:CC_CCR 2 "integer_register_operand" "=&d")]
2175   ""
2176   "
2178   rtx icc = gen_rtx_REG (CCmode, ICC_TEMP);
2179   rtx int_op2 = simplify_gen_subreg (SImode, operands[2], CC_CCRmode, 0);
2180   rtx icr = (ICR_P (REGNO (operands[0]))
2181              ? operands[0] : gen_rtx_REG (CC_CCRmode, ICR_TEMP));
2183   emit_insn (gen_movcc_ccr (operands[2], operands[1]));
2184   emit_insn (gen_cmpsi_cc (icc, int_op2, const0_rtx));
2185   emit_insn (gen_movcc_ccr (icr, gen_rtx_NE (CC_CCRmode, icc, const0_rtx)));
2187   if (! ICR_P (REGNO (operands[0])))
2188     emit_insn (gen_movcc_ccr (operands[0], icr));
2190   DONE;
2193 (define_expand "reload_outcc_ccr"
2194   [(set (match_operand:CC_CCR 2 "integer_register_operand" "=&d")
2195         (match_operand:CC_CCR 1 "cr_operand" "C"))
2196    (set (match_operand:CC_CCR 0 "memory_operand" "=m")
2197         (match_dup 2))]
2198   ""
2199   "")
2201 (define_split
2202   [(set (match_operand:CC_CCR 0 "integer_register_operand" "")
2203         (match_operand:CC_CCR 1 "cr_operand" ""))]
2204   "reload_completed"
2205   [(match_dup 2)]
2206   "
2208   rtx int_op0 = simplify_gen_subreg (SImode, operands[0], CC_CCRmode, 0);
2210   start_sequence ();
2211   emit_move_insn (operands[0], const1_rtx);
2212   emit_insn (gen_rtx_COND_EXEC (VOIDmode,
2213                                 gen_rtx_EQ (CC_CCRmode,
2214                                             operands[1],
2215                                             const0_rtx),
2216                                 gen_rtx_SET (VOIDmode, int_op0,
2217                                              const0_rtx)));
2219   operands[2] = get_insns ();
2220   end_sequence ();
2223 (define_split
2224   [(set (match_operand:CC_CCR 0 "cr_operand" "")
2225         (match_operand:CC_CCR 1 "const_int_operand" ""))]
2226   "reload_completed"
2227   [(match_dup 2)]
2228   "
2230   rtx icc = gen_rtx_REG (CCmode, ICC_TEMP);
2231   rtx r0  = gen_rtx_REG (SImode, GPR_FIRST);
2232   rtx icr = (ICR_P (REGNO (operands[0]))
2233              ? operands[0] : gen_rtx_REG (CC_CCRmode, ICR_TEMP));
2235   start_sequence ();
2237  emit_insn (gen_cmpsi_cc (icc, r0, const0_rtx));
2239   emit_insn (gen_movcc_ccr (icr,
2240                             gen_rtx_fmt_ee (((INTVAL (operands[1]) == 0)
2241                                              ? EQ : NE), CC_CCRmode,
2242                                             r0, const0_rtx)));
2244   if (! ICR_P (REGNO (operands[0])))
2245     emit_insn (gen_movcc_ccr (operands[0], icr));
2247   operands[2] = get_insns ();
2248   end_sequence ();
2252 ;; ::::::::::::::::::::
2253 ;; ::
2254 ;; :: Conversions
2255 ;; ::
2256 ;; ::::::::::::::::::::
2258 ;; Signed conversions from a smaller integer to a larger integer
2260 ;; These operations are optional.  If they are not
2261 ;; present GCC will synthesize them for itself
2262 ;; Even though frv does not provide these instructions, we define them
2263 ;; to allow load + sign extend to be collapsed together
2264 (define_insn "extendqihi2"
2265   [(set (match_operand:HI 0 "integer_register_operand" "=d,d")
2266         (sign_extend:HI (match_operand:QI 1 "gpr_or_memory_operand" "d,m")))]
2267   ""
2268   "@
2269    #
2270    ldsb%I1%U1 %M1,%0"
2271   [(set_attr "length" "8,4")
2272    (set_attr "type" "multi,gload")])
2274 (define_split
2275   [(set (match_operand:HI 0 "integer_register_operand" "")
2276         (sign_extend:HI (match_operand:QI 1 "integer_register_operand" "")))]
2277   "reload_completed"
2278   [(match_dup 2)
2279    (match_dup 3)]
2280   "
2282   rtx op0   = gen_lowpart (SImode, operands[0]);
2283   rtx op1   = gen_lowpart (SImode, operands[1]);
2284   rtx shift = GEN_INT (24);
2286   operands[2] = gen_ashlsi3 (op0, op1, shift);
2287   operands[3] = gen_ashrsi3 (op0, op0, shift);
2290 (define_insn "extendqisi2"
2291   [(set (match_operand:SI 0 "integer_register_operand" "=d,d")
2292         (sign_extend:SI (match_operand:QI 1 "gpr_or_memory_operand" "d,m")))]
2293   ""
2294   "@
2295    #
2296    ldsb%I1%U1 %M1,%0"
2297   [(set_attr "length" "8,4")
2298    (set_attr "type" "multi,gload")])
2300 (define_split
2301   [(set (match_operand:SI 0 "integer_register_operand" "")
2302         (sign_extend:SI (match_operand:QI 1 "integer_register_operand" "")))]
2303   "reload_completed"
2304   [(match_dup 2)
2305    (match_dup 3)]
2306   "
2308   rtx op0   = gen_lowpart (SImode, operands[0]);
2309   rtx op1   = gen_lowpart (SImode, operands[1]);
2310   rtx shift = GEN_INT (24);
2312   operands[2] = gen_ashlsi3 (op0, op1, shift);
2313   operands[3] = gen_ashrsi3 (op0, op0, shift);
2316 ;;(define_insn "extendqidi2"
2317 ;;  [(set (match_operand:DI 0 "register_operand" "=r")
2318 ;;      (sign_extend:DI (match_operand:QI 1 "general_operand" "g")))]
2319 ;;  ""
2320 ;;  "extendqihi2 %0,%1"
2321 ;;  [(set_attr "length" "4")])
2323 (define_insn "extendhisi2"
2324   [(set (match_operand:SI 0 "integer_register_operand" "=d,d")
2325         (sign_extend:SI (match_operand:HI 1 "gpr_or_memory_operand" "d,m")))]
2326   ""
2327   "@
2328    #
2329    ldsh%I1%U1 %M1,%0"
2330   [(set_attr "length" "8,4")
2331    (set_attr "type" "multi,gload")])
2333 (define_split
2334   [(set (match_operand:SI 0 "integer_register_operand" "")
2335         (sign_extend:SI (match_operand:HI 1 "integer_register_operand" "")))]
2336   "reload_completed"
2337   [(match_dup 2)
2338    (match_dup 3)]
2339   "
2341   rtx op0   = gen_lowpart (SImode, operands[0]);
2342   rtx op1   = gen_lowpart (SImode, operands[1]);
2343   rtx shift = GEN_INT (16);
2345   operands[2] = gen_ashlsi3 (op0, op1, shift);
2346   operands[3] = gen_ashrsi3 (op0, op0, shift);
2349 ;;(define_insn "extendhidi2"
2350 ;;  [(set (match_operand:DI 0 "register_operand" "=r")
2351 ;;      (sign_extend:DI (match_operand:HI 1 "general_operand" "g")))]
2352 ;;  ""
2353 ;;  "extendhihi2 %0,%1"
2354 ;;  [(set_attr "length" "4")])
2356 ;;(define_insn "extendsidi2"
2357 ;;  [(set (match_operand:DI 0 "register_operand" "=r")
2358 ;;      (sign_extend:DI (match_operand:SI 1 "general_operand" "g")))]
2359 ;;  ""
2360 ;;  "extendsidi2 %0,%1"
2361 ;;  [(set_attr "length" "4")])
2363 ;; Unsigned conversions from a smaller integer to a larger integer
2364 (define_insn "zero_extendqihi2"
2365   [(set (match_operand:HI 0 "integer_register_operand" "=d,d,d")
2366         (zero_extend:HI
2367           (match_operand:QI 1 "gpr_or_memory_operand" "d,L,m")))]
2368   ""
2369   "@
2370    andi %1,#0xff,%0
2371    setlos %1,%0
2372    ldub%I1%U1 %M1,%0"
2373   [(set_attr "length" "4")
2374    (set_attr "type" "int,int,gload")])
2376 (define_insn "zero_extendqisi2"
2377   [(set (match_operand:SI 0 "integer_register_operand" "=d,d,d")
2378         (zero_extend:SI
2379           (match_operand:QI 1 "gpr_or_memory_operand" "d,L,m")))]
2380   ""
2381   "@
2382    andi %1,#0xff,%0
2383    setlos %1,%0
2384    ldub%I1%U1 %M1,%0"
2385   [(set_attr "length" "4")
2386    (set_attr "type" "int,int,gload")])
2388 ;;(define_insn "zero_extendqidi2"
2389 ;;  [(set (match_operand:DI 0 "register_operand" "=r")
2390 ;;      (zero_extend:DI (match_operand:QI 1 "general_operand" "g")))]
2391 ;;  ""
2392 ;;  "zero_extendqihi2 %0,%1"
2393 ;;  [(set_attr "length" "4")])
2395 ;; Do not set the type for the sethi to "sethi", since the scheduler will think
2396 ;; the sethi takes 0 cycles as part of allowing sethi/setlo to be in the same
2397 ;; VLIW instruction.
2398 (define_insn "zero_extendhisi2"
2399   [(set (match_operand:SI 0 "integer_register_operand" "=d,d")
2400         (zero_extend:SI (match_operand:HI 1 "gpr_or_memory_operand" "0,m")))]
2401   ""
2402   "@
2403     sethi #hi(#0),%0
2404     lduh%I1%U1 %M1,%0"
2405   [(set_attr "length" "4")
2406    (set_attr "type" "int,gload")])
2408 ;;(define_insn "zero_extendhidi2"
2409 ;;  [(set (match_operand:DI 0 "register_operand" "=r")
2410 ;;      (zero_extend:DI (match_operand:HI 1 "general_operand" "g")))]
2411 ;;  ""
2412 ;;  "zero_extendhihi2 %0,%1"
2413 ;;  [(set_attr "length" "4")])
2415 ;;(define_insn "zero_extendsidi2"
2416 ;;  [(set (match_operand:DI 0 "register_operand" "=r")
2417 ;;      (zero_extend:DI (match_operand:SI 1 "general_operand" "g")))]
2418 ;;  ""
2419 ;;  "zero_extendsidi2 %0,%1"
2420 ;;  [(set_attr "length" "4")])
2422 ;;;; Convert between floating point types of different sizes.
2424 ;;(define_insn "extendsfdf2"
2425 ;;  [(set (match_operand:DF 0 "register_operand" "=r")
2426 ;;      (float_extend:DF (match_operand:SF 1 "register_operand" "r")))]
2427 ;;  ""
2428 ;;  "extendsfdf2 %0,%1"
2429 ;;  [(set_attr "length" "4")])
2431 ;;(define_insn "truncdfsf2"
2432 ;;  [(set (match_operand:SF 0 "register_operand" "=r")
2433 ;;      (float_truncate:SF (match_operand:DF 1 "register_operand" "r")))]
2434 ;;  ""
2435 ;;  "truncdfsf2 %0,%1"
2436 ;;  [(set_attr "length" "4")])
2438 ;;;; Convert between signed integer types and floating point.
2439 (define_insn "floatsisf2"
2440   [(set (match_operand:SF 0 "fpr_operand" "=f")
2441         (float:SF (match_operand:SI 1 "fpr_operand" "f")))]
2442   "TARGET_HARD_FLOAT"
2443   "fitos %1,%0"
2444   [(set_attr "length" "4")
2445    (set_attr "type" "fsconv")])
2447 (define_insn "floatsidf2"
2448   [(set (match_operand:DF 0 "fpr_operand" "=h")
2449         (float:DF (match_operand:SI 1 "fpr_operand" "f")))]
2450   "TARGET_HARD_FLOAT && TARGET_DOUBLE"
2451   "fitod %1,%0"
2452   [(set_attr "length" "4")
2453    (set_attr "type" "fdconv")])
2455 ;;(define_insn "floatdisf2"
2456 ;;  [(set (match_operand:SF 0 "register_operand" "=r")
2457 ;;      (float:SF (match_operand:DI 1 "register_operand" "r")))]
2458 ;;  ""
2459 ;;  "floatdisf2 %0,%1"
2460 ;;  [(set_attr "length" "4")])
2462 ;;(define_insn "floatdidf2"
2463 ;;  [(set (match_operand:DF 0 "register_operand" "=r")
2464 ;;      (float:DF (match_operand:DI 1 "register_operand" "r")))]
2465 ;;  ""
2466 ;;  "floatdidf2 %0,%1"
2467 ;;  [(set_attr "length" "4")])
2469 (define_insn "fix_truncsfsi2"
2470   [(set (match_operand:SI 0 "fpr_operand" "=f")
2471         (fix:SI (match_operand:SF 1 "fpr_operand" "f")))]
2472   "TARGET_HARD_FLOAT"
2473   "fstoi %1,%0"
2474   [(set_attr "length" "4")
2475    (set_attr "type" "fsconv")])
2477 (define_insn "fix_truncdfsi2"
2478   [(set (match_operand:SI 0 "fpr_operand" "=f")
2479         (fix:SI (match_operand:DF 1 "fpr_operand" "h")))]
2480   "TARGET_HARD_FLOAT && TARGET_DOUBLE"
2481   "fdtoi %1,%0"
2482   [(set_attr "length" "4")
2483    (set_attr "type" "fdconv")])
2485 ;;(define_insn "fix_truncsfdi2"
2486 ;;  [(set (match_operand:DI 0 "register_operand" "=r")
2487 ;;      (fix:DI (match_operand:SF 1 "register_operand" "r")))]
2488 ;;  ""
2489 ;;  "fix_truncsfdi2 %0,%1"
2490 ;;  [(set_attr "length" "4")])
2492 ;;(define_insn "fix_truncdfdi2"
2493 ;;  [(set (match_operand:DI 0 "register_operand" "=r")
2494 ;;      (fix:DI (match_operand:DF 1 "register_operand" "r")))]
2495 ;;  ""
2496 ;;  "fix_truncdfdi2 %0,%1"
2497 ;;  [(set_attr "length" "4")])
2499 ;;;; Convert between unsigned integer types and floating point.
2501 ;;(define_insn "floatunssisf2"
2502 ;;  [(set (match_operand:SF 0 "register_operand" "=r")
2503 ;;      (unsigned_float:SF (match_operand:SI 1 "register_operand" "r")))]
2504 ;;  ""
2505 ;;  "floatunssisf2 %0,%1"
2506 ;;  [(set_attr "length" "4")])
2508 ;;(define_insn "floatunssidf2"
2509 ;;  [(set (match_operand:DF 0 "register_operand" "=r")
2510 ;;      (unsigned_float:DF (match_operand:SI 1 "register_operand" "r")))]
2511 ;;  ""
2512 ;;  "floatunssidf2 %0,%1"
2513 ;;  [(set_attr "length" "4")])
2515 ;;(define_insn "floatunsdisf2"
2516 ;;  [(set (match_operand:SF 0 "register_operand" "=r")
2517 ;;      (unsigned_float:SF (match_operand:DI 1 "register_operand" "r")))]
2518 ;;  ""
2519 ;;  "floatunsdisf2 %0,%1"
2520 ;;  [(set_attr "length" "4")])
2522 ;;(define_insn "floatunsdidf2"
2523 ;;  [(set (match_operand:DF 0 "register_operand" "=r")
2524 ;;      (unsigned_float:DF (match_operand:DI 1 "register_operand" "r")))]
2525 ;;  ""
2526 ;;  "floatunsdidf2 %0,%1"
2527 ;;  [(set_attr "length" "4")])
2529 ;;(define_insn "fixuns_truncsfsi2"
2530 ;;  [(set (match_operand:SI 0 "register_operand" "=r")
2531 ;;      (unsigned_fix:SI (match_operand:SF 1 "register_operand" "r")))]
2532 ;;  ""
2533 ;;  "fixuns_truncsfsi2 %0,%1"
2534 ;;  [(set_attr "length" "4")])
2536 ;;(define_insn "fixuns_truncdfsi2"
2537 ;;  [(set (match_operand:SI 0 "register_operand" "=r")
2538 ;;      (unsigned_fix:SI (match_operand:DF 1 "register_operand" "r")))]
2539 ;;  ""
2540 ;;  "fixuns_truncdfsi2 %0,%1"
2541 ;;  [(set_attr "length" "4")])
2543 ;;(define_insn "fixuns_truncsfdi2"
2544 ;;  [(set (match_operand:DI 0 "register_operand" "=r")
2545 ;;      (unsigned_fix:DI (match_operand:SF 1 "register_operand" "r")))]
2546 ;;  ""
2547 ;;  "fixuns_truncsfdi2 %0,%1"
2548 ;;  [(set_attr "length" "4")])
2550 ;;(define_insn "fixuns_truncdfdi2"
2551 ;;  [(set (match_operand:DI 0 "register_operand" "=r")
2552 ;;      (unsigned_fix:DI (match_operand:DF 1 "register_operand" "r")))]
2553 ;;  ""
2554 ;;  "fixuns_truncdfdi2 %0,%1"
2555 ;;  [(set_attr "length" "4")])
2558 ;; ::::::::::::::::::::
2559 ;; ::
2560 ;; :: 32 bit Integer arithmetic
2561 ;; ::
2562 ;; ::::::::::::::::::::
2564 ;; Addition
2565 (define_insn "addsi3"
2566   [(set (match_operand:SI 0 "integer_register_operand" "=d")
2567         (plus:SI (match_operand:SI 1 "integer_register_operand" "%d")
2568                  (match_operand:SI 2 "gpr_or_int12_operand" "dNOP")))]
2569   ""
2570   "add%I2 %1,%2,%0"
2571   [(set_attr "length" "4")
2572    (set_attr "type" "int")])
2574 ;; Subtraction.  No need to worry about constants, since the compiler
2575 ;; canonicalizes them into addsi3's.  We prevent SUBREG's here to work around a
2576 ;; combine bug, that combines the 32x32->upper 32 bit multiply that uses a
2577 ;; SUBREG with a minus that shows up in modulus by constants.
2578 (define_insn "subsi3"
2579   [(set (match_operand:SI 0 "integer_register_operand" "=d")
2580         (minus:SI (match_operand:SI 1 "gpr_no_subreg_operand" "d")
2581                   (match_operand:SI 2 "gpr_no_subreg_operand" "d")))]
2582   ""
2583   "sub %1,%2,%0"
2584   [(set_attr "length" "4")
2585    (set_attr "type" "int")])
2587 ;; Signed multiplication producing 64 bit results from 32 bit inputs
2588 ;; Note, frv doesn't have a 32x32->32 bit multiply, but the compiler
2589 ;; will do the 32x32->64 bit multiply and use the bottom word.
2590 (define_expand "mulsidi3"
2591   [(set (match_operand:DI 0 "integer_register_operand" "")
2592         (mult:DI (sign_extend:DI (match_operand:SI 1 "integer_register_operand" ""))
2593                  (sign_extend:DI (match_operand:SI 2 "gpr_or_int12_operand" ""))))]
2594   ""
2595   "
2597   if (GET_CODE (operands[2]) == CONST_INT)
2598     {
2599       emit_insn (gen_mulsidi3_const (operands[0], operands[1], operands[2]));
2600       DONE;
2601     }
2604 (define_insn "*mulsidi3_reg"
2605   [(set (match_operand:DI 0 "even_gpr_operand" "=e")
2606         (mult:DI (sign_extend:DI (match_operand:SI 1 "integer_register_operand" "%d"))
2607                  (sign_extend:DI (match_operand:SI 2 "integer_register_operand" "d"))))]
2608   ""
2609   "smul %1,%2,%0"
2610   [(set_attr "length" "4")
2611    (set_attr "type" "mul")])
2613 (define_insn "mulsidi3_const"
2614   [(set (match_operand:DI 0 "even_gpr_operand" "=e")
2615         (mult:DI (sign_extend:DI (match_operand:SI 1 "integer_register_operand" "d"))
2616                  (match_operand:SI 2 "int12_operand" "NOP")))]
2617   ""
2618   "smuli %1,%2,%0"
2619   [(set_attr "length" "4")
2620    (set_attr "type" "mul")])
2622 ;; Unsigned multiplication producing 64 bit results from 32 bit inputs
2623 (define_expand "umulsidi3"
2624   [(set (match_operand:DI 0 "even_gpr_operand" "")
2625         (mult:DI (zero_extend:DI (match_operand:SI 1 "integer_register_operand" ""))
2626                  (zero_extend:DI (match_operand:SI 2 "gpr_or_int12_operand" ""))))]
2627   ""
2628   "
2630   if (GET_CODE (operands[2]) == CONST_INT)
2631     {
2632       emit_insn (gen_umulsidi3_const (operands[0], operands[1], operands[2]));
2633       DONE;
2634     }
2637 (define_insn "*mulsidi3_reg"
2638   [(set (match_operand:DI 0 "even_gpr_operand" "=e")
2639         (mult:DI (zero_extend:DI (match_operand:SI 1 "integer_register_operand" "%d"))
2640                  (zero_extend:DI (match_operand:SI 2 "integer_register_operand" "d"))))]
2641   ""
2642   "umul %1,%2,%0"
2643   [(set_attr "length" "4")
2644    (set_attr "type" "mul")])
2646 (define_insn "umulsidi3_const"
2647   [(set (match_operand:DI 0 "even_gpr_operand" "=e")
2648         (mult:DI (zero_extend:DI (match_operand:SI 1 "integer_register_operand" "d"))
2649                  (match_operand:SI 2 "int12_operand" "NOP")))]
2650   ""
2651   "umuli %1,%2,%0"
2652   [(set_attr "length" "4")
2653    (set_attr "type" "mul")])
2655 ;; Signed Division
2656 (define_insn "divsi3"
2657   [(set (match_operand:SI 0 "register_operand" "=d,d")
2658         (div:SI (match_operand:SI 1 "register_operand" "d,d")
2659                 (match_operand:SI 2 "gpr_or_int12_operand" "d,NOP")))]
2660   ""
2661   "sdiv%I2 %1,%2,%0"
2662   [(set_attr "length" "4")
2663    (set_attr "type" "div")])
2665 ;; Unsigned Division
2666 (define_insn "udivsi3"
2667   [(set (match_operand:SI 0 "register_operand" "=d,d")
2668         (udiv:SI (match_operand:SI 1 "register_operand" "d,d")
2669                  (match_operand:SI 2 "gpr_or_int12_operand" "d,NOP")))]
2670   ""
2671   "udiv%I2 %1,%2,%0"
2672   [(set_attr "length" "4")
2673    (set_attr "type" "div")])
2675 ;; Negation
2676 (define_insn "negsi2"
2677   [(set (match_operand:SI 0 "integer_register_operand" "=d")
2678         (neg:SI (match_operand:SI 1 "integer_register_operand" "d")))]
2679   ""
2680   "sub %.,%1,%0"
2681   [(set_attr "length" "4")
2682    (set_attr "type" "int")])
2684 ;; Find first one bit
2685 ;; (define_insn "ffssi2"
2686 ;;   [(set (match_operand:SI 0 "register_operand" "=r")
2687 ;;      (ffs:SI (match_operand:SI 1 "register_operand" "r")))]
2688 ;;   ""
2689 ;;   "ffssi2 %0,%1"
2690 ;;   [(set_attr "length" "4")])
2693 ;; ::::::::::::::::::::
2694 ;; ::
2695 ;; :: 64 bit Integer arithmetic
2696 ;; ::
2697 ;; ::::::::::::::::::::
2699 ;; Addition
2700 (define_expand "adddi3"
2701   [(parallel [(set (match_operand:DI 0 "integer_register_operand" "")
2702                    (plus:DI (match_operand:DI 1 "integer_register_operand" "")
2703                             (match_operand:DI 2 "gpr_or_int10_operand" "")))
2704               (clobber (match_scratch:CC 3 ""))])]
2705   ""
2706   "
2708   if (GET_CODE (operands[2]) == CONST_INT
2709       && INTVAL (operands[2]) == -2048
2710       && !no_new_pseudos)
2711     operands[2] = force_reg (DImode, operands[2]);
2714 (define_insn_and_split "*adddi3_internal"
2715   [(set (match_operand:DI 0 "integer_register_operand" "=&e,e,e,&e,e,&e,e")
2716         (plus:DI (match_operand:DI 1 "integer_register_operand" "%e,0,e,e,0,e,0")
2717                  (match_operand:DI 2 "gpr_or_int10_operand" "e,e,0,N,N,OP,OP")))
2718    (clobber (match_scratch:CC 3 "=t,t,t,t,t,t,t"))]
2719   "GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != -2048"
2720   "#"
2721   "reload_completed"
2722   [(match_dup 4)
2723    (match_dup 5)]
2724   "
2726   rtx op0_high = gen_highpart (SImode, operands[0]);
2727   rtx op1_high = gen_highpart (SImode, operands[1]);
2728   rtx op0_low  = gen_lowpart (SImode, operands[0]);
2729   rtx op1_low  = gen_lowpart (SImode, operands[1]);
2730   rtx op2 = operands[2];
2731   rtx op3 = operands[3];
2733   if (GET_CODE (op2) != CONST_INT)
2734     {
2735       rtx op2_high = gen_highpart (SImode, operands[2]);
2736       rtx op2_low  = gen_lowpart (SImode, operands[2]);
2737       operands[4] = gen_adddi3_lower (op0_low, op1_low, op2_low, op3);
2738       operands[5] = gen_adddi3_upper (op0_high, op1_high, op2_high, op3);
2739     }
2740   else if (INTVAL (op2) >= 0)
2741     {
2742       operands[4] = gen_adddi3_lower (op0_low, op1_low, op2, op3);
2743       operands[5] = gen_adddi3_upper (op0_high, op1_high, const0_rtx, op3);
2744     }
2745   else
2746     {
2747       operands[4] = gen_subdi3_lower (op0_low, op1_low,
2748                                       GEN_INT (- INTVAL (op2)), op3);
2749       operands[5] = gen_subdi3_upper (op0_high, op1_high, const0_rtx, op3);
2750     }
2752   [(set_attr "length" "8")
2753    (set_attr "type" "multi")])
2755 ;; Subtraction  No need to worry about constants, since the compiler
2756 ;; canonicalizes them into adddi3's.
2757 (define_insn_and_split "subdi3"
2758   [(set (match_operand:DI 0 "integer_register_operand" "=&e,e,e")
2759         (minus:DI (match_operand:DI 1 "integer_register_operand" "e,0,e")
2760                   (match_operand:DI 2 "integer_register_operand" "e,e,0")))
2761    (clobber (match_scratch:CC 3 "=t,t,t"))]
2762   ""
2763   "#"
2764   "reload_completed"
2765   [(match_dup 4)
2766    (match_dup 5)]
2767   "
2769   rtx op0_high = gen_highpart (SImode, operands[0]);
2770   rtx op1_high = gen_highpart (SImode, operands[1]);
2771   rtx op2_high = gen_highpart (SImode, operands[2]);
2772   rtx op0_low  = gen_lowpart (SImode, operands[0]);
2773   rtx op1_low  = gen_lowpart (SImode, operands[1]);
2774   rtx op2_low  = gen_lowpart (SImode, operands[2]);
2775   rtx op3 = operands[3];
2777   operands[4] = gen_subdi3_lower (op0_low, op1_low, op2_low, op3);
2778   operands[5] = gen_subdi3_upper (op0_high, op1_high, op2_high, op3);
2780   [(set_attr "length" "8")
2781    (set_attr "type" "multi")])
2783 ;; Patterns for addsi3/subdi3 after spliting
2784 (define_insn "adddi3_lower"
2785   [(set (match_operand:SI 0 "integer_register_operand" "=d")
2786         (plus:SI (match_operand:SI 1 "integer_register_operand" "d")
2787                  (match_operand:SI 2 "gpr_or_int10_operand" "dOP")))
2788    (set (match_operand:CC 3 "icc_operand" "=t")
2789         (compare:CC (plus:SI (match_dup 1)
2790                              (match_dup 2))
2791                     (const_int 0)))]
2792   "GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) >= 0"
2793   "add%I2cc %1,%2,%0,%3"
2794   [(set_attr "length" "4")
2795    (set_attr "type" "int")])
2797 (define_insn "adddi3_upper"
2798   [(set (match_operand:SI 0 "integer_register_operand" "=d,d")
2799         (plus:SI (match_operand:SI 1 "integer_register_operand" "d,d")
2800                  (plus:SI (match_operand:SI 2 "reg_or_0_operand" "d,O")
2801                           (match_operand:CC 3 "icc_operand" "t,t"))))]
2802   ""
2803   "@
2804    addx %1,%2,%0,%3
2805    addx %1,%.,%0,%3"
2806   [(set_attr "length" "4")
2807    (set_attr "type" "int")])
2809 (define_insn "subdi3_lower"
2810   [(set (match_operand:SI 0 "integer_register_operand" "=d")
2811         (minus:SI (match_operand:SI 1 "integer_register_operand" "d")
2812                   (match_operand:SI 2 "gpr_or_int10_operand" "dOP")))
2813    (set (match_operand:CC 3 "icc_operand" "=t")
2814         (compare:CC (plus:SI (match_dup 1)
2815                              (match_dup 2))
2816                     (const_int 0)))]
2817   "GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) >= 0"
2818   "sub%I2cc %1,%2,%0,%3"
2819   [(set_attr "length" "4")
2820    (set_attr "type" "int")])
2822 (define_insn "subdi3_upper"
2823   [(set (match_operand:SI 0 "integer_register_operand" "=d,d")
2824         (minus:SI (match_operand:SI 1 "integer_register_operand" "d,d")
2825                   (minus:SI (match_operand:SI 2 "reg_or_0_operand" "d,O")
2826                             (match_operand:CC 3 "icc_operand" "t,t"))))]
2827   ""
2828   "@
2829    subx %1,%2,%0,%3
2830    subx %1,%.,%0,%3"
2831   [(set_attr "length" "4")
2832    (set_attr "type" "int")])
2834 (define_insn_and_split "negdi2"
2835   [(set (match_operand:DI 0 "integer_register_operand" "=&e,e")
2836         (neg:DI (match_operand:DI 1 "integer_register_operand" "e,0")))
2837    (clobber (match_scratch:CC 2 "=t,t"))]
2838   ""
2839   "#"
2840   "reload_completed"
2841   [(match_dup 3)
2842    (match_dup 4)]
2843   "
2845   rtx op0_high = gen_highpart (SImode, operands[0]);
2846   rtx op1_high = gen_rtx_REG (SImode, GPR_FIRST);
2847   rtx op2_high = gen_highpart (SImode, operands[1]);
2848   rtx op0_low  = gen_lowpart (SImode, operands[0]);
2849   rtx op1_low  = op1_high;
2850   rtx op2_low  = gen_lowpart (SImode, operands[1]);
2851   rtx op3 = operands[2];
2853   operands[3] = gen_subdi3_lower (op0_low, op1_low, op2_low, op3);
2854   operands[4] = gen_subdi3_upper (op0_high, op1_high, op2_high, op3);
2856   [(set_attr "length" "8")
2857    (set_attr "type" "multi")])
2859 ;; Multiplication (same size)
2860 ;; (define_insn "muldi3"
2861 ;;   [(set (match_operand:DI 0 "register_operand" "=r")
2862 ;;      (mult:DI (match_operand:DI 1 "register_operand" "%r")
2863 ;;               (match_operand:DI 2 "nonmemory_operand" "ri")))]
2864 ;;   ""
2865 ;;   "muldi3 %0,%1,%2"
2866 ;;   [(set_attr "length" "4")])
2868 ;; Signed Division
2869 ;; (define_insn "divdi3"
2870 ;;   [(set (match_operand:DI 0 "register_operand" "=r")
2871 ;;      (div:DI (match_operand:DI 1 "register_operand" "r")
2872 ;;              (match_operand:DI 2 "nonmemory_operand" "ri")))]
2873 ;;   ""
2874 ;;   "divdi3 %0,%1,%2"
2875 ;;   [(set_attr "length" "4")])
2877 ;; Undsgned Division
2878 ;; (define_insn "udivdi3"
2879 ;;   [(set (match_operand:DI 0 "register_operand" "=r")
2880 ;;      (udiv:DI (match_operand:DI 1 "register_operand" "r")
2881 ;;               (match_operand:DI 2 "nonmemory_operand" "ri")))]
2882 ;;   ""
2883 ;;   "udivdi3 %0,%1,%2"
2884 ;;   [(set_attr "length" "4")])
2886 ;; Negation
2887 ;; (define_insn "negdi2"
2888 ;;   [(set (match_operand:DI 0 "register_operand" "=r")
2889 ;;      (neg:DI (match_operand:DI 1 "register_operand" "r")))]
2890 ;;   ""
2891 ;;   "negdi2 %0,%1"
2892 ;;   [(set_attr "length" "4")])
2894 ;; Find first one bit
2895 ;; (define_insn "ffsdi2"
2896 ;;   [(set (match_operand:DI 0 "register_operand" "=r")
2897 ;;      (ffs:DI (match_operand:DI 1 "register_operand" "r")))]
2898 ;;   ""
2899 ;;   "ffsdi2 %0,%1"
2900 ;;   [(set_attr "length" "4")])
2903 ;; ::::::::::::::::::::
2904 ;; ::
2905 ;; :: 32 bit floating point arithmetic
2906 ;; ::
2907 ;; ::::::::::::::::::::
2909 ;; Addition
2910 (define_insn "addsf3"
2911   [(set (match_operand:SF 0 "fpr_operand" "=f")
2912         (plus:SF (match_operand:SF 1 "fpr_operand" "%f")
2913                  (match_operand:SF 2 "fpr_operand" "f")))]
2914   "TARGET_HARD_FLOAT"
2915   "fadds %1,%2,%0"
2916   [(set_attr "length" "4")
2917    (set_attr "type" "fsadd")])
2919 ;; Subtraction
2920 (define_insn "subsf3"
2921   [(set (match_operand:SF 0 "fpr_operand" "=f")
2922         (minus:SF (match_operand:SF 1 "fpr_operand" "f")
2923                   (match_operand:SF 2 "fpr_operand" "f")))]
2924   "TARGET_HARD_FLOAT"
2925   "fsubs %1,%2,%0"
2926   [(set_attr "length" "4")
2927    (set_attr "type" "fsadd")])
2929 ;; Multiplication
2930 (define_insn "mulsf3"
2931   [(set (match_operand:SF 0 "fpr_operand" "=f")
2932         (mult:SF (match_operand:SF 1 "fpr_operand" "%f")
2933                  (match_operand:SF 2 "fpr_operand" "f")))]
2934   "TARGET_HARD_FLOAT"
2935   "fmuls %1,%2,%0"
2936   [(set_attr "length" "4")
2937    (set_attr "type" "fsmul")])
2939 ;; Multiplication with addition/subtraction
2940 (define_insn "*muladdsf4"
2941   [(set (match_operand:SF 0 "fpr_operand" "=f")
2942         (plus:SF (mult:SF (match_operand:SF 1 "fpr_operand" "%f")
2943                           (match_operand:SF 2 "fpr_operand" "f"))
2944                  (match_operand:SF 3 "fpr_operand" "0")))]
2945   "TARGET_HARD_FLOAT && TARGET_MULADD"
2946   "fmadds %1,%2,%0"
2947   [(set_attr "length" "4")
2948    (set_attr "type" "fmas")])
2950 (define_insn "*mulsubsf4"
2951   [(set (match_operand:SF 0 "fpr_operand" "=f")
2952         (minus:SF (mult:SF (match_operand:SF 1 "fpr_operand" "%f")
2953                            (match_operand:SF 2 "fpr_operand" "f"))
2954                   (match_operand:SF 3 "fpr_operand" "0")))]
2955   "TARGET_HARD_FLOAT && TARGET_MULADD"
2956   "fmsubs %1,%2,%0"
2957   [(set_attr "length" "4")
2958    (set_attr "type" "fmas")])
2960 ;; Division
2961 (define_insn "divsf3"
2962   [(set (match_operand:SF 0 "fpr_operand" "=f")
2963         (div:SF (match_operand:SF 1 "fpr_operand" "f")
2964                 (match_operand:SF 2 "fpr_operand" "f")))]
2965   "TARGET_HARD_FLOAT"
2966   "fdivs %1,%2,%0"
2967   [(set_attr "length" "4")
2968    (set_attr "type" "fsdiv")])
2970 ;; Negation
2971 (define_insn "negsf2"
2972   [(set (match_operand:SF 0 "fpr_operand" "=f")
2973         (neg:SF (match_operand:SF 1 "fpr_operand" "f")))]
2974   "TARGET_HARD_FLOAT"
2975   "fnegs %1,%0"
2976   [(set_attr "length" "4")
2977    (set_attr "type" "fsconv")])
2979 ;; Absolute value
2980 (define_insn "abssf2"
2981   [(set (match_operand:SF 0 "fpr_operand" "=f")
2982         (abs:SF (match_operand:SF 1 "fpr_operand" "f")))]
2983   "TARGET_HARD_FLOAT"
2984   "fabss %1,%0"
2985   [(set_attr "length" "4")
2986    (set_attr "type" "fsconv")])
2988 ;; Square root
2989 (define_insn "sqrtsf2"
2990   [(set (match_operand:SF 0 "fpr_operand" "=f")
2991         (sqrt:SF (match_operand:SF 1 "fpr_operand" "f")))]
2992   "TARGET_HARD_FLOAT"
2993   "fsqrts %1,%0"
2994   [(set_attr "length" "4")
2995    (set_attr "type" "sqrt_single")])
2998 ;; ::::::::::::::::::::
2999 ;; ::
3000 ;; :: 64 bit floating point arithmetic
3001 ;; ::
3002 ;; ::::::::::::::::::::
3004 ;; Addition
3005 (define_insn "adddf3"
3006   [(set (match_operand:DF 0 "even_fpr_operand" "=h")
3007         (plus:DF (match_operand:DF 1 "fpr_operand" "%h")
3008                  (match_operand:DF 2 "fpr_operand" "h")))]
3009   "TARGET_HARD_FLOAT && TARGET_DOUBLE"
3010   "faddd %1,%2,%0"
3011   [(set_attr "length" "4")
3012    (set_attr "type" "fdadd")])
3014 ;; Subtraction
3015 (define_insn "subdf3"
3016   [(set (match_operand:DF 0 "even_fpr_operand" "=h")
3017         (minus:DF (match_operand:DF 1 "fpr_operand" "h")
3018                   (match_operand:DF 2 "fpr_operand" "h")))]
3019   "TARGET_HARD_FLOAT && TARGET_DOUBLE"
3020   "fsubd %1,%2,%0"
3021   [(set_attr "length" "4")
3022    (set_attr "type" "fdadd")])
3024 ;; Multiplication
3025 (define_insn "muldf3"
3026   [(set (match_operand:DF 0 "even_fpr_operand" "=h")
3027         (mult:DF (match_operand:DF 1 "fpr_operand" "%h")
3028                  (match_operand:DF 2 "fpr_operand" "h")))]
3029   "TARGET_HARD_FLOAT && TARGET_DOUBLE"
3030   "fmuld %1,%2,%0"
3031   [(set_attr "length" "4")
3032    (set_attr "type" "fdmul")])
3034 ;; Multiplication with addition/subtraction
3035 (define_insn "*muladddf4"
3036   [(set (match_operand:DF 0 "fpr_operand" "=f")
3037         (plus:DF (mult:DF (match_operand:DF 1 "fpr_operand" "%f")
3038                           (match_operand:DF 2 "fpr_operand" "f"))
3039                  (match_operand:DF 3 "fpr_operand" "0")))]
3040   "TARGET_HARD_FLOAT && TARGET_DOUBLE && TARGET_MULADD"
3041   "fmaddd %1,%2,%0"
3042   [(set_attr "length" "4")
3043    (set_attr "type" "fmas")])
3045 (define_insn "*mulsubdf4"
3046   [(set (match_operand:DF 0 "fpr_operand" "=f")
3047         (minus:DF (mult:DF (match_operand:DF 1 "fpr_operand" "%f")
3048                            (match_operand:DF 2 "fpr_operand" "f"))
3049                   (match_operand:DF 3 "fpr_operand" "0")))]
3050   "TARGET_HARD_FLOAT && TARGET_DOUBLE && TARGET_MULADD"
3051   "fmsubd %1,%2,%0"
3052   [(set_attr "length" "4")
3053    (set_attr "type" "fmas")])
3055 ;; Division
3056 (define_insn "divdf3"
3057   [(set (match_operand:DF 0 "even_fpr_operand" "=h")
3058         (div:DF (match_operand:DF 1 "fpr_operand" "h")
3059                 (match_operand:DF 2 "fpr_operand" "h")))]
3060   "TARGET_HARD_FLOAT && TARGET_DOUBLE"
3061   "fdivd %1,%2,%0"
3062   [(set_attr "length" "4")
3063    (set_attr "type" "fddiv")])
3065 ;; Negation
3066 (define_insn "negdf2"
3067   [(set (match_operand:DF 0 "even_fpr_operand" "=h")
3068         (neg:DF (match_operand:DF 1 "fpr_operand" "h")))]
3069   "TARGET_HARD_FLOAT && TARGET_DOUBLE"
3070   "fnegd %1,%0"
3071   [(set_attr "length" "4")
3072    (set_attr "type" "fdconv")])
3074 ;; Absolute value
3075 (define_insn "absdf2"
3076   [(set (match_operand:DF 0 "even_fpr_operand" "=h")
3077         (abs:DF (match_operand:DF 1 "fpr_operand" "h")))]
3078   "TARGET_HARD_FLOAT && TARGET_DOUBLE"
3079   "fabsd %1,%0"
3080   [(set_attr "length" "4")
3081    (set_attr "type" "fdconv")])
3083 ;; Square root
3084 (define_insn "sqrtdf2"
3085   [(set (match_operand:DF 0 "even_fpr_operand" "=h")
3086         (sqrt:DF (match_operand:DF 1 "fpr_operand" "h")))]
3087   "TARGET_HARD_FLOAT && TARGET_DOUBLE"
3088   "fsqrtd %1,%0"
3089   [(set_attr "length" "4")
3090    (set_attr "type" "sqrt_double")])
3093 ;; ::::::::::::::::::::
3094 ;; ::
3095 ;; :: 32 bit Integer Shifts and Rotates
3096 ;; ::
3097 ;; ::::::::::::::::::::
3099 ;; Arithmetic Shift Left
3100 (define_insn "ashlsi3"
3101   [(set (match_operand:SI 0 "integer_register_operand" "=d,d")
3102         (ashift:SI (match_operand:SI 1 "integer_register_operand" "d,d")
3103                    (match_operand:SI 2 "gpr_or_int12_operand" "d,NOP")))]
3104   ""
3105   "sll%I2 %1,%2,%0"
3106   [(set_attr "length" "4")
3107    (set_attr "type" "int")])
3109 ;; Arithmetic Shift Right
3110 (define_insn "ashrsi3"
3111   [(set (match_operand:SI 0 "integer_register_operand" "=d,d")
3112         (ashiftrt:SI (match_operand:SI 1 "integer_register_operand" "d,d")
3113                      (match_operand:SI 2 "gpr_or_int12_operand" "d,NOP")))]
3114   ""
3115   "sra%I2 %1, %2, %0"
3116   [(set_attr "length" "4")
3117    (set_attr "type" "int")])
3119 ;; Logical Shift Right
3120 (define_insn "lshrsi3"
3121   [(set (match_operand:SI 0 "integer_register_operand" "=d,d")
3122         (lshiftrt:SI (match_operand:SI 1 "integer_register_operand" "d,d")
3123                      (match_operand:SI 2 "gpr_or_int12_operand" "d,NOP")))]
3124   ""
3125   "srl%I2 %1, %2, %0"
3126   [(set_attr "length" "4")
3127    (set_attr "type" "int")])
3129 ;; Rotate Left
3130 ;; (define_insn "rotlsi3"
3131 ;;   [(set (match_operand:SI 0 "register_operand" "=r")
3132 ;;      (rotate:SI (match_operand:SI 1 "register_operand" "r")
3133 ;;                 (match_operand:SI 2 "nonmemory_operand" "ri")))]
3134 ;;   ""
3135 ;;   "rotlsi3 %0,%1,%2"
3136 ;;   [(set_attr "length" "4")])
3138 ;; Rotate Right
3139 ;; (define_insn "rotrsi3"
3140 ;;   [(set (match_operand:SI 0 "register_operand" "=r")
3141 ;;      (rotatert:SI (match_operand:SI 1 "register_operand" "r")
3142 ;;                   (match_operand:SI 2 "nonmemory_operand" "ri")))]
3143 ;;   ""
3144 ;;   "rotrsi3 %0,%1,%2"
3145 ;;   [(set_attr "length" "4")])
3148 ;; ::::::::::::::::::::
3149 ;; ::
3150 ;; :: 64 bit Integer Shifts and Rotates
3151 ;; ::
3152 ;; ::::::::::::::::::::
3154 ;; Arithmetic Shift Left
3155 ;; (define_insn "ashldi3"
3156 ;;   [(set (match_operand:DI 0 "register_operand" "=r")
3157 ;;      (ashift:DI (match_operand:DI 1 "register_operand" "r")
3158 ;;                 (match_operand:SI 2 "nonmemory_operand" "ri")))]
3159 ;;   ""
3160 ;;   "ashldi3 %0,%1,%2"
3161 ;;   [(set_attr "length" "4")])
3163 ;; Arithmetic Shift Right
3164 ;; (define_insn "ashrdi3"
3165 ;;   [(set (match_operand:DI 0 "register_operand" "=r")
3166 ;;      (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
3167 ;;                   (match_operand:SI 2 "nonmemory_operand" "ri")))]
3168 ;;   ""
3169 ;;   "ashrdi3 %0,%1,%2"
3170 ;;   [(set_attr "length" "4")])
3172 ;; Logical Shift Right
3173 ;; (define_insn "lshrdi3"
3174 ;;   [(set (match_operand:DI 0 "register_operand" "=r")
3175 ;;      (lshiftrt:DI (match_operand:DI 1 "register_operand" "r")
3176 ;;                   (match_operand:SI 2 "nonmemory_operand" "ri")))]
3177 ;;   ""
3178 ;;   "lshrdi3 %0,%1,%2"
3179 ;;   [(set_attr "length" "4")])
3181 ;; Rotate Left
3182 ;; (define_insn "rotldi3"
3183 ;;   [(set (match_operand:DI 0 "register_operand" "=r")
3184 ;;      (rotate:DI (match_operand:DI 1 "register_operand" "r")
3185 ;;                 (match_operand:SI 2 "nonmemory_operand" "ri")))]
3186 ;;   ""
3187 ;;   "rotldi3 %0,%1,%2"
3188 ;;   [(set_attr "length" "4")])
3190 ;; Rotate Right
3191 ;; (define_insn "rotrdi3"
3192 ;;   [(set (match_operand:DI 0 "register_operand" "=r")
3193 ;;      (rotatert:DI (match_operand:DI 1 "register_operand" "r")
3194 ;;                   (match_operand:SI 2 "nonmemory_operand" "ri")))]
3195 ;;   ""
3196 ;;   "rotrdi3 %0,%1,%2"
3197 ;;   [(set_attr "length" "4")])
3200 ;; ::::::::::::::::::::
3201 ;; ::
3202 ;; :: 32 Bit Integer Logical operations
3203 ;; ::
3204 ;; ::::::::::::::::::::
3206 ;; Logical AND, 32 bit integers
3207 (define_insn "andsi3_media"
3208   [(set (match_operand:SI 0 "gpr_or_fpr_operand" "=d,f")
3209         (and:SI (match_operand:SI 1 "gpr_or_fpr_operand" "%d,f")
3210                 (match_operand:SI 2 "gpr_fpr_or_int12_operand" "dNOP,f")))]
3211   "TARGET_MEDIA"
3212   "@
3213    and%I2 %1, %2, %0
3214    mand %1, %2, %0"
3215   [(set_attr "length" "4")
3216    (set_attr "type" "int,mlogic")])
3218 (define_insn "andsi3_nomedia"
3219   [(set (match_operand:SI 0 "integer_register_operand" "=d")
3220         (and:SI (match_operand:SI 1 "integer_register_operand" "%d")
3221                 (match_operand:SI 2 "gpr_or_int12_operand" "dNOP")))]
3222   "!TARGET_MEDIA"
3223   "and%I2 %1, %2, %0"
3224   [(set_attr "length" "4")
3225    (set_attr "type" "int")])
3227 (define_expand "andsi3"
3228   [(set (match_operand:SI 0 "gpr_or_fpr_operand" "")
3229         (and:SI (match_operand:SI 1 "gpr_or_fpr_operand" "")
3230                 (match_operand:SI 2 "gpr_fpr_or_int12_operand" "")))]
3231   ""
3232   "")
3234 ;; Inclusive OR, 32 bit integers
3235 (define_insn "iorsi3_media"
3236   [(set (match_operand:SI 0 "gpr_or_fpr_operand" "=d,f")
3237         (ior:SI (match_operand:SI 1 "gpr_or_fpr_operand" "%d,f")
3238                 (match_operand:SI 2 "gpr_fpr_or_int12_operand" "dNOP,f")))]
3239   "TARGET_MEDIA"
3240   "@
3241    or%I2 %1, %2, %0
3242    mor %1, %2, %0"
3243   [(set_attr "length" "4")
3244    (set_attr "type" "int,mlogic")])
3246 (define_insn "iorsi3_nomedia"
3247   [(set (match_operand:SI 0 "integer_register_operand" "=d")
3248         (ior:SI (match_operand:SI 1 "integer_register_operand" "%d")
3249                 (match_operand:SI 2 "gpr_or_int12_operand" "dNOP")))]
3250   "!TARGET_MEDIA"
3251   "or%I2 %1, %2, %0"
3252   [(set_attr "length" "4")
3253    (set_attr "type" "int")])
3255 (define_expand "iorsi3"
3256   [(set (match_operand:SI 0 "gpr_or_fpr_operand" "")
3257         (ior:SI (match_operand:SI 1 "gpr_or_fpr_operand" "")
3258                 (match_operand:SI 2 "gpr_fpr_or_int12_operand" "")))]
3259   ""
3260   "")
3262 ;; Exclusive OR, 32 bit integers
3263 (define_insn "xorsi3_media"
3264   [(set (match_operand:SI 0 "gpr_or_fpr_operand" "=d,f")
3265         (xor:SI (match_operand:SI 1 "gpr_or_fpr_operand" "%d,f")
3266                 (match_operand:SI 2 "gpr_fpr_or_int12_operand" "dNOP,f")))]
3267   "TARGET_MEDIA"
3268   "@
3269    xor%I2 %1, %2, %0
3270    mxor %1, %2, %0"
3271   [(set_attr "length" "4")
3272    (set_attr "type" "int,mlogic")])
3274 (define_insn "xorsi3_nomedia"
3275   [(set (match_operand:SI 0 "integer_register_operand" "=d")
3276         (xor:SI (match_operand:SI 1 "integer_register_operand" "%d")
3277                 (match_operand:SI 2 "gpr_or_int12_operand" "dNOP")))]
3278   "!TARGET_MEDIA"
3279   "xor%I2 %1, %2, %0"
3280   [(set_attr "length" "4")
3281    (set_attr "type" "int")])
3283 (define_expand "xorsi3"
3284   [(set (match_operand:SI 0 "gpr_or_fpr_operand" "")
3285         (xor:SI (match_operand:SI 1 "gpr_or_fpr_operand" "")
3286                 (match_operand:SI 2 "gpr_fpr_or_int12_operand" "")))]
3287   ""
3288   "")
3290 ;; One's complement, 32 bit integers
3291 (define_insn "one_cmplsi2_media"
3292   [(set (match_operand:SI 0 "gpr_or_fpr_operand" "=d,f")
3293         (not:SI (match_operand:SI 1 "gpr_or_fpr_operand" "d,f")))]
3294   "TARGET_MEDIA"
3295   "@
3296    not %1, %0
3297    mnot %1, %0"
3298   [(set_attr "length" "4")
3299    (set_attr "type" "int,mlogic")])
3301 (define_insn "one_cmplsi2_nomedia"
3302   [(set (match_operand:SI 0 "integer_register_operand" "=d")
3303         (not:SI (match_operand:SI 1 "integer_register_operand" "d")))]
3304   "!TARGET_MEDIA"
3305   "not %1,%0"
3306   [(set_attr "length" "4")
3307    (set_attr "type" "int")])
3309 (define_expand "one_cmplsi2"
3310   [(set (match_operand:SI 0 "gpr_or_fpr_operand" "")
3311         (not:SI (match_operand:SI 1 "gpr_or_fpr_operand" "")))]
3312   ""
3313   "")
3316 ;; ::::::::::::::::::::
3317 ;; ::
3318 ;; :: 64 Bit Integer Logical operations
3319 ;; ::
3320 ;; ::::::::::::::::::::
3322 ;; Logical AND, 64 bit integers
3323 ;; (define_insn "anddi3"
3324 ;;   [(set (match_operand:DI 0 "register_operand" "=r")
3325 ;;      (and:DI (match_operand:DI 1 "register_operand" "%r")
3326 ;;              (match_operand:DI 2 "nonmemory_operand" "ri")))]
3327 ;;   ""
3328 ;;   "anddi3 %0,%1,%2"
3329 ;;   [(set_attr "length" "4")])
3331 ;; Inclusive OR, 64 bit integers
3332 ;; (define_insn "iordi3"
3333 ;;   [(set (match_operand:DI 0 "register_operand" "=r")
3334 ;;      (ior:DI (match_operand:DI 1 "register_operand" "%r")
3335 ;;              (match_operand:DI 2 "nonmemory_operand" "ri")))]
3336 ;;   ""
3337 ;;   "iordi3 %0,%1,%2"
3338 ;;   [(set_attr "length" "4")])
3340 ;; Excludive OR, 64 bit integers
3341 ;; (define_insn "xordi3"
3342 ;;   [(set (match_operand:DI 0 "register_operand" "=r")
3343 ;;      (xor:DI (match_operand:DI 1 "register_operand" "%r")
3344 ;;              (match_operand:DI 2 "nonmemory_operand" "ri")))]
3345 ;;   ""
3346 ;;   "xordi3 %0,%1,%2"
3347 ;;   [(set_attr "length" "4")])
3349 ;; One's complement, 64 bit integers
3350 ;; (define_insn "one_cmpldi2"
3351 ;;   [(set (match_operand:DI 0 "register_operand" "=r")
3352 ;;      (not:DI (match_operand:DI 1 "register_operand" "r")))]
3353 ;;   ""
3354 ;;   "notdi3 %0,%1"
3355 ;;   [(set_attr "length" "4")])
3358 ;; ::::::::::::::::::::
3359 ;; ::
3360 ;; :: Combination of integer operation with comparison
3361 ;; ::
3362 ;; ::::::::::::::::::::
3364 (define_insn "*combo_intop_compare1"
3365   [(set (match_operand:CC 0 "icc_operand" "=t")
3366         (compare:CC (match_operator:SI 1 "intop_compare_operator"
3367                                        [(match_operand:SI 2 "integer_register_operand" "d")
3368                                         (match_operand:SI 3 "gpr_or_int10_operand" "dJ")])
3369                     (const_int 0)))]
3370   ""
3371   "%O1%I3cc %2, %3, %., %0"
3372   [(set_attr "type" "int")
3373    (set_attr "length" "4")])
3375 (define_insn "*combo_intop_compare2"
3376   [(set (match_operand:CC_UNS 0 "icc_operand" "=t")
3377         (compare:CC_UNS (match_operator:SI 1 "intop_compare_operator"
3378                                            [(match_operand:SI 2 "integer_register_operand" "d")
3379                                             (match_operand:SI 3 "gpr_or_int10_operand" "dJ")])
3380                         (const_int 0)))]
3381   ""
3382   "%O1%I3cc %2, %3, %., %0"
3383   [(set_attr "type" "int")
3384    (set_attr "length" "4")])
3386 (define_insn "*combo_intop_compare3"
3387   [(set (match_operand:CC 0 "icc_operand" "=t")
3388         (compare:CC (match_operator:SI 1 "intop_compare_operator"
3389                                        [(match_operand:SI 2 "integer_register_operand" "d")
3390                                         (match_operand:SI 3 "gpr_or_int10_operand" "dJ")])
3391                     (const_int 0)))
3392    (set (match_operand:SI 4 "integer_register_operand" "=d")
3393         (match_operator:SI 5 "intop_compare_operator"
3394                            [(match_dup 2)
3395                             (match_dup 3)]))]
3396   "GET_CODE (operands[1]) == GET_CODE (operands[5])"
3397   "%O1%I3cc %2, %3, %4, %0"
3398   [(set_attr "type" "int")
3399    (set_attr "length" "4")])
3401 (define_insn "*combo_intop_compare4"
3402   [(set (match_operand:CC_UNS 0 "icc_operand" "=t")
3403         (compare:CC_UNS (match_operator:SI 1 "intop_compare_operator"
3404                                            [(match_operand:SI 2 "integer_register_operand" "d")
3405                                             (match_operand:SI 3 "gpr_or_int10_operand" "dJ")])
3406                     (const_int 0)))
3407    (set (match_operand:SI 4 "integer_register_operand" "=d")
3408         (match_operator:SI 5 "intop_compare_operator"
3409                            [(match_dup 2)
3410                             (match_dup 3)]))]
3411   "GET_CODE (operands[1]) == GET_CODE (operands[5])"
3412   "%O1%I3cc %2, %3, %4, %0"
3413   [(set_attr "type" "int")
3414    (set_attr "length" "4")])
3417 ;; ::::::::::::::::::::
3418 ;; ::
3419 ;; :: Comparisons
3420 ;; ::
3421 ;; ::::::::::::::::::::
3423 ;; Note, we store the operands in the comparison insns, and use them later
3424 ;; when generating the branch or scc operation.
3426 ;; First the routines called by the machine independent part of the compiler
3427 (define_expand "cmpsi"
3428   [(set (cc0)
3429         (compare (match_operand:SI 0 "integer_register_operand" "")
3430                  (match_operand:SI 1 "gpr_or_int10_operand" "")))]
3431   ""
3432   "
3434   frv_compare_op0 = operands[0];
3435   frv_compare_op1 = operands[1];
3436   DONE;
3439 ;(define_expand "cmpdi"
3440 ;  [(set (cc0)
3441 ;        (compare (match_operand:DI 0 "register_operand" "")
3442 ;                (match_operand:DI 1 "nonmemory_operand" "")))]
3443 ;  ""
3444 ;  "
3446 ;  frv_compare_op0 = operands[0];
3447 ;  frv_compare_op1 = operands[1];
3448 ;  DONE;
3449 ;}")
3451 (define_expand "cmpsf"
3452  [(set (cc0)
3453        (compare (match_operand:SF 0 "fpr_operand" "")
3454                  (match_operand:SF 1 "fpr_operand" "")))]
3455  "TARGET_HARD_FLOAT"
3458   frv_compare_op0 = operands[0];
3459   frv_compare_op1 = operands[1];
3460   DONE;
3463 (define_expand "cmpdf"
3464   [(set (cc0)
3465         (compare (match_operand:DF 0 "fpr_operand" "")
3466                  (match_operand:DF 1 "fpr_operand" "")))]
3467   "TARGET_HARD_FLOAT && TARGET_DOUBLE"
3468   "
3470   frv_compare_op0 = operands[0];
3471   frv_compare_op1 = operands[1];
3472   DONE;
3475 ;; Now, the actual comparisons, generated by the branch and/or scc operations
3477 (define_insn "cmpsi_cc"
3478   [(set (match_operand:CC 0 "icc_operand" "=t,t")
3479         (compare:CC (match_operand:SI 1 "integer_register_operand" "d,d")
3480                     (match_operand:SI 2 "gpr_or_int10_operand" "d,J")))]
3481   ""
3482   "cmp%I2 %1,%2,%0"
3483   [(set_attr "length" "4")
3484    (set_attr "type" "int")])
3486 (define_insn "*cmpsi_cc_uns"
3487   [(set (match_operand:CC_UNS 0 "icc_operand" "=t,t")
3488         (compare:CC_UNS (match_operand:SI 1 "integer_register_operand" "d,d")
3489                         (match_operand:SI 2 "gpr_or_int10_operand" "d,J")))]
3490   ""
3491   "cmp%I2 %1,%2,%0"
3492   [(set_attr "length" "4")
3493    (set_attr "type" "int")])
3495 (define_insn "*cmpsf_cc_fp"
3496   [(set (match_operand:CC_FP 0 "fcc_operand" "=u")
3497         (compare:CC_FP (match_operand:SF 1 "fpr_operand" "f")
3498                        (match_operand:SF 2 "fpr_operand" "f")))]
3499   "TARGET_HARD_FLOAT"
3500   "fcmps %1,%2,%0"
3501   [(set_attr "length" "4")
3502    (set_attr "type" "fsadd")])
3504 (define_insn "*cmpdf_cc_fp"
3505   [(set (match_operand:CC_FP 0 "fcc_operand" "=u")
3506         (compare:CC_FP (match_operand:DF 1 "even_fpr_operand" "h")
3507                        (match_operand:DF 2 "even_fpr_operand" "h")))]
3508   "TARGET_HARD_FLOAT && TARGET_DOUBLE"
3509   "fcmpd %1,%2,%0"
3510   [(set_attr "length" "4")
3511    (set_attr "type" "fdadd")])
3514 ;; ::::::::::::::::::::
3515 ;; ::
3516 ;; :: Branches
3517 ;; ::
3518 ;; ::::::::::::::::::::
3520 ;; Define_expands called by the machine independent part of the compiler
3521 ;; to allocate a new comparison register.  Each of these named patterns
3522 ;; must be present, and they cannot be amalgamated into one pattern.
3524 ;; If a fixed condition code register is being used, (as opposed to, say,
3525 ;; using cc0), then the expands should look like this:
3527 ;; (define_expand "<name_of_test>"
3528 ;;   [(set (reg:CC <number_of_CC_register>)
3529 ;;      (compare:CC (match_dup 1)
3530 ;;                  (match_dup 2)))
3531 ;;    (set (pc)
3532 ;;      (if_then_else (eq:CC (reg:CC <number_of_CC_register>)
3533 ;;                           (const_int 0))
3534 ;;                    (label_ref (match_operand 0 "" ""))
3535 ;;                    (pc)))]
3536 ;;   ""
3537 ;;   "{
3538 ;;     operands[1] = frv_compare_op0;
3539 ;;     operands[2] = frv_compare_op1;
3540 ;;   }"
3541 ;; )
3543 (define_expand "beq"
3544   [(use (match_operand 0 "" ""))]
3545   ""
3546   "
3548   if (! frv_emit_cond_branch (EQ, operands[0]))
3549     FAIL;
3551   DONE;
3554 (define_expand "bne"
3555   [(use (match_operand 0 "" ""))]
3556   ""
3557   "
3559   if (! frv_emit_cond_branch (NE, operands[0]))
3560     FAIL;
3562   DONE;
3565 (define_expand "blt"
3566   [(use (match_operand 0 "" ""))]
3567   ""
3568   "
3570   if (! frv_emit_cond_branch (LT, operands[0]))
3571     FAIL;
3573   DONE;
3576 (define_expand "ble"
3577   [(use (match_operand 0 "" ""))]
3578   ""
3579   "
3581   if (! frv_emit_cond_branch (LE, operands[0]))
3582     FAIL;
3584   DONE;
3587 (define_expand "bgt"
3588   [(use (match_operand 0 "" ""))]
3589   ""
3590   "
3592   if (! frv_emit_cond_branch (GT, operands[0]))
3593     FAIL;
3595   DONE;
3598 (define_expand "bge"
3599   [(use (match_operand 0 "" ""))]
3600   ""
3601   "
3603   if (! frv_emit_cond_branch (GE, operands[0]))
3604     FAIL;
3606   DONE;
3609 (define_expand "bltu"
3610   [(use (match_operand 0 "" ""))]
3611   ""
3612   "
3614   if (! frv_emit_cond_branch (LTU, operands[0]))
3615     FAIL;
3617   DONE;
3620 (define_expand "bleu"
3621   [(use (match_operand 0 "" ""))]
3622   ""
3623   "
3625   if (! frv_emit_cond_branch (LEU, operands[0]))
3626     FAIL;
3628   DONE;
3631 (define_expand "bgtu"
3632   [(use (match_operand 0 "" ""))]
3633   ""
3634   "
3636   if (! frv_emit_cond_branch (GTU, operands[0]))
3637     FAIL;
3639   DONE;
3642 (define_expand "bgeu"
3643   [(use (match_operand 0 "" ""))]
3644   ""
3645   "
3647   if (! frv_emit_cond_branch (GEU, operands[0]))
3648     FAIL;
3650   DONE;
3653 ;; Actual branches.  We must allow for the (label_ref) and the (pc) to be
3654 ;; swapped.  If they are swapped, it reverses the sense of the branch.
3656 ;; Note - unlike the define expands above, these patterns can be amalgamated
3657 ;; into one pattern for branch-if-true and one for branch-if-false.  This does
3658 ;; require an operand operator to select the correct branch mnemonic.
3660 ;; If a fixed condition code register is being used, (as opposed to, say,
3661 ;; using cc0), then the expands could look like this:
3663 ;; (define_insn "*branch_true"
3664 ;;   [(set (pc)
3665 ;;      (if_then_else (match_operator:CC 0 "comparison_operator"
3666 ;;                                       [(reg:CC <number_of_CC_register>)
3667 ;;                                        (const_int 0)])
3668 ;;                    (label_ref (match_operand 1 "" ""))
3669 ;;                    (pc)))]
3670 ;;   ""
3671 ;;   "b%B0 %1"
3672 ;;   [(set_attr "length" "4")]
3673 ;; )
3675 ;; In the above example the %B is a directive to frv_print_operand()
3676 ;; to decode and print the correct branch mnemonic.
3678 (define_insn "*branch_signed_true"
3679   [(set (pc)
3680         (if_then_else (match_operator:CC 0 "signed_relational_operator"
3681                                          [(match_operand 1 "icc_operand" "t")
3682                                           (const_int 0)])
3683                       (label_ref (match_operand 2 "" ""))
3684                       (pc)))]
3685   ""
3686   "*
3688   if (get_attr_length (insn) == 4)
3689     return \"b%c0 %1,%#,%l2\";
3690   else
3691     return \"b%C0 %1,%#,1f\;call %l2\\n1:\";
3693   [(set (attr "length")
3694         (if_then_else
3695             (and (ge (minus (match_dup 2) (pc)) (const_int -32768))
3696                  (le (minus (match_dup 2) (pc)) (const_int 32764)))
3697             (const_int 4)
3698             (const_int 8)))
3699    (set (attr "far_jump")
3700         (if_then_else
3701             (eq_attr "length" "4")
3702             (const_string "no")
3703             (const_string "yes")))
3704    (set (attr "type")
3705         (if_then_else
3706             (eq_attr "length" "4")
3707             (const_string "branch")
3708             (const_string "multi")))])
3710 (define_insn "*branch_signed_false"
3711   [(set (pc)
3712         (if_then_else (match_operator:CC 0 "signed_relational_operator"
3713                                          [(match_operand 1 "icc_operand" "t")
3714                                           (const_int 0)])
3715                       (pc)
3716                       (label_ref (match_operand 2 "" ""))))]
3717   ""
3718   "*
3720   if (get_attr_length (insn) == 4)
3721     return \"b%C0 %1,%#,%l2\";
3722   else
3723     return \"b%c0 %1,%#,1f\;call %l2\\n1:\";
3725   [(set (attr "length")
3726         (if_then_else
3727             (and (ge (minus (match_dup 2) (pc)) (const_int -32768))
3728                  (le (minus (match_dup 2) (pc)) (const_int 32764)))
3729             (const_int 4)
3730             (const_int 8)))
3731    (set (attr "far_jump")
3732         (if_then_else
3733             (eq_attr "length" "4")
3734             (const_string "no")
3735             (const_string "yes")))
3736    (set (attr "type")
3737         (if_then_else
3738             (eq_attr "length" "4")
3739             (const_string "branch")
3740             (const_string "multi")))])
3742 (define_insn "*branch_unsigned_true"
3743   [(set (pc)
3744         (if_then_else (match_operator:CC_UNS 0 "unsigned_relational_operator"
3745                                              [(match_operand 1 "icc_operand" "t")
3746                                               (const_int 0)])
3747                       (label_ref (match_operand 2 "" ""))
3748                       (pc)))]
3749   ""
3750   "*
3752   if (get_attr_length (insn) == 4)
3753     return \"b%c0 %1,%#,%l2\";
3754   else
3755     return \"b%C0 %1,%#,1f\;call %l2\\n1:\";
3757   [(set (attr "length")
3758         (if_then_else
3759             (and (ge (minus (match_dup 2) (pc)) (const_int -32768))
3760                  (le (minus (match_dup 2) (pc)) (const_int 32764)))
3761             (const_int 4)
3762             (const_int 8)))
3763    (set (attr "far_jump")
3764         (if_then_else
3765             (eq_attr "length" "4")
3766             (const_string "no")
3767             (const_string "yes")))
3768    (set (attr "type")
3769         (if_then_else
3770             (eq_attr "length" "4")
3771             (const_string "branch")
3772             (const_string "multi")))])
3774 (define_insn "*branch_unsigned_false"
3775   [(set (pc)
3776         (if_then_else (match_operator:CC_UNS 0 "unsigned_relational_operator"
3777                                              [(match_operand 1 "icc_operand" "t")
3778                                               (const_int 0)])
3779                       (pc)
3780                       (label_ref (match_operand 2 "" ""))))]
3781   ""
3782   "*
3784   if (get_attr_length (insn) == 4)
3785     return \"b%C0 %1,%#,%l2\";
3786   else
3787     return \"b%c0 %1,%#,1f\;call %l2\\n1:\";
3789   [(set (attr "length")
3790         (if_then_else
3791             (and (ge (minus (match_dup 2) (pc)) (const_int -32768))
3792                  (le (minus (match_dup 2) (pc)) (const_int 32764)))
3793             (const_int 4)
3794             (const_int 8)))
3795    (set (attr "far_jump")
3796         (if_then_else
3797             (eq_attr "length" "4")
3798             (const_string "no")
3799             (const_string "yes")))
3800    (set (attr "type")
3801         (if_then_else
3802             (eq_attr "length" "4")
3803             (const_string "branch")
3804             (const_string "multi")))])
3806 (define_insn "*branch_fp_true"
3807   [(set (pc)
3808         (if_then_else (match_operator:CC_FP 0 "float_relational_operator"
3809                                             [(match_operand 1 "fcc_operand" "u")
3810                                              (const_int 0)])
3811                       (label_ref (match_operand 2 "" ""))
3812                       (pc)))]
3813   ""
3814   "*
3816   if (get_attr_length (insn) == 4)
3817     return \"fb%f0 %1,%#,%l2\";
3818   else
3819     return \"fb%F0 %1,%#,1f\;call %l2\\n1:\";
3821   [(set (attr "length")
3822         (if_then_else
3823             (and (ge (minus (match_dup 2) (pc)) (const_int -32768))
3824                  (le (minus (match_dup 2) (pc)) (const_int 32764)))
3825             (const_int 4)
3826             (const_int 8)))
3827    (set (attr "far_jump")
3828         (if_then_else
3829             (eq_attr "length" "4")
3830             (const_string "no")
3831             (const_string "yes")))
3832    (set (attr "type")
3833         (if_then_else
3834             (eq_attr "length" "4")
3835             (const_string "branch")
3836             (const_string "multi")))])
3838 (define_insn "*branch_fp_false"
3839   [(set (pc)
3840         (if_then_else (match_operator:CC_FP 0 "float_relational_operator"
3841                                             [(match_operand 1 "fcc_operand" "u")
3842                                              (const_int 0)])
3843                       (pc)
3844                       (label_ref (match_operand 2 "" ""))))]
3845   ""
3846   "*
3848   if (get_attr_length (insn) == 4)
3849     return \"fb%F0 %1,%#,%l2\";
3850   else
3851     return \"fb%f0 %1,%#,1f\;call %l2\\n1:\";
3853   [(set (attr "length")
3854         (if_then_else
3855             (and (ge (minus (match_dup 2) (pc)) (const_int -32768))
3856                  (le (minus (match_dup 2) (pc)) (const_int 32764)))
3857             (const_int 4)
3858             (const_int 8)))
3859    (set (attr "far_jump")
3860         (if_then_else
3861             (eq_attr "length" "4")
3862             (const_string "no")
3863             (const_string "yes")))
3864    (set (attr "type")
3865         (if_then_else
3866             (eq_attr "length" "4")
3867             (const_string "branch")
3868             (const_string "multi")))])
3871 ;; ::::::::::::::::::::
3872 ;; ::
3873 ;; :: Set flag operations
3874 ;; ::
3875 ;; ::::::::::::::::::::
3877 ;; Define_expands called by the machine independent part of the compiler
3878 ;; to allocate a new comparison register
3880 (define_expand "seq"
3881   [(match_operand:SI 0 "integer_register_operand" "")]
3882   "TARGET_SCC"
3883   "
3885   if (! frv_emit_scc (EQ, operands[0]))
3886     FAIL;
3888   DONE;
3891 (define_expand "sne"
3892   [(match_operand:SI 0 "integer_register_operand" "")]
3893   "TARGET_SCC"
3894   "
3896   if (! frv_emit_scc (NE, operands[0]))
3897     FAIL;
3899   DONE;
3902 (define_expand "slt"
3903   [(match_operand:SI 0 "integer_register_operand" "")]
3904   "TARGET_SCC"
3905   "
3907   if (! frv_emit_scc (LT, operands[0]))
3908     FAIL;
3910   DONE;
3913 (define_expand "sle"
3914   [(match_operand:SI 0 "integer_register_operand" "")]
3915   "TARGET_SCC"
3916   "
3918   if (! frv_emit_scc (LE, operands[0]))
3919     FAIL;
3921   DONE;
3924 (define_expand "sgt"
3925   [(match_operand:SI 0 "integer_register_operand" "")]
3926   "TARGET_SCC"
3927   "
3929   if (! frv_emit_scc (GT, operands[0]))
3930     FAIL;
3932   DONE;
3935 (define_expand "sge"
3936   [(match_operand:SI 0 "integer_register_operand" "")]
3937   "TARGET_SCC"
3938   "
3940   if (! frv_emit_scc (GE, operands[0]))
3941     FAIL;
3943   DONE;
3946 (define_expand "sltu"
3947   [(match_operand:SI 0 "integer_register_operand" "")]
3948   "TARGET_SCC"
3949   "
3951   if (! frv_emit_scc (LTU, operands[0]))
3952     FAIL;
3954   DONE;
3957 (define_expand "sleu"
3958   [(match_operand:SI 0 "integer_register_operand" "")]
3959   "TARGET_SCC"
3960   "
3962   if (! frv_emit_scc (LEU, operands[0]))
3963     FAIL;
3965   DONE;
3968 (define_expand "sgtu"
3969   [(match_operand:SI 0 "integer_register_operand" "")]
3970   "TARGET_SCC"
3971   "
3973   if (! frv_emit_scc (GTU, operands[0]))
3974     FAIL;
3976   DONE;
3979 (define_expand "sgeu"
3980   [(match_operand:SI 0 "integer_register_operand" "")]
3981   "TARGET_SCC"
3982   "
3984   if (! frv_emit_scc (GEU, operands[0]))
3985     FAIL;
3987   DONE;
3990 (define_insn "*scc_signed"
3991   [(set (match_operand:SI 0 "integer_register_operand" "=d")
3992         (match_operator:SI 1 "signed_relational_operator"
3993                            [(match_operand:CC 2 "icc_operand" "t")
3994                             (const_int 0)]))
3995    (clobber (match_operand:CC_CCR 3 "icr_operand" "=v"))]
3996   ""
3997   "#"
3998   [(set_attr "length" "12")
3999    (set_attr "type" "multi")])
4001 (define_insn "*scc_unsigned"
4002   [(set (match_operand:SI 0 "integer_register_operand" "=d")
4003         (match_operator:SI 1 "unsigned_relational_operator"
4004                            [(match_operand:CC_UNS 2 "icc_operand" "t")
4005                             (const_int 0)]))
4006    (clobber (match_operand:CC_CCR 3 "icr_operand" "=v"))]
4007   ""
4008   "#"
4009   [(set_attr "length" "12")
4010    (set_attr "type" "multi")])
4012 (define_insn "*scc_float"
4013   [(set (match_operand:SI 0 "integer_register_operand" "=d")
4014         (match_operator:SI 1 "float_relational_operator"
4015                            [(match_operand:CC_FP 2 "fcc_operand" "u")
4016                             (const_int 0)]))
4017    (clobber (match_operand:CC_CCR 3 "fcr_operand" "=w"))]
4018   ""
4019   "#"
4020   [(set_attr "length" "12")
4021    (set_attr "type" "multi")])
4023 ;; XXX -- add reload_completed to the splits, because register allocation
4024 ;; currently isn't ready to see cond_exec packets.
4025 (define_split
4026   [(set (match_operand:SI 0 "integer_register_operand" "")
4027         (match_operator:SI 1 "relational_operator"
4028                            [(match_operand 2 "cc_operand" "")
4029                             (const_int 0)]))
4030    (clobber (match_operand 3 "cr_operand" ""))]
4031   "reload_completed"
4032   [(match_dup 4)]
4033   "operands[4] = frv_split_scc (operands[0], operands[1], operands[2],
4034                                 operands[3], (HOST_WIDE_INT) 1);")
4036 (define_insn "*scc_neg1_signed"
4037   [(set (match_operand:SI 0 "integer_register_operand" "=d")
4038         (neg:SI (match_operator:SI 1 "signed_relational_operator"
4039                                    [(match_operand:CC 2 "icc_operand" "t")
4040                                     (const_int 0)])))
4041    (clobber (match_operand:CC_CCR 3 "icr_operand" "=v"))]
4042   ""
4043   "#"
4044   [(set_attr "length" "12")
4045    (set_attr "type" "multi")])
4047 (define_insn "*scc_neg1_unsigned"
4048   [(set (match_operand:SI 0 "integer_register_operand" "=d")
4049         (neg:SI (match_operator:SI 1 "unsigned_relational_operator"
4050                                    [(match_operand:CC_UNS 2 "icc_operand" "t")
4051                                     (const_int 0)])))
4052    (clobber (match_operand:CC_CCR 3 "icr_operand" "=v"))]
4053   ""
4054   "#"
4055   [(set_attr "length" "12")
4056    (set_attr "type" "multi")])
4058 (define_insn "*scc_neg1_float"
4059   [(set (match_operand:SI 0 "integer_register_operand" "=d")
4060         (neg:SI (match_operator:SI 1 "float_relational_operator"
4061                                    [(match_operand:CC_FP 2 "fcc_operand" "u")
4062                                     (const_int 0)])))
4063    (clobber (match_operand:CC_CCR 3 "fcr_operand" "=w"))]
4064   ""
4065   "#"
4066   [(set_attr "length" "12")
4067    (set_attr "type" "multi")])
4069 (define_split
4070   [(set (match_operand:SI 0 "integer_register_operand" "")
4071         (neg:SI (match_operator:SI 1 "relational_operator"
4072                                    [(match_operand 2 "cc_operand" "")
4073                                     (const_int 0)])))
4074    (clobber (match_operand 3 "cr_operand" ""))]
4075   "reload_completed"
4076   [(match_dup 4)]
4077   "operands[4] = frv_split_scc (operands[0], operands[1], operands[2],
4078                                 operands[3], (HOST_WIDE_INT) -1);")
4081 ;; ::::::::::::::::::::
4082 ;; ::
4083 ;; :: Conditionally executed instructions
4084 ;; ::
4085 ;; ::::::::::::::::::::
4087 ;; Convert ICC/FCC comparison into CCR bits so we can do conditional execution
4088 (define_insn "*ck_signed"
4089   [(set (match_operand:CC_CCR 0 "icr_operand" "=v")
4090         (match_operator:CC_CCR 1 "signed_relational_operator"
4091                                [(match_operand:CC 2 "icc_operand" "t")
4092                                 (const_int 0)]))]
4093   ""
4094   "ck%c1 %2, %0"
4095   [(set_attr "length" "4")
4096    (set_attr "type" "ccr")])
4098 (define_insn "*ck_unsigned"
4099   [(set (match_operand:CC_CCR 0 "icr_operand" "=v")
4100         (match_operator:CC_CCR 1 "unsigned_relational_operator"
4101                                [(match_operand:CC_UNS 2 "icc_operand" "t")
4102                                 (const_int 0)]))]
4103   ""
4104   "ck%c1 %2, %0"
4105   [(set_attr "length" "4")
4106    (set_attr "type" "ccr")])
4108 (define_insn "*fck_float"
4109   [(set (match_operand:CC_CCR 0 "fcr_operand" "=w")
4110         (match_operator:CC_CCR 1 "float_relational_operator"
4111                                [(match_operand:CC_FP 2 "fcc_operand" "u")
4112                                 (const_int 0)]))]
4113   "TARGET_HAS_FPRS"
4114   "fck%c1 %2, %0"
4115   [(set_attr "length" "4")
4116    (set_attr "type" "ccr")])
4118 ;; Conditionally convert ICC/FCC comparison into CCR bits to provide && and ||
4119 ;; tests in conditional execution
4120 (define_insn "cond_exec_ck"
4121   [(set (match_operand:CC_CCR 0 "cr_operand" "=v,w")
4122         (if_then_else:CC_CCR (match_operator 1 "ccr_eqne_operator"
4123                                              [(match_operand 2 "cr_operand" "C,C")
4124                                               (const_int 0)])
4125                              (match_operator 3 "relational_operator"
4126                                              [(match_operand 4 "cc_operand" "t,u")
4127                                               (const_int 0)])
4128                              (const_int 0)))]
4129   ""
4130   "@
4131    cck%c3 %4, %0, %2, %e1
4132    cfck%f3 %4, %0, %2, %e1"
4133   [(set_attr "length" "4")
4134    (set_attr "type" "ccr")])
4136 ;; Conditionally set a register to either 0 or another register
4137 (define_insn "*cond_exec_movqi"
4138   [(cond_exec
4139     (match_operator 0 "ccr_eqne_operator"
4140                     [(match_operand 1 "cr_operand" "C,C,C,C,C,C")
4141                      (const_int 0)])
4142     (set (match_operand:QI 2 "condexec_dest_operand" "=d,d,U,?f,?f,?d")
4143          (match_operand:QI 3 "condexec_source_operand" "dO,U,dO,f,d,f")))]
4144   "register_operand(operands[2], QImode) || reg_or_0_operand (operands[3], QImode)"
4145   "* return output_condmove_single (operands, insn);"
4146   [(set_attr "length" "4")
4147    (set_attr "type" "int,gload,gstore,fsconv,movgf,movfg")])
4149 (define_insn "*cond_exec_movhi"
4150   [(cond_exec
4151     (match_operator 0 "ccr_eqne_operator"
4152                     [(match_operand 1 "cr_operand" "C,C,C,C,C,C")
4153                      (const_int 0)])
4154     (set (match_operand:HI 2 "condexec_dest_operand" "=d,d,U,?f,?f,?d")
4155          (match_operand:HI 3 "condexec_source_operand" "dO,U,dO,f,d,f")))]
4156   "register_operand(operands[2], HImode) || reg_or_0_operand (operands[3], HImode)"
4157   "* return output_condmove_single (operands, insn);"
4158   [(set_attr "length" "4")
4159    (set_attr "type" "int,gload,gstore,fsconv,movgf,movfg")])
4161 (define_insn "*cond_exec_movsi"
4162   [(cond_exec
4163     (match_operator 0 "ccr_eqne_operator"
4164                     [(match_operand 1 "cr_operand" "C,C,C,C,C,C,C,C")
4165                      (const_int 0)])
4166     (set (match_operand:SI 2 "condexec_dest_operand" "=d,d,U,?f,?f,?d,?f,?m")
4167          (match_operand:SI 3 "condexec_source_operand" "dO,U,dO,f,d,f,m,f")))]
4168   "register_operand(operands[2], SImode) || reg_or_0_operand (operands[3], SImode)"
4169   "* return output_condmove_single (operands, insn);"
4170   [(set_attr "length" "4")
4171    (set_attr "type" "int,gload,gstore,fsconv,movgf,movfg,fload,fstore")])
4174 (define_insn "*cond_exec_movsf_has_fprs"
4175   [(cond_exec
4176     (match_operator 0 "ccr_eqne_operator"
4177                     [(match_operand 1 "cr_operand" "C,C,C,C,C,C,C,C,C,C")
4178                      (const_int 0)])
4179     (set (match_operand:SF 2 "condexec_dest_operand" "=f,?d,?d,?f,f,f,?d,U,?U,U")
4180          (match_operand:SF 3 "condexec_source_operand" "f,d,f,d,G,U,U,f,d,G")))]
4181   "TARGET_HAS_FPRS"
4182   "* return output_condmove_single (operands, insn);"
4183   [(set_attr "length" "4")
4184    (set_attr "type" "fsconv,int,movgf,movfg,movgf,fload,gload,fstore,gstore,gstore")])
4186 (define_insn "*cond_exec_movsf_no_fprs"
4187   [(cond_exec
4188     (match_operator 0 "ccr_eqne_operator"
4189                     [(match_operand 1 "cr_operand" "C,C,C")
4190                      (const_int 0)])
4191     (set (match_operand:SF 2 "condexec_dest_operand" "=d,d,U")
4192          (match_operand:SF 3 "condexec_source_operand" "d,U,dG")))]
4193   "! TARGET_HAS_FPRS"
4194   "* return output_condmove_single (operands, insn);"
4195   [(set_attr "length" "4")
4196    (set_attr "type" "int,gload,gstore")])
4198 (define_insn "*cond_exec_si_binary1"
4199   [(cond_exec
4200     (match_operator 0 "ccr_eqne_operator"
4201                     [(match_operand 1 "cr_operand" "C")
4202                      (const_int 0)])
4203     (set (match_operand:SI 2 "integer_register_operand" "=d")
4204          (match_operator:SI 3 "condexec_si_binary_operator"
4205                             [(match_operand:SI 4 "integer_register_operand" "d")
4206                              (match_operand:SI 5 "integer_register_operand" "d")])))]
4207   ""
4208   "*
4210   switch (GET_CODE (operands[3]))
4211     {
4212       case PLUS:     return \"cadd %4, %z5, %2, %1, %e0\";
4213       case MINUS:    return \"csub %4, %z5, %2, %1, %e0\";
4214       case AND:      return \"cand %4, %z5, %2, %1, %e0\";
4215       case IOR:      return \"cor %4, %z5, %2, %1, %e0\";
4216       case XOR:      return \"cxor %4, %z5, %2, %1, %e0\";
4217       case ASHIFT:   return \"csll %4, %z5, %2, %1, %e0\";
4218       case ASHIFTRT: return \"csra %4, %z5, %2, %1, %e0\";
4219       case LSHIFTRT: return \"csrl %4, %z5, %2, %1, %e0\";
4220       default:       abort ();
4221     }
4223   [(set_attr "length" "4")
4224    (set_attr "type" "int")])
4226 (define_insn "*cond_exec_si_binary2"
4227   [(cond_exec
4228     (match_operator 0 "ccr_eqne_operator"
4229                     [(match_operand 1 "cr_operand" "C")
4230                      (const_int 0)])
4231     (set (match_operand:SI 2 "fpr_operand" "=f")
4232          (match_operator:SI 3 "condexec_si_media_operator"
4233                             [(match_operand:SI 4 "fpr_operand" "f")
4234                              (match_operand:SI 5 "fpr_operand" "f")])))]
4235   "TARGET_MEDIA"
4236   "*
4238   switch (GET_CODE (operands[3]))
4239     {
4240       case AND: return \"cmand %4, %5, %2, %1, %e0\";
4241       case IOR: return \"cmor %4, %5, %2, %1, %e0\";
4242       case XOR: return \"cmxor %4, %5, %2, %1, %e0\";
4243       default:  abort ();
4244     }
4246   [(set_attr "length" "4")
4247    (set_attr "type" "mlogic")])
4249 ;; Note, flow does not (currently) know how to handle an operation that uses
4250 ;; only part of the hard registers allocated for a multiregister value, such as
4251 ;; DImode in this case if the user is only interested in the lower 32-bits.  So
4252 ;; we emit a USE of the entire register after the csmul instruction so it won't
4253 ;; get confused.  See frv_ifcvt_modify_insn for more details.
4255 (define_insn "*cond_exec_si_smul"
4256   [(cond_exec
4257     (match_operator 0 "ccr_eqne_operator"
4258                     [(match_operand 1 "cr_operand" "C")
4259                      (const_int 0)])
4260     (set (match_operand:DI 2 "even_gpr_operand" "=e")
4261          (mult:DI (sign_extend:DI (match_operand:SI 3 "integer_register_operand" "%d"))
4262                   (sign_extend:DI (match_operand:SI 4 "integer_register_operand" "d")))))]
4263   ""
4264   "csmul %3, %4, %2, %1, %e0"
4265   [(set_attr "length" "4")
4266    (set_attr "type" "mul")])
4268 (define_insn "*cond_exec_si_divide"
4269   [(cond_exec
4270     (match_operator 0 "ccr_eqne_operator"
4271                     [(match_operand 1 "cr_operand" "C")
4272                      (const_int 0)])
4273     (set (match_operand:SI 2 "integer_register_operand" "=d")
4274          (match_operator:SI 3 "condexec_si_divide_operator"
4275                             [(match_operand:SI 4 "integer_register_operand" "d")
4276                              (match_operand:SI 5 "integer_register_operand" "d")])))]
4277   ""
4278   "*
4280   switch (GET_CODE (operands[3]))
4281     {
4282       case DIV:  return \"csdiv %4, %z5, %2, %1, %e0\";
4283       case UDIV: return \"cudiv %4, %z5, %2, %1, %e0\";
4284       default:   abort ();
4285     }
4287   [(set_attr "length" "4")
4288    (set_attr "type" "div")])
4290 (define_insn "*cond_exec_si_unary1"
4291   [(cond_exec
4292     (match_operator 0 "ccr_eqne_operator"
4293                     [(match_operand 1 "cr_operand" "C")
4294                      (const_int 0)])
4295     (set (match_operand:SI 2 "integer_register_operand" "=d")
4296          (match_operator:SI 3 "condexec_si_unary_operator"
4297                             [(match_operand:SI 4 "integer_register_operand" "d")])))]
4298   ""
4299   "*
4301   switch (GET_CODE (operands[3]))
4302     {
4303       case NOT: return \"cnot %4, %2, %1, %e0\";
4304       case NEG: return \"csub %., %4, %2, %1, %e0\";
4305       default:  abort ();
4306     }
4308   [(set_attr "length" "4")
4309    (set_attr "type" "int")])
4311 (define_insn "*cond_exec_si_unary2"
4312   [(cond_exec
4313     (match_operator 0 "ccr_eqne_operator"
4314                     [(match_operand 1 "cr_operand" "C")
4315                      (const_int 0)])
4316     (set (match_operand:SI 2 "fpr_operand" "=f")
4317          (not:SI (match_operand:SI 3 "fpr_operand" "f"))))]
4318   "TARGET_MEDIA"
4319   "cmnot %3, %2, %1, %e0"
4320   [(set_attr "length" "4")
4321    (set_attr "type" "mlogic")])
4323 (define_insn "*cond_exec_cmpsi_cc"
4324   [(cond_exec
4325     (match_operator 0 "ccr_eqne_operator"
4326                     [(match_operand 1 "cr_operand" "C")
4327                      (const_int 0)])
4328     (set (match_operand:CC 2 "icc_operand" "=t")
4329          (compare:CC (match_operand:SI 3 "integer_register_operand" "d")
4330                      (match_operand:SI 4 "reg_or_0_operand" "dO"))))]
4331   "reload_completed
4332    && REGNO (operands[1]) == REGNO (operands[2]) - ICC_FIRST + ICR_FIRST"
4333   "ccmp %3, %z4, %1, %e0"
4334   [(set_attr "length" "4")
4335    (set_attr "type" "int")])
4337 (define_insn "*cond_exec_cmpsi_cc_uns"
4338   [(cond_exec
4339     (match_operator 0 "ccr_eqne_operator"
4340                     [(match_operand 1 "cr_operand" "C")
4341                      (const_int 0)])
4342     (set (match_operand:CC_UNS 2 "icc_operand" "=t")
4343          (compare:CC_UNS (match_operand:SI 3 "integer_register_operand" "d")
4344                          (match_operand:SI 4 "reg_or_0_operand" "dO"))))]
4345   "reload_completed
4346    && REGNO (operands[1]) == REGNO (operands[2]) - ICC_FIRST + ICR_FIRST"
4347   "ccmp %3, %z4, %1, %e0"
4348   [(set_attr "length" "4")
4349    (set_attr "type" "int")])
4351 (define_insn "*cond_exec_sf_conv"
4352   [(cond_exec
4353     (match_operator 0 "ccr_eqne_operator"
4354                     [(match_operand 1 "cr_operand" "C")
4355                      (const_int 0)])
4356     (set (match_operand:SF 2 "fpr_operand" "=f")
4357          (match_operator:SF 3 "condexec_sf_conv_operator"
4358                             [(match_operand:SF 4 "fpr_operand" "f")])))]
4359   "TARGET_HARD_FLOAT"
4360   "*
4362   switch (GET_CODE (operands[3]))
4363     {
4364       case ABS: return \"cfabss %4, %2, %1, %e0\";
4365       case NEG: return \"cfnegs %4, %2, %1, %e0\";
4366       default:  abort ();
4367     }
4369   [(set_attr "length" "4")
4370    (set_attr "type" "fsconv")])
4372 (define_insn "*cond_exec_sf_add"
4373   [(cond_exec
4374     (match_operator 0 "ccr_eqne_operator"
4375                     [(match_operand 1 "cr_operand" "C")
4376                      (const_int 0)])
4377     (set (match_operand:SF 2 "fpr_operand" "=f")
4378          (match_operator:SF 3 "condexec_sf_add_operator"
4379                             [(match_operand:SF 4 "fpr_operand" "f")
4380                              (match_operand:SF 5 "fpr_operand" "f")])))]
4381   "TARGET_HARD_FLOAT"
4382   "*
4384   switch (GET_CODE (operands[3]))
4385     {
4386       case PLUS:  return \"cfadds %4, %5, %2, %1, %e0\";
4387       case MINUS: return \"cfsubs %4, %5, %2, %1, %e0\";
4388       default:    abort ();
4389     }
4391   [(set_attr "length" "4")
4392    (set_attr "type" "fsadd")])
4394 (define_insn "*cond_exec_sf_mul"
4395   [(cond_exec
4396     (match_operator 0 "ccr_eqne_operator"
4397                     [(match_operand 1 "cr_operand" "C")
4398                      (const_int 0)])
4399     (set (match_operand:SF 2 "fpr_operand" "=f")
4400          (mult:SF (match_operand:SF 3 "fpr_operand" "f")
4401                   (match_operand:SF 4 "fpr_operand" "f"))))]
4402   "TARGET_HARD_FLOAT"
4403   "cfmuls %3, %4, %2, %1, %e0"
4404   [(set_attr "length" "4")
4405    (set_attr "type" "fsmul")])
4407 (define_insn "*cond_exec_sf_div"
4408   [(cond_exec
4409     (match_operator 0 "ccr_eqne_operator"
4410                     [(match_operand 1 "cr_operand" "C")
4411                      (const_int 0)])
4412     (set (match_operand:SF 2 "fpr_operand" "=f")
4413          (div:SF (match_operand:SF 3 "fpr_operand" "f")
4414                  (match_operand:SF 4 "fpr_operand" "f"))))]
4415   "TARGET_HARD_FLOAT"
4416   "cfdivs %3, %4, %2, %1, %e0"
4417   [(set_attr "length" "4")
4418    (set_attr "type" "fsdiv")])
4420 (define_insn "*cond_exec_sf_sqrt"
4421   [(cond_exec
4422     (match_operator 0 "ccr_eqne_operator"
4423                     [(match_operand 1 "cr_operand" "C")
4424                      (const_int 0)])
4425     (set (match_operand:SF 2 "fpr_operand" "=f")
4426          (sqrt:SF (match_operand:SF 3 "fpr_operand" "f"))))]
4427   "TARGET_HARD_FLOAT"
4428   "cfsqrts %3, %2, %1, %e0"
4429   [(set_attr "length" "4")
4430    (set_attr "type" "fsdiv")])
4432 (define_insn "*cond_exec_cmpsi_cc_fp"
4433   [(cond_exec
4434     (match_operator 0 "ccr_eqne_operator"
4435                     [(match_operand 1 "cr_operand" "C")
4436                      (const_int 0)])
4437     (set (match_operand:CC_FP 2 "fcc_operand" "=u")
4438          (compare:CC_FP (match_operand:SF 3 "fpr_operand" "f")
4439                         (match_operand:SF 4 "fpr_operand" "f"))))]
4440   "reload_completed && TARGET_HARD_FLOAT
4441    && REGNO (operands[1]) == REGNO (operands[2]) - FCC_FIRST + FCR_FIRST"
4442   "cfcmps %3, %4, %2, %1, %e0"
4443   [(set_attr "length" "4")
4444    (set_attr "type" "fsconv")])
4447 ;; ::::::::::::::::::::
4448 ;; ::
4449 ;; :: Logical operations on CR registers
4450 ;; ::
4451 ;; ::::::::::::::::::::
4453 ;; We use UNSPEC to encode andcr/iorcr/etc. rather than the normal RTL
4454 ;; operations, since the RTL operations only have an idea of TRUE and FALSE,
4455 ;; while the CRs have TRUE, FALSE, and UNDEFINED.
4457 (define_expand "andcr"
4458   [(set (match_operand:CC_CCR 0 "cr_operand" "")
4459         (unspec:CC_CCR [(match_operand:CC_CCR 1 "cr_operand" "")
4460                         (match_operand:CC_CCR 2 "cr_operand" "")
4461                         (const_int 0)] UNSPEC_CR_LOGIC))]
4462   ""
4463   "")
4465 (define_expand "orcr"
4466   [(set (match_operand:CC_CCR 0 "cr_operand" "")
4467         (unspec:CC_CCR [(match_operand:CC_CCR 1 "cr_operand" "")
4468                         (match_operand:CC_CCR 2 "cr_operand" "")
4469                         (const_int 1)] UNSPEC_CR_LOGIC))]
4470   ""
4471   "")
4473 (define_expand "xorcr"
4474   [(set (match_operand:CC_CCR 0 "cr_operand" "")
4475         (unspec:CC_CCR [(match_operand:CC_CCR 1 "cr_operand" "")
4476                         (match_operand:CC_CCR 2 "cr_operand" "")
4477                         (const_int 2)] UNSPEC_CR_LOGIC))]
4478   ""
4479   "")
4481 (define_expand "nandcr"
4482   [(set (match_operand:CC_CCR 0 "cr_operand" "")
4483         (unspec:CC_CCR [(match_operand:CC_CCR 1 "cr_operand" "")
4484                         (match_operand:CC_CCR 2 "cr_operand" "")
4485                         (const_int 3)] UNSPEC_CR_LOGIC))]
4486   ""
4487   "")
4489 (define_expand "norcr"
4490   [(set (match_operand:CC_CCR 0 "cr_operand" "")
4491         (unspec:CC_CCR [(match_operand:CC_CCR 1 "cr_operand" "")
4492                         (match_operand:CC_CCR 2 "cr_operand" "")
4493                         (const_int 4)] UNSPEC_CR_LOGIC))]
4494   ""
4495   "")
4497 (define_expand "andncr"
4498   [(set (match_operand:CC_CCR 0 "cr_operand" "")
4499         (unspec:CC_CCR [(match_operand:CC_CCR 1 "cr_operand" "")
4500                         (match_operand:CC_CCR 2 "cr_operand" "")
4501                         (const_int 5)] UNSPEC_CR_LOGIC))]
4502   ""
4503   "")
4505 (define_expand "orncr"
4506   [(set (match_operand:CC_CCR 0 "cr_operand" "")
4507         (unspec:CC_CCR [(match_operand:CC_CCR 1 "cr_operand" "")
4508                         (match_operand:CC_CCR 2 "cr_operand" "")
4509                         (const_int 6)] UNSPEC_CR_LOGIC))]
4510   ""
4511   "")
4513 (define_expand "nandncr"
4514   [(set (match_operand:CC_CCR 0 "cr_operand" "")
4515         (unspec:CC_CCR [(match_operand:CC_CCR 1 "cr_operand" "")
4516                         (match_operand:CC_CCR 2 "cr_operand" "")
4517                         (const_int 7)] UNSPEC_CR_LOGIC))]
4518   ""
4519   "")
4521 (define_expand "norncr"
4522   [(set (match_operand:CC_CCR 0 "cr_operand" "")
4523         (unspec:CC_CCR [(match_operand:CC_CCR 1 "cr_operand" "")
4524                         (match_operand:CC_CCR 2 "cr_operand" "")
4525                         (const_int 8)] UNSPEC_CR_LOGIC))]
4526   ""
4527   "")
4529 (define_expand "notcr"
4530   [(set (match_operand:CC_CCR 0 "cr_operand" "")
4531         (unspec:CC_CCR [(match_operand:CC_CCR 1 "cr_operand" "")
4532                         (match_dup 1)
4533                         (const_int 9)] UNSPEC_CR_LOGIC))]
4534   ""
4535   "")
4537 (define_insn "*logical_cr"
4538   [(set (match_operand:CC_CCR 0 "cr_operand" "=C")
4539         (unspec:CC_CCR [(match_operand:CC_CCR 1 "cr_operand" "C")
4540                         (match_operand:CC_CCR 2 "cr_operand" "C")
4541                         (match_operand:SI 3 "const_int_operand" "n")]
4542                        UNSPEC_CR_LOGIC))]
4543   ""
4544   "*
4546   switch (INTVAL (operands[3]))
4547   {
4548   default: break;
4549   case 0: return \"andcr %1, %2, %0\";
4550   case 1: return \"orcr %1, %2, %0\";
4551   case 2: return \"xorcr %1, %2, %0\";
4552   case 3: return \"nandcr %1, %2, %0\";
4553   case 4: return \"norcr %1, %2, %0\";
4554   case 5: return \"andncr %1, %2, %0\";
4555   case 6: return \"orncr %1, %2, %0\";
4556   case 7: return \"nandncr %1, %2, %0\";
4557   case 8: return \"norncr %1, %2, %0\";
4558   case 9: return \"notcr %1, %0\";
4559   }
4561   fatal_insn (\"logical_cr\", insn);
4563   [(set_attr "length" "4")
4564    (set_attr "type" "ccr")])
4567 ;; ::::::::::::::::::::
4568 ;; ::
4569 ;; :: Conditional move instructions
4570 ;; ::
4571 ;; ::::::::::::::::::::
4574 ;; - conditional moves based on floating-point comparisons require
4575 ;;   TARGET_HARD_FLOAT, because an FPU is required to do the comparison.
4577 ;; - conditional moves between FPRs based on integer comparisons
4578 ;;   require TARGET_HAS_FPRS.
4580 (define_expand "movqicc"
4581   [(set (match_operand:QI 0 "integer_register_operand" "")
4582         (if_then_else:QI (match_operand 1 "" "")
4583                          (match_operand:QI 2 "gpr_or_int_operand" "")
4584                          (match_operand:QI 3 "gpr_or_int_operand" "")))]
4585   "TARGET_COND_MOVE"
4586   "
4588   if (!frv_emit_cond_move (operands[0], operands[1], operands[2], operands[3]))
4589     FAIL;
4591   DONE;
4594 (define_insn "*movqicc_internal1_signed"
4595   [(set (match_operand:QI 0 "integer_register_operand" "=d,d,d")
4596         (if_then_else:QI (match_operator:CC 1 "signed_relational_operator"
4597                              [(match_operand:CC 2 "icc_operand" "t,t,t")
4598                               (const_int 0)])
4599                          (match_operand:QI 3 "reg_or_0_operand" "0,dO,dO")
4600                          (match_operand:QI 4 "reg_or_0_operand" "dO,0,dO")))
4601    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v"))]
4602   ""
4603   "#"
4604   [(set_attr "length" "8,8,12")
4605    (set_attr "type" "multi")])
4607 (define_insn "*movqicc_internal1_unsigned"
4608   [(set (match_operand:QI 0 "integer_register_operand" "=d,d,d")
4609         (if_then_else:QI (match_operator:CC_UNS 1 "unsigned_relational_operator"
4610                              [(match_operand:CC_UNS 2 "icc_operand" "t,t,t")
4611                               (const_int 0)])
4612                          (match_operand:QI 3 "reg_or_0_operand" "0,dO,dO")
4613                          (match_operand:QI 4 "reg_or_0_operand" "dO,0,dO")))
4614    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v"))]
4615   ""
4616   "#"
4617   [(set_attr "length" "8,8,12")
4618    (set_attr "type" "multi")])
4620 (define_insn "*movqicc_internal1_float"
4621   [(set (match_operand:QI 0 "integer_register_operand" "=d,d,d")
4622         (if_then_else:QI (match_operator:CC_FP 1 "float_relational_operator"
4623                              [(match_operand:CC_FP 2 "fcc_operand" "u,u,u")
4624                               (const_int 0)])
4625                          (match_operand:QI 3 "reg_or_0_operand" "0,dO,dO")
4626                          (match_operand:QI 4 "reg_or_0_operand" "dO,0,dO")))
4627    (clobber (match_operand:CC_CCR 5 "fcr_operand" "=w,w,w"))]
4628   "TARGET_HARD_FLOAT"
4629   "#"
4630   [(set_attr "length" "8,8,12")
4631    (set_attr "type" "multi")])
4633 (define_insn "*movqicc_internal2_signed"
4634   [(set (match_operand:QI 0 "integer_register_operand" "=d,d,d,d,d")
4635         (if_then_else:QI (match_operator:CC 1 "signed_relational_operator"
4636                              [(match_operand:CC 2 "icc_operand" "t,t,t,t,t")
4637                               (const_int 0)])
4638                          (match_operand:QI 3 "const_int_operand" "O,O,L,n,n")
4639                          (match_operand:QI 4 "const_int_operand" "L,n,O,O,n")))
4640    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v,v,v"))]
4641   "(INTVAL (operands[3]) == 0
4642     || INTVAL (operands[4]) == 0
4643     || (IN_RANGE_P (INTVAL (operands[3]), -2048, 2047)
4644         && IN_RANGE_P (INTVAL (operands[4]) - INTVAL (operands[3]), -2048, 2047)))"
4645   "#"
4646   [(set_attr "length" "8,12,8,12,12")
4647    (set_attr "type" "multi")])
4649 (define_insn "*movqicc_internal2_unsigned"
4650   [(set (match_operand:QI 0 "integer_register_operand" "=d,d,d,d,d")
4651         (if_then_else:QI (match_operator:CC_UNS 1 "unsigned_relational_operator"
4652                              [(match_operand:CC_UNS 2 "icc_operand" "t,t,t,t,t")
4653                               (const_int 0)])
4654                          (match_operand:QI 3 "const_int_operand" "O,O,L,n,n")
4655                          (match_operand:QI 4 "const_int_operand" "L,n,O,O,n")))
4656    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v,v,v"))]
4657   "(INTVAL (operands[3]) == 0
4658     || INTVAL (operands[4]) == 0
4659     || (IN_RANGE_P (INTVAL (operands[3]), -2048, 2047)
4660         && IN_RANGE_P (INTVAL (operands[4]) - INTVAL (operands[3]), -2048, 2047)))"
4661   "#"
4662   [(set_attr "length" "8,12,8,12,12")
4663    (set_attr "type" "multi")])
4665 (define_insn "*movqicc_internal2_float"
4666   [(set (match_operand:QI 0 "integer_register_operand" "=d,d,d,d,d")
4667         (if_then_else:QI (match_operator:CC_FP 1 "float_relational_operator"
4668                              [(match_operand:CC_FP 2 "fcc_operand" "u,u,u,u,u")
4669                               (const_int 0)])
4670                          (match_operand:QI 3 "const_int_operand" "O,O,L,n,n")
4671                          (match_operand:QI 4 "const_int_operand" "L,n,O,O,n")))
4672    (clobber (match_operand:CC_CCR 5 "fcr_operand" "=w,w,w,w,w"))]
4673   "TARGET_HARD_FLOAT
4674    && (INTVAL (operands[3]) == 0
4675        || INTVAL (operands[4]) == 0
4676        || (IN_RANGE_P (INTVAL (operands[3]), -2048, 2047)
4677            && IN_RANGE_P (INTVAL (operands[4]) - INTVAL (operands[3]), -2048, 2047)))"
4678   "#"
4679   [(set_attr "length" "8,12,8,12,12")
4680    (set_attr "type" "multi")])
4682 (define_split
4683   [(set (match_operand:QI 0 "integer_register_operand" "")
4684         (if_then_else:QI (match_operator 1 "relational_operator"
4685                              [(match_operand 2 "cc_operand" "")
4686                               (const_int 0)])
4687                          (match_operand:QI 3 "gpr_or_int_operand" "")
4688                          (match_operand:QI 4 "gpr_or_int_operand" "")))
4689    (clobber (match_operand:CC_CCR 5 "cr_operand" ""))]
4690   "reload_completed"
4691   [(match_dup 6)]
4692   "operands[6] = frv_split_cond_move (operands);")
4694 (define_expand "movhicc"
4695   [(set (match_operand:HI 0 "integer_register_operand" "")
4696         (if_then_else:HI (match_operand 1 "" "")
4697                          (match_operand:HI 2 "gpr_or_int_operand" "")
4698                          (match_operand:HI 3 "gpr_or_int_operand" "")))]
4699   "TARGET_COND_MOVE"
4700   "
4702   if (!frv_emit_cond_move (operands[0], operands[1], operands[2], operands[3]))
4703     FAIL;
4705   DONE;
4708 (define_insn "*movhicc_internal1_signed"
4709   [(set (match_operand:HI 0 "integer_register_operand" "=d,d,d")
4710         (if_then_else:HI (match_operator:CC 1 "signed_relational_operator"
4711                              [(match_operand:CC 2 "icc_operand" "t,t,t")
4712                               (const_int 0)])
4713                          (match_operand:HI 3 "reg_or_0_operand" "0,dO,dO")
4714                          (match_operand:HI 4 "reg_or_0_operand" "dO,0,dO")))
4715    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v"))]
4716   ""
4717   "#"
4718   [(set_attr "length" "8,8,12")
4719    (set_attr "type" "multi")])
4721 (define_insn "*movhicc_internal1_unsigned"
4722   [(set (match_operand:HI 0 "integer_register_operand" "=d,d,d")
4723         (if_then_else:HI (match_operator:CC_UNS 1 "unsigned_relational_operator"
4724                              [(match_operand:CC_UNS 2 "icc_operand" "t,t,t")
4725                               (const_int 0)])
4726                          (match_operand:HI 3 "reg_or_0_operand" "0,dO,dO")
4727                          (match_operand:HI 4 "reg_or_0_operand" "dO,0,dO")))
4728    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v"))]
4729   ""
4730   "#"
4731   [(set_attr "length" "8,8,12")
4732    (set_attr "type" "multi")])
4734 (define_insn "*movhicc_internal1_float"
4735   [(set (match_operand:HI 0 "integer_register_operand" "=d,d,d")
4736         (if_then_else:HI (match_operator:CC_FP 1 "float_relational_operator"
4737                              [(match_operand:CC_FP 2 "fcc_operand" "u,u,u")
4738                               (const_int 0)])
4739                          (match_operand:HI 3 "reg_or_0_operand" "0,dO,dO")
4740                          (match_operand:HI 4 "reg_or_0_operand" "dO,0,dO")))
4741    (clobber (match_operand:CC_CCR 5 "fcr_operand" "=w,w,w"))]
4742   "TARGET_HARD_FLOAT"
4743   "#"
4744   [(set_attr "length" "8,8,12")
4745    (set_attr "type" "multi")])
4747 (define_insn "*movhicc_internal2_signed"
4748   [(set (match_operand:HI 0 "integer_register_operand" "=d,d,d,d,d")
4749         (if_then_else:HI (match_operator:CC 1 "signed_relational_operator"
4750                              [(match_operand:CC 2 "icc_operand" "t,t,t,t,t")
4751                               (const_int 0)])
4752                          (match_operand:HI 3 "const_int_operand" "O,O,L,n,n")
4753                          (match_operand:HI 4 "const_int_operand" "L,n,O,O,n")))
4754    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v,v,v"))]
4755   "(INTVAL (operands[3]) == 0
4756     || INTVAL (operands[4]) == 0
4757     || (IN_RANGE_P (INTVAL (operands[3]), -2048, 2047)
4758         && IN_RANGE_P (INTVAL (operands[4]) - INTVAL (operands[3]), -2048, 2047)))"
4759   "#"
4760   [(set_attr "length" "8,12,8,12,12")
4761    (set_attr "type" "multi")])
4763 (define_insn "*movhicc_internal2_unsigned"
4764   [(set (match_operand:HI 0 "integer_register_operand" "=d,d,d,d,d")
4765         (if_then_else:HI (match_operator:CC_UNS 1 "unsigned_relational_operator"
4766                              [(match_operand:CC_UNS 2 "icc_operand" "t,t,t,t,t")
4767                               (const_int 0)])
4768                          (match_operand:HI 3 "const_int_operand" "O,O,L,n,n")
4769                          (match_operand:HI 4 "const_int_operand" "L,n,O,O,n")))
4770    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v,v,v"))]
4771   "(INTVAL (operands[3]) == 0
4772     || INTVAL (operands[4]) == 0
4773     || (IN_RANGE_P (INTVAL (operands[3]), -2048, 2047)
4774         && IN_RANGE_P (INTVAL (operands[4]) - INTVAL (operands[3]), -2048, 2047)))"
4775   "#"
4776   [(set_attr "length" "8,12,8,12,12")
4777    (set_attr "type" "multi")])
4779 (define_insn "*movhicc_internal2_float"
4780   [(set (match_operand:HI 0 "integer_register_operand" "=d,d,d,d,d")
4781         (if_then_else:HI (match_operator:CC_FP 1 "float_relational_operator"
4782                              [(match_operand:CC_FP 2 "fcc_operand" "u,u,u,u,u")
4783                               (const_int 0)])
4784                          (match_operand:HI 3 "const_int_operand" "O,O,L,n,n")
4785                          (match_operand:HI 4 "const_int_operand" "L,n,O,O,n")))
4786    (clobber (match_operand:CC_CCR 5 "fcr_operand" "=w,w,w,w,w"))]
4787   "TARGET_HARD_FLOAT
4788    && (INTVAL (operands[3]) == 0
4789        || INTVAL (operands[4]) == 0
4790        || (IN_RANGE_P (INTVAL (operands[3]), -2048, 2047)
4791            && IN_RANGE_P (INTVAL (operands[4]) - INTVAL (operands[3]), -2048, 2047)))"
4792   "#"
4793   [(set_attr "length" "8,12,8,12,12")
4794    (set_attr "type" "multi")])
4796 (define_split
4797   [(set (match_operand:HI 0 "integer_register_operand" "")
4798         (if_then_else:HI (match_operator 1 "relational_operator"
4799                              [(match_operand 2 "cc_operand" "")
4800                               (const_int 0)])
4801                          (match_operand:HI 3 "gpr_or_int_operand" "")
4802                          (match_operand:HI 4 "gpr_or_int_operand" "")))
4803    (clobber (match_operand:CC_CCR 5 "cr_operand" ""))]
4804   "reload_completed"
4805   [(match_dup 6)]
4806   "operands[6] = frv_split_cond_move (operands);")
4808 (define_expand "movsicc"
4809   [(set (match_operand:SI 0 "integer_register_operand" "")
4810         (if_then_else:SI (match_operand 1 "" "")
4811                          (match_operand:SI 2 "gpr_or_int_operand" "")
4812                          (match_operand:SI 3 "gpr_or_int_operand" "")))]
4813   "TARGET_COND_MOVE"
4814   "
4816   if (!frv_emit_cond_move (operands[0], operands[1], operands[2], operands[3]))
4817     FAIL;
4819   DONE;
4822 (define_insn "*movsicc_internal1_signed"
4823   [(set (match_operand:SI 0 "integer_register_operand" "=d,d,d")
4824         (if_then_else:SI (match_operator:CC 1 "signed_relational_operator"
4825                              [(match_operand:CC 2 "icc_operand" "t,t,t")
4826                               (const_int 0)])
4827                          (match_operand:SI 3 "reg_or_0_operand" "0,dO,dO")
4828                          (match_operand:SI 4 "reg_or_0_operand" "dO,0,dO")))
4829    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v"))]
4830   ""
4831   "#"
4832   [(set_attr "length" "8,8,12")
4833    (set_attr "type" "multi")])
4835 (define_insn "*movsicc_internal1_unsigned"
4836   [(set (match_operand:SI 0 "integer_register_operand" "=d,d,d")
4837         (if_then_else:SI (match_operator:CC_UNS 1 "unsigned_relational_operator"
4838                              [(match_operand:CC_UNS 2 "icc_operand" "t,t,t")
4839                               (const_int 0)])
4840                          (match_operand:SI 3 "reg_or_0_operand" "0,dO,dO")
4841                          (match_operand:SI 4 "reg_or_0_operand" "dO,0,dO")))
4842    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v"))]
4843   ""
4844   "#"
4845   [(set_attr "length" "8,8,12")
4846    (set_attr "type" "multi")])
4848 (define_insn "*movsicc_internal1_float"
4849   [(set (match_operand:SI 0 "integer_register_operand" "=d,d,d")
4850         (if_then_else:SI (match_operator:CC_FP 1 "float_relational_operator"
4851                              [(match_operand:CC_FP 2 "fcc_operand" "u,u,u")
4852                               (const_int 0)])
4853                          (match_operand:SI 3 "reg_or_0_operand" "0,dO,dO")
4854                          (match_operand:SI 4 "reg_or_0_operand" "dO,0,dO")))
4855    (clobber (match_operand:CC_CCR 5 "fcr_operand" "=w,w,w"))]
4856   "TARGET_HARD_FLOAT"
4857   "#"
4858   [(set_attr "length" "8,8,12")
4859    (set_attr "type" "multi")])
4861 (define_insn "*movsicc_internal2_signed"
4862   [(set (match_operand:SI 0 "integer_register_operand" "=d,d,d,d,d")
4863         (if_then_else:SI (match_operator:CC 1 "signed_relational_operator"
4864                              [(match_operand:CC 2 "icc_operand" "t,t,t,t,t")
4865                               (const_int 0)])
4866                          (match_operand:SI 3 "const_int_operand" "O,O,L,n,n")
4867                          (match_operand:SI 4 "const_int_operand" "L,n,O,O,n")))
4868    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v,v,v"))]
4869   "(INTVAL (operands[3]) == 0
4870     || INTVAL (operands[4]) == 0
4871     || (IN_RANGE_P (INTVAL (operands[3]), -2048, 2047)
4872         && IN_RANGE_P (INTVAL (operands[4]) - INTVAL (operands[3]), -2048, 2047)))"
4873   "#"
4874   [(set_attr "length" "8,12,8,12,12")
4875    (set_attr "type" "multi")])
4877 (define_insn "*movsicc_internal2_unsigned"
4878   [(set (match_operand:SI 0 "integer_register_operand" "=d,d,d,d,d")
4879         (if_then_else:SI (match_operator:CC_UNS 1 "unsigned_relational_operator"
4880                              [(match_operand:CC_UNS 2 "icc_operand" "t,t,t,t,t")
4881                               (const_int 0)])
4882                          (match_operand:SI 3 "const_int_operand" "O,O,L,n,n")
4883                          (match_operand:SI 4 "const_int_operand" "L,n,O,O,n")))
4884    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v,v,v"))]
4885   "(INTVAL (operands[3]) == 0
4886     || INTVAL (operands[4]) == 0
4887     || (IN_RANGE_P (INTVAL (operands[3]), -2048, 2047)
4888         && IN_RANGE_P (INTVAL (operands[4]) - INTVAL (operands[3]), -2048, 2047)))"
4889   "#"
4890   [(set_attr "length" "8,12,8,12,12")
4891    (set_attr "type" "multi")])
4893 (define_insn "*movsicc_internal2_float"
4894   [(set (match_operand:SI 0 "integer_register_operand" "=d,d,d,d,d")
4895         (if_then_else:SI (match_operator:CC_FP 1 "float_relational_operator"
4896                              [(match_operand:CC_FP 2 "fcc_operand" "u,u,u,u,u")
4897                               (const_int 0)])
4898                          (match_operand:SI 3 "const_int_operand" "O,O,L,n,n")
4899                          (match_operand:SI 4 "const_int_operand" "L,n,O,O,n")))
4900    (clobber (match_operand:CC_CCR 5 "fcr_operand" "=w,w,w,w,w"))]
4901   "TARGET_HARD_FLOAT
4902    && (INTVAL (operands[3]) == 0
4903        || INTVAL (operands[4]) == 0
4904        || (IN_RANGE_P (INTVAL (operands[3]), -2048, 2047)
4905            && IN_RANGE_P (INTVAL (operands[4]) - INTVAL (operands[3]), -2048, 2047)))"
4906   "#"
4907   [(set_attr "length" "8,12,8,12,12")
4908    (set_attr "type" "multi")])
4910 (define_split
4911   [(set (match_operand:SI 0 "integer_register_operand" "")
4912         (if_then_else:SI (match_operator 1 "relational_operator"
4913                              [(match_operand 2 "cc_operand" "")
4914                               (const_int 0)])
4915                          (match_operand:SI 3 "gpr_or_int_operand" "")
4916                          (match_operand:SI 4 "gpr_or_int_operand" "")))
4917    (clobber (match_operand:CC_CCR 5 "cr_operand" ""))]
4918   "reload_completed"
4919   [(match_dup 6)]
4920   "operands[6] = frv_split_cond_move (operands);")
4922 (define_expand "movsfcc"
4923   [(set (match_operand:SF 0 "register_operand" "")
4924         (if_then_else:SF (match_operand 1 "" "")
4925                          (match_operand:SF 2 "register_operand" "")
4926                          (match_operand:SF 3 "register_operand" "")))]
4927   "TARGET_COND_MOVE"
4928   "
4930   if (!frv_emit_cond_move (operands[0], operands[1], operands[2], operands[3]))
4931     FAIL;
4933   DONE;
4936 (define_insn "*movsfcc_has_fprs_signed"
4937   [(set (match_operand:SF 0 "register_operand" "=f,f,f,?f,?f,?d")
4938         (if_then_else:SF (match_operator:CC 1 "signed_relational_operator"
4939                              [(match_operand:CC 2 "icc_operand" "t,t,t,t,t,t")
4940                               (const_int 0)])
4941                          (match_operand:SF 3 "register_operand" "0,f,f,f,d,fd")
4942                          (match_operand:SF 4 "register_operand" "f,0,f,d,fd,fd")))
4943    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v,v,v,v"))]
4944   "TARGET_HAS_FPRS"
4945   "#"
4946   [(set_attr "length" "8,8,12,12,12,12")
4947    (set_attr "type" "multi")])
4949 (define_insn "*movsfcc_has_fprs_unsigned"
4950   [(set (match_operand:SF 0 "register_operand" "=f,f,f,?f,?f,?d")
4951         (if_then_else:SF (match_operator:CC_UNS 1 "unsigned_relational_operator"
4952                              [(match_operand:CC_UNS 2 "icc_operand" "t,t,t,t,t,t")
4953                               (const_int 0)])
4954                          (match_operand:SF 3 "register_operand" "0,f,f,f,d,fd")
4955                          (match_operand:SF 4 "register_operand" "f,0,f,d,fd,fd")))
4956    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v,v,v,v"))]
4957   "TARGET_HAS_FPRS"
4958   "#"
4959   [(set_attr "length" "8,8,12,12,12,12")
4960    (set_attr "type" "multi")])
4962 (define_insn "*movsfcc_hardfloat_float"
4963   [(set (match_operand:SF 0 "register_operand" "=f,f,f,?f,?f,?d")
4964         (if_then_else:SF (match_operator:CC_FP 1 "float_relational_operator"
4965                              [(match_operand:CC_FP 2 "fcc_operand" "u,u,u,u,u,u")
4966                               (const_int 0)])
4967                          (match_operand:SF 3 "register_operand" "0,f,f,f,d,fd")
4968                          (match_operand:SF 4 "register_operand" "f,0,f,d,fd,fd")))
4969    (clobber (match_operand:CC_CCR 5 "fcr_operand" "=w,w,w,w,w,w"))]
4970   "TARGET_HARD_FLOAT"
4971   "#"
4972   [(set_attr "length" "8,8,12,12,12,12")
4973    (set_attr "type" "multi")])
4975 (define_insn "*movsfcc_no_fprs_signed"
4976   [(set (match_operand:SF 0 "integer_register_operand" "=d,d,d")
4977         (if_then_else:SF (match_operator:CC 1 "signed_relational_operator"
4978                              [(match_operand:CC 2 "icc_operand" "t,t,t")
4979                               (const_int 0)])
4980                          (match_operand:SF 3 "integer_register_operand" "0,d,d")
4981                          (match_operand:SF 4 "integer_register_operand" "d,0,d")))
4982    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v"))]
4983   "! TARGET_HAS_FPRS"
4984   "#"
4985   [(set_attr "length" "8,8,12")
4986    (set_attr "type" "multi")])
4988 (define_insn "*movsfcc_no_fprs_unsigned"
4989   [(set (match_operand:SF 0 "integer_register_operand" "=d,d,d")
4990         (if_then_else:SF (match_operator:CC_UNS 1 "unsigned_relational_operator"
4991                              [(match_operand:CC_UNS 2 "icc_operand" "t,t,t")
4992                               (const_int 0)])
4993                          (match_operand:SF 3 "integer_register_operand" "0,d,d")
4994                          (match_operand:SF 4 "integer_register_operand" "d,0,d")))
4995    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v"))]
4996   "! TARGET_HAS_FPRS"
4997   "#"
4998   [(set_attr "length" "8,8,12")
4999    (set_attr "type" "multi")])
5001 (define_split
5002   [(set (match_operand:SF 0 "register_operand" "")
5003         (if_then_else:SF (match_operator 1 "relational_operator"
5004                              [(match_operand 2 "cc_operand" "")
5005                               (const_int 0)])
5006                          (match_operand:SF 3 "register_operand" "")
5007                          (match_operand:SF 4 "register_operand" "")))
5008    (clobber (match_operand:CC_CCR 5 "cr_operand" ""))]
5009   "reload_completed"
5010   [(match_dup 6)]
5011   "operands[6] = frv_split_cond_move (operands);")
5014 ;; ::::::::::::::::::::
5015 ;; ::
5016 ;; :: Minimum, maximum, and integer absolute value
5017 ;; ::
5018 ;; ::::::::::::::::::::
5020 ;; These 'instructions' are provided to give the compiler a slightly better
5021 ;; nudge at register allocation, then it would if it constructed the
5022 ;; instructions from basic building blocks (since it indicates it prefers one
5023 ;; of the operands to be the same as the destination.  It also helps the
5024 ;; earlier passes of the compiler, by not breaking things into small basic
5025 ;; blocks.
5027 (define_expand "abssi2"
5028   [(parallel [(set (match_operand:SI 0 "integer_register_operand" "")
5029                    (abs:SI (match_operand:SI 1 "integer_register_operand" "")))
5030               (clobber (match_dup 2))
5031               (clobber (match_dup 3))])]
5032   "TARGET_COND_MOVE"
5033   "
5035   operands[2] = gen_reg_rtx (CCmode);
5036   operands[3] = gen_reg_rtx (CC_CCRmode);
5039 (define_insn_and_split "*abssi2_internal"
5040   [(set (match_operand:SI 0 "integer_register_operand" "=d,d")
5041         (abs:SI (match_operand:SI 1 "integer_register_operand" "0,d")))
5042    (clobber (match_operand:CC 2 "icc_operand" "=t,t"))
5043    (clobber (match_operand:CC_CCR 3 "icr_operand" "=v,v"))]
5044   "TARGET_COND_MOVE"
5045   "#"
5046   "reload_completed"
5047   [(match_dup 4)]
5048   "operands[4] = frv_split_abs (operands);"
5049   [(set_attr "length" "12,16")
5050    (set_attr "type" "multi")])
5052 (define_expand "sminsi3"
5053   [(parallel [(set (match_operand:SI 0 "integer_register_operand" "")
5054                    (smin:SI (match_operand:SI 1 "integer_register_operand" "")
5055                             (match_operand:SI 2 "gpr_or_int10_operand" "")))
5056               (clobber (match_dup 3))
5057               (clobber (match_dup 4))])]
5058   "TARGET_COND_MOVE"
5059   "
5061   operands[3] = gen_reg_rtx (CCmode);
5062   operands[4] = gen_reg_rtx (CC_CCRmode);
5065 (define_expand "smaxsi3"
5066   [(parallel [(set (match_operand:SI 0 "integer_register_operand" "")
5067                    (smax:SI (match_operand:SI 1 "integer_register_operand" "")
5068                             (match_operand:SI 2 "gpr_or_int10_operand" "")))
5069               (clobber (match_dup 3))
5070               (clobber (match_dup 4))])]
5071   "TARGET_COND_MOVE"
5072   "
5074   operands[3] = gen_reg_rtx (CCmode);
5075   operands[4] = gen_reg_rtx (CC_CCRmode);
5078 (define_insn_and_split "*minmax_si_signed"
5079   [(set (match_operand:SI 0 "integer_register_operand" "=d,d,&d")
5080         (match_operator:SI 1 "minmax_operator"
5081                            [(match_operand:SI 2 "integer_register_operand" "%0,dO,d")
5082                             (match_operand:SI 3 "gpr_or_int10_operand" "dO,0,dJ")]))
5083    (clobber (match_operand:CC 4 "icc_operand" "=t,t,t"))
5084    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v"))]
5085   "TARGET_COND_MOVE"
5086   "#"
5087   "reload_completed"
5088   [(match_dup 6)]
5089   "operands[6] = frv_split_minmax (operands);"
5090   [(set_attr "length" "12,12,16")
5091    (set_attr "type" "multi")])
5093 (define_expand "uminsi3"
5094   [(parallel [(set (match_operand:SI 0 "integer_register_operand" "")
5095                    (umin:SI (match_operand:SI 1 "integer_register_operand" "")
5096                             (match_operand:SI 2 "gpr_or_int10_operand" "")))
5097               (clobber (match_dup 3))
5098               (clobber (match_dup 4))])]
5099   "TARGET_COND_MOVE"
5100   "
5102   operands[3] = gen_reg_rtx (CC_UNSmode);
5103   operands[4] = gen_reg_rtx (CC_CCRmode);
5106 (define_expand "umaxsi3"
5107   [(parallel [(set (match_operand:SI 0 "integer_register_operand" "")
5108                    (umax:SI (match_operand:SI 1 "integer_register_operand" "")
5109                             (match_operand:SI 2 "gpr_or_int10_operand" "")))
5110               (clobber (match_dup 3))
5111               (clobber (match_dup 4))])]
5112   "TARGET_COND_MOVE"
5113   "
5115   operands[3] = gen_reg_rtx (CC_UNSmode);
5116   operands[4] = gen_reg_rtx (CC_CCRmode);
5119 (define_insn_and_split "*minmax_si_unsigned"
5120   [(set (match_operand:SI 0 "integer_register_operand" "=d,d,&d")
5121         (match_operator:SI 1 "minmax_operator"
5122                            [(match_operand:SI 2 "integer_register_operand" "%0,dO,d")
5123                             (match_operand:SI 3 "gpr_or_int10_operand" "dO,0,dJ")]))
5124    (clobber (match_operand:CC_UNS 4 "icc_operand" "=t,t,t"))
5125    (clobber (match_operand:CC_CCR 5 "icr_operand" "=v,v,v"))]
5126   "TARGET_COND_MOVE"
5127   "#"
5128   "reload_completed"
5129   [(match_dup 6)]
5130   "operands[6] = frv_split_minmax (operands);"
5131   [(set_attr "length" "12,12,16")
5132    (set_attr "type" "multi")])
5134 (define_expand "sminsf3"
5135   [(parallel [(set (match_operand:SF 0 "fpr_operand" "")
5136                    (smin:SF (match_operand:SF 1 "fpr_operand" "")
5137                             (match_operand:SF 2 "fpr_operand" "")))
5138               (clobber (match_dup 3))
5139               (clobber (match_dup 4))])]
5140   "TARGET_COND_MOVE && TARGET_HARD_FLOAT"
5141   "
5143   operands[3] = gen_reg_rtx (CC_FPmode);
5144   operands[4] = gen_reg_rtx (CC_CCRmode);
5147 (define_expand "smaxsf3"
5148   [(parallel [(set (match_operand:SF 0 "fpr_operand" "")
5149                    (smax:SF (match_operand:SF 1 "fpr_operand" "")
5150                             (match_operand:SF 2 "fpr_operand" "")))
5151               (clobber (match_dup 3))
5152               (clobber (match_dup 4))])]
5153   "TARGET_COND_MOVE && TARGET_HARD_FLOAT"
5154   "
5156   operands[3] = gen_reg_rtx (CC_FPmode);
5157   operands[4] = gen_reg_rtx (CC_CCRmode);
5160 (define_insn_and_split "*minmax_sf"
5161   [(set (match_operand:SF 0 "fpr_operand" "=f,f,f")
5162         (match_operator:SF 1 "minmax_operator"
5163                            [(match_operand:SF 2 "fpr_operand" "%0,f,f")
5164                             (match_operand:SF 3 "fpr_operand" "f,0,f")]))
5165    (clobber (match_operand:CC_FP 4 "fcc_operand" "=u,u,u"))
5166    (clobber (match_operand:CC_CCR 5 "fcr_operand" "=w,w,w"))]
5167   "TARGET_COND_MOVE && TARGET_HARD_FLOAT"
5168   "#"
5169   "reload_completed"
5170   [(match_dup 6)]
5171   "operands[6] = frv_split_minmax (operands);"
5172   [(set_attr "length" "12,12,16")
5173    (set_attr "type" "multi")])
5175 (define_expand "smindf3"
5176   [(parallel [(set (match_operand:DF 0 "fpr_operand" "")
5177                    (smin:DF (match_operand:DF 1 "fpr_operand" "")
5178                             (match_operand:DF 2 "fpr_operand" "")))
5179               (clobber (match_dup 3))
5180               (clobber (match_dup 4))])]
5181   "TARGET_COND_MOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE"
5182   "
5184   operands[3] = gen_reg_rtx (CC_FPmode);
5185   operands[4] = gen_reg_rtx (CC_CCRmode);
5188 (define_expand "smaxdf3"
5189   [(parallel [(set (match_operand:DF 0 "fpr_operand" "")
5190                    (smax:DF (match_operand:DF 1 "fpr_operand" "")
5191                             (match_operand:DF 2 "fpr_operand" "")))
5192               (clobber (match_dup 3))
5193               (clobber (match_dup 4))])]
5194   "TARGET_COND_MOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE"
5195   "
5197   operands[3] = gen_reg_rtx (CC_FPmode);
5198   operands[4] = gen_reg_rtx (CC_CCRmode);
5201 (define_insn_and_split "*minmax_df"
5202   [(set (match_operand:DF 0 "fpr_operand" "=f,f,f")
5203         (match_operator:DF 1 "minmax_operator"
5204                            [(match_operand:DF 2 "fpr_operand" "%0,f,f")
5205                             (match_operand:DF 3 "fpr_operand" "f,0,f")]))
5206    (clobber (match_operand:CC_FP 4 "fcc_operand" "=u,u,u"))
5207    (clobber (match_operand:CC_CCR 5 "fcr_operand" "=w,w,w"))]
5208   "TARGET_COND_MOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE"
5209   "#"
5210   "reload_completed"
5211   [(match_dup 6)]
5212   "operands[6] = frv_split_minmax (operands);"
5213   [(set_attr "length" "12,12,16")
5214    (set_attr "type" "multi")])
5217 ;; ::::::::::::::::::::
5218 ;; ::
5219 ;; :: Call and branch instructions
5220 ;; ::
5221 ;; ::::::::::::::::::::
5223 ;; Subroutine call instruction returning no value.  Operand 0 is the function
5224 ;; to call; operand 1 is the number of bytes of arguments pushed (in mode
5225 ;; `SImode', except it is normally a `const_int'); operand 2 is the number of
5226 ;; registers used as operands.
5228 ;; On most machines, operand 2 is not actually stored into the RTL pattern.  It
5229 ;; is supplied for the sake of some RISC machines which need to put this
5230 ;; information into the assembler code; they can put it in the RTL instead of
5231 ;; operand 1.
5233 (define_expand "call"
5234   [(use (match_operand:QI 0 "" ""))
5235    (use (match_operand 1 "" ""))
5236    (use (match_operand 2 "" ""))
5237    (use (match_operand 3 "" ""))]
5238   ""
5239   "
5241   rtx lr = gen_rtx_REG (Pmode, LR_REGNO);
5242   rtx addr;
5244   if (GET_CODE (operands[0]) != MEM)
5245     abort ();
5247   addr = XEXP (operands[0], 0);
5248   if (! call_operand (addr, Pmode))
5249     addr = force_reg (Pmode, addr);
5251   if (! operands[2])
5252     operands[2] = const0_rtx;
5254   emit_call_insn (gen_call_internal (addr, operands[1], operands[2], lr));
5255   DONE;
5258 (define_insn "call_internal"
5259   [(call (mem:QI (match_operand:SI 0 "call_operand" "S,dNOP"))
5260          (match_operand 1 "" ""))
5261    (use (match_operand 2 "" ""))
5262    (clobber (match_operand:SI 3 "lr_operand" "=l,l"))]
5263   ""
5264   "@
5265    call %0
5266    call%i0l %M0"
5267   [(set_attr "length" "4")
5268    (set_attr "type" "call,jumpl")])
5270 ;; Subroutine call instruction returning a value.  Operand 0 is the hard
5271 ;; register in which the value is returned.  There are three more operands, the
5272 ;; same as the three operands of the `call' instruction (but with numbers
5273 ;; increased by one).
5275 ;; Subroutines that return `BLKmode' objects use the `call' insn.
5277 (define_expand "call_value"
5278   [(use (match_operand 0 "" ""))
5279    (use (match_operand:QI 1 "" ""))
5280    (use (match_operand 2 "" ""))
5281    (use (match_operand 3 "" ""))
5282    (use (match_operand 4 "" ""))]
5283   ""
5284   "
5286   rtx lr = gen_rtx_REG (Pmode, LR_REGNO);
5287   rtx addr;
5289   if (GET_CODE (operands[1]) != MEM)
5290     abort ();
5292   addr = XEXP (operands[1], 0);
5293   if (! call_operand (addr, Pmode))
5294     addr = force_reg (Pmode, addr);
5296   if (! operands[3])
5297     operands[3] = const0_rtx;
5299   emit_call_insn (gen_call_value_internal (operands[0], addr, operands[2],
5300                                            operands[3], lr));
5301   DONE;
5304 (define_insn "call_value_internal"
5305   [(set (match_operand 0 "register_operand" "=d,d")
5306         (call (mem:QI (match_operand:SI 1 "call_operand" "S,dNOP"))
5307                       (match_operand 2 "" "")))
5308    (use (match_operand 3 "" ""))
5309    (clobber (match_operand:SI 4 "lr_operand" "=l,l"))]
5310   ""
5311   "@
5312    call %1
5313    call%i1l %M1"
5314   [(set_attr "length" "4")
5315    (set_attr "type" "call,jumpl")])
5317 ;; return instruction generated instead of jmp to epilog
5318 (define_expand "return"
5319   [(parallel [(return)
5320               (use (match_dup 0))
5321               (use (const_int 1))])]
5322   "direct_return_p ()"
5323   "
5325   operands[0] = gen_rtx_REG (Pmode, LR_REGNO);
5328 ;; return instruction generated by the epilogue
5329 (define_expand "epilogue_return"
5330   [(parallel [(return)
5331               (use (match_operand:SI 0 "register_operand" ""))
5332               (use (const_int 0))])]
5333   ""
5334   "")
5336 (define_insn "*return_internal"
5337   [(return)
5338    (use (match_operand:SI 0 "register_operand" "l,d"))
5339    (use (match_operand:SI 1 "immediate_operand" "n,n"))]
5340   ""
5341   "@
5342     ret
5343     jmpl @(%0,%.)"
5344   [(set_attr "length" "4")
5345    (set_attr "type" "jump,jumpl")])
5347 ;; A version of addsi3 for deallocating stack space at the end of the
5348 ;; epilogue.  The addition is done in parallel with an (unspec_volatile),
5349 ;; which represents the clobbering of the deallocated space.
5350 (define_insn "stack_adjust"
5351   [(set (match_operand:SI 0 "register_operand" "=d")
5352         (plus:SI (match_operand:SI 1 "register_operand" "d")
5353                  (match_operand:SI 2 "general_operand" "dNOP")))
5354    (unspec_volatile [(const_int 0)] UNSPEC_STACK_ADJUST)]
5355   ""
5356   "add%I2 %1,%2,%0"
5357   [(set_attr "length" "4")
5358    (set_attr "type" "int")])
5360 ;; Normal unconditional jump
5362 ;; Use the "call" instruction for long branches, but prefer to use "bra" for
5363 ;; short ones since it does not force us to save the link register.
5365 ;; This define_insn uses the branch-shortening code to decide which
5366 ;; instruction it emits.  Since the main branch-shortening interface is
5367 ;; through get_attr_length(), the two alternatives must be given different
5368 ;; lengths.  Here we pretend that the far jump is 8 rather than 4 bytes
5369 ;; long, though both alternatives are really the same size.
5370 (define_insn "jump"
5371   [(set (pc) (label_ref (match_operand 0 "" "")))]
5372   ""
5373   "*
5375   if (get_attr_length (insn) == 4)
5376     return \"bra %l0\";
5377   else
5378     return \"call %l0\";
5380   [(set (attr "length")
5381         (if_then_else
5382             (and (ge (minus (match_dup 0) (pc)) (const_int -32768))
5383                  (le (minus (match_dup 0) (pc)) (const_int 32764)))
5384             (const_int 4)
5385             (const_int 8)))
5386    (set (attr "far_jump")
5387         (if_then_else
5388             (eq_attr "length" "4")
5389             (const_string "no")
5390             (const_string "yes")))
5391    (set (attr "type")
5392         (if_then_else
5393             (eq_attr "length" "4")
5394             (const_string "jump")
5395             (const_string "call")))])
5397 ;; Indirect jump through a register
5398 (define_insn "indirect_jump"
5399   [(set (pc) (match_operand:SI 0 "register_operand" "d,l"))]
5400   ""
5401   "@
5402    jmpl @(%0,%.)
5403    bralr"
5404   [(set_attr "length" "4")
5405    (set_attr "type" "jumpl,branch")])
5407 ;; Instruction to jump to a variable address.  This is a low-level capability
5408 ;; which can be used to implement a dispatch table when there is no `casesi'
5409 ;; pattern.  Either the 'casesi' pattern or the 'tablejump' pattern, or both,
5410 ;; MUST be present in this file.
5412 ;; This pattern requires two operands: the address or offset, and a label which
5413 ;; should immediately precede the jump table.  If the macro
5414 ;; `CASE_VECTOR_PC_RELATIVE' is defined then the first operand is an offset
5415 ;; which counts from the address of the table; otherwise, it is an absolute
5416 ;; address to jump to.  In either case, the first operand has mode `Pmode'.
5418 ;; The `tablejump' insn is always the last insn before the jump table it uses.
5419 ;; Its assembler code normally has no need to use the second operand, but you
5420 ;; should incorporate it in the RTL pattern so that the jump optimizer will not
5421 ;; delete the table as unreachable code.
5423 (define_expand "tablejump"
5424   [(parallel [(set (pc) (match_operand:SI 0 "address_operand" "p"))
5425               (use (label_ref (match_operand 1 "" "")))])]
5426   "!flag_pic"
5427   "")
5429 (define_insn "tablejump_insn"
5430   [(set (pc) (match_operand:SI 0 "address_operand" "p"))
5431    (use (label_ref (match_operand 1 "" "")))]
5432   ""
5433   "jmp%I0l %M0"
5434   [(set_attr "length" "4")
5435    (set_attr "type" "jumpl")])
5437 ;; Implement switch statements when generating PIC code.  Switches are
5438 ;; implemented by `tablejump' when not using -fpic.
5440 ;; Emit code here to do the range checking and make the index zero based.
5441 ;; operand 0 is the index
5442 ;; operand 1 is the lower bound
5443 ;; operand 2 is the range of indices (highest - lowest + 1)
5444 ;; operand 3 is the label that precedes the table itself
5445 ;; operand 4 is the fall through label
5447 (define_expand "casesi"
5448   [(use (match_operand:SI 0 "integer_register_operand" ""))
5449    (use (match_operand:SI 1 "const_int_operand" ""))
5450    (use (match_operand:SI 2 "const_int_operand" ""))
5451    (use (match_operand 3 "" ""))
5452    (use (match_operand 4 "" ""))]
5453   "flag_pic"
5454   "
5456   rtx indx;
5457   rtx scale;
5458   rtx low = operands[1];
5459   rtx range = operands[2];
5460   rtx table = operands[3];
5461   rtx treg;
5462   rtx fail = operands[4];
5463   rtx mem;
5464   rtx reg2;
5465   rtx reg3;
5467   if (GET_CODE (operands[1]) != CONST_INT)
5468     abort ();
5470   if (GET_CODE (operands[2]) != CONST_INT)
5471     abort ();
5473   /* If we can't generate an immediate instruction, promote to register.  */
5474   if (! IN_RANGE_P (INTVAL (range), -2048, 2047))
5475     range = force_reg (SImode, range);
5477   /* If low bound is 0, we don't have to subtract it.  */
5478   if (INTVAL (operands[1]) == 0)
5479     indx = operands[0];
5480   else
5481     {
5482       indx = gen_reg_rtx (SImode);
5483       if (IN_RANGE_P (INTVAL (low), -2047, 2048))
5484         emit_insn (gen_addsi3 (indx, operands[0], GEN_INT (- INTVAL (low))));
5485       else
5486         emit_insn (gen_subsi3 (indx, operands[0], force_reg (SImode, low)));
5487     }
5489   /* Do an unsigned comparison (in the proper mode) between the index
5490      expression and the value which represents the length of the range.
5491      Since we just finished subtracting the lower bound of the range
5492      from the index expression, this comparison allows us to simultaneously
5493      check that the original index expression value is both greater than
5494      or equal to the minimum value of the range and less than or equal to
5495      the maximum value of the range.  */
5497   emit_cmp_and_jump_insns (indx, range, GTU, NULL_RTX, SImode, 1, fail);
5499   /* Move the table address to a register.  */
5500   treg = gen_reg_rtx (Pmode);
5501   emit_insn (gen_movsi (treg, gen_rtx_LABEL_REF (VOIDmode, table)));
5503   /* Scale index-low by wordsize.  */
5504   scale = gen_reg_rtx (SImode);
5505   emit_insn (gen_ashlsi3 (scale, indx, GEN_INT (2)));
5507   /* Load the address, add the start of the table back in,
5508      and jump to it.  */
5509   mem = gen_rtx_MEM (SImode, gen_rtx_PLUS (Pmode, scale, treg));
5510   reg2 = gen_reg_rtx (SImode);
5511   reg3 = gen_reg_rtx (SImode);
5512   emit_insn (gen_movsi (reg2, mem));
5513   emit_insn (gen_addsi3 (reg3, reg2, treg));
5514   emit_jump_insn (gen_tablejump_insn (reg3, table));
5515   DONE;
5519 ;; ::::::::::::::::::::
5520 ;; ::
5521 ;; :: Prologue and Epilogue instructions
5522 ;; ::
5523 ;; ::::::::::::::::::::
5525 ;; Called after register allocation to add any instructions needed for the
5526 ;; prologue.  Using a prologue insn is favored compared to putting all of the
5527 ;; instructions in the FUNCTION_PROLOGUE macro, since it allows the scheduler
5528 ;; to intermix instructions with the saves of the caller saved registers.  In
5529 ;; some cases, it might be necessary to emit a barrier instruction as the last
5530 ;; insn to prevent such scheduling.
5531 (define_expand "prologue"
5532   [(const_int 1)]
5533   ""
5534   "
5536   frv_expand_prologue ();
5537   DONE;
5540 ;; Called after register allocation to add any instructions needed for the
5541 ;; epilogue.  Using an epilogue insn is favored compared to putting all of the
5542 ;; instructions in the FUNCTION_EPILOGUE macro, since it allows the scheduler
5543 ;; to intermix instructions with the restires of the caller saved registers.
5544 ;; In some cases, it might be necessary to emit a barrier instruction as the
5545 ;; first insn to prevent such scheduling.
5546 (define_expand "epilogue"
5547   [(const_int 2)]
5548   ""
5549   "
5551   frv_expand_epilogue (FALSE);
5552   DONE;
5555 ;; This pattern, if defined, emits RTL for exit from a function without the final
5556 ;; branch back to the calling function.  This pattern will be emitted before any
5557 ;; sibling call (aka tail call) sites.
5559 ;; The sibcall_epilogue pattern must not clobber any arguments used for
5560 ;; parameter passing or any stack slots for arguments passed to the current
5561 ;; function.
5562 (define_expand "sibcall_epilogue"
5563   [(const_int 3)]
5564   ""
5565   "
5567   frv_expand_epilogue (TRUE);
5568   DONE;
5571 ;; Set up the pic register to hold the address of the pic table
5572 (define_insn "pic_prologue"
5573   [(set (match_operand:SI 0 "integer_register_operand" "=d")
5574         (unspec_volatile:SI [(const_int 0)] UNSPEC_PIC_PROLOGUE))
5575    (clobber (match_operand:SI 1 "lr_operand" "=l"))
5576    (clobber (match_operand:SI 2 "integer_register_operand" "=d"))]
5577   ""
5578   "*
5580   static int frv_pic_labelno = 0;
5582   operands[3] = GEN_INT (frv_pic_labelno++);
5583   return \"call %P3\\n%P3:\;movsg %1, %0\;sethi #gprelhi(%P3), %2\;setlo #gprello(%P3), %2\;sub %0,%2,%0\";
5585   [(set_attr "length" "16")
5586    (set_attr "type" "multi")])
5588 ;; ::::::::::::::::::::
5589 ;; ::
5590 ;; :: Miscellaneous instructions
5591 ;; ::
5592 ;; ::::::::::::::::::::
5594 ;; No operation, needed in case the user uses -g but not -O.
5595 (define_insn "nop"
5596   [(const_int 0)]
5597   ""
5598   "nop"
5599   [(set_attr "length" "4")
5600    (set_attr "type" "int")])
5602 ;; Pseudo instruction that prevents the scheduler from moving code above this
5603 ;; point.  Note, type unknown is used to make sure the VLIW instructions are
5604 ;; not continued past this point.
5605 (define_insn "blockage"
5606   [(unspec_volatile [(const_int 0)] UNSPEC_BLOCKAGE)]
5607   ""
5608   "# blockage"
5609   [(set_attr "length" "0")
5610    (set_attr "type" "unknown")])
5612 ;; ::::::::::::::::::::
5613 ;; ::
5614 ;; :: Media instructions
5615 ;; ::
5616 ;; ::::::::::::::::::::
5618 ;; Unimplemented instructions:
5619 ;;   - MCMPSH, MCMPUH
5621 (define_constants
5622   [(UNSPEC_MLOGIC               100)
5623    (UNSPEC_MNOT                 101)
5624    (UNSPEC_MAVEH                102)
5625    (UNSPEC_MSATH                103)
5626    (UNSPEC_MADDH                104)
5627    (UNSPEC_MQADDH               105)
5628    (UNSPEC_MPACKH               106)
5629    (UNSPEC_MUNPACKH             107)
5630    (UNSPEC_MDPACKH              108)
5631    (UNSPEC_MBTOH                109)
5632    (UNSPEC_MHTOB                110)
5633    (UNSPEC_MROT                 111)
5634    (UNSPEC_MSHIFT               112)
5635    (UNSPEC_MEXPDHW              113)
5636    (UNSPEC_MEXPDHD              114)
5637    (UNSPEC_MWCUT                115)
5638    (UNSPEC_MMULH                116)
5639    (UNSPEC_MMULXH               117)
5640    (UNSPEC_MMACH                118)
5641    (UNSPEC_MMRDH                119)
5642    (UNSPEC_MQMULH               120)
5643    (UNSPEC_MQMULXH              121)
5644    (UNSPEC_MQMACH               122)
5645    (UNSPEC_MCPX                 123)
5646    (UNSPEC_MQCPX                124)
5647    (UNSPEC_MCUT                 125)
5648    (UNSPEC_MRDACC               126)
5649    (UNSPEC_MRDACCG              127)
5650    (UNSPEC_MWTACC               128)
5651    (UNSPEC_MWTACCG              129)
5652    (UNSPEC_MTRAP                130)
5653    (UNSPEC_MCLRACC              131)
5654    (UNSPEC_MCLRACCA             132)
5655    (UNSPEC_MCOP1                133)
5656    (UNSPEC_MCOP2                134)
5657    (UNSPEC_MDUNPACKH            135)
5658    (UNSPEC_MDUNPACKH_INTERNAL   136)
5659    (UNSPEC_MBTOHE               137)
5660    (UNSPEC_MBTOHE_INTERNAL      138)
5661    (UNSPEC_MBTOHE               137)
5662    (UNSPEC_MBTOHE_INTERNAL      138)
5663    (UNSPEC_MQMACH2              139)
5664    (UNSPEC_MADDACC              140)
5665    (UNSPEC_MDADDACC             141)
5666    (UNSPEC_MABSHS               142)
5667    (UNSPEC_MDROTLI              143)
5668    (UNSPEC_MCPLHI               144)
5669    (UNSPEC_MCPLI                145)
5670    (UNSPEC_MDCUTSSI             146)
5671    (UNSPEC_MQSATHS              147)
5672    (UNSPEC_MHSETLOS             148)
5673    (UNSPEC_MHSETLOH             149)
5674    (UNSPEC_MHSETHIS             150)
5675    (UNSPEC_MHSETHIH             151)
5676    (UNSPEC_MHDSETS              152)
5677    (UNSPEC_MHDSETH              153)
5680 ;; Logic operations: type "mlogic"
5682 (define_expand "mand"
5683   [(set (match_operand:SI 0 "fpr_operand" "")
5684         (unspec:SI [(match_operand:SI 1 "fpr_operand" "")
5685                     (match_operand:SI 2 "fpr_operand" "")
5686                     (match_dup 3)]
5687                    UNSPEC_MLOGIC))]
5688   "TARGET_MEDIA"
5689   "operands[3] = GEN_INT (FRV_BUILTIN_MAND);")
5691 (define_expand "mor"
5692   [(set (match_operand:SI 0 "fpr_operand" "")
5693         (unspec:SI [(match_operand:SI 1 "fpr_operand" "")
5694                     (match_operand:SI 2 "fpr_operand" "")
5695                     (match_dup 3)]
5696                    UNSPEC_MLOGIC))]
5697   "TARGET_MEDIA"
5698   "operands[3] = GEN_INT (FRV_BUILTIN_MOR);")
5700 (define_expand "mxor"
5701   [(set (match_operand:SI 0 "fpr_operand" "")
5702         (unspec:SI [(match_operand:SI 1 "fpr_operand" "")
5703                     (match_operand:SI 2 "fpr_operand" "")
5704                     (match_dup 3)]
5705                    UNSPEC_MLOGIC))]
5706   "TARGET_MEDIA"
5707   "operands[3] = GEN_INT (FRV_BUILTIN_MXOR);")
5709 (define_insn "*mlogic"
5710   [(set (match_operand:SI 0 "fpr_operand" "=f")
5711         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
5712                     (match_operand:SI 2 "fpr_operand" "f")
5713                     (match_operand:SI 3 "const_int_operand" "n")]
5714                    UNSPEC_MLOGIC))]
5715   "TARGET_MEDIA"
5716   "*
5718   switch (INTVAL (operands[3]))
5719   {
5720   default:               break;
5721   case FRV_BUILTIN_MAND: return \"mand %1, %2, %0\";
5722   case FRV_BUILTIN_MOR:  return \"mor %1, %2, %0\";
5723   case FRV_BUILTIN_MXOR: return \"mxor %1, %2, %0\";
5724   }
5726   fatal_insn (\"Bad media insn, mlogic\", insn);
5728   [(set_attr "length" "4")
5729    (set_attr "type" "mlogic")])
5731 (define_insn "*cond_exec_mlogic"
5732   [(cond_exec
5733     (match_operator 0 "ccr_eqne_operator"
5734                     [(match_operand 1 "cr_operand" "C")
5735                      (const_int 0)])
5736     (set (match_operand:SI 2 "fpr_operand" "=f")
5737          (unspec:SI [(match_operand:SI 3 "fpr_operand" "f")
5738                      (match_operand:SI 4 "fpr_operand" "f")
5739                      (match_operand:SI 5 "const_int_operand" "n")]
5740                     UNSPEC_MLOGIC)))]
5741   "TARGET_MEDIA"
5742   "*
5744   switch (INTVAL (operands[5]))
5745   {
5746   default:                  break;
5747   case FRV_BUILTIN_MAND: return \"cmand %3, %4, %2, %1, %e0\";
5748   case FRV_BUILTIN_MOR:  return \"cmor %3, %4, %2, %1, %e0\";
5749   case FRV_BUILTIN_MXOR: return \"cmxor %3, %4, %2, %1, %e0\";
5750   }
5752   fatal_insn (\"Bad media insn, cond_exec_mlogic\", insn);
5754   [(set_attr "length" "4")
5755    (set_attr "type" "mlogic")])
5757 ;; Logical not: type "mlogic"
5759 (define_insn "mnot"
5760   [(set (match_operand:SI 0 "fpr_operand" "=f")
5761         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")] UNSPEC_MNOT))]
5762   "TARGET_MEDIA"
5763   "mnot %1, %0"
5764   [(set_attr "length" "4")
5765    (set_attr "type" "mlogic")])
5767 (define_insn "*cond_exec_mnot"
5768   [(cond_exec
5769     (match_operator 0 "ccr_eqne_operator"
5770                     [(match_operand 1 "cr_operand" "C")
5771                      (const_int 0)])
5772     (set (match_operand:SI 2 "fpr_operand" "=f")
5773          (unspec:SI [(match_operand:SI 3 "fpr_operand" "f")] UNSPEC_MNOT)))]
5774   "TARGET_MEDIA"
5775   "cmnot %3, %2, %1, %e0"
5776   [(set_attr "length" "4")
5777    (set_attr "type" "mlogic")])
5779 ;; Dual average (halfword): type "maveh"
5781 (define_insn "maveh"
5782   [(set (match_operand:SI 0 "fpr_operand" "=f")
5783         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
5784                     (match_operand:SI 2 "fpr_operand" "f")]
5785                    UNSPEC_MAVEH))]
5786   "TARGET_MEDIA"
5787   "maveh %1, %2, %0"
5788   [(set_attr "length" "4")
5789    (set_attr "type" "maveh")])
5791 ;; Dual saturation (halfword): type "msath"
5793 (define_expand "msaths"
5794   [(set (match_operand:SI 0 "fpr_operand" "=f")
5795         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
5796                     (match_operand:SI 2 "fpr_operand" "f")
5797                     (match_dup 3)]
5798                    UNSPEC_MSATH))]
5799   "TARGET_MEDIA"
5800   "operands[3] = GEN_INT (FRV_BUILTIN_MSATHS);")
5802 (define_expand "msathu"
5803   [(set (match_operand:SI 0 "fpr_operand" "=f")
5804         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
5805                     (match_operand:SI 2 "fpr_operand" "f")
5806                     (match_dup 3)]
5807                    UNSPEC_MSATH))]
5808   "TARGET_MEDIA"
5809   "operands[3] = GEN_INT (FRV_BUILTIN_MSATHU);")
5811 (define_insn "*msath"
5812   [(set (match_operand:SI 0 "fpr_operand" "=f")
5813         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
5814                     (match_operand:SI 2 "fpr_operand" "f")
5815                     (match_operand:SI 3 "const_int_operand" "n")]
5816                    UNSPEC_MSATH))]
5817   "TARGET_MEDIA"
5818   "*
5820   switch (INTVAL (operands[3]))
5821   {
5822   default:                  break;
5823   case FRV_BUILTIN_MSATHS:  return \"msaths %1, %2, %0\";
5824   case FRV_BUILTIN_MSATHU:  return \"msathu %1, %2, %0\";
5825   }
5827   fatal_insn (\"Bad media insn, msath\", insn);
5829   [(set_attr "length" "4")
5830    (set_attr "type" "msath")])
5832 ;; Dual addition/subtraction with saturation (halfword): type "maddh"
5834 (define_expand "maddhss"
5835   [(set (match_operand:SI 0 "fpr_operand" "=f")
5836         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
5837                     (match_operand:SI 2 "fpr_operand" "f")
5838                     (match_dup 3)]
5839                    UNSPEC_MADDH))]
5840   "TARGET_MEDIA"
5841   "operands[3] = GEN_INT (FRV_BUILTIN_MADDHSS);")
5843 (define_expand "maddhus"
5844   [(set (match_operand:SI 0 "fpr_operand" "=f")
5845         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
5846                     (match_operand:SI 2 "fpr_operand" "f")
5847                     (match_dup 3)]
5848                    UNSPEC_MADDH))]
5849   "TARGET_MEDIA"
5850   "operands[3] = GEN_INT (FRV_BUILTIN_MADDHUS);")
5852 (define_expand "msubhss"
5853   [(set (match_operand:SI 0 "fpr_operand" "=f")
5854         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
5855                     (match_operand:SI 2 "fpr_operand" "f")
5856                     (match_dup 3)]
5857                    UNSPEC_MADDH))]
5858   "TARGET_MEDIA"
5859   "operands[3] = GEN_INT (FRV_BUILTIN_MSUBHSS);")
5861 (define_expand "msubhus"
5862   [(set (match_operand:SI 0 "fpr_operand" "=f")
5863         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
5864                     (match_operand:SI 2 "fpr_operand" "f")
5865                     (match_dup 3)]
5866                    UNSPEC_MADDH))]
5867   "TARGET_MEDIA"
5868   "operands[3] = GEN_INT (FRV_BUILTIN_MSUBHUS);")
5870 (define_insn "*maddh"
5871   [(set (match_operand:SI 0 "fpr_operand" "=f")
5872         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
5873                     (match_operand:SI 2 "fpr_operand" "f")
5874                     (match_operand:SI 3 "const_int_operand" "n")]
5875                    UNSPEC_MADDH))]
5876   "TARGET_MEDIA"
5877   "*
5879   switch (INTVAL (operands[3]))
5880   {
5881   default:                  break;
5882   case FRV_BUILTIN_MADDHSS: return \"maddhss %1, %2, %0\";
5883   case FRV_BUILTIN_MADDHUS: return \"maddhus %1, %2, %0\";
5884   case FRV_BUILTIN_MSUBHSS: return \"msubhss %1, %2, %0\";
5885   case FRV_BUILTIN_MSUBHUS: return \"msubhus %1, %2, %0\";
5886   }
5888   fatal_insn (\"Bad media insn, maddh\", insn);
5890   [(set_attr "length" "4")
5891    (set_attr "type" "maddh")])
5893 (define_insn "*cond_exec_maddh"
5894   [(cond_exec
5895     (match_operator 0 "ccr_eqne_operator"
5896                     [(match_operand 1 "cr_operand" "C")
5897                      (const_int 0)])
5898     (set (match_operand:SI 2 "fpr_operand" "=f")
5899          (unspec:SI [(match_operand:SI 3 "fpr_operand" "f")
5900                      (match_operand:SI 4 "fpr_operand" "f")
5901                      (match_operand:SI 5 "const_int_operand" "n")]
5902                     UNSPEC_MADDH)))]
5903   "TARGET_MEDIA"
5904   "*
5906   switch (INTVAL (operands[5]))
5907   {
5908   default:                  break;
5909   case FRV_BUILTIN_MADDHSS: return \"cmaddhss %3, %4, %2, %1, %e0\";
5910   case FRV_BUILTIN_MADDHUS: return \"cmaddhus %3, %4, %2, %1, %e0\";
5911   case FRV_BUILTIN_MSUBHSS: return \"cmsubhss %3, %4, %2, %1, %e0\";
5912   case FRV_BUILTIN_MSUBHUS: return \"cmsubhus %3, %4, %2, %1, %e0\";
5913   }
5915   fatal_insn (\"Bad media insn, cond_exec_maddh\", insn);
5917   [(set_attr "length" "4")
5918    (set_attr "type" "maddh")])
5920 ;; Quad addition/subtraction with saturation (halfword): type "mqaddh"
5922 (define_expand "mqaddhss"
5923   [(set (match_operand:DI 0 "even_fpr_operand" "=h")
5924         (unspec:DI [(match_operand:DI 1 "even_fpr_operand" "h")
5925                     (match_operand:DI 2 "even_fpr_operand" "h")
5926                     (match_dup 3)]
5927                    UNSPEC_MQADDH))]
5928   "TARGET_MEDIA"
5929   "operands[3] = GEN_INT (FRV_BUILTIN_MQADDHSS);")
5931 (define_expand "mqaddhus"
5932   [(set (match_operand:DI 0 "even_fpr_operand" "=h")
5933         (unspec:DI [(match_operand:DI 1 "even_fpr_operand" "h")
5934                     (match_operand:DI 2 "even_fpr_operand" "h")
5935                     (match_dup 3)]
5936                    UNSPEC_MQADDH))]
5937   "TARGET_MEDIA"
5938   "operands[3] = GEN_INT (FRV_BUILTIN_MQADDHUS);")
5940 (define_expand "mqsubhss"
5941   [(set (match_operand:DI 0 "even_fpr_operand" "=h")
5942         (unspec:DI [(match_operand:DI 1 "even_fpr_operand" "h")
5943                     (match_operand:DI 2 "even_fpr_operand" "h")
5944                     (match_dup 3)]
5945                    UNSPEC_MQADDH))]
5946   "TARGET_MEDIA"
5947   "operands[3] = GEN_INT (FRV_BUILTIN_MQSUBHSS);")
5949 (define_expand "mqsubhus"
5950   [(set (match_operand:DI 0 "even_fpr_operand" "=h")
5951         (unspec:DI [(match_operand:DI 1 "even_fpr_operand" "h")
5952                     (match_operand:DI 2 "even_fpr_operand" "h")
5953                     (match_dup 3)]
5954                    UNSPEC_MQADDH))]
5955   "TARGET_MEDIA"
5956   "operands[3] = GEN_INT (FRV_BUILTIN_MQSUBHUS);")
5958 (define_insn "*mqaddh"
5959   [(set (match_operand:DI 0 "even_fpr_operand" "=h")
5960         (unspec:DI [(match_operand:DI 1 "even_fpr_operand" "h")
5961                     (match_operand:DI 2 "even_fpr_operand" "h")
5962                     (match_operand:SI 3 "const_int_operand" "n")]
5963                    UNSPEC_MQADDH))]
5964   "TARGET_MEDIA"
5965   "*
5967   switch (INTVAL (operands[3]))
5968   {
5969   default:                   break;
5970   case FRV_BUILTIN_MQADDHSS: return \"mqaddhss %1, %2, %0\";
5971   case FRV_BUILTIN_MQADDHUS: return \"mqaddhus %1, %2, %0\";
5972   case FRV_BUILTIN_MQSUBHSS: return \"mqsubhss %1, %2, %0\";
5973   case FRV_BUILTIN_MQSUBHUS: return \"mqsubhus %1, %2, %0\";
5974   }
5976   fatal_insn (\"Bad media insn, mqaddh\", insn);
5978   [(set_attr "length" "4")
5979    (set_attr "type" "mqaddh")])
5981 (define_insn "*cond_exec_mqaddh"
5982   [(cond_exec
5983     (match_operator 0 "ccr_eqne_operator"
5984                     [(match_operand 1 "cr_operand" "C")
5985                      (const_int 0)])
5986     (set (match_operand:DI 2 "even_fpr_operand" "=h")
5987          (unspec:DI [(match_operand:DI 3 "even_fpr_operand" "h")
5988                      (match_operand:DI 4 "even_fpr_operand" "h")
5989                      (match_operand:SI 5 "const_int_operand" "n")]
5990                     UNSPEC_MQADDH)))]
5991   "TARGET_MEDIA"
5992   "*
5994   switch (INTVAL (operands[5]))
5995   {
5996   default:                   break;
5997   case FRV_BUILTIN_MQADDHSS: return \"cmqaddhss %3, %4, %2, %1, %e0\";
5998   case FRV_BUILTIN_MQADDHUS: return \"cmqaddhus %3, %4, %2, %1, %e0\";
5999   case FRV_BUILTIN_MQSUBHSS: return \"cmqsubhss %3, %4, %2, %1, %e0\";
6000   case FRV_BUILTIN_MQSUBHUS: return \"cmqsubhus %3, %4, %2, %1, %e0\";
6001   }
6003   fatal_insn (\"Bad media insn, cond_exec_mqaddh\", insn);
6005   [(set_attr "length" "4")
6006    (set_attr "type" "mqaddh")])
6008 ;; Pack halfword: type "mpackh"
6010 (define_insn "mpackh"
6011   [(set (match_operand:SI 0 "fpr_operand" "=f")
6012         (unspec:SI [(match_operand:HI 1 "fpr_operand" "f")
6013                     (match_operand:HI 2 "fpr_operand" "f")]
6014                    UNSPEC_MPACKH))]
6015   "TARGET_MEDIA"
6016   "mpackh %1, %2, %0"
6017   [(set_attr "length" "4")
6018    (set_attr "type" "mpackh")])
6020 ;; Unpack halfword: type "mpackh"
6022 (define_insn "munpackh"
6023   [(set (match_operand:DI 0 "even_fpr_operand" "=h")
6024         (unspec:DI [(match_operand:SI 1 "fpr_operand" "f")]
6025                    UNSPEC_MUNPACKH))]
6026   "TARGET_MEDIA"
6027   "munpackh %1, %0"
6028   [(set_attr "length" "4")
6029    (set_attr "type" "munpackh")])
6031 ;; Dual pack halfword: type "mdpackh"
6033 (define_insn "mdpackh"
6034     [(set (match_operand:DI 0 "even_fpr_operand" "=h")
6035           (unspec:DI [(match_operand:DI 1 "even_fpr_operand" "h")
6036                       (match_operand:DI 2 "even_fpr_operand" "h")]
6037                      UNSPEC_MDPACKH))]
6038   "TARGET_MEDIA"
6039   "mdpackh %1, %2, %0"
6040   [(set_attr "length" "4")
6041    (set_attr "type" "mdpackh")])
6043 ;; Byte-halfword conversion: type "mbhconv"
6045 (define_insn "mbtoh"
6046   [(set (match_operand:DI 0 "even_fpr_operand" "=h")
6047         (unspec:DI [(match_operand:SI 1 "fpr_operand" "f")]
6048                    UNSPEC_MBTOH))]
6049   "TARGET_MEDIA"
6050   "mbtoh %1, %0"
6051   [(set_attr "length" "4")
6052    (set_attr "type" "mbhconv")])
6054 (define_insn "*cond_exec_mbtoh"
6055   [(cond_exec
6056     (match_operator 0 "ccr_eqne_operator"
6057                     [(match_operand 1 "cr_operand" "C")
6058                      (const_int 0)])
6059     (set (match_operand:DI 2 "even_fpr_operand" "=h")
6060          (unspec:DI [(match_operand:SI 3 "fpr_operand" "f")]
6061                     UNSPEC_MBTOH)))]
6062   "TARGET_MEDIA"
6063   "cmbtoh %3, %2, %1, %e0"
6064   [(set_attr "length" "4")
6065    (set_attr "type" "mbhconv")])
6067 (define_insn "mhtob"
6068   [(set (match_operand:SI 0 "fpr_operand" "=f")
6069         (unspec:SI [(match_operand:DI 1 "even_fpr_operand" "h")]
6070                    UNSPEC_MHTOB))]
6071   "TARGET_MEDIA"
6072   "mhtob %1, %0"
6073   [(set_attr "length" "4")
6074    (set_attr "type" "mbhconv")])
6076 (define_insn "*cond_exec_mhtob"
6077   [(cond_exec
6078     (match_operator 0 "ccr_eqne_operator"
6079                     [(match_operand 1 "cr_operand" "C")
6080                      (const_int 0)])
6081     (set (match_operand:SI 2 "fpr_operand" "=f")
6082          (unspec:SI [(match_operand:DI 3 "even_fpr_operand" "h")]
6083                     UNSPEC_MHTOB)))]
6084   "TARGET_MEDIA"
6085   "cmhtob %3, %2, %1, %e0"
6086   [(set_attr "length" "4")
6087    (set_attr "type" "mbhconv")])
6089 ;; Rotate: type "mrot"
6091 (define_expand "mrotli"
6092   [(set (match_operand:SI 0 "fpr_operand" "")
6093         (unspec:SI [(match_operand:SI 1 "fpr_operand" "")
6094                     (match_operand:SI 2 "uint5_operand" "")
6095                     (match_dup 3)]
6096                    UNSPEC_MROT))]
6097   "TARGET_MEDIA"
6098   "operands[3] = GEN_INT (FRV_BUILTIN_MROTLI);")
6100 (define_expand "mrotri"
6101   [(set (match_operand:SI 0 "fpr_operand" "")
6102         (unspec:SI [(match_operand:SI 1 "fpr_operand" "")
6103                     (match_operand:SI 2 "uint5_operand" "")
6104                     (match_dup 3)]
6105                    UNSPEC_MROT))]
6106   "TARGET_MEDIA"
6107   "operands[3] = GEN_INT (FRV_BUILTIN_MROTRI);")
6109 (define_insn "*mrot"
6110   [(set (match_operand:SI 0 "fpr_operand" "=f")
6111         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
6112                     (match_operand:SI 2 "uint5_operand" "I")
6113                     (match_operand:SI 3 "const_int_operand" "n")]
6114                    UNSPEC_MROT))]
6115   "TARGET_MEDIA"
6116   "*
6118   switch (INTVAL (operands[3]))
6119   {
6120   default:                 break;
6121   case FRV_BUILTIN_MROTLI: return \"mrotli %1, %2, %0\";
6122   case FRV_BUILTIN_MROTRI: return \"mrotri %1, %2, %0\";
6123   }
6125   fatal_insn (\"Bad media insn, mrot\", insn);
6127   [(set_attr "length" "4")
6128    (set_attr "type" "mrot")])
6130 ;; Dual shift halfword: type "msh"
6132 (define_expand "msllhi"
6133   [(set (match_operand:SI 0 "fpr_operand" "")
6134         (unspec:SI [(match_operand:SI 1 "fpr_operand" "")
6135                     (match_operand:SI 2 "uint4_operand" "")
6136                     (match_dup 3)]
6137                    UNSPEC_MSHIFT))]
6138   "TARGET_MEDIA"
6139   "operands[3] = GEN_INT (FRV_BUILTIN_MSLLHI);")
6141 (define_expand "msrlhi"
6142   [(set (match_operand:SI 0 "fpr_operand" "")
6143         (unspec:SI [(match_operand:SI 1 "fpr_operand" "")
6144                     (match_operand:SI 2 "uint4_operand" "")
6145                     (match_dup 3)]
6146                    UNSPEC_MSHIFT))]
6147   "TARGET_MEDIA"
6148   "operands[3] = GEN_INT (FRV_BUILTIN_MSRLHI);")
6150 (define_expand "msrahi"
6151   [(set (match_operand:SI 0 "fpr_operand" "")
6152         (unspec:SI [(match_operand:SI 1 "fpr_operand" "")
6153                     (match_operand:SI 2 "uint4_operand" "")
6154                     (match_dup 3)]
6155                    UNSPEC_MSHIFT))]
6156   "TARGET_MEDIA"
6157   "operands[3] = GEN_INT (FRV_BUILTIN_MSRAHI);")
6159 (define_insn "*mshift"
6160   [(set (match_operand:SI 0 "fpr_operand" "=f")
6161         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
6162                     (match_operand:SI 2 "uint4_operand" "I")
6163                     (match_operand:SI 3 "const_int_operand" "n")]
6164                    UNSPEC_MSHIFT))]
6165   "TARGET_MEDIA"
6166   "*
6168   switch (INTVAL (operands[3]))
6169   {
6170   default:                 break;
6171   case FRV_BUILTIN_MSLLHI: return \"msllhi %1, %2, %0\";
6172   case FRV_BUILTIN_MSRLHI: return \"msrlhi %1, %2, %0\";
6173   case FRV_BUILTIN_MSRAHI: return \"msrahi %1, %2, %0\";
6174   }
6176   fatal_insn (\"Bad media insn, mshift\", insn);
6178   [(set_attr "length" "4")
6179    (set_attr "type" "mshift")])
6181 ;; Expand halfword to word: type "mexpdhw"
6183 (define_insn "mexpdhw"
6184   [(set (match_operand:SI 0 "even_fpr_operand" "=h")
6185         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
6186                     (match_operand:SI 2 "uint1_operand" "I")]
6187                    UNSPEC_MEXPDHW))]
6188   "TARGET_MEDIA"
6189   "mexpdhw %1, %2, %0"
6190   [(set_attr "length" "4")
6191    (set_attr "type" "mexpdhw")])
6193 (define_insn "*cond_exec_mexpdhw"
6194   [(cond_exec
6195     (match_operator 0 "ccr_eqne_operator"
6196                     [(match_operand 1 "cr_operand" "C")
6197                      (const_int 0)])
6198     (set (match_operand:SI 2 "even_fpr_operand" "=h")
6199          (unspec:SI [(match_operand:SI 3 "fpr_operand" "f")
6200                      (match_operand:SI 4 "uint1_operand" "I")]
6201                     UNSPEC_MEXPDHW)))]
6202   "TARGET_MEDIA"
6203   "cmexpdhw %3, %4, %2, %1, %e0"
6204   [(set_attr "length" "4")
6205    (set_attr "type" "mexpdhw")])
6207 ;; Expand halfword to double: type "mexpdhd"
6209 (define_insn "mexpdhd"
6210   [(set (match_operand:DI 0 "even_fpr_operand" "=h")
6211         (unspec:DI [(match_operand:SI 1 "fpr_operand" "f")
6212                     (match_operand:SI 2 "uint1_operand" "I")]
6213                    UNSPEC_MEXPDHD))]
6214   "TARGET_MEDIA"
6215   "mexpdhd %1, %2, %0"
6216   [(set_attr "length" "4")
6217    (set_attr "type" "mexpdhd")])
6219 (define_insn "*cond_exec_mexpdhd"
6220   [(cond_exec
6221     (match_operator 0 "ccr_eqne_operator"
6222                     [(match_operand 1 "cr_operand" "C")
6223                      (const_int 0)])
6224     (set (match_operand:DI 2 "even_fpr_operand" "=h")
6225          (unspec:DI [(match_operand:SI 3 "fpr_operand" "f")
6226                      (match_operand:SI 4 "uint1_operand" "I")]
6227                     UNSPEC_MEXPDHD)))]
6228   "TARGET_MEDIA"
6229   "cmexpdhd %3, %4, %2, %1, %e0"
6230   [(set_attr "length" "4")
6231    (set_attr "type" "mexpdhd")])
6233 ;; FR cut: type "mwcut"
6235 (define_insn "mwcut"
6236   [(set (match_operand:SI 0 "fpr_operand" "=f")
6237         (unspec:SI [(match_operand:DI 1 "fpr_operand" "f")
6238                     (match_operand:SI 2 "fpr_or_int6_operand" "fI")]
6239                    UNSPEC_MWCUT))]
6240   "TARGET_MEDIA"
6241   "mwcut%i2 %1, %2, %0"
6242   [(set_attr "length" "4")
6243    (set_attr "type" "mwcut")])
6245 ;; Dual multiplication (halfword): type "mmulh"
6247 (define_expand "mmulhs"
6248   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "=b")
6249                    (unspec:DI [(match_operand:SI 1 "fpr_operand" "f")
6250                                (match_operand:SI 2 "fpr_operand" "f")
6251                                (match_dup 4)]
6252                               UNSPEC_MMULH))
6253               (set (match_operand:HI 3 "accg_operand" "=B")
6254                    (unspec:HI [(const_int 0)] UNSPEC_MMULH))])]
6255   "TARGET_MEDIA"
6256   "operands[4] = GEN_INT (FRV_BUILTIN_MMULHS);")
6258 (define_expand "mmulhu"
6259   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "=b")
6260                    (unspec:DI [(match_operand:SI 1 "fpr_operand" "f")
6261                                (match_operand:SI 2 "fpr_operand" "f")
6262                                (match_dup 4)]
6263                               UNSPEC_MMULH))
6264               (set (match_operand:HI 3 "accg_operand" "=B")
6265                    (unspec:HI [(const_int 0)] UNSPEC_MMULH))])]
6266   "TARGET_MEDIA"
6267   "operands[4] = GEN_INT (FRV_BUILTIN_MMULHU);")
6269 (define_insn "*mmulh"
6270   [(set (match_operand:DI 0 "even_acc_operand" "=b")
6271         (unspec:DI [(match_operand:SI 1 "fpr_operand" "f")
6272                     (match_operand:SI 2 "fpr_operand" "f")
6273                     (match_operand:SI 3 "const_int_operand" "n")]
6274                    UNSPEC_MMULH))
6275    (set (match_operand:HI 4 "accg_operand" "=B")
6276         (unspec:HI [(const_int 0)] UNSPEC_MMULH))]
6277   "TARGET_MEDIA"
6278   "*
6280   switch (INTVAL (operands[3]))
6281   {
6282   default:                  break;
6283   case FRV_BUILTIN_MMULHS:  return \"mmulhs %1, %2, %0\";
6284   case FRV_BUILTIN_MMULHU:  return \"mmulhu %1, %2, %0\";
6285   }
6287   fatal_insn (\"Bad media insn, mmulh\", insn);
6289   [(set_attr "length" "4")
6290    (set_attr "type" "mmulh")])
6292 (define_insn "*cond_exec_mmulh"
6293   [(cond_exec
6294     (match_operator 0 "ccr_eqne_operator"
6295                     [(match_operand 1 "cr_operand" "C")
6296                      (const_int 0)])
6297     (parallel [(set (match_operand:DI 2 "even_acc_operand" "=b")
6298                     (unspec:DI [(match_operand:SI 3 "fpr_operand" "f")
6299                                 (match_operand:SI 4 "fpr_operand" "f")
6300                                 (match_operand:SI 5 "const_int_operand" "n")]
6301                                UNSPEC_MMULH))
6302                (set (match_operand:HI 6 "accg_operand" "=B")
6303                     (unspec:HI [(const_int 0)] UNSPEC_MMULH))]))]
6304   "TARGET_MEDIA"
6305   "*
6307   switch (INTVAL (operands[5]))
6308   {
6309   default:                  break;
6310   case FRV_BUILTIN_MMULHS:  return \"cmmulhs %3, %4, %2, %1, %e0\";
6311   case FRV_BUILTIN_MMULHU:  return \"cmmulhu %3, %4, %2, %1, %e0\";
6312   }
6314   fatal_insn (\"Bad media insn, cond_exec_mmulh\", insn);
6316   [(set_attr "length" "4")
6317    (set_attr "type" "mmulh")])
6319 ;; Dual cross multiplication (halfword): type "mmulxh"
6321 (define_expand "mmulxhs"
6322   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "=b")
6323                    (unspec:DI [(match_operand:SI 1 "fpr_operand" "f")
6324                                (match_operand:SI 2 "fpr_operand" "f")
6325                                (match_dup 4)]
6326                               UNSPEC_MMULXH))
6327               (set (match_operand:HI 3 "accg_operand" "=B")
6328                    (unspec:HI [(const_int 0)] UNSPEC_MMULXH))])]
6329   "TARGET_MEDIA"
6330   "operands[4] = GEN_INT (FRV_BUILTIN_MMULXHS);")
6332 (define_expand "mmulxhu"
6333   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "=b")
6334                    (unspec:DI [(match_operand:SI 1 "fpr_operand" "f")
6335                                (match_operand:SI 2 "fpr_operand" "f")
6336                                (match_dup 4)]
6337                               UNSPEC_MMULXH))
6338               (set (match_operand:HI 3 "accg_operand" "=B")
6339                    (unspec:HI [(const_int 0)] UNSPEC_MMULXH))])]
6340   "TARGET_MEDIA"
6341   "operands[4] = GEN_INT (FRV_BUILTIN_MMULXHU);")
6343 (define_insn "*mmulxh"
6344   [(set (match_operand:DI 0 "even_acc_operand" "=b")
6345         (unspec:DI [(match_operand:SI 1 "fpr_operand" "f")
6346                     (match_operand:SI 2 "fpr_operand" "f")
6347                     (match_operand:SI 3 "const_int_operand" "n")]
6348                    UNSPEC_MMULXH))
6349    (set (match_operand:HI 4 "accg_operand" "=B")
6350         (unspec:HI [(const_int 0)] UNSPEC_MMULXH))]
6351   "TARGET_MEDIA"
6352   "*
6354   switch (INTVAL (operands[3]))
6355   {
6356   default:                  break;
6357   case FRV_BUILTIN_MMULXHS: return \"mmulxhs %1, %2, %0\";
6358   case FRV_BUILTIN_MMULXHU: return \"mmulxhu %1, %2, %0\";
6359   }
6361   fatal_insn (\"Bad media insn, mmulxh\", insn);
6363   [(set_attr "length" "4")
6364    (set_attr "type" "mmulxh")])
6366 ;; Dual product-sum (halfword): type "mmach"
6368 (define_expand "mmachs"
6369   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "+b")
6370                    (unspec:DI [(match_dup 0)
6371                                (match_operand:SI 1 "fpr_operand" "f")
6372                                (match_operand:SI 2 "fpr_operand" "f")
6373                                (match_operand:HI 3 "accg_operand" "+B")
6374                                (match_dup 4)]
6375                               UNSPEC_MMACH))
6376               (set (match_dup 3)
6377                    (unspec:HI [(const_int 0)] UNSPEC_MMACH))])]
6378   "TARGET_MEDIA"
6379   "operands[4] = GEN_INT (FRV_BUILTIN_MMACHS);")
6381 (define_expand "mmachu"
6382   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "+b")
6383                    (unspec:DI [(match_dup 0)
6384                                (match_operand:SI 1 "fpr_operand" "f")
6385                                (match_operand:SI 2 "fpr_operand" "f")
6386                                (match_operand:HI 3 "accg_operand" "+B")
6387                                (match_dup 4)]
6388                               UNSPEC_MMACH))
6389               (set (match_dup 3)
6390                    (unspec:HI [(const_int 0)] UNSPEC_MMACH))])]
6391   "TARGET_MEDIA"
6392   "operands[4] = GEN_INT (FRV_BUILTIN_MMACHU);")
6394 (define_insn "*mmach"
6395   [(set (match_operand:DI 0 "even_acc_operand" "+b")
6396         (unspec:DI [(match_dup 0)
6397                     (match_operand:SI 1 "fpr_operand" "f")
6398                     (match_operand:SI 2 "fpr_operand" "f")
6399                     (match_operand:HI 3 "accg_operand" "+B")
6400                     (match_operand:SI 4 "const_int_operand" "n")]
6401                    UNSPEC_MMACH))
6402    (set (match_dup 3) (unspec:HI [(const_int 0)] UNSPEC_MMACH))]
6403   "TARGET_MEDIA"
6404   "*
6406   switch (INTVAL (operands[4]))
6407   {
6408   default:                 break;
6409   case FRV_BUILTIN_MMACHS: return \"mmachs %1, %2, %0\";
6410   case FRV_BUILTIN_MMACHU: return \"mmachu %1, %2, %0\";
6411   }
6413   fatal_insn (\"Bad media insn, mmach\", insn);
6415   [(set_attr "length" "4")
6416    (set_attr "type" "mmach")])
6418 (define_insn "*cond_exec_mmach"
6419   [(cond_exec
6420     (match_operator 0 "ccr_eqne_operator"
6421                     [(match_operand 1 "cr_operand" "C")
6422                      (const_int 0)])
6423     (parallel [(set (match_operand:DI 2 "even_acc_operand" "+b")
6424                     (unspec:DI [(match_dup 2)
6425                                 (match_operand:SI 3 "fpr_operand" "f")
6426                                 (match_operand:SI 4 "fpr_operand" "f")
6427                                 (match_operand:HI 5 "accg_operand" "+B")
6428                                 (match_operand:SI 6 "const_int_operand" "n")]
6429                                UNSPEC_MMACH))
6430                (set (match_dup 5)
6431                     (unspec:HI [(const_int 0)] UNSPEC_MMACH))]))]
6432   "TARGET_MEDIA"
6433   "*
6435   switch (INTVAL (operands[6]))
6436   {
6437   default:                 break;
6438   case FRV_BUILTIN_MMACHS: return \"cmmachs %3, %4, %2, %1, %e0\";
6439   case FRV_BUILTIN_MMACHU: return \"cmmachu %3, %4, %2, %1, %e0\";
6440   }
6442   fatal_insn (\"Bad media insn, cond_exec_mmach\", insn);
6444   [(set_attr "length" "4")
6445    (set_attr "type" "mmach")])
6447 ;; Dual product-difference: type "mmrdh"
6449 (define_expand "mmrdhs"
6450   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "+b")
6451                    (unspec:DI [(match_dup 0)
6452                                (match_operand:SI 1 "fpr_operand" "f")
6453                                (match_operand:SI 2 "fpr_operand" "f")
6454                                (match_operand:HI 3 "accg_operand" "+B")
6455                                (match_dup 4)]
6456                               UNSPEC_MMRDH))
6457               (set (match_dup 3)
6458                    (unspec:HI [(const_int 0)] UNSPEC_MMRDH))])]
6459   "TARGET_MEDIA"
6460   "operands[4] = GEN_INT (FRV_BUILTIN_MMRDHS);")
6462 (define_expand "mmrdhu"
6463   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "+b")
6464                    (unspec:DI [(match_dup 0)
6465                                (match_operand:SI 1 "fpr_operand" "f")
6466                                (match_operand:SI 2 "fpr_operand" "f")
6467                                (match_operand:HI 3 "accg_operand" "+B")
6468                                (match_dup 4)]
6469                               UNSPEC_MMRDH))
6470               (set (match_dup 3)
6471                    (unspec:HI [(const_int 0)] UNSPEC_MMRDH))])]
6472   "TARGET_MEDIA"
6473   "operands[4] = GEN_INT (FRV_BUILTIN_MMRDHU);")
6475 (define_insn "*mmrdh"
6476   [(set (match_operand:DI 0 "even_acc_operand" "+b")
6477         (unspec:DI [(match_dup 0)
6478                     (match_operand:SI 1 "fpr_operand" "f")
6479                     (match_operand:SI 2 "fpr_operand" "f")
6480                     (match_operand:HI 3 "accg_operand" "+B")
6481                     (match_operand:SI 4 "const_int_operand" "n")]
6482                    UNSPEC_MMRDH))
6483    (set (match_dup 3)
6484         (unspec:HI [(const_int 0)] UNSPEC_MMRDH))]
6485   "TARGET_MEDIA"
6486   "*
6488   switch (INTVAL (operands[4]))
6489   {
6490   default:                 break;
6491   case FRV_BUILTIN_MMRDHS: return \"mmrdhs %1, %2, %0\";
6492   case FRV_BUILTIN_MMRDHU: return \"mmrdhu %1, %2, %0\";
6493   }
6495   fatal_insn (\"Bad media insn, mrdh\", insn);
6497   [(set_attr "length" "4")
6498    (set_attr "type" "mmrdh")])
6500 ;; Quad multiply (halfword): type "mqmulh"
6502 (define_expand "mqmulhs"
6503   [(parallel [(set (match_operand:V4SI 0 "quad_acc_operand" "=A")
6504                    (unspec:V4SI [(match_operand:DI 1 "even_fpr_operand" "h")
6505                                  (match_operand:DI 2 "even_fpr_operand" "h")
6506                                  (match_dup 4)]
6507                                 UNSPEC_MQMULH))
6508               (set (match_operand:V4QI 3 "accg_operand" "=B")
6509                    (unspec:V4QI [(const_int 0)] UNSPEC_MQMULH))])]
6510   "TARGET_MEDIA"
6511   "operands[4] = GEN_INT (FRV_BUILTIN_MQMULHS);")
6513 (define_expand "mqmulhu"
6514   [(parallel [(set (match_operand:V4SI 0 "quad_acc_operand" "=A")
6515                    (unspec:V4SI [(match_operand:DI 1 "even_fpr_operand" "h")
6516                                  (match_operand:DI 2 "even_fpr_operand" "h")
6517                                  (match_dup 4)]
6518                                 UNSPEC_MQMULH))
6519               (set (match_operand:V4QI 3 "accg_operand" "=B")
6520                    (unspec:V4QI [(const_int 0)] UNSPEC_MQMULH))])]
6521   "TARGET_MEDIA"
6522   "operands[4] = GEN_INT (FRV_BUILTIN_MQMULHU);")
6524 (define_insn "*mqmulh"
6525   [(set (match_operand:V4SI 0 "quad_acc_operand" "=A")
6526         (unspec:V4SI [(match_operand:DI 1 "even_fpr_operand" "h")
6527                       (match_operand:DI 2 "even_fpr_operand" "h")
6528                       (match_operand:SI 3 "const_int_operand" "n")]
6529                      UNSPEC_MQMULH))
6530    (set (match_operand:V4QI 4 "accg_operand" "=B")
6531         (unspec:V4QI [(const_int 0)] UNSPEC_MQMULH))]
6532   "TARGET_MEDIA"
6533   "*
6535   switch (INTVAL (operands[3]))
6536   {
6537   default:                   break;
6538   case FRV_BUILTIN_MQMULHS:  return \"mqmulhs %1, %2, %0\";
6539   case FRV_BUILTIN_MQMULHU:  return \"mqmulhu %1, %2, %0\";
6540   }
6542   fatal_insn (\"Bad media insn, mqmulh\", insn);
6544   [(set_attr "length" "4")
6545    (set_attr "type" "mqmulh")])
6547 (define_insn "*cond_exec_mqmulh"
6548   [(cond_exec
6549     (match_operator 0 "ccr_eqne_operator"
6550                     [(match_operand 1 "cr_operand" "C")
6551                      (const_int 0)])
6552     (parallel [(set (match_operand:V4SI 2 "quad_acc_operand" "=A")
6553                     (unspec:V4SI [(match_operand:DI 3 "even_fpr_operand" "h")
6554                                   (match_operand:DI 4 "even_fpr_operand" "h")
6555                                   (match_operand:SI 5 "const_int_operand" "n")]
6556                                  UNSPEC_MQMULH))
6557                (set (match_operand:V4QI 6 "accg_operand" "=B")
6558                     (unspec:V4QI [(const_int 0)] UNSPEC_MQMULH))]))]
6559   "TARGET_MEDIA"
6560   "*
6562   switch (INTVAL (operands[5]))
6563   {
6564   default:                   break;
6565   case FRV_BUILTIN_MQMULHS:  return \"cmqmulhs %3, %4, %2, %1, %e0\";
6566   case FRV_BUILTIN_MQMULHU:  return \"cmqmulhu %3, %4, %2, %1, %e0\";
6567   }
6569   fatal_insn (\"Bad media insn, cond_exec_mqmulh\", insn);
6571   [(set_attr "length" "4")
6572    (set_attr "type" "mqmulh")])
6574 ;; Quad cross multiply (halfword): type "mqmulxh"
6576 (define_expand "mqmulxhs"
6577   [(parallel [(set (match_operand:V4SI 0 "quad_acc_operand" "=A")
6578                    (unspec:V4SI [(match_operand:DI 1 "even_fpr_operand" "h")
6579                                  (match_operand:DI 2 "even_fpr_operand" "h")
6580                                  (match_dup 4)]
6581                                 UNSPEC_MQMULXH))
6582               (set (match_operand:V4QI 3 "accg_operand" "=B")
6583                    (unspec:V4QI [(const_int 0)] UNSPEC_MQMULXH))])]
6584   "TARGET_MEDIA"
6585   "operands[4] = GEN_INT (FRV_BUILTIN_MQMULXHS);")
6587 (define_expand "mqmulxhu"
6588   [(parallel [(set (match_operand:V4SI 0 "quad_acc_operand" "=A")
6589                    (unspec:V4SI [(match_operand:DI 1 "even_fpr_operand" "h")
6590                                  (match_operand:DI 2 "even_fpr_operand" "h")
6591                                  (match_dup 4)]
6592                                 UNSPEC_MQMULXH))
6593               (set (match_operand:V4QI 3 "accg_operand" "=B")
6594                    (unspec:V4QI [(const_int 0)] UNSPEC_MQMULXH))])]
6595   "TARGET_MEDIA"
6596   "operands[4] = GEN_INT (FRV_BUILTIN_MQMULXHU);")
6598 (define_insn "*mqmulxh"
6599   [(set (match_operand:V4SI 0 "quad_acc_operand" "=A")
6600         (unspec:V4SI [(match_operand:DI 1 "even_fpr_operand" "h")
6601                       (match_operand:DI 2 "even_fpr_operand" "h")
6602                       (match_operand:SI 3 "const_int_operand" "n")]
6603                      UNSPEC_MQMULXH))
6604    (set (match_operand:V4QI 4 "accg_operand" "=B")
6605         (unspec:V4QI [(const_int 0)] UNSPEC_MQMULXH))]
6606   "TARGET_MEDIA"
6607   "*
6609   switch (INTVAL (operands[3]))
6610   {
6611   default:                   break;
6612   case FRV_BUILTIN_MQMULXHS: return \"mqmulxhs %1, %2, %0\";
6613   case FRV_BUILTIN_MQMULXHU: return \"mqmulxhu %1, %2, %0\";
6614   }
6616   fatal_insn (\"Bad media insn, mqmulxh\", insn);
6618   [(set_attr "length" "4")
6619    (set_attr "type" "mqmulxh")])
6621 ;; Quad product-sum (halfword): type "mqmach"
6623 (define_expand "mqmachs"
6624   [(parallel [(set (match_operand:V4SI 0 "even_acc_operand" "+A")
6625                    (unspec:V4SI [(match_dup 0)
6626                                  (match_operand:DI 1 "even_fpr_operand" "h")
6627                                  (match_operand:DI 2 "even_fpr_operand" "h")
6628                                  (match_operand:V4QI 3 "accg_operand" "+B")
6629                                  (match_dup 4)]
6630                                 UNSPEC_MQMACH))
6631               (set (match_dup 3)
6632                    (unspec:V4QI [(const_int 0)] UNSPEC_MQMACH))])]
6633   "TARGET_MEDIA"
6634   "operands[4] = GEN_INT (FRV_BUILTIN_MQMACHS);")
6636 (define_expand "mqmachu"
6637   [(parallel [(set (match_operand:V4SI 0 "even_acc_operand" "+A")
6638                    (unspec:V4SI [(match_dup 0)
6639                                  (match_operand:DI 1 "even_fpr_operand" "h")
6640                                  (match_operand:DI 2 "even_fpr_operand" "h")
6641                                  (match_operand:V4QI 3 "accg_operand" "+B")
6642                                  (match_dup 4)]
6643                                 UNSPEC_MQMACH))
6644               (set (match_dup 3)
6645                    (unspec:V4QI [(const_int 0)] UNSPEC_MQMACH))])]
6646   "TARGET_MEDIA"
6647   "operands[4] = GEN_INT (FRV_BUILTIN_MQMACHU);")
6649 (define_insn "*mqmach"
6650   [(set (match_operand:V4SI 0 "even_acc_operand" "+A")
6651         (unspec:V4SI [(match_dup 0)
6652                       (match_operand:DI 1 "even_fpr_operand" "h")
6653                       (match_operand:DI 2 "even_fpr_operand" "h")
6654                       (match_operand:V4QI 3 "accg_operand" "+B")
6655                       (match_operand:SI 4 "const_int_operand" "n")]
6656                      UNSPEC_MQMACH))
6657    (set (match_dup 3)
6658         (unspec:V4QI [(const_int 0)] UNSPEC_MQMACH))]
6659   "TARGET_MEDIA"
6660   "*
6662   switch (INTVAL (operands[4]))
6663   {
6664   default:                  break;
6665   case FRV_BUILTIN_MQMACHS: return \"mqmachs %1, %2, %0\";
6666   case FRV_BUILTIN_MQMACHU: return \"mqmachu %1, %2, %0\";
6667   }
6669   fatal_insn (\"Bad media insn, mqmach\", insn);
6671   [(set_attr "length" "4")
6672    (set_attr "type" "mqmach")])
6674 (define_insn "*cond_exec_mqmach"
6675   [(cond_exec
6676     (match_operator 0 "ccr_eqne_operator"
6677                     [(match_operand 1 "cr_operand" "C")
6678                      (const_int 0)])
6679     (parallel [(set (match_operand:V4SI 2 "even_acc_operand" "+A")
6680                     (unspec:V4SI [(match_dup 2)
6681                                   (match_operand:DI 3 "even_fpr_operand" "h")
6682                                   (match_operand:DI 4 "even_fpr_operand" "h")
6683                                   (match_operand:V4QI 5 "accg_operand" "+B")
6684                                   (match_operand:SI 6 "const_int_operand" "n")]
6685                                  UNSPEC_MQMACH))
6686                (set (match_dup 5)
6687                     (unspec:V4QI [(const_int 0)] UNSPEC_MQMACH))]))]
6688   "TARGET_MEDIA"
6689   "*
6691   switch (INTVAL (operands[6]))
6692   {
6693   default:                  break;
6694   case FRV_BUILTIN_MQMACHS: return \"cmqmachs %3, %4, %2, %1, %e0\";
6695   case FRV_BUILTIN_MQMACHU: return \"cmqmachu %3, %4, %2, %1, %e0\";
6696   }
6698   fatal_insn (\"Bad media insn, cond_exec_mqmach\", insn);
6700   [(set_attr "length" "4")
6701    (set_attr "type" "mqmach")])
6703 ;; Dual complex number product-sum (halfword)
6705 (define_expand "mcpxrs"
6706   [(parallel [(set (match_operand:SI 0 "acc_operand" "=a")
6707                    (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
6708                                (match_operand:SI 2 "fpr_operand" "f")
6709                                (match_dup 4)]
6710                               UNSPEC_MCPX))
6711               (set (match_operand:QI 3 "accg_operand" "=B")
6712                    (unspec:QI [(const_int 0)] UNSPEC_MCPX))])]
6713   "TARGET_MEDIA"
6714   "operands[4] = GEN_INT (FRV_BUILTIN_MCPXRS);")
6716 (define_expand "mcpxru"
6717   [(parallel [(set (match_operand:SI 0 "acc_operand" "=a")
6718                    (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
6719                                (match_operand:SI 2 "fpr_operand" "f")
6720                                (match_dup 4)]
6721                               UNSPEC_MCPX))
6722               (set (match_operand:QI 3 "accg_operand" "=B")
6723                    (unspec:QI [(const_int 0)] UNSPEC_MCPX))])]
6724   "TARGET_MEDIA"
6725   "operands[4] = GEN_INT (FRV_BUILTIN_MCPXRU);")
6727 (define_expand "mcpxis"
6728   [(parallel [(set (match_operand:SI 0 "acc_operand" "=a")
6729                    (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
6730                                (match_operand:SI 2 "fpr_operand" "f")
6731                                (match_dup 4)]
6732                               UNSPEC_MCPX))
6733               (set (match_operand:QI 3 "accg_operand" "=B")
6734                    (unspec:QI [(const_int 0)] UNSPEC_MCPX))])]
6735   "TARGET_MEDIA"
6736   "operands[4] = GEN_INT (FRV_BUILTIN_MCPXIS);")
6738 (define_expand "mcpxiu"
6739   [(parallel [(set (match_operand:SI 0 "acc_operand" "=a")
6740                    (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
6741                                (match_operand:SI 2 "fpr_operand" "f")
6742                                (match_dup 4)]
6743                               UNSPEC_MCPX))
6744               (set (match_operand:QI 3 "accg_operand" "=B")
6745                    (unspec:QI [(const_int 0)] UNSPEC_MCPX))])]
6746   "TARGET_MEDIA"
6747   "operands[4] = GEN_INT (FRV_BUILTIN_MCPXIU);")
6749 (define_insn "*mcpx"
6750   [(parallel [(set (match_operand:SI 0 "acc_operand" "=a")
6751                    (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
6752                                (match_operand:SI 2 "fpr_operand" "f")
6753                                (match_operand:SI 3 "const_int_operand" "n")]
6754                               UNSPEC_MCPX))
6755               (set (match_operand:QI 4 "accg_operand" "=B")
6756                    (unspec:QI [(const_int 0)] UNSPEC_MCPX))])]
6757   "TARGET_MEDIA"
6758   "*
6760   switch (INTVAL (operands[3]))
6761   {
6762   default:                 break;
6763   case FRV_BUILTIN_MCPXRS: return \"mcpxrs %1, %2, %0\";
6764   case FRV_BUILTIN_MCPXRU: return \"mcpxru %1, %2, %0\";
6765   case FRV_BUILTIN_MCPXIS: return \"mcpxis %1, %2, %0\";
6766   case FRV_BUILTIN_MCPXIU: return \"mcpxiu %1, %2, %0\";
6767   }
6769   fatal_insn (\"Bad media insn, mcpx\", insn);
6771   [(set_attr "length" "4")
6772    (set_attr "type" "mcpx")])
6774 (define_insn "*cond_exec_mcpx"
6775   [(cond_exec
6776     (match_operator 0 "ccr_eqne_operator"
6777                     [(match_operand 1 "cr_operand" "C")
6778                      (const_int 0)])
6779     (parallel [(set (match_operand:SI 2 "acc_operand" "=a")
6780                     (unspec:SI [(match_operand:SI 3 "fpr_operand" "f")
6781                                 (match_operand:SI 4 "fpr_operand" "f")
6782                                 (match_operand:SI 5 "const_int_operand" "n")]
6783                                UNSPEC_MCPX))
6784                (set (match_operand:QI 6 "accg_operand" "=B")
6785                     (unspec:QI [(const_int 0)] UNSPEC_MCPX))]))]
6786   "TARGET_MEDIA"
6787   "*
6789   switch (INTVAL (operands[5]))
6790   {
6791   default:                 break;
6792   case FRV_BUILTIN_MCPXRS: return \"cmcpxrs %3, %4, %2, %1, %e0\";
6793   case FRV_BUILTIN_MCPXRU: return \"cmcpxru %3, %4, %2, %1, %e0\";
6794   case FRV_BUILTIN_MCPXIS: return \"cmcpxis %3, %4, %2, %1, %e0\";
6795   case FRV_BUILTIN_MCPXIU: return \"cmcpxiu %3, %4, %2, %1, %e0\";
6796   }
6798   fatal_insn (\"Bad media insn, cond_exec_mcpx\", insn);
6800   [(set_attr "length" "4")
6801    (set_attr "type" "mcpx")])
6803 ;; Quad complex number product-sum (halfword): type "mqcpx"
6805 (define_expand "mqcpxrs"
6806   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "=b")
6807                    (unspec:DI [(match_operand:DI 1 "fpr_operand" "f")
6808                                (match_operand:DI 2 "fpr_operand" "f")
6809                                (match_dup 4)]
6810                               UNSPEC_MQCPX))
6811               (set (match_operand:HI 3 "accg_operand" "=B")
6812                    (unspec:HI [(const_int 0)] UNSPEC_MQCPX))])]
6813   "TARGET_MEDIA"
6814   "operands[4] = GEN_INT (FRV_BUILTIN_MQCPXRS);")
6816 (define_expand "mqcpxru"
6817   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "=b")
6818                    (unspec:DI [(match_operand:DI 1 "fpr_operand" "f")
6819                                (match_operand:DI 2 "fpr_operand" "f")
6820                                (match_dup 4)]
6821                               UNSPEC_MQCPX))
6822               (set (match_operand:HI 3 "accg_operand" "=B")
6823                    (unspec:HI [(const_int 0)] UNSPEC_MQCPX))])]
6824   "TARGET_MEDIA"
6825   "operands[4] = GEN_INT (FRV_BUILTIN_MQCPXRU);")
6827 (define_expand "mqcpxis"
6828   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "=b")
6829                    (unspec:DI [(match_operand:DI 1 "fpr_operand" "f")
6830                                (match_operand:DI 2 "fpr_operand" "f")
6831                                (match_dup 4)]
6832                               UNSPEC_MQCPX))
6833               (set (match_operand:HI 3 "accg_operand" "=B")
6834                    (unspec:HI [(const_int 0)] UNSPEC_MQCPX))])]
6835   "TARGET_MEDIA"
6836   "operands[4] = GEN_INT (FRV_BUILTIN_MQCPXIS);")
6838 (define_expand "mqcpxiu"
6839   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "=b")
6840                    (unspec:DI [(match_operand:DI 1 "fpr_operand" "f")
6841                                (match_operand:DI 2 "fpr_operand" "f")
6842                                (match_dup 4)]
6843                               UNSPEC_MQCPX))
6844               (set (match_operand:HI 3 "accg_operand" "=B")
6845                    (unspec:HI [(const_int 0)] UNSPEC_MQCPX))])]
6846   "TARGET_MEDIA"
6847   "operands[4] = GEN_INT (FRV_BUILTIN_MQCPXIU);")
6849 (define_insn "*mqcpx"
6850   [(set (match_operand:DI 0 "even_acc_operand" "=b")
6851         (unspec:DI [(match_operand:DI 1 "fpr_operand" "f")
6852                     (match_operand:DI 2 "fpr_operand" "f")
6853                     (match_operand:SI 3 "const_int_operand" "n")]
6854                    UNSPEC_MQCPX))
6855    (set (match_operand:HI 4 "accg_operand" "=B")
6856         (unspec:HI [(const_int 0)] UNSPEC_MQCPX))]
6857   "TARGET_MEDIA"
6858   "*
6860   switch (INTVAL (operands[3]))
6861   {
6862   default:                  break;
6863   case FRV_BUILTIN_MQCPXRS: return \"mqcpxrs %1, %2, %0\";
6864   case FRV_BUILTIN_MQCPXRU: return \"mqcpxru %1, %2, %0\";
6865   case FRV_BUILTIN_MQCPXIS: return \"mqcpxis %1, %2, %0\";
6866   case FRV_BUILTIN_MQCPXIU: return \"mqcpxiu %1, %2, %0\";
6867   }
6869   fatal_insn (\"Bad media insn, mqcpx\", insn);
6871   [(set_attr "length" "4")
6872    (set_attr "type" "mqcpx")])
6874 ;; Cut: type "mcut"
6876 (define_expand "mcut"
6877   [(set (match_operand:SI 0 "fpr_operand" "=f")
6878         (unspec:SI [(match_operand:SI 1 "acc_operand" "a")
6879                     (match_operand:SI 2 "fpr_or_int6_operand" "fI")
6880                     (match_operand:QI 3 "accg_operand" "B")
6881                     (match_dup 4)]
6882                    UNSPEC_MCUT))]
6883   "TARGET_MEDIA"
6884   "operands[4] = GEN_INT (FRV_BUILTIN_MCUT);")
6886 (define_expand "mcutss"
6887   [(set (match_operand:SI 0 "fpr_operand" "=f")
6888         (unspec:SI [(match_operand:SI 1 "acc_operand" "a")
6889                     (match_operand:SI 2 "fpr_or_int6_operand" "fI")
6890                     (match_operand:QI 3 "accg_operand" "B")
6891                     (match_dup 4)]
6892                    UNSPEC_MCUT))]
6893   "TARGET_MEDIA"
6894   "operands[4] = GEN_INT (FRV_BUILTIN_MCUTSS);")
6896 (define_insn "*mcut"
6897   [(set (match_operand:SI 0 "fpr_operand" "=f")
6898         (unspec:SI [(match_operand:SI 1 "acc_operand" "a")
6899                     (match_operand:SI 2 "fpr_or_int6_operand" "fI")
6900                     (match_operand:QI 3 "accg_operand" "B")
6901                     (match_operand:SI 4 "const_int_operand" "n")]
6902                    UNSPEC_MCUT))]
6903   "TARGET_MEDIA"
6904   "*
6906   switch (INTVAL (operands[4]))
6907   {
6908   default:                 break;
6909   case FRV_BUILTIN_MCUT:   return \"mcut%i2 %1, %2, %0\";
6910   case FRV_BUILTIN_MCUTSS: return \"mcutss%i2 %1, %2, %0\";
6911   }
6913   fatal_insn (\"Bad media insn, mcut\", insn);
6915   [(set_attr "length" "4")
6916    (set_attr "type" "mcut")])
6918 ;; Accumulator read: type "mrdacc"
6920 (define_insn "mrdacc"
6921   [(set (match_operand:SI 0 "fpr_operand" "=f")
6922         (unspec:SI [(match_operand:SI 1 "acc_operand" "a")] UNSPEC_MRDACC))]
6923   "TARGET_MEDIA"
6924   "mrdacc %1, %0"
6925   [(set_attr "length" "4")
6926    (set_attr "type" "mrdacc")])
6928 (define_insn "mrdaccg"
6929   [(set (match_operand:SI 0 "fpr_operand" "=f")
6930         (unspec:SI [(match_operand:QI 1 "accg_operand" "B")] UNSPEC_MRDACCG))]
6931   "TARGET_MEDIA"
6932   "mrdaccg %1, %0"
6933   [(set_attr "length" "4")
6934    (set_attr "type" "mrdacc")])
6936 ;; Accumulator write: type "mwtacc"
6938 (define_insn "mwtacc"
6939   [(set (match_operand:SI 0 "acc_operand" "=a")
6940         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")] UNSPEC_MWTACC))]
6941   "TARGET_MEDIA"
6942   "mwtacc %1, %0"
6943   [(set_attr "length" "4")
6944    (set_attr "type" "mwtacc")])
6946 (define_insn "mwtaccg"
6947   [(set (match_operand:QI 0 "accg_operand" "=B")
6948         (unspec:QI [(match_operand:SI 1 "fpr_operand" "f")] UNSPEC_MWTACCG))]
6949   "TARGET_MEDIA"
6950   "mwtaccg %1, %0"
6951   [(set_attr "length" "4")
6952    (set_attr "type" "mwtacc")])
6954 ;; Trap: This one executes on the control unit, not the media units.
6956 (define_insn "mtrap"
6957   [(unspec_volatile [(const_int 0)] UNSPEC_MTRAP)]
6958   "TARGET_MEDIA"
6959   "mtrap"
6960   [(set_attr "length" "4")
6961    (set_attr "type" "trap")])
6963 ;; Clear single accumulator: type "mclracc"
6965 (define_insn "mclracc_internal"
6966   [(set (match_operand:SI 0 "acc_operand" "=a")
6967         (unspec:SI [(const_int 0)] UNSPEC_MCLRACC))
6968    (set (match_operand:QI 1 "accg_operand" "=B")
6969         (unspec:QI [(const_int 0)] UNSPEC_MCLRACC))]
6970   "TARGET_MEDIA"
6971   "mclracc %0,#0"
6972   [(set_attr "length" "4")
6973    (set_attr "type" "mclracc")])
6975 (define_expand "mclracc"
6976   [(parallel [(set (match_operand:SI 0 "acc_operand" "=a")
6977                    (unspec:SI [(const_int 0)] UNSPEC_MCLRACC))
6978               (set (match_dup 1)
6979                    (unspec:QI [(const_int 0)] UNSPEC_MCLRACC))])]
6980   "TARGET_MEDIA"
6981   "
6983   if (GET_CODE (operands[0]) != REG || !ACC_P (REGNO (operands[0])))
6984     FAIL;
6986   operands[1] = frv_matching_accg_for_acc (operands[0]);
6989 ;; Clear all accumulators: type "mclracca"
6991 (define_insn "mclracca8_internal"
6992   [(set (match_operand:V4SI 0 "quad_acc_operand" "=b")
6993         (unspec:V4SI [(const_int 0)] UNSPEC_MCLRACCA))
6994    (set (match_operand:V4SI 1 "quad_acc_operand" "=b")
6995         (unspec:V4SI [(const_int 0)] UNSPEC_MCLRACCA))
6996    (set (match_operand:V4QI 2 "accg_operand" "=B")
6997         (unspec:V4QI [(const_int 0)] UNSPEC_MCLRACCA))
6998    (set (match_operand:V4QI 3 "accg_operand" "=B")
6999         (unspec:V4QI [(const_int 0)] UNSPEC_MCLRACCA))]
7000   "TARGET_MEDIA && TARGET_ACC_8"
7001   "mclracc acc0,#1"
7002   [(set_attr "length" "4")
7003    (set_attr "type" "mclracca")])
7005 (define_insn "mclracca4_internal"
7006   [(set (match_operand:V4SI 0 "quad_acc_operand" "=b")
7007         (unspec:V4SI [(const_int 0)] UNSPEC_MCLRACCA))
7008    (set (match_operand:V4QI 1 "accg_operand" "=B")
7009         (unspec:V4QI [(const_int 0)] UNSPEC_MCLRACCA))]
7010   "TARGET_MEDIA && TARGET_ACC_4"
7011   "mclracc acc0,#1"
7012   [(set_attr "length" "4")
7013    (set_attr "type" "mclracca")])
7015 (define_expand "mclracca8"
7016   [(parallel [(set (match_dup 0) (unspec:V4SI [(const_int 0)] UNSPEC_MCLRACCA))
7017               (set (match_dup 1) (unspec:V4SI [(const_int 0)] UNSPEC_MCLRACCA))
7018               (set (match_dup 2) (unspec:V4QI [(const_int 0)] UNSPEC_MCLRACCA))
7019               (set (match_dup 3) (unspec:V4QI [(const_int 0)] UNSPEC_MCLRACCA))])]
7020   "TARGET_MEDIA && TARGET_ACC_8"
7021   "
7023   operands[0] = gen_rtx_REG (V4SImode, ACC_FIRST);
7024   operands[1] = gen_rtx_REG (V4SImode, ACC_FIRST + 4);
7025   operands[2] = gen_rtx_REG (V4QImode, ACCG_FIRST);
7026   operands[3] = gen_rtx_REG (V4QImode, ACCG_FIRST + 4);
7029 (define_expand "mclracca4"
7030   [(parallel [(set (match_dup 0) (unspec:V4SI [(const_int 0)] UNSPEC_MCLRACCA))
7031               (set (match_dup 1) (unspec:V4QI [(const_int 0)] UNSPEC_MCLRACCA))])]
7032   "TARGET_MEDIA && TARGET_ACC_4"
7033   "
7035   operands[0] = gen_rtx_REG (V4SImode, ACC_FIRST);
7036   operands[1] = gen_rtx_REG (V4QImode, ACCG_FIRST);
7039 (define_insn "mcop1"
7040   [(set (match_operand:SI 0 "fpr_operand" "=f")
7041         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
7042                     (match_operand:SI 2 "fpr_operand" "f")] UNSPEC_MCOP1))]
7043   "TARGET_MEDIA_REV1"
7044   "mcop1 %1, %2, %0"
7045   [(set_attr "length" "4")
7046 ;; What is the class of the insn ???
7047    (set_attr "type" "multi")])
7049 (define_insn "mcop2"
7050   [(set (match_operand:SI 0 "fpr_operand" "=f")
7051         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")
7052                     (match_operand:SI 2 "fpr_operand" "f")] UNSPEC_MCOP2))]
7053   "TARGET_MEDIA_REV1"
7054   "mcop2 %1, %2, %0"
7055   [(set_attr "length" "4")
7056 ;; What is the class of the insn ???
7057    (set_attr "type" "multi")])
7059 (define_insn "*mdunpackh_internal"
7060   [(set (match_operand:V4SI 0 "quad_fpr_operand" "=x")
7061         (unspec:V4SI [(match_operand:DI 1 "even_fpr_operand" "h")]
7062                      UNSPEC_MDUNPACKH_INTERNAL))]
7063   "TARGET_MEDIA_REV1"
7064   "mdunpackh %1, %0"
7065   [(set_attr "length" "4")
7066    (set_attr "type" "mdunpackh")])
7068 (define_insn_and_split "mdunpackh"
7069   [(set (match_operand:V4SI 0 "memory_operand" "=o")
7070         (unspec:V4SI [(match_operand:DI 1 "even_fpr_operand" "h")]
7071                      UNSPEC_MDUNPACKH))
7072    (clobber (match_scratch:V4SI 2 "=x"))]
7073   "TARGET_MEDIA_REV1"
7074   "#"
7075   "reload_completed"
7076   [(set (match_dup 2)
7077         (unspec:V4SI [(match_dup 1)] UNSPEC_MDUNPACKH_INTERNAL))
7078    (set (match_dup 3)
7079         (match_dup 4))
7080    (set (match_dup 5)
7081         (match_dup 6))]
7082   "
7084   operands[3] = change_address (operands[0], DImode, NULL_RTX);
7085   operands[4] = gen_rtx_REG (DImode, REGNO (operands[2]));
7086   operands[5] = frv_index_memory (operands[0], DImode, 1);
7087   operands[6] = gen_rtx_REG (DImode, REGNO (operands[2])+2);
7089   [(set_attr "length" "20")
7090    (set_attr "type" "multi")])
7092 (define_insn "*mbtohe_internal"
7093   [(set (match_operand:V4SI 0 "quad_fpr_operand" "=x")
7094         (unspec:V4SI [(match_operand:SI 1 "fpr_operand" "f")]
7095                      UNSPEC_MBTOHE_INTERNAL))]
7096   "TARGET_MEDIA_REV1"
7097   "mbtohe %1, %0"
7098   [(set_attr "length" "4")
7099    (set_attr "type" "mbhconve")])
7101 (define_insn_and_split "mbtohe"
7102   [(set (match_operand:V4SI 0 "memory_operand" "=o")
7103         (unspec:V4SI [(match_operand:SI 1 "fpr_operand" "f")]
7104                      UNSPEC_MBTOHE))
7105    (clobber (match_scratch:V4SI 2 "=x"))]
7106   "TARGET_MEDIA_REV1"
7107   "#"
7108   "reload_completed"
7109   [(set (match_dup 2)
7110         (unspec:V4SI [(match_dup 1)] UNSPEC_MBTOHE_INTERNAL))
7111    (set (match_dup 3)
7112         (match_dup 4))
7113    (set (match_dup 5)
7114         (match_dup 6))]
7115   "
7117   operands[3] = change_address (operands[0], DImode, NULL_RTX);
7118   operands[4] = gen_rtx_REG (DImode, REGNO (operands[2]));
7119   operands[5] = frv_index_memory (operands[0], DImode, 1);
7120   operands[6] = gen_rtx_REG (DImode, REGNO (operands[2])+2);
7122   [(set_attr "length" "20")
7123    (set_attr "type" "multi")])
7125 ;; Quad product-sum (halfword) instructions only found on the FR400.
7126 ;; type "mqmach"
7128 (define_expand "mqxmachs"
7129   [(parallel [(set (match_operand:V4SI 0 "quad_acc_operand" "")
7130                    (unspec:V4SI [(match_dup 0)
7131                                  (match_operand:DI 1 "even_fpr_operand" "")
7132                                  (match_operand:DI 2 "even_fpr_operand" "")
7133                                  (match_operand:V4QI 3 "accg_operand" "")
7134                                  (match_dup 4)]
7135                                 UNSPEC_MQMACH2))
7136                 (set (match_dup 3)
7137                      (unspec:V4QI [(const_int 0)] UNSPEC_MQMACH2))])]
7138   "TARGET_MEDIA_REV2"
7139   "operands[4] = GEN_INT (FRV_BUILTIN_MQXMACHS);")
7141 (define_expand "mqxmacxhs"
7142   [(parallel [(set (match_operand:V4SI 0 "quad_acc_operand" "")
7143                    (unspec:V4SI [(match_dup 0)
7144                                  (match_operand:DI 1 "even_fpr_operand" "")
7145                                  (match_operand:DI 2 "even_fpr_operand" "")
7146                                  (match_operand:V4QI 3 "accg_operand" "")
7147                                  (match_dup 4)]
7148                                 UNSPEC_MQMACH2))
7149               (set (match_dup 3)
7150                    (unspec:V4QI [(const_int 0)] UNSPEC_MQMACH2))])]
7151   "TARGET_MEDIA_REV2"
7152   "operands[4] = GEN_INT (FRV_BUILTIN_MQXMACXHS);")
7154 (define_expand "mqmacxhs"
7155   [(parallel [(set (match_operand:V4SI 0 "quad_acc_operand" "")
7156                    (unspec:V4SI [(match_dup 0)
7157                                  (match_operand:DI 1 "even_fpr_operand" "")
7158                                  (match_operand:DI 2 "even_fpr_operand" "")
7159                                  (match_operand:V4QI 3 "accg_operand" "")
7160                                  (match_dup 4)]
7161                                 UNSPEC_MQMACH2))
7162               (set (match_dup 3)
7163                    (unspec:V4QI [(const_int 0)] UNSPEC_MQMACH2))])]
7164   "TARGET_MEDIA_REV2"
7165   "operands[4] = GEN_INT (FRV_BUILTIN_MQMACXHS);")
7167 (define_insn "*mqmach2"
7168   [(set (match_operand:V4SI 0 "quad_acc_operand" "+A")
7169         (unspec:V4SI [(match_dup 0)
7170                       (match_operand:DI 1 "even_fpr_operand" "h")
7171                       (match_operand:DI 2 "even_fpr_operand" "h")
7172                       (match_operand:V4QI 3 "accg_operand" "+B")
7173                       (match_operand:SI 4 "const_int_operand" "n")]
7174                      UNSPEC_MQMACH2))
7175    (set (match_dup 3)
7176         (unspec:V4QI [(const_int 0)] UNSPEC_MQMACH2))]
7177   "TARGET_MEDIA_REV2"
7178   "*
7180   switch (INTVAL (operands[4]))
7181   {
7182   default:                    break;
7183   case FRV_BUILTIN_MQXMACHS:  return \"mqxmachs %1, %2, %0\";
7184   case FRV_BUILTIN_MQXMACXHS: return \"mqxmacxhs %1, %2, %0\";
7185   case FRV_BUILTIN_MQMACXHS:  return \"mqmacxhs %1, %2, %0\";
7186   }
7188   fatal_insn (\"Bad media insn, mqmach2\", insn);
7190   [(set_attr "length" "4")
7191    (set_attr "type" "mqmach")])
7193 ;; Accumulator addition/subtraction: type "maddacc"
7195 (define_expand "maddaccs"
7196   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "")
7197                    (unspec:DI [(match_dup 0)
7198                                (match_operand:DI 1 "even_acc_operand" "")]
7199                               UNSPEC_MADDACC))
7200               (set (match_operand:HI 2 "accg_operand" "")
7201                    (unspec:HI [(match_dup 2)
7202                                (match_operand:HI 3 "accg_operand" "")
7203                                (match_dup 4)]
7204                               UNSPEC_MADDACC))])]
7205   "TARGET_MEDIA_REV2"
7206   "operands[4] = GEN_INT (FRV_BUILTIN_MADDACCS);")
7208 (define_expand "msubaccs"
7209   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "")
7210                    (unspec:DI [(match_dup 0)
7211                                (match_operand:DI 1 "even_acc_operand" "")]
7212                               UNSPEC_MADDACC))
7213               (set (match_operand:HI 2 "accg_operand" "")
7214                    (unspec:HI [(match_dup 2)
7215                                (match_operand:HI 3 "accg_operand" "")
7216                                (match_dup 4)]
7217                               UNSPEC_MADDACC))])]
7218   "TARGET_MEDIA_REV2"
7219   "operands[4] = GEN_INT (FRV_BUILTIN_MSUBACCS);")
7221 (define_expand "masaccs"
7222   [(parallel [(set (match_operand:DI 0 "even_acc_operand" "")
7223                    (unspec:DI [(match_dup 0)
7224                                (match_operand:DI 1 "even_acc_operand" "")]
7225                               UNSPEC_MADDACC))
7226               (set (match_operand:HI 2 "accg_operand" "")
7227                    (unspec:HI [(match_dup 2)
7228                                (match_operand:HI 3 "accg_operand" "")
7229                                (match_dup 4)]
7230                               UNSPEC_MADDACC))])]
7231   "TARGET_MEDIA_REV2"
7232   "operands[4] = GEN_INT (FRV_BUILTIN_MASACCS);")
7234 (define_insn "*maddacc"
7235   [(set (match_operand:DI 0 "even_acc_operand" "+b")
7236         (unspec:DI [(match_dup 0)
7237                     (match_operand:DI 1 "even_acc_operand" "b")]
7238                    UNSPEC_MADDACC))
7239    (set (match_operand:HI 2 "accg_operand" "+B")
7240         (unspec:HI [(match_dup 2)
7241                     (match_operand:HI 3 "accg_operand" "B")
7242                     (match_operand:SI 4 "const_int_operand" "n")]
7243                    UNSPEC_MADDACC))]
7244   "TARGET_MEDIA_REV2"
7245   "*
7247   switch (INTVAL (operands[4]))
7248   {
7249   default:                   break;
7250   case FRV_BUILTIN_MADDACCS: return \"maddaccs %1, %0\";
7251   case FRV_BUILTIN_MSUBACCS: return \"msubaccs %1, %0\";
7252   case FRV_BUILTIN_MASACCS:  return \"masaccs %1, %0\";
7253   }
7255   fatal_insn (\"Bad media insn, maddacc\", insn);
7257   [(set_attr "length" "4")
7258    (set_attr "type" "maddacc")])
7260 ;; Dual accumulator addition/subtraction: type "mdaddacc"
7262 (define_expand "mdaddaccs"
7263   [(parallel [(set (match_operand:V4SI 0 "quad_acc_operand" "")
7264                    (unspec:V4SI [(match_dup 0)
7265                                  (match_operand:V4SI 1 "quad_acc_operand" "")]
7266                                 UNSPEC_MDADDACC))
7267               (set (match_operand:V4QI 2 "accg_operand" "")
7268                    (unspec:V4QI [(match_dup 2)
7269                                  (match_operand:V4QI 3 "accg_operand" "")
7270                                  (match_dup 4)]
7271                                 UNSPEC_MDADDACC))])]
7272   "TARGET_MEDIA_REV2"
7273   "operands[4] = GEN_INT (FRV_BUILTIN_MDADDACCS);")
7275 (define_expand "mdsubaccs"
7276   [(parallel [(set (match_operand:V4SI 0 "quad_acc_operand" "")
7277                    (unspec:V4SI [(match_dup 0)
7278                                  (match_operand:V4SI 1 "quad_acc_operand" "")]
7279                                 UNSPEC_MDADDACC))
7280               (set (match_operand:V4QI 2 "accg_operand" "")
7281                    (unspec:V4QI [(match_dup 2)
7282                                  (match_operand:V4QI 3 "accg_operand" "")
7283                                  (match_dup 4)]
7284                                 UNSPEC_MDADDACC))])]
7285   "TARGET_MEDIA_REV2"
7286   "operands[4] = GEN_INT (FRV_BUILTIN_MDSUBACCS);")
7288 (define_expand "mdasaccs"
7289   [(parallel [(set (match_operand:V4SI 0 "quad_acc_operand" "")
7290                    (unspec:V4SI [(match_dup 0)
7291                                  (match_operand:V4SI 1 "quad_acc_operand" "")]
7292                                 UNSPEC_MDADDACC))
7293               (set (match_operand:V4QI 2 "accg_operand" "")
7294                    (unspec:V4QI [(match_dup 2)
7295                                  (match_operand:V4QI 3 "accg_operand" "")
7296                                  (match_dup 4)]
7297                                 UNSPEC_MDADDACC))])]
7298   "TARGET_MEDIA_REV2"
7299   "operands[4] = GEN_INT (FRV_BUILTIN_MDASACCS);")
7301 (define_insn "*mdaddacc"
7302   [(set (match_operand:V4SI 0 "quad_acc_operand" "+A")
7303         (unspec:V4SI [(match_dup 0)
7304                       (match_operand:V4SI 1 "quad_acc_operand" "A")]
7305                      UNSPEC_MDADDACC))
7306    (set (match_operand:V4QI 2 "accg_operand" "+B")
7307         (unspec:V4QI [(match_dup 2)
7308                       (match_operand:V4QI 3 "accg_operand" "B")
7309                       (match_operand:SI 4 "const_int_operand" "n")]
7310                      UNSPEC_MDADDACC))]
7311   "TARGET_MEDIA_REV2"
7312   "*
7314   switch (INTVAL (operands[4]))
7315   {
7316   default:                    break;
7317   case FRV_BUILTIN_MDADDACCS: return \"mdaddaccs %1, %0\";
7318   case FRV_BUILTIN_MDSUBACCS: return \"mdsubaccs %1, %0\";
7319   case FRV_BUILTIN_MDASACCS:  return \"mdasaccs %1, %0\";
7320   }
7322   fatal_insn (\"Bad media insn, mdaddacc\", insn);
7324   [(set_attr "length" "4")
7325    (set_attr "type" "mdaddacc")])
7327 ;; Dual absolute (halfword): type "mabsh"
7329 (define_insn "mabshs"
7330   [(set (match_operand:SI 0 "fpr_operand" "=f")
7331         (unspec:SI [(match_operand:SI 1 "fpr_operand" "f")] UNSPEC_MABSHS))]
7332   "TARGET_MEDIA_REV2"
7333   "mabshs %1, %0"
7334   [(set_attr "length" "4")
7335    (set_attr "type" "mabsh")])
7337 ;; Dual rotate: type "mdrot"
7339 (define_insn "mdrotli"
7340   [(set (match_operand:DI 0 "even_fpr_operand" "=h")
7341         (unspec:DI [(match_operand:DI 1 "even_fpr_operand" "h")
7342                     (match_operand:SI 2 "uint5_operand" "I")]
7343                    UNSPEC_MDROTLI))]
7344   "TARGET_MEDIA_REV2"
7345   "mdrotli %1, %2, %0"
7346   [(set_attr "length" "4")
7347    (set_attr "type" "mdrot")])
7349 ;; Dual coupling (concatenation): type "mcpl"
7351 (define_insn "mcplhi"
7352   [(set (match_operand:SI 0 "fpr_operand" "=f")
7353         (unspec:SI [(match_operand:DI 1 "fpr_operand" "h")
7354                     (match_operand:SI 2 "uint4_operand" "I")]
7355                    UNSPEC_MCPLHI))]
7356   "TARGET_MEDIA_REV2"
7357   "mcplhi %1, %2, %0"
7358   [(set_attr "length" "4")
7359    (set_attr "type" "mcpl")])
7361 (define_insn "mcpli"
7362   [(set (match_operand:SI 0 "fpr_operand" "=f")
7363         (unspec:SI [(match_operand:DI 1 "fpr_operand" "h")
7364                     (match_operand:SI 2 "uint5_operand" "I")]
7365                    UNSPEC_MCPLI))]
7366   "TARGET_MEDIA_REV2"
7367   "mcpli %1, %2, %0"
7368   [(set_attr "length" "4")
7369    (set_attr "type" "mcpl")])
7371 ;; Dual cut: type "mdcut"
7373 (define_insn "mdcutssi"
7374   [(set (match_operand:DI 0 "even_fpr_operand" "=h")
7375         (unspec:DI [(match_operand:DI 1 "even_acc_operand" "b")
7376                     (match_operand:SI 2 "int6_operand" "I")
7377                     (match_operand:HI 3 "accg_operand" "B")]
7378                    UNSPEC_MDCUTSSI))]
7379   "TARGET_MEDIA_REV2"
7380   "mdcutssi %1, %2, %0"
7381   [(set_attr "length" "4")
7382    (set_attr "type" "mdcut")])
7384 ;; Quad saturate (halfword): type "mqsath"
7386 (define_insn "mqsaths"
7387   [(set (match_operand:DI 0 "even_fpr_operand" "=h")
7388         (unspec:DI [(match_operand:DI 1 "even_fpr_operand" "h")
7389                     (match_operand:DI 2 "even_fpr_operand" "h")]
7390                    UNSPEC_MQSATHS))]
7391   "TARGET_MEDIA_REV2"
7392   "mqsaths %1, %2, %0"
7393   [(set_attr "length" "4")
7394    (set_attr "type" "mqsath")])
7396 ;; Set hi/lo instructions: type "mset"
7398 (define_insn "mhsetlos"
7399   [(set (match_operand:SI 0 "fpr_operand" "=f")
7400         (unspec:SI [(match_operand:SI 1 "fpr_operand" "0")
7401                     (match_operand:SI 2 "int12_operand" "NOP")]
7402                    UNSPEC_MHSETLOS))]
7403   "TARGET_MEDIA_REV2"
7404   "mhsetlos %2, %0"
7405   [(set_attr "length" "4")
7406    (set_attr "type" "mset")])
7408 (define_insn "mhsetloh"
7409   [(set (match_operand:SI 0 "fpr_operand" "=f")
7410         (unspec:SI [(match_operand:SI 1 "fpr_operand" "0")
7411                     (match_operand:SI 2 "int5_operand" "I")]
7412                    UNSPEC_MHSETLOH))]
7413   "TARGET_MEDIA_REV2"
7414   "mhsetloh %2, %0"
7415   [(set_attr "length" "4")
7416    (set_attr "type" "mset")])
7418 (define_insn "mhsethis"
7419   [(set (match_operand:SI 0 "fpr_operand" "=f")
7420         (unspec:SI [(match_operand:SI 1 "fpr_operand" "0")
7421                     (match_operand:SI 2 "int12_operand" "NOP")]
7422                    UNSPEC_MHSETHIS))]
7423   "TARGET_MEDIA_REV2"
7424   "mhsethis %2, %0"
7425   [(set_attr "length" "4")
7426    (set_attr "type" "mset")])
7428 (define_insn "mhsethih"
7429   [(set (match_operand:SI 0 "fpr_operand" "=f")
7430         (unspec:SI [(match_operand:SI 1 "fpr_operand" "0")
7431                     (match_operand:SI 2 "int5_operand" "I")]
7432                    UNSPEC_MHSETHIH))]
7433   "TARGET_MEDIA_REV2"
7434   "mhsethih %2, %0"
7435   [(set_attr "length" "4")
7436    (set_attr "type" "mset")])
7438 (define_insn "mhdsets"
7439   [(set (match_operand:SI 0 "fpr_operand" "=f")
7440         (unspec:SI [(match_operand:SI 1 "int12_operand" "NOP")]
7441                    UNSPEC_MHDSETS))]
7442   "TARGET_MEDIA_REV2"
7443   "mhdsets %1, %0"
7444   [(set_attr "length" "4")
7445    (set_attr "type" "mset")])
7447 (define_insn "mhdseth"
7448   [(set (match_operand:SI 0 "fpr_operand" "=f")
7449         (unspec:SI [(match_operand:SI 1 "fpr_operand" "0")
7450                     (match_operand:SI 2 "int5_operand" "I")]
7451                    UNSPEC_MHDSETH))]
7452   "TARGET_MEDIA_REV2"
7453   "mhdseth %2, %0"
7454   [(set_attr "length" "4")
7455    (set_attr "type" "mset")])