OSDN Git Service

* config/xtensa/xtensa.c (gen_float_relational): Handle unordered
[pf3gnuchains/gcc-fork.git] / gcc / config / xtensa / xtensa.md
1 ;; GCC machine description for Tensilica's Xtensa architecture.
2 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
3 ;; Free Software Foundation, Inc.
4 ;; Contributed by Bob Wilson (bwilson@tensilica.com) at Tensilica.
5
6 ;; This file is part of GCC.
7
8 ;; GCC is free software; you can redistribute it and/or modify it
9 ;; under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 3, or (at your option)
11 ;; any later version.
12
13 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
14 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16 ;; License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING3.  If not see
20 ;; <http://www.gnu.org/licenses/>.
21
22
23 (define_constants [
24   (A0_REG               0)
25   (A1_REG               1)
26   (A7_REG               7)
27   (A8_REG               8)
28
29   (UNSPEC_NOP           2)
30   (UNSPEC_PLT           3)
31   (UNSPEC_RET_ADDR      4)
32
33   (UNSPECV_SET_FP       1)
34   (UNSPECV_ENTRY        2)
35   (UNSPECV_MEMW         3)
36   (UNSPECV_S32RI        4)
37   (UNSPECV_S32C1I       5)
38   (UNSPECV_EH_RETURN    6)
39 ])
40
41 ;; This code iterator allows signed and unsigned widening multiplications
42 ;; to use the same template.
43 (define_code_iterator any_extend [sign_extend zero_extend])
44
45 ;; <u> expands to an empty string when doing a signed operation and
46 ;; "u" when doing an unsigned operation.
47 (define_code_attr u [(sign_extend "") (zero_extend "u")])
48
49 ;; <su> is like <u>, but the signed form expands to "s" rather than "".
50 (define_code_attr su [(sign_extend "s") (zero_extend "u")])
51
52 ;; This code iterator allows four integer min/max operations to be
53 ;; generated from one template.
54 (define_code_iterator any_minmax [smin umin smax umax])
55
56 ;; <minmax> expands to the opcode name for any_minmax operations.
57 (define_code_attr minmax [(smin "min") (umin "minu")
58                           (smax "max") (umax "maxu")])
59
60 ;; This code iterator allows all branch instructions to be generated from
61 ;; a single define_expand template.
62 (define_code_iterator any_cond [eq ne gt ge lt le gtu geu ltu leu
63                                 uneq ltgt ungt unge unlt unle
64                                 unordered ordered])
65
66 ;; This code iterator is for setting a register from a comparison.
67 (define_code_iterator any_scc [eq ne gt ge lt le])
68
69 ;; This code iterator is for floating-point comparisons.
70 (define_code_iterator any_scc_sf [eq lt le uneq unlt unle unordered])
71 (define_code_attr scc_sf [(eq "oeq") (lt "olt") (le "ole") 
72                           (uneq "ueq") (unlt "ult") (unle "ule")
73                           (unordered "un")])
74
75 ;; This iterator and attribute allow to combine most atomic operations.
76 (define_code_iterator ATOMIC [and ior xor plus minus mult])
77 (define_code_attr atomic [(and "and") (ior "ior") (xor "xor") 
78                           (plus "add") (minus "sub") (mult "nand")])
79
80 ;; This mode iterator allows the HI and QI patterns to be defined from
81 ;; the same template.
82 (define_mode_iterator HQI [HI QI])
83
84 \f
85 ;; Attributes.
86
87 (define_attr "type"
88   "unknown,jump,call,load,store,move,arith,multi,nop,farith,fmadd,fdiv,fsqrt,fconv,fload,fstore,mul16,mul32,div32,mac16,rsr,wsr,entry"
89   (const_string "unknown"))
90
91 (define_attr "mode"
92   "unknown,none,QI,HI,SI,DI,SF,DF,BL"
93   (const_string "unknown"))
94
95 (define_attr "length" "" (const_int 1))
96
97 ;; Describe a user's asm statement.
98 (define_asm_attributes
99   [(set_attr "type" "multi")])
100
101 \f
102 ;; Pipeline model.
103
104 ;; The Xtensa basically has simple 5-stage RISC pipeline.
105 ;; Most instructions complete in 1 cycle, and it is OK to assume that
106 ;; everything is fully pipelined.  The exceptions have special insn
107 ;; reservations in the pipeline description below.  The Xtensa can
108 ;; issue one instruction per cycle, so defining CPU units is unnecessary.
109
110 (define_insn_reservation "xtensa_any_insn" 1
111                          (eq_attr "type" "!load,fload,rsr,mul16,mul32,fmadd,fconv")
112                          "nothing")
113
114 (define_insn_reservation "xtensa_memory" 2
115                          (eq_attr "type" "load,fload")
116                          "nothing")
117
118 (define_insn_reservation "xtensa_sreg" 2
119                          (eq_attr "type" "rsr")
120                          "nothing")
121
122 (define_insn_reservation "xtensa_mul16" 2
123                          (eq_attr "type" "mul16")
124                          "nothing")
125
126 (define_insn_reservation "xtensa_mul32" 2
127                          (eq_attr "type" "mul32")
128                          "nothing")
129
130 (define_insn_reservation "xtensa_fmadd" 4
131                          (eq_attr "type" "fmadd")
132                          "nothing")
133
134 (define_insn_reservation "xtensa_fconv" 2
135                          (eq_attr "type" "fconv")
136                          "nothing")
137 \f
138 ;; Include predicates and constraints.
139
140 (include "predicates.md")
141 (include "constraints.md")
142
143 \f
144 ;; Addition.
145
146 (define_insn "addsi3"
147   [(set (match_operand:SI 0 "register_operand" "=D,D,a,a,a")
148         (plus:SI (match_operand:SI 1 "register_operand" "%d,d,r,r,r")
149                  (match_operand:SI 2 "add_operand" "d,O,r,J,N")))]
150   ""
151   "@
152    add.n\t%0, %1, %2
153    addi.n\t%0, %1, %d2
154    add\t%0, %1, %2
155    addi\t%0, %1, %d2
156    addmi\t%0, %1, %x2"
157   [(set_attr "type"     "arith,arith,arith,arith,arith")
158    (set_attr "mode"     "SI")
159    (set_attr "length"   "2,2,3,3,3")])
160
161 (define_insn "*addx"
162   [(set (match_operand:SI 0 "register_operand" "=a")
163         (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
164                           (match_operand:SI 3 "addsubx_operand" "i"))
165                  (match_operand:SI 2 "register_operand" "r")))]
166   "TARGET_ADDX"
167   "addx%3\t%0, %1, %2"
168   [(set_attr "type"     "arith")
169    (set_attr "mode"     "SI")
170    (set_attr "length"   "3")])
171
172 (define_insn "addsf3"
173   [(set (match_operand:SF 0 "register_operand" "=f")
174         (plus:SF (match_operand:SF 1 "register_operand" "%f")
175                  (match_operand:SF 2 "register_operand" "f")))]
176   "TARGET_HARD_FLOAT"
177   "add.s\t%0, %1, %2"
178   [(set_attr "type"     "fmadd")
179    (set_attr "mode"     "SF")
180    (set_attr "length"   "3")])
181
182 \f
183 ;; Subtraction.
184
185 (define_insn "subsi3"
186   [(set (match_operand:SI 0 "register_operand" "=a")
187         (minus:SI (match_operand:SI 1 "register_operand" "r")
188                   (match_operand:SI 2 "register_operand" "r")))]
189   ""
190   "sub\t%0, %1, %2"
191   [(set_attr "type"     "arith")
192    (set_attr "mode"     "SI")
193    (set_attr "length"   "3")])
194
195 (define_insn "*subx"
196   [(set (match_operand:SI 0 "register_operand" "=a")
197         (minus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
198                            (match_operand:SI 3 "addsubx_operand" "i"))
199                   (match_operand:SI 2 "register_operand" "r")))]
200   "TARGET_ADDX"
201   "subx%3\t%0, %1, %2"
202   [(set_attr "type"     "arith")
203    (set_attr "mode"     "SI")
204    (set_attr "length"   "3")])
205
206 (define_insn "subsf3"
207   [(set (match_operand:SF 0 "register_operand" "=f")
208         (minus:SF (match_operand:SF 1 "register_operand" "f")
209                   (match_operand:SF 2 "register_operand" "f")))]
210   "TARGET_HARD_FLOAT"
211   "sub.s\t%0, %1, %2"
212   [(set_attr "type"     "fmadd")
213    (set_attr "mode"     "SF")
214    (set_attr "length"   "3")])
215
216 \f
217 ;; Multiplication.
218
219 (define_expand "<u>mulsidi3"
220   [(set (match_operand:DI 0 "register_operand")
221         (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand"))
222                  (any_extend:DI (match_operand:SI 2 "register_operand"))))]
223   "TARGET_MUL32_HIGH"
224 {
225   emit_insn (gen_mulsi3 (gen_lowpart (SImode, operands[0]),
226                          operands[1], operands[2]));
227   emit_insn (gen_<u>mulsi3_highpart (gen_highpart (SImode, operands[0]),
228                                      operands[1], operands[2]));
229   DONE;
230 })
231
232 (define_insn "<u>mulsi3_highpart"
233   [(set (match_operand:SI 0 "register_operand" "=a")
234         (truncate:SI
235          (lshiftrt:DI
236           (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "%r"))
237                    (any_extend:DI (match_operand:SI 2 "register_operand" "r")))
238           (const_int 32))))]
239   "TARGET_MUL32_HIGH"
240   "mul<su>h\t%0, %1, %2"
241   [(set_attr "type"     "mul32")
242    (set_attr "mode"     "SI")
243    (set_attr "length"   "3")])
244
245 (define_insn "mulsi3"
246   [(set (match_operand:SI 0 "register_operand" "=a")
247         (mult:SI (match_operand:SI 1 "register_operand" "%r")
248                  (match_operand:SI 2 "register_operand" "r")))]
249   "TARGET_MUL32"
250   "mull\t%0, %1, %2"
251   [(set_attr "type"     "mul32")
252    (set_attr "mode"     "SI")
253    (set_attr "length"   "3")])
254
255 (define_insn "mulhisi3"
256   [(set (match_operand:SI 0 "register_operand" "=C,A")
257         (mult:SI (sign_extend:SI
258                   (match_operand:HI 1 "register_operand" "%r,r"))
259                  (sign_extend:SI
260                   (match_operand:HI 2 "register_operand" "r,r"))))]
261   "TARGET_MUL16 || TARGET_MAC16"
262   "@
263    mul16s\t%0, %1, %2
264    mul.aa.ll\t%1, %2"
265   [(set_attr "type"     "mul16,mac16")
266    (set_attr "mode"     "SI")
267    (set_attr "length"   "3,3")])
268
269 (define_insn "umulhisi3"
270   [(set (match_operand:SI 0 "register_operand" "=C,A")
271         (mult:SI (zero_extend:SI
272                   (match_operand:HI 1 "register_operand" "%r,r"))
273                  (zero_extend:SI
274                   (match_operand:HI 2 "register_operand" "r,r"))))]
275   "TARGET_MUL16 || TARGET_MAC16"
276   "@
277    mul16u\t%0, %1, %2
278    umul.aa.ll\t%1, %2"
279   [(set_attr "type"     "mul16,mac16")
280    (set_attr "mode"     "SI")
281    (set_attr "length"   "3,3")])
282
283 (define_insn "muladdhisi"
284   [(set (match_operand:SI 0 "register_operand" "=A")
285         (plus:SI (mult:SI (sign_extend:SI
286                            (match_operand:HI 1 "register_operand" "%r"))
287                           (sign_extend:SI
288                            (match_operand:HI 2 "register_operand" "r")))
289                  (match_operand:SI 3 "register_operand" "0")))]
290   "TARGET_MAC16"
291   "mula.aa.ll\t%1, %2"
292   [(set_attr "type"     "mac16")
293    (set_attr "mode"     "SI")
294    (set_attr "length"   "3")])
295
296 (define_insn "mulsubhisi"
297   [(set (match_operand:SI 0 "register_operand" "=A")
298         (minus:SI (match_operand:SI 1 "register_operand" "0")
299                   (mult:SI (sign_extend:SI
300                             (match_operand:HI 2 "register_operand" "%r"))
301                            (sign_extend:SI
302                             (match_operand:HI 3 "register_operand" "r")))))]
303   "TARGET_MAC16"
304   "muls.aa.ll\t%2, %3"
305   [(set_attr "type"     "mac16")
306    (set_attr "mode"     "SI")
307    (set_attr "length"   "3")])
308
309 (define_insn "mulsf3"
310   [(set (match_operand:SF 0 "register_operand" "=f")
311         (mult:SF (match_operand:SF 1 "register_operand" "%f")
312                  (match_operand:SF 2 "register_operand" "f")))]
313   "TARGET_HARD_FLOAT"
314   "mul.s\t%0, %1, %2"
315   [(set_attr "type"     "fmadd")
316    (set_attr "mode"     "SF")
317    (set_attr "length"   "3")])
318
319 (define_insn "muladdsf3"
320   [(set (match_operand:SF 0 "register_operand" "=f")
321         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f")
322                           (match_operand:SF 2 "register_operand" "f"))
323                  (match_operand:SF 3 "register_operand" "0")))]
324   "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
325   "madd.s\t%0, %1, %2"
326   [(set_attr "type"     "fmadd")
327    (set_attr "mode"     "SF")
328    (set_attr "length"   "3")])
329
330 (define_insn "mulsubsf3"
331   [(set (match_operand:SF 0 "register_operand" "=f")
332         (minus:SF (match_operand:SF 1 "register_operand" "0")
333                   (mult:SF (match_operand:SF 2 "register_operand" "%f")
334                            (match_operand:SF 3 "register_operand" "f"))))]
335   "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
336   "msub.s\t%0, %2, %3"
337   [(set_attr "type"     "fmadd")
338    (set_attr "mode"     "SF")
339    (set_attr "length"   "3")])
340
341 \f
342 ;; Division.
343
344 (define_insn "divsi3"
345   [(set (match_operand:SI 0 "register_operand" "=a")
346         (div:SI (match_operand:SI 1 "register_operand" "r")
347                 (match_operand:SI 2 "register_operand" "r")))]
348   "TARGET_DIV32"
349   "quos\t%0, %1, %2"
350   [(set_attr "type"     "div32")
351    (set_attr "mode"     "SI")
352    (set_attr "length"   "3")])
353
354 (define_insn "udivsi3"
355   [(set (match_operand:SI 0 "register_operand" "=a")
356         (udiv:SI (match_operand:SI 1 "register_operand" "r")
357                  (match_operand:SI 2 "register_operand" "r")))]
358   "TARGET_DIV32"
359   "quou\t%0, %1, %2"
360   [(set_attr "type"     "div32")
361    (set_attr "mode"     "SI")
362    (set_attr "length"   "3")])
363
364 (define_insn "divsf3"
365   [(set (match_operand:SF 0 "register_operand" "=f")
366         (div:SF (match_operand:SF 1 "register_operand" "f")
367                 (match_operand:SF 2 "register_operand" "f")))]
368   "TARGET_HARD_FLOAT_DIV"
369   "div.s\t%0, %1, %2"
370   [(set_attr "type"     "fdiv")
371    (set_attr "mode"     "SF")
372    (set_attr "length"   "3")])
373
374 (define_insn "*recipsf2"
375   [(set (match_operand:SF 0 "register_operand" "=f")
376         (div:SF (match_operand:SF 1 "const_float_1_operand" "")
377                 (match_operand:SF 2 "register_operand" "f")))]
378   "TARGET_HARD_FLOAT_RECIP && flag_unsafe_math_optimizations"
379   "recip.s\t%0, %2"
380   [(set_attr "type"     "fdiv")
381    (set_attr "mode"     "SF")
382    (set_attr "length"   "3")])
383
384 \f
385 ;; Remainders.
386
387 (define_insn "modsi3"
388   [(set (match_operand:SI 0 "register_operand" "=a")
389         (mod:SI (match_operand:SI 1 "register_operand" "r")
390                 (match_operand:SI 2 "register_operand" "r")))]
391   "TARGET_DIV32"
392   "rems\t%0, %1, %2"
393   [(set_attr "type"     "div32")
394    (set_attr "mode"     "SI")
395    (set_attr "length"   "3")])
396
397 (define_insn "umodsi3"
398   [(set (match_operand:SI 0 "register_operand" "=a")
399         (umod:SI (match_operand:SI 1 "register_operand" "r")
400                  (match_operand:SI 2 "register_operand" "r")))]
401   "TARGET_DIV32"
402   "remu\t%0, %1, %2"
403   [(set_attr "type"     "div32")
404    (set_attr "mode"     "SI")
405    (set_attr "length"   "3")])
406
407 \f
408 ;; Square roots.
409
410 (define_insn "sqrtsf2"
411   [(set (match_operand:SF 0 "register_operand" "=f")
412         (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
413   "TARGET_HARD_FLOAT_SQRT"
414   "sqrt.s\t%0, %1"
415   [(set_attr "type"     "fsqrt")
416    (set_attr "mode"     "SF")
417    (set_attr "length"   "3")])
418
419 (define_insn "*rsqrtsf2"
420   [(set (match_operand:SF 0 "register_operand" "=f")
421         (div:SF (match_operand:SF 1 "const_float_1_operand" "")
422                 (sqrt:SF (match_operand:SF 2 "register_operand" "f"))))]
423   "TARGET_HARD_FLOAT_RSQRT && flag_unsafe_math_optimizations"
424   "rsqrt.s\t%0, %2"
425   [(set_attr "type"     "fsqrt")
426    (set_attr "mode"     "SF")
427    (set_attr "length"   "3")])
428
429 \f
430 ;; Absolute value.
431
432 (define_insn "abssi2"
433   [(set (match_operand:SI 0 "register_operand" "=a")
434         (abs:SI (match_operand:SI 1 "register_operand" "r")))]
435   "TARGET_ABS"
436   "abs\t%0, %1"
437   [(set_attr "type"     "arith")
438    (set_attr "mode"     "SI")
439    (set_attr "length"   "3")])
440
441 (define_insn "abssf2"
442   [(set (match_operand:SF 0 "register_operand" "=f")
443         (abs:SF (match_operand:SF 1 "register_operand" "f")))]
444   "TARGET_HARD_FLOAT"
445   "abs.s\t%0, %1"
446   [(set_attr "type"     "farith")
447    (set_attr "mode"     "SF")
448    (set_attr "length"   "3")])
449
450 \f
451 ;; Min and max.
452
453 (define_insn "<code>si3"
454   [(set (match_operand:SI 0 "register_operand" "=a")
455         (any_minmax:SI (match_operand:SI 1 "register_operand" "%r")
456                        (match_operand:SI 2 "register_operand" "r")))]
457   "TARGET_MINMAX"
458   "<minmax>\t%0, %1, %2"
459   [(set_attr "type"     "arith")
460    (set_attr "mode"     "SI")
461    (set_attr "length"   "3")])
462
463 \f
464 ;; Count leading/trailing zeros and find first bit.
465
466 (define_insn "clzsi2"
467   [(set (match_operand:SI 0 "register_operand" "=a")
468         (clz:SI (match_operand:SI 1 "register_operand" "r")))]
469   "TARGET_NSA"
470   "nsau\t%0, %1"
471   [(set_attr "type"     "arith")
472    (set_attr "mode"     "SI")
473    (set_attr "length"   "3")])
474
475 (define_expand "ctzsi2"
476   [(set (match_operand:SI 0 "register_operand" "")
477         (ctz:SI (match_operand:SI 1 "register_operand" "")))]
478   "TARGET_NSA"
479 {
480   rtx temp = gen_reg_rtx (SImode);
481   emit_insn (gen_negsi2 (temp, operands[1]));
482   emit_insn (gen_andsi3 (temp, temp, operands[1]));
483   emit_insn (gen_clzsi2 (temp, temp));
484   emit_insn (gen_negsi2 (temp, temp));
485   emit_insn (gen_addsi3 (operands[0], temp, GEN_INT (31)));
486   DONE;
487 })
488
489 (define_expand "ffssi2"
490   [(set (match_operand:SI 0 "register_operand" "")
491         (ffs:SI (match_operand:SI 1 "register_operand" "")))]
492   "TARGET_NSA"
493 {
494   rtx temp = gen_reg_rtx (SImode);
495   emit_insn (gen_negsi2 (temp, operands[1]));
496   emit_insn (gen_andsi3 (temp, temp, operands[1]));
497   emit_insn (gen_clzsi2 (temp, temp));
498   emit_insn (gen_negsi2 (temp, temp));
499   emit_insn (gen_addsi3 (operands[0], temp, GEN_INT (32)));
500   DONE;
501 })
502
503 \f
504 ;; Negation and one's complement.
505
506 (define_insn "negsi2"
507   [(set (match_operand:SI 0 "register_operand" "=a")
508         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
509   ""
510   "neg\t%0, %1"
511   [(set_attr "type"     "arith")
512    (set_attr "mode"     "SI")
513    (set_attr "length"   "3")])
514
515 (define_expand "one_cmplsi2"
516   [(set (match_operand:SI 0 "register_operand" "")
517         (not:SI (match_operand:SI 1 "register_operand" "")))]
518   ""
519 {
520   rtx temp = gen_reg_rtx (SImode);
521   emit_insn (gen_movsi (temp, constm1_rtx));
522   emit_insn (gen_xorsi3 (operands[0], temp, operands[1]));
523   DONE;
524 })
525
526 (define_insn "negsf2"
527   [(set (match_operand:SF 0 "register_operand" "=f")
528         (neg:SF (match_operand:SF 1 "register_operand" "f")))]
529   "TARGET_HARD_FLOAT"
530   "neg.s\t%0, %1"
531   [(set_attr "type"     "farith")
532    (set_attr "mode"     "SF")
533    (set_attr "length"   "3")])
534
535 \f
536 ;; Logical instructions.
537
538 (define_insn "andsi3"
539   [(set (match_operand:SI 0 "register_operand" "=a,a")
540         (and:SI (match_operand:SI 1 "register_operand" "%r,r")
541                 (match_operand:SI 2 "mask_operand" "P,r")))]
542   ""
543   "@
544    extui\t%0, %1, 0, %K2
545    and\t%0, %1, %2"
546   [(set_attr "type"     "arith,arith")
547    (set_attr "mode"     "SI")
548    (set_attr "length"   "3,3")])
549
550 (define_insn "iorsi3"
551   [(set (match_operand:SI 0 "register_operand" "=a")
552         (ior:SI (match_operand:SI 1 "register_operand" "%r")
553                 (match_operand:SI 2 "register_operand" "r")))]
554   ""
555   "or\t%0, %1, %2"
556   [(set_attr "type"     "arith")
557    (set_attr "mode"     "SI")
558    (set_attr "length"   "3")])
559
560 (define_insn "xorsi3"
561   [(set (match_operand:SI 0 "register_operand" "=a")
562         (xor:SI (match_operand:SI 1 "register_operand" "%r")
563                 (match_operand:SI 2 "register_operand" "r")))]
564   ""
565   "xor\t%0, %1, %2"
566   [(set_attr "type"     "arith")
567    (set_attr "mode"     "SI")
568    (set_attr "length"   "3")])
569
570 \f
571 ;; Zero-extend instructions.
572
573 (define_insn "zero_extendhisi2"
574   [(set (match_operand:SI 0 "register_operand" "=a,a")
575         (zero_extend:SI (match_operand:HI 1 "nonimmed_operand" "r,U")))]
576   ""
577   "@
578    extui\t%0, %1, 0, 16
579    l16ui\t%0, %1"
580   [(set_attr "type"     "arith,load")
581    (set_attr "mode"     "SI")
582    (set_attr "length"   "3,3")])
583
584 (define_insn "zero_extendqisi2"
585   [(set (match_operand:SI 0 "register_operand" "=a,a")
586         (zero_extend:SI (match_operand:QI 1 "nonimmed_operand" "r,U")))]
587   ""
588   "@
589    extui\t%0, %1, 0, 8
590    l8ui\t%0, %1"
591   [(set_attr "type"     "arith,load")
592    (set_attr "mode"     "SI")
593    (set_attr "length"   "3,3")])
594
595 \f
596 ;; Sign-extend instructions.
597
598 (define_expand "extendhisi2"
599   [(set (match_operand:SI 0 "register_operand" "")
600         (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
601   ""
602 {
603   if (sext_operand (operands[1], HImode))
604     emit_insn (gen_extendhisi2_internal (operands[0], operands[1]));
605   else
606     xtensa_extend_reg (operands[0], operands[1]);
607   DONE;
608 })
609
610 (define_insn "extendhisi2_internal"
611   [(set (match_operand:SI 0 "register_operand" "=B,a")
612         (sign_extend:SI (match_operand:HI 1 "sext_operand" "r,U")))]
613   ""
614   "@
615    sext\t%0, %1, 15
616    l16si\t%0, %1"
617   [(set_attr "type"     "arith,load")
618    (set_attr "mode"     "SI")
619    (set_attr "length"   "3,3")])
620
621 (define_expand "extendqisi2"
622   [(set (match_operand:SI 0 "register_operand" "")
623         (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
624   ""
625 {
626   if (TARGET_SEXT)
627     emit_insn (gen_extendqisi2_internal (operands[0], operands[1]));
628   else
629     xtensa_extend_reg (operands[0], operands[1]);
630   DONE;
631 })
632
633 (define_insn "extendqisi2_internal"
634   [(set (match_operand:SI 0 "register_operand" "=B")
635         (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
636   "TARGET_SEXT"
637   "sext\t%0, %1, 7"
638   [(set_attr "type"     "arith")
639    (set_attr "mode"     "SI")
640    (set_attr "length"   "3")])
641
642 \f
643 ;; Field extract instructions.
644
645 (define_expand "extv"
646   [(set (match_operand:SI 0 "register_operand" "")
647         (sign_extract:SI (match_operand:SI 1 "register_operand" "")
648                          (match_operand:SI 2 "const_int_operand" "")
649                          (match_operand:SI 3 "const_int_operand" "")))]
650   "TARGET_SEXT"
651 {
652   if (!sext_fldsz_operand (operands[2], SImode))
653     FAIL;
654
655   /* We could expand to a right shift followed by SEXT but that's
656      no better than the standard left and right shift sequence.  */
657   if (!lsbitnum_operand (operands[3], SImode))
658     FAIL;
659
660   emit_insn (gen_extv_internal (operands[0], operands[1],
661                                 operands[2], operands[3]));
662   DONE;
663 })
664
665 (define_insn "extv_internal"
666   [(set (match_operand:SI 0 "register_operand" "=a")
667         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
668                          (match_operand:SI 2 "sext_fldsz_operand" "i")
669                          (match_operand:SI 3 "lsbitnum_operand" "i")))]
670   "TARGET_SEXT"
671 {
672   int fldsz = INTVAL (operands[2]);
673   operands[2] = GEN_INT (fldsz - 1);
674   return "sext\t%0, %1, %2";
675 }
676   [(set_attr "type"     "arith")
677    (set_attr "mode"     "SI")
678    (set_attr "length"   "3")])
679
680 (define_expand "extzv"
681   [(set (match_operand:SI 0 "register_operand" "")
682         (zero_extract:SI (match_operand:SI 1 "register_operand" "")
683                          (match_operand:SI 2 "const_int_operand" "")
684                          (match_operand:SI 3 "const_int_operand" "")))]
685   ""
686 {
687   if (!extui_fldsz_operand (operands[2], SImode))
688     FAIL;
689   emit_insn (gen_extzv_internal (operands[0], operands[1],
690                                  operands[2], operands[3]));
691   DONE;
692 })
693
694 (define_insn "extzv_internal"
695   [(set (match_operand:SI 0 "register_operand" "=a")
696         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
697                          (match_operand:SI 2 "extui_fldsz_operand" "i")
698                          (match_operand:SI 3 "const_int_operand" "i")))]
699   ""
700 {
701   int shift;
702   if (BITS_BIG_ENDIAN)
703     shift = (32 - (INTVAL (operands[2]) + INTVAL (operands[3]))) & 0x1f;
704   else
705     shift = INTVAL (operands[3]) & 0x1f;
706   operands[3] = GEN_INT (shift);
707   return "extui\t%0, %1, %3, %2";
708 }
709   [(set_attr "type"     "arith")
710    (set_attr "mode"     "SI")
711    (set_attr "length"   "3")])
712
713 \f
714 ;; Conversions.
715
716 (define_insn "fix_truncsfsi2"
717   [(set (match_operand:SI 0 "register_operand" "=a")
718         (fix:SI (match_operand:SF 1 "register_operand" "f")))]
719   "TARGET_HARD_FLOAT"
720   "trunc.s\t%0, %1, 0"
721   [(set_attr "type"     "fconv")
722    (set_attr "mode"     "SF")
723    (set_attr "length"   "3")])
724
725 (define_insn "fixuns_truncsfsi2"
726   [(set (match_operand:SI 0 "register_operand" "=a")
727         (unsigned_fix:SI (match_operand:SF 1 "register_operand" "f")))]
728   "TARGET_HARD_FLOAT"
729   "utrunc.s\t%0, %1, 0"
730   [(set_attr "type"     "fconv")
731    (set_attr "mode"     "SF")
732    (set_attr "length"   "3")])
733
734 (define_insn "floatsisf2"
735   [(set (match_operand:SF 0 "register_operand" "=f")
736         (float:SF (match_operand:SI 1 "register_operand" "a")))]
737   "TARGET_HARD_FLOAT"
738   "float.s\t%0, %1, 0"
739   [(set_attr "type"     "fconv")
740    (set_attr "mode"     "SF")
741    (set_attr "length"   "3")])
742
743 (define_insn "floatunssisf2"
744   [(set (match_operand:SF 0 "register_operand" "=f")
745         (unsigned_float:SF (match_operand:SI 1 "register_operand" "a")))]
746   "TARGET_HARD_FLOAT"
747   "ufloat.s\t%0, %1, 0"
748   [(set_attr "type"     "fconv")
749    (set_attr "mode"     "SF")
750    (set_attr "length"   "3")])
751
752 \f
753 ;; Data movement instructions.
754
755 ;; 64-bit Integer moves
756
757 (define_expand "movdi"
758   [(set (match_operand:DI 0 "nonimmed_operand" "")
759         (match_operand:DI 1 "general_operand" ""))]
760   ""
761 {
762   if (CONSTANT_P (operands[1]) && !TARGET_CONST16)
763     operands[1] = force_const_mem (DImode, operands[1]);
764
765   if (!register_operand (operands[0], DImode)
766       && !register_operand (operands[1], DImode))
767     operands[1] = force_reg (DImode, operands[1]);
768
769   operands[1] = xtensa_copy_incoming_a7 (operands[1]);
770 })
771
772 (define_insn_and_split "movdi_internal"
773   [(set (match_operand:DI 0 "nonimmed_operand" "=a,W,a,a,U")
774         (match_operand:DI 1 "move_operand" "r,i,T,U,r"))]
775   "register_operand (operands[0], DImode)
776    || register_operand (operands[1], DImode)"
777   "#"
778   "reload_completed"
779   [(set (match_dup 0) (match_dup 2))
780    (set (match_dup 1) (match_dup 3))]
781 {
782   xtensa_split_operand_pair (operands, SImode);
783   if (reg_overlap_mentioned_p (operands[0], operands[3]))
784     {
785       rtx tmp;
786       tmp = operands[0], operands[0] = operands[1], operands[1] = tmp;
787       tmp = operands[2], operands[2] = operands[3], operands[3] = tmp;
788     }
789 })
790
791 ;; 32-bit Integer moves
792
793 (define_expand "movsi"
794   [(set (match_operand:SI 0 "nonimmed_operand" "")
795         (match_operand:SI 1 "general_operand" ""))]
796   ""
797 {
798   if (xtensa_emit_move_sequence (operands, SImode))
799     DONE;
800 })
801
802 (define_insn "movsi_internal"
803   [(set (match_operand:SI 0 "nonimmed_operand" "=D,D,D,D,R,R,a,q,a,W,a,a,U,*a,*A")
804         (match_operand:SI 1 "move_operand" "M,D,d,R,D,d,r,r,I,i,T,U,r,*A,*r"))]
805   "xtensa_valid_move (SImode, operands)"
806   "@
807    movi.n\t%0, %x1
808    mov.n\t%0, %1
809    mov.n\t%0, %1
810    %v1l32i.n\t%0, %1
811    %v0s32i.n\t%1, %0
812    %v0s32i.n\t%1, %0
813    mov\t%0, %1
814    movsp\t%0, %1
815    movi\t%0, %x1
816    const16\t%0, %t1\;const16\t%0, %b1
817    %v1l32r\t%0, %1
818    %v1l32i\t%0, %1
819    %v0s32i\t%1, %0
820    rsr\t%0, ACCLO
821    wsr\t%1, ACCLO"
822   [(set_attr "type" "move,move,move,load,store,store,move,move,move,move,load,load,store,rsr,wsr")
823    (set_attr "mode"     "SI")
824    (set_attr "length"   "2,2,2,2,2,2,3,3,3,6,3,3,3,3,3")])
825
826 ;; 16-bit Integer moves
827
828 (define_expand "movhi"
829   [(set (match_operand:HI 0 "nonimmed_operand" "")
830         (match_operand:HI 1 "general_operand" ""))]
831   ""
832 {
833   if (xtensa_emit_move_sequence (operands, HImode))
834     DONE;
835 })
836
837 (define_insn "movhi_internal"
838   [(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,U,*a,*A")
839         (match_operand:HI 1 "move_operand" "M,d,r,I,U,r,*A,*r"))]
840   "xtensa_valid_move (HImode, operands)"
841   "@
842    movi.n\t%0, %x1
843    mov.n\t%0, %1
844    mov\t%0, %1
845    movi\t%0, %x1
846    %v1l16ui\t%0, %1
847    %v0s16i\t%1, %0
848    rsr\t%0, ACCLO
849    wsr\t%1, ACCLO"
850   [(set_attr "type"     "move,move,move,move,load,store,rsr,wsr")
851    (set_attr "mode"     "HI")
852    (set_attr "length"   "2,2,3,3,3,3,3,3")])
853
854 ;; 8-bit Integer moves
855
856 (define_expand "movqi"
857   [(set (match_operand:QI 0 "nonimmed_operand" "")
858         (match_operand:QI 1 "general_operand" ""))]
859   ""
860 {
861   if (xtensa_emit_move_sequence (operands, QImode))
862     DONE;
863 })
864
865 (define_insn "movqi_internal"
866   [(set (match_operand:QI 0 "nonimmed_operand" "=D,D,a,a,a,U,*a,*A")
867         (match_operand:QI 1 "move_operand" "M,d,r,I,U,r,*A,*r"))]
868   "xtensa_valid_move (QImode, operands)"
869   "@
870    movi.n\t%0, %x1
871    mov.n\t%0, %1
872    mov\t%0, %1
873    movi\t%0, %x1
874    %v1l8ui\t%0, %1
875    %v0s8i\t%1, %0
876    rsr\t%0, ACCLO
877    wsr\t%1, ACCLO"
878   [(set_attr "type"     "move,move,move,move,load,store,rsr,wsr")
879    (set_attr "mode"     "QI")
880    (set_attr "length"   "2,2,3,3,3,3,3,3")])
881
882 ;; 32-bit floating point moves
883
884 (define_expand "movsf"
885   [(set (match_operand:SF 0 "nonimmed_operand" "")
886         (match_operand:SF 1 "general_operand" ""))]
887   ""
888 {
889   if (!TARGET_CONST16 && CONSTANT_P (operands[1]))
890     operands[1] = force_const_mem (SFmode, operands[1]);
891
892   if ((!register_operand (operands[0], SFmode)
893        && !register_operand (operands[1], SFmode))
894       || (FP_REG_P (xt_true_regnum (operands[0]))
895           && !(reload_in_progress | reload_completed)
896           && (constantpool_mem_p (operands[1])
897               || CONSTANT_P (operands[1]))))
898     operands[1] = force_reg (SFmode, operands[1]);
899
900   operands[1] = xtensa_copy_incoming_a7 (operands[1]);
901 })
902
903 (define_insn "movsf_internal"
904   [(set (match_operand:SF 0 "nonimmed_operand" "=f,f,U,D,D,R,a,f,a,W,a,a,U")
905         (match_operand:SF 1 "move_operand" "f,U,f,d,R,d,r,r,f,iF,T,U,r"))]
906   "((register_operand (operands[0], SFmode)
907      || register_operand (operands[1], SFmode))
908     && !(FP_REG_P (xt_true_regnum (operands[0]))
909          && (constantpool_mem_p (operands[1]) || CONSTANT_P (operands[1]))))"
910   "@
911    mov.s\t%0, %1
912    %v1lsi\t%0, %1
913    %v0ssi\t%1, %0
914    mov.n\t%0, %1
915    %v1l32i.n\t%0, %1
916    %v0s32i.n\t%1, %0
917    mov\t%0, %1
918    wfr\t%0, %1
919    rfr\t%0, %1
920    const16\t%0, %t1\;const16\t%0, %b1
921    %v1l32r\t%0, %1
922    %v1l32i\t%0, %1
923    %v0s32i\t%1, %0"
924   [(set_attr "type"     "farith,fload,fstore,move,load,store,move,farith,farith,move,load,load,store")
925    (set_attr "mode"     "SF")
926    (set_attr "length"   "3,3,3,2,2,2,3,3,3,6,3,3,3")])
927
928 (define_insn "*lsiu"
929   [(set (match_operand:SF 0 "register_operand" "=f")
930         (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "+a")
931                          (match_operand:SI 2 "fpmem_offset_operand" "i"))))
932    (set (match_dup 1)
933         (plus:SI (match_dup 1) (match_dup 2)))]
934   "TARGET_HARD_FLOAT"
935 {
936   if (TARGET_SERIALIZE_VOLATILE && volatile_refs_p (PATTERN (insn)))
937     output_asm_insn ("memw", operands);
938   return "lsiu\t%0, %1, %2";
939 }
940   [(set_attr "type"     "fload")
941    (set_attr "mode"     "SF")
942    (set_attr "length"   "3")])
943
944 (define_insn "*ssiu"
945   [(set (mem:SF (plus:SI (match_operand:SI 0 "register_operand" "+a")
946                          (match_operand:SI 1 "fpmem_offset_operand" "i")))
947         (match_operand:SF 2 "register_operand" "f"))
948    (set (match_dup 0)
949         (plus:SI (match_dup 0) (match_dup 1)))]
950   "TARGET_HARD_FLOAT"
951 {
952   if (TARGET_SERIALIZE_VOLATILE && volatile_refs_p (PATTERN (insn)))
953     output_asm_insn ("memw", operands);
954   return "ssiu\t%2, %0, %1";
955 }
956   [(set_attr "type"     "fstore")
957    (set_attr "mode"     "SF")
958    (set_attr "length"   "3")])
959
960 ;; 64-bit floating point moves
961
962 (define_expand "movdf"
963   [(set (match_operand:DF 0 "nonimmed_operand" "")
964         (match_operand:DF 1 "general_operand" ""))]
965   ""
966 {
967   if (CONSTANT_P (operands[1]) && !TARGET_CONST16)
968     operands[1] = force_const_mem (DFmode, operands[1]);
969
970   if (!register_operand (operands[0], DFmode)
971       && !register_operand (operands[1], DFmode))
972     operands[1] = force_reg (DFmode, operands[1]);
973
974   operands[1] = xtensa_copy_incoming_a7 (operands[1]);
975 })
976
977 (define_insn_and_split "movdf_internal"
978   [(set (match_operand:DF 0 "nonimmed_operand" "=a,W,a,a,U")
979         (match_operand:DF 1 "move_operand" "r,iF,T,U,r"))]
980   "register_operand (operands[0], DFmode)
981    || register_operand (operands[1], DFmode)"
982   "#"
983   "reload_completed"
984   [(set (match_dup 0) (match_dup 2))
985    (set (match_dup 1) (match_dup 3))]
986 {
987   xtensa_split_operand_pair (operands, SFmode);
988   if (reg_overlap_mentioned_p (operands[0], operands[3]))
989     {
990       rtx tmp;
991       tmp = operands[0], operands[0] = operands[1], operands[1] = tmp;
992       tmp = operands[2], operands[2] = operands[3], operands[3] = tmp;
993     }
994 })
995
996 ;; Block moves
997
998 (define_expand "movmemsi"
999   [(parallel [(set (match_operand:BLK 0 "" "")
1000                    (match_operand:BLK 1 "" ""))
1001               (use (match_operand:SI 2 "arith_operand" ""))
1002               (use (match_operand:SI 3 "const_int_operand" ""))])]
1003   ""
1004 {
1005   if (!xtensa_expand_block_move (operands))
1006     FAIL;
1007   DONE;
1008 })
1009
1010 \f
1011 ;; Shift instructions.
1012
1013 (define_expand "ashlsi3"
1014   [(set (match_operand:SI 0 "register_operand" "")
1015         (ashift:SI (match_operand:SI 1 "register_operand" "")
1016                    (match_operand:SI 2 "arith_operand" "")))]
1017   ""
1018 {
1019   operands[1] = xtensa_copy_incoming_a7 (operands[1]);
1020 })
1021
1022 (define_insn "ashlsi3_internal"
1023   [(set (match_operand:SI 0 "register_operand" "=a,a")
1024         (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
1025                    (match_operand:SI 2 "arith_operand" "J,r")))]
1026   ""      
1027   "@
1028    slli\t%0, %1, %R2
1029    ssl\t%2\;sll\t%0, %1"
1030   [(set_attr "type"     "arith,arith")
1031    (set_attr "mode"     "SI")
1032    (set_attr "length"   "3,6")])
1033
1034 (define_insn "ashrsi3"
1035   [(set (match_operand:SI 0 "register_operand" "=a,a")
1036         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
1037                      (match_operand:SI 2 "arith_operand" "J,r")))]
1038   ""
1039   "@
1040    srai\t%0, %1, %R2
1041    ssr\t%2\;sra\t%0, %1"
1042   [(set_attr "type"     "arith,arith")
1043    (set_attr "mode"     "SI")
1044    (set_attr "length"   "3,6")])
1045
1046 (define_insn "lshrsi3"
1047   [(set (match_operand:SI 0 "register_operand" "=a,a")
1048         (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
1049                      (match_operand:SI 2 "arith_operand" "J,r")))]
1050   ""
1051 {
1052   if (which_alternative == 0)
1053     {
1054       if ((INTVAL (operands[2]) & 0x1f) < 16)
1055         return "srli\t%0, %1, %R2";
1056       else
1057         return "extui\t%0, %1, %R2, %L2";
1058     }
1059   return "ssr\t%2\;srl\t%0, %1";
1060 }
1061   [(set_attr "type"     "arith,arith")
1062    (set_attr "mode"     "SI")
1063    (set_attr "length"   "3,6")])
1064
1065 (define_insn "rotlsi3"
1066   [(set (match_operand:SI 0 "register_operand" "=a,a")
1067         (rotate:SI (match_operand:SI 1 "register_operand" "r,r")
1068                      (match_operand:SI 2 "arith_operand" "J,r")))]
1069   ""
1070   "@
1071    ssai\t%L2\;src\t%0, %1, %1
1072    ssl\t%2\;src\t%0, %1, %1"
1073   [(set_attr "type"     "multi,multi")
1074    (set_attr "mode"     "SI")
1075    (set_attr "length"   "6,6")])
1076
1077 (define_insn "rotrsi3"
1078   [(set (match_operand:SI 0 "register_operand" "=a,a")
1079         (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
1080                      (match_operand:SI 2 "arith_operand" "J,r")))]
1081   ""
1082   "@
1083    ssai\t%R2\;src\t%0, %1, %1
1084    ssr\t%2\;src\t%0, %1, %1"
1085   [(set_attr "type"     "multi,multi")
1086    (set_attr "mode"     "SI")
1087    (set_attr "length"   "6,6")])
1088
1089 \f
1090 ;; Comparisons.
1091
1092 ;; Handle comparisons by stashing away the operands and then using that
1093 ;; information in the subsequent conditional branch.
1094
1095 (define_expand "cmpsi"
1096   [(set (cc0)
1097         (compare:CC (match_operand:SI 0 "register_operand" "")
1098                     (match_operand:SI 1 "nonmemory_operand" "")))]
1099   ""
1100 {
1101   branch_cmp[0] = operands[0];
1102   branch_cmp[1] = operands[1];
1103   branch_type = CMP_SI;
1104   DONE;
1105 })
1106
1107 (define_expand "cmpsf"
1108   [(set (cc0)
1109         (compare:CC (match_operand:SF 0 "register_operand" "")
1110                     (match_operand:SF 1 "register_operand" "")))]
1111   "TARGET_HARD_FLOAT"
1112 {
1113   branch_cmp[0] = operands[0];
1114   branch_cmp[1] = operands[1];
1115   branch_type = CMP_SF;
1116   DONE;
1117 })
1118
1119 \f
1120 ;; Conditional branches.
1121
1122 (define_expand "b<code>"
1123   [(set (pc)
1124         (if_then_else (any_cond (cc0) (const_int 0))
1125                       (label_ref (match_operand 0 "" ""))
1126                       (pc)))]
1127   ""
1128 {
1129   xtensa_expand_conditional_branch (operands, <CODE>);
1130   DONE;
1131 })
1132
1133 ;; Branch patterns for standard integer comparisons
1134
1135 (define_insn "*btrue"
1136   [(set (pc)
1137         (if_then_else (match_operator 3 "branch_operator"
1138                        [(match_operand:SI 0 "register_operand" "r,r")
1139                         (match_operand:SI 1 "branch_operand" "K,r")])
1140                       (label_ref (match_operand 2 "" ""))
1141                       (pc)))]
1142   ""
1143 {
1144   return xtensa_emit_branch (false, which_alternative == 0, operands);
1145 }
1146   [(set_attr "type"     "jump,jump")
1147    (set_attr "mode"     "none")
1148    (set_attr "length"   "3,3")])
1149
1150 (define_insn "*bfalse"
1151   [(set (pc)
1152         (if_then_else (match_operator 3 "branch_operator"
1153                        [(match_operand:SI 0 "register_operand" "r,r")
1154                         (match_operand:SI 1 "branch_operand" "K,r")])
1155                       (pc)
1156                       (label_ref (match_operand 2 "" ""))))]
1157   ""
1158 {
1159   return xtensa_emit_branch (true, which_alternative == 0, operands);
1160 }
1161   [(set_attr "type"     "jump,jump")
1162    (set_attr "mode"     "none")
1163    (set_attr "length"   "3,3")])
1164
1165 (define_insn "*ubtrue"
1166   [(set (pc)
1167         (if_then_else (match_operator 3 "ubranch_operator"
1168                        [(match_operand:SI 0 "register_operand" "r,r")
1169                         (match_operand:SI 1 "ubranch_operand" "L,r")])
1170                       (label_ref (match_operand 2 "" ""))
1171                       (pc)))]
1172   ""
1173 {
1174   return xtensa_emit_branch (false, which_alternative == 0, operands);
1175 }
1176   [(set_attr "type"     "jump,jump")
1177    (set_attr "mode"     "none")
1178    (set_attr "length"   "3,3")])
1179
1180 (define_insn "*ubfalse"
1181   [(set (pc)
1182         (if_then_else (match_operator 3 "ubranch_operator"
1183                          [(match_operand:SI 0 "register_operand" "r,r")
1184                           (match_operand:SI 1 "ubranch_operand" "L,r")])
1185                       (pc)
1186                       (label_ref (match_operand 2 "" ""))))]
1187   ""
1188 {
1189   return xtensa_emit_branch (true, which_alternative == 0, operands);
1190 }
1191   [(set_attr "type"     "jump,jump")
1192    (set_attr "mode"     "none")
1193    (set_attr "length"   "3,3")])
1194
1195 ;; Branch patterns for bit testing
1196
1197 (define_insn "*bittrue"
1198   [(set (pc)
1199         (if_then_else (match_operator 3 "boolean_operator"
1200                         [(zero_extract:SI
1201                             (match_operand:SI 0 "register_operand" "r,r")
1202                             (const_int 1)
1203                             (match_operand:SI 1 "arith_operand" "J,r"))
1204                          (const_int 0)])
1205                       (label_ref (match_operand 2 "" ""))
1206                       (pc)))]
1207   ""
1208 {
1209   return xtensa_emit_bit_branch (false, which_alternative == 0, operands);
1210 }
1211   [(set_attr "type"     "jump")
1212    (set_attr "mode"     "none")
1213    (set_attr "length"   "3")])
1214
1215 (define_insn "*bitfalse"
1216   [(set (pc)
1217         (if_then_else (match_operator 3 "boolean_operator"
1218                         [(zero_extract:SI
1219                             (match_operand:SI 0 "register_operand" "r,r")
1220                             (const_int 1)
1221                             (match_operand:SI 1 "arith_operand" "J,r"))
1222                          (const_int 0)])
1223                       (pc)
1224                       (label_ref (match_operand 2 "" ""))))]
1225   ""
1226 {
1227   return xtensa_emit_bit_branch (true, which_alternative == 0, operands);
1228 }
1229   [(set_attr "type"     "jump")
1230    (set_attr "mode"     "none")
1231    (set_attr "length"   "3")])
1232
1233 (define_insn "*masktrue"
1234   [(set (pc)
1235         (if_then_else (match_operator 3 "boolean_operator"
1236                  [(and:SI (match_operand:SI 0 "register_operand" "r")
1237                           (match_operand:SI 1 "register_operand" "r"))
1238                   (const_int 0)])
1239                       (label_ref (match_operand 2 "" ""))
1240                       (pc)))]
1241   ""
1242 {
1243   switch (GET_CODE (operands[3]))
1244     {
1245     case EQ:            return "bnone\t%0, %1, %2";
1246     case NE:            return "bany\t%0, %1, %2";
1247     default:            gcc_unreachable ();
1248     }
1249 }
1250   [(set_attr "type"     "jump")
1251    (set_attr "mode"     "none")
1252    (set_attr "length"   "3")])
1253
1254 (define_insn "*maskfalse"
1255   [(set (pc)
1256         (if_then_else (match_operator 3 "boolean_operator"
1257                  [(and:SI (match_operand:SI 0 "register_operand" "r")
1258                           (match_operand:SI 1 "register_operand" "r"))
1259                   (const_int 0)])
1260                       (pc)
1261                       (label_ref (match_operand 2 "" ""))))]
1262   ""
1263 {
1264   switch (GET_CODE (operands[3]))
1265     {
1266     case EQ:            return "bany\t%0, %1, %2";
1267     case NE:            return "bnone\t%0, %1, %2";
1268     default:            gcc_unreachable ();
1269     }
1270 }
1271   [(set_attr "type"     "jump")
1272    (set_attr "mode"     "none")
1273    (set_attr "length"   "3")])
1274
1275
1276 ;; Define the loop insns used by bct optimization to represent the
1277 ;; start and end of a zero-overhead loop (in loop.c).  This start
1278 ;; template generates the loop insn; the end template doesn't generate
1279 ;; any instructions since loop end is handled in hardware.
1280
1281 (define_insn "zero_cost_loop_start"
1282   [(set (pc)
1283         (if_then_else (eq (match_operand:SI 0 "register_operand" "a")
1284                           (const_int 0))
1285                       (label_ref (match_operand 1 "" ""))
1286                       (pc)))
1287    (set (reg:SI 19)
1288         (plus:SI (match_dup 0) (const_int -1)))]
1289   ""
1290   "loopnez\t%0, %l1"
1291   [(set_attr "type"     "jump")
1292    (set_attr "mode"     "none")
1293    (set_attr "length"   "3")])
1294
1295 (define_insn "zero_cost_loop_end"
1296   [(set (pc)
1297         (if_then_else (ne (reg:SI 19) (const_int 0))
1298                       (label_ref (match_operand 0 "" ""))
1299                       (pc)))
1300    (set (reg:SI 19)
1301         (plus:SI (reg:SI 19) (const_int -1)))]
1302   ""
1303 {
1304     xtensa_emit_loop_end (insn, operands);
1305     return "";
1306 }
1307   [(set_attr "type"     "jump")
1308    (set_attr "mode"     "none")
1309    (set_attr "length"   "0")])
1310
1311 \f
1312 ;; Setting a register from a comparison.
1313
1314 (define_expand "s<code>"
1315   [(set (match_operand:SI 0 "register_operand" "")
1316         (any_scc:SI (match_dup 1)
1317                     (match_dup 2)))]
1318   ""
1319 {
1320   operands[1] = gen_rtx_<CODE> (SImode, branch_cmp[0], branch_cmp[1]);
1321   if (!xtensa_expand_scc (operands))
1322     FAIL;
1323   DONE;
1324 })
1325
1326 \f
1327 ;; Conditional moves.
1328
1329 (define_expand "movsicc"
1330   [(set (match_operand:SI 0 "register_operand" "")
1331         (if_then_else:SI (match_operand 1 "comparison_operator" "")
1332                          (match_operand:SI 2 "register_operand" "")
1333                          (match_operand:SI 3 "register_operand" "")))]
1334   ""
1335 {
1336   if (!xtensa_expand_conditional_move (operands, 0))
1337     FAIL;
1338   DONE;
1339 })
1340
1341 (define_expand "movsfcc"
1342   [(set (match_operand:SF 0 "register_operand" "")
1343         (if_then_else:SF (match_operand 1 "comparison_operator" "")
1344                          (match_operand:SF 2 "register_operand" "")
1345                          (match_operand:SF 3 "register_operand" "")))]
1346   ""
1347 {
1348   if (!xtensa_expand_conditional_move (operands, 1))
1349     FAIL;
1350   DONE;
1351 })
1352
1353 (define_insn "movsicc_internal0"
1354   [(set (match_operand:SI 0 "register_operand" "=a,a")
1355         (if_then_else:SI (match_operator 4 "branch_operator"
1356                            [(match_operand:SI 1 "register_operand" "r,r")
1357                             (const_int 0)])
1358                          (match_operand:SI 2 "register_operand" "r,0")
1359                          (match_operand:SI 3 "register_operand" "0,r")))]
1360   ""
1361 {
1362   return xtensa_emit_movcc (which_alternative == 1, false, false, operands);
1363 }
1364   [(set_attr "type"     "move,move")
1365    (set_attr "mode"     "SI")
1366    (set_attr "length"   "3,3")])
1367
1368 (define_insn "movsicc_internal1"
1369   [(set (match_operand:SI 0 "register_operand" "=a,a")
1370         (if_then_else:SI (match_operator 4 "boolean_operator"
1371                            [(match_operand:CC 1 "register_operand" "b,b")
1372                             (const_int 0)])
1373                          (match_operand:SI 2 "register_operand" "r,0")
1374                          (match_operand:SI 3 "register_operand" "0,r")))]
1375   "TARGET_BOOLEANS"
1376 {
1377   return xtensa_emit_movcc (which_alternative == 1, false, true, operands);
1378 }
1379   [(set_attr "type"     "move,move")
1380    (set_attr "mode"     "SI")
1381    (set_attr "length"   "3,3")])
1382
1383 (define_insn "movsfcc_internal0"
1384   [(set (match_operand:SF 0 "register_operand" "=a,a,f,f")
1385         (if_then_else:SF (match_operator 4 "branch_operator"
1386                            [(match_operand:SI 1 "register_operand" "r,r,r,r")
1387                             (const_int 0)])
1388                          (match_operand:SF 2 "register_operand" "r,0,f,0")
1389                          (match_operand:SF 3 "register_operand" "0,r,0,f")))]
1390   ""
1391 {
1392   return xtensa_emit_movcc ((which_alternative & 1) == 1,
1393                             which_alternative >= 2, false, operands);
1394 }
1395   [(set_attr "type"     "move,move,move,move")
1396    (set_attr "mode"     "SF")
1397    (set_attr "length"   "3,3,3,3")])
1398
1399 (define_insn "movsfcc_internal1"
1400   [(set (match_operand:SF 0 "register_operand" "=a,a,f,f")
1401         (if_then_else:SF (match_operator 4 "boolean_operator"
1402                            [(match_operand:CC 1 "register_operand" "b,b,b,b")
1403                             (const_int 0)])
1404                          (match_operand:SF 2 "register_operand" "r,0,f,0")
1405                          (match_operand:SF 3 "register_operand" "0,r,0,f")))]
1406   "TARGET_BOOLEANS"
1407 {
1408   return xtensa_emit_movcc ((which_alternative & 1) == 1,
1409                             which_alternative >= 2, true, operands);
1410 }
1411   [(set_attr "type"     "move,move,move,move")
1412    (set_attr "mode"     "SF")
1413    (set_attr "length"   "3,3,3,3")])
1414
1415 \f
1416 ;; Floating-point comparisons.
1417
1418 (define_insn "s<code>_sf"
1419   [(set (match_operand:CC 0 "register_operand" "=b")
1420         (any_scc_sf:CC (match_operand:SF 1 "register_operand" "f")
1421                        (match_operand:SF 2 "register_operand" "f")))]
1422   "TARGET_HARD_FLOAT"
1423   "<scc_sf>.s\t%0, %1, %2"
1424   [(set_attr "type"     "farith")
1425    (set_attr "mode"     "BL")
1426    (set_attr "length"   "3")])
1427
1428 \f
1429 ;; Unconditional branches.
1430
1431 (define_insn "jump"
1432   [(set (pc)
1433         (label_ref (match_operand 0 "" "")))]
1434   ""
1435   "j\t%l0"
1436   [(set_attr "type"     "jump")
1437    (set_attr "mode"     "none")
1438    (set_attr "length"   "3")])
1439
1440 (define_expand "indirect_jump"
1441   [(set (pc)
1442         (match_operand 0 "register_operand" ""))]
1443   ""
1444 {
1445   rtx dest = operands[0];
1446   if (GET_CODE (dest) != REG || GET_MODE (dest) != Pmode)
1447     operands[0] = copy_to_mode_reg (Pmode, dest);
1448
1449   emit_jump_insn (gen_indirect_jump_internal (dest));
1450   DONE;
1451 })
1452
1453 (define_insn "indirect_jump_internal"
1454   [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
1455   ""
1456   "jx\t%0"
1457   [(set_attr "type"     "jump")
1458    (set_attr "mode"     "none")
1459    (set_attr "length"   "3")])
1460
1461
1462 (define_expand "tablejump"
1463   [(use (match_operand:SI 0 "register_operand" ""))
1464    (use (label_ref (match_operand 1 "" "")))]
1465    ""
1466 {
1467   rtx target = operands[0];
1468   if (flag_pic)
1469     {
1470       /* For PIC, the table entry is relative to the start of the table.  */
1471       rtx label = gen_reg_rtx (SImode);
1472       target = gen_reg_rtx (SImode);
1473       emit_move_insn (label, gen_rtx_LABEL_REF (SImode, operands[1]));
1474       emit_insn (gen_addsi3 (target, operands[0], label));
1475     }
1476   emit_jump_insn (gen_tablejump_internal (target, operands[1]));
1477   DONE;
1478 })
1479
1480 (define_insn "tablejump_internal"
1481   [(set (pc)
1482         (match_operand:SI 0 "register_operand" "r"))
1483    (use (label_ref (match_operand 1 "" "")))]
1484   ""
1485   "jx\t%0"
1486   [(set_attr "type"     "jump")
1487    (set_attr "mode"     "none")
1488    (set_attr "length"   "3")])
1489
1490 \f
1491 ;; Function calls.
1492
1493 (define_expand "sym_PLT"
1494   [(const (unspec [(match_operand:SI 0 "" "")] UNSPEC_PLT))]
1495   ""
1496   "")
1497
1498 (define_expand "call"
1499   [(call (match_operand 0 "memory_operand" "")
1500          (match_operand 1 "" ""))]
1501   ""
1502 {
1503   rtx addr = XEXP (operands[0], 0);
1504   if (flag_pic && GET_CODE (addr) == SYMBOL_REF
1505       && (!SYMBOL_REF_LOCAL_P (addr) || SYMBOL_REF_EXTERNAL_P (addr)))
1506     addr = gen_sym_PLT (addr);
1507   if (!call_insn_operand (addr, VOIDmode))
1508     XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, addr);
1509 })
1510
1511 (define_insn "call_internal"
1512   [(call (mem (match_operand:SI 0 "call_insn_operand" "nir"))
1513          (match_operand 1 "" "i"))]
1514   ""
1515 {
1516   return xtensa_emit_call (0, operands);
1517 }
1518   [(set_attr "type"     "call")
1519    (set_attr "mode"     "none")
1520    (set_attr "length"   "3")])
1521
1522 (define_expand "call_value"
1523   [(set (match_operand 0 "register_operand" "")
1524         (call (match_operand 1 "memory_operand" "")
1525               (match_operand 2 "" "")))]
1526   ""
1527 {
1528   rtx addr = XEXP (operands[1], 0);
1529   if (flag_pic && GET_CODE (addr) == SYMBOL_REF
1530       && (!SYMBOL_REF_LOCAL_P (addr) || SYMBOL_REF_EXTERNAL_P (addr)))
1531     addr = gen_sym_PLT (addr);
1532   if (!call_insn_operand (addr, VOIDmode))
1533     XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, addr);
1534 })
1535
1536 (define_insn "call_value_internal"
1537    [(set (match_operand 0 "register_operand" "=a")
1538          (call (mem (match_operand:SI 1 "call_insn_operand" "nir"))
1539                (match_operand 2 "" "i")))]
1540   ""
1541 {
1542   return xtensa_emit_call (1, operands);
1543 }
1544   [(set_attr "type"     "call")
1545    (set_attr "mode"     "none")
1546    (set_attr "length"   "3")])
1547
1548 (define_insn "entry"
1549   [(set (reg:SI A1_REG)
1550         (unspec_volatile:SI [(match_operand:SI 0 "const_int_operand" "i")]
1551                             UNSPECV_ENTRY))]
1552   ""
1553   "entry\tsp, %0"
1554   [(set_attr "type"     "entry")
1555    (set_attr "mode"     "SI")
1556    (set_attr "length"   "3")])
1557
1558 (define_insn "return"
1559   [(return)
1560    (use (reg:SI A0_REG))]
1561   "reload_completed"
1562 {
1563   return (TARGET_DENSITY ? "retw.n" : "retw");
1564 }
1565   [(set_attr "type"     "jump")
1566    (set_attr "mode"     "none")
1567    (set_attr "length"   "2")])
1568
1569 \f
1570 ;; Miscellaneous instructions.
1571
1572 (define_expand "prologue"
1573   [(const_int 0)]
1574   ""
1575 {
1576   xtensa_expand_prologue ();
1577   DONE;
1578 })
1579
1580 (define_expand "epilogue"
1581   [(return)]
1582   ""
1583 {
1584   emit_jump_insn (gen_return ());
1585   DONE;
1586 })
1587
1588 (define_insn "nop"
1589   [(const_int 0)]
1590   ""
1591 {
1592   return (TARGET_DENSITY ? "nop.n" : "nop");
1593 }
1594   [(set_attr "type"     "nop")
1595    (set_attr "mode"     "none")
1596    (set_attr "length"   "3")])
1597
1598 (define_expand "nonlocal_goto"
1599   [(match_operand:SI 0 "general_operand" "")
1600    (match_operand:SI 1 "general_operand" "")
1601    (match_operand:SI 2 "general_operand" "")
1602    (match_operand:SI 3 "" "")]
1603   ""
1604 {
1605   xtensa_expand_nonlocal_goto (operands);
1606   DONE;
1607 })
1608
1609 ;; Stuff an address into the return address register along with the window
1610 ;; size in the high bits.  Because we don't have the window size of the
1611 ;; previous frame, assume the function called out with a CALL8 since that
1612 ;; is what compilers always use.  Note: __builtin_frob_return_addr has
1613 ;; already been applied to the handler, but the generic version doesn't
1614 ;; allow us to frob it quite enough, so we just frob here.
1615
1616 (define_insn_and_split "eh_return"
1617   [(set (reg:SI A0_REG)
1618         (unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")]
1619                             UNSPECV_EH_RETURN))
1620    (clobber (match_scratch:SI 1 "=r"))]
1621   ""
1622   "#"
1623   "reload_completed"
1624   [(set (match_dup 1) (ashift:SI (match_dup 0) (const_int 2)))
1625    (set (match_dup 1) (plus:SI (match_dup 1) (const_int 2)))
1626    (set (reg:SI A0_REG) (rotatert:SI (match_dup 1) (const_int 2)))]
1627   "")
1628
1629 ;; Setting up a frame pointer is tricky for Xtensa because GCC doesn't
1630 ;; know if a frame pointer is required until the reload pass, and
1631 ;; because there may be an incoming argument value in the hard frame
1632 ;; pointer register (a7).  If there is an incoming argument in that
1633 ;; register, the "set_frame_ptr" insn gets inserted immediately after
1634 ;; the insn that copies the incoming argument to a pseudo or to the
1635 ;; stack.  This serves several purposes here: (1) it keeps the
1636 ;; optimizer from copy-propagating or scheduling the use of a7 as an
1637 ;; incoming argument away from the beginning of the function; (2) we
1638 ;; can use a post-reload splitter to expand away the insn if a frame
1639 ;; pointer is not required, so that the post-reload scheduler can do
1640 ;; the right thing; and (3) it makes it easy for the prologue expander
1641 ;; to search for this insn to determine whether it should add a new insn
1642 ;; to set up the frame pointer.
1643
1644 (define_insn "set_frame_ptr"
1645   [(set (reg:SI A7_REG) (unspec_volatile:SI [(const_int 0)] UNSPECV_SET_FP))]
1646   ""
1647 {
1648   if (frame_pointer_needed)
1649     return "mov\ta7, sp";
1650   return "";
1651 }
1652   [(set_attr "type"     "move")
1653    (set_attr "mode"     "SI")
1654    (set_attr "length"   "3")])
1655
1656 ;; Post-reload splitter to remove fp assignment when it's not needed.
1657 (define_split
1658   [(set (reg:SI A7_REG) (unspec_volatile:SI [(const_int 0)] UNSPECV_SET_FP))]
1659   "reload_completed && !frame_pointer_needed"
1660   [(unspec [(const_int 0)] UNSPEC_NOP)]
1661   "")
1662
1663 ;; The preceding splitter needs something to split the insn into;
1664 ;; things start breaking if the result is just a "use" so instead we
1665 ;; generate the following insn.
1666 (define_insn "*unspec_nop"
1667   [(unspec [(const_int 0)] UNSPEC_NOP)]
1668   ""
1669   ""
1670   [(set_attr "type"     "nop")
1671    (set_attr "mode"     "none")
1672    (set_attr "length"   "0")])
1673
1674 \f
1675 ;; Instructions for the Xtensa "boolean" option.
1676
1677 (define_insn "*booltrue"
1678   [(set (pc)
1679         (if_then_else (match_operator 2 "boolean_operator"
1680                          [(match_operand:CC 0 "register_operand" "b")
1681                           (const_int 0)])
1682                       (label_ref (match_operand 1 "" ""))
1683                       (pc)))]
1684   "TARGET_BOOLEANS"
1685 {
1686   if (GET_CODE (operands[2]) == EQ)
1687     return "bf\t%0, %1";
1688   else
1689     return "bt\t%0, %1";
1690 }
1691   [(set_attr "type"     "jump")
1692    (set_attr "mode"     "none")
1693    (set_attr "length"   "3")])
1694
1695 (define_insn "*boolfalse"
1696   [(set (pc)
1697         (if_then_else (match_operator 2 "boolean_operator"
1698                          [(match_operand:CC 0 "register_operand" "b")
1699                           (const_int 0)])
1700                       (pc)
1701                       (label_ref (match_operand 1 "" ""))))]
1702   "TARGET_BOOLEANS"
1703 {
1704   if (GET_CODE (operands[2]) == EQ)
1705     return "bt\t%0, %1";
1706   else
1707     return "bf\t%0, %1";
1708 }
1709   [(set_attr "type"     "jump")
1710    (set_attr "mode"     "none")
1711    (set_attr "length"   "3")])
1712
1713 \f
1714 ;; Atomic operations
1715
1716 (define_expand "memory_barrier"
1717   [(set (mem:BLK (match_dup 0))
1718         (unspec_volatile:BLK [(mem:BLK (match_dup 0))] UNSPECV_MEMW))]
1719   ""
1720 {
1721   operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (SImode));
1722   MEM_VOLATILE_P (operands[0]) = 1;
1723 })
1724
1725 (define_insn "*memory_barrier"
1726   [(set (match_operand:BLK 0 "" "")
1727         (unspec_volatile:BLK [(match_operand:BLK 1 "" "")] UNSPECV_MEMW))]
1728   ""
1729   "memw"
1730   [(set_attr "type"     "unknown")
1731    (set_attr "mode"     "none")
1732    (set_attr "length"   "3")])
1733
1734 ;; sync_lock_release is only implemented for SImode.
1735 ;; For other modes, just use the default of a store with a memory_barrier.
1736 (define_insn "sync_lock_releasesi"
1737   [(set (match_operand:SI 0 "mem_operand" "=U")
1738         (unspec_volatile:SI
1739           [(match_operand:SI 1 "register_operand" "r")]
1740           UNSPECV_S32RI))]
1741   "TARGET_RELEASE_SYNC"
1742   "s32ri\t%1, %0"
1743   [(set_attr "type"     "store")
1744    (set_attr "mode"     "SI")
1745    (set_attr "length"   "3")])
1746
1747 (define_insn "sync_compare_and_swapsi"
1748   [(parallel
1749     [(set (match_operand:SI 0 "register_operand" "=a")
1750           (match_operand:SI 1 "mem_operand" "+U"))
1751      (set (match_dup 1)
1752           (unspec_volatile:SI
1753             [(match_dup 1)
1754              (match_operand:SI 2 "register_operand" "r")
1755              (match_operand:SI 3 "register_operand" "0")]
1756             UNSPECV_S32C1I))])]
1757   "TARGET_S32C1I"
1758   "wsr\t%2, SCOMPARE1\;s32c1i\t%3, %1"
1759   [(set_attr "type"     "multi")
1760    (set_attr "mode"     "SI")
1761    (set_attr "length"   "6")])
1762
1763 (define_expand "sync_compare_and_swap<mode>"
1764   [(parallel
1765     [(set (match_operand:HQI 0 "register_operand" "")
1766           (match_operand:HQI 1 "mem_operand" ""))
1767      (set (match_dup 1)
1768           (unspec_volatile:HQI
1769             [(match_dup 1)
1770              (match_operand:HQI 2 "register_operand" "")
1771              (match_operand:HQI 3 "register_operand" "")]
1772             UNSPECV_S32C1I))])]
1773   "TARGET_S32C1I"
1774 {
1775   xtensa_expand_compare_and_swap (operands[0], operands[1],
1776                                   operands[2], operands[3]);
1777   DONE;
1778 })
1779
1780 (define_expand "sync_lock_test_and_set<mode>"
1781   [(match_operand:HQI 0 "register_operand")
1782    (match_operand:HQI 1 "memory_operand")
1783    (match_operand:HQI 2 "register_operand")]
1784   "TARGET_S32C1I"
1785 {
1786   xtensa_expand_atomic (SET, operands[0], operands[1], operands[2], false);
1787   DONE;
1788 })
1789
1790 (define_expand "sync_<atomic><mode>"
1791   [(set (match_operand:HQI 0 "memory_operand")
1792         (ATOMIC:HQI (match_dup 0)
1793                     (match_operand:HQI 1 "register_operand")))]
1794   "TARGET_S32C1I"
1795 {
1796   xtensa_expand_atomic (<CODE>, NULL_RTX, operands[0], operands[1], false);
1797   DONE;
1798 })
1799
1800 (define_expand "sync_old_<atomic><mode>"
1801   [(set (match_operand:HQI 0 "register_operand")
1802         (match_operand:HQI 1 "memory_operand"))
1803    (set (match_dup 1)
1804         (ATOMIC:HQI (match_dup 1)
1805                     (match_operand:HQI 2 "register_operand")))]
1806   "TARGET_S32C1I"
1807 {
1808   xtensa_expand_atomic (<CODE>, operands[0], operands[1], operands[2], false);
1809   DONE;
1810 })
1811
1812 (define_expand "sync_new_<atomic><mode>"
1813   [(set (match_operand:HQI 0 "register_operand")
1814         (ATOMIC:HQI (match_operand:HQI 1 "memory_operand")
1815                     (match_operand:HQI 2 "register_operand"))) 
1816    (set (match_dup 1) (ATOMIC:HQI (match_dup 1) (match_dup 2)))]
1817   "TARGET_S32C1I"
1818 {
1819   xtensa_expand_atomic (<CODE>, operands[0], operands[1], operands[2], true);
1820   DONE;
1821 })